diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index d23682596fd3f..663ace48e9e80 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -20,3 +20,6 @@ f97fddab91fbf290ea5b691fe355d6f915220b6e cc907f80b95c6ec530c5ee1b05b044a468f07eca # format let-chains b2d2184edea578109a48ec3d8decbee5948e8f35 +# test directives migration +6e48b96692d63a79a14563f27fe5185f122434f8 +ec2cc761bc7067712ecc7734502f703fe3b024c8 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f95551d679b98..8b0a33841ad99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,9 +65,20 @@ jobs: - name: x86_64-gnu-tools os: ubuntu-20.04-16core-64gb env: {} + defaults: + run: + shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}" timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: + - if: "contains(matrix.os, 'windows')" + uses: msys2/setup-msys2@v2.22.0 + with: + msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}" + update: false + release: true + path-type: inherit + install: "make dos2unix diffutils\n" - name: disable git crlf conversion run: git config --global core.autocrlf false - name: checkout the source code @@ -461,9 +472,20 @@ jobs: RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-extended --enable-profiler" SCRIPT: python x.py dist bootstrap --include-default-paths os: windows-2019-8core-32gb + defaults: + run: + shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}" timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: + - if: "contains(matrix.os, 'windows')" + uses: msys2/setup-msys2@v2.22.0 + with: + msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}" + update: false + release: true + path-type: inherit + install: "make dos2unix diffutils\n" - name: disable git crlf conversion run: git config --global core.autocrlf false - name: checkout the source code @@ -589,9 +611,20 @@ jobs: env: CODEGEN_BACKENDS: "llvm,cranelift" os: ubuntu-20.04-16core-64gb + defaults: + run: + shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}" timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: + - if: "contains(matrix.os, 'windows')" + uses: msys2/setup-msys2@v2.22.0 + with: + msystem: "${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }}" + update: false + release: true + path-type: inherit + install: "make dos2unix diffutils\n" - name: disable git crlf conversion run: git config --global core.autocrlf false - name: checkout the source code diff --git a/Cargo.lock b/Cargo.lock index 5b19c4a721eba..e37e8614af2cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,20 +129,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "anstream" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon 2.1.0", - "colorchoice", - "utf8parse", -] - [[package]] name = "anstream" version = "0.6.11" @@ -152,7 +138,7 @@ dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", - "anstyle-wincon 3.0.2", + "anstyle-wincon", "colorchoice", "utf8parse", ] @@ -181,16 +167,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "anstyle-wincon" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" -dependencies = [ - "anstyle", - "windows-sys 0.48.0", -] - [[package]] name = "anstyle-wincon" version = "3.0.2" @@ -534,7 +510,7 @@ version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ - "anstream 0.6.11", + "anstream", "anstyle", "clap_lex", "strsim 0.11.0", @@ -572,7 +548,7 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" name = "clippy" version = "0.1.78" dependencies = [ - "anstream 0.5.0", + "anstream", "clippy_config", "clippy_lints", "clippy_utils", @@ -580,7 +556,7 @@ dependencies = [ "filetime", "futures", "if_chain", - "itertools", + "itertools 0.12.1", "parking_lot", "quote", "regex", @@ -592,7 +568,7 @@ dependencies = [ "tester", "tokio", "toml 0.7.8", - "ui_test", + "ui_test 0.22.2", "walkdir", ] @@ -613,7 +589,7 @@ dependencies = [ "aho-corasick", "clap", "indoc", - "itertools", + "itertools 0.12.1", "opener", "shell-escape", "walkdir", @@ -628,7 +604,7 @@ dependencies = [ "clippy_config", "clippy_utils", "declare_clippy_lint", - "itertools", + "itertools 0.12.1", "quine-mc_cluskey", "regex", "regex-syntax 0.8.2", @@ -650,7 +626,7 @@ version = "0.1.78" dependencies = [ "arrayvec", "clippy_config", - "itertools", + "itertools 0.12.1", "rustc-semver", ] @@ -974,7 +950,7 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69" name = "declare_clippy_lint" version = "0.1.78" dependencies = [ - "itertools", + "itertools 0.12.1", "quote", "syn 2.0.48", ] @@ -1230,7 +1206,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" dependencies = [ - "anstream 0.6.11", + "anstream", "anstyle", "env_filter", "humantime", @@ -2054,6 +2030,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -2476,7 +2461,7 @@ dependencies = [ "regex", "rustc_version", "smallvec", - "ui_test", + "ui_test 0.21.2", ] [[package]] @@ -3308,13 +3293,14 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39dcf8d82b1f79a179bdb284dc44db440a9666eefa5a6df5ef282d6db930d544" +checksum = "a26170e1d79ea32f7ccec3188dd13cfc1f18c82764a9cbc1071667c0f865a4ea" dependencies = [ "anyhow", "rustc_version", "tempfile", + "walkdir", ] [[package]] @@ -3431,18 +3417,29 @@ version = "0.0.0" dependencies = [ "bitflags 2.4.2", "memchr", + "rustc_ast_ir", "rustc_data_structures", "rustc_index", "rustc_lexer", "rustc_macros", "rustc_serialize", "rustc_span", - "rustc_type_ir", "smallvec", "thin-vec", "tracing", ] +[[package]] +name = "rustc_ast_ir" +version = "0.0.0" +dependencies = [ + "rustc_data_structures", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "smallvec", +] + [[package]] name = "rustc_ast_lowering" version = "0.0.0" @@ -3468,7 +3465,7 @@ dependencies = [ name = "rustc_ast_passes" version = "0.0.0" dependencies = [ - "itertools", + "itertools 0.11.0", "rustc_ast", "rustc_ast_pretty", "rustc_attr", @@ -3488,7 +3485,7 @@ dependencies = [ name = "rustc_ast_pretty" version = "0.0.0" dependencies = [ - "itertools", + "itertools 0.11.0", "rustc_ast", "rustc_span", "thin-vec", @@ -3528,7 +3525,7 @@ name = "rustc_borrowck" version = "0.0.0" dependencies = [ "either", - "itertools", + "itertools 0.11.0", "polonius-engine", "rustc_data_structures", "rustc_errors", @@ -3581,7 +3578,7 @@ name = "rustc_codegen_llvm" version = "0.0.0" dependencies = [ "bitflags 2.4.2", - "itertools", + "itertools 0.11.0", "libc", "measureme", "object", @@ -3617,7 +3614,7 @@ dependencies = [ "ar_archive_writer", "bitflags 2.4.2", "cc", - "itertools", + "itertools 0.11.0", "jobserver", "libc", "object", @@ -3898,7 +3895,7 @@ dependencies = [ name = "rustc_hir_analysis" version = "0.0.0" dependencies = [ - "itertools", + "itertools 0.11.0", "rustc_arena", "rustc_ast", "rustc_attr", @@ -3937,7 +3934,7 @@ dependencies = [ name = "rustc_hir_typeck" version = "0.0.0" dependencies = [ - "itertools", + "itertools 0.11.0", "rustc_ast", "rustc_attr", "rustc_data_structures", @@ -4100,6 +4097,7 @@ dependencies = [ "rustc_target", "rustc_trait_selection", "rustc_type_ir", + "smallvec", "tracing", "unicode-security", ] @@ -4194,6 +4192,7 @@ dependencies = [ "rustc_apfloat", "rustc_arena", "rustc_ast", + "rustc_ast_ir", "rustc_attr", "rustc_data_structures", "rustc_error_messages", @@ -4220,7 +4219,7 @@ name = "rustc_mir_build" version = "0.0.0" dependencies = [ "either", - "itertools", + "itertools 0.11.0", "rustc_apfloat", "rustc_arena", "rustc_ast", @@ -4267,7 +4266,7 @@ name = "rustc_mir_transform" version = "0.0.0" dependencies = [ "either", - "itertools", + "itertools 0.11.0", "rustc_arena", "rustc_ast", "rustc_attr", @@ -4347,7 +4346,7 @@ dependencies = [ name = "rustc_passes" version = "0.0.0" dependencies = [ - "itertools", + "itertools 0.11.0", "rustc_ast", "rustc_ast_pretty", "rustc_attr", @@ -4597,7 +4596,7 @@ name = "rustc_trait_selection" version = "0.0.0" dependencies = [ "bitflags 2.4.2", - "itertools", + "itertools 0.11.0", "rustc_ast", "rustc_attr", "rustc_data_structures", @@ -4636,7 +4635,7 @@ dependencies = [ name = "rustc_transmute" version = "0.0.0" dependencies = [ - "itertools", + "itertools 0.11.0", "rustc_data_structures", "rustc_hir", "rustc_infer", @@ -4651,7 +4650,7 @@ dependencies = [ name = "rustc_ty_utils" version = "0.0.0" dependencies = [ - "itertools", + "itertools 0.11.0", "rustc_data_structures", "rustc_errors", "rustc_fluent_macro", @@ -4674,6 +4673,7 @@ version = "0.0.0" dependencies = [ "bitflags 2.4.2", "derivative", + "rustc_ast_ir", "rustc_data_structures", "rustc_index", "rustc_macros", @@ -4699,7 +4699,7 @@ dependencies = [ "askama", "expect-test", "indexmap", - "itertools", + "itertools 0.11.0", "minifier", "once_cell", "regex", @@ -4781,7 +4781,7 @@ dependencies = [ "dirs", "getopts", "ignore", - "itertools", + "itertools 0.11.0", "lazy_static", "regex", "rustfmt-config_proc_macro", @@ -5043,6 +5043,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "spanned" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad48ded9f0734eca7058107cc170767b8758e41e4088fb0020e7ff7ec6b0d92d" +dependencies = [ + "bstr", + "color-eyre", +] + [[package]] name = "spdx-expression" version = "0.5.2" @@ -5794,6 +5804,34 @@ dependencies = [ "tempfile", ] +[[package]] +name = "ui_test" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1ded30ff8c9d83e8d85d7e8e8aabbaf2c282a2b0ea09ef3f1accd4906134c7" +dependencies = [ + "annotate-snippets 0.10.1", + "anyhow", + "bstr", + "cargo-platform", + "cargo_metadata 0.18.1", + "color-eyre", + "colored", + "comma", + "crossbeam-channel", + "indicatif", + "lazy_static", + "levenshtein", + "prettydiff", + "regex", + "rustc_version", + "rustfix", + "serde", + "serde_json", + "spanned", + "tempfile", +] + [[package]] name = "unic-langid" version = "0.9.4" diff --git a/INSTALL.md b/INSTALL.md index b872d317e3627..d7e0fd72044e9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -145,10 +145,9 @@ toolchain. 1. Download the latest [MSYS2 installer][msys2] and go through the installer. -2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from the MSYS2 installation - directory (e.g. `C:\msys64`), depending on whether you want 32-bit or 64-bit - Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd - -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead.) +2. Start a MINGW64 or MINGW32 shell (depending on whether you want 32-bit + or 64-bit Rust) either from your start menu, or by running `mingw64.exe` + or `mingw32.exe` from your MSYS2 installation directory (e.g. `C:\msys64`). 3. From this terminal, install the required tools: @@ -157,8 +156,7 @@ toolchain. pacman -Sy pacman-mirrors # Install build tools needed for Rust. If you're building a 32-bit compiler, - # then replace "x86_64" below with "i686". If you've already got Git, Python, - # or CMake installed and in PATH you can remove them from this list. + # then replace "x86_64" below with "i686". # Note that it is important that you do **not** use the 'python2', 'cmake', # and 'ninja' packages from the 'msys2' subsystem. # The build has historically been known to fail with these packages. @@ -175,9 +173,21 @@ toolchain. 4. Navigate to Rust's source code (or clone it), then build it: ```sh - python x.py setup user && python x.py build && python x.py install + python x.py setup dist && python x.py build && python x.py install ``` +If you want to use the native versions of Git, Python, or CMake you can remove +them from the above pacman command and install them from another source. Make +sure that they're in your Windows PATH, and edit the relevant `mingw[32|64].ini` +file in your MSYS2 installation directory by uncommenting the line +`MSYS2_PATH_TYPE=inherit` to include them in your MSYS2 PATH. + +Using Windows native Python can be helpful if you get errors when building LLVM. +You may also want to use Git for Windows, as it is often *much* faster. Turning +off real-time protection in the Windows Virus & Threat protections settings can +also help with long run times (although note that it will automatically turn +itself back on after some time). + ### MSVC MSVC builds of Rust additionally require an installation of Visual Studio 2017 diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index ec3ab828b7194..28e148bddb220 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -958,7 +958,7 @@ fn univariant< #[cfg(feature = "randomize")] { use rand::{seq::SliceRandom, SeedableRng}; - // `ReprOptions.layout_seed` is a deterministic seed we can use to randomize field + // `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field // ordering. let mut rng = rand_xoshiro::Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed); diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index c45a4a410f964..297dbf890290d 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -41,7 +41,7 @@ bitflags! { // Internal only for now. If true, don't reorder fields. const IS_LINEAR = 1 << 3; // If true, the type's layout can be randomized using - // the seed stored in `ReprOptions.layout_seed` + // the seed stored in `ReprOptions.field_shuffle_seed` const RANDOMIZE_LAYOUT = 1 << 4; // Any of these flags being set prevent field reordering optimisation. const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits() diff --git a/compiler/rustc_ast/Cargo.toml b/compiler/rustc_ast/Cargo.toml index 087f6a192b5c8..d33f9666b484c 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml @@ -8,14 +8,13 @@ edition = "2021" # tidy-alphabetical-start bitflags = "2.4.1" memchr = "=2.5.0" +rustc_ast_ir = { path = "../rustc_ast_ir" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_index = { path = "../rustc_index" } rustc_lexer = { path = "../rustc_lexer" } rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } -# For Mutability and Movability, which could be uplifted into a common crate. -rustc_type_ir = { path = "../rustc_type_ir" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } thin-vec = "0.2.12" tracing = "0.1" diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 3fdb2a2225a58..4ae18b4cf4854 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -27,6 +27,7 @@ pub use UnsafeSource::*; use crate::ptr::P; use crate::token::{self, CommentKind, Delimiter}; use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream}; +pub use rustc_ast_ir::{Movability, Mutability}; use rustc_data_structures::packed::Pu128; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stack::ensure_sufficient_stack; @@ -35,7 +36,6 @@ use rustc_macros::HashStable_Generic; use rustc_span::source_map::{respan, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; -pub use rustc_type_ir::{Movability, Mutability}; use std::fmt; use std::mem; use thin_vec::{thin_vec, ThinVec}; @@ -1296,23 +1296,10 @@ impl Expr { ExprKind::Yeet(..) => ExprPrecedence::Yeet, ExprKind::FormatArgs(..) => ExprPrecedence::FormatArgs, ExprKind::Become(..) => ExprPrecedence::Become, - ExprKind::Err => ExprPrecedence::Err, + ExprKind::Err(_) | ExprKind::Dummy => ExprPrecedence::Err, } } - pub fn take(&mut self) -> Self { - mem::replace( - self, - Expr { - id: DUMMY_NODE_ID, - kind: ExprKind::Err, - span: DUMMY_SP, - attrs: AttrVec::new(), - tokens: None, - }, - ) - } - /// To a first-order approximation, is this a pattern? pub fn is_approximately_pattern(&self) -> bool { matches!( @@ -1531,7 +1518,10 @@ pub enum ExprKind { FormatArgs(P), /// Placeholder for an expression that wasn't syntactically well formed in some way. - Err, + Err(ErrorGuaranteed), + + /// Acts as a null expression. Lowering it will always emit a bug. + Dummy, } /// Used to differentiate between `for` loops and `for await` loops. diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index c42c41999732c..60bc21c6441fc 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1526,7 +1526,7 @@ pub fn noop_visit_expr( } ExprKind::Try(expr) => vis.visit_expr(expr), ExprKind::TryBlock(body) => vis.visit_block(body), - ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err => {} + ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err(_) | ExprKind::Dummy => {} } vis.visit_id(id); vis.visit_span(span); @@ -1642,7 +1642,7 @@ impl DummyAstNode for Expr { fn dummy() -> Self { Expr { id: DUMMY_NODE_ID, - kind: ExprKind::Err, + kind: ExprKind::Dummy, span: Default::default(), attrs: Default::default(), tokens: Default::default(), diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 50fe37dcdb6fc..5ccc7d51066d9 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -107,7 +107,7 @@ impl Lit { /// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation. pub fn from_token(token: &Token) -> Option { match token.uninterpolate().kind { - Ident(name, false) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)), + Ident(name, IdentIsRaw::No) if name.is_bool_lit() => Some(Lit::new(Bool, name, None)), Literal(token_lit) => Some(token_lit), Interpolated(ref nt) if let NtExpr(expr) | NtLiteral(expr) = &nt.0 @@ -183,7 +183,7 @@ impl LitKind { } } -pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool { +pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool { let ident_token = Token::new(Ident(name, is_raw), span); !ident_token.is_reserved_ident() @@ -214,7 +214,7 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool { .contains(&name) } -fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool { +fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool { let ident_token = Token::new(Ident(name, is_raw), span); !ident_token.is_reserved_ident() @@ -223,6 +223,24 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: bool) -> bool { .contains(&name) } +#[derive(PartialEq, Encodable, Decodable, Debug, Copy, Clone, HashStable_Generic)] +pub enum IdentIsRaw { + No, + Yes, +} + +impl From for IdentIsRaw { + fn from(b: bool) -> Self { + if b { Self::Yes } else { Self::No } + } +} + +impl From for bool { + fn from(is_raw: IdentIsRaw) -> bool { + matches!(is_raw, IdentIsRaw::Yes) + } +} + // SAFETY: due to the `Clone` impl below, all fields of all variants other than // `Interpolated` must impl `Copy`. #[derive(PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] @@ -298,7 +316,7 @@ pub enum TokenKind { /// Do not forget about `NtIdent` when you want to match on identifiers. /// It's recommended to use `Token::(ident,uninterpolate,uninterpolated_span)` to /// treat regular and interpolated identifiers in the same way. - Ident(Symbol, /* is_raw */ bool), + Ident(Symbol, IdentIsRaw), /// Lifetime identifier token. /// Do not forget about `NtLifetime` when you want to match on lifetime identifiers. /// It's recommended to use `Token::(lifetime,uninterpolate,uninterpolated_span)` to @@ -411,7 +429,7 @@ impl Token { /// Recovers a `Token` from an `Ident`. This creates a raw identifier if necessary. pub fn from_ast_ident(ident: Ident) -> Self { - Token::new(Ident(ident.name, ident.is_raw_guess()), ident.span) + Token::new(Ident(ident.name, ident.is_raw_guess().into()), ident.span) } /// For interpolated tokens, returns a span of the fragment to which the interpolated @@ -567,7 +585,7 @@ impl Token { pub fn can_begin_literal_maybe_minus(&self) -> bool { match self.uninterpolate().kind { Literal(..) | BinOp(Minus) => true, - Ident(name, false) if name.is_bool_lit() => true, + Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true, Interpolated(ref nt) => match &nt.0 { NtLiteral(_) => true, NtExpr(e) => match &e.kind { @@ -602,7 +620,7 @@ impl Token { /// Returns an identifier if this token is an identifier. #[inline] - pub fn ident(&self) -> Option<(Ident, /* is_raw */ bool)> { + pub fn ident(&self) -> Option<(Ident, IdentIsRaw)> { // We avoid using `Token::uninterpolate` here because it's slow. match &self.kind { &Ident(name, is_raw) => Some((Ident::new(name, self.span), is_raw)), @@ -755,7 +773,7 @@ impl Token { /// Returns `true` if the token is a non-raw identifier for which `pred` holds. pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool { match self.ident() { - Some((id, false)) => pred(id), + Some((id, IdentIsRaw::No)) => pred(id), _ => false, } } @@ -806,7 +824,7 @@ impl Token { _ => return None, }, SingleQuote => match joint.kind { - Ident(name, false) => Lifetime(Symbol::intern(&format!("'{name}"))), + Ident(name, IdentIsRaw::No) => Lifetime(Symbol::intern(&format!("'{name}"))), _ => return None, }, @@ -836,7 +854,7 @@ pub enum Nonterminal { NtPat(P), NtExpr(P), NtTy(P), - NtIdent(Ident, /* is_raw */ bool), + NtIdent(Ident, IdentIsRaw), NtLifetime(Ident), NtLiteral(P), /// Stuff inside brackets for attributes diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 298c01a456740..adc3056cc2921 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -656,7 +656,7 @@ impl TokenStream { DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), Delimiter::Bracket, [ - TokenTree::token_alone(token::Ident(sym::doc, false), span), + TokenTree::token_alone(token::Ident(sym::doc, token::IdentIsRaw::No), span), TokenTree::token_alone(token::Eq, span), TokenTree::token_alone( TokenKind::lit(token::StrRaw(num_of_hashes), data, None), diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs index 098b8f2d6d038..f21a9cabb81be 100644 --- a/compiler/rustc_ast/src/util/classify.rs +++ b/compiler/rustc_ast/src/util/classify.rs @@ -89,7 +89,8 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> { | Paren(_) | Try(_) | Yeet(None) - | Err => break None, + | Err(_) + | Dummy => break None, } } } diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index ecf379cc2408a..f29022386a9d3 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -1063,7 +1063,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V } ExprKind::Try(subexpression) => try_visit!(visitor.visit_expr(subexpression)), ExprKind::TryBlock(body) => try_visit!(visitor.visit_block(body)), - ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err => {} + ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err(_) | ExprKind::Dummy => {} } visitor.visit_expr_post(expression) diff --git a/compiler/rustc_ast_ir/Cargo.toml b/compiler/rustc_ast_ir/Cargo.toml new file mode 100644 index 0000000000000..e761b7adad3fd --- /dev/null +++ b/compiler/rustc_ast_ir/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "rustc_ast_ir" +version = "0.0.0" +edition = "2021" + +[dependencies] +# tidy-alphabetical-start +rustc_data_structures = { path = "../rustc_data_structures", optional = true } +rustc_macros = { path = "../rustc_macros", optional = true } +rustc_serialize = { path = "../rustc_serialize", optional = true } +rustc_span = { path = "../rustc_span", optional = true } +smallvec = { version = "1.8.1" } +# tidy-alphabetical-end + +[features] +default = ["nightly"] +nightly = [ + "rustc_serialize", + "rustc_data_structures", + "rustc_macros", + "rustc_span", +] diff --git a/compiler/rustc_ast_ir/src/lib.rs b/compiler/rustc_ast_ir/src/lib.rs new file mode 100644 index 0000000000000..9fe1370921345 --- /dev/null +++ b/compiler/rustc_ast_ir/src/lib.rs @@ -0,0 +1,68 @@ +#![cfg_attr(feature = "nightly", feature(rustc_attrs))] +#![cfg_attr(feature = "nightly", allow(internal_features))] + +#[cfg(feature = "nightly")] +#[macro_use] +extern crate rustc_macros; + +/// The movability of a coroutine / closure literal: +/// whether a coroutine contains self-references, causing it to be `!Unpin`. +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] +#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))] +pub enum Movability { + /// May contain self-references, `!Unpin`. + Static, + /// Must not contain self-references, `Unpin`. + Movable, +} + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] +#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))] +pub enum Mutability { + // N.B. Order is deliberate, so that Not < Mut + Not, + Mut, +} + +impl Mutability { + pub fn invert(self) -> Self { + match self { + Mutability::Mut => Mutability::Not, + Mutability::Not => Mutability::Mut, + } + } + + /// Returns `""` (empty string) or `"mut "` depending on the mutability. + pub fn prefix_str(self) -> &'static str { + match self { + Mutability::Mut => "mut ", + Mutability::Not => "", + } + } + + /// Returns `"&"` or `"&mut "` depending on the mutability. + pub fn ref_prefix_str(self) -> &'static str { + match self { + Mutability::Not => "&", + Mutability::Mut => "&mut ", + } + } + + /// Returns `""` (empty string) or `"mutably "` depending on the mutability. + pub fn mutably_str(self) -> &'static str { + match self { + Mutability::Not => "", + Mutability::Mut => "mutably ", + } + } + + /// Return `true` if self is mutable + pub fn is_mut(self) -> bool { + matches!(self, Self::Mut) + } + + /// Return `true` if self is **not** mutable + pub fn is_not(self) -> bool { + matches!(self, Self::Not) + } +} diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index d1ba93f067553..4e1c477a3d771 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -103,12 +103,8 @@ impl<'hir> LoweringContext<'_, 'hir> { span: Span, ) -> Result { let sig_id = if self.is_in_trait_impl { item_id } else { path_id }; - let sig_id = self - .resolver - .get_partial_res(sig_id) - .map(|r| r.expect_full_res().opt_def_id()) - .unwrap_or(None); - + let sig_id = + self.resolver.get_partial_res(sig_id).and_then(|r| r.expect_full_res().opt_def_id()); sig_id.ok_or_else(|| { self.tcx .dcx() @@ -138,7 +134,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } else { self.tcx.fn_arg_names(sig_id).len() }; - let inputs = self.arena.alloc_from_iter((0..args_count).into_iter().map(|arg| hir::Ty { + let inputs = self.arena.alloc_from_iter((0..args_count).map(|arg| hir::Ty { hir_id: self.next_id(), kind: hir::TyKind::InferDelegation(sig_id, hir::InferDelegationKind::Input(arg)), span: self.lower_span(param_span), diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index 834409da6750a..eafbe3462bb54 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -1,6 +1,5 @@ use rustc_errors::{ - codes::*, AddToDiagnostic, DiagnosticArgFromDisplay, DiagnosticBuilder, EmissionGuarantee, - SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagnosticMessageOp, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{symbol::Ident, Span, Symbol}; @@ -44,7 +43,7 @@ pub struct InvalidAbiReason(pub &'static str); impl AddToDiagnostic for InvalidAbiReason { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _: F, ) { #[allow(rustc::untranslatable_diagnostic)] @@ -95,7 +94,7 @@ pub enum AssocTyParenthesesSub { pub struct MisplacedImplTrait<'a> { #[primary_span] pub span: Span, - pub position: DiagnosticArgFromDisplay<'a>, + pub position: DiagArgFromDisplay<'a>, } #[derive(Diagnostic)] diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index aafa99b3aa6fb..9950db4784b9c 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -14,6 +14,7 @@ use rustc_ast::*; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; +use rustc_middle::span_bug; use rustc_session::errors::report_lit_error; use rustc_span::source_map::{respan, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; @@ -328,9 +329,12 @@ impl<'hir> LoweringContext<'_, 'hir> { ) } ExprKind::Yield(opt_expr) => self.lower_expr_yield(e.span, opt_expr.as_deref()), - ExprKind::Err => { - hir::ExprKind::Err(self.dcx().span_delayed_bug(e.span, "lowered ExprKind::Err")) + ExprKind::Err(guar) => hir::ExprKind::Err(*guar), + + ExprKind::Dummy => { + span_bug!(e.span, "lowered ExprKind::Dummy") } + ExprKind::Try(sub_expr) => self.lower_expr_try(e.span, sub_expr), ExprKind::Paren(_) | ExprKind::ForLoop { .. } => { diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index ef843da7307d3..087d240b0d50f 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -51,7 +51,7 @@ use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::Lrc; -use rustc_errors::{DiagCtxt, DiagnosticArgFromDisplay, StashKey}; +use rustc_errors::{DiagArgFromDisplay, DiagCtxt, StashKey}; use rustc_hir as hir; use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res}; use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE}; @@ -1473,7 +1473,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { .create_feature_err( MisplacedImplTrait { span: t.span, - position: DiagnosticArgFromDisplay(&position), + position: DiagArgFromDisplay(&position), }, feature, ) @@ -1483,7 +1483,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ImplTraitContext::Disallowed(position) => { let guar = self.dcx().emit_err(MisplacedImplTrait { span: t.span, - position: DiagnosticArgFromDisplay(&position), + position: DiagArgFromDisplay(&position), }); hir::TyKind::Err(guar) } @@ -1636,7 +1636,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { if let Some(old_def_id) = self.orig_opt_local_def_id(param) { old_def_id } else { - self.dcx().span_bug(lifetime.ident.span, "no def-id for fresh lifetime"); + self.dcx() + .span_delayed_bug(lifetime.ident.span, "no def-id for fresh lifetime"); + continue; } } diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index c097feb6b3476..469cdac11e439 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -331,7 +331,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ExprKind::Lit(..) | ExprKind::ConstBlock(..) | ExprKind::IncludedBytes(..) - | ExprKind::Err => {} + | ExprKind::Err(_) + | ExprKind::Dummy => {} ExprKind::Path(..) if allow_paths => {} ExprKind::Unary(UnOp::Neg, inner) if matches!(inner.kind, ExprKind::Lit(_)) => {} _ => { diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index e5153c8979039..0f37093f0576c 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -2,8 +2,7 @@ use rustc_ast::ParamKindOrd; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DiagnosticBuilder, EmissionGuarantee, - SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Applicability, Diag, EmissionGuarantee, SubdiagnosticMessageOp, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{symbol::Ident, Span, Symbol}; @@ -377,7 +376,7 @@ pub struct EmptyLabelManySpans(pub Vec); impl AddToDiagnostic for EmptyLabelManySpans { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _: F, ) { diag.span_labels(self.0, ""); @@ -738,7 +737,7 @@ pub struct StableFeature { impl AddToDiagnostic for StableFeature { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _: F, ) { diag.arg("name", self.name); diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 7ea0078ea3bb9..6e1974f48b26b 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -185,7 +185,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool { // IDENT + `!`: `println!()`, but `if !x { ... }` needs a space after the `if` (Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Not, .. }, _)) - if !Ident::new(*sym, *span).is_reserved() || *is_raw => + if !Ident::new(*sym, *span).is_reserved() || matches!(is_raw, IdentIsRaw::Yes) => { false } @@ -197,7 +197,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool { || *sym == kw::Fn || *sym == kw::SelfUpper || *sym == kw::Pub - || *is_raw => + || matches!(is_raw, IdentIsRaw::Yes) => { false } @@ -731,7 +731,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere token::NtBlock(e) => self.block_to_string(e), token::NtStmt(e) => self.stmt_to_string(e), token::NtPat(e) => self.pat_to_string(e), - token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(*e, *is_raw).to_string(), + &token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(e, is_raw.into()).to_string(), token::NtLifetime(e) => e.to_string(), token::NtLiteral(e) => self.expr_to_string(e), token::NtVis(e) => self.vis_to_string(e), @@ -795,7 +795,7 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere /* Name components */ token::Ident(s, is_raw) => { - IdentPrinter::new(s, is_raw, convert_dollar_crate).to_string().into() + IdentPrinter::new(s, is_raw.into(), convert_dollar_crate).to_string().into() } token::Lifetime(s) => s.to_string().into(), diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index ff154a009ed05..433ef03b6e544 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -893,11 +893,16 @@ impl<'a> State<'a> { self.word_nbsp("try"); self.print_block_with_attrs(blk, attrs) } - ast::ExprKind::Err => { + ast::ExprKind::Err(_) => { self.popen(); self.word("/*ERROR*/"); self.pclose() } + ast::ExprKind::Dummy => { + self.popen(); + self.word("/*DUMMY*/"); + self.pclose(); + } } self.ann.post(self, AnnNode::Expr(expr)); diff --git a/compiler/rustc_attr/src/session_diagnostics.rs b/compiler/rustc_attr/src/session_diagnostics.rs index 79370602842b0..8cbd401d300a2 100644 --- a/compiler/rustc_attr/src/session_diagnostics.rs +++ b/compiler/rustc_attr/src/session_diagnostics.rs @@ -2,7 +2,7 @@ use std::num::IntErrorKind; use rustc_ast as ast; use rustc_errors::{ - codes::*, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level, + codes::*, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level, }; use rustc_macros::Diagnostic; use rustc_span::{Span, Symbol}; @@ -51,9 +51,9 @@ pub(crate) struct UnknownMetaItem<'a> { // Manual implementation to be able to format `expected` items correctly. impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnknownMetaItem<'_> { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::>(); - DiagnosticBuilder::new(dcx, level, fluent::attr_unknown_meta_item) + Diag::new(dcx, level, fluent::attr_unknown_meta_item) .with_span(self.span) .with_code(E0541) .with_arg("item", self.item) @@ -198,8 +198,8 @@ pub(crate) struct UnsupportedLiteral { } impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UnsupportedLiteral { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { - let mut diag = DiagnosticBuilder::new( + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { + let mut diag = Diag::new( dcx, level, match self.reason { diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs index 429bcb74a8efc..6b576ba3c4cc6 100644 --- a/compiler/rustc_borrowck/src/borrowck_errors.rs +++ b/compiler/rustc_borrowck/src/borrowck_errors.rs @@ -1,7 +1,7 @@ #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -use rustc_errors::{codes::*, struct_span_code_err, DiagCtxt, DiagnosticBuilder}; +use rustc_errors::{codes::*, struct_span_code_err, Diag, DiagCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::Span; @@ -17,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { place: &str, borrow_place: &str, value_place: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { self.dcx().create_err(crate::session_diagnostics::MoveBorrow { place, span, @@ -33,7 +33,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { desc: &str, borrow_span: Span, borrow_desc: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), span, @@ -53,7 +53,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { old_loan_span: Span, old_opt_via: &str, old_load_end_span: Option, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") }; let mut err = struct_span_code_err!( self.dcx(), @@ -100,7 +100,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { desc: &str, old_loan_span: Span, old_load_end_span: Option, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let mut err = struct_span_code_err!( self.dcx(), new_loan_span, @@ -133,7 +133,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { noun_old: &str, old_opt_via: &str, previous_end_span: Option, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let mut err = struct_span_code_err!( self.dcx(), new_loan_span, @@ -165,7 +165,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { old_opt_via: &str, previous_end_span: Option, second_borrow_desc: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let mut err = struct_span_code_err!( self.dcx(), new_loan_span, @@ -197,7 +197,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { kind_old: &str, msg_old: &str, old_load_end_span: Option, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") }; let mut err = struct_span_code_err!( self.dcx(), @@ -238,7 +238,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { span: Span, borrow_span: Span, desc: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), span, @@ -255,12 +255,12 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { span: Span, desc: &str, is_arg: bool, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" }; struct_span_code_err!(self.dcx(), span, E0384, "cannot assign {} {}", msg, desc) } - pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'tcx> { + pub(crate) fn cannot_assign(&self, span: Span, desc: &str) -> Diag<'tcx> { struct_span_code_err!(self.dcx(), span, E0594, "cannot assign to {}", desc) } @@ -268,7 +268,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { &self, move_from_span: Span, move_from_desc: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), move_from_span, @@ -286,7 +286,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { move_from_span: Span, ty: Ty<'_>, is_index: Option, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let type_name = match (&ty.kind(), is_index) { (&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array", (&ty::Slice(_), _) => "slice", @@ -307,7 +307,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { &self, move_from_span: Span, container_ty: Ty<'_>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), move_from_span, @@ -324,7 +324,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { verb: &str, optional_adverb_for_moved: &str, moved_path: Option, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let moved_path = moved_path.map(|mp| format!(": `{mp}`")).unwrap_or_default(); struct_span_code_err!( @@ -343,7 +343,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { span: Span, path: &str, reason: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), span, @@ -361,7 +361,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { immutable_place: &str, immutable_section: &str, action: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), mutate_span, @@ -379,7 +379,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { &self, span: Span, yield_span: Span, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let coroutine_kind = self.body.coroutine.as_ref().unwrap().coroutine_kind; struct_span_code_err!( self.dcx(), @@ -390,10 +390,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { .with_span_label(yield_span, "possible yield occurs here") } - pub(crate) fn cannot_borrow_across_destructor( - &self, - borrow_span: Span, - ) -> DiagnosticBuilder<'tcx> { + pub(crate) fn cannot_borrow_across_destructor(&self, borrow_span: Span) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), borrow_span, @@ -402,11 +399,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { ) } - pub(crate) fn path_does_not_live_long_enough( - &self, - span: Span, - path: &str, - ) -> DiagnosticBuilder<'tcx> { + pub(crate) fn path_does_not_live_long_enough(&self, span: Span, path: &str) -> Diag<'tcx> { struct_span_code_err!(self.dcx(), span, E0597, "{} does not live long enough", path,) } @@ -416,7 +409,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { return_kind: &str, reference_desc: &str, path_desc: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), span, @@ -439,7 +432,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { borrowed_path: &str, capture_span: Span, scope: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), closure_span, @@ -451,10 +444,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { .with_span_label(closure_span, format!("may outlive borrowed value {borrowed_path}")) } - pub(crate) fn thread_local_value_does_not_live_long_enough( - &self, - span: Span, - ) -> DiagnosticBuilder<'tcx> { + pub(crate) fn thread_local_value_does_not_live_long_enough(&self, span: Span) -> Diag<'tcx> { struct_span_code_err!( self.dcx(), span, @@ -463,10 +453,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { ) } - pub(crate) fn temporary_value_borrowed_for_too_long( - &self, - span: Span, - ) -> DiagnosticBuilder<'tcx> { + pub(crate) fn temporary_value_borrowed_for_too_long(&self, span: Span) -> Diag<'tcx> { struct_span_code_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed",) } } @@ -475,7 +462,7 @@ pub(crate) fn borrowed_data_escapes_closure<'tcx>( tcx: TyCtxt<'tcx>, escape_span: Span, escapes_from: &str, -) -> DiagnosticBuilder<'tcx> { +) -> Diag<'tcx> { struct_span_code_err!( tcx.dcx(), escape_span, diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs index a540fcee871c7..9b8b7e8ddda6b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs @@ -1,4 +1,4 @@ -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_infer::infer::canonical::Canonical; use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError; use rustc_infer::infer::region_constraints::Constraint; @@ -144,7 +144,7 @@ impl<'tcx> ToUniverseInfo<'tcx> for ! { trait TypeOpInfo<'tcx> { /// Returns an error to be reported if rerunning the type op fails to /// recover the error's cause. - fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx>; + fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx>; fn base_universe(&self) -> ty::UniverseIndex; @@ -154,7 +154,7 @@ trait TypeOpInfo<'tcx> { cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option>, - ) -> Option>; + ) -> Option>; #[instrument(level = "debug", skip(self, mbcx))] fn report_error( @@ -217,7 +217,7 @@ struct PredicateQuery<'tcx> { } impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> { - fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> { tcx.dcx().create_err(HigherRankedLifetimeError { cause: Some(HigherRankedErrorCause::CouldNotProve { predicate: self.canonical_query.value.value.predicate.to_string(), @@ -236,7 +236,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> { cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option>, - ) -> Option> { + ) -> Option> { let (infcx, key, _) = mbcx.infcx.tcx.infer_ctxt().build_with_canonical(cause.span, &self.canonical_query); let ocx = ObligationCtxt::new(&infcx); @@ -254,7 +254,7 @@ impl<'tcx, T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T> where T: Copy + fmt::Display + TypeFoldable> + 'tcx, { - fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> { tcx.dcx().create_err(HigherRankedLifetimeError { cause: Some(HigherRankedErrorCause::CouldNotNormalize { value: self.canonical_query.value.value.value.to_string(), @@ -273,7 +273,7 @@ where cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option>, - ) -> Option> { + ) -> Option> { let (infcx, key, _) = mbcx.infcx.tcx.infer_ctxt().build_with_canonical(cause.span, &self.canonical_query); let ocx = ObligationCtxt::new(&infcx); @@ -297,7 +297,7 @@ struct AscribeUserTypeQuery<'tcx> { } impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> { - fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> { // FIXME: This error message isn't great, but it doesn't show up in the existing UI tests, // and is only the fallback when the nice error fails. Consider improving this some more. tcx.dcx().create_err(HigherRankedLifetimeError { cause: None, span }) @@ -313,7 +313,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> { cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option>, - ) -> Option> { + ) -> Option> { let (infcx, key, _) = mbcx.infcx.tcx.infer_ctxt().build_with_canonical(cause.span, &self.canonical_query); let ocx = ObligationCtxt::new(&infcx); @@ -323,7 +323,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> { } impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> { - fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> { // FIXME: This error message isn't great, but it doesn't show up in the existing UI tests, // and is only the fallback when the nice error fails. Consider improving this some more. tcx.dcx().create_err(HigherRankedLifetimeError { cause: None, span }) @@ -339,7 +339,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> { _cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option>, - ) -> Option> { + ) -> Option> { try_extract_error_from_region_constraints( mbcx.infcx, placeholder_region, @@ -360,7 +360,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>( ocx: &ObligationCtxt<'_, 'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option>, -) -> Option> { +) -> Option> { // We generally shouldn't have errors here because the query was // already run, but there's no point using `span_delayed_bug` // when we're going to emit an error here anyway. @@ -384,7 +384,7 @@ fn try_extract_error_from_region_constraints<'tcx>( region_constraints: &RegionConstraintData<'tcx>, mut region_var_origin: impl FnMut(RegionVid) -> RegionVariableOrigin, mut universe_of_region: impl FnMut(RegionVid) -> UniverseIndex, -) -> Option> { +) -> Option> { let placeholder_universe = match placeholder_region.kind() { ty::RePlaceholder(p) => p.universe, ty::ReVar(vid) => universe_of_region(vid), diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index e1509da913a56..1e869ae924fb3 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -6,7 +6,7 @@ use either::Either; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan}; +use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::{walk_block, walk_expr, Visitor}; @@ -334,7 +334,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, mpi: MovePathIndex, move_span: Span, - err: &mut DiagnosticBuilder<'tcx>, + err: &mut Diag<'tcx>, in_pattern: &mut bool, move_spans: UseSpans<'_>, ) { @@ -486,7 +486,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { desired_action: InitializationRequiringAction, span: Span, use_spans: UseSpans<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { // We need all statements in the body where the binding was assigned to later find all // the branching code paths where the binding *wasn't* assigned to. let inits = &self.move_data.init_path_map[mpi]; @@ -633,7 +633,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn suggest_assign_value( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, moved_place: PlaceRef<'tcx>, sugg_span: Span, ) { @@ -672,7 +672,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn suggest_borrow_fn_like( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ty: Ty<'tcx>, move_sites: &[MoveSite], value_name: &str, @@ -738,13 +738,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { true } - fn suggest_cloning( - &self, - err: &mut DiagnosticBuilder<'_>, - ty: Ty<'tcx>, - expr: &hir::Expr<'_>, - span: Span, - ) { + fn suggest_cloning(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>, span: Span) { let tcx = self.infcx.tcx; // Try to find predicates on *generic params* that would allow copying `ty` let suggestion = @@ -776,12 +770,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - fn suggest_adding_copy_bounds( - &self, - err: &mut DiagnosticBuilder<'_>, - ty: Ty<'tcx>, - span: Span, - ) { + fn suggest_adding_copy_bounds(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, span: Span) { let tcx = self.infcx.tcx; let generics = tcx.generics_of(self.mir_def_id()); @@ -891,7 +880,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { location: Location, (place, _span): (Place<'tcx>, Span), borrow: &BorrowData<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let borrow_spans = self.retrieve_borrow_spans(borrow); let borrow_span = borrow_spans.args_or_use(); @@ -941,7 +930,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { (place, span): (Place<'tcx>, Span), gen_borrow_kind: BorrowKind, issued_borrow: &BorrowData<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let issued_spans = self.retrieve_borrow_spans(issued_borrow); let issued_span = issued_spans.args_or_use(); @@ -1228,7 +1217,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { #[instrument(level = "debug", skip(self, err))] fn suggest_using_local_if_applicable( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, location: Location, issued_borrow: &BorrowData<'tcx>, explanation: BorrowExplanation<'tcx>, @@ -1324,7 +1313,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn suggest_slice_method_if_applicable( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, place: Place<'tcx>, borrowed_place: Place<'tcx>, ) { @@ -1433,7 +1422,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// ``` pub(crate) fn explain_iterator_advancement_in_for_loop_if_applicable( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, issued_spans: &UseSpans<'tcx>, ) { @@ -1559,7 +1548,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // A bare path doesn't need a `let` assignment, it's already a simple // binding access. // As a new binding wasn't added, we don't need to modify the advancing call. - sugg.push((loop_span.with_hi(pat_span.lo()), format!("while let Some("))); + sugg.push((loop_span.with_hi(pat_span.lo()), "while let Some(".to_string())); sugg.push(( pat_span.shrink_to_hi().with_hi(head.span.lo()), ") = ".to_string(), @@ -1620,7 +1609,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// ``` fn suggest_using_closure_argument_instead_of_capture( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, borrowed_place: Place<'tcx>, issued_spans: &UseSpans<'tcx>, ) { @@ -1754,7 +1743,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn suggest_binding_for_closure_capture_self( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, issued_spans: &UseSpans<'tcx>, ) { let UseSpans::ClosureUse { capture_kind_span, .. } = issued_spans else { return }; @@ -2149,7 +2138,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { drop_span: Span, borrow_spans: UseSpans<'tcx>, explanation: BorrowExplanation<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { debug!( "report_local_value_does_not_live_long_enough(\ {:?}, {:?}, {:?}, {:?}, {:?}\ @@ -2324,7 +2313,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, drop_span: Span, borrow_span: Span, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { debug!( "report_thread_local_value_does_not_live_long_enough(\ {:?}, {:?}\ @@ -2349,7 +2338,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { borrow_spans: UseSpans<'tcx>, proper_span: Span, explanation: BorrowExplanation<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { if let BorrowExplanation::MustBeValidFor { category, span, from_closure: false, .. } = explanation { @@ -2515,7 +2504,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { return_span: Span, category: ConstraintCategory<'tcx>, opt_place_desc: Option<&String>, - ) -> Option> { + ) -> Option> { let return_kind = match category { ConstraintCategory::Return(_) => "return", ConstraintCategory::Yield => "yield", @@ -2610,7 +2599,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { constraint_span: Span, captured_var: &str, scope: &str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let tcx = self.infcx.tcx; let args_span = use_span.args_or_use(); @@ -2718,7 +2707,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { upvar_span: Span, upvar_name: Symbol, escape_span: Span, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let tcx = self.infcx.tcx; let escapes_from = tcx.def_descr(self.mir_def_id().to_def_id()); @@ -3000,7 +2989,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.buffer_error(err); } - fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut DiagnosticBuilder<'_>) { + fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diag<'_>) { let tcx = self.infcx.tcx; if let ( Some(Terminator { @@ -3535,11 +3524,7 @@ enum AnnotatedBorrowFnSignature<'tcx> { impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { /// Annotate the provided diagnostic with information about borrow from the fn signature that /// helps explain. - pub(crate) fn emit( - &self, - cx: &mut MirBorrowckCtxt<'_, 'tcx>, - diag: &mut DiagnosticBuilder<'_>, - ) -> String { + pub(crate) fn emit(&self, cx: &mut MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diag<'_>) -> String { match self { &AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => { diag.span_label( diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index f7b59ec5fe0b7..418eabe3ae242 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -3,7 +3,7 @@ #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_hir as hir; use rustc_hir::intravisit::Visitor; use rustc_index::IndexSlice; @@ -65,7 +65,7 @@ impl<'tcx> BorrowExplanation<'tcx> { tcx: TyCtxt<'tcx>, body: &Body<'tcx>, local_names: &IndexSlice>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, borrow_desc: &str, borrow_span: Option, multiple_borrow_span: Option<(Span, Span)>, @@ -306,7 +306,7 @@ impl<'tcx> BorrowExplanation<'tcx> { fn add_object_lifetime_default_note( &self, tcx: TyCtxt<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, unsize_ty: Ty<'tcx>, ) { if let ty::Adt(def, args) = unsize_ty.kind() { @@ -359,7 +359,7 @@ impl<'tcx> BorrowExplanation<'tcx> { fn add_lifetime_bound_suggestion_to_diagnostic( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, category: &ConstraintCategory<'tcx>, span: Span, region_name: &RegionName, diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index db0d69b6eaa09..53e8ac121bbce 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -5,7 +5,7 @@ use crate::session_diagnostics::{ CaptureVarKind, CaptureVarPathUseCause, OnClosureNote, }; use itertools::Itertools; -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::CoroutineKind; @@ -80,7 +80,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &self, location: Location, place: PlaceRef<'tcx>, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, ) -> bool { debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); let mut target = place.local_or_deref_local(); @@ -588,7 +588,7 @@ impl UseSpans<'_> { pub(super) fn args_subdiag( self, dcx: &rustc_errors::DiagCtxt, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, f: impl FnOnce(Span) -> CaptureArgLabel, ) { if let UseSpans::ClosureUse { args_span, .. } = self { @@ -601,7 +601,7 @@ impl UseSpans<'_> { pub(super) fn var_path_only_subdiag( self, dcx: &rustc_errors::DiagCtxt, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, action: crate::InitializationRequiringAction, ) { use crate::InitializationRequiringAction::*; @@ -638,7 +638,7 @@ impl UseSpans<'_> { pub(super) fn var_subdiag( self, dcx: &rustc_errors::DiagCtxt, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, kind: Option, f: impl FnOnce(hir::ClosureKind, Span) -> CaptureVarCause, ) { @@ -1010,7 +1010,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn explain_captures( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, move_span: Span, move_spans: UseSpans<'tcx>, diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 3478a73254a43..0d1b875cbed5b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -1,7 +1,7 @@ #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty}; use rustc_mir_dataflow::move_paths::{LookupResult, MovePathIndex}; @@ -287,11 +287,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { self.buffer_error(err); } - fn report_cannot_move_from_static( - &mut self, - place: Place<'tcx>, - span: Span, - ) -> DiagnosticBuilder<'tcx> { + fn report_cannot_move_from_static(&mut self, place: Place<'tcx>, span: Span) -> Diag<'tcx> { let description = if place.projection.len() == 1 { format!("static item {}", self.describe_any_place(place.as_ref())) } else { @@ -313,7 +309,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { deref_target_place: Place<'tcx>, span: Span, use_spans: Option>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { // Inspect the type of the content behind the // borrow to provide feedback about why this // was a move rather than a copy. @@ -437,12 +433,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { err } - fn add_move_hints( - &self, - error: GroupedMoveError<'tcx>, - err: &mut DiagnosticBuilder<'_>, - span: Span, - ) { + fn add_move_hints(&self, error: GroupedMoveError<'tcx>, err: &mut Diag<'_>, span: Span) { match error { GroupedMoveError::MovesFromPlace { mut binds_to, move_from, .. } => { self.add_borrow_suggestions(err, span); @@ -505,7 +496,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } - fn add_borrow_suggestions(&self, err: &mut DiagnosticBuilder<'_>, span: Span) { + fn add_borrow_suggestions(&self, err: &mut Diag<'_>, span: Span) { match self.infcx.tcx.sess.source_map().span_to_snippet(span) { Ok(snippet) if snippet.starts_with('*') => { err.span_suggestion_verbose( @@ -526,7 +517,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } - fn add_move_error_suggestions(&self, err: &mut DiagnosticBuilder<'_>, binds_to: &[Local]) { + fn add_move_error_suggestions(&self, err: &mut Diag<'_>, binds_to: &[Local]) { let mut suggestions: Vec<(Span, String, String)> = Vec::new(); for local in binds_to { let bind_to = &self.body.local_decls[*local]; @@ -578,7 +569,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } - fn add_move_error_details(&self, err: &mut DiagnosticBuilder<'_>, binds_to: &[Local]) { + fn add_move_error_details(&self, err: &mut Diag<'_>, binds_to: &[Local]) { for (j, local) in binds_to.iter().enumerate() { let bind_to = &self.body.local_decls[*local]; let binding_span = bind_to.source_info.span; @@ -615,7 +606,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { /// expansion of a packed struct. /// Such errors happen because derive macro expansions shy away from taking /// references to the struct's fields since doing so would be undefined behaviour - fn add_note_for_packed_struct_derive(&self, err: &mut DiagnosticBuilder<'_>, local: Local) { + fn add_note_for_packed_struct_derive(&self, err: &mut Diag<'_>, local: Local) { let local_place: PlaceRef<'tcx> = local.into(); let local_ty = local_place.ty(self.body.local_decls(), self.infcx.tcx).ty.peel_refs(); diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index b8257ba0adcc4..c327e591f3cdd 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -2,7 +2,7 @@ #![allow(rustc::untranslatable_diagnostic)] use hir::ExprKind; -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_hir as hir; use rustc_hir::intravisit::Visitor; use rustc_hir::Node; @@ -540,12 +540,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } - fn suggest_map_index_mut_alternatives( - &self, - ty: Ty<'tcx>, - err: &mut DiagnosticBuilder<'tcx>, - span: Span, - ) { + fn suggest_map_index_mut_alternatives(&self, ty: Ty<'tcx>, err: &mut Diag<'tcx>, span: Span) { let Some(adt) = ty.ty_adt_def() else { return }; let did = adt.did(); if self.infcx.tcx.is_diagnostic_item(sym::HashMap, did) @@ -553,7 +548,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { { struct V<'a, 'tcx> { assign_span: Span, - err: &'a mut DiagnosticBuilder<'tcx>, + err: &'a mut Diag<'tcx>, ty: Ty<'tcx>, suggested: bool, } @@ -717,7 +712,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { fn construct_mut_suggestion_for_local_binding_patterns( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, local: Local, ) { let local_decl = &self.body.local_decls[local]; @@ -795,7 +790,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { tcx: TyCtxt<'_>, closure_local_def_id: hir::def_id::LocalDefId, the_place_err: PlaceRef<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) { let tables = tcx.typeck(closure_local_def_id); if let Some((span, closure_kind_origin)) = tcx.closure_kind_origin(closure_local_def_id) { @@ -857,7 +852,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { // Attempt to search similar mutable associated items for suggestion. // In the future, attempt in all path but initially for RHS of for_loop - fn suggest_similar_mut_method_for_for_loop(&self, err: &mut DiagnosticBuilder<'_>, span: Span) { + fn suggest_similar_mut_method_for_for_loop(&self, err: &mut Diag<'_>, span: Span) { use hir::{ BorrowKind, Expr, ExprKind::{AddrOf, Block, Call, MethodCall}, @@ -941,7 +936,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } /// Targeted error when encountering an `FnMut` closure where an `Fn` closure was expected. - fn expected_fn_found_fn_mut_call(&self, err: &mut DiagnosticBuilder<'_>, sp: Span, act: &str) { + fn expected_fn_found_fn_mut_call(&self, err: &mut Diag<'_>, sp: Span, act: &str) { err.span_label(sp, format!("cannot {act}")); let hir = self.infcx.tcx.hir(); @@ -1031,7 +1026,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } - fn suggest_using_iter_mut(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_using_iter_mut(&self, err: &mut Diag<'_>) { let source = self.body.source; let hir = self.infcx.tcx.hir(); if let InstanceDef::Item(def_id) = source.instance @@ -1072,7 +1067,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } } - fn suggest_make_local_mut(&self, err: &mut DiagnosticBuilder<'_>, local: Local, name: Symbol) { + fn suggest_make_local_mut(&self, err: &mut Diag<'_>, local: Local, name: Symbol) { let local_decl = &self.body.local_decls[local]; let (pointer_sigil, pointer_desc) = diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index b2c7a98142eec..1a42e551597bb 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -5,7 +5,7 @@ #![allow(rustc::untranslatable_diagnostic)] use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_middle::ty::RegionVid; use smallvec::SmallVec; use std::collections::BTreeMap; @@ -134,14 +134,13 @@ impl OutlivesSuggestionBuilder { for (r, bound) in unified.into_iter() { if !unified_already.contains(fr) { - suggested.push(SuggestedConstraint::Equal(fr_name.clone(), bound)); + suggested.push(SuggestedConstraint::Equal(fr_name, bound)); unified_already.insert(r); } } if !other.is_empty() { - let other = - other.iter().map(|(_, rname)| rname.clone()).collect::>(); + let other = other.iter().map(|(_, rname)| *rname).collect::>(); suggested.push(SuggestedConstraint::Outlives(fr_name, other)) } } @@ -158,13 +157,12 @@ impl OutlivesSuggestionBuilder { self.constraints_to_add.entry(fr).or_default().push(outlived_fr); } - /// Emit an intermediate note on the given `DiagnosticBuilder` if the involved regions are - /// suggestable. + /// Emit an intermediate note on the given `Diag` if the involved regions are suggestable. pub(crate) fn intermediate_suggestion( &mut self, mbcx: &MirBorrowckCtxt<'_, '_>, errci: &ErrorConstraintInfo<'_>, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, ) { // Emit an intermediate note. let fr_name = self.region_vid_to_name(mbcx, errci.fr); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 50d22881c3e61..3765dfe5db53c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -1,7 +1,7 @@ //! Error reporting machinery for lifetime errors. use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan}; +use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::Res::Def; use rustc_hir::def_id::DefId; @@ -73,7 +73,7 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> { /// /// Usually we expect this to either be empty or contain a small number of items, so we can avoid /// allocation most of the time. -pub(crate) struct RegionErrors<'tcx>(Vec>, TyCtxt<'tcx>); +pub(crate) struct RegionErrors<'tcx>(Vec<(RegionErrorKind<'tcx>, ErrorGuaranteed)>, TyCtxt<'tcx>); impl<'tcx> RegionErrors<'tcx> { pub fn new(tcx: TyCtxt<'tcx>) -> Self { @@ -82,15 +82,18 @@ impl<'tcx> RegionErrors<'tcx> { #[track_caller] pub fn push(&mut self, val: impl Into>) { let val = val.into(); - self.1.sess.dcx().delayed_bug(format!("{val:?}")); - self.0.push(val); + let guar = self.1.sess.dcx().delayed_bug(format!("{val:?}")); + self.0.push((val, guar)); } pub fn is_empty(&self) -> bool { self.0.is_empty() } - pub fn into_iter(self) -> impl Iterator> { + pub fn into_iter(self) -> impl Iterator, ErrorGuaranteed)> { self.0.into_iter() } + pub fn has_errors(&self) -> Option { + self.0.get(0).map(|x| x.1) + } } impl std::fmt::Debug for RegionErrors<'_> { @@ -200,7 +203,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { // and the span which bounded to the trait for adding 'static lifetime suggestion fn suggest_static_lifetime_for_gat_from_hrtb( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, lower_bound: RegionVid, ) { let mut suggestions = vec![]; @@ -280,7 +283,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { .iter() .rfind(|param| param.def_id.to_def_id() == defid) .is_some() { - suggestions.push((bounded_span.shrink_to_hi(), format!(" + 'static"))); + suggestions.push((bounded_span.shrink_to_hi(), " + 'static".to_string())); } }); }); @@ -304,10 +307,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let mut last_unexpected_hidden_region: Option<(Span, Ty<'_>, ty::OpaqueTypeKey<'tcx>)> = None; - for nll_error in nll_errors.into_iter() { + for (nll_error, _) in nll_errors.into_iter() { match nll_error { RegionErrorKind::TypeTestError { type_test } => { - // Try to convert the lower-bound region into something named we can print for the user. + // Try to convert the lower-bound region into something named we can print for + // the user. let lower_bound_region = self.to_error_region(type_test.lower_bound); let type_test_span = type_test.span; @@ -580,7 +584,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { &self, errci: &ErrorConstraintInfo<'tcx>, kind: ReturnConstraint, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let ErrorConstraintInfo { outlived_fr, span, .. } = errci; let mut output_ty = self.regioncx.universal_regions().unnormalized_output_ty; @@ -649,10 +653,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { /// | ^^^^^^^^^^ `x` escapes the function body here /// ``` #[instrument(level = "debug", skip(self))] - fn report_escaping_data_error( - &self, - errci: &ErrorConstraintInfo<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + fn report_escaping_data_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> Diag<'tcx> { let ErrorConstraintInfo { span, category, .. } = errci; let fr_name_and_span = self.regioncx.get_var_name_and_span_for_region( @@ -760,7 +761,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { /// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it /// | is returning data with lifetime `'b` /// ``` - fn report_general_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> DiagnosticBuilder<'tcx> { + fn report_general_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> Diag<'tcx> { let ErrorConstraintInfo { fr, fr_is_local, @@ -823,7 +824,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { /// ``` fn add_static_impl_trait_suggestion( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, fr: RegionVid, // We need to pass `fr_name` - computing it again will label it twice. fr_name: RegionName, @@ -912,7 +913,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { fn maybe_suggest_constrain_dyn_trait_impl( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, f: Region<'tcx>, o: Region<'tcx>, category: &ConstraintCategory<'tcx>, @@ -974,7 +975,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { #[instrument(skip(self, err), level = "debug")] fn suggest_constrain_dyn_trait_in_impl( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, found_dids: &FxIndexSet, ident: Ident, self_ty: &hir::Ty<'_>, @@ -1007,12 +1008,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { suggested } - fn suggest_adding_lifetime_params( - &self, - diag: &mut DiagnosticBuilder<'_>, - sub: RegionVid, - sup: RegionVid, - ) { + fn suggest_adding_lifetime_params(&self, diag: &mut Diag<'_>, sub: RegionVid, sup: RegionVid) { let (Some(sub), Some(sup)) = (self.to_error_region(sub), self.to_error_region(sup)) else { return; }; @@ -1038,7 +1034,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { suggest_adding_lifetime_params(self.infcx.tcx, sub, ty_sup, ty_sub, diag); } - fn suggest_move_on_borrowing_closure(&self, diag: &mut DiagnosticBuilder<'_>) { + fn suggest_move_on_borrowing_closure(&self, diag: &mut Diag<'_>) { let map = self.infcx.tcx.hir(); let body_id = map.body_owned_by(self.mir_def_id()); let expr = &map.body(body_id).value.peel_blocks(); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index e228bef1139a6..f6f33e10c20d4 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Display}; use std::iter; use rustc_data_structures::fx::IndexEntry; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_middle::ty::print::RegionHighlightMode; @@ -106,7 +106,7 @@ impl RegionName { } } - pub(crate) fn highlight_region_name(&self, diag: &mut DiagnosticBuilder<'_>) { + pub(crate) fn highlight_region_name(&self, diag: &mut Diag<'_>) { match &self.source { RegionNameSource::NamedLateParamRegion(span) | RegionNameSource::NamedEarlyParamRegion(span) => { @@ -192,7 +192,7 @@ impl Display for RegionName { } impl rustc_errors::IntoDiagnosticArg for RegionName { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { self.to_string().into_diagnostic_arg() } } diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index dbaa9e5bcfab0..ef582033c4ea1 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -20,7 +20,7 @@ extern crate tracing; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::graph::dominators::Dominators; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir as hir; use rustc_hir::def_id::LocalDefId; use rustc_index::bit_set::{BitSet, ChunkedBitSet}; @@ -2395,8 +2395,8 @@ mod diags { use super::*; enum BufferedDiag<'tcx> { - Error(DiagnosticBuilder<'tcx>), - NonError(DiagnosticBuilder<'tcx, ()>), + Error(Diag<'tcx>), + NonError(Diag<'tcx, ()>), } impl<'tcx> BufferedDiag<'tcx> { @@ -2423,10 +2423,9 @@ mod diags { /// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary /// when errors in the map are being re-added to the error buffer so that errors with the /// same primary span come out in a consistent order. - buffered_move_errors: - BTreeMap, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx>)>, + buffered_move_errors: BTreeMap, (PlaceRef<'tcx>, Diag<'tcx>)>, - buffered_mut_errors: FxIndexMap, usize)>, + buffered_mut_errors: FxIndexMap, usize)>, /// Buffer of diagnostics to be reported. A mixture of error and non-error diagnostics. buffered_diags: Vec>, @@ -2441,28 +2440,28 @@ mod diags { } } - pub fn buffer_error(&mut self, t: DiagnosticBuilder<'tcx>) { - self.buffered_diags.push(BufferedDiag::Error(t)); + pub fn buffer_error(&mut self, diag: Diag<'tcx>) { + self.buffered_diags.push(BufferedDiag::Error(diag)); } - pub fn buffer_non_error(&mut self, t: DiagnosticBuilder<'tcx, ()>) { - self.buffered_diags.push(BufferedDiag::NonError(t)); + pub fn buffer_non_error(&mut self, diag: Diag<'tcx, ()>) { + self.buffered_diags.push(BufferedDiag::NonError(diag)); } } impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { - pub fn buffer_error(&mut self, t: DiagnosticBuilder<'tcx>) { - self.diags.buffer_error(t); + pub fn buffer_error(&mut self, diag: Diag<'tcx>) { + self.diags.buffer_error(diag); } - pub fn buffer_non_error(&mut self, t: DiagnosticBuilder<'tcx, ()>) { - self.diags.buffer_non_error(t); + pub fn buffer_non_error(&mut self, diag: Diag<'tcx, ()>) { + self.diags.buffer_non_error(diag); } pub fn buffer_move_error( &mut self, move_out_indices: Vec, - place_and_err: (PlaceRef<'tcx>, DiagnosticBuilder<'tcx>), + place_and_err: (PlaceRef<'tcx>, Diag<'tcx>), ) -> bool { if let Some((_, diag)) = self.diags.buffered_move_errors.insert(move_out_indices, place_and_err) @@ -2475,16 +2474,13 @@ mod diags { } } - pub fn get_buffered_mut_error( - &mut self, - span: Span, - ) -> Option<(DiagnosticBuilder<'tcx>, usize)> { + pub fn get_buffered_mut_error(&mut self, span: Span) -> Option<(Diag<'tcx>, usize)> { // FIXME(#120456) - is `swap_remove` correct? self.diags.buffered_mut_errors.swap_remove(&span) } - pub fn buffer_mut_error(&mut self, span: Span, t: DiagnosticBuilder<'tcx>, count: usize) { - self.diags.buffered_mut_errors.insert(span, (t, count)); + pub fn buffer_mut_error(&mut self, span: Span, diag: Diag<'tcx>, count: usize) { + self.diags.buffered_mut_errors.insert(span, (diag, count)); } pub fn emit_errors(&mut self) -> Option { @@ -2524,7 +2520,7 @@ mod diags { pub fn has_move_error( &self, move_out_indices: &[MoveOutIndex], - ) -> Option<&(PlaceRef<'tcx>, DiagnosticBuilder<'tcx>)> { + ) -> Option<&(PlaceRef<'tcx>, Diag<'tcx>)> { self.diags.buffered_move_errors.get(move_out_indices) } } diff --git a/compiler/rustc_borrowck/src/nll.rs b/compiler/rustc_borrowck/src/nll.rs index 80d79e1beb708..4aa32a61f7c36 100644 --- a/compiler/rustc_borrowck/src/nll.rs +++ b/compiler/rustc_borrowck/src/nll.rs @@ -184,12 +184,9 @@ pub(crate) fn compute_regions<'cx, 'tcx>( let (closure_region_requirements, nll_errors) = regioncx.solve(infcx, body, polonius_output.clone()); - if !nll_errors.is_empty() { + if let Some(guar) = nll_errors.has_errors() { // Suppress unhelpful extra errors in `infer_opaque_types`. - infcx.set_tainted_by_errors(infcx.dcx().span_delayed_bug( - body.span, - "`compute_regions` tainted `infcx` with errors but did not emit any errors", - )); + infcx.set_tainted_by_errors(guar); } let remapped_opaque_tys = regioncx.infer_opaque_types(infcx, opaque_type_values); diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index ce2c0dbaff7d9..c3800a1f1f21b 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -5,7 +5,7 @@ use rustc_data_structures::binary_search_util; use rustc_data_structures::frozen::Frozen; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::graph::scc::Sccs; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir::def_id::CRATE_DEF_ID; use rustc_index::{IndexSlice, IndexVec}; use rustc_infer::infer::outlives::test_type_match; @@ -592,7 +592,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Adds annotations for `#[rustc_regions]`; see `UniversalRegions::annotate`. - pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut DiagnosticBuilder<'_, ()>) { + pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_, ()>) { self.universal_regions.annotate(tcx, err) } diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index 897918fb0a45b..86d20599a2a88 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -311,17 +311,14 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { // Add implied bounds from impl header. if matches!(tcx.def_kind(defining_ty_def_id), DefKind::AssocFn | DefKind::AssocConst) { for &(ty, _) in tcx.assumed_wf_types(tcx.local_parent(defining_ty_def_id)) { - let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = self + let result: Result<_, ErrorGuaranteed> = self .param_env .and(type_op::normalize::Normalize::new(ty)) - .fully_perform(self.infcx, span) - else { - // Note: this path is currently not reached in any test, so - // any example that triggers this would be worth minimizing - // and converting into a test. - tcx.dcx().span_delayed_bug(span, format!("failed to normalize {ty:?}")); + .fully_perform(self.infcx, span); + let Ok(TypeOpOutput { output: norm_ty, constraints: c, .. }) = result else { continue; }; + constraints.extend(c); // We currently add implied bounds from the normalized ty only. diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index dd355c3525c30..00296aa38daae 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -1,7 +1,8 @@ use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; -use rustc_infer::infer::{NllRegionVariableOrigin, ObligationEmittingRelation}; +use rustc_infer::infer::NllRegionVariableOrigin; +use rustc_infer::infer::{ObligationEmittingRelation, StructurallyRelateAliases}; use rustc_infer::traits::{Obligation, PredicateObligations}; use rustc_middle::mir::ConstraintCategory; use rustc_middle::traits::query::NoSolution; @@ -123,7 +124,11 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> { // `handle_opaque_type` cannot handle subtyping, so to support subtyping // we instead eagerly generalize here. This is a bit of a mess but will go // away once we're using the new solver. - let mut enable_subtyping = |ty, ty_is_expected| { + // + // Given `opaque rel B`, we create a new infer var `ty_vid` constrain it + // by using `ty_vid rel B` and then finally and end by equating `ty_vid` to + // the opaque. + let mut enable_subtyping = |ty, opaque_is_expected| { let ty_vid = infcx.next_ty_var_id_in_universe( TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, @@ -132,7 +137,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> { ty::UniverseIndex::ROOT, ); - let variance = if ty_is_expected { + let variance = if opaque_is_expected { self.ambient_variance } else { self.ambient_variance.xform(ty::Contravariant) @@ -140,7 +145,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> { self.type_checker.infcx.instantiate_ty_var( self, - ty_is_expected, + opaque_is_expected, ty_vid, variance, ty, @@ -149,8 +154,8 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> { }; let (a, b) = match (a.kind(), b.kind()) { - (&ty::Alias(ty::Opaque, ..), _) => (a, enable_subtyping(b, false)?), - (_, &ty::Alias(ty::Opaque, ..)) => (enable_subtyping(a, true)?, b), + (&ty::Alias(ty::Opaque, ..), _) => (a, enable_subtyping(b, true)?), + (_, &ty::Alias(ty::Opaque, ..)) => (enable_subtyping(a, false)?, b), _ => unreachable!( "expected at least one opaque type in `relate_opaques`, got {a} and {b}." ), @@ -544,6 +549,10 @@ impl<'bccx, 'tcx> ObligationEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx self.locations.span(self.type_checker.body) } + fn structurally_relate_aliases(&self) -> StructurallyRelateAliases { + StructurallyRelateAliases::No + } + fn param_env(&self) -> ty::ParamEnv<'tcx> { self.type_checker.param_env } diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index e743948103467..9c65f64b03fec 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -16,7 +16,7 @@ #![allow(rustc::untranslatable_diagnostic)] use rustc_data_structures::fx::FxIndexMap; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::lang_items::LangItem; use rustc_hir::BodyOwnerKind; @@ -343,7 +343,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// that this region imposes on others. The methods in this file /// handle the part about dumping the inference context internal /// state. - pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut DiagnosticBuilder<'_, ()>) { + pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_, ()>) { match self.defining_ty { DefiningTy::Closure(def_id, args) => { let v = with_no_trimmed_paths!( diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index c5a73c3199579..29bf5e9f30493 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -1,3 +1,4 @@ +use ast::token::IdentIsRaw; use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter}; @@ -12,7 +13,7 @@ use rustc_session::lint; use rustc_session::parse::ParseSess; use rustc_span::symbol::Ident; use rustc_span::symbol::{kw, sym, Symbol}; -use rustc_span::{InnerSpan, Span}; +use rustc_span::{ErrorGuaranteed, InnerSpan, Span}; use rustc_target::asm::InlineAsmArch; use smallvec::smallvec; @@ -416,7 +417,7 @@ fn parse_reg<'a>( ) -> PResult<'a, ast::InlineAsmRegOrRegClass> { p.expect(&token::OpenDelim(Delimiter::Parenthesis))?; let result = match p.token.uninterpolate().kind { - token::Ident(name, false) => ast::InlineAsmRegOrRegClass::RegClass(name), + token::Ident(name, IdentIsRaw::No) => ast::InlineAsmRegOrRegClass::RegClass(name), token::Literal(token::Lit { kind: token::LitKind::Str, symbol, suffix: _ }) => { *explicit_reg = true; ast::InlineAsmRegOrRegClass::Reg(symbol) @@ -432,7 +433,10 @@ fn parse_reg<'a>( Ok(result) } -fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option { +fn expand_preparsed_asm( + ecx: &mut ExtCtxt<'_>, + args: AsmArgs, +) -> Result { let mut template = vec![]; // Register operands are implicitly used since they are not allowed to be // referenced in the template string. @@ -458,10 +462,10 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option template_part, Err(err) => { - if let Some((err, _)) = err { - err.emit(); - } - return None; + return Err(match err { + Ok((err, _)) => err.emit(), + Err(guar) => guar, + }); } }; @@ -550,8 +554,8 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option, args: AsmArgs) -> Option( ) -> Box { match parse_args(ecx, sp, tts, false) { Ok(args) => { - let expr = if let Some(inline_asm) = expand_preparsed_asm(ecx, args) { - P(ast::Expr { + let expr = match expand_preparsed_asm(ecx, args) { + Ok(inline_asm) => P(ast::Expr { id: ast::DUMMY_NODE_ID, kind: ast::ExprKind::InlineAsm(P(inline_asm)), span: sp, attrs: ast::AttrVec::new(), tokens: None, - }) - } else { - DummyResult::raw_expr(sp, true) + }), + Err(guar) => DummyResult::raw_expr(sp, Some(guar)), }; MacEager::expr(expr) } Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } @@ -761,28 +764,25 @@ pub(super) fn expand_global_asm<'cx>( tts: TokenStream, ) -> Box { match parse_args(ecx, sp, tts, true) { - Ok(args) => { - if let Some(inline_asm) = expand_preparsed_asm(ecx, args) { - MacEager::items(smallvec![P(ast::Item { - ident: Ident::empty(), - attrs: ast::AttrVec::new(), - id: ast::DUMMY_NODE_ID, - kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)), - vis: ast::Visibility { - span: sp.shrink_to_lo(), - kind: ast::VisibilityKind::Inherited, - tokens: None, - }, - span: sp, + Ok(args) => match expand_preparsed_asm(ecx, args) { + Ok(inline_asm) => MacEager::items(smallvec![P(ast::Item { + ident: Ident::empty(), + attrs: ast::AttrVec::new(), + id: ast::DUMMY_NODE_ID, + kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)), + vis: ast::Visibility { + span: sp.shrink_to_lo(), + kind: ast::VisibilityKind::Inherited, tokens: None, - })]) - } else { - DummyResult::any(sp) - } - } + }, + span: sp, + tokens: None, + })]), + Err(guar) => DummyResult::any(sp, guar), + }, Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs index 501d557f3ab8a..613ce43dec2d6 100644 --- a/compiler/rustc_builtin_macros/src/assert.rs +++ b/compiler/rustc_builtin_macros/src/assert.rs @@ -23,8 +23,8 @@ pub fn expand_assert<'cx>( let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) { Ok(assert) => assert, Err(err) => { - err.emit(); - return DummyResult::any(span); + let guar = err.emit(); + return DummyResult::any(span, guar); } }; diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index d244897f8a5de..56c56b2704b00 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -1,7 +1,6 @@ use rustc_ast::{ ptr::P, - token, - token::Delimiter, + token::{self, Delimiter, IdentIsRaw}, tokenstream::{DelimSpan, TokenStream, TokenTree}, BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID, @@ -170,7 +169,10 @@ impl<'cx, 'a> Context<'cx, 'a> { ]; let captures = self.capture_decls.iter().flat_map(|cap| { [ - TokenTree::token_joint_hidden(token::Ident(cap.ident.name, false), cap.ident.span), + TokenTree::token_joint_hidden( + token::Ident(cap.ident.name, IdentIsRaw::No), + cap.ident.span, + ), TokenTree::token_alone(token::Comma, self.span), ] }); @@ -301,7 +303,8 @@ impl<'cx, 'a> Context<'cx, 'a> { | ExprKind::Closure(_) | ExprKind::ConstBlock(_) | ExprKind::Continue(_) - | ExprKind::Err + | ExprKind::Dummy + | ExprKind::Err(_) | ExprKind::Field(_, _) | ExprKind::ForLoop { .. } | ExprKind::FormatArgs(_) diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs index 581d390992adc..04bf7dceeff49 100644 --- a/compiler/rustc_builtin_macros/src/cfg.rs +++ b/compiler/rustc_builtin_macros/src/cfg.rs @@ -8,14 +8,14 @@ use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_attr as attr; use rustc_errors::PResult; -use rustc_expand::base::{self, *}; +use rustc_expand::base::{DummyResult, ExtCtxt, MacEager, MacResult}; use rustc_span::Span; pub fn expand_cfg( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); match parse_cfg(cx, sp, tts) { @@ -29,8 +29,8 @@ pub fn expand_cfg( MacEager::expr(cx.expr_bool(sp, matches_cfg)) } Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/compile_error.rs b/compiler/rustc_builtin_macros/src/compile_error.rs index f157575da79bc..b4455d7823f35 100644 --- a/compiler/rustc_builtin_macros/src/compile_error.rs +++ b/compiler/rustc_builtin_macros/src/compile_error.rs @@ -1,24 +1,22 @@ // The compiler code necessary to support the compile_error! extension. use rustc_ast::tokenstream::TokenStream; -use rustc_expand::base::{self, *}; +use rustc_expand::base::{get_single_str_from_tts, DummyResult, ExtCtxt, MacResult}; use rustc_span::Span; pub fn expand_compile_error<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { - let Some(var) = get_single_str_from_tts(cx, sp, tts, "compile_error!") else { - return DummyResult::any(sp); +) -> Box { + let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") { + Ok(var) => var, + Err(guar) => return DummyResult::any(sp, guar), }; - #[expect( - rustc::diagnostic_outside_of_impl, - reason = "diagnostic message is specified by user" - )] + #[expect(rustc::diagnostic_outside_of_impl, reason = "diagnostic message is specified by user")] #[expect(rustc::untranslatable_diagnostic, reason = "diagnostic message is specified by user")] - cx.dcx().span_err(sp, var.to_string()); + let guar = cx.dcx().span_err(sp, var.to_string()); - DummyResult::any(sp) + DummyResult::any(sp, guar) } diff --git a/compiler/rustc_builtin_macros/src/concat.rs b/compiler/rustc_builtin_macros/src/concat.rs index 795161e65d81e..abfaa9b006edb 100644 --- a/compiler/rustc_builtin_macros/src/concat.rs +++ b/compiler/rustc_builtin_macros/src/concat.rs @@ -1,73 +1,69 @@ -use rustc_ast as ast; use rustc_ast::tokenstream::TokenStream; -use rustc_expand::base::{self, DummyResult}; +use rustc_ast::{ExprKind, LitKind, UnOp}; +use rustc_expand::base::{get_exprs_from_tts, DummyResult, ExtCtxt, MacEager, MacResult}; use rustc_session::errors::report_lit_error; use rustc_span::symbol::Symbol; use crate::errors; pub fn expand_concat( - cx: &mut base::ExtCtxt<'_>, + cx: &mut ExtCtxt<'_>, sp: rustc_span::Span, tts: TokenStream, -) -> Box { - let Some(es) = base::get_exprs_from_tts(cx, tts) else { - return DummyResult::any(sp); +) -> Box { + let es = match get_exprs_from_tts(cx, tts) { + Ok(es) => es, + Err(guar) => return DummyResult::any(sp, guar), }; let mut accumulator = String::new(); let mut missing_literal = vec![]; - let mut has_errors = false; + let mut guar = None; for e in es { match e.kind { - ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Str(s, _) | ast::LitKind::Float(s, _)) => { + ExprKind::Lit(token_lit) => match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Str(s, _) | LitKind::Float(s, _)) => { accumulator.push_str(s.as_str()); } - Ok(ast::LitKind::Char(c)) => { + Ok(LitKind::Char(c)) => { accumulator.push(c); } - Ok(ast::LitKind::Int(i, _)) => { + Ok(LitKind::Int(i, _)) => { accumulator.push_str(&i.to_string()); } - Ok(ast::LitKind::Bool(b)) => { + Ok(LitKind::Bool(b)) => { accumulator.push_str(&b.to_string()); } - Ok(ast::LitKind::CStr(..)) => { - cx.dcx().emit_err(errors::ConcatCStrLit { span: e.span }); - has_errors = true; + Ok(LitKind::CStr(..)) => { + guar = Some(cx.dcx().emit_err(errors::ConcatCStrLit { span: e.span })); } - Ok(ast::LitKind::Byte(..) | ast::LitKind::ByteStr(..)) => { - cx.dcx().emit_err(errors::ConcatBytestr { span: e.span }); - has_errors = true; + Ok(LitKind::Byte(..) | LitKind::ByteStr(..)) => { + guar = Some(cx.dcx().emit_err(errors::ConcatBytestr { span: e.span })); } - Ok(ast::LitKind::Err(_)) => { - has_errors = true; + Ok(LitKind::Err(guarantee)) => { + guar = Some(guarantee); } Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span); - has_errors = true; + guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span)); } }, // We also want to allow negative numeric literals. - ast::ExprKind::Unary(ast::UnOp::Neg, ref expr) - if let ast::ExprKind::Lit(token_lit) = expr.kind => - { - match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Int(i, _)) => accumulator.push_str(&format!("-{i}")), - Ok(ast::LitKind::Float(f, _)) => accumulator.push_str(&format!("-{f}")), + ExprKind::Unary(UnOp::Neg, ref expr) if let ExprKind::Lit(token_lit) = expr.kind => { + match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Int(i, _)) => accumulator.push_str(&format!("-{i}")), + Ok(LitKind::Float(f, _)) => accumulator.push_str(&format!("-{f}")), Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span); - has_errors = true; + guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span)); } _ => missing_literal.push(e.span), } } - ast::ExprKind::IncludedBytes(..) => { + ExprKind::IncludedBytes(..) => { cx.dcx().emit_err(errors::ConcatBytestr { span: e.span }); } - ast::ExprKind::Err => { - has_errors = true; + ExprKind::Err(guarantee) => { + guar = Some(guarantee); } + ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { missing_literal.push(e.span); } @@ -75,11 +71,11 @@ pub fn expand_concat( } if !missing_literal.is_empty() { - cx.dcx().emit_err(errors::ConcatMissingLiteral { spans: missing_literal }); - return DummyResult::any(sp); - } else if has_errors { - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatMissingLiteral { spans: missing_literal }); + return DummyResult::any(sp, guar); + } else if let Some(guar) = guar { + return DummyResult::any(sp, guar); } let sp = cx.with_def_site_ctxt(sp); - base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator))) + MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator))) } diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs index 3ef8cb7bffef2..3fb0b50f41756 100644 --- a/compiler/rustc_builtin_macros/src/concat_bytes.rs +++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs @@ -1,192 +1,181 @@ -use rustc_ast as ast; -use rustc_ast::{ptr::P, tokenstream::TokenStream}; -use rustc_expand::base::{self, DummyResult}; +use rustc_ast::{ptr::P, token, tokenstream::TokenStream, ExprKind, LitIntType, LitKind, UintTy}; +use rustc_expand::base::{get_exprs_from_tts, DummyResult, ExtCtxt, MacEager, MacResult}; use rustc_session::errors::report_lit_error; -use rustc_span::Span; +use rustc_span::{ErrorGuaranteed, Span}; use crate::errors; /// Emits errors for literal expressions that are invalid inside and outside of an array. fn invalid_type_err( - cx: &mut base::ExtCtxt<'_>, - token_lit: ast::token::Lit, + cx: &mut ExtCtxt<'_>, + token_lit: token::Lit, span: Span, is_nested: bool, -) { +) -> ErrorGuaranteed { use errors::{ ConcatBytesInvalid, ConcatBytesInvalidSuggestion, ConcatBytesNonU8, ConcatBytesOob, }; let snippet = cx.sess.source_map().span_to_snippet(span).ok(); let dcx = cx.dcx(); - match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::CStr(_, _)) => { + match LitKind::from_token_lit(token_lit) { + Ok(LitKind::CStr(_, _)) => { // Avoid ambiguity in handling of terminal `NUL` by refusing to // concatenate C string literals as bytes. - dcx.emit_err(errors::ConcatCStrLit { span: span }); + dcx.emit_err(errors::ConcatCStrLit { span }) } - Ok(ast::LitKind::Char(_)) => { + Ok(LitKind::Char(_)) => { let sugg = snippet.map(|snippet| ConcatBytesInvalidSuggestion::CharLit { span, snippet }); - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "character", sugg }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "character", sugg }) } - Ok(ast::LitKind::Str(_, _)) => { + Ok(LitKind::Str(_, _)) => { // suggestion would be invalid if we are nested let sugg = if !is_nested { snippet.map(|snippet| ConcatBytesInvalidSuggestion::StrLit { span, snippet }) } else { None }; - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "string", sugg }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "string", sugg }) } - Ok(ast::LitKind::Float(_, _)) => { - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "float", sugg: None }); + Ok(LitKind::Float(_, _)) => { + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "float", sugg: None }) } - Ok(ast::LitKind::Bool(_)) => { - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "boolean", sugg: None }); + Ok(LitKind::Bool(_)) => { + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "boolean", sugg: None }) } - Ok(ast::LitKind::Err(_)) => {} - Ok(ast::LitKind::Int(_, _)) if !is_nested => { + Ok(LitKind::Int(_, _)) if !is_nested => { let sugg = - snippet.map(|snippet| ConcatBytesInvalidSuggestion::IntLit { span: span, snippet }); - dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "numeric", sugg }); + snippet.map(|snippet| ConcatBytesInvalidSuggestion::IntLit { span, snippet }); + dcx.emit_err(ConcatBytesInvalid { span, lit_kind: "numeric", sugg }) } - Ok(ast::LitKind::Int( - val, - ast::LitIntType::Unsuffixed | ast::LitIntType::Unsigned(ast::UintTy::U8), - )) => { + Ok(LitKind::Int(val, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::U8))) => { assert!(val.get() > u8::MAX.into()); // must be an error - dcx.emit_err(ConcatBytesOob { span }); - } - Ok(ast::LitKind::Int(_, _)) => { - dcx.emit_err(ConcatBytesNonU8 { span }); - } - Ok(ast::LitKind::ByteStr(..) | ast::LitKind::Byte(_)) => unreachable!(), - Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, span); + dcx.emit_err(ConcatBytesOob { span }) } + Ok(LitKind::Int(_, _)) => dcx.emit_err(ConcatBytesNonU8 { span }), + Ok(LitKind::ByteStr(..) | LitKind::Byte(_)) => unreachable!(), + Ok(LitKind::Err(guar)) => guar, + Err(err) => report_lit_error(&cx.sess.parse_sess, err, token_lit, span), } } +/// Returns `expr` as a *single* byte literal if applicable. +/// +/// Otherwise, returns `None`, and either pushes the `expr`'s span to `missing_literals` or +/// updates `guar` accordingly. fn handle_array_element( - cx: &mut base::ExtCtxt<'_>, - has_errors: &mut bool, + cx: &mut ExtCtxt<'_>, + guar: &mut Option, missing_literals: &mut Vec, expr: &P, ) -> Option { let dcx = cx.dcx(); - match expr.kind { - ast::ExprKind::Array(_) | ast::ExprKind::Repeat(_, _) => { - if !*has_errors { - dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }); - } - *has_errors = true; - None - } - ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Int( - val, - ast::LitIntType::Unsuffixed | ast::LitIntType::Unsigned(ast::UintTy::U8), - )) if val.get() <= u8::MAX.into() => Some(val.get() as u8), - Ok(ast::LitKind::Byte(val)) => Some(val), - Ok(ast::LitKind::ByteStr(..)) => { - if !*has_errors { - dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: true }); + match expr.kind { + ExprKind::Lit(token_lit) => { + match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Int( + val, + LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::U8), + )) if let Ok(val) = u8::try_from(val.get()) => { + return Some(val); } - *has_errors = true; - None - } - _ => { - if !*has_errors { - invalid_type_err(cx, token_lit, expr.span, true); + Ok(LitKind::Byte(val)) => return Some(val), + Ok(LitKind::ByteStr(..)) => { + guar.get_or_insert_with(|| { + dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: true }) + }); } - *has_errors = true; - None - } - }, - ast::ExprKind::IncludedBytes(..) => { - if !*has_errors { - dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }); - } - *has_errors = true; - None + _ => { + guar.get_or_insert_with(|| invalid_type_err(cx, token_lit, expr.span, true)); + } + }; + } + ExprKind::Array(_) | ExprKind::Repeat(_, _) => { + guar.get_or_insert_with(|| { + dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }) + }); } - _ => { - missing_literals.push(expr.span); - None + ExprKind::IncludedBytes(..) => { + guar.get_or_insert_with(|| { + dcx.emit_err(errors::ConcatBytesArray { span: expr.span, bytestr: false }) + }); } + _ => missing_literals.push(expr.span), } + + None } pub fn expand_concat_bytes( - cx: &mut base::ExtCtxt<'_>, - sp: rustc_span::Span, + cx: &mut ExtCtxt<'_>, + sp: Span, tts: TokenStream, -) -> Box { - let Some(es) = base::get_exprs_from_tts(cx, tts) else { - return DummyResult::any(sp); +) -> Box { + let es = match get_exprs_from_tts(cx, tts) { + Ok(es) => es, + Err(guar) => return DummyResult::any(sp, guar), }; let mut accumulator = Vec::new(); let mut missing_literals = vec![]; - let mut has_errors = false; + let mut guar = None; for e in es { match &e.kind { - ast::ExprKind::Array(exprs) => { + ExprKind::Array(exprs) => { for expr in exprs { if let Some(elem) = - handle_array_element(cx, &mut has_errors, &mut missing_literals, expr) + handle_array_element(cx, &mut guar, &mut missing_literals, expr) { accumulator.push(elem); } } } - ast::ExprKind::Repeat(expr, count) => { - if let ast::ExprKind::Lit(token_lit) = count.value.kind - && let Ok(ast::LitKind::Int(count_val, _)) = - ast::LitKind::from_token_lit(token_lit) + ExprKind::Repeat(expr, count) => { + if let ExprKind::Lit(token_lit) = count.value.kind + && let Ok(LitKind::Int(count_val, _)) = LitKind::from_token_lit(token_lit) { if let Some(elem) = - handle_array_element(cx, &mut has_errors, &mut missing_literals, expr) + handle_array_element(cx, &mut guar, &mut missing_literals, expr) { for _ in 0..count_val.get() { accumulator.push(elem); } } } else { - cx.dcx().emit_err(errors::ConcatBytesBadRepeat { span: count.value.span }); + guar = Some( + cx.dcx().emit_err(errors::ConcatBytesBadRepeat { span: count.value.span }), + ); } } - &ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) { - Ok(ast::LitKind::Byte(val)) => { + &ExprKind::Lit(token_lit) => match LitKind::from_token_lit(token_lit) { + Ok(LitKind::Byte(val)) => { accumulator.push(val); } - Ok(ast::LitKind::ByteStr(ref bytes, _)) => { + Ok(LitKind::ByteStr(ref bytes, _)) => { accumulator.extend_from_slice(bytes); } _ => { - if !has_errors { - invalid_type_err(cx, token_lit, e.span, false); - } - has_errors = true; + guar.get_or_insert_with(|| invalid_type_err(cx, token_lit, e.span, false)); } }, - ast::ExprKind::IncludedBytes(bytes) => { + ExprKind::IncludedBytes(bytes) => { accumulator.extend_from_slice(bytes); } - ast::ExprKind::Err => { - has_errors = true; + ExprKind::Err(guarantee) => { + guar = Some(*guarantee); } + ExprKind::Dummy => cx.dcx().span_bug(e.span, "concatenating `ExprKind::Dummy`"), _ => { missing_literals.push(e.span); } } } if !missing_literals.is_empty() { - cx.dcx().emit_err(errors::ConcatBytesMissingLiteral { spans: missing_literals }); - return base::MacEager::expr(DummyResult::raw_expr(sp, true)); - } else if has_errors { - return base::MacEager::expr(DummyResult::raw_expr(sp, true)); + let guar = cx.dcx().emit_err(errors::ConcatBytesMissingLiteral { spans: missing_literals }); + return MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); + } else if let Some(guar) = guar { + return MacEager::expr(DummyResult::raw_expr(sp, Some(guar))); } let sp = cx.with_def_site_ctxt(sp); - base::MacEager::expr(cx.expr_byte_str(sp, accumulator)) + MacEager::expr(cx.expr_byte_str(sp, accumulator)) } diff --git a/compiler/rustc_builtin_macros/src/concat_idents.rs b/compiler/rustc_builtin_macros/src/concat_idents.rs index 17fd3901cc6bc..fffcddc5325bd 100644 --- a/compiler/rustc_builtin_macros/src/concat_idents.rs +++ b/compiler/rustc_builtin_macros/src/concat_idents.rs @@ -1,8 +1,8 @@ -use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; -use rustc_expand::base::{self, *}; +use rustc_ast::{AttrVec, Expr, ExprKind, Path, Ty, TyKind, DUMMY_NODE_ID}; +use rustc_expand::base::{DummyResult, ExtCtxt, MacResult}; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; @@ -12,10 +12,10 @@ pub fn expand_concat_idents<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { if tts.is_empty() { - cx.dcx().emit_err(errors::ConcatIdentsMissingArgs { span: sp }); - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatIdentsMissingArgs { span: sp }); + return DummyResult::any(sp, guar); } let mut res_str = String::new(); @@ -24,8 +24,8 @@ pub fn expand_concat_idents<'cx>( match e { TokenTree::Token(Token { kind: token::Comma, .. }, _) => {} _ => { - cx.dcx().emit_err(errors::ConcatIdentsMissingComma { span: sp }); - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatIdentsMissingComma { span: sp }); + return DummyResult::any(sp, guar); } } } else { @@ -36,8 +36,8 @@ pub fn expand_concat_idents<'cx>( } } - cx.dcx().emit_err(errors::ConcatIdentsIdentArgs { span: sp }); - return DummyResult::any(sp); + let guar = cx.dcx().emit_err(errors::ConcatIdentsIdentArgs { span: sp }); + return DummyResult::any(sp, guar); } } @@ -47,21 +47,21 @@ pub fn expand_concat_idents<'cx>( ident: Ident, } - impl base::MacResult for ConcatIdentsResult { - fn make_expr(self: Box) -> Option> { - Some(P(ast::Expr { - id: ast::DUMMY_NODE_ID, - kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)), + impl MacResult for ConcatIdentsResult { + fn make_expr(self: Box) -> Option> { + Some(P(Expr { + id: DUMMY_NODE_ID, + kind: ExprKind::Path(None, Path::from_ident(self.ident)), span: self.ident.span, - attrs: ast::AttrVec::new(), + attrs: AttrVec::new(), tokens: None, })) } - fn make_ty(self: Box) -> Option> { - Some(P(ast::Ty { - id: ast::DUMMY_NODE_ID, - kind: ast::TyKind::Path(None, ast::Path::from_ident(self.ident)), + fn make_ty(self: Box) -> Option> { + Some(P(Ty { + id: DUMMY_NODE_ID, + kind: TyKind::Path(None, Path::from_ident(self.ident)), span: self.ident.span, tokens: None, })) diff --git a/compiler/rustc_builtin_macros/src/deriving/decodable.rs b/compiler/rustc_builtin_macros/src/deriving/decodable.rs index 97d6b82de98c6..bf4693cd54198 100644 --- a/compiler/rustc_builtin_macros/src/deriving/decodable.rs +++ b/compiler/rustc_builtin_macros/src/deriving/decodable.rs @@ -198,7 +198,7 @@ where match fields { Unnamed(fields, is_tuple) => { let path_expr = cx.expr_path(outer_pat_path); - if !*is_tuple { + if matches!(is_tuple, IsTuple::No) { path_expr } else { let fields = fields diff --git a/compiler/rustc_builtin_macros/src/deriving/default.rs b/compiler/rustc_builtin_macros/src/deriving/default.rs index d5a42566e1912..386d4a54b655b 100644 --- a/compiler/rustc_builtin_macros/src/deriving/default.rs +++ b/compiler/rustc_builtin_macros/src/deriving/default.rs @@ -6,7 +6,7 @@ use rustc_ast::{attr, walk_list, EnumDef, VariantData}; use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt}; use rustc_span::symbol::Ident; use rustc_span::symbol::{kw, sym}; -use rustc_span::Span; +use rustc_span::{ErrorGuaranteed, Span}; use smallvec::SmallVec; use thin_vec::{thin_vec, ThinVec}; @@ -62,8 +62,8 @@ fn default_struct_substructure( let default_call = |span| cx.expr_call_global(span, default_ident.clone(), ThinVec::new()); let expr = match summary { - Unnamed(_, false) => cx.expr_ident(trait_span, substr.type_ident), - Unnamed(fields, true) => { + Unnamed(_, IsTuple::No) => cx.expr_ident(trait_span, substr.type_ident), + Unnamed(fields, IsTuple::Yes) => { let exprs = fields.iter().map(|sp| default_call(*sp)).collect(); cx.expr_call_ident(trait_span, substr.type_ident, exprs) } @@ -83,16 +83,19 @@ fn default_enum_substructure( trait_span: Span, enum_def: &EnumDef, ) -> BlockOrExpr { - let expr = if let Ok(default_variant) = extract_default_variant(cx, enum_def, trait_span) - && let Ok(_) = validate_default_attribute(cx, default_variant) - { - // We now know there is exactly one unit variant with exactly one `#[default]` attribute. - cx.expr_path(cx.path( - default_variant.span, - vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident], - )) - } else { - DummyResult::raw_expr(trait_span, true) + let expr = match try { + let default_variant = extract_default_variant(cx, enum_def, trait_span)?; + validate_default_attribute(cx, default_variant)?; + default_variant + } { + Ok(default_variant) => { + // We now know there is exactly one unit variant with exactly one `#[default]` attribute. + cx.expr_path(cx.path( + default_variant.span, + vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident], + )) + } + Err(guar) => DummyResult::raw_expr(trait_span, Some(guar)), }; BlockOrExpr::new_expr(expr) } @@ -101,7 +104,7 @@ fn extract_default_variant<'a>( cx: &mut ExtCtxt<'_>, enum_def: &'a EnumDef, trait_span: Span, -) -> Result<&'a rustc_ast::Variant, ()> { +) -> Result<&'a rustc_ast::Variant, ErrorGuaranteed> { let default_variants: SmallVec<[_; 1]> = enum_def .variants .iter() @@ -120,9 +123,9 @@ fn extract_default_variant<'a>( let suggs = possible_defaults .map(|v| errors::NoDefaultVariantSugg { span: v.span, ident: v.ident }) .collect(); - cx.dcx().emit_err(errors::NoDefaultVariant { span: trait_span, suggs }); + let guar = cx.dcx().emit_err(errors::NoDefaultVariant { span: trait_span, suggs }); - return Err(()); + return Err(guar); } [first, rest @ ..] => { let suggs = default_variants @@ -140,28 +143,28 @@ fn extract_default_variant<'a>( .then_some(errors::MultipleDefaultsSugg { spans, ident: variant.ident }) }) .collect(); - cx.dcx().emit_err(errors::MultipleDefaults { + let guar = cx.dcx().emit_err(errors::MultipleDefaults { span: trait_span, first: first.span, additional: rest.iter().map(|v| v.span).collect(), suggs, }); - return Err(()); + return Err(guar); } }; if !matches!(variant.data, VariantData::Unit(..)) { - cx.dcx().emit_err(errors::NonUnitDefault { span: variant.ident.span }); - return Err(()); + let guar = cx.dcx().emit_err(errors::NonUnitDefault { span: variant.ident.span }); + return Err(guar); } if let Some(non_exhaustive_attr) = attr::find_by_name(&variant.attrs, sym::non_exhaustive) { - cx.dcx().emit_err(errors::NonExhaustiveDefault { + let guar = cx.dcx().emit_err(errors::NonExhaustiveDefault { span: variant.ident.span, non_exhaustive: non_exhaustive_attr.span, }); - return Err(()); + return Err(guar); } Ok(variant) @@ -170,7 +173,7 @@ fn extract_default_variant<'a>( fn validate_default_attribute( cx: &mut ExtCtxt<'_>, default_variant: &rustc_ast::Variant, -) -> Result<(), ()> { +) -> Result<(), ErrorGuaranteed> { let attrs: SmallVec<[_; 1]> = attr::filter_by_name(&default_variant.attrs, kw::Default).collect(); @@ -183,7 +186,7 @@ fn validate_default_attribute( let sugg = errors::MultipleDefaultAttrsSugg { spans: rest.iter().map(|attr| attr.span).collect(), }; - cx.dcx().emit_err(errors::MultipleDefaultAttrs { + let guar = cx.dcx().emit_err(errors::MultipleDefaultAttrs { span: default_variant.ident.span, first: first.span, first_rest: rest[0].span, @@ -192,13 +195,13 @@ fn validate_default_attribute( sugg, }); - return Err(()); + return Err(guar); } }; if !attr.is_word() { - cx.dcx().emit_err(errors::DefaultHasArg { span: attr.span }); + let guar = cx.dcx().emit_err(errors::DefaultHasArg { span: attr.span }); - return Err(()); + return Err(guar); } Ok(()) } diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 6eeb028728c9d..3ee4fded74999 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -286,10 +286,16 @@ pub struct FieldInfo { pub other_selflike_exprs: Vec>, } +#[derive(Copy, Clone)] +pub enum IsTuple { + No, + Yes, +} + /// Fields for a static method pub enum StaticFields { /// Tuple and unit structs/enum variants like this. - Unnamed(Vec, bool /*is tuple*/), + Unnamed(Vec, IsTuple), /// Normal structs/struct variants. Named(Vec<(Ident, Span)>), } @@ -1439,7 +1445,10 @@ impl<'a> TraitDef<'a> { } } - let is_tuple = matches!(struct_def, ast::VariantData::Tuple(..)); + let is_tuple = match struct_def { + ast::VariantData::Tuple(..) => IsTuple::Yes, + _ => IsTuple::No, + }; match (just_spans.is_empty(), named_idents.is_empty()) { (false, false) => cx .dcx() diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs index a0fd0e3f9be08..f057d44bf710a 100644 --- a/compiler/rustc_builtin_macros/src/env.rs +++ b/compiler/rustc_builtin_macros/src/env.rs @@ -3,9 +3,13 @@ // interface. // +use rustc_ast::token::{self, LitKind}; use rustc_ast::tokenstream::TokenStream; -use rustc_ast::{self as ast, AstDeref, GenericArg}; -use rustc_expand::base::{self, *}; +use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability}; +use rustc_expand::base::{ + expr_to_string, get_exprs_from_tts, get_single_str_from_tts, DummyResult, ExtCtxt, MacEager, + MacResult, +}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; use std::env; @@ -27,9 +31,10 @@ pub fn expand_option_env<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { - let Some(var) = get_single_str_from_tts(cx, sp, tts, "option_env!") else { - return DummyResult::any(sp); +) -> Box { + let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") { + Ok(var) => var, + Err(guar) => return DummyResult::any(sp, guar), }; let sp = cx.with_def_site_ctxt(sp); @@ -46,7 +51,7 @@ pub fn expand_option_env<'cx>( sp, cx.ty_ident(sp, Ident::new(sym::str, sp)), Some(lt), - ast::Mutability::Not, + Mutability::Not, ))], )) } @@ -63,26 +68,27 @@ pub fn expand_env<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let mut exprs = match get_exprs_from_tts(cx, tts) { - Some(exprs) if exprs.is_empty() || exprs.len() > 2 => { - cx.dcx().emit_err(errors::EnvTakesArgs { span: sp }); - return DummyResult::any(sp); + Ok(exprs) if exprs.is_empty() || exprs.len() > 2 => { + let guar = cx.dcx().emit_err(errors::EnvTakesArgs { span: sp }); + return DummyResult::any(sp, guar); } - None => return DummyResult::any(sp), - Some(exprs) => exprs.into_iter(), + Err(guar) => return DummyResult::any(sp, guar), + Ok(exprs) => exprs.into_iter(), }; let var_expr = exprs.next().unwrap(); - let Some((var, _)) = expr_to_string(cx, var_expr.clone(), "expected string literal") else { - return DummyResult::any(sp); + let var = match expr_to_string(cx, var_expr.clone(), "expected string literal") { + Ok((var, _)) => var, + Err(guar) => return DummyResult::any(sp, guar), }; let custom_msg = match exprs.next() { None => None, Some(second) => match expr_to_string(cx, second, "expected string literal") { - None => return DummyResult::any(sp), - Some((s, _)) => Some(s), + Ok((s, _)) => Some(s), + Err(guar) => return DummyResult::any(sp, guar), }, }; @@ -91,32 +97,30 @@ pub fn expand_env<'cx>( cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value)); let e = match value { None => { - let ast::ExprKind::Lit(ast::token::Lit { - kind: ast::token::LitKind::Str | ast::token::LitKind::StrRaw(..), - symbol, - .. + let ExprKind::Lit(token::Lit { + kind: LitKind::Str | LitKind::StrRaw(..), symbol, .. }) = &var_expr.kind else { unreachable!("`expr_to_string` ensures this is a string lit") }; - if let Some(msg_from_user) = custom_msg { - cx.dcx().emit_err(errors::EnvNotDefinedWithUserMessage { span, msg_from_user }); + let guar = if let Some(msg_from_user) = custom_msg { + cx.dcx().emit_err(errors::EnvNotDefinedWithUserMessage { span, msg_from_user }) } else if is_cargo_env_var(var.as_str()) { cx.dcx().emit_err(errors::EnvNotDefined::CargoEnvVar { span, var: *symbol, var_expr: var_expr.ast_deref(), - }); + }) } else { cx.dcx().emit_err(errors::EnvNotDefined::CustomEnvVar { span, var: *symbol, var_expr: var_expr.ast_deref(), - }); - } + }) + }; - return DummyResult::any(sp); + return DummyResult::any(sp, guar); } Some(value) => cx.expr_str(span, value), }; diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index f304a37be854b..6546a35734c63 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -1,6 +1,6 @@ use rustc_errors::{ - codes::*, AddToDiagnostic, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, - Level, MultiSpan, SingleLabelManySpans, SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level, MultiSpan, + SingleLabelManySpans, SubdiagnosticMessageOp, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{symbol::Ident, Span, Symbol}; @@ -136,27 +136,6 @@ pub(crate) struct BenchSig { pub(crate) span: Span, } -#[derive(Diagnostic)] -#[diag(builtin_macros_test_arg_non_lifetime)] -pub(crate) struct TestArgNonLifetime { - #[primary_span] - pub(crate) span: Span, -} - -#[derive(Diagnostic)] -#[diag(builtin_macros_should_panic)] -pub(crate) struct ShouldPanic { - #[primary_span] - pub(crate) span: Span, -} - -#[derive(Diagnostic)] -#[diag(builtin_macros_test_args)] -pub(crate) struct TestArgs { - #[primary_span] - pub(crate) span: Span, -} - #[derive(Diagnostic)] #[diag(builtin_macros_alloc_must_statics)] pub(crate) struct AllocMustStatics { @@ -448,12 +427,12 @@ pub(crate) struct EnvNotDefinedWithUserMessage { // Hand-written implementation to support custom user messages. impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefinedWithUserMessage { #[track_caller] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { #[expect( rustc::untranslatable_diagnostic, reason = "cannot translate user-provided messages" )] - let mut diag = DiagnosticBuilder::new(dcx, level, self.msg_from_user.to_string()); + let mut diag = Diag::new(dcx, level, self.msg_from_user.to_string()); diag.span(self.span); diag } @@ -613,7 +592,7 @@ pub(crate) struct FormatUnusedArg { impl AddToDiagnostic for FormatUnusedArg { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ) { diag.arg("named", self.named); @@ -800,7 +779,7 @@ pub(crate) struct AsmClobberNoReg { } impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { // eager translation as `span_labels` takes `AsRef` let lbl1 = dcx.eagerly_translate_to_string( crate::fluent_generated::builtin_macros_asm_clobber_abi, @@ -810,14 +789,10 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg { crate::fluent_generated::builtin_macros_asm_clobber_outputs, [].into_iter(), ); - DiagnosticBuilder::new( - dcx, - level, - crate::fluent_generated::builtin_macros_asm_clobber_no_reg, - ) - .with_span(self.spans.clone()) - .with_span_labels(self.clobbers, &lbl1) - .with_span_labels(self.spans, &lbl2) + Diag::new(dcx, level, crate::fluent_generated::builtin_macros_asm_clobber_no_reg) + .with_span(self.spans.clone()) + .with_span_labels(self.clobbers, &lbl1) + .with_span_labels(self.spans, &lbl2) } } diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index b66f7111ff006..0ce9d7ead8217 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -8,11 +8,12 @@ use rustc_ast::{ FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, }; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan, PResult, SingleLabelManySpans}; +use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans}; use rustc_expand::base::{self, *}; +use rustc_parse::parser::Recovered; use rustc_parse_format as parse; use rustc_span::symbol::{Ident, Symbol}; -use rustc_span::{BytePos, InnerSpan, Span}; +use rustc_span::{BytePos, ErrorGuaranteed, InnerSpan, Span}; use rustc_lint_defs::builtin::NAMED_ARGUMENTS_USED_POSITIONALLY; use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics, LintId}; @@ -111,9 +112,8 @@ fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult< _ => return Err(err), } } - Ok(recovered) => { - assert!(recovered); - } + Ok(Recovered::Yes) => (), + Ok(Recovered::No) => unreachable!(), } } first = false; @@ -160,7 +160,7 @@ fn make_format_args( ecx: &mut ExtCtxt<'_>, input: MacroInput, append_newline: bool, -) -> Result { +) -> Result { let msg = "format argument must be a string literal"; let unexpanded_fmt_span = input.fmtstr.span; @@ -173,38 +173,41 @@ fn make_format_args( } Ok(fmt) => fmt, Err(err) => { - if let Some((mut err, suggested)) = err { - if !suggested { - if let ExprKind::Block(block, None) = &efmt.kind - && block.stmts.len() == 1 - && let StmtKind::Expr(expr) = &block.stmts[0].kind - && let ExprKind::Path(None, path) = &expr.kind - && path.is_potential_trivial_const_arg() - { - err.multipart_suggestion( - "quote your inlined format argument to use as string literal", - vec![ - (unexpanded_fmt_span.shrink_to_hi(), "\"".to_string()), - (unexpanded_fmt_span.shrink_to_lo(), "\"".to_string()), - ], - Applicability::MaybeIncorrect, - ); - } else { - let sugg_fmt = match args.explicit_args().len() { - 0 => "{}".to_string(), - _ => format!("{}{{}}", "{} ".repeat(args.explicit_args().len())), - }; - err.span_suggestion( - unexpanded_fmt_span.shrink_to_lo(), - "you might be missing a string literal to format with", - format!("\"{sugg_fmt}\", "), - Applicability::MaybeIncorrect, - ); + let guar = match err { + Ok((mut err, suggested)) => { + if !suggested { + if let ExprKind::Block(block, None) = &efmt.kind + && block.stmts.len() == 1 + && let StmtKind::Expr(expr) = &block.stmts[0].kind + && let ExprKind::Path(None, path) = &expr.kind + && path.is_potential_trivial_const_arg() + { + err.multipart_suggestion( + "quote your inlined format argument to use as string literal", + vec![ + (unexpanded_fmt_span.shrink_to_hi(), "\"".to_string()), + (unexpanded_fmt_span.shrink_to_lo(), "\"".to_string()), + ], + Applicability::MaybeIncorrect, + ); + } else { + let sugg_fmt = match args.explicit_args().len() { + 0 => "{}".to_string(), + _ => format!("{}{{}}", "{} ".repeat(args.explicit_args().len())), + }; + err.span_suggestion( + unexpanded_fmt_span.shrink_to_lo(), + "you might be missing a string literal to format with", + format!("\"{sugg_fmt}\", "), + Applicability::MaybeIncorrect, + ); + } } + err.emit() } - err.emit(); - } - return Err(()); + Err(guar) => guar, + }; + return Err(guar); } }; @@ -293,8 +296,8 @@ fn make_format_args( } } } - ecx.dcx().emit_err(e); - return Err(()); + let guar = ecx.dcx().emit_err(e); + return Err(guar); } let to_span = |inner_span: rustc_parse_format::InnerSpan| { @@ -353,9 +356,9 @@ fn make_format_args( } else { // For the moment capturing variables from format strings expanded from macros is // disabled (see RFC #2795) - ecx.dcx().emit_err(errors::FormatNoArgNamed { span, name }); + let guar = ecx.dcx().emit_err(errors::FormatNoArgNamed { span, name }); unnamed_arg_after_named_arg = true; - DummyResult::raw_expr(span, true) + DummyResult::raw_expr(span, Some(guar)) }; Ok(args.add(FormatArgument { kind: FormatArgumentKind::Captured(ident), expr })) } @@ -727,7 +730,7 @@ fn report_redundant_format_arguments<'a>( args: &FormatArguments, used: &[bool], placeholders: Vec<(Span, &str)>, -) -> Option> { +) -> Option> { let mut fmt_arg_indices = vec![]; let mut args_spans = vec![]; let mut fmt_spans = vec![]; @@ -972,16 +975,13 @@ fn expand_format_args_impl<'cx>( ) -> Box { sp = ecx.with_def_site_ctxt(sp); match parse_args(ecx, sp, tts) { - Ok(input) => { - if let Ok(format_args) = make_format_args(ecx, input, nl) { - MacEager::expr(ecx.expr(sp, ExprKind::FormatArgs(P(format_args)))) - } else { - MacEager::expr(DummyResult::raw_expr(sp, true)) - } - } + Ok(input) => match make_format_args(ecx, input, nl) { + Ok(format_args) => MacEager::expr(ecx.expr(sp, ExprKind::FormatArgs(P(format_args)))), + Err(guar) => MacEager::expr(DummyResult::raw_expr(sp, Some(guar))), + }, Err(err) => { - err.emit(); - DummyResult::any(sp) + let guar = err.emit(); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index d30ccab239437..f344dbcd10c06 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -15,6 +15,7 @@ #![feature(lint_reasons)] #![feature(proc_macro_internals)] #![feature(proc_macro_quote)] +#![feature(try_blocks)] extern crate proc_macro; diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index 43d13569d1ee1..8e0978de23748 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -3,7 +3,10 @@ use rustc_ast::ptr::P; use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_ast_pretty::pprust; -use rustc_expand::base::{self, *}; +use rustc_expand::base::{ + check_zero_tts, get_single_str_from_tts, parse_expr, resolve_path, DummyResult, ExtCtxt, + MacEager, MacResult, +}; use rustc_expand::module::DirOwnership; use rustc_parse::new_parser_from_file; use rustc_parse::parser::{ForceCollect, Parser}; @@ -23,14 +26,14 @@ pub fn expand_line( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "line!"); + check_zero_tts(cx, sp, tts, "line!"); let topmost = cx.expansion_cause().unwrap_or(sp); let loc = cx.source_map().lookup_char_pos(topmost.lo()); - base::MacEager::expr(cx.expr_u32(topmost, loc.line as u32)) + MacEager::expr(cx.expr_u32(topmost, loc.line as u32)) } /* column!(): expands to the current column number */ @@ -38,14 +41,14 @@ pub fn expand_column( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "column!"); + check_zero_tts(cx, sp, tts, "column!"); let topmost = cx.expansion_cause().unwrap_or(sp); let loc = cx.source_map().lookup_char_pos(topmost.lo()); - base::MacEager::expr(cx.expr_u32(topmost, loc.col.to_usize() as u32 + 1)) + MacEager::expr(cx.expr_u32(topmost, loc.col.to_usize() as u32 + 1)) } /// file!(): expands to the current filename */ @@ -55,15 +58,15 @@ pub fn expand_file( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "file!"); + check_zero_tts(cx, sp, tts, "file!"); let topmost = cx.expansion_cause().unwrap_or(sp); let loc = cx.source_map().lookup_char_pos(topmost.lo()); use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; - base::MacEager::expr(cx.expr_str( + MacEager::expr(cx.expr_str( topmost, Symbol::intern( &loc.file.name.for_scope(cx.sess, RemapPathScopeComponents::MACRO).to_string_lossy(), @@ -75,23 +78,23 @@ pub fn expand_stringify( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); let s = pprust::tts_to_string(&tts); - base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&s))) + MacEager::expr(cx.expr_str(sp, Symbol::intern(&s))) } pub fn expand_mod( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - base::check_zero_tts(cx, sp, tts, "module_path!"); + check_zero_tts(cx, sp, tts, "module_path!"); let mod_path = &cx.current_expansion.module.mod_path; let string = mod_path.iter().map(|x| x.to_string()).collect::>().join("::"); - base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&string))) + MacEager::expr(cx.expr_str(sp, Symbol::intern(&string))) } /// include! : parse the given file as an expr @@ -101,17 +104,18 @@ pub fn expand_include<'cx>( cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - let Some(file) = get_single_str_from_tts(cx, sp, tts, "include!") else { - return DummyResult::any(sp); + let file = match get_single_str_from_tts(cx, sp, tts, "include!") { + Ok(file) => file, + Err(guar) => return DummyResult::any(sp, guar), }; // The file will be added to the code map by the parser let file = match resolve_path(&cx.sess, file.as_str(), sp) { Ok(f) => f, Err(err) => { - err.emit(); - return DummyResult::any(sp); + let guar = err.emit(); + return DummyResult::any(sp, guar); } }; let p = new_parser_from_file(cx.parse_sess(), &file, Some(sp)); @@ -128,9 +132,9 @@ pub fn expand_include<'cx>( p: Parser<'a>, node_id: ast::NodeId, } - impl<'a> base::MacResult for ExpandResult<'a> { + impl<'a> MacResult for ExpandResult<'a> { fn make_expr(mut self: Box>) -> Option> { - let r = base::parse_expr(&mut self.p)?; + let expr = parse_expr(&mut self.p).ok()?; if self.p.token != token::Eof { self.p.sess.buffer_lint( INCOMPLETE_INCLUDE, @@ -139,7 +143,7 @@ pub fn expand_include<'cx>( "include macro expected single expression in source", ); } - Some(r) + Some(expr) } fn make_items(mut self: Box>) -> Option; 1]>> { @@ -174,32 +178,33 @@ pub fn expand_include_str( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_str!") else { - return DummyResult::any(sp); + let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") { + Ok(file) => file, + Err(guar) => return DummyResult::any(sp, guar), }; let file = match resolve_path(&cx.sess, file.as_str(), sp) { Ok(f) => f, Err(err) => { - err.emit(); - return DummyResult::any(sp); + let guar = err.emit(); + return DummyResult::any(sp, guar); } }; match cx.source_map().load_binary_file(&file) { Ok(bytes) => match std::str::from_utf8(&bytes) { Ok(src) => { let interned_src = Symbol::intern(src); - base::MacEager::expr(cx.expr_str(sp, interned_src)) + MacEager::expr(cx.expr_str(sp, interned_src)) } Err(_) => { - cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display())); - DummyResult::any(sp) + let guar = cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display())); + DummyResult::any(sp, guar) } }, Err(e) => { - cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); - DummyResult::any(sp) + let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); + DummyResult::any(sp, guar) } } } @@ -208,26 +213,27 @@ pub fn expand_include_bytes( cx: &mut ExtCtxt<'_>, sp: Span, tts: TokenStream, -) -> Box { +) -> Box { let sp = cx.with_def_site_ctxt(sp); - let Some(file) = get_single_str_from_tts(cx, sp, tts, "include_bytes!") else { - return DummyResult::any(sp); + let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") { + Ok(file) => file, + Err(guar) => return DummyResult::any(sp, guar), }; let file = match resolve_path(&cx.sess, file.as_str(), sp) { Ok(f) => f, Err(err) => { - err.emit(); - return DummyResult::any(sp); + let guar = err.emit(); + return DummyResult::any(sp, guar); } }; match cx.source_map().load_binary_file(&file) { Ok(bytes) => { let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes)); - base::MacEager::expr(expr) + MacEager::expr(expr) } Err(e) => { - cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); - DummyResult::any(sp) + let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); + DummyResult::any(sp, guar) } } } diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 0631f796894b1..81ac78dd58fa6 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -5,7 +5,7 @@ use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute}; use rustc_ast::ptr::P; use rustc_ast::{self as ast, attr, GenericParamKind}; use rustc_ast_pretty::pprust; -use rustc_errors::{Applicability, DiagnosticBuilder, Level}; +use rustc_errors::{Applicability, Diag, Level}; use rustc_expand::base::*; use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Span}; @@ -410,7 +410,7 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) Some(ast::ItemKind::MacCall(_)) => Level::Warning, _ => Level::Error, }; - let mut err = DiagnosticBuilder::<()>::new(dcx, level, msg); + let mut err = Diag::<()>::new(dcx, level, msg); err.span(attr_sp); if let Some(item) = item { err.span_label( diff --git a/compiler/rustc_builtin_macros/src/type_ascribe.rs b/compiler/rustc_builtin_macros/src/type_ascribe.rs index 564797012ae26..e8b8fe75338cb 100644 --- a/compiler/rustc_builtin_macros/src/type_ascribe.rs +++ b/compiler/rustc_builtin_macros/src/type_ascribe.rs @@ -13,8 +13,8 @@ pub fn expand_type_ascribe( let (expr, ty) = match parse_ascribe(cx, tts) { Ok(parsed) => parsed, Err(err) => { - err.emit(); - return DummyResult::any(span); + let guar = err.emit(); + return DummyResult::any(span, guar); } }; diff --git a/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs b/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs index 80a2776ca1e2f..a71217a554b57 100644 --- a/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs +++ b/compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs @@ -4,17 +4,14 @@ // Test that the simd_f{min,max} intrinsics produce the correct results. -#![feature(repr_simd, platform_intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub f32, pub f32, pub f32, pub f32); -extern "platform-intrinsic" { - fn simd_fmin(x: T, y: T) -> T; - fn simd_fmax(x: T, y: T) -> T; -} +use std::intrinsics::simd::*; fn main() { let x = f32x4(1.0, 2.0, 3.0, 4.0); diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index a79909ce0c878..47db7ee369186 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -8,6 +8,7 @@ rustc_attrs, transparent_unions, auto_traits, + freeze_impls, thread_local )] #![no_core] diff --git a/compiler/rustc_codegen_cranelift/patches/0029-stdlib-rawdylib-processprng.patch b/compiler/rustc_codegen_cranelift/patches/0029-stdlib-rawdylib-processprng.patch new file mode 100644 index 0000000000000..6af11e54d88af --- /dev/null +++ b/compiler/rustc_codegen_cranelift/patches/0029-stdlib-rawdylib-processprng.patch @@ -0,0 +1,47 @@ +From 9f65e742ba3e41474e6126c6c4469c48eaa6ca7e Mon Sep 17 00:00:00 2001 +From: Chris Denton +Date: Tue, 20 Feb 2024 16:01:40 -0300 +Subject: [PATCH] Don't use raw-dylib in std + +--- + library/std/src/sys/pal/windows/c.rs | 2 +- + library/std/src/sys/pal/windows/rand.rs | 3 +-- + 2 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs +index ad8e01bfa9b..9ca8e4c16ce 100644 +--- a/library/std/src/sys/pal/windows/c.rs ++++ b/library/std/src/sys/pal/windows/c.rs +@@ -323,7 +323,7 @@ pub unsafe fn NtWriteFile( + + // Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. + cfg_if::cfg_if! { +-if #[cfg(not(target_vendor = "win7"))] { ++if #[cfg(any())] { + #[cfg(target_arch = "x86")] + #[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")] + extern "system" { +diff --git a/library/std/src/sys/pal/windows/rand.rs b/library/std/src/sys/pal/windows/rand.rs +index e427546222a..f2fe42a4d51 100644 +--- a/library/std/src/sys/pal/windows/rand.rs ++++ b/library/std/src/sys/pal/windows/rand.rs +@@ -2,7 +2,7 @@ + use core::mem; + use core::ptr; + +-#[cfg(not(target_vendor = "win7"))] ++#[cfg(any())] + #[inline] + pub fn hashmap_random_keys() -> (u64, u64) { + let mut v = (0, 0); +@@ -13,7 +13,6 @@ pub fn hashmap_random_keys() -> (u64, u64) { + v + } + +-#[cfg(target_vendor = "win7")] + pub fn hashmap_random_keys() -> (u64, u64) { + use crate::ffi::c_void; + use crate::io; +-- +2.42.0.windows.2 + diff --git a/compiler/rustc_codegen_cranelift/src/archive.rs b/compiler/rustc_codegen_cranelift/src/archive.rs index 5a29bc18def54..414d3db1c51a1 100644 --- a/compiler/rustc_codegen_cranelift/src/archive.rs +++ b/compiler/rustc_codegen_cranelift/src/archive.rs @@ -8,7 +8,7 @@ use rustc_session::Session; pub(crate) struct ArArchiveBuilderBuilder; impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { - fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box + 'a> { + fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box { Box::new(ArArchiveBuilder::new(sess, get_native_object_symbols)) } diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index 199d5df29e7d0..84269ec294263 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -23,7 +23,7 @@ use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement}; use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; use rustc_middle::ty::GenericArgsRef; use rustc_span::source_map::Spanned; -use rustc_span::symbol::{kw, sym, Symbol}; +use rustc_span::symbol::{sym, Symbol}; pub(crate) use self::llvm::codegen_llvm_intrinsic_call; use crate::prelude::*; @@ -1132,7 +1132,7 @@ fn codegen_regular_intrinsic_call<'tcx>( ret.write_cvalue(fx, val); } - kw::Try => { + sym::catch_unwind => { intrinsic_args!(fx, args => (f, data, catch_fn); intrinsic); let f = f.load_scalar(fx); let data = data.load_scalar(fx); diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs index 230009741dc41..1f364f78ece76 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -1,6 +1,6 @@ #![feature( no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, - decl_macro, rustc_attrs, transparent_unions, auto_traits, + decl_macro, rustc_attrs, transparent_unions, auto_traits, freeze_impls, thread_local )] #![no_core] diff --git a/compiler/rustc_codegen_gcc/src/archive.rs b/compiler/rustc_codegen_gcc/src/archive.rs index 11fa074f5ac79..73ff0c37b6656 100644 --- a/compiler/rustc_codegen_gcc/src/archive.rs +++ b/compiler/rustc_codegen_gcc/src/archive.rs @@ -10,7 +10,7 @@ use rustc_session::cstore::DllImport; pub(crate) struct ArArchiveBuilderBuilder; impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { - fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box + 'a> { + fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box { Box::new(ArArchiveBuilder::new(sess, get_native_object_symbols)) } diff --git a/compiler/rustc_codegen_gcc/src/errors.rs b/compiler/rustc_codegen_gcc/src/errors.rs index 79eb4406b8a33..988a7e1033e28 100644 --- a/compiler/rustc_codegen_gcc/src/errors.rs +++ b/compiler/rustc_codegen_gcc/src/errors.rs @@ -1,6 +1,5 @@ use rustc_errors::{ - DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, - IntoDiagnosticArg, Level, + DiagCtxt, DiagArgValue, Diag, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; @@ -35,11 +34,11 @@ pub(crate) enum PossibleFeature<'a> { struct ExitCode(Option); impl IntoDiagnosticArg for ExitCode { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { let ExitCode(exit_code) = self; match exit_code { Some(t) => t.into_diagnostic_arg(), - None => DiagnosticArgValue::Str(Cow::Borrowed("")), + None => DiagArgValue::Str(Cow::Borrowed("")), } } } @@ -112,12 +111,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> { pub(crate) struct MissingFeatures; impl IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> { - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new( - dcx, - level, - fluent::codegen_gcc_target_feature_disable_or_enable - ); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::codegen_gcc_target_feature_disable_or_enable); if let Some(span) = self.span { diag.span(span); }; diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index f162ef831b768..d43f5d74757ae 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::ty::layout::LayoutOf; #[cfg(feature="master")] use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; -use rustc_span::{Span, Symbol, symbol::kw, sym}; +use rustc_span::{Span, Symbol, sym}; use rustc_target::abi::HasDataLayout; use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; use rustc_target::spec::PanicStrategy; @@ -129,7 +129,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { let res = self.context.new_call(None, builtin, &[a]); self.icmp(IntPredicate::IntEQ, res, self.const_i32(0)) } - kw::Try => { + sym::catch_unwind => { try_intrinsic( self, args[0].immediate(), diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 67bc86e4c9026..ca43ac4b0e71a 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -60,7 +60,7 @@ fn llvm_machine_type(cpu: &str) -> LLVMMachineType { } } -impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { +impl<'a> ArchiveBuilder for LlvmArchiveBuilder<'a> { fn add_archive( &mut self, archive: &Path, @@ -107,7 +107,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { pub struct LlvmArchiveBuilderBuilder; impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder { - fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box + 'a> { + fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box { // FIXME use ArArchiveBuilder on most targets again once reading thin archives is // implemented if true { @@ -313,7 +313,7 @@ fn get_llvm_object_symbols( llvm::LLVMRustGetSymbols( buf.as_ptr(), buf.len(), - &mut *state as *mut &mut _ as *mut c_void, + std::ptr::addr_of_mut!(*state) as *mut c_void, callback, error_callback, ) diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 27cb0366f17dc..08aab84986800 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -36,7 +36,7 @@ use rustc_span::InnerSpan; use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; use crate::llvm::diagnostic::OptimizationDiagnosticKind; -use libc::{c_char, c_int, c_uint, c_void, size_t}; +use libc::{c_char, c_int, c_void, size_t}; use std::ffi::CString; use std::fs; use std::io::{self, Write}; @@ -406,7 +406,7 @@ fn report_inline_asm( cgcx: &CodegenContext, msg: String, level: llvm::DiagnosticLevel, - mut cookie: c_uint, + mut cookie: u64, source: Option<(String, Vec)>, ) { // In LTO build we may get srcloc values from other crates which are invalid @@ -420,7 +420,7 @@ fn report_inline_asm( llvm::DiagnosticLevel::Warning => Level::Warning, llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note, }; - cgcx.diag_emitter.inline_asm_error(cookie as u32, msg, level, source); + cgcx.diag_emitter.inline_asm_error(cookie.try_into().unwrap(), msg, level, source); } unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) { diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index 24b3aa4223a4e..5bef240340ba5 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -4,7 +4,7 @@ use std::path::Path; use crate::fluent_generated as fluent; use rustc_data_structures::small_c_str::SmallCStr; -use rustc_errors::{DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level}; +use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; @@ -100,11 +100,11 @@ pub(crate) struct DynamicLinkingWithLTO; pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>); impl IntoDiagnostic<'_, G> for ParseTargetMachineConfig<'_> { - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let diag: DiagnosticBuilder<'_, G> = self.0.into_diagnostic(dcx, level); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let diag: Diag<'_, G> = self.0.into_diagnostic(dcx, level); let (message, _) = diag.messages.first().expect("`LlvmError` with no message"); let message = dcx.eagerly_translate_to_string(message.clone(), diag.args.iter()); - DiagnosticBuilder::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config) + Diag::new(dcx, level, fluent::codegen_llvm_parse_target_machine_config) .with_arg("error", message) } } @@ -120,12 +120,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> { pub(crate) struct MissingFeatures; impl IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> { - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new( - dcx, - level, - fluent::codegen_llvm_target_feature_disable_or_enable, - ); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::codegen_llvm_target_feature_disable_or_enable); if let Some(span) = self.span { diag.span(span); }; @@ -184,7 +180,7 @@ pub enum LlvmError<'a> { pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String); impl IntoDiagnostic<'_, G> for WithLlvmError<'_> { - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { use LlvmError::*; let msg_with_llvm_err = match &self.0 { WriteOutput { .. } => fluent::codegen_llvm_write_output_with_llvm_err, diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 23e6f054a7c1e..e5de2f783765b 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -17,7 +17,7 @@ use rustc_hir as hir; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf}; use rustc_middle::ty::{self, GenericArgsRef, Ty}; use rustc_middle::{bug, span_bug}; -use rustc_span::{sym, symbol::kw, Span, Symbol}; +use rustc_span::{sym, Span, Symbol}; use rustc_target::abi::{self, Align, HasDataLayout, Primitive}; use rustc_target::spec::{HasTargetSpec, PanicStrategy}; @@ -133,8 +133,8 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { } sym::unlikely => self .call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(false)]), - kw::Try => { - try_intrinsic( + sym::catch_unwind => { + catch_unwind_intrinsic( self, args[0].immediate(), args[1].immediate(), @@ -457,7 +457,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { } } -fn try_intrinsic<'ll>( +fn catch_unwind_intrinsic<'ll>( bx: &mut Builder<'_, 'll, '_>, try_func: &'ll Value, data: &'ll Value, @@ -1079,7 +1079,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>( .map(|(arg_idx, val)| { let idx = val.unwrap_leaf().try_to_i32().unwrap(); if idx >= i32::try_from(total_len).unwrap() { - bx.sess().dcx().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds { + bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds { span, name, arg_idx: arg_idx as u64, @@ -1138,24 +1138,15 @@ fn generic_simd_intrinsic<'ll, 'tcx>( let val = bx.const_get_elt(vector, i as u64); match bx.const_to_opt_u128(val, true) { None => { - bx.sess().dcx().emit_err( - InvalidMonomorphization::ShuffleIndexNotConstant { - span, - name, - arg_idx, - }, - ); - None + bug!("typeck should have already ensured that these are const") } Some(idx) if idx >= total_len => { - bx.sess().dcx().emit_err( - InvalidMonomorphization::ShuffleIndexOutOfBounds { - span, - name, - arg_idx, - total_len, - }, - ); + bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds { + span, + name, + arg_idx, + total_len, + }); None } Some(idx) => Some(bx.const_i32(idx as i32)), @@ -1184,10 +1175,22 @@ fn generic_simd_intrinsic<'ll, 'tcx>( out_ty: arg_tys[2] } ); + let idx = bx + .const_to_opt_u128(args[1].immediate(), false) + .expect("typeck should have ensure that this is a const"); + if idx >= in_len.into() { + bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds { + span, + name, + arg_idx: 1, + total_len: in_len.into(), + }); + return Ok(bx.const_null(llret_ty)); + } return Ok(bx.insert_element( args[0].immediate(), args[2].immediate(), - args[1].immediate(), + bx.const_i32(idx as i32), )); } if name == sym::simd_extract { @@ -1195,7 +1198,19 @@ fn generic_simd_intrinsic<'ll, 'tcx>( ret_ty == in_elem, InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty } ); - return Ok(bx.extract_element(args[0].immediate(), args[1].immediate())); + let idx = bx + .const_to_opt_u128(args[1].immediate(), false) + .expect("typeck should have ensure that this is a const"); + if idx >= in_len.into() { + bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds { + span, + name, + arg_idx: 1, + total_len: in_len.into(), + }); + return Ok(bx.const_null(llret_ty)); + } + return Ok(bx.extract_element(args[0].immediate(), bx.const_i32(idx as i32))); } if name == sym::simd_select { @@ -2091,9 +2106,16 @@ fn generic_simd_intrinsic<'ll, 'tcx>( return Ok(args[0].immediate()); } + #[derive(Copy, Clone)] + enum Sign { + Unsigned, + Signed, + } + use Sign::*; + enum Style { Float, - Int(/* is signed? */ bool), + Int(Sign), Unsupported, } @@ -2101,11 +2123,11 @@ fn generic_simd_intrinsic<'ll, 'tcx>( // vectors of pointer-sized integers should've been // disallowed before here, so this unwrap is safe. ty::Int(i) => ( - Style::Int(true), + Style::Int(Signed), i.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Uint(u) => ( - Style::Int(false), + Style::Int(Unsigned), u.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Float(f) => (Style::Float, f.bit_width()), @@ -2113,11 +2135,11 @@ fn generic_simd_intrinsic<'ll, 'tcx>( }; let (out_style, out_width) = match out_elem.kind() { ty::Int(i) => ( - Style::Int(true), + Style::Int(Signed), i.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Uint(u) => ( - Style::Int(false), + Style::Int(Unsigned), u.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(), ), ty::Float(f) => (Style::Float, f.bit_width()), @@ -2125,31 +2147,31 @@ fn generic_simd_intrinsic<'ll, 'tcx>( }; match (in_style, out_style) { - (Style::Int(in_is_signed), Style::Int(_)) => { + (Style::Int(sign), Style::Int(_)) => { return Ok(match in_width.cmp(&out_width) { Ordering::Greater => bx.trunc(args[0].immediate(), llret_ty), Ordering::Equal => args[0].immediate(), - Ordering::Less => { - if in_is_signed { - bx.sext(args[0].immediate(), llret_ty) - } else { - bx.zext(args[0].immediate(), llret_ty) - } - } + Ordering::Less => match sign { + Sign::Signed => bx.sext(args[0].immediate(), llret_ty), + Sign::Unsigned => bx.zext(args[0].immediate(), llret_ty), + }, }); } - (Style::Int(in_is_signed), Style::Float) => { - return Ok(if in_is_signed { - bx.sitofp(args[0].immediate(), llret_ty) - } else { - bx.uitofp(args[0].immediate(), llret_ty) - }); + (Style::Int(Sign::Signed), Style::Float) => { + return Ok(bx.sitofp(args[0].immediate(), llret_ty)); } - (Style::Float, Style::Int(out_is_signed)) => { - return Ok(match (out_is_signed, name == sym::simd_as) { - (false, false) => bx.fptoui(args[0].immediate(), llret_ty), - (true, false) => bx.fptosi(args[0].immediate(), llret_ty), - (_, true) => bx.cast_float_to_int(out_is_signed, args[0].immediate(), llret_ty), + (Style::Int(Sign::Unsigned), Style::Float) => { + return Ok(bx.uitofp(args[0].immediate(), llret_ty)); + } + (Style::Float, Style::Int(sign)) => { + return Ok(match (sign, name == sym::simd_as) { + (Sign::Unsigned, false) => bx.fptoui(args[0].immediate(), llret_ty), + (Sign::Signed, false) => bx.fptosi(args[0].immediate(), llret_ty), + (_, true) => bx.cast_float_to_int( + matches!(sign, Sign::Signed), + args[0].immediate(), + llret_ty, + ), }); } (Style::Float, Style::Float) => { diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 35210b0b2e86d..c84461e53eb1b 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -169,7 +169,7 @@ impl WriteBackendMethods for LlvmCodegenBackend { fn print_pass_timings(&self) { unsafe { let mut size = 0; - let cstr = llvm::LLVMRustPrintPassTimings(&mut size as *mut usize); + let cstr = llvm::LLVMRustPrintPassTimings(std::ptr::addr_of_mut!(size)); if cstr.is_null() { println!("failed to get pass timings"); } else { @@ -182,7 +182,7 @@ impl WriteBackendMethods for LlvmCodegenBackend { fn print_statistics(&self) { unsafe { let mut size = 0; - let cstr = llvm::LLVMRustPrintStatistics(&mut size as *mut usize); + let cstr = llvm::LLVMRustPrintStatistics(std::ptr::addr_of_mut!(size)); if cstr.is_null() { println!("failed to get pass stats"); } else { diff --git a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs index 06e846a2b45eb..f9b28178ddb97 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs @@ -123,7 +123,7 @@ impl SrcMgrDiagnostic { #[derive(Clone)] pub struct InlineAsmDiagnostic { pub level: super::DiagnosticLevel, - pub cookie: c_uint, + pub cookie: u64, pub message: String, pub source: Option<(String, Vec)>, } @@ -149,7 +149,7 @@ impl InlineAsmDiagnostic { let smdiag = SrcMgrDiagnostic::unpack(super::LLVMRustGetSMDiagnostic(di, &mut cookie)); InlineAsmDiagnostic { level: smdiag.level, - cookie, + cookie: cookie.into(), message: smdiag.message, source: smdiag.source, } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index dbf35e5f49952..70fc7a66bcdc7 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2256,7 +2256,7 @@ extern "C" { pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>( DI: &'a DiagnosticInfo, level_out: &mut DiagnosticLevel, - cookie_out: &mut c_uint, + cookie_out: &mut u64, message_out: &mut Option<&'a Twine>, ); diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 54e8ed85e3250..1b2beac56a20b 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -435,7 +435,7 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut dyn PrintBackendInfo, sess &tm, cpu_cstring.as_ptr(), callback, - &mut out as *mut &mut dyn PrintBackendInfo as *mut c_void, + std::ptr::addr_of_mut!(out) as *mut c_void, ); } } diff --git a/compiler/rustc_codegen_ssa/messages.ftl b/compiler/rustc_codegen_ssa/messages.ftl index fa7719d89716e..5ba66d1be4329 100644 --- a/compiler/rustc_codegen_ssa/messages.ftl +++ b/compiler/rustc_codegen_ssa/messages.ftl @@ -106,14 +106,12 @@ codegen_ssa_invalid_monomorphization_return_type = invalid monomorphization of ` codegen_ssa_invalid_monomorphization_second_argument_length = invalid monomorphization of `{$name}` intrinsic: expected second argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len} -codegen_ssa_invalid_monomorphization_shuffle_index_not_constant = invalid monomorphization of `{$name}` intrinsic: shuffle index #{$arg_idx} is not a constant - -codegen_ssa_invalid_monomorphization_shuffle_index_out_of_bounds = invalid monomorphization of `{$name}` intrinsic: shuffle index #{$arg_idx} is out of bounds (limit {$total_len}) - codegen_ssa_invalid_monomorphization_simd_argument = invalid monomorphization of `{$name}` intrinsic: expected SIMD argument type, found non-SIMD `{$ty}` codegen_ssa_invalid_monomorphization_simd_first = invalid monomorphization of `{$name}` intrinsic: expected SIMD first type, found non-SIMD `{$ty}` +codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds = invalid monomorphization of `{$name}` intrinsic: SIMD index #{$arg_idx} is out of bounds (limit {$total_len}) + codegen_ssa_invalid_monomorphization_simd_input = invalid monomorphization of `{$name}` intrinsic: expected SIMD input type, found non-SIMD `{$ty}` codegen_ssa_invalid_monomorphization_simd_return = invalid monomorphization of `{$name}` intrinsic: expected SIMD return type, found non-SIMD `{$ty}` diff --git a/compiler/rustc_codegen_ssa/src/assert_module_sources.rs b/compiler/rustc_codegen_ssa/src/assert_module_sources.rs index 344e7dbdf034d..cbee4877122f0 100644 --- a/compiler/rustc_codegen_ssa/src/assert_module_sources.rs +++ b/compiler/rustc_codegen_ssa/src/assert_module_sources.rs @@ -27,7 +27,7 @@ use crate::errors; use rustc_ast as ast; use rustc_data_structures::unord::UnordMap; use rustc_data_structures::unord::UnordSet; -use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; +use rustc_errors::{DiagArgValue, IntoDiagnosticArg}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::mir::mono::CodegenUnitNameBuilder; use rustc_middle::ty::TyCtxt; @@ -206,8 +206,8 @@ impl fmt::Display for CguReuse { } impl IntoDiagnosticArg for CguReuse { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self.to_string())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self.to_string())) } } diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 0dadd047c9a97..22b58c13949e2 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -21,7 +21,7 @@ use std::path::{Path, PathBuf}; pub use crate::errors::{ArchiveBuildFailure, ExtractBundledLibsError, UnknownArchiveKind}; pub trait ArchiveBuilderBuilder { - fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box + 'a>; + fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box; /// Creates a DLL Import Library . /// and returns the path on disk to that import library. @@ -74,7 +74,7 @@ pub trait ArchiveBuilderBuilder { } } -pub trait ArchiveBuilder<'a> { +pub trait ArchiveBuilder { fn add_file(&mut self, path: &Path); fn add_archive( @@ -167,7 +167,7 @@ pub fn try_extract_macho_fat_archive( } } -impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { +impl<'a> ArchiveBuilder for ArArchiveBuilder<'a> { fn add_archive( &mut self, archive_path: &Path, diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 1ad0dec064006..e4a050dcfc9bd 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -308,7 +308,7 @@ fn link_rlib<'a>( codegen_results: &CodegenResults, flavor: RlibFlavor, tmpdir: &MaybeTempDir, -) -> Result + 'a>, ErrorGuaranteed> { +) -> Result, ErrorGuaranteed> { let lib_search_paths = archive_search_paths(sess); let mut ab = archive_builder_builder.new_archive_builder(sess); diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 8e76e47cfefca..c6b04431fab10 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -623,7 +623,7 @@ pub fn create_compressed_metadata_file_for_xcoff( /// that contains a custom section of the name `section_name` with contents /// `data`. /// -/// NB: the `object` crate does not yet have support for writing the the wasm +/// NB: the `object` crate does not yet have support for writing the wasm /// object file format. The format is simple enough that for now an extra crate /// from crates.io (such as `wasm-encoder`). The file format is: /// diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index c2fc32130ea00..c784ee4867596 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -16,8 +16,8 @@ use rustc_data_structures::sync::Lrc; use rustc_errors::emitter::Emitter; use rustc_errors::translation::Translate; use rustc_errors::{ - DiagCtxt, DiagnosticArgMap, DiagnosticBuilder, DiagnosticMessage, ErrCode, FatalError, - FluentBundle, Level, MultiSpan, Style, + Diag, DiagArgMap, DiagCtxt, DiagnosticMessage, ErrCode, FatalError, FluentBundle, Level, + MultiSpan, Style, }; use rustc_fs_util::link_or_copy; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; @@ -1013,7 +1013,7 @@ struct Diagnostic { messages: Vec<(DiagnosticMessage, Style)>, code: Option, children: Vec, - args: DiagnosticArgMap, + args: DiagArgMap, } // A cut-down version of `rustc_errors::SubDiagnostic` that impls `Send`. It's @@ -1829,16 +1829,16 @@ impl Translate for SharedEmitter { } impl Emitter for SharedEmitter { - fn emit_diagnostic(&mut self, mut diag: rustc_errors::Diagnostic) { + fn emit_diagnostic(&mut self, mut diag: rustc_errors::DiagInner) { // Check that we aren't missing anything interesting when converting to - // the cut-down local `Diagnostic`. + // the cut-down local `DiagInner`. assert_eq!(diag.span, MultiSpan::new()); assert_eq!(diag.suggestions, Ok(vec![])); assert_eq!(diag.sort_span, rustc_span::DUMMY_SP); assert_eq!(diag.is_lint, None); // No sensible check for `diag.emitted_at`. - let args = mem::replace(&mut diag.args, DiagnosticArgMap::default()); + let args = mem::replace(&mut diag.args, DiagArgMap::default()); drop( self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic { level: diag.level(), @@ -1880,12 +1880,12 @@ impl SharedEmitterMain { // Convert it back to a full `Diagnostic` and emit. let dcx = sess.dcx(); let mut d = - rustc_errors::Diagnostic::new_with_messages(diag.level, diag.messages); + rustc_errors::DiagInner::new_with_messages(diag.level, diag.messages); d.code = diag.code; // may be `None`, that's ok d.children = diag .children .into_iter() - .map(|sub| rustc_errors::SubDiagnostic { + .map(|sub| rustc_errors::Subdiag { level: sub.level, messages: sub.messages, span: MultiSpan::new(), @@ -1898,7 +1898,7 @@ impl SharedEmitterMain { Ok(SharedEmitterMessage::InlineAsmError(cookie, msg, level, source)) => { assert!(matches!(level, Level::Error | Level::Warning | Level::Note)); let msg = msg.strip_prefix("error: ").unwrap_or(&msg).to_string(); - let mut err = DiagnosticBuilder::<()>::new(sess.dcx(), level, msg); + let mut err = Diag::<()>::new(sess.dcx(), level, msg); // If the cookie is 0 then we don't have span information. if cookie != 0 { diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index e42a8bd9ed98d..8fae80de0640d 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -4,8 +4,8 @@ use crate::assert_module_sources::CguReuse; use crate::back::command::Command; use crate::fluent_generated as fluent; use rustc_errors::{ - codes::*, DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, - IntoDiagnosticArg, Level, + codes::*, Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, + Level, }; use rustc_macros::Diagnostic; use rustc_middle::ty::layout::LayoutError; @@ -153,8 +153,8 @@ impl<'a> CopyPath<'a> { struct DebugArgPath<'a>(pub &'a Path); impl IntoDiagnosticArg for DebugArgPath<'_> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(format!("{:?}", self.0))) + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { + DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0))) } } @@ -216,8 +216,8 @@ pub enum LinkRlibError { pub struct ThorinErrorWrapper(pub thorin::Error); impl IntoDiagnostic<'_, G> for ThorinErrorWrapper { - fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let build = |msg| DiagnosticBuilder::new(dcx, level, msg); + fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> { + let build = |msg| Diag::new(dcx, level, msg); match self.0 { thorin::Error::ReadInput(_) => build(fluent::codegen_ssa_thorin_read_input_failure), thorin::Error::ParseFileKind(_) => { @@ -349,8 +349,8 @@ pub struct LinkingFailed<'a> { } impl IntoDiagnostic<'_, G> for LinkingFailed<'_> { - fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::codegen_ssa_linking_failed); + fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::codegen_ssa_linking_failed); diag.arg("linker_path", format!("{}", self.linker_path.display())); diag.arg("exit_status", format!("{}", self.exit_status)); @@ -797,16 +797,8 @@ pub enum InvalidMonomorphization<'tcx> { out_ty: Ty<'tcx>, }, - #[diag(codegen_ssa_invalid_monomorphization_shuffle_index_not_constant, code = E0511)] - ShuffleIndexNotConstant { - #[primary_span] - span: Span, - name: Symbol, - arg_idx: u64, - }, - - #[diag(codegen_ssa_invalid_monomorphization_shuffle_index_out_of_bounds, code = E0511)] - ShuffleIndexOutOfBounds { + #[diag(codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds, code = E0511)] + SimdIndexOutOfBounds { #[primary_span] span: Span, name: Symbol, @@ -983,10 +975,10 @@ pub enum ExpectedPointerMutability { } impl IntoDiagnosticArg for ExpectedPointerMutability { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { match self { - ExpectedPointerMutability::Mut => DiagnosticArgValue::Str(Cow::Borrowed("*mut")), - ExpectedPointerMutability::Not => DiagnosticArgValue::Str(Cow::Borrowed("*_")), + ExpectedPointerMutability::Mut => DiagArgValue::Str(Cow::Borrowed("*mut")), + ExpectedPointerMutability::Not => DiagArgValue::Str(Cow::Borrowed("*_")), } } } diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 00007110938e0..9c7aadb81f828 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -319,7 +319,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { targets: &SwitchTargets, ) { let discr = self.codegen_operand(bx, discr); + let discr_value = discr.immediate(); let switch_ty = discr.layout.ty; + // If our discriminant is a constant we can branch directly + if let Some(const_discr) = bx.const_to_opt_u128(discr_value, false) { + let target = targets.target_for_value(const_discr); + bx.br(helper.llbb_with_cleanup(self, target)); + return; + }; + let mut target_iter = targets.iter(); if target_iter.len() == 1 { // If there are two targets (one conditional, one fallback), emit `br` instead of @@ -330,14 +338,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if switch_ty == bx.tcx().types.bool { // Don't generate trivial icmps when switching on bool. match test_value { - 0 => bx.cond_br(discr.immediate(), llfalse, lltrue), - 1 => bx.cond_br(discr.immediate(), lltrue, llfalse), + 0 => bx.cond_br(discr_value, llfalse, lltrue), + 1 => bx.cond_br(discr_value, lltrue, llfalse), _ => bug!(), } } else { let switch_llty = bx.immediate_backend_type(bx.layout_of(switch_ty)); let llval = bx.const_uint_big(switch_llty, test_value); - let cmp = bx.icmp(IntPredicate::IntEQ, discr.immediate(), llval); + let cmp = bx.icmp(IntPredicate::IntEQ, discr_value, llval); bx.cond_br(cmp, lltrue, llfalse); } } else if self.cx.sess().opts.optimize == OptLevel::No @@ -362,11 +370,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let ll2 = helper.llbb_with_cleanup(self, target2); let switch_llty = bx.immediate_backend_type(bx.layout_of(switch_ty)); let llval = bx.const_uint_big(switch_llty, test_value1); - let cmp = bx.icmp(IntPredicate::IntEQ, discr.immediate(), llval); + let cmp = bx.icmp(IntPredicate::IntEQ, discr_value, llval); bx.cond_br(cmp, ll1, ll2); } else { bx.switch( - discr.immediate(), + discr_value, helper.llbb_with_cleanup(self, targets.otherwise()), target_iter.map(|(value, target)| (value, helper.llbb_with_cleanup(self, target))), ); diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 935329f118904..62bc68b1a20e9 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -1,7 +1,7 @@ use std::mem; use rustc_errors::{ - DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg, + DiagArgName, DiagArgValue, DiagnosticMessage, IntoDiagnostic, IntoDiagnosticArg, }; use rustc_hir::CRATE_HIR_ID; use rustc_middle::mir::AssertKind; @@ -36,7 +36,7 @@ impl MachineStopType for ConstEvalErrKind { AssertFailure(x) => x.diagnostic_message(), } } - fn add_args(self: Box, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) { + fn add_args(self: Box, adder: &mut dyn FnMut(DiagArgName, DiagArgValue)) { use ConstEvalErrKind::*; match *self { RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {} diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 267f3acaaa5b2..62aab9d563559 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -1,8 +1,8 @@ use std::borrow::Cow; use rustc_errors::{ - codes::*, DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, DiagnosticMessage, - EmissionGuarantee, IntoDiagnostic, Level, + codes::*, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage, EmissionGuarantee, IntoDiagnostic, + Level, }; use rustc_hir::ConstContext; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; @@ -11,11 +11,10 @@ use rustc_middle::mir::interpret::{ PointerKind, ResourceExhaustionInfo, UndefinedBehaviorInfo, UnsupportedOpInfo, ValidationErrorInfo, }; -use rustc_middle::ty::{self, Ty}; +use rustc_middle::ty::{self, Mutability, Ty}; use rustc_span::Span; use rustc_target::abi::call::AdjustForForeignAbiError; use rustc_target::abi::{Size, WrappingRange}; -use rustc_type_ir::Mutability; use crate::interpret::InternKind; @@ -426,7 +425,7 @@ pub struct UndefinedBehavior { pub trait ReportErrorExt { /// Returns the diagnostic message for this error. fn diagnostic_message(&self) -> DiagnosticMessage; - fn add_args(self, diag: &mut DiagnosticBuilder<'_, G>); + fn add_args(self, diag: &mut Diag<'_, G>); fn debug(self) -> String where @@ -505,7 +504,7 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> { } } - fn add_args(self, diag: &mut DiagnosticBuilder<'_, G>) { + fn add_args(self, diag: &mut Diag<'_, G>) { use UndefinedBehaviorInfo::*; let dcx = diag.dcx; match self { @@ -671,7 +670,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { } } - fn add_args(self, err: &mut DiagnosticBuilder<'_, G>) { + fn add_args(self, err: &mut Diag<'_, G>) { use crate::fluent_generated as fluent; use rustc_middle::mir::interpret::ValidationErrorKind::*; @@ -683,7 +682,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { let message = if let Some(path) = self.path { err.dcx.eagerly_translate_to_string( fluent::const_eval_validation_front_matter_invalid_value_with_path, - [("path".into(), DiagnosticArgValue::Str(path.into()))].iter().map(|(a, b)| (a, b)), + [("path".into(), DiagArgValue::Str(path.into()))].iter().map(|(a, b)| (a, b)), ) } else { err.dcx.eagerly_translate_to_string( @@ -697,7 +696,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { fn add_range_arg( r: WrappingRange, max_hi: u128, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, ) { let WrappingRange { start: lo, end: hi } = r; assert!(hi <= max_hi); @@ -716,8 +715,8 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { }; let args = [ - ("lo".into(), DiagnosticArgValue::Str(lo.to_string().into())), - ("hi".into(), DiagnosticArgValue::Str(hi.to_string().into())), + ("lo".into(), DiagArgValue::Str(lo.to_string().into())), + ("hi".into(), DiagArgValue::Str(hi.to_string().into())), ]; let args = args.iter().map(|(a, b)| (a, b)); let message = err.dcx.eagerly_translate_to_string(msg, args); @@ -798,7 +797,7 @@ impl ReportErrorExt for UnsupportedOpInfo { UnsupportedOpInfo::ExternStatic(_) => const_eval_extern_static, } } - fn add_args(self, diag: &mut DiagnosticBuilder<'_, G>) { + fn add_args(self, diag: &mut Diag<'_, G>) { use crate::fluent_generated::*; use UnsupportedOpInfo::*; @@ -831,7 +830,7 @@ impl<'tcx> ReportErrorExt for InterpError<'tcx> { InterpError::MachineStop(e) => e.diagnostic_message(), } } - fn add_args(self, diag: &mut DiagnosticBuilder<'_, G>) { + fn add_args(self, diag: &mut Diag<'_, G>) { match self { InterpError::UndefinedBehavior(ub) => ub.add_args(diag), InterpError::Unsupported(e) => e.add_args(diag), @@ -856,13 +855,13 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> { } } } - fn add_args(self, diag: &mut DiagnosticBuilder<'_, G>) { + fn add_args(self, diag: &mut Diag<'_, G>) { match self { InvalidProgramInfo::TooGeneric | InvalidProgramInfo::AlreadyReported(_) => {} InvalidProgramInfo::Layout(e) => { // The level doesn't matter, `dummy_diag` is consumed without it being used. let dummy_level = Level::Bug; - let dummy_diag: DiagnosticBuilder<'_, ()> = + let dummy_diag: Diag<'_, ()> = e.into_diagnostic().into_diagnostic(diag.dcx, dummy_level); for (name, val) in dummy_diag.args.iter() { diag.arg(name.clone(), val.clone()); @@ -888,12 +887,12 @@ impl ReportErrorExt for ResourceExhaustionInfo { ResourceExhaustionInfo::AddressSpaceFull => const_eval_address_space_full, } } - fn add_args(self, _: &mut DiagnosticBuilder<'_, G>) {} + fn add_args(self, _: &mut Diag<'_, G>) {} } impl rustc_errors::IntoDiagnosticArg for InternKind { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Borrowed(match self { + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(match self { InternKind::Static(Mutability::Not) => "static", InternKind::Static(Mutability::Mut) => "static_mut", InternKind::Constant => "const", diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index 959ec2ca86558..82ce9ecd21d18 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -140,7 +140,7 @@ pub fn intern_const_alloc_recursive< alloc.1.mutability = base_mutability; alloc.1.provenance().ptrs().iter().map(|&(_, prov)| prov).collect() } else { - intern_shallow(ecx, base_alloc_id, base_mutability).unwrap().map(|prov| prov).collect() + intern_shallow(ecx, base_alloc_id, base_mutability).unwrap().collect() }; // We need to distinguish "has just been interned" from "was already in `tcx`", // so we track this in a separate set. @@ -277,7 +277,7 @@ impl<'mir, 'tcx: 'mir, M: super::intern::CompileTimeMachine<'mir, 'tcx, !>> // We are not doing recursive interning, so we don't currently support provenance. // (If this assertion ever triggers, we should just implement a // proper recursive interning loop -- or just call `intern_const_alloc_recursive`. - if !self.tcx.try_get_global_alloc(prov.alloc_id()).is_some() { + if self.tcx.try_get_global_alloc(prov.alloc_id()).is_none() { panic!("`intern_with_temp_alloc` with nested allocations"); } } diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index f020616f6d8c8..1cb991b38f7e9 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -379,10 +379,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let (input, input_len) = self.operand_to_simd(&args[0])?; let (dest, dest_len) = self.place_to_simd(dest)?; assert_eq!(input_len, dest_len, "Return vector length must match input length"); - assert!( - index < dest_len, - "Index `{index}` must be in bounds of vector with length {dest_len}" - ); + // Bounds are not checked by typeck so we have to do it ourselves. + if index >= input_len { + throw_ub_format!( + "`simd_insert` index {index} is out-of-bounds of vector with length {input_len}" + ); + } for i in 0..dest_len { let place = self.project_index(&dest, i)?; @@ -397,10 +399,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { sym::simd_extract => { let index = u64::from(self.read_scalar(&args[1])?.to_u32()?); let (input, input_len) = self.operand_to_simd(&args[0])?; - assert!( - index < input_len, - "index `{index}` must be in bounds of vector with length {input_len}" - ); + // Bounds are not checked by typeck so we have to do it ourselves. + if index >= input_len { + throw_ub_format!( + "`simd_extract` index {index} is out-of-bounds of vector with length {input_len}" + ); + } self.copy_op(&self.project_index(&input, index)?, dest)?; } sym::likely | sym::unlikely | sym::black_box => { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index effaedd0820c3..c98dc4deb7579 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -1,6 +1,6 @@ //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations. -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::{Diag, ErrorGuaranteed}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_index::bit_set::BitSet; @@ -187,7 +187,7 @@ pub struct Checker<'mir, 'tcx> { local_has_storage_dead: Option>, error_emitted: Option, - secondary_errors: Vec>, + secondary_errors: Vec>, } impl<'mir, 'tcx> Deref for Checker<'mir, 'tcx> { @@ -318,12 +318,12 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { assert!(err.is_error()); match op.importance() { - ops::DiagnosticImportance::Primary => { + ops::DiagImportance::Primary => { let reported = err.emit(); self.error_emitted = Some(reported); } - ops::DiagnosticImportance::Secondary => self.secondary_errors.push(err), + ops::DiagImportance::Secondary => self.secondary_errors.push(err), } } diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 5b4bbf8510b60..1107b894ab3ee 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -2,7 +2,7 @@ use hir::def_id::LocalDefId; use hir::{ConstContext, LangItem}; -use rustc_errors::{codes::*, DiagnosticBuilder}; +use rustc_errors::{codes::*, Diag}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_infer::infer::TyCtxtInferExt; @@ -29,7 +29,7 @@ pub enum Status { } #[derive(Clone, Copy)] -pub enum DiagnosticImportance { +pub enum DiagImportance { /// An operation that must be removed for const-checking to pass. Primary, @@ -44,11 +44,11 @@ pub trait NonConstOp<'tcx>: std::fmt::Debug { Status::Forbidden } - fn importance(&self) -> DiagnosticImportance { - DiagnosticImportance::Primary + fn importance(&self) -> DiagImportance { + DiagImportance::Primary } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>; + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx>; } #[derive(Debug)] @@ -62,7 +62,7 @@ impl<'tcx> NonConstOp<'tcx> for FloatingPointOp { } } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { feature_err( &ccx.tcx.sess, sym::const_fn_floating_point_arithmetic, @@ -76,7 +76,7 @@ impl<'tcx> NonConstOp<'tcx> for FloatingPointOp { #[derive(Debug)] pub struct FnCallIndirect; impl<'tcx> NonConstOp<'tcx> for FnCallIndirect { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::UnallowedFnPointerCall { span, kind: ccx.const_kind() }) } } @@ -96,7 +96,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { // FIXME: make this translatable #[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::untranslatable_diagnostic)] - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, _: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, _: Span) -> Diag<'tcx> { let FnCallNonConst { caller, callee, args, span, call_source, feature } = *self; let ConstCx { tcx, param_env, .. } = *ccx; @@ -317,7 +317,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { pub struct FnCallUnstable(pub DefId, pub Option); impl<'tcx> NonConstOp<'tcx> for FnCallUnstable { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { let FnCallUnstable(def_id, feature) = *self; let mut err = ccx @@ -353,7 +353,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine { } } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { let msg = format!("{:#}s are not allowed in {}s", self.0, ccx.const_kind()); if let hir::CoroutineKind::Desugared( hir::CoroutineDesugaring::Async, @@ -373,7 +373,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine { #[derive(Debug)] pub struct HeapAllocation; impl<'tcx> NonConstOp<'tcx> for HeapAllocation { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::UnallowedHeapAllocations { span, kind: ccx.const_kind(), @@ -385,7 +385,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation { #[derive(Debug)] pub struct InlineAsm; impl<'tcx> NonConstOp<'tcx> for InlineAsm { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::UnallowedInlineAsm { span, kind: ccx.const_kind() }) } } @@ -396,7 +396,7 @@ pub struct LiveDrop<'tcx> { pub dropped_ty: Ty<'tcx>, } impl<'tcx> NonConstOp<'tcx> for LiveDrop<'tcx> { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::LiveDrop { span, dropped_ty: self.dropped_ty, @@ -414,7 +414,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow { fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status { Status::Unstable(sym::const_refs_to_cell) } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.tcx .sess .create_feature_err(errors::InteriorMutabilityBorrow { span }, sym::const_refs_to_cell) @@ -427,12 +427,12 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow { /// it in the future for static items. pub struct CellBorrow; impl<'tcx> NonConstOp<'tcx> for CellBorrow { - fn importance(&self) -> DiagnosticImportance { + fn importance(&self) -> DiagImportance { // Most likely the code will try to do mutation with these borrows, which // triggers its own errors. Only show this one if that does not happen. - DiagnosticImportance::Secondary + DiagImportance::Secondary } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { // FIXME: Maybe a more elegant solution to this if else case if let hir::ConstContext::Static(_) = ccx.const_kind() { ccx.dcx().create_err(errors::InteriorMutableDataRefer { @@ -463,13 +463,13 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow { Status::Forbidden } - fn importance(&self) -> DiagnosticImportance { + fn importance(&self) -> DiagImportance { // Most likely the code will try to do mutation with these borrows, which // triggers its own errors. Only show this one if that does not happen. - DiagnosticImportance::Secondary + DiagImportance::Secondary } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { match self.0 { hir::BorrowKind::Raw => ccx.tcx.dcx().create_err(errors::UnallowedMutableRaw { span, @@ -493,7 +493,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientMutBorrow { Status::Unstable(sym::const_mut_refs) } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { let kind = ccx.const_kind(); match self.0 { hir::BorrowKind::Raw => ccx @@ -515,12 +515,12 @@ impl<'tcx> NonConstOp<'tcx> for MutDeref { Status::Unstable(sym::const_mut_refs) } - fn importance(&self) -> DiagnosticImportance { + fn importance(&self) -> DiagImportance { // Usually a side-effect of a `TransientMutBorrow` somewhere. - DiagnosticImportance::Secondary + DiagImportance::Secondary } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.tcx.sess.create_feature_err( errors::MutDerefErr { span, kind: ccx.const_kind() }, sym::const_mut_refs, @@ -532,7 +532,7 @@ impl<'tcx> NonConstOp<'tcx> for MutDeref { #[derive(Debug)] pub struct PanicNonStr; impl<'tcx> NonConstOp<'tcx> for PanicNonStr { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::PanicNonStrErr { span }) } } @@ -543,7 +543,7 @@ impl<'tcx> NonConstOp<'tcx> for PanicNonStr { #[derive(Debug)] pub struct RawPtrComparison; impl<'tcx> NonConstOp<'tcx> for RawPtrComparison { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { // FIXME(const_trait_impl): revert to span_bug? ccx.dcx().create_err(errors::RawPtrComparisonErr { span }) } @@ -556,7 +556,7 @@ impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref { Status::Unstable(sym::const_mut_refs) } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { feature_err( &ccx.tcx.sess, sym::const_mut_refs, @@ -572,7 +572,7 @@ impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref { #[derive(Debug)] pub struct RawPtrToIntCast; impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::RawPtrToIntErr { span }) } } @@ -589,7 +589,7 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess { } } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { let mut err = feature_err( &ccx.tcx.sess, sym::const_refs_to_static, @@ -609,7 +609,7 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess { #[derive(Debug)] pub struct ThreadLocalAccess; impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess { - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { ccx.dcx().create_err(errors::ThreadLocalAccessErr { span }) } } @@ -625,16 +625,14 @@ pub mod ty { Status::Unstable(sym::const_mut_refs) } - fn importance(&self) -> DiagnosticImportance { + fn importance(&self) -> DiagImportance { match self.0 { - mir::LocalKind::Temp => DiagnosticImportance::Secondary, - mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => { - DiagnosticImportance::Primary - } + mir::LocalKind::Temp => DiagImportance::Secondary, + mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => DiagImportance::Primary, } } - fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { + fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { feature_err( &ccx.tcx.sess, sym::const_mut_refs, diff --git a/compiler/rustc_const_eval/src/util/caller_location.rs b/compiler/rustc_const_eval/src/util/caller_location.rs index b8e15c485f58f..af9a4a4271d74 100644 --- a/compiler/rustc_const_eval/src/util/caller_location.rs +++ b/compiler/rustc_const_eval/src/util/caller_location.rs @@ -1,10 +1,9 @@ use rustc_hir::LangItem; use rustc_middle::mir; use rustc_middle::query::TyCtxtAt; -use rustc_middle::ty; use rustc_middle::ty::layout::LayoutOf; +use rustc_middle::ty::{self, Mutability}; use rustc_span::symbol::Symbol; -use rustc_type_ir::Mutability; use crate::const_eval::{mk_eval_cx_to_read_const_val, CanAccessMutGlobal, CompileTimeEvalContext}; use crate::interpret::*; diff --git a/compiler/rustc_data_structures/src/sync.rs b/compiler/rustc_data_structures/src/sync.rs index adcb6ceaebf89..32202ac3eded1 100644 --- a/compiler/rustc_data_structures/src/sync.rs +++ b/compiler/rustc_data_structures/src/sync.rs @@ -429,7 +429,7 @@ impl RwLock { #[inline(always)] pub fn leak(&self) -> &T { let guard = self.read(); - let ret = unsafe { &*(&*guard as *const T) }; + let ret = unsafe { &*std::ptr::addr_of!(*guard) }; std::mem::forget(guard); ret } diff --git a/compiler/rustc_error_codes/src/error_codes/E0511.md b/compiler/rustc_error_codes/src/error_codes/E0511.md index 5351a685eb512..681f4e611c32d 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0511.md +++ b/compiler/rustc_error_codes/src/error_codes/E0511.md @@ -3,9 +3,9 @@ Invalid monomorphization of an intrinsic function was used. Erroneous code example: ```compile_fail,E0511 -#![feature(platform_intrinsics)] +#![feature(intrinsics)] -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(a: T, b: T) -> T; } @@ -19,13 +19,13 @@ The generic type has to be a SIMD type. Example: ``` #![feature(repr_simd)] -#![feature(platform_intrinsics)] +#![feature(intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] struct i32x2(i32, i32); -extern "platform-intrinsic" { +extern "rust-intrinsic" { fn simd_add(a: T, b: T) -> T; } diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 52b5a7eff48fd..e6668769b955e 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -9,8 +9,8 @@ use crate::emitter::FileWithAnnotatedLines; use crate::snippet::Line; use crate::translation::{to_fluent_args, Translate}; use crate::{ - CodeSuggestion, Diagnostic, DiagnosticMessage, Emitter, ErrCode, FluentBundle, - LazyFallbackBundle, Level, MultiSpan, Style, SubDiagnostic, + CodeSuggestion, DiagInner, DiagnosticMessage, Emitter, ErrCode, FluentBundle, + LazyFallbackBundle, Level, MultiSpan, Style, Subdiag, }; use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation}; use rustc_data_structures::sync::Lrc; @@ -44,7 +44,7 @@ impl Translate for AnnotateSnippetEmitter { impl Emitter for AnnotateSnippetEmitter { /// The entry point for the diagnostics generation - fn emit_diagnostic(&mut self, mut diag: Diagnostic) { + fn emit_diagnostic(&mut self, mut diag: DiagInner) { let fluent_args = to_fluent_args(diag.args.iter()); let mut suggestions = diag.suggestions.unwrap_or(vec![]); @@ -82,7 +82,7 @@ fn source_string(file: Lrc, line: &Line) -> String { file.get_line(line.line_index - 1).map(|a| a.to_string()).unwrap_or_default() } -/// Maps `Diagnostic::Level` to `snippet::AnnotationType` +/// Maps `diagnostic::Level` to `snippet::AnnotationType` fn annotation_type_for_level(level: Level) -> AnnotationType { match level { Level::Bug | Level::Fatal | Level::Error | Level::DelayedBug => AnnotationType::Error, @@ -129,7 +129,7 @@ impl AnnotateSnippetEmitter { args: &FluentArgs<'_>, code: &Option, msp: &MultiSpan, - _children: &[SubDiagnostic], + _children: &[Subdiag], _suggestions: &[CodeSuggestion], ) { let message = self.translate_messages(messages, args); diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 65c49a6085c4e..0cf519d2029f4 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -18,23 +18,23 @@ use std::ops::{Deref, DerefMut}; use std::panic; use std::thread::panicking; -/// Error type for `Diagnostic`'s `suggestions` field, indicating that -/// `.disable_suggestions()` was called on the `Diagnostic`. +/// Error type for `DiagInner`'s `suggestions` field, indicating that +/// `.disable_suggestions()` was called on the `DiagInner`. #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] pub struct SuggestionsDisabled; /// Simplified version of `FluentArg` that can implement `Encodable` and `Decodable`. Collection of -/// `DiagnosticArg` are converted to `FluentArgs` (consuming the collection) at the start of -/// diagnostic emission. -pub type DiagnosticArg<'iter> = (&'iter DiagnosticArgName, &'iter DiagnosticArgValue); +/// `DiagArg` are converted to `FluentArgs` (consuming the collection) at the start of diagnostic +/// emission. +pub type DiagArg<'iter> = (&'iter DiagArgName, &'iter DiagArgValue); /// Name of a diagnostic argument. -pub type DiagnosticArgName = Cow<'static, str>; +pub type DiagArgName = Cow<'static, str>; /// Simplified version of `FluentValue` that can implement `Encodable` and `Decodable`. Converted /// to a `FluentValue` by the emitter to be used in diagnostic translation. #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] -pub enum DiagnosticArgValue { +pub enum DiagArgValue { Str(Cow<'static, str>), // This gets converted to a `FluentNumber`, which is an `f64`. An `i32` // safely fits in an `f64`. Any integers bigger than that will be converted @@ -43,31 +43,31 @@ pub enum DiagnosticArgValue { StrListSepByAnd(Vec>), } -pub type DiagnosticArgMap = FxIndexMap; +pub type DiagArgMap = FxIndexMap; -/// Trait for types that `DiagnosticBuilder::emit` can return as a "guarantee" -/// (or "proof") token that the emission happened. +/// Trait for types that `Diag::emit` can return as a "guarantee" (or "proof") +/// token that the emission happened. pub trait EmissionGuarantee: Sized { /// This exists so that bugs and fatal errors can both result in `!` (an /// abort) when emitted, but have different aborting behaviour. type EmitResult = Self; - /// Implementation of `DiagnosticBuilder::emit`, fully controlled by each - /// `impl` of `EmissionGuarantee`, to make it impossible to create a value - /// of `Self::EmitResult` without actually performing the emission. + /// Implementation of `Diag::emit`, fully controlled by each `impl` of + /// `EmissionGuarantee`, to make it impossible to create a value of + /// `Self::EmitResult` without actually performing the emission. #[track_caller] - fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult; + fn emit_producing_guarantee(diag: Diag<'_, Self>) -> Self::EmitResult; } impl EmissionGuarantee for ErrorGuaranteed { - fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult { - db.emit_producing_error_guaranteed() + fn emit_producing_guarantee(diag: Diag<'_, Self>) -> Self::EmitResult { + diag.emit_producing_error_guaranteed() } } impl EmissionGuarantee for () { - fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult { - db.emit_producing_nothing(); + fn emit_producing_guarantee(diag: Diag<'_, Self>) -> Self::EmitResult { + diag.emit_producing_nothing(); } } @@ -79,8 +79,8 @@ pub struct BugAbort; impl EmissionGuarantee for BugAbort { type EmitResult = !; - fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult { - db.emit_producing_nothing(); + fn emit_producing_guarantee(diag: Diag<'_, Self>) -> Self::EmitResult { + diag.emit_producing_nothing(); panic::panic_any(ExplicitBug); } } @@ -93,26 +93,45 @@ pub struct FatalAbort; impl EmissionGuarantee for FatalAbort { type EmitResult = !; - fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult { - db.emit_producing_nothing(); + fn emit_producing_guarantee(diag: Diag<'_, Self>) -> Self::EmitResult { + diag.emit_producing_nothing(); crate::FatalError.raise() } } impl EmissionGuarantee for rustc_span::fatal_error::FatalError { - fn emit_producing_guarantee(db: DiagnosticBuilder<'_, Self>) -> Self::EmitResult { - db.emit_producing_nothing(); + fn emit_producing_guarantee(diag: Diag<'_, Self>) -> Self::EmitResult { + diag.emit_producing_nothing(); rustc_span::fatal_error::FatalError } } /// Trait implemented by error types. This is rarely implemented manually. Instead, use /// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic]. +/// +/// When implemented manually, it should be generic over the emission +/// guarantee, i.e.: +/// ```ignore (fragment) +/// impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for Foo { ... } +/// ``` +/// rather than being specific: +/// ```ignore (fragment) +/// impl<'a> IntoDiagnostic<'a> for Bar { ... } // the default type param is `ErrorGuaranteed` +/// impl<'a> IntoDiagnostic<'a, ()> for Baz { ... } +/// ``` +/// There are two reasons for this. +/// - A diagnostic like `Foo` *could* be emitted at any level -- `level` is +/// passed in to `into_diagnostic` from outside. Even if in practice it is +/// always emitted at a single level, we let the diagnostic creation/emission +/// site determine the level (by using `create_err`, `emit_warn`, etc.) +/// rather than the `IntoDiagnostic` impl. +/// - Derived impls are always generic, and it's good for the hand-written +/// impls to be consistent with them. #[rustc_diagnostic_item = "IntoDiagnostic"] pub trait IntoDiagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> { /// Write out as a diagnostic out of `DiagCtxt`. #[must_use] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G>; + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G>; } impl<'a, T, G> IntoDiagnostic<'a, G> for Spanned @@ -120,31 +139,31 @@ where T: IntoDiagnostic<'a, G>, G: EmissionGuarantee, { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { self.node.into_diagnostic(dcx, level).with_span(self.span) } } -/// Converts a value of a type into a `DiagnosticArg` (typically a field of an `IntoDiagnostic` -/// struct). Implemented as a custom trait rather than `From` so that it is implemented on the type -/// being converted rather than on `DiagnosticArgValue`, which enables types from other `rustc_*` -/// crates to implement this. +/// Converts a value of a type into a `DiagArg` (typically a field of an `IntoDiagnostic` struct). +/// Implemented as a custom trait rather than `From` so that it is implemented on the type being +/// converted rather than on `DiagArgValue`, which enables types from other `rustc_*` crates to +/// implement this. pub trait IntoDiagnosticArg { - fn into_diagnostic_arg(self) -> DiagnosticArgValue; + fn into_diagnostic_arg(self) -> DiagArgValue; } -impl IntoDiagnosticArg for DiagnosticArgValue { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { +impl IntoDiagnosticArg for DiagArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self } } -impl Into> for DiagnosticArgValue { +impl Into> for DiagArgValue { fn into(self) -> FluentValue<'static> { match self { - DiagnosticArgValue::Str(s) => From::from(s), - DiagnosticArgValue::Number(n) => From::from(n), - DiagnosticArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l), + DiagArgValue::Str(s) => From::from(s), + DiagArgValue::Number(n) => From::from(n), + DiagArgValue::StrListSepByAnd(l) => fluent_value_from_str_list_sep_by_and(l), } } } @@ -157,7 +176,7 @@ where Self: Sized, { /// Add a subdiagnostic to an existing diagnostic. - fn add_to_diagnostic(self, diag: &mut DiagnosticBuilder<'_, G>) { + fn add_to_diagnostic(self, diag: &mut Diag<'_, G>) { self.add_to_diagnostic_with(diag, |_, m| m); } @@ -165,40 +184,40 @@ where /// (to optionally perform eager translation). fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ); } pub trait SubdiagnosticMessageOp = - Fn(&mut DiagnosticBuilder<'_, G>, SubdiagnosticMessage) -> SubdiagnosticMessage; + Fn(&mut Diag<'_, G>, SubdiagnosticMessage) -> SubdiagnosticMessage; /// Trait implemented by lint types. This should not be implemented manually. Instead, use /// `#[derive(LintDiagnostic)]` -- see [rustc_macros::LintDiagnostic]. #[rustc_diagnostic_item = "DecorateLint"] pub trait DecorateLint<'a, G: EmissionGuarantee> { /// Decorate and emit a lint. - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, G>); + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>); fn msg(&self) -> DiagnosticMessage; } #[derive(Clone, Debug, Encodable, Decodable)] -pub struct DiagnosticLocation { +pub struct DiagLocation { file: Cow<'static, str>, line: u32, col: u32, } -impl DiagnosticLocation { +impl DiagLocation { #[track_caller] fn caller() -> Self { let loc = panic::Location::caller(); - DiagnosticLocation { file: loc.file().into(), line: loc.line(), col: loc.column() } + DiagLocation { file: loc.file().into(), line: loc.line(), col: loc.column() } } } -impl fmt::Display for DiagnosticLocation { +impl fmt::Display for DiagLocation { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}:{}:{}", self.file, self.line, self.col) } @@ -213,11 +232,11 @@ pub struct IsLint { } #[derive(Debug, PartialEq, Eq)] -pub struct DiagnosticStyledString(pub Vec); +pub struct DiagStyledString(pub Vec); -impl DiagnosticStyledString { - pub fn new() -> DiagnosticStyledString { - DiagnosticStyledString(vec![]) +impl DiagStyledString { + pub fn new() -> DiagStyledString { + DiagStyledString(vec![]) } pub fn push_normal>(&mut self, t: S) { self.0.push(StringPart::normal(t)); @@ -232,12 +251,12 @@ impl DiagnosticStyledString { self.push_normal(t); } } - pub fn normal>(t: S) -> DiagnosticStyledString { - DiagnosticStyledString(vec![StringPart::normal(t)]) + pub fn normal>(t: S) -> DiagStyledString { + DiagStyledString(vec![StringPart::normal(t)]) } - pub fn highlighted>(t: S) -> DiagnosticStyledString { - DiagnosticStyledString(vec![StringPart::highlighted(t)]) + pub fn highlighted>(t: S) -> DiagStyledString { + DiagStyledString(vec![StringPart::highlighted(t)]) } pub fn content(&self) -> String { @@ -261,13 +280,13 @@ impl StringPart { } } -/// The main part of a diagnostic. Note that `DiagnosticBuilder`, which wraps -/// this type, is used for most operations, and should be used instead whenever -/// possible. This type should only be used when `DiagnosticBuilder`'s lifetime -/// causes difficulties, e.g. when storing diagnostics within `DiagCtxt`. +/// The main part of a diagnostic. Note that `Diag`, which wraps this type, is +/// used for most operations, and should be used instead whenever possible. +/// This type should only be used when `Diag`'s lifetime causes difficulties, +/// e.g. when storing diagnostics within `DiagCtxt`. #[must_use] #[derive(Clone, Debug, Encodable, Decodable)] -pub struct Diagnostic { +pub struct DiagInner { // NOTE(eddyb) this is private to disallow arbitrary after-the-fact changes, // outside of what methods in this crate themselves allow. pub(crate) level: Level, @@ -275,9 +294,9 @@ pub struct Diagnostic { pub messages: Vec<(DiagnosticMessage, Style)>, pub code: Option, pub span: MultiSpan, - pub children: Vec, + pub children: Vec, pub suggestions: Result, SuggestionsDisabled>, - pub args: DiagnosticArgMap, + pub args: DiagArgMap, /// This is not used for highlighting or rendering any error message. Rather, it can be used /// as a sort key to sort a buffer of diagnostics. By default, it is the primary span of @@ -288,18 +307,18 @@ pub struct Diagnostic { /// With `-Ztrack_diagnostics` enabled, /// we print where in rustc this error was emitted. - pub(crate) emitted_at: DiagnosticLocation, + pub(crate) emitted_at: DiagLocation, } -impl Diagnostic { +impl DiagInner { #[track_caller] pub fn new>(level: Level, message: M) -> Self { - Diagnostic::new_with_messages(level, vec![(message.into(), Style::NoStyle)]) + DiagInner::new_with_messages(level, vec![(message.into(), Style::NoStyle)]) } #[track_caller] pub fn new_with_messages(level: Level, messages: Vec<(DiagnosticMessage, Style)>) -> Self { - Diagnostic { + DiagInner { level, messages, code: None, @@ -309,7 +328,7 @@ impl Diagnostic { args: Default::default(), sort_span: DUMMY_SP, is_lint: None, - emitted_at: DiagnosticLocation::caller(), + emitted_at: DiagLocation::caller(), } } @@ -374,7 +393,7 @@ impl Diagnostic { } } - // See comment on `DiagnosticBuilder::subdiagnostic_message_to_diagnostic_message`. + // See comment on `Diag::subdiagnostic_message_to_diagnostic_message`. pub(crate) fn subdiagnostic_message_to_diagnostic_message( &self, attr: impl Into, @@ -390,7 +409,7 @@ impl Diagnostic { message: impl Into, span: MultiSpan, ) { - let sub = SubDiagnostic { + let sub = Subdiag { level, messages: vec![( self.subdiagnostic_message_to_diagnostic_message(message), @@ -401,7 +420,7 @@ impl Diagnostic { self.children.push(sub); } - pub(crate) fn arg(&mut self, name: impl Into, arg: impl IntoDiagnosticArg) { + pub(crate) fn arg(&mut self, name: impl Into, arg: impl IntoDiagnosticArg) { self.args.insert(name.into(), arg.into_diagnostic_arg()); } @@ -413,9 +432,9 @@ impl Diagnostic { &[(DiagnosticMessage, Style)], &Option, &MultiSpan, - &[SubDiagnostic], + &[Subdiag], &Result, SuggestionsDisabled>, - Vec<(&DiagnosticArgName, &DiagnosticArgValue)>, + Vec<(&DiagArgName, &DiagArgValue)>, &Option, ) { ( @@ -433,7 +452,7 @@ impl Diagnostic { } } -impl Hash for Diagnostic { +impl Hash for DiagInner { fn hash(&self, state: &mut H) where H: Hasher, @@ -442,7 +461,7 @@ impl Hash for Diagnostic { } } -impl PartialEq for Diagnostic { +impl PartialEq for DiagInner { fn eq(&self, other: &Self) -> bool { self.keys() == other.keys() } @@ -451,75 +470,70 @@ impl PartialEq for Diagnostic { /// A "sub"-diagnostic attached to a parent diagnostic. /// For example, a note attached to an error. #[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)] -pub struct SubDiagnostic { +pub struct Subdiag { pub level: Level, pub messages: Vec<(DiagnosticMessage, Style)>, pub span: MultiSpan, } /// Used for emitting structured error messages and other diagnostic information. -/// Wraps a `Diagnostic`, adding some useful things. +/// Wraps a `DiagInner`, adding some useful things. /// - The `dcx` field, allowing it to (a) emit itself, and (b) do a drop check /// that it has been emitted or cancelled. /// - The `EmissionGuarantee`, which determines the type returned from `emit`. /// -/// Each constructed `DiagnosticBuilder` must be consumed by a function such as -/// `emit`, `cancel`, `delay_as_bug`, or `into_diagnostic`. A panic occurrs if a -/// `DiagnosticBuilder` is dropped without being consumed by one of these -/// functions. +/// Each constructed `Diag` must be consumed by a function such as `emit`, +/// `cancel`, `delay_as_bug`, or `into_diagnostic`. A panic occurrs if a `Diag` +/// is dropped without being consumed by one of these functions. /// -/// If there is some state in a downstream crate you would like to -/// access in the methods of `DiagnosticBuilder` here, consider -/// extending `DiagCtxtFlags`. +/// If there is some state in a downstream crate you would like to access in +/// the methods of `Diag` here, consider extending `DiagCtxtFlags`. #[must_use] -pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> { +pub struct Diag<'a, G: EmissionGuarantee = ErrorGuaranteed> { pub dcx: &'a DiagCtxt, - /// Why the `Option`? It is always `Some` until the `DiagnosticBuilder` is - /// consumed via `emit`, `cancel`, etc. At that point it is consumed and - /// replaced with `None`. Then `drop` checks that it is `None`; if not, it - /// panics because a diagnostic was built but not used. + /// Why the `Option`? It is always `Some` until the `Diag` is consumed via + /// `emit`, `cancel`, etc. At that point it is consumed and replaced with + /// `None`. Then `drop` checks that it is `None`; if not, it panics because + /// a diagnostic was built but not used. /// - /// Why the Box? `Diagnostic` is a large type, and `DiagnosticBuilder` is - /// often used as a return value, especially within the frequently-used - /// `PResult` type. In theory, return value optimization (RVO) should avoid - /// unnecessary copying. In practice, it does not (at the time of writing). - diag: Option>, + /// Why the Box? `DiagInner` is a large type, and `Diag` is often used as a + /// return value, especially within the frequently-used `PResult` type. In + /// theory, return value optimization (RVO) should avoid unnecessary + /// copying. In practice, it does not (at the time of writing). + diag: Option>, _marker: PhantomData, } -// Cloning a `DiagnosticBuilder` is a recipe for a diagnostic being emitted -// twice, which would be bad. -impl !Clone for DiagnosticBuilder<'_, G> {} +// Cloning a `Diag` is a recipe for a diagnostic being emitted twice, which +// would be bad. +impl !Clone for Diag<'_, G> {} -rustc_data_structures::static_assert_size!( - DiagnosticBuilder<'_, ()>, - 2 * std::mem::size_of::() -); +rustc_data_structures::static_assert_size!(Diag<'_, ()>, 2 * std::mem::size_of::()); -impl Deref for DiagnosticBuilder<'_, G> { - type Target = Diagnostic; +impl Deref for Diag<'_, G> { + type Target = DiagInner; - fn deref(&self) -> &Diagnostic { + fn deref(&self) -> &DiagInner { self.diag.as_ref().unwrap() } } -impl DerefMut for DiagnosticBuilder<'_, G> { - fn deref_mut(&mut self) -> &mut Diagnostic { +impl DerefMut for Diag<'_, G> { + fn deref_mut(&mut self) -> &mut DiagInner { self.diag.as_mut().unwrap() } } -impl Debug for DiagnosticBuilder<'_, G> { +impl Debug for Diag<'_, G> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.diag.fmt(f) } } -/// `DiagnosticBuilder` impls many `&mut self -> &mut Self` methods. Each one -/// modifies an existing diagnostic, either in a standalone fashion, e.g. +/// `Diag` impls many `&mut self -> &mut Self` methods. Each one modifies an +/// existing diagnostic, either in a standalone fashion, e.g. /// `err.code(code);`, or in a chained fashion to make multiple modifications, /// e.g. `err.code(code).span(span);`. /// @@ -546,14 +560,14 @@ macro_rules! with_fn { } => { // The original function. $(#[$attrs])* - #[doc = concat!("See [`DiagnosticBuilder::", stringify!($f), "()`].")] + #[doc = concat!("See [`Diag::", stringify!($f), "()`].")] pub fn $f(&mut $self, $($name: $ty),*) -> &mut Self { $($body)* } // The `with_*` variant. $(#[$attrs])* - #[doc = concat!("See [`DiagnosticBuilder::", stringify!($f), "()`].")] + #[doc = concat!("See [`Diag::", stringify!($f), "()`].")] pub fn $with_f(mut $self, $($name: $ty),*) -> Self { $self.$f($($name),*); $self @@ -561,17 +575,16 @@ macro_rules! with_fn { }; } -impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { +impl<'a, G: EmissionGuarantee> Diag<'a, G> { #[rustc_lint_diagnostics] #[track_caller] pub fn new>(dcx: &'a DiagCtxt, level: Level, message: M) -> Self { - Self::new_diagnostic(dcx, Diagnostic::new(level, message)) + Self::new_diagnostic(dcx, DiagInner::new(level, message)) } - /// Creates a new `DiagnosticBuilder` with an already constructed - /// diagnostic. + /// Creates a new `Diag` with an already constructed diagnostic. #[track_caller] - pub(crate) fn new_diagnostic(dcx: &'a DiagCtxt, diag: Diagnostic) -> Self { + pub(crate) fn new_diagnostic(dcx: &'a DiagCtxt, diag: DiagInner) -> Self { debug!("Created new diagnostic"); Self { dcx, diag: Some(Box::new(diag)), _marker: PhantomData } } @@ -644,9 +657,9 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { pub fn note_expected_found( &mut self, expected_label: &dyn fmt::Display, - expected: DiagnosticStyledString, + expected: DiagStyledString, found_label: &dyn fmt::Display, - found: DiagnosticStyledString, + found: DiagStyledString, ) -> &mut Self { self.note_expected_found_extra(expected_label, expected, found_label, found, &"", &"") } @@ -654,9 +667,9 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { pub fn note_expected_found_extra( &mut self, expected_label: &dyn fmt::Display, - expected: DiagnosticStyledString, + expected: DiagStyledString, found_label: &dyn fmt::Display, - found: DiagnosticStyledString, + found: DiagStyledString, expected_extra: &dyn fmt::Display, found_extra: &dyn fmt::Display, ) -> &mut Self { @@ -715,7 +728,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { self } - /// This is like [`DiagnosticBuilder::note()`], but it's only printed once. + /// This is like [`Diag::note()`], but it's only printed once. pub fn note_once(&mut self, msg: impl Into) -> &mut Self { self.sub(Level::OnceNote, msg, MultiSpan::new()); self @@ -723,7 +736,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { with_fn! { with_span_note, /// Prints the span with a note above it. - /// This is like [`DiagnosticBuilder::note()`], but it gets its own span. + /// This is like [`Diag::note()`], but it gets its own span. #[rustc_lint_diagnostics] pub fn span_note( &mut self, @@ -735,7 +748,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { } } /// Prints the span with a note above it. - /// This is like [`DiagnosticBuilder::note_once()`], but it gets its own span. + /// This is like [`Diag::note_once()`], but it gets its own span. pub fn span_note_once>( &mut self, sp: S, @@ -754,7 +767,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { } } /// Prints the span with a warning above it. - /// This is like [`DiagnosticBuilder::warn()`], but it gets its own span. + /// This is like [`Diag::warn()`], but it gets its own span. #[rustc_lint_diagnostics] pub fn span_warn>( &mut self, @@ -773,7 +786,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { self } } - /// This is like [`DiagnosticBuilder::help()`], but it's only printed once. + /// This is like [`Diag::help()`], but it's only printed once. pub fn help_once(&mut self, msg: impl Into) -> &mut Self { self.sub(Level::OnceHelp, msg, MultiSpan::new()); self @@ -786,7 +799,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { } /// Prints the span with some help above it. - /// This is like [`DiagnosticBuilder::help()`], but it gets its own span. + /// This is like [`Diag::help()`], but it gets its own span. #[rustc_lint_diagnostics] pub fn span_help>( &mut self, @@ -856,7 +869,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { ) } - /// [`DiagnosticBuilder::multipart_suggestion()`] but you can set the [`SuggestionStyle`]. + /// [`Diag::multipart_suggestion()`] but you can set the [`SuggestionStyle`]. pub fn multipart_suggestion_with_style( &mut self, msg: impl Into, @@ -948,7 +961,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { self } } - /// [`DiagnosticBuilder::span_suggestion()`] but you can set the [`SuggestionStyle`]. + /// [`Diag::span_suggestion()`] but you can set the [`SuggestionStyle`]. pub fn span_suggestion_with_style( &mut self, sp: Span, @@ -993,7 +1006,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { with_fn! { with_span_suggestions, /// Prints out a message with multiple suggested edits of the code. - /// See also [`DiagnosticBuilder::span_suggestion()`]. + /// See also [`Diag::span_suggestion()`]. pub fn span_suggestions( &mut self, sp: Span, @@ -1039,7 +1052,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { /// Prints out a message with multiple suggested edits of the code, where each edit consists of /// multiple parts. - /// See also [`DiagnosticBuilder::multipart_suggestion()`]. + /// See also [`Diag::multipart_suggestion()`]. pub fn multipart_suggestions( &mut self, msg: impl Into, @@ -1199,7 +1212,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { /// Add an argument. pub fn arg( &mut self, - name: impl Into, + name: impl Into, arg: impl IntoDiagnosticArg, ) -> &mut Self { self.deref_mut().arg(name, arg); @@ -1231,14 +1244,14 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { .into_iter() .map(|m| (self.subdiagnostic_message_to_diagnostic_message(m.content), m.style)) .collect(); - let sub = SubDiagnostic { level, messages, span }; + let sub = Subdiag { level, messages, span }; self.children.push(sub); } - /// Takes the diagnostic. For use by methods that consume the - /// DiagnosticBuilder: `emit`, `cancel`, etc. Afterwards, `drop` is the - /// only code that will be run on `self`. - fn take_diag(&mut self) -> Diagnostic { + /// Takes the diagnostic. For use by methods that consume the Diag: `emit`, + /// `cancel`, etc. Afterwards, `drop` is the only code that will be run on + /// `self`. + fn take_diag(&mut self) -> DiagInner { Box::into_inner(self.diag.take().unwrap()) } @@ -1257,7 +1270,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { // because delayed bugs have their level changed to `Bug` when they are // actually printed, so they produce an ICE. // - // (Also, even though `level` isn't `pub`, the whole `Diagnostic` could + // (Also, even though `level` isn't `pub`, the whole `DiagInner` could // be overwritten with a new one thanks to `DerefMut`. So this assert // protects against that, too.) assert!( @@ -1319,13 +1332,13 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> { } } -/// Destructor bomb: every `DiagnosticBuilder` must be consumed (emitted, -/// cancelled, etc.) or we emit a bug. -impl Drop for DiagnosticBuilder<'_, G> { +/// Destructor bomb: every `Diag` must be consumed (emitted, cancelled, etc.) +/// or we emit a bug. +impl Drop for Diag<'_, G> { fn drop(&mut self) { match self.diag.take() { Some(diag) if !panicking() => { - self.dcx.emit_diagnostic(Diagnostic::new( + self.dcx.emit_diagnostic(DiagInner::new( Level::Bug, DiagnosticMessage::from("the following error was constructed but not emitted"), )); diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index bc1e81642ff26..70c8d9718681d 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -1,8 +1,8 @@ -use crate::diagnostic::DiagnosticLocation; +use crate::diagnostic::DiagLocation; use crate::{fluent_generated as fluent, AddToDiagnostic}; use crate::{ - DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, EmissionGuarantee, ErrCode, IntoDiagnostic, - IntoDiagnosticArg, Level, SubdiagnosticMessageOp, + Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, ErrCode, IntoDiagnostic, IntoDiagnosticArg, + Level, SubdiagnosticMessageOp, }; use rustc_ast as ast; use rustc_ast_pretty::pprust; @@ -20,28 +20,28 @@ use std::num::ParseIntError; use std::path::{Path, PathBuf}; use std::process::ExitStatus; -pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display); +pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display); -impl IntoDiagnosticArg for DiagnosticArgFromDisplay<'_> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { +impl IntoDiagnosticArg for DiagArgFromDisplay<'_> { + fn into_diagnostic_arg(self) -> DiagArgValue { self.0.to_string().into_diagnostic_arg() } } -impl<'a> From<&'a dyn fmt::Display> for DiagnosticArgFromDisplay<'a> { +impl<'a> From<&'a dyn fmt::Display> for DiagArgFromDisplay<'a> { fn from(t: &'a dyn fmt::Display) -> Self { - DiagnosticArgFromDisplay(t) + DiagArgFromDisplay(t) } } -impl<'a, T: fmt::Display> From<&'a T> for DiagnosticArgFromDisplay<'a> { +impl<'a, T: fmt::Display> From<&'a T> for DiagArgFromDisplay<'a> { fn from(t: &'a T) -> Self { - DiagnosticArgFromDisplay(t) + DiagArgFromDisplay(t) } } impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.clone().into_diagnostic_arg() } } @@ -50,7 +50,7 @@ macro_rules! into_diagnostic_arg_using_display { ($( $ty:ty ),+ $(,)?) => { $( impl IntoDiagnosticArg for $ty { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } @@ -62,10 +62,10 @@ macro_rules! into_diagnostic_arg_for_number { ($( $ty:ty ),+ $(,)?) => { $( impl IntoDiagnosticArg for $ty { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { // Convert to a string if it won't fit into `Number`. if let Ok(n) = TryInto::::try_into(self) { - DiagnosticArgValue::Number(n) + DiagArgValue::Number(n) } else { self.to_string().into_diagnostic_arg() } @@ -95,74 +95,74 @@ into_diagnostic_arg_using_display!( into_diagnostic_arg_for_number!(i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize); impl IntoDiagnosticArg for bool { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { if self { - DiagnosticArgValue::Str(Cow::Borrowed("true")) + DiagArgValue::Str(Cow::Borrowed("true")) } else { - DiagnosticArgValue::Str(Cow::Borrowed("false")) + DiagArgValue::Str(Cow::Borrowed("false")) } } } impl IntoDiagnosticArg for char { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}"))) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(format!("{self:?}"))) } } impl IntoDiagnosticArg for Vec { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::StrListSepByAnd( + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::StrListSepByAnd( self.into_iter().map(|c| Cow::Owned(format!("{c:?}"))).collect(), ) } } impl IntoDiagnosticArg for Symbol { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_ident_string().into_diagnostic_arg() } } impl<'a> IntoDiagnosticArg for &'a str { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } impl IntoDiagnosticArg for String { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self)) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self)) } } impl<'a> IntoDiagnosticArg for Cow<'a, str> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self.into_owned())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self.into_owned())) } } impl<'a> IntoDiagnosticArg for &'a Path { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self.display().to_string())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self.display().to_string())) } } impl IntoDiagnosticArg for PathBuf { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self.display().to_string())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self.display().to_string())) } } impl IntoDiagnosticArg for PanicStrategy { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self.desc().to_string())) } } impl IntoDiagnosticArg for hir::ConstContext { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Borrowed(match self { + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(match self { hir::ConstContext::ConstFn => "const_fn", hir::ConstContext::Static(_) => "static", hir::ConstContext::Const { .. } => "const", @@ -171,123 +171,122 @@ impl IntoDiagnosticArg for hir::ConstContext { } impl IntoDiagnosticArg for ast::Expr { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(pprust::expr_to_string(&self))) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(pprust::expr_to_string(&self))) } } impl IntoDiagnosticArg for ast::Path { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(pprust::path_to_string(&self))) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(pprust::path_to_string(&self))) } } impl IntoDiagnosticArg for ast::token::Token { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(pprust::token_to_string(&self)) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(pprust::token_to_string(&self)) } } impl IntoDiagnosticArg for ast::token::TokenKind { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(pprust::token_kind_to_string(&self)) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(pprust::token_kind_to_string(&self)) } } impl IntoDiagnosticArg for type_ir::FloatTy { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Borrowed(self.name_str())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(self.name_str())) } } impl IntoDiagnosticArg for std::ffi::CString { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned())) } } impl IntoDiagnosticArg for rustc_data_structures::small_c_str::SmallCStr { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(self.to_string_lossy().into_owned())) } } impl IntoDiagnosticArg for ast::Visibility { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { let s = pprust::vis_to_string(&self); let s = s.trim_end().to_string(); - DiagnosticArgValue::Str(Cow::Owned(s)) + DiagArgValue::Str(Cow::Owned(s)) } } impl IntoDiagnosticArg for rustc_lint_defs::Level { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag())) } } #[derive(Clone)] -pub struct DiagnosticSymbolList(Vec); +pub struct DiagSymbolList(Vec); -impl From> for DiagnosticSymbolList { +impl From> for DiagSymbolList { fn from(v: Vec) -> Self { - DiagnosticSymbolList(v) + DiagSymbolList(v) } } -impl IntoDiagnosticArg for DiagnosticSymbolList { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::StrListSepByAnd( +impl IntoDiagnosticArg for DiagSymbolList { + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::StrListSepByAnd( self.0.into_iter().map(|sym| Cow::Owned(format!("`{sym}`"))).collect(), ) } } impl IntoDiagnosticArg for hir::def::Res { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Borrowed(self.descr())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(self.descr())) } } impl IntoDiagnostic<'_, G> for TargetDataLayoutErrors<'_> { - fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { + fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> { match self { TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => { - DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_address_space) + Diag::new(dcx, level, fluent::errors_target_invalid_address_space) .with_arg("addr_space", addr_space) .with_arg("cause", cause) .with_arg("err", err) } TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => { - DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits) + Diag::new(dcx, level, fluent::errors_target_invalid_bits) .with_arg("kind", kind) .with_arg("bit", bit) .with_arg("cause", cause) .with_arg("err", err) } TargetDataLayoutErrors::MissingAlignment { cause } => { - DiagnosticBuilder::new(dcx, level, fluent::errors_target_missing_alignment) + Diag::new(dcx, level, fluent::errors_target_missing_alignment) .with_arg("cause", cause) } TargetDataLayoutErrors::InvalidAlignment { cause, err } => { - DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_alignment) + Diag::new(dcx, level, fluent::errors_target_invalid_alignment) .with_arg("cause", cause) .with_arg("err_kind", err.diag_ident()) .with_arg("align", err.align()) } TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => { - DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_architecture) + Diag::new(dcx, level, fluent::errors_target_inconsistent_architecture) .with_arg("dl", dl) .with_arg("target", target) } TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => { - DiagnosticBuilder::new(dcx, level, fluent::errors_target_inconsistent_pointer_width) + Diag::new(dcx, level, fluent::errors_target_inconsistent_pointer_width) .with_arg("pointer_size", pointer_size) .with_arg("target", target) } TargetDataLayoutErrors::InvalidBitsSize { err } => { - DiagnosticBuilder::new(dcx, level, fluent::errors_target_invalid_bits_size) - .with_arg("err", err) + Diag::new(dcx, level, fluent::errors_target_invalid_bits_size).with_arg("err", err) } } } @@ -301,7 +300,7 @@ pub struct SingleLabelManySpans { impl AddToDiagnostic for SingleLabelManySpans { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _: F, ) { diag.span_labels(self.spans, self.label); @@ -316,21 +315,21 @@ pub struct ExpectedLifetimeParameter { pub count: usize, } -impl IntoDiagnosticArg for DiagnosticLocation { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::from(self.to_string())) +impl IntoDiagnosticArg for DiagLocation { + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::from(self.to_string())) } } impl IntoDiagnosticArg for Backtrace { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::from(self.to_string())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::from(self.to_string())) } } impl IntoDiagnosticArg for Level { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::from(self.to_string())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::from(self.to_string())) } } @@ -344,7 +343,7 @@ pub struct IndicateAnonymousLifetime { } impl IntoDiagnosticArg for type_ir::ClosureKind { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(self.as_str().into()) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(self.as_str().into()) } } diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index c4b2c28fc231e..304922018ebe7 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1,6 +1,6 @@ //! The current rustc diagnostics emitter. //! -//! An `Emitter` takes care of generating the output from a `DiagnosticBuilder` struct. +//! An `Emitter` takes care of generating the output from a `Diag` struct. //! //! There are various `Emitter` implementations that generate different output formats such as //! JSON and human readable output. @@ -17,9 +17,9 @@ use crate::snippet::{ use crate::styled_buffer::StyledBuffer; use crate::translation::{to_fluent_args, Translate}; use crate::{ - diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, Diagnostic, DiagnosticMessage, - ErrCode, FluentBundle, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic, - SubstitutionHighlight, SuggestionStyle, TerminalUrl, + diagnostic::DiagLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagnosticMessage, ErrCode, + FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight, + SuggestionStyle, TerminalUrl, }; use rustc_lint_defs::pluralize; @@ -194,7 +194,7 @@ pub type DynEmitter = dyn Emitter + DynSend; /// Emitter trait for emitting errors. pub trait Emitter: Translate { /// Emit a structured diagnostic. - fn emit_diagnostic(&mut self, diag: Diagnostic); + fn emit_diagnostic(&mut self, diag: DiagInner); /// Emit a notification that an artifact has been output. /// Currently only supported for the JSON format. @@ -202,7 +202,7 @@ pub trait Emitter: Translate { /// Emit a report about future breakage. /// Currently only supported for the JSON format. - fn emit_future_breakage_report(&mut self, _diags: Vec) {} + fn emit_future_breakage_report(&mut self, _diags: Vec) {} /// Emit list of unused externs. /// Currently only supported for the JSON format. @@ -229,12 +229,12 @@ pub trait Emitter: Translate { /// /// There are a lot of conditions to this method, but in short: /// - /// * If the current `Diagnostic` has only one visible `CodeSuggestion`, + /// * If the current `DiagInner` has only one visible `CodeSuggestion`, /// we format the `help` suggestion depending on the content of the /// substitutions. In that case, we modify the span and clear the /// suggestions. /// - /// * If the current `Diagnostic` has multiple suggestions, + /// * If the current `DiagInner` has multiple suggestions, /// we leave `primary_span` and the suggestions untouched. fn primary_span_formatted( &mut self, @@ -303,7 +303,7 @@ pub trait Emitter: Translate { fn fix_multispans_in_extern_macros_and_render_macro_backtrace( &self, span: &mut MultiSpan, - children: &mut Vec, + children: &mut Vec, level: &Level, backtrace: bool, ) { @@ -350,7 +350,7 @@ pub trait Emitter: Translate { (in Nightly builds, run with -Z macro-backtrace for more info)", ); - children.push(SubDiagnostic { + children.push(Subdiag { level: Level::Note, messages: vec![(DiagnosticMessage::from(msg), Style::NoStyle)], span: MultiSpan::new(), @@ -362,7 +362,7 @@ pub trait Emitter: Translate { fn render_multispans_macro_backtrace( &self, span: &mut MultiSpan, - children: &mut Vec, + children: &mut Vec, backtrace: bool, ) { for span in iter::once(span).chain(children.iter_mut().map(|child| &mut child.span)) { @@ -461,11 +461,7 @@ pub trait Emitter: Translate { // This does a small "fix" for multispans by looking to see if it can find any that // point directly at external macros. Since these are often difficult to read, // this will change the span to point at the use site. - fn fix_multispans_in_extern_macros( - &self, - span: &mut MultiSpan, - children: &mut Vec, - ) { + fn fix_multispans_in_extern_macros(&self, span: &mut MultiSpan, children: &mut Vec) { debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children); self.fix_multispan_in_extern_macros(span); for child in children.iter_mut() { @@ -518,7 +514,7 @@ impl Emitter for HumanEmitter { self.sm.as_ref() } - fn emit_diagnostic(&mut self, mut diag: Diagnostic) { + fn emit_diagnostic(&mut self, mut diag: DiagInner) { let fluent_args = to_fluent_args(diag.args.iter()); let mut suggestions = diag.suggestions.unwrap_or(vec![]); @@ -597,7 +593,7 @@ impl Emitter for SilentEmitter { None } - fn emit_diagnostic(&mut self, mut diag: Diagnostic) { + fn emit_diagnostic(&mut self, mut diag: DiagInner) { if diag.level == Level::Fatal { diag.sub(Level::Note, self.fatal_note.clone(), MultiSpan::new()); self.fatal_dcx.emit_diagnostic(diag); @@ -1235,7 +1231,7 @@ impl HumanEmitter { max } - fn get_max_line_num(&mut self, span: &MultiSpan, children: &[SubDiagnostic]) -> usize { + fn get_max_line_num(&mut self, span: &MultiSpan, children: &[Subdiag]) -> usize { let primary = self.get_multispan_max_line_num(span); children .iter() @@ -1331,7 +1327,7 @@ impl HumanEmitter { level: &Level, max_line_num_len: usize, is_secondary: bool, - emitted_at: Option<&DiagnosticLocation>, + emitted_at: Option<&DiagLocation>, ) -> io::Result<()> { let mut buffer = StyledBuffer::new(); @@ -2098,9 +2094,9 @@ impl HumanEmitter { args: &FluentArgs<'_>, code: &Option, span: &MultiSpan, - children: &[SubDiagnostic], + children: &[Subdiag], suggestions: &[CodeSuggestion], - emitted_at: Option<&DiagnosticLocation>, + emitted_at: Option<&DiagLocation>, ) { let max_line_num_len = if self.ui_testing { ANONYMIZED_LINE_NUM.len() diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index e57b414c52df7..88a83c8bf785d 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -17,7 +17,7 @@ use crate::registry::Registry; use crate::translation::{to_fluent_args, Translate}; use crate::{ diagnostic::IsLint, CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, - SubDiagnostic, TerminalUrl, + Subdiag, TerminalUrl, }; use rustc_lint_defs::Applicability; @@ -176,7 +176,7 @@ impl Translate for JsonEmitter { } impl Emitter for JsonEmitter { - fn emit_diagnostic(&mut self, diag: crate::Diagnostic) { + fn emit_diagnostic(&mut self, diag: crate::DiagInner) { let data = Diagnostic::from_errors_diagnostic(diag, self); let result = self.emit(EmitTyped::Diagnostic(data)); if let Err(e) = result { @@ -192,7 +192,7 @@ impl Emitter for JsonEmitter { } } - fn emit_future_breakage_report(&mut self, diags: Vec) { + fn emit_future_breakage_report(&mut self, diags: Vec) { let data: Vec> = diags .into_iter() .map(|mut diag| { @@ -340,7 +340,7 @@ struct UnusedExterns<'a, 'b, 'c> { } impl Diagnostic { - fn from_errors_diagnostic(diag: crate::Diagnostic, je: &JsonEmitter) -> Diagnostic { + fn from_errors_diagnostic(diag: crate::DiagInner, je: &JsonEmitter) -> Diagnostic { let args = to_fluent_args(diag.args.iter()); let sugg = diag.suggestions.iter().flatten().map(|sugg| { let translated_message = @@ -431,16 +431,16 @@ impl Diagnostic { } fn from_sub_diagnostic( - diag: &SubDiagnostic, + subdiag: &Subdiag, args: &FluentArgs<'_>, je: &JsonEmitter, ) -> Diagnostic { - let translated_message = je.translate_messages(&diag.messages, args); + let translated_message = je.translate_messages(&subdiag.messages, args); Diagnostic { message: translated_message.to_string(), code: None, - level: diag.level.to_str(), - spans: DiagnosticSpan::from_multispan(&diag.span, args, je), + level: subdiag.level.to_str(), + spans: DiagnosticSpan::from_multispan(&subdiag.span, args, je), children: vec![], rendered: None, } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index ada8fa2e96544..2652feff62a45 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -37,14 +37,13 @@ extern crate self as rustc_errors; pub use codes::*; pub use diagnostic::{ - AddToDiagnostic, BugAbort, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgMap, - DiagnosticArgName, DiagnosticArgValue, DiagnosticBuilder, DiagnosticStyledString, - EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg, StringPart, SubDiagnostic, - SubdiagnosticMessageOp, + AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, + DiagInner, DiagStyledString, EmissionGuarantee, FatalAbort, IntoDiagnostic, IntoDiagnosticArg, + StringPart, Subdiag, SubdiagnosticMessageOp, }; pub use diagnostic_impls::{ - DiagnosticArgFromDisplay, DiagnosticSymbolList, ExpectedLifetimeParameter, - IndicateAnonymousLifetime, SingleLabelManySpans, + DiagArgFromDisplay, DiagSymbolList, ExpectedLifetimeParameter, IndicateAnonymousLifetime, + SingleLabelManySpans, }; pub use emitter::ColorConfig; pub use rustc_error_messages::{ @@ -98,7 +97,7 @@ mod styled_buffer; mod tests; pub mod translation; -pub type PErr<'a> = DiagnosticBuilder<'a>; +pub type PErr<'a> = Diag<'a>; pub type PResult<'a, T> = Result>; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } @@ -433,7 +432,7 @@ struct DiagCtxtInner { /// lint error count. lint_err_guars: Vec, /// The delayed bugs and their error guarantees. - delayed_bugs: Vec<(DelayedDiagnostic, ErrorGuaranteed)>, + delayed_bugs: Vec<(DelayedDiagInner, ErrorGuaranteed)>, /// The number of stashed errors. Unlike the other counts, this can go up /// and down, so it doesn't guarantee anything. @@ -476,9 +475,9 @@ struct DiagCtxtInner { /// add more information). All stashed diagnostics must be emitted with /// `emit_stashed_diagnostics` by the time the `DiagCtxtInner` is dropped, /// otherwise an assertion failure will occur. - stashed_diagnostics: FxIndexMap<(Span, StashKey), Diagnostic>, + stashed_diagnostics: FxIndexMap<(Span, StashKey), DiagInner>, - future_breakage_diagnostics: Vec, + future_breakage_diagnostics: Vec, /// The [`Self::unstable_expect_diagnostics`] should be empty when this struct is /// dropped. However, it can have values if the compilation is stopped early @@ -487,13 +486,13 @@ struct DiagCtxtInner { /// have been converted. check_unstable_expect_diagnostics: bool, - /// Expected [`Diagnostic`][struct@diagnostic::Diagnostic]s store a [`LintExpectationId`] as part of + /// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part of /// the lint level. [`LintExpectationId`]s created early during the compilation /// (before `HirId`s have been defined) are not stable and can therefore not be /// stored on disk. This buffer stores these diagnostics until the ID has been - /// replaced by a stable [`LintExpectationId`]. The [`Diagnostic`][struct@diagnostic::Diagnostic]s are the - /// submitted for storage and added to the list of fulfilled expectations. - unstable_expect_diagnostics: Vec, + /// replaced by a stable [`LintExpectationId`]. The [`DiagInner`][struct@diagnostic::DiagInner]s + /// are submitted for storage and added to the list of fulfilled expectations. + unstable_expect_diagnostics: Vec, /// expected diagnostic will have the level `Expect` which additionally /// carries the [`LintExpectationId`] of the expectation that can be @@ -531,11 +530,11 @@ pub enum StashKey { UndeterminedMacroResolution, } -fn default_track_diagnostic(diag: Diagnostic, f: &mut dyn FnMut(Diagnostic)) { +fn default_track_diagnostic(diag: DiagInner, f: &mut dyn FnMut(DiagInner)) { (*f)(diag) } -pub static TRACK_DIAGNOSTIC: AtomicRef = +pub static TRACK_DIAGNOSTIC: AtomicRef = AtomicRef::new(&(default_track_diagnostic as _)); #[derive(Copy, Clone, Default)] @@ -640,7 +639,7 @@ impl DiagCtxt { pub fn eagerly_translate<'a>( &self, message: DiagnosticMessage, - args: impl Iterator>, + args: impl Iterator>, ) -> SubdiagnosticMessage { let inner = self.inner.borrow(); inner.eagerly_translate(message, args) @@ -650,7 +649,7 @@ impl DiagCtxt { pub fn eagerly_translate_to_string<'a>( &self, message: DiagnosticMessage, - args: impl Iterator>, + args: impl Iterator>, ) -> String { let inner = self.inner.borrow(); inner.eagerly_translate_to_string(message, args) @@ -718,7 +717,7 @@ impl DiagCtxt { /// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key. /// Retrieve a stashed diagnostic with `steal_diagnostic`. - pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) { + pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: DiagInner) { let mut inner = self.inner.borrow_mut(); let key = (span.with_parent(None), key); @@ -736,7 +735,7 @@ impl DiagCtxt { } /// Steal a previously stashed diagnostic with the given `Span` and [`StashKey`] as the key. - pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option> { + pub fn steal_diagnostic(&self, span: Span, key: StashKey) -> Option> { let mut inner = self.inner.borrow_mut(); let key = (span.with_parent(None), key); // FIXME(#120456) - is `swap_remove` correct? @@ -746,7 +745,7 @@ impl DiagCtxt { inner.stashed_err_count -= 1; } } - Some(DiagnosticBuilder::new_diagnostic(self, diag)) + Some(Diag::new_diagnostic(self, diag)) } pub fn has_stashed_diagnostic(&self, span: Span, key: StashKey) -> bool { @@ -824,16 +823,16 @@ impl DiagCtxt { (0, _) => { // Use `ForceWarning` rather than `Warning` to guarantee emission, e.g. with a // configuration like `--cap-lints allow --force-warn bare_trait_objects`. - inner.emit_diagnostic(Diagnostic::new( + inner.emit_diagnostic(DiagInner::new( ForceWarning(None), DiagnosticMessage::Str(warnings), )); } (_, 0) => { - inner.emit_diagnostic(Diagnostic::new(Error, errors)); + inner.emit_diagnostic(DiagInner::new(Error, errors)); } (_, _) => { - inner.emit_diagnostic(Diagnostic::new(Error, format!("{errors}; {warnings}"))); + inner.emit_diagnostic(DiagInner::new(Error, format!("{errors}; {warnings}"))); } } @@ -844,7 +843,7 @@ impl DiagCtxt { .emitted_diagnostic_codes .iter() .filter_map(|&code| { - if registry.try_find_description(code).is_ok().clone() { + if registry.try_find_description(code).is_ok() { Some(code.to_string()) } else { None @@ -864,14 +863,14 @@ impl DiagCtxt { "For more information about an error, try `rustc --explain {}`.", &error_codes[0] ); - inner.emit_diagnostic(Diagnostic::new(FailureNote, msg1)); - inner.emit_diagnostic(Diagnostic::new(FailureNote, msg2)); + inner.emit_diagnostic(DiagInner::new(FailureNote, msg1)); + inner.emit_diagnostic(DiagInner::new(FailureNote, msg2)); } else { let msg = format!( "For more information about this error, try `rustc --explain {}`.", &error_codes[0] ); - inner.emit_diagnostic(Diagnostic::new(FailureNote, msg)); + inner.emit_diagnostic(DiagInner::new(FailureNote, msg)); } } } @@ -896,7 +895,7 @@ impl DiagCtxt { self.inner.borrow_mut().taught_diagnostics.insert(code) } - pub fn emit_diagnostic(&self, diagnostic: Diagnostic) -> Option { + pub fn emit_diagnostic(&self, diagnostic: DiagInner) -> Option { self.inner.borrow_mut().emit_diagnostic(diagnostic) } @@ -1000,8 +999,8 @@ impl DiagCtxt { impl DiagCtxt { // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. #[track_caller] - pub fn struct_bug(&self, msg: impl Into) -> DiagnosticBuilder<'_, BugAbort> { - DiagnosticBuilder::new(self, Bug, msg) + pub fn struct_bug(&self, msg: impl Into) -> Diag<'_, BugAbort> { + Diag::new(self, Bug, msg) } // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. @@ -1016,7 +1015,7 @@ impl DiagCtxt { &self, span: impl Into, msg: impl Into, - ) -> DiagnosticBuilder<'_, BugAbort> { + ) -> Diag<'_, BugAbort> { self.struct_bug(msg).with_span(span) } @@ -1027,10 +1026,7 @@ impl DiagCtxt { } #[track_caller] - pub fn create_bug<'a>( - &'a self, - bug: impl IntoDiagnostic<'a, BugAbort>, - ) -> DiagnosticBuilder<'a, BugAbort> { + pub fn create_bug<'a>(&'a self, bug: impl IntoDiagnostic<'a, BugAbort>) -> Diag<'a, BugAbort> { bug.into_diagnostic(self, Bug) } @@ -1041,11 +1037,8 @@ impl DiagCtxt { #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_fatal( - &self, - msg: impl Into, - ) -> DiagnosticBuilder<'_, FatalAbort> { - DiagnosticBuilder::new(self, Fatal, msg) + pub fn struct_fatal(&self, msg: impl Into) -> Diag<'_, FatalAbort> { + Diag::new(self, Fatal, msg) } #[rustc_lint_diagnostics] @@ -1060,7 +1053,7 @@ impl DiagCtxt { &self, span: impl Into, msg: impl Into, - ) -> DiagnosticBuilder<'_, FatalAbort> { + ) -> Diag<'_, FatalAbort> { self.struct_fatal(msg).with_span(span) } @@ -1074,7 +1067,7 @@ impl DiagCtxt { pub fn create_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalAbort>, - ) -> DiagnosticBuilder<'a, FatalAbort> { + ) -> Diag<'a, FatalAbort> { fatal.into_diagnostic(self, Fatal) } @@ -1087,7 +1080,7 @@ impl DiagCtxt { pub fn create_almost_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, FatalError>, - ) -> DiagnosticBuilder<'a, FatalError> { + ) -> Diag<'a, FatalError> { fatal.into_diagnostic(self, Fatal) } @@ -1102,8 +1095,8 @@ impl DiagCtxt { // FIXME: This method should be removed (every error should have an associated error code). #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_err(&self, msg: impl Into) -> DiagnosticBuilder<'_> { - DiagnosticBuilder::new(self, Error, msg) + pub fn struct_err(&self, msg: impl Into) -> Diag<'_> { + Diag::new(self, Error, msg) } #[rustc_lint_diagnostics] @@ -1118,7 +1111,7 @@ impl DiagCtxt { &self, span: impl Into, msg: impl Into, - ) -> DiagnosticBuilder<'_> { + ) -> Diag<'_> { self.struct_err(msg).with_span(span) } @@ -1133,7 +1126,7 @@ impl DiagCtxt { } #[track_caller] - pub fn create_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> DiagnosticBuilder<'a> { + pub fn create_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> Diag<'a> { err.into_diagnostic(self, Error) } @@ -1146,7 +1139,7 @@ impl DiagCtxt { // No `#[rustc_lint_diagnostics]` because bug messages aren't user-facing. #[track_caller] pub fn delayed_bug(&self, msg: impl Into) -> ErrorGuaranteed { - DiagnosticBuilder::::new(self, DelayedBug, msg).emit() + Diag::::new(self, DelayedBug, msg).emit() } /// Ensures that an error is printed. See `Level::DelayedBug`. @@ -1160,13 +1153,13 @@ impl DiagCtxt { sp: impl Into, msg: impl Into, ) -> ErrorGuaranteed { - DiagnosticBuilder::::new(self, DelayedBug, msg).with_span(sp).emit() + Diag::::new(self, DelayedBug, msg).with_span(sp).emit() } #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_warn(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { - DiagnosticBuilder::new(self, Warning, msg) + pub fn struct_warn(&self, msg: impl Into) -> Diag<'_, ()> { + Diag::new(self, Warning, msg) } #[rustc_lint_diagnostics] @@ -1181,7 +1174,7 @@ impl DiagCtxt { &self, span: impl Into, msg: impl Into, - ) -> DiagnosticBuilder<'_, ()> { + ) -> Diag<'_, ()> { self.struct_warn(msg).with_span(span) } @@ -1192,10 +1185,7 @@ impl DiagCtxt { } #[track_caller] - pub fn create_warn<'a>( - &'a self, - warning: impl IntoDiagnostic<'a, ()>, - ) -> DiagnosticBuilder<'a, ()> { + pub fn create_warn<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) -> Diag<'a, ()> { warning.into_diagnostic(self, Warning) } @@ -1206,8 +1196,8 @@ impl DiagCtxt { #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_note(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { - DiagnosticBuilder::new(self, Note, msg) + pub fn struct_note(&self, msg: impl Into) -> Diag<'_, ()> { + Diag::new(self, Note, msg) } #[rustc_lint_diagnostics] @@ -1222,7 +1212,7 @@ impl DiagCtxt { &self, span: impl Into, msg: impl Into, - ) -> DiagnosticBuilder<'_, ()> { + ) -> Diag<'_, ()> { self.struct_note(msg).with_span(span) } @@ -1233,10 +1223,7 @@ impl DiagCtxt { } #[track_caller] - pub fn create_note<'a>( - &'a self, - note: impl IntoDiagnostic<'a, ()>, - ) -> DiagnosticBuilder<'a, ()> { + pub fn create_note<'a>(&'a self, note: impl IntoDiagnostic<'a, ()>) -> Diag<'a, ()> { note.into_diagnostic(self, Note) } @@ -1247,23 +1234,20 @@ impl DiagCtxt { #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_help(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { - DiagnosticBuilder::new(self, Help, msg) + pub fn struct_help(&self, msg: impl Into) -> Diag<'_, ()> { + Diag::new(self, Help, msg) } #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_failure_note( - &self, - msg: impl Into, - ) -> DiagnosticBuilder<'_, ()> { - DiagnosticBuilder::new(self, FailureNote, msg) + pub fn struct_failure_note(&self, msg: impl Into) -> Diag<'_, ()> { + Diag::new(self, FailureNote, msg) } #[rustc_lint_diagnostics] #[track_caller] - pub fn struct_allow(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { - DiagnosticBuilder::new(self, Allow, msg) + pub fn struct_allow(&self, msg: impl Into) -> Diag<'_, ()> { + Diag::new(self, Allow, msg) } #[rustc_lint_diagnostics] @@ -1272,8 +1256,8 @@ impl DiagCtxt { &self, msg: impl Into, id: LintExpectationId, - ) -> DiagnosticBuilder<'_, ()> { - DiagnosticBuilder::new(self, Expect(id), msg) + ) -> Diag<'_, ()> { + Diag::new(self, Expect(id), msg) } } @@ -1305,7 +1289,7 @@ impl DiagCtxtInner { } // Return value is only `Some` if the level is `Error` or `DelayedBug`. - fn emit_diagnostic(&mut self, mut diagnostic: Diagnostic) -> Option { + fn emit_diagnostic(&mut self, mut diagnostic: DiagInner) -> Option { assert!(diagnostic.level.can_be_top_or_sub().0); if let Some(expectation_id) = diagnostic.level.get_expectation_id() { @@ -1354,7 +1338,7 @@ impl DiagCtxtInner { #[allow(deprecated)] let guar = ErrorGuaranteed::unchecked_error_guaranteed(); self.delayed_bugs - .push((DelayedDiagnostic::with_backtrace(diagnostic, backtrace), guar)); + .push((DelayedDiagInner::with_backtrace(diagnostic, backtrace), guar)); Some(guar) }; } @@ -1393,7 +1377,7 @@ impl DiagCtxtInner { debug!(?diagnostic); debug!(?self.emitted_diagnostics); - let already_emitted_sub = |sub: &mut SubDiagnostic| { + let already_emitted_sub = |sub: &mut Subdiag| { debug!(?sub); if sub.level != OnceNote && sub.level != OnceHelp { return false; @@ -1477,7 +1461,7 @@ impl DiagCtxtInner { pub fn eagerly_translate<'a>( &self, message: DiagnosticMessage, - args: impl Iterator>, + args: impl Iterator>, ) -> SubdiagnosticMessage { SubdiagnosticMessage::Translated(Cow::from(self.eagerly_translate_to_string(message, args))) } @@ -1486,7 +1470,7 @@ impl DiagCtxtInner { pub fn eagerly_translate_to_string<'a>( &self, message: DiagnosticMessage, - args: impl Iterator>, + args: impl Iterator>, ) -> String { let args = crate::translation::to_fluent_args(args); self.emitter.translate_message(&message, &args).map_err(Report::new).unwrap().to_string() @@ -1494,7 +1478,7 @@ impl DiagCtxtInner { fn eagerly_translate_for_subdiag( &self, - diag: &Diagnostic, + diag: &DiagInner, msg: impl Into, ) -> SubdiagnosticMessage { let msg = diag.subdiagnostic_message_to_diagnostic_message(msg); @@ -1514,14 +1498,26 @@ impl DiagCtxtInner { let bugs: Vec<_> = std::mem::take(&mut self.delayed_bugs).into_iter().map(|(b, _)| b).collect(); - // If backtraces are enabled, also print the query stack let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(true, |x| &x != "0"); - for (i, bug) in bugs.into_iter().enumerate() { - if let Some(file) = self.ice_file.as_ref() - && let Ok(mut out) = std::fs::File::options().create(true).append(true).open(file) - { - let _ = write!( - &mut out, + let decorate = backtrace || self.ice_file.is_none(); + let mut out = self + .ice_file + .as_ref() + .and_then(|file| std::fs::File::options().create(true).append(true).open(file).ok()); + + // Put the overall explanation before the `DelayedBug`s, to frame them + // better (e.g. separate warnings from them). Also, use notes, which + // don't count as errors, to avoid possibly triggering + // `-Ztreat-err-as-bug`, which we don't want. + let note1 = "no errors encountered even though delayed bugs were created"; + let note2 = "those delayed bugs will now be shown as internal compiler errors"; + self.emit_diagnostic(DiagInner::new(Note, note1)); + self.emit_diagnostic(DiagInner::new(Note, note2)); + + for bug in bugs { + if let Some(out) = &mut out { + _ = write!( + out, "delayed bug: {}\n{}\n", bug.inner .messages @@ -1532,28 +1528,16 @@ impl DiagCtxtInner { ); } - if i == 0 { - // Put the overall explanation before the `DelayedBug`s, to - // frame them better (e.g. separate warnings from them). Also, - // make it a note so it doesn't count as an error, because that - // could trigger `-Ztreat-err-as-bug`, which we don't want. - let note1 = "no errors encountered even though delayed bugs were created"; - let note2 = "those delayed bugs will now be shown as internal compiler errors"; - self.emit_diagnostic(Diagnostic::new(Note, note1)); - self.emit_diagnostic(Diagnostic::new(Note, note2)); - } - - let mut bug = - if backtrace || self.ice_file.is_none() { bug.decorate(self) } else { bug.inner }; + let mut bug = if decorate { bug.decorate(self) } else { bug.inner }; - // "Undelay" the delayed bugs (into plain `Bug`s). + // "Undelay" the delayed bugs into plain bugs. if bug.level != DelayedBug { // NOTE(eddyb) not panicking here because we're already producing // an ICE, and the more information the merrier. // - // We are at the `Diagnostic`/`DiagCtxtInner` level rather than - // the usual `DiagnosticBuilder`/`DiagCtxt` level, so we must - // augment `bug` in a lower-level fashion. + // We are at the `DiagInner`/`DiagCtxtInner` level rather than + // the usual `Diag`/`DiagCtxt` level, so we must augment `bug` + // in a lower-level fashion. bug.arg("level", bug.level); let msg = crate::fluent_generated::errors_invalid_flushed_delayed_diagnostic_level; let msg = self.eagerly_translate_for_subdiag(&bug, msg); // after the `arg` call @@ -1581,20 +1565,20 @@ impl DiagCtxtInner { } } -struct DelayedDiagnostic { - inner: Diagnostic, +struct DelayedDiagInner { + inner: DiagInner, note: Backtrace, } -impl DelayedDiagnostic { - fn with_backtrace(diagnostic: Diagnostic, backtrace: Backtrace) -> Self { - DelayedDiagnostic { inner: diagnostic, note: backtrace } +impl DelayedDiagInner { + fn with_backtrace(diagnostic: DiagInner, backtrace: Backtrace) -> Self { + DelayedDiagInner { inner: diagnostic, note: backtrace } } - fn decorate(self, dcx: &DiagCtxtInner) -> Diagnostic { - // We are at the `Diagnostic`/`DiagCtxtInner` level rather than the - // usual `DiagnosticBuilder`/`DiagCtxt` level, so we must construct - // `diag` in a lower-level fashion. + fn decorate(self, dcx: &DiagCtxtInner) -> DiagInner { + // We are at the `DiagInner`/`DiagCtxtInner` level rather than the + // usual `Diag`/`DiagCtxt` level, so we must construct `diag` in a + // lower-level fashion. let mut diag = self.inner; let msg = match self.note.status() { BacktraceStatus::Captured => crate::fluent_generated::errors_delayed_at_with_newline, @@ -1750,7 +1734,7 @@ impl Level { // FIXME(eddyb) this doesn't belong here AFAICT, should be moved to callsite. pub fn add_elided_lifetime_in_path_suggestion( source_map: &SourceMap, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, n: usize, path_span: Span, incl_angl_brckt: bool, @@ -1772,18 +1756,18 @@ pub fn add_elided_lifetime_in_path_suggestion( } pub fn report_ambiguity_error<'a, G: EmissionGuarantee>( - db: &mut DiagnosticBuilder<'a, G>, + diag: &mut Diag<'a, G>, ambiguity: rustc_lint_defs::AmbiguityErrorDiag, ) { - db.span_label(ambiguity.label_span, ambiguity.label_msg); - db.note(ambiguity.note_msg); - db.span_note(ambiguity.b1_span, ambiguity.b1_note_msg); + diag.span_label(ambiguity.label_span, ambiguity.label_msg); + diag.note(ambiguity.note_msg); + diag.span_note(ambiguity.b1_span, ambiguity.b1_note_msg); for help_msg in ambiguity.b1_help_msgs { - db.help(help_msg); + diag.help(help_msg); } - db.span_note(ambiguity.b2_span, ambiguity.b2_note_msg); + diag.span_note(ambiguity.b2_span, ambiguity.b2_note_msg); for help_msg in ambiguity.b2_help_msgs { - db.help(help_msg); + diag.help(help_msg); } } diff --git a/compiler/rustc_errors/src/translation.rs b/compiler/rustc_errors/src/translation.rs index 5f074dbbbad30..1f98ba4c3b974 100644 --- a/compiler/rustc_errors/src/translation.rs +++ b/compiler/rustc_errors/src/translation.rs @@ -1,6 +1,6 @@ use crate::error::{TranslateError, TranslateErrorKind}; use crate::snippet::Style; -use crate::{DiagnosticArg, DiagnosticMessage, FluentBundle}; +use crate::{DiagArg, DiagnosticMessage, FluentBundle}; use rustc_data_structures::sync::Lrc; pub use rustc_error_messages::FluentArgs; use std::borrow::Cow; @@ -12,9 +12,7 @@ use std::error::Report; /// /// Typically performed once for each diagnostic at the start of `emit_diagnostic` and then /// passed around as a reference thereafter. -pub fn to_fluent_args<'iter>( - iter: impl Iterator>, -) -> FluentArgs<'static> { +pub fn to_fluent_args<'iter>(iter: impl Iterator>) -> FluentArgs<'static> { let mut args = if let Some(size) = iter.size_hint().1 { FluentArgs::with_capacity(size) } else { diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 1c8d18bec65cb..485f0e7e46deb 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -13,7 +13,7 @@ use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind use rustc_attr::{self as attr, Deprecation, Stability}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync::{self, Lrc}; -use rustc_errors::{Applicability, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, PResult}; +use rustc_errors::{Applicability, Diag, DiagCtxt, ErrorGuaranteed, PResult}; use rustc_feature::Features; use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT; use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics, RegisteredTools}; @@ -532,7 +532,7 @@ impl MacResult for MacEager { /// after hitting errors. #[derive(Copy, Clone)] pub struct DummyResult { - is_error: bool, + guar: Option, span: Span, } @@ -541,20 +541,24 @@ impl DummyResult { /// /// Use this as a return value after hitting any errors and /// calling `span_err`. - pub fn any(span: Span) -> Box { - Box::new(DummyResult { is_error: true, span }) + pub fn any(span: Span, guar: ErrorGuaranteed) -> Box { + Box::new(DummyResult { guar: Some(guar), span }) } /// Same as `any`, but must be a valid fragment, not error. pub fn any_valid(span: Span) -> Box { - Box::new(DummyResult { is_error: false, span }) + Box::new(DummyResult { guar: None, span }) } /// A plain dummy expression. - pub fn raw_expr(sp: Span, is_error: bool) -> P { + pub fn raw_expr(sp: Span, guar: Option) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(ThinVec::new()) }, + kind: if let Some(guar) = guar { + ast::ExprKind::Err(guar) + } else { + ast::ExprKind::Tup(ThinVec::new()) + }, span: sp, attrs: ast::AttrVec::new(), tokens: None, @@ -582,7 +586,7 @@ impl DummyResult { impl MacResult for DummyResult { fn make_expr(self: Box) -> Option> { - Some(DummyResult::raw_expr(self.span, self.is_error)) + Some(DummyResult::raw_expr(self.span, self.guar)) } fn make_pat(self: Box) -> Option> { @@ -608,7 +612,7 @@ impl MacResult for DummyResult { fn make_stmts(self: Box) -> Option> { Some(smallvec![ast::Stmt { id: ast::DUMMY_NODE_ID, - kind: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)), + kind: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.guar)), span: self.span, }]) } @@ -884,17 +888,19 @@ impl SyntaxExtension { } } + /// A dummy bang macro `foo!()`. pub fn dummy_bang(edition: Edition) -> SyntaxExtension { fn expander<'cx>( - _: &'cx mut ExtCtxt<'_>, + cx: &'cx mut ExtCtxt<'_>, span: Span, _: TokenStream, ) -> Box { - DummyResult::any(span) + DummyResult::any(span, cx.dcx().span_delayed_bug(span, "expanded a dummy bang macro")) } SyntaxExtension::default(SyntaxExtensionKind::LegacyBang(Box::new(expander)), edition) } + /// A dummy derive macro `#[derive(Foo)]`. pub fn dummy_derive(edition: Edition) -> SyntaxExtension { fn expander( _: &mut ExtCtxt<'_>, @@ -1066,7 +1072,7 @@ pub struct ExtCtxt<'a> { pub sess: &'a Session, pub ecfg: expand::ExpansionConfig<'a>, pub num_standard_library_imports: usize, - pub reduced_recursion_limit: Option, + pub reduced_recursion_limit: Option<(Limit, ErrorGuaranteed)>, pub root_path: PathBuf, pub resolver: &'a mut dyn ResolverExpand, pub current_expansion: ExpansionData, @@ -1244,7 +1250,7 @@ pub fn resolve_path( /// Extracts a string literal from the macro expanded version of `expr`, /// returning a diagnostic error of `err_msg` if `expr` is not a string literal. /// The returned bool indicates whether an applicable suggestion has already been -/// added to the diagnostic to avoid emitting multiple suggestions. `Err(None)` +/// added to the diagnostic to avoid emitting multiple suggestions. `Err(Err(ErrorGuaranteed))` /// indicates that an ast error was encountered. // FIXME(Nilstrieb) Make this function setup translatable #[allow(rustc::untranslatable_diagnostic)] @@ -1252,7 +1258,10 @@ pub fn expr_to_spanned_string<'a>( cx: &'a mut ExtCtxt<'_>, expr: P, err_msg: &'static str, -) -> Result<(Symbol, ast::StrStyle, Span), Option<(DiagnosticBuilder<'a>, bool)>> { +) -> Result< + (Symbol, ast::StrStyle, Span), + Result<(Diag<'a>, bool /* has_suggestions */), ErrorGuaranteed>, +> { // Perform eager expansion on the expression. // We want to be able to handle e.g., `concat!("foo", "bar")`. let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr(); @@ -1269,35 +1278,33 @@ pub fn expr_to_spanned_string<'a>( "", Applicability::MaybeIncorrect, ); - Some((err, true)) + Ok((err, true)) } - Ok(ast::LitKind::Err(_)) => None, - Err(err) => { - report_lit_error(&cx.sess.parse_sess, err, token_lit, expr.span); - None - } - _ => Some((cx.dcx().struct_span_err(expr.span, err_msg), false)), + Ok(ast::LitKind::Err(guar)) => Err(guar), + Err(err) => Err(report_lit_error(&cx.sess.parse_sess, err, token_lit, expr.span)), + _ => Ok((cx.dcx().struct_span_err(expr.span, err_msg), false)), }, - ast::ExprKind::Err => None, - _ => Some((cx.dcx().struct_span_err(expr.span, err_msg), false)), + ast::ExprKind::Err(guar) => Err(guar), + ast::ExprKind::Dummy => { + cx.dcx().span_bug(expr.span, "tried to get a string literal from `ExprKind::Dummy`") + } + _ => Ok((cx.dcx().struct_span_err(expr.span, err_msg), false)), }) } /// Extracts a string literal from the macro expanded version of `expr`, /// emitting `err_msg` if `expr` is not a string literal. This does not stop -/// compilation on error, merely emits a non-fatal error and returns `None`. +/// compilation on error, merely emits a non-fatal error and returns `Err`. pub fn expr_to_string( cx: &mut ExtCtxt<'_>, expr: P, err_msg: &'static str, -) -> Option<(Symbol, ast::StrStyle)> { +) -> Result<(Symbol, ast::StrStyle), ErrorGuaranteed> { expr_to_spanned_string(cx, expr, err_msg) - .map_err(|err| { - err.map(|(err, _)| { - err.emit(); - }) + .map_err(|err| match err { + Ok((err, _)) => err.emit(), + Err(guar) => guar, }) - .ok() .map(|(symbol, style, _)| (symbol, style)) } @@ -1311,32 +1318,30 @@ pub fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str } } -/// Parse an expression. On error, emit it, advancing to `Eof`, and return `None`. -pub fn parse_expr(p: &mut parser::Parser<'_>) -> Option> { - match p.parse_expr() { - Ok(e) => return Some(e), - Err(err) => { - err.emit(); - } - } +/// Parse an expression. On error, emit it, advancing to `Eof`, and return `Err`. +pub fn parse_expr(p: &mut parser::Parser<'_>) -> Result, ErrorGuaranteed> { + let guar = match p.parse_expr() { + Ok(expr) => return Ok(expr), + Err(err) => err.emit(), + }; while p.token != token::Eof { p.bump(); } - None + Err(guar) } /// Interpreting `tts` as a comma-separated sequence of expressions, -/// expect exactly one string literal, or emit an error and return `None`. +/// expect exactly one string literal, or emit an error and return `Err`. pub fn get_single_str_from_tts( cx: &mut ExtCtxt<'_>, span: Span, tts: TokenStream, name: &str, -) -> Option { +) -> Result { let mut p = cx.new_parser_from_tts(tts); if p.token == token::Eof { - cx.dcx().emit_err(errors::OnlyOneArgument { span, name }); - return None; + let guar = cx.dcx().emit_err(errors::OnlyOneArgument { span, name }); + return Err(guar); } let ret = parse_expr(&mut p)?; let _ = p.eat(&token::Comma); @@ -1348,8 +1353,11 @@ pub fn get_single_str_from_tts( } /// Extracts comma-separated expressions from `tts`. -/// On error, emit it, and return `None`. -pub fn get_exprs_from_tts(cx: &mut ExtCtxt<'_>, tts: TokenStream) -> Option>> { +/// On error, emit it, and return `Err`. +pub fn get_exprs_from_tts( + cx: &mut ExtCtxt<'_>, + tts: TokenStream, +) -> Result>, ErrorGuaranteed> { let mut p = cx.new_parser_from_tts(tts); let mut es = Vec::new(); while p.token != token::Eof { @@ -1364,11 +1372,11 @@ pub fn get_exprs_from_tts(cx: &mut ExtCtxt<'_>, tts: TokenStream) -> Option AstFragment { - self.make_from(DummyResult::any(span)).expect("couldn't create a dummy AST fragment") + pub(crate) fn dummy(self, span: Span, guar: ErrorGuaranteed) -> AstFragment { + self.make_from(DummyResult::any(span, guar)).expect("couldn't create a dummy AST fragment") } pub fn supports_macro_expansion(self) -> SupportsMacroExpansion { @@ -604,14 +604,14 @@ impl<'a, 'b> MacroExpander<'a, 'b> { (fragment, invocations) } - fn error_recursion_limit_reached(&mut self) { + fn error_recursion_limit_reached(&mut self) -> ErrorGuaranteed { let expn_data = self.cx.current_expansion.id.expn_data(); let suggested_limit = match self.cx.ecfg.recursion_limit { Limit(0) => Limit(2), limit => limit * 2, }; - self.cx.dcx().emit_err(RecursionLimitReached { + let guar = self.cx.dcx().emit_err(RecursionLimitReached { span: expn_data.call_site, descr: expn_data.kind.descr(), suggested_limit, @@ -619,14 +619,21 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }); self.cx.trace_macros_diag(); + guar } /// A macro's expansion does not fit in this fragment kind. /// For example, a non-type macro in a type position. - fn error_wrong_fragment_kind(&mut self, kind: AstFragmentKind, mac: &ast::MacCall, span: Span) { - self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name: &mac.path }); - + fn error_wrong_fragment_kind( + &mut self, + kind: AstFragmentKind, + mac: &ast::MacCall, + span: Span, + ) -> ErrorGuaranteed { + let guar = + self.cx.dcx().emit_err(WrongFragmentKind { span, kind: kind.name(), name: &mac.path }); self.cx.trace_macros_diag(); + guar } fn expand_invoc( @@ -634,36 +641,41 @@ impl<'a, 'b> MacroExpander<'a, 'b> { invoc: Invocation, ext: &SyntaxExtensionKind, ) -> ExpandResult { - let recursion_limit = - self.cx.reduced_recursion_limit.unwrap_or(self.cx.ecfg.recursion_limit); + let recursion_limit = match self.cx.reduced_recursion_limit { + Some((limit, _)) => limit, + None => self.cx.ecfg.recursion_limit, + }; + if !recursion_limit.value_within_limit(self.cx.current_expansion.depth) { - if self.cx.reduced_recursion_limit.is_none() { - self.error_recursion_limit_reached(); - } + let guar = match self.cx.reduced_recursion_limit { + Some((_, guar)) => guar, + None => self.error_recursion_limit_reached(), + }; // Reduce the recursion limit by half each time it triggers. - self.cx.reduced_recursion_limit = Some(recursion_limit / 2); + self.cx.reduced_recursion_limit = Some((recursion_limit / 2, guar)); - return ExpandResult::Ready(invoc.fragment_kind.dummy(invoc.span())); + return ExpandResult::Ready(invoc.fragment_kind.dummy(invoc.span(), guar)); } let (fragment_kind, span) = (invoc.fragment_kind, invoc.span()); ExpandResult::Ready(match invoc.kind { InvocationKind::Bang { mac, .. } => match ext { SyntaxExtensionKind::Bang(expander) => { - let Ok(tok_result) = expander.expand(self.cx, span, mac.args.tokens.clone()) - else { - return ExpandResult::Ready(fragment_kind.dummy(span)); - }; - self.parse_ast_fragment(tok_result, fragment_kind, &mac.path, span) + match expander.expand(self.cx, span, mac.args.tokens.clone()) { + Ok(tok_result) => { + self.parse_ast_fragment(tok_result, fragment_kind, &mac.path, span) + } + Err(guar) => return ExpandResult::Ready(fragment_kind.dummy(span, guar)), + } } SyntaxExtensionKind::LegacyBang(expander) => { let tok_result = expander.expand(self.cx, span, mac.args.tokens.clone()); let result = if let Some(result) = fragment_kind.make_from(tok_result) { result } else { - self.error_wrong_fragment_kind(fragment_kind, &mac, span); - fragment_kind.dummy(span) + let guar = self.error_wrong_fragment_kind(fragment_kind, &mac, span); + fragment_kind.dummy(span, guar) }; result } @@ -705,11 +717,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.cx.dcx().emit_err(UnsupportedKeyValue { span }); } let inner_tokens = attr_item.args.inner_tokens(); - let Ok(tok_result) = expander.expand(self.cx, span, inner_tokens, tokens) - else { - return ExpandResult::Ready(fragment_kind.dummy(span)); - }; - self.parse_ast_fragment(tok_result, fragment_kind, &attr_item.path, span) + match expander.expand(self.cx, span, inner_tokens, tokens) { + Ok(tok_result) => self.parse_ast_fragment( + tok_result, + fragment_kind, + &attr_item.path, + span, + ), + Err(guar) => return ExpandResult::Ready(fragment_kind.dummy(span, guar)), + } } SyntaxExtensionKind::LegacyAttr(expander) => { match validate_attr::parse_meta(&self.cx.sess.parse_sess, &attr) { @@ -729,15 +745,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> { AstFragmentKind::Expr | AstFragmentKind::MethodReceiverExpr ) && items.is_empty() { - self.cx.dcx().emit_err(RemoveExprNotSupported { span }); - fragment_kind.dummy(span) + let guar = self.cx.dcx().emit_err(RemoveExprNotSupported { span }); + fragment_kind.dummy(span, guar) } else { fragment_kind.expect_from_annotatables(items) } } Err(err) => { - err.emit(); - fragment_kind.dummy(span) + let guar = err.emit(); + fragment_kind.dummy(span, guar) } } } @@ -857,9 +873,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { err.span(span); } annotate_err_with_kind(&mut err, kind, span); - err.emit(); + let guar = err.emit(); self.cx.trace_macros_diag(); - kind.dummy(span) + kind.dummy(span, guar) } } } diff --git a/compiler/rustc_expand/src/mbe/diagnostics.rs b/compiler/rustc_expand/src/mbe/diagnostics.rs index 25af974d3266c..053063b690e62 100644 --- a/compiler/rustc_expand/src/mbe/diagnostics.rs +++ b/compiler/rustc_expand/src/mbe/diagnostics.rs @@ -7,11 +7,11 @@ use crate::mbe::{ use rustc_ast::token::{self, Token, TokenKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast_pretty::pprust; -use rustc_errors::{Applicability, DiagCtxt, DiagnosticBuilder, DiagnosticMessage}; +use rustc_errors::{Applicability, Diag, DiagCtxt, DiagnosticMessage}; use rustc_parse::parser::{Parser, Recovery}; use rustc_span::source_map::SourceMap; use rustc_span::symbol::Ident; -use rustc_span::Span; +use rustc_span::{ErrorGuaranteed, Span}; use std::borrow::Cow; use super::macro_rules::{parser_from_cx, NoopTracker}; @@ -47,7 +47,7 @@ pub(super) fn failed_to_match_macro<'cx>( let Some(BestFailure { token, msg: label, remaining_matcher, .. }) = tracker.best_failure else { - return DummyResult::any(sp); + return DummyResult::any(sp, cx.dcx().span_delayed_bug(sp, "failed to match a macro")); }; let span = token.span.substitute_dummy(sp); @@ -106,9 +106,9 @@ pub(super) fn failed_to_match_macro<'cx>( } } } - err.emit(); + let guar = err.emit(); cx.trace_macros_diag(); - DummyResult::any(sp) + DummyResult::any(sp, guar) } /// The tracker used for the slow error path that collects useful info for diagnostics. @@ -180,10 +180,10 @@ impl<'a, 'cx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'a, 'cx, } Error(err_sp, msg) => { let span = err_sp.substitute_dummy(self.root_span); - self.cx.dcx().span_err(span, msg.clone()); - self.result = Some(DummyResult::any(span)); + let guar = self.cx.dcx().span_err(span, msg.clone()); + self.result = Some(DummyResult::any(span, guar)); } - ErrorReported(_) => self.result = Some(DummyResult::any(self.root_span)), + ErrorReported(guar) => self.result = Some(DummyResult::any(self.root_span, *guar)), } } @@ -218,13 +218,13 @@ impl<'matcher> Tracker<'matcher> for FailureForwarder { } pub(super) fn emit_frag_parse_err( - mut e: DiagnosticBuilder<'_>, + mut e: Diag<'_>, parser: &Parser<'_>, orig_parser: &mut Parser<'_>, site_span: Span, arm_span: Span, kind: AstFragmentKind, -) { +) -> ErrorGuaranteed { // FIXME(davidtwco): avoid depending on the error message text if parser.token == token::Eof && let DiagnosticMessage::Str(message) = &e.messages[0].0 @@ -282,14 +282,10 @@ pub(super) fn emit_frag_parse_err( }, _ => annotate_err_with_kind(&mut e, kind, site_span), }; - e.emit(); + e.emit() } -pub(crate) fn annotate_err_with_kind( - err: &mut DiagnosticBuilder<'_>, - kind: AstFragmentKind, - span: Span, -) { +pub(crate) fn annotate_err_with_kind(err: &mut Diag<'_>, kind: AstFragmentKind, span: Span) { match kind { AstFragmentKind::Ty => { err.span_label(span, "this macro call doesn't expand to a type"); @@ -315,12 +311,7 @@ enum ExplainDocComment { }, } -pub(super) fn annotate_doc_comment( - dcx: &DiagCtxt, - err: &mut DiagnosticBuilder<'_>, - sm: &SourceMap, - span: Span, -) { +pub(super) fn annotate_doc_comment(dcx: &DiagCtxt, err: &mut Diag<'_>, sm: &SourceMap, span: Span) { if let Ok(src) = sm.span_to_snippet(span) { if src.starts_with("///") || src.starts_with("/**") { err.subdiagnostic(dcx, ExplainDocComment::Outer { span }); diff --git a/compiler/rustc_expand/src/mbe/macro_check.rs b/compiler/rustc_expand/src/mbe/macro_check.rs index e66cfbe6fb689..8174cb03d337b 100644 --- a/compiler/rustc_expand/src/mbe/macro_check.rs +++ b/compiler/rustc_expand/src/mbe/macro_check.rs @@ -107,14 +107,14 @@ use crate::errors; use crate::mbe::{KleeneToken, TokenTree}; -use rustc_ast::token::{Delimiter, Token, TokenKind}; +use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind}; use rustc_ast::{NodeId, DUMMY_NODE_ID}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{DiagnosticMessage, MultiSpan}; use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER}; use rustc_session::parse::ParseSess; use rustc_span::symbol::kw; -use rustc_span::{symbol::MacroRulesNormalizedIdent, Span}; +use rustc_span::{symbol::MacroRulesNormalizedIdent, ErrorGuaranteed, Span}; use smallvec::SmallVec; @@ -203,17 +203,17 @@ pub(super) fn check_meta_variables( span: Span, lhses: &[TokenTree], rhses: &[TokenTree], -) -> bool { +) -> Result<(), ErrorGuaranteed> { if lhses.len() != rhses.len() { sess.dcx.span_bug(span, "length mismatch between LHSes and RHSes") } - let mut valid = true; + let mut guar = None; for (lhs, rhs) in iter::zip(lhses, rhses) { let mut binders = Binders::default(); - check_binders(sess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut valid); - check_occurrences(sess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut valid); + check_binders(sess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut guar); + check_occurrences(sess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut guar); } - valid + guar.map_or(Ok(()), Err) } /// Checks `lhs` as part of the LHS of a macro definition, extends `binders` with new binders, and @@ -226,7 +226,7 @@ pub(super) fn check_meta_variables( /// - `macros` is the stack of possible outer macros /// - `binders` contains the binders of the LHS /// - `ops` is the stack of Kleene operators from the LHS -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_binders( sess: &ParseSess, node_id: NodeId, @@ -234,7 +234,7 @@ fn check_binders( macros: &Stack<'_, MacroState<'_>>, binders: &mut Binders, ops: &Stack<'_, KleeneToken>, - valid: &mut bool, + guar: &mut Option, ) { match *lhs { TokenTree::Token(..) => {} @@ -258,7 +258,7 @@ fn check_binders( binders.insert(name, BinderInfo { span, ops: ops.into() }); } else { // 3. The meta-variable is bound: This is an occurrence. - check_occurrences(sess, node_id, lhs, macros, binders, ops, valid); + check_occurrences(sess, node_id, lhs, macros, binders, ops, guar); } } // Similarly, this can only happen when checking a toplevel macro. @@ -281,8 +281,10 @@ fn check_binders( if let Some(prev_info) = get_binder_info(macros, binders, name) { // Duplicate binders at the top-level macro definition are errors. The lint is only // for nested macro definitions. - sess.dcx.emit_err(errors::DuplicateMatcherBinding { span, prev: prev_info.span }); - *valid = false; + *guar = Some( + sess.dcx + .emit_err(errors::DuplicateMatcherBinding { span, prev: prev_info.span }), + ); } else { binders.insert(name, BinderInfo { span, ops: ops.into() }); } @@ -291,13 +293,13 @@ fn check_binders( TokenTree::MetaVarExpr(..) => {} TokenTree::Delimited(.., ref del) => { for tt in &del.tts { - check_binders(sess, node_id, tt, macros, binders, ops, valid); + check_binders(sess, node_id, tt, macros, binders, ops, guar); } } TokenTree::Sequence(_, ref seq) => { let ops = ops.push(seq.kleene); for tt in &seq.tts { - check_binders(sess, node_id, tt, macros, binders, &ops, valid); + check_binders(sess, node_id, tt, macros, binders, &ops, guar); } } } @@ -327,7 +329,7 @@ fn get_binder_info<'a>( /// - `macros` is the stack of possible outer macros /// - `binders` contains the binders of the associated LHS /// - `ops` is the stack of Kleene operators from the RHS -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_occurrences( sess: &ParseSess, node_id: NodeId, @@ -335,7 +337,7 @@ fn check_occurrences( macros: &Stack<'_, MacroState<'_>>, binders: &Binders, ops: &Stack<'_, KleeneToken>, - valid: &mut bool, + guar: &mut Option, ) { match *rhs { TokenTree::Token(..) => {} @@ -353,11 +355,11 @@ fn check_occurrences( check_ops_is_prefix(sess, node_id, macros, binders, ops, dl.entire(), name); } TokenTree::Delimited(.., ref del) => { - check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, valid); + check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, guar); } TokenTree::Sequence(_, ref seq) => { let ops = ops.push(seq.kleene); - check_nested_occurrences(sess, node_id, &seq.tts, macros, binders, &ops, valid); + check_nested_occurrences(sess, node_id, &seq.tts, macros, binders, &ops, guar); } } } @@ -392,7 +394,7 @@ enum NestedMacroState { /// - `macros` is the stack of possible outer macros /// - `binders` contains the binders of the associated LHS /// - `ops` is the stack of Kleene operators from the RHS -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_nested_occurrences( sess: &ParseSess, node_id: NodeId, @@ -400,7 +402,7 @@ fn check_nested_occurrences( macros: &Stack<'_, MacroState<'_>>, binders: &Binders, ops: &Stack<'_, KleeneToken>, - valid: &mut bool, + guar: &mut Option, ) { let mut state = NestedMacroState::Empty; let nested_macros = macros.push(MacroState { binders, ops: ops.into() }); @@ -409,7 +411,7 @@ fn check_nested_occurrences( match (state, tt) { ( NestedMacroState::Empty, - &TokenTree::Token(Token { kind: TokenKind::Ident(name, false), .. }), + &TokenTree::Token(Token { kind: TokenKind::Ident(name, IdentIsRaw::No), .. }), ) => { if name == kw::MacroRules { state = NestedMacroState::MacroRules; @@ -432,7 +434,7 @@ fn check_nested_occurrences( (NestedMacroState::MacroRulesNot, &TokenTree::MetaVar(..)) => { state = NestedMacroState::MacroRulesNotName; // We check that the meta-variable is correctly used. - check_occurrences(sess, node_id, tt, macros, binders, ops, valid); + check_occurrences(sess, node_id, tt, macros, binders, ops, guar); } (NestedMacroState::MacroRulesNotName, TokenTree::Delimited(.., del)) | (NestedMacroState::MacroName, TokenTree::Delimited(.., del)) @@ -441,7 +443,7 @@ fn check_nested_occurrences( let macro_rules = state == NestedMacroState::MacroRulesNotName; state = NestedMacroState::Empty; let rest = - check_nested_macro(sess, node_id, macro_rules, &del.tts, &nested_macros, valid); + check_nested_macro(sess, node_id, macro_rules, &del.tts, &nested_macros, guar); // If we did not check the whole macro definition, then check the rest as if outside // the macro definition. check_nested_occurrences( @@ -451,7 +453,7 @@ fn check_nested_occurrences( macros, binders, ops, - valid, + guar, ); } ( @@ -463,7 +465,7 @@ fn check_nested_occurrences( (NestedMacroState::Macro, &TokenTree::MetaVar(..)) => { state = NestedMacroState::MacroName; // We check that the meta-variable is correctly used. - check_occurrences(sess, node_id, tt, macros, binders, ops, valid); + check_occurrences(sess, node_id, tt, macros, binders, ops, guar); } (NestedMacroState::MacroName, TokenTree::Delimited(.., del)) if del.delim == Delimiter::Parenthesis => @@ -477,7 +479,7 @@ fn check_nested_occurrences( &nested_macros, &mut nested_binders, &Stack::Empty, - valid, + guar, ); } (NestedMacroState::MacroNameParen, TokenTree::Delimited(.., del)) @@ -491,12 +493,12 @@ fn check_nested_occurrences( &nested_macros, &nested_binders, &Stack::Empty, - valid, + guar, ); } (_, tt) => { state = NestedMacroState::Empty; - check_occurrences(sess, node_id, tt, macros, binders, ops, valid); + check_occurrences(sess, node_id, tt, macros, binders, ops, guar); } } } @@ -515,14 +517,14 @@ fn check_nested_occurrences( /// - `macro_rules` specifies whether the macro is `macro_rules` /// - `tts` is checked as a list of (LHS) => {RHS} /// - `macros` is the stack of outer macros -/// - `valid` is set in case of errors +/// - `guar` is set in case of errors fn check_nested_macro( sess: &ParseSess, node_id: NodeId, macro_rules: bool, tts: &[TokenTree], macros: &Stack<'_, MacroState<'_>>, - valid: &mut bool, + guar: &mut Option, ) -> usize { let n = tts.len(); let mut i = 0; @@ -539,8 +541,8 @@ fn check_nested_macro( let lhs = &tts[i]; let rhs = &tts[i + 2]; let mut binders = Binders::default(); - check_binders(sess, node_id, lhs, macros, &mut binders, &Stack::Empty, valid); - check_occurrences(sess, node_id, rhs, macros, &binders, &Stack::Empty, valid); + check_binders(sess, node_id, lhs, macros, &mut binders, &Stack::Empty, guar); + check_occurrences(sess, node_id, rhs, macros, &binders, &Stack::Empty, guar); // Since the last semicolon is optional for `macro_rules` macros and decl_macro are not terminated, // we increment our checked position by how many token trees we already checked (the 3 // above) before checking for the separator. diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index c82609503c18a..c11d538048aa9 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -8,6 +8,7 @@ use crate::mbe::macro_parser::{Error, ErrorReported, Failure, Success, TtParser} use crate::mbe::macro_parser::{MatchedSeq, MatchedTokenTree, MatcherLoc}; use crate::mbe::transcribe::transcribe; +use ast::token::IdentIsRaw; use rustc_ast as ast; use rustc_ast::token::{self, Delimiter, NonterminalKind, Token, TokenKind, TokenKind::*}; use rustc_ast::tokenstream::{DelimSpan, TokenStream}; @@ -65,8 +66,10 @@ impl<'a> ParserAnyMacro<'a> { let fragment = match parse_ast_fragment(parser, kind) { Ok(f) => f, Err(err) => { - diagnostics::emit_frag_parse_err(err, parser, snapshot, site_span, arm_span, kind); - return kind.dummy(site_span); + let guar = diagnostics::emit_frag_parse_err( + err, parser, snapshot, site_span, arm_span, kind, + ); + return kind.dummy(site_span, guar); } }; @@ -100,7 +103,6 @@ struct MacroRulesMacroExpander { transparency: Transparency, lhses: Vec>, rhses: Vec, - valid: bool, } impl TTMacroExpander for MacroRulesMacroExpander { @@ -110,9 +112,6 @@ impl TTMacroExpander for MacroRulesMacroExpander { sp: Span, input: TokenStream, ) -> Box { - if !self.valid { - return DummyResult::any(sp); - } expand_macro( cx, sp, @@ -127,12 +126,17 @@ impl TTMacroExpander for MacroRulesMacroExpander { } } -fn macro_rules_dummy_expander<'cx>( - _: &'cx mut ExtCtxt<'_>, - span: Span, - _: TokenStream, -) -> Box { - DummyResult::any(span) +struct DummyExpander(ErrorGuaranteed); + +impl TTMacroExpander for DummyExpander { + fn expand<'cx>( + &self, + _: &'cx mut ExtCtxt<'_>, + span: Span, + _: TokenStream, + ) -> Box { + DummyResult::any(span, self.0) + } } fn trace_macros_note(cx_expansions: &mut FxIndexMap>, sp: Span, message: String) { @@ -216,8 +220,8 @@ fn expand_macro<'cx>( let tts = match transcribe(cx, &named_matches, rhs, rhs_span, transparency) { Ok(tts) => tts, Err(err) => { - err.emit(); - return DummyResult::any(arm_span); + let guar = err.emit(); + return DummyResult::any(arm_span, guar); } }; @@ -248,9 +252,9 @@ fn expand_macro<'cx>( is_local, }) } - Err(CanRetry::No(_)) => { + Err(CanRetry::No(guar)) => { debug!("Will not retry matching as an error was emitted already"); - DummyResult::any(sp) + DummyResult::any(sp, guar) } Err(CanRetry::Yes) => { // Retry and emit a better error. @@ -370,7 +374,7 @@ pub fn compile_declarative_macro( def.id != DUMMY_NODE_ID, ) }; - let dummy_syn_ext = || (mk_syn_ext(Box::new(macro_rules_dummy_expander)), Vec::new()); + let dummy_syn_ext = |guar| (mk_syn_ext(Box::new(DummyExpander(guar))), Vec::new()); let dcx = &sess.parse_sess.dcx; let lhs_nm = Ident::new(sym::lhs, def.span); @@ -455,19 +459,20 @@ pub fn compile_declarative_macro( let mut err = sess.dcx().struct_span_err(sp, s); err.span_label(sp, msg); annotate_doc_comment(sess.dcx(), &mut err, sess.source_map(), sp); - err.emit(); - return dummy_syn_ext(); + let guar = err.emit(); + return dummy_syn_ext(guar); } Error(sp, msg) => { - sess.dcx().span_err(sp.substitute_dummy(def.span), msg); - return dummy_syn_ext(); + let guar = sess.dcx().span_err(sp.substitute_dummy(def.span), msg); + return dummy_syn_ext(guar); } - ErrorReported(_) => { - return dummy_syn_ext(); + ErrorReported(guar) => { + return dummy_syn_ext(guar); } }; - let mut valid = true; + let mut guar = None; + let mut check_emission = |ret: Result<(), ErrorGuaranteed>| guar = guar.or(ret.err()); // Extract the arguments: let lhses = match &argument_map[&MacroRulesNormalizedIdent::new(lhs_nm)] { @@ -487,7 +492,7 @@ pub fn compile_declarative_macro( .unwrap(); // We don't handle errors here, the driver will abort // after parsing/expansion. we can report every error in every macro this way. - valid &= check_lhs_nt_follows(sess, def, &tt).is_ok(); + check_emission(check_lhs_nt_follows(sess, def, &tt)); return tt; } sess.dcx().span_bug(def.span, "wrong-structured lhs") @@ -519,15 +524,21 @@ pub fn compile_declarative_macro( }; for rhs in &rhses { - valid &= check_rhs(sess, rhs); + check_emission(check_rhs(sess, rhs)); } // don't abort iteration early, so that errors for multiple lhses can be reported for lhs in &lhses { - valid &= check_lhs_no_empty_seq(sess, slice::from_ref(lhs)); + check_emission(check_lhs_no_empty_seq(sess, slice::from_ref(lhs))); } - valid &= macro_check::check_meta_variables(&sess.parse_sess, def.id, def.span, &lhses, &rhses); + check_emission(macro_check::check_meta_variables( + &sess.parse_sess, + def.id, + def.span, + &lhses, + &rhses, + )); let (transparency, transparency_error) = attr::find_transparency(&def.attrs, macro_rules); match transparency_error { @@ -540,11 +551,15 @@ pub fn compile_declarative_macro( None => {} } + if let Some(guar) = guar { + // To avoid warning noise, only consider the rules of this + // macro for the lint, if all rules are valid. + return dummy_syn_ext(guar); + } + // Compute the spans of the macro rules for unused rule linting. - // To avoid warning noise, only consider the rules of this - // macro for the lint, if all rules are valid. // Also, we are only interested in non-foreign macros. - let rule_spans = if valid && def.id != DUMMY_NODE_ID { + let rule_spans = if def.id != DUMMY_NODE_ID { lhses .iter() .zip(rhses.iter()) @@ -561,23 +576,19 @@ pub fn compile_declarative_macro( }; // Convert the lhses into `MatcherLoc` form, which is better for doing the - // actual matching. Unless the matcher is invalid. - let lhses = if valid { - lhses - .iter() - .map(|lhs| { - // Ignore the delimiters around the matcher. - match lhs { - mbe::TokenTree::Delimited(.., delimited) => { - mbe::macro_parser::compute_locs(&delimited.tts) - } - _ => sess.dcx().span_bug(def.span, "malformed macro lhs"), + // actual matching. + let lhses = lhses + .iter() + .map(|lhs| { + // Ignore the delimiters around the matcher. + match lhs { + mbe::TokenTree::Delimited(.., delimited) => { + mbe::macro_parser::compute_locs(&delimited.tts) } - }) - .collect() - } else { - vec![] - }; + _ => sess.dcx().span_bug(def.span, "malformed macro lhs"), + } + }) + .collect(); let expander = Box::new(MacroRulesMacroExpander { name: def.ident, @@ -586,7 +597,6 @@ pub fn compile_declarative_macro( transparency, lhses, rhses, - valid, }); (mk_syn_ext(expander), rule_spans) } @@ -639,7 +649,7 @@ fn is_empty_token_tree(sess: &Session, seq: &mbe::SequenceRepetition) -> bool { /// Checks that the lhs contains no repetition which could match an empty token /// tree, because then the matcher would hang indefinitely. -fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> bool { +fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> Result<(), ErrorGuaranteed> { use mbe::TokenTree; for tt in tts { match tt { @@ -647,35 +657,26 @@ fn check_lhs_no_empty_seq(sess: &Session, tts: &[mbe::TokenTree]) -> bool { | TokenTree::MetaVar(..) | TokenTree::MetaVarDecl(..) | TokenTree::MetaVarExpr(..) => (), - TokenTree::Delimited(.., del) => { - if !check_lhs_no_empty_seq(sess, &del.tts) { - return false; - } - } + TokenTree::Delimited(.., del) => check_lhs_no_empty_seq(sess, &del.tts)?, TokenTree::Sequence(span, seq) => { if is_empty_token_tree(sess, seq) { let sp = span.entire(); - sess.dcx().span_err(sp, "repetition matches empty token tree"); - return false; - } - if !check_lhs_no_empty_seq(sess, &seq.tts) { - return false; + let guar = sess.dcx().span_err(sp, "repetition matches empty token tree"); + return Err(guar); } + check_lhs_no_empty_seq(sess, &seq.tts)? } } } - true + Ok(()) } -fn check_rhs(sess: &Session, rhs: &mbe::TokenTree) -> bool { +fn check_rhs(sess: &Session, rhs: &mbe::TokenTree) -> Result<(), ErrorGuaranteed> { match *rhs { - mbe::TokenTree::Delimited(..) => return true, - _ => { - sess.dcx().span_err(rhs.span(), "macro rhs must be delimited"); - } + mbe::TokenTree::Delimited(..) => Ok(()), + _ => Err(sess.dcx().span_err(rhs.span(), "macro rhs must be delimited")), } - false } fn check_matcher( @@ -1302,7 +1303,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { match tok { TokenTree::Token(token) => match token.kind { FatArrow | Comma | Eq | BinOp(token::Or) => IsInFollow::Yes, - Ident(name, false) if name == kw::If || name == kw::In => IsInFollow::Yes, + Ident(name, IdentIsRaw::No) if name == kw::If || name == kw::In => { + IsInFollow::Yes + } _ => IsInFollow::No(TOKENS), }, _ => IsInFollow::No(TOKENS), @@ -1313,7 +1316,9 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { match tok { TokenTree::Token(token) => match token.kind { FatArrow | Comma | Eq => IsInFollow::Yes, - Ident(name, false) if name == kw::If || name == kw::In => IsInFollow::Yes, + Ident(name, IdentIsRaw::No) if name == kw::If || name == kw::In => { + IsInFollow::Yes + } _ => IsInFollow::No(TOKENS), }, _ => IsInFollow::No(TOKENS), @@ -1336,7 +1341,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { | BinOp(token::Shr) | Semi | BinOp(token::Or) => IsInFollow::Yes, - Ident(name, false) if name == kw::As || name == kw::Where => { + Ident(name, IdentIsRaw::No) if name == kw::As || name == kw::Where => { IsInFollow::Yes } _ => IsInFollow::No(TOKENS), @@ -1364,7 +1369,8 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { match tok { TokenTree::Token(token) => match token.kind { Comma => IsInFollow::Yes, - Ident(name, is_raw) if is_raw || name != kw::Priv => IsInFollow::Yes, + Ident(_, IdentIsRaw::Yes) => IsInFollow::Yes, + Ident(name, _) if name != kw::Priv => IsInFollow::Yes, _ => { if token.can_begin_type() { IsInFollow::Yes diff --git a/compiler/rustc_expand/src/mbe/metavar_expr.rs b/compiler/rustc_expand/src/mbe/metavar_expr.rs index 3ca0787ce8e1f..84f7dc4771a9e 100644 --- a/compiler/rustc_expand/src/mbe/metavar_expr.rs +++ b/compiler/rustc_expand/src/mbe/metavar_expr.rs @@ -1,4 +1,4 @@ -use rustc_ast::token::{self, Delimiter}; +use rustc_ast::token::{self, Delimiter, IdentIsRaw}; use rustc_ast::tokenstream::{RefTokenTreeCursor, TokenStream, TokenTree}; use rustc_ast::{LitIntType, LitKind}; use rustc_ast_pretty::pprust; @@ -142,7 +142,7 @@ fn parse_ident<'sess>( if let Some(tt) = iter.next() && let TokenTree::Token(token, _) = tt { - if let Some((elem, false)) = token.ident() { + if let Some((elem, IdentIsRaw::No)) = token.ident() { return Ok(elem); } let token_str = pprust::token_to_string(token); diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 0fdfa5631389e..ec1dd807d1a4f 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -2,7 +2,7 @@ use crate::errors; use crate::mbe::macro_parser::count_metavar_decls; use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree}; -use rustc_ast::token::{self, Delimiter, Token}; +use rustc_ast::token::{self, Delimiter, IdentIsRaw, Token}; use rustc_ast::{tokenstream, NodeId}; use rustc_ast_pretty::pprust; use rustc_feature::Features; @@ -222,7 +222,7 @@ fn parse_tree<'a>( Some(tokenstream::TokenTree::Token(token, _)) if token.is_ident() => { let (ident, is_raw) = token.ident().unwrap(); let span = ident.span.with_lo(span.lo()); - if ident.name == kw::Crate && !is_raw { + if ident.name == kw::Crate && matches!(is_raw, IdentIsRaw::No) { TokenTree::token(token::Ident(kw::DollarCrate, is_raw), span) } else { TokenTree::MetaVar(span, ident) diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 519e4a634d8ab..8fcd468e34b7a 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -9,7 +9,7 @@ use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_errors::{pluralize, PResult}; use rustc_span::hygiene::{LocalExpnId, Transparency}; use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent}; @@ -555,23 +555,14 @@ fn count_repetitions<'a>( ) -> PResult<'a, usize> { // Recursively count the number of matches in `matched` at given depth // (or at the top-level of `matched` if no depth is given). - fn count<'a>( - cx: &ExtCtxt<'a>, - depth_curr: usize, - depth_max: usize, - matched: &NamedMatch, - sp: &DelimSpan, - ) -> PResult<'a, usize> { + fn count<'a>(depth_curr: usize, depth_max: usize, matched: &NamedMatch) -> PResult<'a, usize> { match matched { MatchedTokenTree(_) | MatchedNonterminal(_) => Ok(1), MatchedSeq(named_matches) => { if depth_curr == depth_max { Ok(named_matches.len()) } else { - named_matches - .iter() - .map(|elem| count(cx, depth_curr + 1, depth_max, elem, sp)) - .sum() + named_matches.iter().map(|elem| count(depth_curr + 1, depth_max, elem)).sum() } } } @@ -612,7 +603,7 @@ fn count_repetitions<'a>( return Err(cx.dcx().create_err(CountRepetitionMisplaced { span: sp.entire() })); } - count(cx, depth_user, depth_max, matched, sp) + count(depth_user, depth_max, matched) } /// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident] @@ -631,12 +622,7 @@ where /// Used by meta-variable expressions when an user input is out of the actual declared bounds. For /// example, index(999999) in an repetition of only three elements. -fn out_of_bounds_err<'a>( - cx: &ExtCtxt<'a>, - max: usize, - span: Span, - ty: &str, -) -> DiagnosticBuilder<'a> { +fn out_of_bounds_err<'a>(cx: &ExtCtxt<'a>, max: usize, span: Span, ty: &str) -> Diag<'a> { let msg = if max == 0 { format!( "meta-variable expression `{ty}` with depth parameter \ diff --git a/compiler/rustc_expand/src/module.rs b/compiler/rustc_expand/src/module.rs index e979f9a75d4d1..1282cf2c03a00 100644 --- a/compiler/rustc_expand/src/module.rs +++ b/compiler/rustc_expand/src/module.rs @@ -4,7 +4,7 @@ use crate::errors::{ }; use rustc_ast::ptr::P; use rustc_ast::{token, AttrVec, Attribute, Inline, Item, ModSpans}; -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::{Diag, ErrorGuaranteed}; use rustc_parse::new_parser_from_file; use rustc_parse::validate_attr; use rustc_session::parse::ParseSess; @@ -43,7 +43,7 @@ pub enum ModError<'a> { ModInBlock(Option), FileNotFound(Ident, PathBuf, PathBuf), MultipleCandidates(Ident, PathBuf, PathBuf), - ParserError(DiagnosticBuilder<'a>), + ParserError(Diag<'a>), } pub(crate) fn parse_external_mod( diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index 7a888250ca161..0e07b41b43c7d 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -2,6 +2,7 @@ use crate::tests::{ matches_codepattern, string_to_stream, with_error_checking_parse, with_expected_parse_error, }; +use ast::token::IdentIsRaw; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token}; use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; @@ -74,9 +75,12 @@ fn string_to_tts_macro() { match tts { [ - TokenTree::Token(Token { kind: token::Ident(name_macro_rules, false), .. }, _), + TokenTree::Token( + Token { kind: token::Ident(name_macro_rules, IdentIsRaw::No), .. }, + _, + ), TokenTree::Token(Token { kind: token::Not, .. }, _), - TokenTree::Token(Token { kind: token::Ident(name_zip, false), .. }, _), + TokenTree::Token(Token { kind: token::Ident(name_zip, IdentIsRaw::No), .. }, _), TokenTree::Delimited(.., macro_delim, macro_tts), ] if name_macro_rules == &kw::MacroRules && name_zip.as_str() == "zip" => { let tts = ¯o_tts.trees().collect::>(); @@ -90,7 +94,10 @@ fn string_to_tts_macro() { match &tts[..] { [ TokenTree::Token(Token { kind: token::Dollar, .. }, _), - TokenTree::Token(Token { kind: token::Ident(name, false), .. }, _), + TokenTree::Token( + Token { kind: token::Ident(name, IdentIsRaw::No), .. }, + _, + ), ] if first_delim == &Delimiter::Parenthesis && name.as_str() == "a" => { } _ => panic!("value 3: {:?} {:?}", first_delim, first_tts), @@ -99,7 +106,10 @@ fn string_to_tts_macro() { match &tts[..] { [ TokenTree::Token(Token { kind: token::Dollar, .. }, _), - TokenTree::Token(Token { kind: token::Ident(name, false), .. }, _), + TokenTree::Token( + Token { kind: token::Ident(name, IdentIsRaw::No), .. }, + _, + ), ] if second_delim == &Delimiter::Parenthesis && name.as_str() == "a" => {} _ => panic!("value 4: {:?} {:?}", second_delim, second_tts), @@ -119,8 +129,11 @@ fn string_to_tts_1() { let tts = string_to_stream("fn a(b: i32) { b; }".to_string()); let expected = TokenStream::new(vec![ - TokenTree::token_alone(token::Ident(kw::Fn, false), sp(0, 2)), - TokenTree::token_joint_hidden(token::Ident(Symbol::intern("a"), false), sp(3, 4)), + TokenTree::token_alone(token::Ident(kw::Fn, IdentIsRaw::No), sp(0, 2)), + TokenTree::token_joint_hidden( + token::Ident(Symbol::intern("a"), IdentIsRaw::No), + sp(3, 4), + ), TokenTree::Delimited( DelimSpan::from_pair(sp(4, 5), sp(11, 12)), // `JointHidden` because the `(` is followed immediately by @@ -128,10 +141,16 @@ fn string_to_tts_1() { DelimSpacing::new(Spacing::JointHidden, Spacing::Alone), Delimiter::Parenthesis, TokenStream::new(vec![ - TokenTree::token_joint(token::Ident(Symbol::intern("b"), false), sp(5, 6)), + TokenTree::token_joint( + token::Ident(Symbol::intern("b"), IdentIsRaw::No), + sp(5, 6), + ), TokenTree::token_alone(token::Colon, sp(6, 7)), // `JointHidden` because the `i32` is immediately followed by the `)`. - TokenTree::token_joint_hidden(token::Ident(sym::i32, false), sp(8, 11)), + TokenTree::token_joint_hidden( + token::Ident(sym::i32, IdentIsRaw::No), + sp(8, 11), + ), ]) .into(), ), @@ -143,7 +162,10 @@ fn string_to_tts_1() { DelimSpacing::new(Spacing::Alone, Spacing::Alone), Delimiter::Brace, TokenStream::new(vec![ - TokenTree::token_joint(token::Ident(Symbol::intern("b"), false), sp(15, 16)), + TokenTree::token_joint( + token::Ident(Symbol::intern("b"), IdentIsRaw::No), + sp(15, 16), + ), // `Alone` because the `;` is followed by whitespace. TokenTree::token_alone(token::Semi, sp(16, 17)), ]) diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 62d0deb2d3a6d..6fe0d61136322 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -1,4 +1,5 @@ use crate::base::ExtCtxt; +use ast::token::IdentIsRaw; use pm::bridge::{ server, DelimSpan, Diagnostic, ExpnGlobals, Group, Ident, LitKind, Literal, Punct, TokenTree, }; @@ -10,7 +11,7 @@ use rustc_ast::util::literal::escape_byte_str_symbol; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, MultiSpan, PResult}; +use rustc_errors::{Diag, ErrorGuaranteed, MultiSpan, PResult}; use rustc_parse::lexer::nfc_normalize; use rustc_parse::parse_stream_from_source_str; use rustc_session::parse::ParseSess; @@ -216,7 +217,9 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec op("?"), SingleQuote => op("'"), - Ident(sym, is_raw) => trees.push(TokenTree::Ident(Ident { sym, is_raw, span })), + Ident(sym, is_raw) => { + trees.push(TokenTree::Ident(Ident { sym, is_raw: is_raw.into(), span })) + } Lifetime(name) => { let ident = symbol::Ident::new(name, span).without_first_quote(); trees.extend([ @@ -238,7 +241,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec)> for Vec { trees.push(TokenTree::Ident(Ident { sym: ident.name, - is_raw: *is_raw, + is_raw: matches!(is_raw, IdentIsRaw::Yes), span: ident.span, })) } @@ -352,7 +355,7 @@ impl ToInternal> } TokenTree::Ident(self::Ident { sym, is_raw, span }) => { rustc.sess().symbol_gallery.insert(sym, span); - smallvec![tokenstream::TokenTree::token_alone(Ident(sym, is_raw), span)] + smallvec![tokenstream::TokenTree::token_alone(Ident(sym, is_raw.into()), span)] } TokenTree::Literal(self::Literal { kind: self::LitKind::Integer, @@ -510,8 +513,8 @@ impl server::FreeFunctions for Rustc<'_, '_> { fn emit_diagnostic(&mut self, diagnostic: Diagnostic) { let message = rustc_errors::DiagnosticMessage::from(diagnostic.message); - let mut diag: DiagnosticBuilder<'_, ()> = - DiagnosticBuilder::new(&self.sess().dcx, diagnostic.level.to_internal(), message); + let mut diag: Diag<'_, ()> = + Diag::new(&self.sess().dcx, diagnostic.level.to_internal(), message); diag.span(MultiSpan::from_spans(diagnostic.spans)); for child in diagnostic.children { diag.sub(child.level.to_internal(), child.message, MultiSpan::from_spans(child.spans)); @@ -570,7 +573,7 @@ impl server::TokenStream for Rustc<'_, '_> { match &expr.kind { ast::ExprKind::Lit(token_lit) if token_lit.kind == token::Bool => { Ok(tokenstream::TokenStream::token_alone( - token::Ident(token_lit.symbol, false), + token::Ident(token_lit.symbol, IdentIsRaw::No), expr.span, )) } diff --git a/compiler/rustc_expand/src/tokenstream/tests.rs b/compiler/rustc_expand/src/tokenstream/tests.rs index 91c4dd732e3a5..78795e86fd5da 100644 --- a/compiler/rustc_expand/src/tokenstream/tests.rs +++ b/compiler/rustc_expand/src/tokenstream/tests.rs @@ -1,6 +1,6 @@ use crate::tests::string_to_stream; -use rustc_ast::token; +use rustc_ast::token::{self, IdentIsRaw}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_span::create_default_session_globals_then; use rustc_span::{BytePos, Span, Symbol}; @@ -86,7 +86,8 @@ fn test_diseq_1() { fn test_is_empty() { create_default_session_globals_then(|| { let test0 = TokenStream::default(); - let test1 = TokenStream::token_alone(token::Ident(Symbol::intern("a"), false), sp(0, 1)); + let test1 = + TokenStream::token_alone(token::Ident(Symbol::intern("a"), IdentIsRaw::No), sp(0, 1)); let test2 = string_to_ts("foo(bar::baz)"); assert_eq!(test0.is_empty(), true); diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 18f6ae35054b4..1b2993dabdb83 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -84,6 +84,8 @@ declare_features! ( (accepted, cfg_doctest, "1.40.0", Some(62210)), /// Enables `#[cfg(panic = "...")]` config key. (accepted, cfg_panic, "1.60.0", Some(77443)), + /// Allows `cfg(target_abi = "...")`. + (accepted, cfg_target_abi, "CURRENT_RUSTC_VERSION", Some(80970)), /// Allows `cfg(target_feature = "...")`. (accepted, cfg_target_feature, "1.27.0", Some(29717)), /// Allows `cfg(target_vendor = "...")`. diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 99875ec540545..327c70ede28ee 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -25,7 +25,6 @@ pub type GatedCfg = (Symbol, Symbol, GateFn); const GATED_CFGS: &[GatedCfg] = &[ // (name in cfg, feature, function to check if the feature is enabled) (sym::overflow_checks, sym::cfg_overflow_checks, cfg_fn!(cfg_overflow_checks)), - (sym::target_abi, sym::cfg_target_abi, cfg_fn!(cfg_target_abi)), (sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)), ( sym::target_has_atomic_equal_alignment, @@ -278,25 +277,35 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ungated!(cfg_attr, Normal, template!(List: "predicate, attr1, attr2, ..."), DuplicatesOk), // Testing: - ungated!(ignore, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing), + ungated!( + ignore, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing, + @only_local: true, + ), ungated!( should_panic, Normal, template!(Word, List: r#"expected = "reason""#, NameValueStr: "reason"), FutureWarnFollowing, + @only_local: true, ), // FIXME(Centril): This can be used on stable but shouldn't. - ungated!(reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing), + ungated!( + reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing, + @only_local: true, + ), // Macros: ungated!(automatically_derived, Normal, template!(Word), WarnFollowing), - ungated!(macro_use, Normal, template!(Word, List: "name1, name2, ..."), WarnFollowingWordOnly), - ungated!(macro_escape, Normal, template!(Word), WarnFollowing), // Deprecated synonym for `macro_use`. + ungated!( + macro_use, Normal, template!(Word, List: "name1, name2, ..."), WarnFollowingWordOnly, + @only_local: true, + ), + ungated!(macro_escape, Normal, template!(Word), WarnFollowing, @only_local: true), // Deprecated synonym for `macro_use`. ungated!(macro_export, Normal, template!(Word, List: "local_inner_macros"), WarnFollowing), - ungated!(proc_macro, Normal, template!(Word), ErrorFollowing), + ungated!(proc_macro, Normal, template!(Word), ErrorFollowing, @only_local: true), ungated!( - proc_macro_derive, Normal, - template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing, + proc_macro_derive, Normal, template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"), + ErrorFollowing, @only_local: true, ), - ungated!(proc_macro_attribute, Normal, template!(Word), ErrorFollowing), + ungated!(proc_macro_attribute, Normal, template!(Word), ErrorFollowing, @only_local: true), // Lints: ungated!( @@ -309,7 +318,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), gated!( expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk, - lint_reasons, experimental!(expect) + @only_local: true, lint_reasons, experimental!(expect) ), ungated!( forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), @@ -335,50 +344,67 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), // Crate properties: - ungated!(crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing), - ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), DuplicatesOk), + ungated!( + crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing, + @only_local: true, + ), + ungated!( + crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), DuplicatesOk, + @only_local: true, + ), // crate_id is deprecated - ungated!(crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing), + ungated!( + crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing, + @only_local: true, + ), // ABI, linking, symbols, and FFI ungated!( link, Normal, template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated""#), DuplicatesOk, + @only_local: true, ), ungated!(link_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding), - ungated!(no_link, Normal, template!(Word), WarnFollowing), + ungated!(no_link, Normal, template!(Word), WarnFollowing, @only_local: true), ungated!(repr, Normal, template!(List: "C"), DuplicatesOk, @only_local: true), - ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding), - ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding), + ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, @only_local: true), + ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding, @only_local: true), ungated!(no_mangle, Normal, template!(Word), WarnFollowing, @only_local: true), ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, @only_local: true), ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding), // Limits: - ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing), - ungated!(type_length_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing), + ungated!( + recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing, + @only_local: true + ), + ungated!( + type_length_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing, + @only_local: true + ), gated!( move_size_limit, CrateLevel, template!(NameValueStr: "N"), ErrorFollowing, - large_assignments, experimental!(move_size_limit) + @only_local: true, large_assignments, experimental!(move_size_limit) ), // Entry point: gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)), - ungated!(start, Normal, template!(Word), WarnFollowing), - ungated!(no_start, CrateLevel, template!(Word), WarnFollowing), - ungated!(no_main, CrateLevel, template!(Word), WarnFollowing), + ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true), + ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, @only_local: true), + ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true), // Modules, prelude, and resolution: - ungated!(path, Normal, template!(NameValueStr: "file"), FutureWarnFollowing), - ungated!(no_std, CrateLevel, template!(Word), WarnFollowing), - ungated!(no_implicit_prelude, Normal, template!(Word), WarnFollowing), + ungated!(path, Normal, template!(NameValueStr: "file"), FutureWarnFollowing, @only_local: true), + ungated!(no_std, CrateLevel, template!(Word), WarnFollowing, @only_local: true), + ungated!(no_implicit_prelude, Normal, template!(Word), WarnFollowing, @only_local: true), ungated!(non_exhaustive, Normal, template!(Word), WarnFollowing), // Runtime ungated!( windows_subsystem, CrateLevel, - template!(NameValueStr: "windows|console"), FutureWarnFollowing + template!(NameValueStr: "windows|console"), FutureWarnFollowing, + @only_local: true ), ungated!(panic_handler, Normal, template!(Word), WarnFollowing), // RFC 2070 @@ -391,13 +417,17 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ DuplicatesOk, @only_local: true, ), ungated!(track_caller, Normal, template!(Word), WarnFollowing), - ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding), + ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, @only_local: true), gated!( no_sanitize, Normal, template!(List: "address, kcfi, memory, thread"), DuplicatesOk, - experimental!(no_sanitize) + @only_local: true, experimental!(no_sanitize) + ), + gated!( + coverage, Normal, template!(Word, List: "on|off"), + WarnFollowing, @only_local: true, + coverage_attribute, experimental!(coverage) ), - gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)), ungated!( doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk @@ -406,7 +436,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // Debugging ungated!( debugger_visualizer, Normal, - template!(List: r#"natvis_file = "...", gdb_script_file = "...""#), DuplicatesOk + template!(List: r#"natvis_file = "...", gdb_script_file = "...""#), + DuplicatesOk, @only_local: true ), // ========================================================================== @@ -430,26 +461,35 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ marker_trait_attr, experimental!(marker) ), gated!( - thread_local, Normal, template!(Word), WarnFollowing, + thread_local, Normal, template!(Word), WarnFollowing, @only_local: true, "`#[thread_local]` is an experimental feature, and does not currently handle destructors", ), - gated!(no_core, CrateLevel, template!(Word), WarnFollowing, experimental!(no_core)), + gated!( + no_core, CrateLevel, template!(Word), WarnFollowing, + @only_local: true, experimental!(no_core) + ), // RFC 2412 gated!( - optimize, Normal, template!(List: "size|speed"), ErrorPreceding, optimize_attribute, - experimental!(optimize), + optimize, Normal, template!(List: "size|speed"), ErrorPreceding, + @only_local: true, optimize_attribute, experimental!(optimize) ), - gated!(ffi_pure, Normal, template!(Word), WarnFollowing, experimental!(ffi_pure)), - gated!(ffi_const, Normal, template!(Word), WarnFollowing, experimental!(ffi_const)), + gated!( + ffi_pure, Normal, template!(Word), WarnFollowing, + @only_local: true, experimental!(ffi_pure) + ), + gated!( + ffi_const, Normal, template!(Word), WarnFollowing, + @only_local: true, experimental!(ffi_const) + ), gated!( register_tool, CrateLevel, template!(List: "tool1, tool2, ..."), DuplicatesOk, - experimental!(register_tool), + @only_local: true, experimental!(register_tool), ), gated!( cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing, - experimental!(cmse_nonsecure_entry) + @only_local: true, experimental!(cmse_nonsecure_entry) ), // RFC 2632 gated!( @@ -467,11 +507,14 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // `#[collapse_debuginfo]` gated!( collapse_debuginfo, Normal, template!(Word, List: "no|external|yes"), ErrorFollowing, - experimental!(collapse_debuginfo) + @only_local: true, experimental!(collapse_debuginfo) ), // RFC 2397 - gated!(do_not_recommend, Normal, template!(Word), WarnFollowing, experimental!(do_not_recommend)), + gated!( + do_not_recommend, Normal, template!(Word), WarnFollowing, + @only_local: true, experimental!(do_not_recommend) + ), // `#[cfi_encoding = ""]` gated!( @@ -503,7 +546,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), ungated!( rustc_default_body_unstable, Normal, - template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk + template!(List: r#"feature = "name", reason = "...", issue = "N""#), + DuplicatesOk, @only_local: true ), gated!( allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."), DuplicatesOk, @@ -511,16 +555,19 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ), gated!( rustc_allow_const_fn_unstable, Normal, - template!(Word, List: "feat1, feat2, ..."), DuplicatesOk, + template!(Word, List: "feat1, feat2, ..."), DuplicatesOk, @only_local: true, "rustc_allow_const_fn_unstable side-steps feature gating and stability checks" ), gated!( allow_internal_unsafe, Normal, template!(Word), WarnFollowing, - "allow_internal_unsafe side-steps the unsafe_code lint", + @only_local: true, "allow_internal_unsafe side-steps the unsafe_code lint", + ), + rustc_attr!( + rustc_allowed_through_unstable_modules, Normal, template!(Word), + WarnFollowing, @only_local: true, + "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \ + through unstable paths" ), - rustc_attr!(rustc_allowed_through_unstable_modules, Normal, template!(Word), WarnFollowing, - "rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \ - through unstable paths"), // ========================================================================== // Internal attributes: Type system related: @@ -528,7 +575,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ gated!(fundamental, Normal, template!(Word), WarnFollowing, experimental!(fundamental)), gated!( - may_dangle, Normal, template!(Word), WarnFollowing, dropck_eyepatch, + may_dangle, Normal, template!(Word), WarnFollowing, + @only_local: true, dropck_eyepatch, "`may_dangle` has unstable semantics and may be removed in the future", ), @@ -536,31 +584,51 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // Internal attributes: Runtime related: // ========================================================================== - rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_reallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_deallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), + rustc_attr!( + rustc_allocator, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_nounwind, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_reallocator, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_deallocator, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + rustc_attr!( + rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, + @only_local: true, IMPL_DETAIL + ), + gated!( + default_lib_allocator, Normal, template!(Word), WarnFollowing, + @only_local: true, allocator_internals, experimental!(default_lib_allocator), + ), gated!( - default_lib_allocator, Normal, template!(Word), WarnFollowing, allocator_internals, - experimental!(default_lib_allocator), + needs_allocator, Normal, template!(Word), WarnFollowing, + @only_local: true, allocator_internals, experimental!(needs_allocator), ), gated!( - needs_allocator, Normal, template!(Word), WarnFollowing, allocator_internals, - experimental!(needs_allocator), + panic_runtime, Normal, template!(Word), WarnFollowing, + @only_local: true, experimental!(panic_runtime) ), - gated!(panic_runtime, Normal, template!(Word), WarnFollowing, experimental!(panic_runtime)), gated!( needs_panic_runtime, Normal, template!(Word), WarnFollowing, - experimental!(needs_panic_runtime) + @only_local: true, experimental!(needs_panic_runtime) ), gated!( compiler_builtins, Normal, template!(Word), WarnFollowing, + @only_local: true, "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \ which contains compiler-rt intrinsics and will never be stable", ), gated!( profiler_runtime, Normal, template!(Word), WarnFollowing, + @only_local: true, "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \ which contains the profiler runtime and will never be stable", ), @@ -586,7 +654,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ template!(Word, List: "name, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing, IMPL_DETAIL, ), - rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE), + rustc_attr!( + rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, + @only_local: true, INTERNAL_UNSTABLE + ), rustc_attr!( rustc_macro_transparency, Normal, template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing, @@ -792,6 +863,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_intrinsic, Normal, template!(Word), ErrorFollowing, "the `#[rustc_intrinsic]` attribute is used to declare intrinsics with function bodies", ), + rustc_attr!( + rustc_no_mir_inline, Normal, template!(Word), WarnFollowing, + "#[rustc_no_mir_inline] prevents the MIR inliner from inlining a function while not affecting codegen" + ), // ========================================================================== // Internal attributes, Testing: diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 008c59e1be3db..05bb74807326f 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -156,6 +156,9 @@ declare_features! ( Some("removed in favor of `#![feature(marker_trait_attr)]`")), (removed, panic_implementation, "1.28.0", Some(44489), Some("subsumed by `#[panic_handler]`")), + /// Allows `extern "platform-intrinsic" { ... }`. + (removed, platform_intrinsics, "1.4.0", Some(27731), + Some("SIMD intrinsics use the regular intrinsics ABI now")), /// Allows using `#![plugin(myplugin)]`. (removed, plugin, "1.75.0", Some(29597), Some("plugins are no longer supported")), diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 9012b731a1323..db192ae9a3519 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -259,8 +259,6 @@ declare_features! ( (internal, needs_panic_runtime, "1.10.0", Some(32837)), /// Allows using the `#![panic_runtime]` attribute. (internal, panic_runtime, "1.10.0", Some(32837)), - /// Allows `extern "platform-intrinsic" { ... }`. - (internal, platform_intrinsics, "1.4.0", Some(27731)), /// Allows using `#[rustc_allow_const_fn_unstable]`. /// This is an attribute on `const fn` for the same /// purpose as `#[allow_internal_unstable]`. @@ -373,8 +371,6 @@ declare_features! ( (unstable, cfg_sanitize, "1.41.0", Some(39699)), /// Allows `cfg(sanitizer_cfi_generalize_pointers)` and `cfg(sanitizer_cfi_normalize_integers)`. (unstable, cfg_sanitizer_cfi, "1.77.0", Some(89653)), - /// Allows `cfg(target_abi = "...")`. - (unstable, cfg_target_abi, "1.55.0", Some(80970)), /// Allows `cfg(target(abi = "..."))`. (unstable, cfg_target_compact, "1.63.0", Some(96901)), /// Allows `cfg(target_has_atomic_load_store = "...")`. @@ -473,6 +469,8 @@ declare_features! ( (unstable, fn_align, "1.53.0", Some(82232)), /// Support delegating implementation of functions to other already implemented functions. (incomplete, fn_delegation, "1.76.0", Some(118212)), + /// Allows impls for the Freeze trait. + (internal, freeze_impls, "CURRENT_RUSTC_VERSION", Some(121675)), /// Allows defining gen blocks and `gen fn`. (unstable, gen_blocks, "1.75.0", Some(117078)), /// Infer generic args for both consts and types. @@ -518,7 +516,7 @@ declare_features! ( (unstable, marker_trait_attr, "1.30.0", Some(29864)), /// Allows exhaustive pattern matching on types that contain uninhabited types in cases that are /// unambiguously sound. - (incomplete, min_exhaustive_patterns, "1.77.0", Some(119612)), + (unstable, min_exhaustive_patterns, "1.77.0", Some(119612)), /// A minimal, sound subset of specialization intended to be used by the /// standard library until the soundness issues with specialization /// are fixed. diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index b81ad8b194623..f538d6bcb9816 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -420,7 +420,9 @@ impl DefPathData { pub fn name(&self) -> DefPathDataName { use self::DefPathData::*; match *self { - TypeNs(name) if name == kw::Empty => DefPathDataName::Anon { namespace: sym::opaque }, + TypeNs(name) if name == kw::Empty => { + DefPathDataName::Anon { namespace: sym::synthetic } + } TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => { DefPathDataName::Named(name) } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index fcb15925f6a7b..78e7c636a3e74 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3004,6 +3004,11 @@ impl<'hir> Item<'hir> { matches!(self.kind, ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..)) } + /// Check if this is an [`ItemKind::Struct`] or [`ItemKind::Union`]. + pub fn is_struct_or_union(&self) -> bool { + matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..)) + } + expect_methods_self_kind! { expect_extern_crate, Option, ItemKind::ExternCrate(s), *s; diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs index 214d960296880..6caba6ff23e52 100644 --- a/compiler/rustc_hir_analysis/src/astconv/errors.rs +++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs @@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::unord::UnordMap; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, + codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, }; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -371,7 +371,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // FIXME(fmease): Heavily adapted from `rustc_hir_typeck::method::suggest`. Deduplicate. fn note_ambiguous_inherent_assoc_type( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, candidates: Vec, span: Span, ) { @@ -429,7 +429,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let tcx = self.tcx(); let adt_did = self_ty.ty_adt_def().map(|def| def.did()); - let add_def_label = |err: &mut DiagnosticBuilder<'_>| { + let add_def_label = |err: &mut Diag<'_>| { if let Some(did) = adt_did { err.span_label( tcx.def_span(did), diff --git a/compiler/rustc_hir_analysis/src/astconv/generics.rs b/compiler/rustc_hir_analysis/src/astconv/generics.rs index b20326ae5e152..ce4c4609bc85a 100644 --- a/compiler/rustc_hir_analysis/src/astconv/generics.rs +++ b/compiler/rustc_hir_analysis/src/astconv/generics.rs @@ -6,7 +6,7 @@ use crate::astconv::{ use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs}; use rustc_ast::ast::ParamKindOrd; use rustc_errors::{ - codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, + codes::*, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, }; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -47,7 +47,7 @@ fn generic_arg_mismatch_err( } } - let add_braces_suggestion = |arg: &GenericArg<'_>, err: &mut DiagnosticBuilder<'_>| { + let add_braces_suggestion = |arg: &GenericArg<'_>, err: &mut Diag<'_>| { let suggestions = vec![ (arg.span().shrink_to_lo(), String::from("{ ")), (arg.span().shrink_to_hi(), String::from(" }")), diff --git a/compiler/rustc_hir_analysis/src/astconv/lint.rs b/compiler/rustc_hir_analysis/src/astconv/lint.rs index cee29b152e85a..fb5f3426cea6a 100644 --- a/compiler/rustc_hir_analysis/src/astconv/lint.rs +++ b/compiler/rustc_hir_analysis/src/astconv/lint.rs @@ -1,5 +1,5 @@ use rustc_ast::TraitObjectSyntax; -use rustc_errors::{codes::*, DiagnosticBuilder, EmissionGuarantee, StashKey}; +use rustc_errors::{codes::*, Diag, EmissionGuarantee, StashKey}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_lint_defs::{builtin::BARE_TRAIT_OBJECTS, Applicability}; @@ -13,7 +13,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { pub(super) fn maybe_lint_blanket_trait_impl( &self, self_ty: &hir::Ty<'_>, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, ) { let tcx = self.tcx(); let parent_id = tcx.hir().get_parent_item(self_ty.hir_id).def_id; @@ -75,11 +75,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } /// Make sure that we are in the condition to suggest `impl Trait`. - fn maybe_lint_impl_trait( - &self, - self_ty: &hir::Ty<'_>, - diag: &mut DiagnosticBuilder<'_>, - ) -> bool { + fn maybe_lint_impl_trait(&self, self_ty: &hir::Ty<'_>, diag: &mut Diag<'_>) -> bool { let tcx = self.tcx(); let parent_id = tcx.hir().get_parent_item(self_ty.hir_id).def_id; let (sig, generics, owner) = match tcx.hir_node_by_def_id(parent_id) { diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index f374b955d9eb0..218891a7c67c7 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -18,8 +18,7 @@ use crate::require_c_abi_if_c_variadic; use rustc_ast::TraitObjectSyntax; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::{ - codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, - MultiSpan, + codes::*, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, FatalError, MultiSpan, }; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; @@ -1723,7 +1722,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { pub fn prohibit_generics<'a>( &self, segments: impl Iterator> + Clone, - extend: impl Fn(&mut DiagnosticBuilder<'_>), + extend: impl Fn(&mut Diag<'_>), ) -> bool { let args = segments.clone().flat_map(|segment| segment.args().args); @@ -2739,7 +2738,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { &self, constrained_regions: FxHashSet, referenced_regions: FxHashSet, - generate_err: impl Fn(&str) -> DiagnosticBuilder<'tcx>, + generate_err: impl Fn(&str) -> Diag<'tcx>, ) { for br in referenced_regions.difference(&constrained_regions) { let br_name = match *br { diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index deabb9c373857..81e84860b8227 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -612,17 +612,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) { } } - Abi::PlatformIntrinsic => { - for item in items { - intrinsic::check_platform_intrinsic_type( - tcx, - item.id.owner_id.def_id, - item.span, - item.ident.name, - ); - } - } - _ => { for item in items { let def_id = item.id.owner_id.def_id; @@ -1247,7 +1236,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) { fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) { // Helper closure to reduce duplicate code. This gets called everytime we detect a duplicate. // Here `idx` refers to the order of which the discriminant appears, and its index in `vs` - let report = |dis: Discr<'tcx>, idx, err: &mut DiagnosticBuilder<'_>| { + let report = |dis: Discr<'tcx>, idx, err: &mut Diag<'_>| { let var = adt.variant(idx); // HIR for the duplicate discriminant let (span, display_discr) = match var.discr { ty::VariantDiscr::Explicit(discr_def_id) => { @@ -1307,7 +1296,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) let mut i = 0; while i < discrs.len() { let var_i_idx = discrs[i].0; - let mut error: Option> = None; + let mut error: Option> = None; let mut o = i + 1; while o < discrs.len() { diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index 7bdbab4325cbf..29dc434ab4532 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -136,11 +136,15 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>( // 1. Project the RPITIT projections from the trait to the opaques on the impl, // which means that they don't need to be mapped manually. // - // 2. Project any other projections that show up in the bound. That makes sure that - // we don't consider `tests/ui/async-await/in-trait/async-associated-types.rs` - // to be refining. - let (trait_bounds, impl_bounds) = - ocx.normalize(&ObligationCause::dummy(), param_env, (trait_bounds, impl_bounds)); + // 2. Deeply normalize any other projections that show up in the bound. That makes sure + // that we don't consider `tests/ui/async-await/in-trait/async-associated-types.rs` + // or `tests/ui/impl-trait/in-trait/refine-normalize.rs` to be refining. + let Ok((trait_bounds, impl_bounds)) = + ocx.deeply_normalize(&ObligationCause::dummy(), param_env, (trait_bounds, impl_bounds)) + else { + tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)"); + return; + }; // Since we've normalized things, we need to resolve regions, since we'll // possibly have introduced region vars during projection. We don't expect @@ -154,10 +158,8 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>( trait_m_sig.inputs_and_output, )); if !ocx.select_all_or_error().is_empty() { - // This code path is not reached in any tests, but may be reachable. If - // this is triggered, it should be converted to `delayed_bug` and the - // triggering case turned into a test. - tcx.dcx().bug("encountered errors when checking RPITIT refinement (selection)"); + tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)"); + return; } let outlives_env = OutlivesEnvironment::with_bounds( param_env, @@ -165,10 +167,8 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>( ); let errors = infcx.resolve_regions(&outlives_env); if !errors.is_empty() { - // This code path is not reached in any tests, but may be reachable. If - // this is triggered, it should be converted to `delayed_bug` and the - // triggering case turned into a test. - tcx.dcx().bug("encountered errors when checking RPITIT refinement (regions)"); + tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (regions)"); + return; } // Resolve any lifetime variables that may have been introduced during normalization. let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else { diff --git a/compiler/rustc_hir_analysis/src/check/errs.rs b/compiler/rustc_hir_analysis/src/check/errs.rs index 4a7ace274c5bb..c92320bc0fee8 100644 --- a/compiler/rustc_hir_analysis/src/check/errs.rs +++ b/compiler/rustc_hir_analysis/src/check/errs.rs @@ -1,9 +1,8 @@ use rustc_hir as hir; use rustc_hir_pretty::qpath_to_string; use rustc_lint_defs::builtin::STATIC_MUT_REFS; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::{Mutability, TyCtxt}; use rustc_span::Span; -use rustc_type_ir::Mutability; use crate::errors; diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index d7277b22c8410..3b7a7817279fc 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -12,7 +12,7 @@ use rustc_hir as hir; use rustc_middle::traits::{ObligationCause, ObligationCauseCode}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::LocalDefId; -use rustc_span::symbol::{kw, sym}; +use rustc_span::symbol::sym; use rustc_span::{Span, Symbol}; use rustc_target::spec::abi::Abi; @@ -445,7 +445,7 @@ pub fn check_intrinsic_type( ) } - kw::Try => { + sym::catch_unwind => { let mut_u8 = Ty::new_mut_ptr(tcx, tcx.types.u8); let try_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig( [mut_u8], @@ -510,6 +510,77 @@ pub fn check_intrinsic_type( sym::debug_assertions => (0, 1, Vec::new(), tcx.types.bool), + sym::simd_eq + | sym::simd_ne + | sym::simd_lt + | sym::simd_le + | sym::simd_gt + | sym::simd_ge => (2, 0, vec![param(0), param(0)], param(1)), + sym::simd_add + | sym::simd_sub + | sym::simd_mul + | sym::simd_rem + | sym::simd_div + | sym::simd_shl + | sym::simd_shr + | sym::simd_and + | sym::simd_or + | sym::simd_xor + | sym::simd_fmin + | sym::simd_fmax + | sym::simd_fpow + | sym::simd_saturating_add + | sym::simd_saturating_sub => (1, 0, vec![param(0), param(0)], param(0)), + sym::simd_arith_offset => (2, 0, vec![param(0), param(1)], param(0)), + sym::simd_neg + | sym::simd_bswap + | sym::simd_bitreverse + | sym::simd_ctlz + | sym::simd_cttz + | sym::simd_fsqrt + | sym::simd_fsin + | sym::simd_fcos + | sym::simd_fexp + | sym::simd_fexp2 + | sym::simd_flog2 + | sym::simd_flog10 + | sym::simd_flog + | sym::simd_fabs + | sym::simd_ceil + | sym::simd_floor + | sym::simd_round + | sym::simd_trunc => (1, 0, vec![param(0)], param(0)), + sym::simd_fpowi => (1, 0, vec![param(0), tcx.types.i32], param(0)), + sym::simd_fma => (1, 0, vec![param(0), param(0), param(0)], param(0)), + sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)), + sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)), + sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), + sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), + sym::simd_insert => (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0)), + sym::simd_extract => (2, 0, vec![param(0), tcx.types.u32], param(1)), + sym::simd_cast + | sym::simd_as + | sym::simd_cast_ptr + | sym::simd_expose_addr + | sym::simd_from_exposed_addr => (2, 0, vec![param(0)], param(1)), + sym::simd_bitmask => (2, 0, vec![param(0)], param(1)), + sym::simd_select | sym::simd_select_bitmask => { + (2, 0, vec![param(0), param(1), param(1)], param(1)) + } + sym::simd_reduce_all | sym::simd_reduce_any => (1, 0, vec![param(0)], tcx.types.bool), + sym::simd_reduce_add_ordered | sym::simd_reduce_mul_ordered => { + (2, 0, vec![param(0), param(1)], param(1)) + } + sym::simd_reduce_add_unordered + | sym::simd_reduce_mul_unordered + | sym::simd_reduce_and + | sym::simd_reduce_or + | sym::simd_reduce_xor + | sym::simd_reduce_min + | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)), + sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)), + sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)), + other => { tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other }); return; @@ -521,102 +592,3 @@ pub fn check_intrinsic_type( let sig = ty::Binder::bind_with_vars(sig, bound_vars); equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig) } - -/// Type-check `extern "platform-intrinsic" { ... }` functions. -pub fn check_platform_intrinsic_type( - tcx: TyCtxt<'_>, - intrinsic_id: LocalDefId, - span: Span, - name: Symbol, -) { - let generics = tcx.generics_of(intrinsic_id); - let param = |n| { - if let Some(&ty::GenericParamDef { - name, kind: ty::GenericParamDefKind::Type { .. }, .. - }) = generics.opt_param_at(n as usize, tcx) - { - Ty::new_param(tcx, n, name) - } else { - Ty::new_error_with_message(tcx, span, "expected param") - } - }; - - let (n_tps, n_cts, inputs, output) = match name { - sym::simd_eq | sym::simd_ne | sym::simd_lt | sym::simd_le | sym::simd_gt | sym::simd_ge => { - (2, 0, vec![param(0), param(0)], param(1)) - } - sym::simd_add - | sym::simd_sub - | sym::simd_mul - | sym::simd_rem - | sym::simd_div - | sym::simd_shl - | sym::simd_shr - | sym::simd_and - | sym::simd_or - | sym::simd_xor - | sym::simd_fmin - | sym::simd_fmax - | sym::simd_fpow - | sym::simd_saturating_add - | sym::simd_saturating_sub => (1, 0, vec![param(0), param(0)], param(0)), - sym::simd_arith_offset => (2, 0, vec![param(0), param(1)], param(0)), - sym::simd_neg - | sym::simd_bswap - | sym::simd_bitreverse - | sym::simd_ctlz - | sym::simd_cttz - | sym::simd_fsqrt - | sym::simd_fsin - | sym::simd_fcos - | sym::simd_fexp - | sym::simd_fexp2 - | sym::simd_flog2 - | sym::simd_flog10 - | sym::simd_flog - | sym::simd_fabs - | sym::simd_ceil - | sym::simd_floor - | sym::simd_round - | sym::simd_trunc => (1, 0, vec![param(0)], param(0)), - sym::simd_fpowi => (1, 0, vec![param(0), tcx.types.i32], param(0)), - sym::simd_fma => (1, 0, vec![param(0), param(0), param(0)], param(0)), - sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)), - sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)), - sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), - sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)), - sym::simd_insert => (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0)), - sym::simd_extract => (2, 0, vec![param(0), tcx.types.u32], param(1)), - sym::simd_cast - | sym::simd_as - | sym::simd_cast_ptr - | sym::simd_expose_addr - | sym::simd_from_exposed_addr => (2, 0, vec![param(0)], param(1)), - sym::simd_bitmask => (2, 0, vec![param(0)], param(1)), - sym::simd_select | sym::simd_select_bitmask => { - (2, 0, vec![param(0), param(1), param(1)], param(1)) - } - sym::simd_reduce_all | sym::simd_reduce_any => (1, 0, vec![param(0)], tcx.types.bool), - sym::simd_reduce_add_ordered | sym::simd_reduce_mul_ordered => { - (2, 0, vec![param(0), param(1)], param(1)) - } - sym::simd_reduce_add_unordered - | sym::simd_reduce_mul_unordered - | sym::simd_reduce_and - | sym::simd_reduce_or - | sym::simd_reduce_xor - | sym::simd_reduce_min - | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)), - sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)), - sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)), - _ => { - let msg = format!("unrecognized platform-specific intrinsic function: `{name}`"); - tcx.dcx().span_err(span, msg); - return; - } - }; - - let sig = tcx.mk_fn_sig(inputs, output, false, hir::Unsafety::Unsafe, Abi::PlatformIntrinsic); - let sig = ty::Binder::dummy(sig); - equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, 0, n_cts, sig) -} diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 36a92a4cf7cc0..f5bfc6b1b869d 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -78,7 +78,7 @@ use std::num::NonZero; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::ErrorGuaranteed; -use rustc_errors::{pluralize, struct_span_code_err, DiagnosticBuilder}; +use rustc_errors::{pluralize, struct_span_code_err, Diag}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit::Visitor; use rustc_index::bit_set::BitSet; @@ -142,7 +142,7 @@ fn get_owner_return_paths( /// as they must always be defined by the compiler. // FIXME: Move this to a more appropriate place. pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: Abi) { - if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = abi { + if let Abi::RustIntrinsic = abi { tcx.dcx().span_err(sp, "intrinsic must be in `extern \"rust-intrinsic\" { ... }` block"); } } diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs index 9e1e884d9769f..3aef29f4ae4dd 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs @@ -24,6 +24,11 @@ struct InherentOverlapChecker<'tcx> { tcx: TyCtxt<'tcx>, } +rustc_index::newtype_index! { + #[orderable] + pub struct RegionId {} +} + impl<'tcx> InherentOverlapChecker<'tcx> { /// Checks whether any associated items in impls 1 and 2 share the same identifier and /// namespace. @@ -205,11 +210,6 @@ impl<'tcx> InherentOverlapChecker<'tcx> { // This is advantageous to running the algorithm over the // entire graph when there are many connected regions. - rustc_index::newtype_index! { - #[orderable] - pub struct RegionId {} - } - struct ConnectedRegion { idents: SmallVec<[Symbol; 8]>, impl_blocks: FxHashSet, diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index d6281fa08f745..52acc10b9fe7f 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -10,6 +10,7 @@ use rustc_errors::{codes::*, struct_span_code_err}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::query::Providers; use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; +use rustc_session::parse::feature_err; use rustc_span::{sym, ErrorGuaranteed}; use rustc_trait_selection::traits; @@ -49,6 +50,19 @@ fn enforce_trait_manually_implementable( ) -> Result<(), ErrorGuaranteed> { let impl_header_span = tcx.def_span(impl_def_id); + if tcx.lang_items().freeze_trait() == Some(trait_def_id) { + if !tcx.features().freeze_impls { + feature_err( + &tcx.sess, + sym::freeze_impls, + impl_header_span, + "explicit impls for the `Freeze` trait are not permitted", + ) + .with_span_label(impl_header_span, format!("impl of `Freeze` not allowed")) + .emit(); + } + } + // Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]` if trait_def.deny_explicit_impl { let trait_name = tcx.item_name(trait_def_id); diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 07bbaa1926edf..b46a67d08eb03 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -1,14 +1,13 @@ //! Orphan checker: every impl either implements a trait defined in this //! crate or pertains to a type defined in this crate. +use crate::errors; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_middle::ty::{self, AliasKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::def_id::LocalDefId; use rustc_span::Span; -use rustc_trait_selection::traits; - -use crate::errors; +use rustc_trait_selection::traits::{self, IsFirstInputType}; #[instrument(skip(tcx), level = "debug")] pub(crate) fn orphan_check_impl( @@ -288,7 +287,7 @@ fn emit_orphan_check_error<'tcx>( (Vec::new(), Vec::new(), Vec::new(), Vec::new(), Vec::new()); let mut sugg = None; for &(mut ty, is_target_ty) in &tys { - let span = if is_target_ty { + let span = if matches!(is_target_ty, IsFirstInputType::Yes) { // Point at `D` in `impl for C in D` self_ty_span } else { @@ -321,7 +320,8 @@ fn emit_orphan_check_error<'tcx>( } } - let is_foreign = !trait_ref.def_id.is_local() && !is_target_ty; + let is_foreign = + !trait_ref.def_id.is_local() && matches!(is_target_ty, IsFirstInputType::No); match &ty.kind() { ty::Slice(_) => { diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 642009dfa48a8..b6e2695590c13 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -17,7 +17,7 @@ use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::unord::UnordMap; -use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, StashKey}; +use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId}; @@ -186,7 +186,7 @@ pub(crate) fn placeholder_type_error_diag<'tcx>( suggest: bool, hir_ty: Option<&hir::Ty<'_>>, kind: &'static str, -) -> DiagnosticBuilder<'tcx> { +) -> Diag<'tcx> { if placeholder_types.is_empty() { return bad_placeholder(tcx, additional_spans, kind); } @@ -335,7 +335,7 @@ fn bad_placeholder<'tcx>( tcx: TyCtxt<'tcx>, mut spans: Vec, kind: &'static str, -) -> DiagnosticBuilder<'tcx> { +) -> Diag<'tcx> { let kind = if kind.ends_with('s') { format!("{kind}es") } else { format!("{kind}s") }; spans.sort(); @@ -760,7 +760,7 @@ fn convert_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) { let wrapped_discr = prev_discr.map_or(initial, |d| d.wrap_incr(tcx)); prev_discr = Some( if let ty::VariantDiscr::Explicit(const_def_id) = variant.discr { - def.eval_explicit_discr(tcx, const_def_id) + def.eval_explicit_discr(tcx, const_def_id).ok() } else if let Some(discr) = repr_type.disr_incr(tcx, prev_discr) { Some(discr) } else { @@ -1025,7 +1025,15 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> { let is_anonymous = item.ident.name == kw::Empty; let repr = if is_anonymous { - tcx.adt_def(tcx.local_parent(def_id)).repr() + let parent = tcx.local_parent(def_id); + if let Node::Item(item) = tcx.hir_node_by_def_id(parent) + && item.is_struct_or_union() + { + tcx.adt_def(parent).repr() + } else { + tcx.dcx().span_delayed_bug(item.span, "anonymous field inside non struct/union"); + ty::ReprOptions::default() + } } else { tcx.repr_options_of_def(def_id) }; @@ -1669,10 +1677,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( // Feature gate SIMD types in FFI, since I am not sure that the // ABIs are handled at all correctly. -huonw - if abi != abi::Abi::RustIntrinsic - && abi != abi::Abi::PlatformIntrinsic - && !tcx.features().simd_ffi - { + if abi != abi::Abi::RustIntrinsic && !tcx.features().simd_ffi { let check = |ast_ty: &hir::Ty<'_>, ty: Ty<'_>| { if ty.is_simd() { let snip = tcx diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 410a069f9568f..9cc6c16c12639 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -315,7 +315,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { if is_host_effect { if let Some(idx) = host_effect_index { - tcx.dcx().span_bug( + tcx.dcx().span_delayed_bug( param.span, format!("parent also has host effect param? index: {idx}, def: {def_id:?}"), ); diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 351ac2eb7702e..f70bb8c4289f6 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -640,16 +640,30 @@ pub(super) fn implied_predicates_with_filter( // Now require that immediate supertraits are converted, which will, in // turn, reach indirect supertraits, so we detect cycles now instead of - // overflowing during elaboration. - if matches!(filter, PredicateFilter::SelfOnly) { - for &(pred, span) in implied_bounds { - debug!("superbound: {:?}", pred); - if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() - && bound.polarity == ty::ImplPolarity::Positive - { - tcx.at(span).super_predicates_of(bound.def_id()); + // overflowing during elaboration. Same for implied predicates, which + // make sure we walk into associated type bounds. + match filter { + PredicateFilter::SelfOnly => { + for &(pred, span) in implied_bounds { + debug!("superbound: {:?}", pred); + if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() + && bound.polarity == ty::ImplPolarity::Positive + { + tcx.at(span).super_predicates_of(bound.def_id()); + } + } + } + PredicateFilter::SelfAndAssociatedTypeBounds => { + for &(pred, span) in implied_bounds { + debug!("superbound: {:?}", pred); + if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() + && bound.polarity == ty::ImplPolarity::Positive + { + tcx.at(span).implied_predicates_of(bound.def_id()); + } } } + _ => {} } ty::GenericPredicates { parent: None, predicates: implied_bounds } 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 efde4e11c79dd..ae01bf845751a 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -1181,13 +1181,12 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { && !self.tcx.asyncness(lifetime_ref.hir_id.owner.def_id).is_async() && !self.tcx.features().anonymous_lifetime_in_impl_trait { - let mut diag: rustc_errors::DiagnosticBuilder<'_> = - rustc_session::parse::feature_err( - &self.tcx.sess, - sym::anonymous_lifetime_in_impl_trait, - lifetime_ref.ident.span, - "anonymous lifetimes in `impl Trait` are unstable", - ); + let mut diag: rustc_errors::Diag<'_> = rustc_session::parse::feature_err( + &self.tcx.sess, + sym::anonymous_lifetime_in_impl_trait, + lifetime_ref.ident.span, + "anonymous lifetimes in `impl Trait` are unstable", + ); if let Some(generics) = self.tcx.hir().get_generics(lifetime_ref.hir_id.owner.def_id) @@ -1331,7 +1330,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { } } - self.tcx.dcx().span_bug( + self.tcx.dcx().span_delayed_bug( lifetime_ref.ident.span, format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,), ); diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index d217d16ed8421..5330260fbf513 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -2,8 +2,7 @@ use crate::fluent_generated as fluent; use rustc_errors::{ - codes::*, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level, - MultiSpan, + codes::*, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level, MultiSpan, }; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::Ty; @@ -359,8 +358,8 @@ pub struct MissingTypeParams { // Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`. impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for MissingTypeParams { #[track_caller] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { - let mut err = DiagnosticBuilder::new(dcx, level, fluent::hir_analysis_missing_type_params); + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { + let mut err = Diag::new(dcx, level, fluent::hir_analysis_missing_type_params); err.span(self.span); err.code(E0393); err.arg("parameterCount", self.missing_type_params.len()); @@ -1005,13 +1004,6 @@ pub(crate) struct StaticSpecialize { pub span: Span, } -#[derive(Diagnostic)] -#[diag(hir_analysis_missing_tilde_const)] -pub(crate) struct MissingTildeConst { - #[primary_span] - pub span: Span, -} - #[derive(Diagnostic)] pub(crate) enum DropImplPolarity { #[diag(hir_analysis_drop_impl_negative)] diff --git a/compiler/rustc_hir_analysis/src/structured_errors.rs b/compiler/rustc_hir_analysis/src/structured_errors.rs index 6846e4defe5e5..9064ba8693ef5 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors.rs @@ -6,7 +6,7 @@ pub use self::{ missing_cast_for_variadic_arg::*, sized_unsized_cast::*, wrong_number_of_generic_args::*, }; -use rustc_errors::{DiagnosticBuilder, ErrCode}; +use rustc_errors::{Diag, ErrCode}; use rustc_session::Session; pub trait StructuredDiagnostic<'tcx> { @@ -14,7 +14,7 @@ pub trait StructuredDiagnostic<'tcx> { fn code(&self) -> ErrCode; - fn diagnostic(&self) -> DiagnosticBuilder<'tcx> { + fn diagnostic(&self) -> Diag<'tcx> { let err = self.diagnostic_common(); if self.session().teach(self.code()) { @@ -24,13 +24,13 @@ pub trait StructuredDiagnostic<'tcx> { } } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx>; + fn diagnostic_common(&self) -> Diag<'tcx>; - fn diagnostic_regular(&self, err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> { + fn diagnostic_regular(&self, err: Diag<'tcx>) -> Diag<'tcx> { err } - fn diagnostic_extended(&self, err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> { + fn diagnostic_extended(&self, err: Diag<'tcx>) -> Diag<'tcx> { err } } diff --git a/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs b/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs index 363b9ba6996fa..921cf37155a2e 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs @@ -1,5 +1,5 @@ use crate::{errors, structured_errors::StructuredDiagnostic}; -use rustc_errors::{codes::*, DiagnosticBuilder}; +use rustc_errors::{codes::*, Diag}; use rustc_middle::ty::{Ty, TypeVisitableExt}; use rustc_session::Session; use rustc_span::Span; @@ -20,7 +20,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx, '_> { E0617 } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx> { + fn diagnostic_common(&self) -> Diag<'tcx> { let (sugg_span, replace, help) = if let Ok(snippet) = self.sess.source_map().span_to_snippet(self.span) { (Some(self.span), format!("{} as {}", snippet, self.cast_ty), None) @@ -44,7 +44,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx, '_> { err } - fn diagnostic_extended(&self, mut err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> { + fn diagnostic_extended(&self, mut err: Diag<'tcx>) -> Diag<'tcx> { err.note(format!( "certain types, like `{}`, must be casted before passing them to a \ variadic function, because of arcane ABI rules dictated by the C \ diff --git a/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs b/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs index 052c2807a2e6a..1af5e6a9dfc4b 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs @@ -1,5 +1,5 @@ use crate::{errors, structured_errors::StructuredDiagnostic}; -use rustc_errors::{codes::*, DiagnosticBuilder}; +use rustc_errors::{codes::*, Diag}; use rustc_middle::ty::{Ty, TypeVisitableExt}; use rustc_session::Session; use rustc_span::Span; @@ -20,7 +20,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for SizedUnsizedCast<'tcx> { E0607 } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx> { + fn diagnostic_common(&self) -> Diag<'tcx> { let mut err = self.sess.dcx().create_err(errors::CastThinPointerToFatPointer { span: self.span, expr_ty: self.expr_ty, @@ -34,7 +34,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for SizedUnsizedCast<'tcx> { err } - fn diagnostic_extended(&self, mut err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> { + fn diagnostic_extended(&self, mut err: Diag<'tcx>) -> Diag<'tcx> { err.help( "Thin pointers are \"simple\" pointers: they are purely a reference to a memory address. diff --git a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs index 8e0c2ea5ca715..6f4695ec92005 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs @@ -1,5 +1,5 @@ use crate::structured_errors::StructuredDiagnostic; -use rustc_errors::{codes::*, pluralize, Applicability, DiagnosticBuilder, MultiSpan}; +use rustc_errors::{codes::*, pluralize, Applicability, Diag, MultiSpan}; use rustc_hir as hir; use rustc_middle::ty::{self as ty, AssocItems, AssocKind, TyCtxt}; use rustc_session::Session; @@ -518,14 +518,14 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> { + fn start_diagnostics(&self) -> Diag<'tcx> { let span = self.path_segment.ident.span; let msg = self.create_error_message(); self.tcx.dcx().struct_span_err(span, msg).with_code(self.code()) } /// Builds the `expected 1 type argument / supplied 2 type arguments` message. - fn notify(&self, err: &mut DiagnosticBuilder<'_>) { + fn notify(&self, err: &mut Diag<'_>) { let (quantifier, bound) = self.get_quantifier_and_bound(); let provided_args = self.num_provided_args(); @@ -577,7 +577,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest(&self, err: &mut Diag<'_>) { debug!( "suggest(self.provided {:?}, self.gen_args.span(): {:?})", self.num_provided_args(), @@ -605,7 +605,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { /// ```text /// type Map = HashMap; /// ``` - fn suggest_adding_args(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_adding_args(&self, err: &mut Diag<'_>) { if self.gen_args.parenthesized != hir::GenericArgsParentheses::No { return; } @@ -624,7 +624,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest_adding_lifetime_args(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_adding_lifetime_args(&self, err: &mut Diag<'_>) { debug!("suggest_adding_lifetime_args(path_segment: {:?})", self.path_segment); let num_missing_args = self.num_missing_lifetime_args(); let num_params_to_take = num_missing_args; @@ -678,7 +678,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest_adding_type_and_const_args(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_adding_type_and_const_args(&self, err: &mut Diag<'_>) { let num_missing_args = self.num_missing_type_or_const_args(); let msg = format!("add missing {} argument{}", self.kind(), pluralize!(num_missing_args)); @@ -738,7 +738,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { /// ```compile_fail /// Into::into::>(42) // suggests considering `Into::>::into(42)` /// ``` - fn suggest_moving_args_from_assoc_fn_to_trait(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_moving_args_from_assoc_fn_to_trait(&self, err: &mut Diag<'_>) { let trait_ = match self.tcx.trait_of_item(self.def_id) { Some(def_id) => def_id, None => return, @@ -794,7 +794,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { fn suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, qpath: &'tcx hir::QPath<'tcx>, msg: String, num_assoc_fn_excess_args: usize, @@ -827,7 +827,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { fn suggest_moving_args_from_assoc_fn_to_trait_for_method_call( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_def_id: DefId, expr: &'tcx hir::Expr<'tcx>, msg: String, @@ -881,7 +881,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { /// ```text /// type Map = HashMap; /// ``` - fn suggest_removing_args_or_generics(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_removing_args_or_generics(&self, err: &mut Diag<'_>) { let num_provided_lt_args = self.num_provided_lifetime_args(); let num_provided_type_const_args = self.num_provided_type_or_const_args(); let unbound_types = self.get_unbound_associated_types(); @@ -899,7 +899,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let provided_args_matches_unbound_traits = unbound_types.len() == num_redundant_type_or_const_args; - let remove_lifetime_args = |err: &mut DiagnosticBuilder<'_>| { + let remove_lifetime_args = |err: &mut Diag<'_>| { let mut lt_arg_spans = Vec::new(); let mut found_redundant = false; for arg in self.gen_args.args { @@ -940,7 +940,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { ); }; - let remove_type_or_const_args = |err: &mut DiagnosticBuilder<'_>| { + let remove_type_or_const_args = |err: &mut Diag<'_>| { let mut gen_arg_spans = Vec::new(); let mut found_redundant = false; for arg in self.gen_args.args { @@ -1037,7 +1037,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } /// Builds the `type defined here` message. - fn show_definition(&self, err: &mut DiagnosticBuilder<'_>) { + fn show_definition(&self, err: &mut Diag<'_>) { let mut spans: MultiSpan = if let Some(def_span) = self.tcx.def_ident_span(self.def_id) { if self.tcx.sess.source_map().is_span_accessible(def_span) { def_span.into() @@ -1088,7 +1088,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } /// Add note if `impl Trait` is explicitly specified. - fn note_synth_provided(&self, err: &mut DiagnosticBuilder<'_>) { + fn note_synth_provided(&self, err: &mut Diag<'_>) { if !self.is_synth_provided() { return; } @@ -1106,7 +1106,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for WrongNumberOfGenericArgs<'_, 'tcx> { E0107 } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx> { + fn diagnostic_common(&self) -> Diag<'tcx> { let mut err = self.start_diagnostics(); self.notify(&mut err); diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index cb131f1d1669e..c7343387dafc4 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -1,6 +1,6 @@ use crate::coercion::{AsCoercionSite, CoerceMany}; use crate::{Diverges, Expectation, FnCtxt, Needs}; -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_hir::{ self as hir, def::{CtorOf, DefKind, Res}, @@ -177,7 +177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn explain_never_type_coerced_to_unit( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, arm: &hir::Arm<'tcx>, arm_ty: Ty<'tcx>, prior_arm: Option<(Option, Ty<'tcx>, Span)>, @@ -209,7 +209,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_removing_semicolon_for_coerce( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, expr: &hir::Expr<'tcx>, arm_ty: Ty<'tcx>, prior_arm: Option<(Option, Ty<'tcx>, Span)>, @@ -303,7 +303,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// `if let PAT = EXPR {}` expressions that could be turned into `let PAT = EXPR;`. fn explain_if_expr( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ret_reason: Option<(Span, String)>, if_span: Span, cond_expr: &'tcx hir::Expr<'tcx>, @@ -401,12 +401,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // check that the `if` expr without `else` is the fn body's expr if expr.span == sp { - return self.get_fn_decl(hir_id).and_then(|(_, fn_decl, _)| { + return self.get_fn_decl(hir_id).map(|(_, fn_decl, _)| { let (ty, span) = match fn_decl.output { hir::FnRetTy::DefaultReturn(span) => ("()".to_string(), span), hir::FnRetTy::Return(ty) => (ty_to_string(ty), ty.span), }; - Some((span, format!("expected `{ty}` because of this return type"))) + (span, format!("expected `{ty}` because of this return type")) }); } } diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 69bcb6b8c1579..bb6d1ecae02ab 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -4,7 +4,7 @@ use super::{Expectation, FnCtxt, TupleArgumentsFlag}; use crate::errors; use rustc_ast::util::parser::PREC_POSTFIX; -use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, StashKey}; +use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey}; use rustc_hir as hir; use rustc_hir::def::{self, CtorKind, Namespace, Res}; use rustc_hir::def_id::DefId; @@ -347,7 +347,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// likely intention is to call the closure, suggest `(||{})()`. (#55851) fn identify_bad_closure_def_and_call( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, hir_id: hir::HirId, callee_node: &hir::ExprKind<'_>, callee_span: Span, @@ -410,7 +410,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// likely intention is to create an array containing tuples. fn maybe_suggest_bad_array_definition( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, call_expr: &'tcx hir::Expr<'tcx>, callee_expr: &'tcx hir::Expr<'tcx>, ) -> bool { @@ -601,7 +601,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// and suggesting the fix if the method probe is successful. fn suggest_call_as_method( &self, - diag: &mut DiagnosticBuilder<'_, ()>, + diag: &mut Diag<'_, ()>, segment: &'tcx hir::PathSegment<'tcx>, arg_exprs: &'tcx [hir::Expr<'tcx>], call_expr: &'tcx hir::Expr<'tcx>, diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index b662d23c27150..84d042da138f8 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -33,7 +33,7 @@ use super::FnCtxt; use crate::errors; use crate::type_error_struct; use hir::ExprKind; -use rustc_errors::{codes::*, Applicability, DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::{codes::*, Applicability, Diag, ErrorGuaranteed}; use rustc_hir as hir; use rustc_macros::{TypeFoldable, TypeVisitable}; use rustc_middle::mir::Mutability; @@ -182,7 +182,7 @@ fn make_invalid_casting_error<'a, 'tcx>( expr_ty: Ty<'tcx>, cast_ty: Ty<'tcx>, fcx: &FnCtxt<'a, 'tcx>, -) -> DiagnosticBuilder<'a> { +) -> Diag<'a> { type_error_struct!( fcx.dcx(), span, @@ -980,11 +980,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { /// Attempt to suggest using `.is_empty` when trying to cast from a /// collection type to a boolean. - fn try_suggest_collection_to_bool( - &self, - fcx: &FnCtxt<'a, 'tcx>, - err: &mut DiagnosticBuilder<'_>, - ) { + fn try_suggest_collection_to_bool(&self, fcx: &FnCtxt<'a, 'tcx>, err: &mut Diag<'_>) { if self.cast_ty.is_bool() { let derefed = fcx .autoderef(self.expr_span, self.expr_ty) diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 9f6175eac1350..179255993b478 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -36,7 +36,7 @@ //! ``` use crate::FnCtxt; -use rustc_errors::{codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan}; +use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{self, Visitor}; @@ -44,6 +44,8 @@ use rustc_hir::Expr; use rustc_hir_analysis::astconv::AstConv; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::{Coercion, DefineOpaqueTypes, InferOk, InferResult}; +use rustc_infer::traits::TraitEngine; +use rustc_infer::traits::TraitEngineExt as _; use rustc_infer::traits::{Obligation, PredicateObligation}; use rustc_middle::lint::in_external_macro; use rustc_middle::traits::BuiltinImplSource; @@ -61,6 +63,7 @@ use rustc_target::spec::abi::Abi; use rustc_trait_selection::infer::InferCtxtExt as _; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; +use rustc_trait_selection::traits::TraitEngineExt as _; use rustc_trait_selection::traits::{ self, NormalizeExt, ObligationCause, ObligationCauseCode, ObligationCtxt, }; @@ -157,17 +160,19 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // In the new solver, lazy norm may allow us to shallowly equate // more types, but we emit possibly impossible-to-satisfy obligations. // Filter these cases out to make sure our coercion is more accurate. - if self.next_trait_solver() { - if let Ok(res) = &res { - for obligation in &res.obligations { - if !self.predicate_may_hold(obligation) { - return Err(TypeError::Mismatch); - } + match res { + Ok(InferOk { value, obligations }) if self.next_trait_solver() => { + let mut fulfill_cx = >::new(self); + fulfill_cx.register_predicate_obligations(self, obligations); + let errs = fulfill_cx.select_where_possible(self); + if errs.is_empty() { + Ok(InferOk { value, obligations: fulfill_cx.pending_obligations() }) + } else { + Err(TypeError::Mismatch) } } + res => res, } - - res }) } @@ -625,19 +630,32 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let traits = [coerce_unsized_did, unsize_did]; while !queue.is_empty() { let obligation = queue.remove(0); - debug!("coerce_unsized resolve step: {:?}", obligation); let trait_pred = match obligation.predicate.kind().no_bound_vars() { Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred))) if traits.contains(&trait_pred.def_id()) => { - trait_pred + self.resolve_vars_if_possible(trait_pred) + } + // Eagerly process alias-relate obligations in new trait solver, + // since these can be emitted in the process of solving trait goals, + // but we need to constrain vars before processing goals mentioning + // them. + Some(ty::PredicateKind::AliasRelate(..)) => { + let mut fulfill_cx = >::new(self); + fulfill_cx.register_predicate_obligation(self, obligation); + let errs = fulfill_cx.select_where_possible(self); + if !errs.is_empty() { + return Err(TypeError::Mismatch); + } + coercion.obligations.extend(fulfill_cx.pending_obligations()); + continue; } _ => { coercion.obligations.push(obligation); continue; } }; - let trait_pred = self.resolve_vars_if_possible(trait_pred); + debug!("coerce_unsized resolve step: {:?}", trait_pred); match selcx.select(&obligation.with(selcx.tcx(), trait_pred)) { // Uncertain or unimplemented. Ok(None) => { @@ -1173,11 +1191,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if let (Some(a_sig), Some(b_sig)) = (a_sig, b_sig) { // Intrinsics are not coercible to function pointers. - if a_sig.abi() == Abi::RustIntrinsic - || a_sig.abi() == Abi::PlatformIntrinsic - || b_sig.abi() == Abi::RustIntrinsic - || b_sig.abi() == Abi::PlatformIntrinsic - { + if a_sig.abi() == Abi::RustIntrinsic || b_sig.abi() == Abi::RustIntrinsic { return Err(TypeError::IntrinsicCast); } // The signature must match. @@ -1437,7 +1451,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { &mut self, fcx: &FnCtxt<'a, 'tcx>, cause: &ObligationCause<'tcx>, - augment_error: impl FnOnce(&mut DiagnosticBuilder<'_>), + augment_error: impl FnOnce(&mut Diag<'_>), label_unit_as_expected: bool, ) { self.coerce_inner( @@ -1460,7 +1474,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { cause: &ObligationCause<'tcx>, expression: Option<&'tcx hir::Expr<'tcx>>, mut expression_ty: Ty<'tcx>, - augment_error: impl FnOnce(&mut DiagnosticBuilder<'_>), + augment_error: impl FnOnce(&mut Diag<'_>), label_expression_as_expected: bool, ) { // Incorporate whatever type inference information we have @@ -1671,7 +1685,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { fn note_unreachable_loop_return( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, tcx: TyCtxt<'tcx>, expr: &hir::Expr<'tcx>, ret_exprs: &Vec<&'tcx hir::Expr<'tcx>>, @@ -1783,7 +1797,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { id: hir::HirId, expression: Option<&'tcx hir::Expr<'tcx>>, blk_id: Option, - ) -> DiagnosticBuilder<'a> { + ) -> Diag<'a> { let mut err = fcx.err_ctxt().report_mismatched_types(cause, expected, found, ty_err); let parent_id = fcx.tcx.parent_hir_id(id); diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 98e3fbb8b11ab..0c5c80ea89078 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -1,6 +1,6 @@ use crate::FnCtxt; use rustc_errors::MultiSpan; -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::intravisit::Visitor; @@ -19,7 +19,7 @@ use super::method::probe; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn emit_type_mismatch_suggestions( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expr_ty: Ty<'tcx>, expected: Ty<'tcx>, @@ -70,7 +70,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn emit_coerce_suggestions( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expr_ty: Ty<'tcx>, expected: Ty<'tcx>, @@ -174,7 +174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>, - ) -> Option> { + ) -> Option> { self.demand_suptype_with_origin(&self.misc(sp), expected, actual) } @@ -184,7 +184,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { cause: &ObligationCause<'tcx>, expected: Ty<'tcx>, actual: Ty<'tcx>, - ) -> Option> { + ) -> Option> { match self.at(cause, self.param_env).sup(DefineOpaqueTypes::Yes, expected, actual) { Ok(InferOk { obligations, value: () }) => { self.register_predicates(obligations); @@ -205,7 +205,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>, - ) -> Option> { + ) -> Option> { self.demand_eqtype_with_origin(&self.misc(sp), expected, actual) } @@ -214,7 +214,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { cause: &ObligationCause<'tcx>, expected: Ty<'tcx>, actual: Ty<'tcx>, - ) -> Option> { + ) -> Option> { match self.at(cause, self.param_env).eq(DefineOpaqueTypes::Yes, expected, actual) { Ok(InferOk { obligations, value: () }) => { self.register_predicates(obligations); @@ -252,7 +252,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, mut expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, allow_two_phase: AllowTwoPhase, - ) -> (Ty<'tcx>, Option>) { + ) -> (Ty<'tcx>, Option>) { let expected = self.resolve_vars_with_obligations(expected); let e = match self.coerce(expr, checked_ty, expected, allow_two_phase, None) { @@ -280,7 +280,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// with some expectation given by `source`. pub fn note_source_of_type_mismatch_constraint( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, source: TypeMismatchSource<'tcx>, ) -> bool { @@ -550,7 +550,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // expected type. pub fn annotate_loop_expected_due_to_inference( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, error: Option>, ) { @@ -673,7 +673,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn annotate_expected_due_to_let_ty( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, error: Option>, ) { @@ -782,7 +782,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn annotate_alternative_method_deref( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, error: Option>, ) { @@ -1029,7 +1029,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn explain_self_literal( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -1082,7 +1082,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn note_wrong_return_ty_due_to_generic_arg( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, ) { diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index f609d0f7e8f5d..1d324f128f230 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -3,8 +3,8 @@ use std::borrow::Cow; use crate::fluent_generated as fluent; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DiagnosticArgValue, DiagnosticBuilder, - EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Applicability, Diag, DiagArgValue, EmissionGuarantee, + IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp, }; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::Ty; @@ -43,14 +43,14 @@ pub enum ReturnLikeStatementKind { } impl IntoDiagnosticArg for ReturnLikeStatementKind { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { let kind = match self { Self::Return => "return", Self::Become => "become", } .into(); - DiagnosticArgValue::Str(kind) + DiagArgValue::Str(kind) } } @@ -197,7 +197,7 @@ pub struct TypeMismatchFruTypo { impl AddToDiagnostic for TypeMismatchFruTypo { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { diag.arg("expr", self.expr.as_deref().unwrap_or("NONE")); @@ -376,7 +376,7 @@ pub struct RemoveSemiForCoerce { impl AddToDiagnostic for RemoveSemiForCoerce { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { let mut multispan: MultiSpan = self.semi.into(); @@ -552,7 +552,7 @@ pub enum CastUnknownPointerSub { impl rustc_errors::AddToDiagnostic for CastUnknownPointerSub { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ) { match self { diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 89cc46dc5ab80..2b7bce3f48575 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -26,7 +26,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::unord::UnordMap; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, AddToDiagnostic, Applicability, DiagnosticBuilder, + codes::*, pluralize, struct_span_code_err, AddToDiagnostic, Applicability, Diag, ErrorGuaranteed, StashKey, }; use rustc_hir as hir; @@ -69,7 +69,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr: &'tcx hir::Expr<'tcx>, expected_ty: Ty<'tcx>, - extend_err: impl FnOnce(&mut DiagnosticBuilder<'_>), + extend_err: impl FnOnce(&mut Diag<'_>), ) -> Ty<'tcx> { let mut ty = self.check_expr_with_expectation(expr, ExpectHasType(expected_ty)); @@ -77,8 +77,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // coercions from ! to `expected`. if ty.is_never() { if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { - self.dcx() - .span_bug(expr.span, "expression with never type wound up being adjusted"); + let reported = self.dcx().span_delayed_bug( + expr.span, + "expression with never type wound up being adjusted", + ); + return Ty::new_error(self.tcx(), reported); } let adj_ty = self.next_ty_var(TypeVariableOrigin { @@ -951,7 +954,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { lhs: &'tcx hir::Expr<'tcx>, code: ErrCode, op_span: Span, - adjust_err: impl FnOnce(&mut DiagnosticBuilder<'_>), + adjust_err: impl FnOnce(&mut Diag<'_>), ) { if lhs.is_syntactic_place_expr() { return; @@ -977,11 +980,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// Check if the expression that could not be assigned to was a typoed expression that - pub fn check_for_missing_semi( - &self, - expr: &'tcx hir::Expr<'tcx>, - err: &mut DiagnosticBuilder<'_>, - ) -> bool { + pub fn check_for_missing_semi(&self, expr: &'tcx hir::Expr<'tcx>, err: &mut Diag<'_>) -> bool { if let hir::ExprKind::Binary(binop, lhs, rhs) = expr.kind && let hir::BinOpKind::Mul = binop.node && self.tcx.sess.source_map().is_multiline(lhs.span.between(rhs.span)) @@ -1216,7 +1215,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let lhs_ty = self.check_expr_with_needs(lhs, Needs::MutPlace); - let suggest_deref_binop = |err: &mut DiagnosticBuilder<'_>, rhs_ty: Ty<'tcx>| { + let suggest_deref_binop = |err: &mut Diag<'_>, rhs_ty: Ty<'tcx>| { if let Some(lhs_deref_ty) = self.deref_once_mutably_for_diagnostic(lhs_ty) { // Can only assign if the type is sized, so if `DerefMut` yields a type that is // unsized, do not suggest dereferencing it. @@ -2000,7 +1999,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { last_expr_field: &hir::ExprField<'tcx>, variant: &ty::VariantDef, args: GenericArgsRef<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) { // I don't use 'is_range_literal' because only double-sided, half-open ranges count. if let ExprKind::Struct(QPath::LangItem(LangItem::Range, ..), [range_start, range_end], _) = @@ -2516,7 +2515,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_await_on_field_access( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, field_ident: Ident, base: &'tcx hir::Expr<'tcx>, ty: Ty<'tcx>, @@ -2715,7 +2714,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit() } - fn point_at_param_definition(&self, err: &mut DiagnosticBuilder<'_>, param: ty::ParamTy) { + fn point_at_param_definition(&self, err: &mut Diag<'_>, param: ty::ParamTy) { let generics = self.tcx.generics_of(self.body_id); let generic_param = generics.type_param(¶m, self.tcx); if let ty::GenericParamDefKind::Type { synthetic: true, .. } = generic_param.kind { @@ -2734,7 +2733,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn maybe_suggest_array_indexing( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, base: &hir::Expr<'_>, field: Ident, @@ -2758,7 +2757,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_first_deref_field( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, base: &hir::Expr<'_>, field: Ident, @@ -2771,12 +2770,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn no_such_field_err( - &self, - field: Ident, - expr_t: Ty<'tcx>, - id: HirId, - ) -> DiagnosticBuilder<'_> { + fn no_such_field_err(&self, field: Ident, expr_t: Ty<'tcx>, id: HirId) -> Diag<'_> { let span = field.span; debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t); @@ -2859,7 +2853,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err } - fn private_field_err(&self, field: Ident, base_did: DefId) -> DiagnosticBuilder<'_> { + fn private_field_err(&self, field: Ident, base_did: DefId) -> Diag<'_> { let struct_path = self.tcx().def_path_str(base_did); let kind_name = self.tcx().def_descr(base_did); struct_span_code_err!( diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 9303e437a968e..a5892dea1a51b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -5,7 +5,7 @@ use crate::rvalue_scopes; use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, StashKey}; +use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::DefId; @@ -846,7 +846,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let item_name = item_segment.ident; let result = self .resolve_fully_qualified_call(span, item_name, ty.normalized, qself.span, hir_id) - .and_then(|r| { + .map(|r| { // lint bare trait if the method is found in the trait if span.edition().at_least_rust_2021() && let Some(diag) = @@ -854,7 +854,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { diag.emit(); } - Ok(r) + r }) .or_else(|error| { let guar = self @@ -1020,7 +1020,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn note_internal_mutation_in_method( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, expected: Option>, found: Ty<'tcx>, @@ -1516,6 +1516,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// In case there is still ambiguity, the returned type may be an inference /// variable. This is different from `structurally_resolve_type` which errors /// in this case. + #[instrument(level = "debug", skip(self, sp), ret)] pub fn try_structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> { let ty = self.resolve_vars_with_obligations(ty); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 4bc86435482fb..61c52422d195d 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -17,7 +17,7 @@ use itertools::Itertools; use rustc_ast as ast; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{ - codes::*, pluralize, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, StashKey, + codes::*, pluralize, Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey, }; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; @@ -555,14 +555,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { let args = self.infcx.fresh_args_for_item(call_name.span, assoc.def_id); let fn_sig = tcx.fn_sig(assoc.def_id).instantiate(tcx, args); - let fn_sig = - self.instantiate_binder_with_fresh_vars(call_name.span, FnCall, fn_sig); - Some((assoc, fn_sig)); + + self.instantiate_binder_with_fresh_vars(call_name.span, FnCall, fn_sig); } None }; - let suggest_confusable = |err: &mut DiagnosticBuilder<'_>| { + let suggest_confusable = |err: &mut Diag<'_>| { let Some(call_name) = call_ident else { return; }; @@ -1370,7 +1369,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected_ty: Ty<'tcx>, provided_ty: Ty<'tcx>, arg: &hir::Expr<'tcx>, - err: &mut rustc_errors::DiagnosticBuilder<'tcx>, + err: &mut Diag<'tcx>, ) { if let ty::RawPtr(ty::TypeAndMut { mutbl: hir::Mutability::Mut, .. }) = expected_ty.kind() && let ty::RawPtr(ty::TypeAndMut { mutbl: hir::Mutability::Not, .. }) = @@ -2048,7 +2047,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn label_fn_like( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, callable_def_id: Option, callee_ty: Option>, call_expr: &'tcx hir::Expr<'tcx>, diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index e57717c25d93d..ccd9b38bf62ab 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -12,7 +12,7 @@ use core::cmp::min; use core::iter; use rustc_ast::util::parser::{ExprPrecedence, PREC_POSTFIX}; use rustc_data_structures::packed::Pu128; -use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan}; +use rustc_errors::{Applicability, Diag, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def::{CtorKind, CtorOf, DefKind}; @@ -48,11 +48,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .copied() } - pub(in super::super) fn suggest_semicolon_at_end( - &self, - span: Span, - err: &mut DiagnosticBuilder<'_>, - ) { + pub(in super::super) fn suggest_semicolon_at_end(&self, span: Span, err: &mut Diag<'_>) { // This suggestion is incorrect for // fn foo() -> bool { match () { () => true } || match () { () => true } } err.span_suggestion_short( @@ -70,7 +66,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// - Possible missing return type if the return type is the default, and not `fn main()`. pub fn suggest_mismatched_types_on_tail( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -101,7 +97,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// ``` pub(crate) fn suggest_fn_call( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, found: Ty<'tcx>, can_satisfy: impl FnOnce(Ty<'tcx>) -> bool, @@ -183,7 +179,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn suggest_two_fn_call( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, lhs_expr: &'tcx hir::Expr<'tcx>, lhs_ty: Ty<'tcx>, rhs_expr: &'tcx hir::Expr<'tcx>, @@ -257,7 +253,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn suggest_remove_last_method_call( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expected: Ty<'tcx>, ) -> bool { @@ -286,7 +282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn suggest_deref_ref_or_into( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -544,7 +540,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// in the heap by calling `Box::new()`. pub(in super::super) fn suggest_boxing_when_appropriate( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, hir_id: HirId, expected: Ty<'tcx>, @@ -587,7 +583,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// suggest a non-capturing closure pub(in super::super) fn suggest_no_capture_closure( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, ) -> bool { @@ -624,7 +620,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[instrument(skip(self, err))] pub(in super::super) fn suggest_calling_boxed_future_when_appropriate( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -736,7 +732,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// block is needed to be added too (`|| { expr; }`). This is denoted by `needs_block`. pub fn suggest_missing_semicolon( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expression: &'tcx hir::Expr<'tcx>, expected: Ty<'tcx>, needs_block: bool, @@ -795,7 +791,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[instrument(level = "trace", skip(self, err))] pub(in super::super) fn suggest_missing_return_type( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, fn_decl: &hir::FnDecl<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -913,7 +909,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// ``` fn try_suggest_return_impl_trait( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expected: Ty<'tcx>, found: Ty<'tcx>, fn_id: hir::HirId, @@ -1018,7 +1014,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn suggest_missing_break_or_return_expr( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &'tcx hir::Expr<'tcx>, fn_decl: &hir::FnDecl<'tcx>, expected: Ty<'tcx>, @@ -1061,20 +1057,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; } - let scope = self - .tcx - .hir() - .parent_iter(id) - .filter(|(_, node)| { - matches!( - node, - Node::Expr(Expr { kind: ExprKind::Closure(..), .. }) - | Node::Item(_) - | Node::TraitItem(_) - | Node::ImplItem(_) - ) - }) - .next(); + let scope = self.tcx.hir().parent_iter(id).find(|(_, node)| { + matches!( + node, + Node::Expr(Expr { kind: ExprKind::Closure(..), .. }) + | Node::Item(_) + | Node::TraitItem(_) + | Node::ImplItem(_) + ) + }); let in_closure = matches!(scope, Some((_, Node::Expr(Expr { kind: ExprKind::Closure(..), .. })))); @@ -1122,7 +1113,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn suggest_missing_parentheses( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, ) -> bool { let sp = self.tcx.sess.source_map().start_point(expr.span).with_parent(None); @@ -1140,7 +1131,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// if it was possibly mistaken array syntax. pub(crate) fn suggest_block_to_brackets_peeling_refs( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, mut expr: &hir::Expr<'_>, mut expr_ty: Ty<'tcx>, mut expected_ty: Ty<'tcx>, @@ -1167,7 +1158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_clone_for_ref( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, expr: &hir::Expr<'_>, expr_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, @@ -1202,7 +1193,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_copied_cloned_or_as_ref( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, expr: &hir::Expr<'_>, expr_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, @@ -1252,7 +1243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_into( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, expr: &hir::Expr<'_>, expr_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, @@ -1315,7 +1306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// When expecting a `bool` and finding an `Option`, suggests using `let Some(..)` or `.is_some()` pub(crate) fn suggest_option_to_bool( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, expr: &hir::Expr<'_>, expr_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, @@ -1372,7 +1363,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// in case the block was mistaken array syntax, e.g. `{ 1 }` -> `[ 1 ]`. pub(crate) fn suggest_block_to_brackets( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, blk: &hir::Block<'_>, blk_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, @@ -1412,7 +1403,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[instrument(skip(self, err))] pub(crate) fn suggest_floating_point_literal( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, expected_ty: Ty<'tcx>, ) -> bool { @@ -1483,7 +1474,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[instrument(skip(self, err))] pub(crate) fn suggest_null_ptr_for_literal_zero_given_to_ptr_arg( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, expected_ty: Ty<'tcx>, ) -> bool { @@ -1521,7 +1512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_associated_const( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expected_ty: Ty<'tcx>, ) -> bool { @@ -1615,7 +1606,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// which is a side-effect of autoref. pub(crate) fn note_type_is_not_clone( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, expected_ty: Ty<'tcx>, found_ty: Ty<'tcx>, expr: &hir::Expr<'_>, @@ -1815,7 +1806,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, blk: &'tcx hir::Block<'tcx>, expected_ty: Ty<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) -> bool { if let Some((span_semi, boxed)) = self.err_ctxt().could_remove_semicolon(blk, expected_ty) { if let StatementAsExpression::NeedsBoxing = boxed { @@ -1860,7 +1851,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_missing_unwrap_expect( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -1943,7 +1934,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_coercing_result_via_try_operator( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -1990,7 +1981,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// sole field is of the found type, suggest such variants. (Issue #42764) pub(crate) fn suggest_compatible_variants( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, expected: Ty<'tcx>, expr_ty: Ty<'tcx>, @@ -2179,7 +2170,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_non_zero_new_unwrap( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, expected: Ty<'tcx>, expr_ty: Ty<'tcx>, @@ -2723,7 +2714,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_cast( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, @@ -2851,7 +2842,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id); let suggest_fallible_into_or_lhs_from = - |err: &mut DiagnosticBuilder<'_>, exp_to_found_is_fallible: bool| { + |err: &mut Diag<'_>, exp_to_found_is_fallible: bool| { // If we know the expression the expected type is derived from, we might be able // to suggest a widening conversion rather than a narrowing one (which may // panic). For example, given x: u8 and y: u32, if we know the span of "x", @@ -2891,9 +2882,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let suggest_to_change_suffix_or_into = - |err: &mut DiagnosticBuilder<'_>, - found_to_exp_is_fallible: bool, - exp_to_found_is_fallible: bool| { + |err: &mut Diag<'_>, found_to_exp_is_fallible: bool, exp_to_found_is_fallible: bool| { let exp_is_lhs = expected_ty_expr.is_some_and(|e| self.tcx.hir().is_lhs(e.hir_id)); if exp_is_lhs { @@ -3089,7 +3078,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Identify when the user has written `foo..bar()` instead of `foo.bar()`. pub(crate) fn suggest_method_call_on_range_literal( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'tcx>, checked_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, @@ -3167,7 +3156,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// block without a tail expression. pub(crate) fn suggest_return_binding_for_missing_tail_expr( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, checked_ty: Ty<'tcx>, expected_ty: Ty<'tcx>, diff --git a/compiler/rustc_hir_typeck/src/mem_categorization.rs b/compiler/rustc_hir_typeck/src/mem_categorization.rs index c300ec7444b2e..1a860aa406791 100644 --- a/compiler/rustc_hir_typeck/src/mem_categorization.rs +++ b/compiler/rustc_hir_typeck/src/mem_categorization.rs @@ -582,7 +582,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { match ty.kind() { ty::Tuple(args) => Ok(args.len()), _ => { - self.tcx().dcx().span_bug(span, "tuple pattern not applied to a tuple"); + self.tcx().dcx().span_delayed_bug(span, "tuple pattern not applied to a tuple"); + Err(()) } } } diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index f8d0911a2eb69..441558da60ac3 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -11,7 +11,7 @@ pub use self::suggest::SelfSource; pub use self::MethodError::*; use crate::FnCtxt; -use rustc_errors::{Applicability, DiagnosticBuilder, SubdiagnosticMessage}; +use rustc_errors::{Applicability, Diag, SubdiagnosticMessage}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Namespace}; use rustc_hir::def_id::DefId; @@ -126,7 +126,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[instrument(level = "debug", skip(self, err, call_expr))] pub(crate) fn suggest_method_call( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, msg: impl Into + std::fmt::Debug, method_name: Ident, self_ty: Ty<'tcx>, diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 7117a59c40987..bdc796aca3a46 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -804,10 +804,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let trait_ref = principal.with_self_ty(self.tcx, self_ty); self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| { if new_trait_ref.has_non_region_bound_vars() { - this.dcx().span_bug( + this.dcx().span_delayed_bug( this.span, "tried to select method from HRTB with non-lifetime bound vars", ); + return; } let new_trait_ref = this.instantiate_bound_regions_with_erased(new_trait_ref); diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index babdbce000515..28771ae40f538 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -12,8 +12,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::unord::UnordSet; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan, - StashKey, + codes::*, pluralize, struct_span_code_err, Applicability, Diag, MultiSpan, StashKey, }; use rustc_hir as hir; use rustc_hir::def::DefKind; @@ -208,7 +207,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { args: Option<&'tcx [hir::Expr<'tcx>]>, expected: Expectation<'tcx>, trait_missing_method: bool, - ) -> Option> { + ) -> Option> { // Avoid suggestions when we don't know what's going on. if rcvr_ty.references_error() { return None; @@ -344,11 +343,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None } - fn suggest_missing_writer( - &self, - rcvr_ty: Ty<'tcx>, - rcvr_expr: &hir::Expr<'tcx>, - ) -> DiagnosticBuilder<'_> { + fn suggest_missing_writer(&self, rcvr_ty: Ty<'tcx>, rcvr_expr: &hir::Expr<'tcx>) -> Diag<'_> { let mut file = None; let ty_str = self.tcx.short_ty_string(rcvr_ty, &mut file); let mut err = struct_span_code_err!( @@ -370,9 +365,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; if let Some(file) = file { err.note(format!("the full type name has been written to '{}'", file.display())); - err.note(format!( - "consider using `--verbose` to print the full type name to the console" - )); + err.note("consider using `--verbose` to print the full type name to the console"); } err @@ -389,7 +382,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { no_match_data: &mut NoMatchData<'tcx>, expected: Expectation<'tcx>, trait_missing_method: bool, - ) -> Option> { + ) -> Option> { let mode = no_match_data.mode; let tcx = self.tcx; let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty); @@ -497,9 +490,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(file) = ty_file { err.note(format!("the full type name has been written to '{}'", file.display(),)); - err.note(format!( - "consider using `--verbose` to print the full type name to the console" - )); + err.note("consider using `--verbose` to print the full type name to the console"); } if rcvr_ty.references_error() { err.downgrade_to_delayed_bug(); @@ -1134,7 +1125,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - let label_span_not_found = |err: &mut DiagnosticBuilder<'_>| { + let label_span_not_found = |err: &mut Diag<'_>| { if unsatisfied_predicates.is_empty() { err.span_label(span, format!("{item_kind} not found in `{ty_str}`")); let is_string_or_ref_str = match rcvr_ty.kind() { @@ -1418,7 +1409,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn find_likely_intended_associated_item( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, similar_candidate: ty::AssocItem, span: Span, args: Option<&'tcx [hir::Expr<'tcx>]>, @@ -1496,7 +1487,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn confusable_method_name( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, rcvr_ty: Ty<'tcx>, item_name: Ident, call_args: Option>>, @@ -1563,7 +1554,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self_source: SelfSource<'tcx>, args: Option<&'tcx [hir::Expr<'tcx>]>, span: Span, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, sources: &mut Vec, sugg_span: Option, ) { @@ -1709,7 +1700,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Look at all the associated functions without receivers in the type's inherent impls /// to look for builders that return `Self`, `Option` or `Result`. - fn find_builder_fn(&self, err: &mut DiagnosticBuilder<'_>, rcvr_ty: Ty<'tcx>) { + fn find_builder_fn(&self, err: &mut Diag<'_>, rcvr_ty: Ty<'tcx>) { let ty::Adt(adt_def, _) = rcvr_ty.kind() else { return; }; @@ -1794,7 +1785,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// doesn't take a `self` receiver. fn suggest_associated_call_syntax( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, static_candidates: &Vec, rcvr_ty: Ty<'tcx>, source: SelfSource<'tcx>, @@ -1938,7 +1929,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { rcvr_ty: Ty<'tcx>, expr: &hir::Expr<'_>, item_name: Ident, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) -> bool { let tcx = self.tcx; let field_receiver = self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind() { @@ -2261,7 +2252,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Suggest calling a method on a field i.e. `a.field.bar()` instead of `a.bar()` fn suggest_calling_method_on_field( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: SelfSource<'tcx>, span: Span, actual: Ty<'tcx>, @@ -2341,7 +2332,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_unwrapping_inner_self( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: SelfSource<'tcx>, actual: Ty<'tcx>, item_name: Ident, @@ -2530,7 +2521,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn note_unmet_impls_on_type( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, errors: Vec>, suggest_derive: bool, ) { @@ -2613,7 +2604,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn note_predicate_source_and_get_derives( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, unsatisfied_predicates: &[( ty::Predicate<'tcx>, Option>, @@ -2695,7 +2686,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn suggest_derive( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, unsatisfied_predicates: &[( ty::Predicate<'tcx>, Option>, @@ -2731,7 +2722,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn note_derefed_ty_has_method( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, self_source: SelfSource<'tcx>, rcvr_ty: Ty<'tcx>, item_name: Ident, @@ -2811,7 +2802,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_await_before_method( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, item_name: Ident, ty: Ty<'tcx>, call: &hir::Expr<'_>, @@ -2834,12 +2825,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn suggest_use_candidates( - &self, - err: &mut DiagnosticBuilder<'_>, - msg: String, - candidates: Vec, - ) { + fn suggest_use_candidates(&self, err: &mut Diag<'_>, msg: String, candidates: Vec) { let parent_map = self.tcx.visible_parent_map(()); // Separate out candidates that must be imported with a glob, because they are named `_` @@ -2886,7 +2872,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_valid_traits( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, item_name: Ident, valid_out_of_scope_traits: Vec, explain: bool, @@ -2935,7 +2921,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_traits_to_import( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, rcvr_ty: Ty<'tcx>, item_name: Ident, @@ -3479,7 +3465,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// FIXME: currently not working for suggesting `map_or_else`, see #102408 pub(crate) fn suggest_else_fn_with_closure( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, found: Ty<'tcx>, expected: Ty<'tcx>, @@ -3605,7 +3591,7 @@ pub fn all_traits(tcx: TyCtxt<'_>) -> Vec { fn print_disambiguation_help<'tcx>( tcx: TyCtxt<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: SelfSource<'tcx>, args: Option<&'tcx [hir::Expr<'tcx>]>, trait_ref: ty::TraitRef<'tcx>, diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index fba240bf75263..9c9507d58522f 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -5,7 +5,7 @@ use super::FnCtxt; use crate::Expectation; use rustc_ast as ast; use rustc_data_structures::packed::Pu128; -use rustc_errors::{codes::*, struct_span_code_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag}; use rustc_hir as hir; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::traits::ObligationCauseCode; @@ -390,37 +390,36 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.downgrade_to_delayed_bug(); } - let suggest_deref_binop = - |err: &mut DiagnosticBuilder<'_, _>, lhs_deref_ty: Ty<'tcx>| { - if self - .lookup_op_method( - (lhs_expr, lhs_deref_ty), - Some((rhs_expr, rhs_ty)), - Op::Binary(op, is_assign), - expected, - ) - .is_ok() - { - let msg = format!( - "`{}{}` can be used on `{}` if you dereference the left-hand side", - op.node.as_str(), - match is_assign { - IsAssign::Yes => "=", - IsAssign::No => "", - }, - lhs_deref_ty, - ); - err.span_suggestion_verbose( - lhs_expr.span.shrink_to_lo(), - msg, - "*", - rustc_errors::Applicability::MachineApplicable, - ); - } - }; + let suggest_deref_binop = |err: &mut Diag<'_, _>, lhs_deref_ty: Ty<'tcx>| { + if self + .lookup_op_method( + (lhs_expr, lhs_deref_ty), + Some((rhs_expr, rhs_ty)), + Op::Binary(op, is_assign), + expected, + ) + .is_ok() + { + let msg = format!( + "`{}{}` can be used on `{}` if you dereference the left-hand side", + op.node.as_str(), + match is_assign { + IsAssign::Yes => "=", + IsAssign::No => "", + }, + lhs_deref_ty, + ); + err.span_suggestion_verbose( + lhs_expr.span.shrink_to_lo(), + msg, + "*", + rustc_errors::Applicability::MachineApplicable, + ); + } + }; let suggest_different_borrow = - |err: &mut DiagnosticBuilder<'_, _>, + |err: &mut Diag<'_, _>, lhs_adjusted_ty, lhs_new_mutbl: Option, rhs_adjusted_ty, @@ -695,7 +694,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { rhs_expr: &'tcx hir::Expr<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, is_assign: IsAssign, op: hir::BinOp, ) -> bool { diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index b15c9ef901877..bb963ad7a3972 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -3,8 +3,7 @@ use crate::{errors, FnCtxt, LoweredTy}; use rustc_ast as ast; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, - MultiSpan, + codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, }; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; @@ -99,7 +98,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { expected: Ty<'tcx>, actual: Ty<'tcx>, ti: TopInfo<'tcx>, - ) -> Option> { + ) -> Option> { let mut diag = self.demand_eqtype_with_origin(&self.pattern_cause(ti, cause_span), expected, actual)?; if let Some(expr) = ti.origin_expr { @@ -529,7 +528,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty } - fn endpoint_has_type(&self, err: &mut DiagnosticBuilder<'_>, span: Span, ty: Ty<'_>) { + fn endpoint_has_type(&self, err: &mut Diag<'_>, span: Span, ty: Ty<'_>) { if !ty.references_error() { err.span_label(span, format!("this is of type `{ty}`")); } @@ -683,7 +682,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_adding_missing_ref_or_removing_ref( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, expected: Ty<'tcx>, actual: Ty<'tcx>, @@ -715,7 +714,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // Precondition: pat is a Ref(_) pattern - fn borrow_pat_suggestion(&self, err: &mut DiagnosticBuilder<'_>, pat: &Pat<'_>) { + fn borrow_pat_suggestion(&self, err: &mut Diag<'_>, pat: &Pat<'_>) { let tcx = self.tcx; if let PatKind::Ref(inner, mutbl) = pat.kind && let PatKind::Binding(_, _, binding, ..) = inner.kind @@ -933,7 +932,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn maybe_suggest_range_literal( &self, - e: &mut DiagnosticBuilder<'_>, + e: &mut Diag<'_>, opt_def_id: Option, ident: Ident, ) -> bool { @@ -968,7 +967,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn emit_bad_pat_path( &self, - mut e: DiagnosticBuilder<'_>, + mut e: Diag<'_>, pat: &hir::Pat<'tcx>, res: Res, pat_res: Res, @@ -1505,7 +1504,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { variant: &VariantDef, pat: &'_ Pat<'_>, fields: &[hir::PatField<'_>], - ) -> Option> { + ) -> Option> { // if this is a tuple struct, then all field names will be numbers // so if any fields in a struct pattern use shorthand syntax, they will // be invalid identifiers (for example, Foo { 0, 1 }). @@ -1581,7 +1580,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pat: &'tcx Pat<'tcx>, variant: &ty::VariantDef, args: &'tcx ty::List>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let tcx = self.tcx; let (field_names, t, plural) = if let [field] = inexistent_fields { (format!("a field named `{}`", field.ident), "this", "") @@ -1686,7 +1685,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pat: &Pat<'_>, fields: &'tcx [hir::PatField<'tcx>], variant: &ty::VariantDef, - ) -> Option> { + ) -> Option> { if let (Some(CtorKind::Fn), PatKind::Struct(qpath, pattern_fields, ..)) = (variant.ctor_kind(), &pat.kind) { @@ -1772,7 +1771,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, pat: &Pat<'_>, fields: &'tcx [hir::PatField<'tcx>], - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let mut err = self .dcx() .struct_span_err(pat.span, "pattern requires `..` due to inaccessible fields"); @@ -1863,7 +1862,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { unmentioned_fields: &[(&ty::FieldDef, Ident)], have_inaccessible_fields: bool, fields: &'tcx [hir::PatField<'tcx>], - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" }; let field_names = if let [(_, field)] = unmentioned_fields { format!("field `{field}`{inaccessible}") @@ -2035,7 +2034,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { slice: Option<&'tcx Pat<'tcx>>, span: Span, ) -> Option> { - if !slice.is_none() { + if slice.is_some() { return None; } diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index f29ba70be9838..cecc52c8326ef 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -1,8 +1,7 @@ use hir::GenericParamKind; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DiagnosticBuilder, DiagnosticMessage, - DiagnosticStyledString, EmissionGuarantee, IntoDiagnosticArg, MultiSpan, - SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Applicability, Diag, DiagStyledString, DiagnosticMessage, + EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp, }; use rustc_hir as hir; use rustc_hir::FnRetTy; @@ -221,14 +220,14 @@ pub enum RegionOriginNote<'a> { WithRequirement { span: Span, requirement: ObligationCauseAsDiagArg<'a>, - expected_found: Option<(DiagnosticStyledString, DiagnosticStyledString)>, + expected_found: Option<(DiagStyledString, DiagStyledString)>, }, } impl AddToDiagnostic for RegionOriginNote<'_> { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { let mut label_or_note = |span, msg: DiagnosticMessage| { @@ -293,7 +292,7 @@ pub enum LifetimeMismatchLabels { impl AddToDiagnostic for LifetimeMismatchLabels { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { match self { @@ -341,7 +340,7 @@ pub struct AddLifetimeParamsSuggestion<'a> { impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { let mut mk_suggestion = || { @@ -443,7 +442,7 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq { impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq { fn add_to_diagnostic_with>( mut self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { self.unmet_requirements @@ -539,7 +538,7 @@ pub enum TyOrSig<'tcx> { } impl IntoDiagnosticArg for TyOrSig<'_> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { match self { TyOrSig::Ty(ty) => ty.into_diagnostic_arg(), TyOrSig::ClosureSig(sig) => sig.into_diagnostic_arg(), @@ -762,7 +761,7 @@ pub struct ConsiderBorrowingParamHelp { impl AddToDiagnostic for ConsiderBorrowingParamHelp { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ) { let mut type_param_span: MultiSpan = self.spans.clone().into(); @@ -807,7 +806,7 @@ pub struct DynTraitConstraintSuggestion { impl AddToDiagnostic for DynTraitConstraintSuggestion { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ) { let mut multi_span: MultiSpan = vec![self.span].into(); @@ -854,7 +853,7 @@ pub struct ReqIntroducedLocations { impl AddToDiagnostic for ReqIntroducedLocations { fn add_to_diagnostic_with>( mut self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ) { for sp in self.spans { @@ -877,7 +876,7 @@ pub struct MoreTargeted { impl AddToDiagnostic for MoreTargeted { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { diag.code(E0772); @@ -1300,7 +1299,7 @@ pub struct SuggestTuplePatternMany { impl AddToDiagnostic for SuggestTuplePatternMany { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ) { diag.arg("path", self.path); diff --git a/compiler/rustc_infer/src/errors/note_and_explain.rs b/compiler/rustc_infer/src/errors/note_and_explain.rs index c272aa63b08ea..bbcb613b3e4ae 100644 --- a/compiler/rustc_infer/src/errors/note_and_explain.rs +++ b/compiler/rustc_infer/src/errors/note_and_explain.rs @@ -1,8 +1,7 @@ use crate::fluent_generated as fluent; use crate::infer::error_reporting::nice_region_error::find_anon_type; use rustc_errors::{ - AddToDiagnostic, DiagnosticBuilder, EmissionGuarantee, IntoDiagnosticArg, - SubdiagnosticMessageOp, + AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagnosticArg, SubdiagnosticMessageOp, }; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::{symbol::kw, Span}; @@ -111,7 +110,7 @@ pub enum SuffixKind { } impl IntoDiagnosticArg for PrefixKind { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { let kind = match self { Self::Empty => "empty", Self::RefValidFor => "ref_valid_for", @@ -128,19 +127,19 @@ impl IntoDiagnosticArg for PrefixKind { Self::DataValidFor => "data_valid_for", } .into(); - rustc_errors::DiagnosticArgValue::Str(kind) + rustc_errors::DiagArgValue::Str(kind) } } impl IntoDiagnosticArg for SuffixKind { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { let kind = match self { Self::Empty => "empty", Self::Continues => "continues", Self::ReqByBinding => "req_by_binding", } .into(); - rustc_errors::DiagnosticArgValue::Str(kind) + rustc_errors::DiagArgValue::Str(kind) } } @@ -165,7 +164,7 @@ impl RegionExplanation<'_> { impl AddToDiagnostic for RegionExplanation<'_> { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, f: F, ) { diag.arg("pref_kind", self.prefix); diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index 05b9479c7b062..cc09a09468869 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -302,7 +302,23 @@ impl<'a, 'tcx> Trace<'a, 'tcx> { let Trace { at, trace, a_is_expected } = self; let mut fields = at.infcx.combine_fields(trace, at.param_env, define_opaque_types); fields - .equate(a_is_expected) + .equate(StructurallyRelateAliases::No, a_is_expected) + .relate(a, b) + .map(move |_| InferOk { value: (), obligations: fields.obligations }) + } + + /// Equates `a` and `b` while structurally relating aliases. This should only + /// be used inside of the next generation trait solver when relating rigid aliases. + #[instrument(skip(self), level = "debug")] + pub fn eq_structurally_relating_aliases(self, a: T, b: T) -> InferResult<'tcx, ()> + where + T: Relate<'tcx>, + { + let Trace { at, trace, a_is_expected } = self; + debug_assert!(at.infcx.next_trait_solver()); + let mut fields = at.infcx.combine_fields(trace, at.param_env, DefineOpaqueTypes::No); + fields + .equate(StructurallyRelateAliases::Yes, a_is_expected) .relate(a, b) .map(move |_| InferOk { value: (), obligations: fields.obligations }) } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index d40f3f501f58a..911b2f16c8b05 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -60,8 +60,8 @@ use crate::traits::{ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, DiagCtxt, DiagnosticBuilder, - DiagnosticStyledString, ErrorGuaranteed, IntoDiagnosticArg, + codes::*, pluralize, struct_span_code_err, Applicability, Diag, DiagCtxt, DiagStyledString, + ErrorGuaranteed, IntoDiagnosticArg, }; use rustc_hir as hir; use rustc_hir::def::DefKind; @@ -158,7 +158,7 @@ impl<'tcx> Deref for TypeErrCtxt<'_, 'tcx> { pub(super) fn note_and_explain_region<'tcx>( tcx: TyCtxt<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, prefix: &str, region: ty::Region<'tcx>, suffix: &str, @@ -183,7 +183,7 @@ pub(super) fn note_and_explain_region<'tcx>( fn explain_free_region<'tcx>( tcx: TyCtxt<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, prefix: &str, region: ty::Region<'tcx>, suffix: &str, @@ -265,7 +265,7 @@ fn msg_span_from_named_region<'tcx>( } fn emit_msg_span( - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, prefix: &str, description: String, span: Option, @@ -281,7 +281,7 @@ fn emit_msg_span( } fn label_msg_span( - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, prefix: &str, description: String, span: Option, @@ -303,7 +303,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>( hidden_ty: Ty<'tcx>, hidden_region: ty::Region<'tcx>, opaque_ty_key: ty::OpaqueTypeKey<'tcx>, -) -> DiagnosticBuilder<'tcx> { +) -> Diag<'tcx> { let mut err = tcx.dcx().create_err(errors::OpaqueCapturesLifetime { span, opaque_ty: Ty::new_opaque(tcx, opaque_ty_key.def_id.to_def_id(), opaque_ty_key.args), @@ -428,6 +428,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { generic_param_scope: LocalDefId, errors: &[RegionResolutionError<'tcx>], ) -> ErrorGuaranteed { + assert!(!errors.is_empty()); + if let Some(guaranteed) = self.infcx.tainted_by_errors() { return guaranteed; } @@ -440,10 +442,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { debug!("report_region_errors: {} errors after preprocessing", errors.len()); + let mut guar = None; for error in errors { debug!("report_region_errors: error = {:?}", error); - if !self.try_report_nice_region_error(&error) { + guar = Some(if let Some(guar) = self.try_report_nice_region_error(&error) { + guar + } else { match error.clone() { // These errors could indicate all manner of different // problems with many different solutions. Rather @@ -454,21 +459,20 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // general bit of code that displays the error information RegionResolutionError::ConcreteFailure(origin, sub, sup) => { if sub.is_placeholder() || sup.is_placeholder() { - self.report_placeholder_failure(origin, sub, sup).emit(); + self.report_placeholder_failure(origin, sub, sup).emit() } else { - self.report_concrete_failure(origin, sub, sup).emit(); + self.report_concrete_failure(origin, sub, sup).emit() } } - RegionResolutionError::GenericBoundFailure(origin, param_ty, sub) => { - self.report_generic_bound_failure( + RegionResolutionError::GenericBoundFailure(origin, param_ty, sub) => self + .report_generic_bound_failure( generic_param_scope, origin.span(), Some(origin), param_ty, sub, - ); - } + ), RegionResolutionError::SubSupConflict( _, @@ -480,13 +484,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { _, ) => { if sub_r.is_placeholder() { - self.report_placeholder_failure(sub_origin, sub_r, sup_r).emit(); + self.report_placeholder_failure(sub_origin, sub_r, sup_r).emit() } else if sup_r.is_placeholder() { - self.report_placeholder_failure(sup_origin, sub_r, sup_r).emit(); + self.report_placeholder_failure(sup_origin, sub_r, sup_r).emit() } else { self.report_sub_sup_conflict( var_origin, sub_origin, sub_r, sup_origin, sup_r, - ); + ) } } @@ -506,7 +510,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // value. let sub_r = self.tcx.lifetimes.re_erased; - self.report_placeholder_failure(sup_origin, sub_r, sup_r).emit(); + self.report_placeholder_failure(sup_origin, sub_r, sup_r).emit() } RegionResolutionError::CannotNormalize(clause, origin) => { @@ -515,15 +519,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { self.tcx .dcx() .struct_span_err(origin.span(), format!("cannot normalize `{clause}`")) - .emit(); + .emit() } } - } + }) } - self.tcx - .dcx() - .span_delayed_bug(self.tcx.def_span(generic_param_scope), "expected region errors") + guar.unwrap() } // This method goes through all the errors and try to group certain types @@ -580,11 +582,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } /// Adds a note if the types come from similarly named crates - fn check_and_note_conflicting_crates( - &self, - err: &mut DiagnosticBuilder<'_>, - terr: TypeError<'tcx>, - ) { + fn check_and_note_conflicting_crates(&self, err: &mut Diag<'_>, terr: TypeError<'tcx>) { use hir::def_id::CrateNum; use rustc_hir::definitions::DisambiguatedDefPathData; use ty::print::Printer; @@ -658,7 +656,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } - let report_path_match = |err: &mut DiagnosticBuilder<'_>, did1: DefId, did2: DefId| { + let report_path_match = |err: &mut Diag<'_>, did1: DefId, did2: DefId| { // Only report definitions from different crates. If both definitions // are from a local module we could have false positives, e.g. // let _ = [{struct Foo; Foo}, {struct Foo; Foo}]; @@ -708,7 +706,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn note_error_origin( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, cause: &ObligationCause<'tcx>, exp_found: Option>>, terr: TypeError<'tcx>, @@ -947,8 +945,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// ``` fn highlight_outer( &self, - value: &mut DiagnosticStyledString, - other_value: &mut DiagnosticStyledString, + value: &mut DiagStyledString, + other_value: &mut DiagStyledString, name: String, sub: ty::GenericArgsRef<'tcx>, pos: usize, @@ -1021,8 +1019,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// ``` fn cmp_type_arg( &self, - t1_out: &mut DiagnosticStyledString, - t2_out: &mut DiagnosticStyledString, + t1_out: &mut DiagStyledString, + t2_out: &mut DiagStyledString, path: String, sub: &'tcx [ty::GenericArg<'tcx>], other_path: String, @@ -1050,8 +1048,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// Adds a `,` to the type representation only if it is appropriate. fn push_comma( &self, - value: &mut DiagnosticStyledString, - other_value: &mut DiagnosticStyledString, + value: &mut DiagStyledString, + other_value: &mut DiagStyledString, len: usize, pos: usize, ) { @@ -1066,7 +1064,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, sig1: &ty::PolyFnSig<'tcx>, sig2: &ty::PolyFnSig<'tcx>, - ) -> (DiagnosticStyledString, DiagnosticStyledString) { + ) -> (DiagStyledString, DiagStyledString) { let sig1 = &(self.normalize_fn_sig)(*sig1); let sig2 = &(self.normalize_fn_sig)(*sig2); @@ -1083,10 +1081,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let (lt2, sig2) = get_lifetimes(sig2); // unsafe extern "C" for<'a> fn(&'a T) -> &'a T - let mut values = ( - DiagnosticStyledString::normal("".to_string()), - DiagnosticStyledString::normal("".to_string()), - ); + let mut values = + (DiagStyledString::normal("".to_string()), DiagStyledString::normal("".to_string())); // unsafe extern "C" for<'a> fn(&'a T) -> &'a T // ^^^^^^ @@ -1175,15 +1171,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// Compares two given types, eliding parts that are the same between them and highlighting /// relevant differences, and return two representation of those types for highlighted printing. - pub fn cmp( - &self, - t1: Ty<'tcx>, - t2: Ty<'tcx>, - ) -> (DiagnosticStyledString, DiagnosticStyledString) { + pub fn cmp(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> (DiagStyledString, DiagStyledString) { debug!("cmp(t1={}, t1.kind={:?}, t2={}, t2.kind={:?})", t1, t1.kind(), t2, t2.kind()); // helper functions - let recurse = |t1, t2, values: &mut (DiagnosticStyledString, DiagnosticStyledString)| { + let recurse = |t1, t2, values: &mut (DiagStyledString, DiagStyledString)| { let (x1, x2) = self.cmp(t1, t2); (values.0).0.extend(x1.0); (values.1).0.extend(x2.0); @@ -1202,7 +1194,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn push_ref<'tcx>( region: ty::Region<'tcx>, mutbl: hir::Mutability, - s: &mut DiagnosticStyledString, + s: &mut DiagStyledString, ) { s.push_highlighted(fmt_region(region)); s.push_highlighted(mutbl.prefix_str()); @@ -1211,7 +1203,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn maybe_highlight( t1: T, t2: T, - (buf1, buf2): &mut (DiagnosticStyledString, DiagnosticStyledString), + (buf1, buf2): &mut (DiagStyledString, DiagStyledString), tcx: TyCtxt<'_>, ) { let highlight = t1 != t2; @@ -1230,7 +1222,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { mut1: hir::Mutability, r2: ty::Region<'tcx>, mut2: hir::Mutability, - ss: &mut (DiagnosticStyledString, DiagnosticStyledString), + ss: &mut (DiagStyledString, DiagStyledString), ) { let (r1, r2) = (fmt_region(r1), fmt_region(r2)); if r1 != r2 { @@ -1259,7 +1251,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { self.tcx.generics_of(did1).own_args_no_defaults(self.tcx, sub1); let sub_no_defaults_2 = self.tcx.generics_of(did2).own_args_no_defaults(self.tcx, sub2); - let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); + let mut values = (DiagStyledString::new(), DiagStyledString::new()); let path1 = self.tcx.def_path_str(did1); let path2 = self.tcx.def_path_str(did2); if did1 == did2 { @@ -1428,8 +1420,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if split_idx >= min_len { // paths are identical, highlight everything ( - DiagnosticStyledString::highlighted(t1_str), - DiagnosticStyledString::highlighted(t2_str), + DiagStyledString::highlighted(t1_str), + DiagStyledString::highlighted(t2_str), ) } else { let (common, uniq1) = t1_str.split_at(split_idx); @@ -1448,20 +1440,20 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // When finding `&T != &T`, compare the references, then recurse into pointee type (&ty::Ref(r1, ref_ty1, mutbl1), &ty::Ref(r2, ref_ty2, mutbl2)) => { - let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); + let mut values = (DiagStyledString::new(), DiagStyledString::new()); cmp_ty_refs(r1, mutbl1, r2, mutbl2, &mut values); recurse(ref_ty1, ref_ty2, &mut values); values } // When finding T != &T, highlight the borrow (&ty::Ref(r1, ref_ty1, mutbl1), _) => { - let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); + let mut values = (DiagStyledString::new(), DiagStyledString::new()); push_ref(r1, mutbl1, &mut values.0); recurse(ref_ty1, t2, &mut values); values } (_, &ty::Ref(r2, ref_ty2, mutbl2)) => { - let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); + let mut values = (DiagStyledString::new(), DiagStyledString::new()); push_ref(r2, mutbl2, &mut values.1); recurse(t1, ref_ty2, &mut values); values @@ -1469,8 +1461,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // When encountering tuples of the same size, highlight only the differing types (&ty::Tuple(args1), &ty::Tuple(args2)) if args1.len() == args2.len() => { - let mut values = - (DiagnosticStyledString::normal("("), DiagnosticStyledString::normal("(")); + let mut values = (DiagStyledString::normal("("), DiagStyledString::normal("(")); let len = args1.len(); for (i, (left, right)) in args1.iter().zip(args2).enumerate() { recurse(left, right, &mut values); @@ -1520,7 +1511,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { (ty::FnPtr(sig1), ty::FnPtr(sig2)) => self.cmp_fn_sig(sig1, sig2), _ => { - let mut strs = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); + let mut strs = (DiagStyledString::new(), DiagStyledString::new()); maybe_highlight(t1, t2, &mut strs, self.tcx); strs } @@ -1542,7 +1533,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { )] pub fn note_type_err( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, cause: &ObligationCause<'tcx>, secondary_span: Option<(Span, Cow<'static, str>)>, mut values: Option>, @@ -1589,14 +1580,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { types_visitor } - fn report(&self, err: &mut DiagnosticBuilder<'_>) { + fn report(&self, err: &mut Diag<'_>) { self.add_labels_for_types(err, "expected", &self.expected); self.add_labels_for_types(err, "found", &self.found); } fn add_labels_for_types( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, target: &str, types: &FxIndexMap>, ) { @@ -1807,16 +1798,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // If two types mismatch but have similar names, mention that specifically. TypeError::Sorts(values) if let Some(s) = similarity(values) => { let diagnose_primitive = - |prim: Ty<'tcx>, - shadow: Ty<'tcx>, - defid: DefId, - diagnostic: &mut DiagnosticBuilder<'_>| { + |prim: Ty<'tcx>, shadow: Ty<'tcx>, defid: DefId, diag: &mut Diag<'_>| { let name = shadow.sort_string(self.tcx); - diagnostic.note(format!( - "{prim} and {name} have similar names, but are actually distinct types" - )); - diagnostic - .note(format!("{prim} is a primitive defined by the language")); + diag.note(format!( + "{prim} and {name} have similar names, but are actually distinct types" + )); + diag.note(format!("{prim} is a primitive defined by the language")); let def_span = self.tcx.def_span(defid); let msg = if defid.is_local() { format!("{name} is defined in the current crate") @@ -1824,20 +1811,20 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let crate_name = self.tcx.crate_name(defid.krate); format!("{name} is defined in crate `{crate_name}`") }; - diagnostic.span_note(def_span, msg); + diag.span_note(def_span, msg); }; let diagnose_adts = |expected_adt: ty::AdtDef<'tcx>, found_adt: ty::AdtDef<'tcx>, - diagnostic: &mut DiagnosticBuilder<'_>| { + diag: &mut Diag<'_>| { let found_name = values.found.sort_string(self.tcx); let expected_name = values.expected.sort_string(self.tcx); let found_defid = found_adt.did(); let expected_defid = expected_adt.did(); - diagnostic.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types")); + diag.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types")); for (defid, name) in [(found_defid, found_name), (expected_defid, expected_name)] { @@ -1859,7 +1846,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let crate_name = self.tcx.crate_name(defid.krate); format!("{name} is defined in crate `{crate_name}`") }; - diagnostic.span_note(def_span, msg); + diag.span_note(def_span, msg); } }; @@ -1938,7 +1925,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { "the full type name has been written to '{}'", path.display(), )); - diag.note(format!("consider using `--verbose` to print the full type name to the console")); + diag.note("consider using `--verbose` to print the full type name to the console"); } } } @@ -2178,7 +2165,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, trace: TypeTrace<'tcx>, terr: TypeError<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr); let span = trace.cause.span(); @@ -2223,7 +2210,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn values_str( &self, values: ValuePairs<'tcx>, - ) -> Option<(DiagnosticStyledString, DiagnosticStyledString, Option)> { + ) -> Option<(DiagStyledString, DiagStyledString, Option)> { match values { infer::Regions(exp_found) => self.expected_found_str(exp_found), infer::Terms(exp_found) => self.expected_found_str_term(exp_found), @@ -2256,7 +2243,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn expected_found_str_term( &self, exp_found: ty::error::ExpectedFound>, - ) -> Option<(DiagnosticStyledString, DiagnosticStyledString, Option)> { + ) -> Option<(DiagStyledString, DiagStyledString, Option)> { let exp_found = self.resolve_vars_if_possible(exp_found); if exp_found.references_error() { return None; @@ -2274,17 +2261,17 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let mut path = None; if exp_s.len() > len { let exp_s = self.tcx.short_ty_string(expected, &mut path); - exp = DiagnosticStyledString::highlighted(exp_s); + exp = DiagStyledString::highlighted(exp_s); } if fnd_s.len() > len { let fnd_s = self.tcx.short_ty_string(found, &mut path); - fnd = DiagnosticStyledString::highlighted(fnd_s); + fnd = DiagStyledString::highlighted(fnd_s); } (exp, fnd, path) } _ => ( - DiagnosticStyledString::highlighted(exp_found.expected.to_string()), - DiagnosticStyledString::highlighted(exp_found.found.to_string()), + DiagStyledString::highlighted(exp_found.expected.to_string()), + DiagStyledString::highlighted(exp_found.found.to_string()), None, ), }) @@ -2294,15 +2281,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn expected_found_str>>( &self, exp_found: ty::error::ExpectedFound, - ) -> Option<(DiagnosticStyledString, DiagnosticStyledString, Option)> { + ) -> Option<(DiagStyledString, DiagStyledString, Option)> { let exp_found = self.resolve_vars_if_possible(exp_found); if exp_found.references_error() { return None; } Some(( - DiagnosticStyledString::highlighted(exp_found.expected.to_string()), - DiagnosticStyledString::highlighted(exp_found.found.to_string()), + DiagStyledString::highlighted(exp_found.expected.to_string()), + DiagStyledString::highlighted(exp_found.found.to_string()), None, )) } @@ -2314,9 +2301,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { origin: Option>, bound_kind: GenericKind<'tcx>, sub: Region<'tcx>, - ) { + ) -> ErrorGuaranteed { self.construct_generic_bound_failure(generic_param_scope, span, origin, bound_kind, sub) - .emit(); + .emit() } pub fn construct_generic_bound_failure( @@ -2326,7 +2313,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { origin: Option>, bound_kind: GenericKind<'tcx>, sub: Region<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { if let Some(SubregionOrigin::CompareImplItemObligation { span, impl_item_def_id, @@ -2437,6 +2424,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let suggestion = if has_lifetimes { format!(" + {lt_name}") } else { format!(": {lt_name}") }; suggs.push((sp, suggestion)) + } else if let GenericKind::Alias(ref p) = bound_kind + && let ty::Projection = p.kind(self.tcx) + && let DefKind::AssocTy = self.tcx.def_kind(p.def_id) + && let Some(ty::ImplTraitInTraitData::Trait { .. }) = + self.tcx.opt_rpitit_info(p.def_id) + { + // The lifetime found in the `impl` is longer than the one on the RPITIT. + // Do not suggest `::{opaque}: 'static`. } else if let Some(generics) = self.tcx.hir().get_generics(suggestion_scope) { let pred = format!("{bound_kind}: {lt_name}"); let suggestion = format!("{} {}", generics.add_where_or_trailing_comma(), pred); @@ -2567,7 +2562,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { sub_region: Region<'tcx>, sup_origin: SubregionOrigin<'tcx>, sup_region: Region<'tcx>, - ) { + ) -> ErrorGuaranteed { let mut err = self.report_inference_failure(var_origin); note_and_explain_region( @@ -2606,12 +2601,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ); err.note_expected_found(&"", sup_expected, &"", sup_found); - if sub_region.is_error() | sup_region.is_error() { - err.delay_as_bug(); + return if sub_region.is_error() | sup_region.is_error() { + err.delay_as_bug() } else { - err.emit(); - } - return; + err.emit() + }; } self.note_region_origin(&mut err, &sup_origin); @@ -2626,11 +2620,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ); self.note_region_origin(&mut err, &sub_origin); - if sub_region.is_error() | sup_region.is_error() { - err.delay_as_bug(); - } else { - err.emit(); - } + if sub_region.is_error() | sup_region.is_error() { err.delay_as_bug() } else { err.emit() } } /// Determine whether an error associated with the given span and definition @@ -2736,10 +2726,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> { } impl<'tcx> InferCtxt<'tcx> { - fn report_inference_failure( - &self, - var_origin: RegionVariableOrigin, - ) -> DiagnosticBuilder<'tcx> { + fn report_inference_failure(&self, var_origin: RegionVariableOrigin) -> Diag<'tcx> { let br_string = |br: ty::BoundRegionKind| { let mut s = match br { ty::BrNamed(_, name) => name.to_string(), @@ -2905,7 +2892,7 @@ impl<'tcx> ObligationCause<'tcx> { pub struct ObligationCauseAsDiagArg<'tcx>(pub ObligationCause<'tcx>); impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { use crate::traits::ObligationCauseCode::*; let kind = match self.0.code() { CompareImplItemObligation { kind: ty::AssocKind::Fn, .. } => "method_compat", @@ -2919,7 +2906,7 @@ impl IntoDiagnosticArg for ObligationCauseAsDiagArg<'_> { _ => "other", } .into(); - rustc_errors::DiagnosticArgValue::Str(kind) + rustc_errors::DiagArgValue::Str(kind) } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 896d17478504d..6c968c488fec4 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -5,7 +5,7 @@ use crate::errors::{ use crate::infer::error_reporting::TypeErrCtxt; use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::infer::InferCtxt; -use rustc_errors::{codes::*, DiagnosticBuilder, IntoDiagnosticArg}; +use rustc_errors::{codes::*, Diag, IntoDiagnosticArg}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def::{CtorOf, DefKind, Namespace}; @@ -134,13 +134,13 @@ impl InferenceDiagnosticsParentData { } impl IntoDiagnosticArg for UnderspecifiedArgKind { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { let kind = match self { Self::Type { .. } => "type", Self::Const { is_parameter: true } => "const_with_param", Self::Const { is_parameter: false } => "const", }; - rustc_errors::DiagnosticArgValue::Str(kind.into()) + rustc_errors::DiagArgValue::Str(kind.into()) } } @@ -371,7 +371,7 @@ impl<'tcx> InferCtxt<'tcx> { span: Span, arg_data: InferenceDiagnosticsData, error_code: TypeAnnotationNeeded, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let source_kind = "other"; let source_name = ""; let failure_span = None; @@ -419,7 +419,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { arg: GenericArg<'tcx>, error_code: TypeAnnotationNeeded, should_label_span: bool, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let arg = self.resolve_vars_if_possible(arg); let arg_data = self.extract_inference_diagnostics_data(arg, None); diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs index cf8ac5441060d..aa700005a3afb 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -12,7 +12,7 @@ use crate::infer::SubregionOrigin; use crate::infer::TyCtxt; use rustc_errors::AddToDiagnostic; -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::{Diag, ErrorGuaranteed}; use rustc_hir::Ty; use rustc_middle::ty::Region; @@ -142,7 +142,7 @@ pub fn suggest_adding_lifetime_params<'tcx>( sub: Region<'tcx>, ty_sup: &'tcx Ty<'_>, ty_sub: &'tcx Ty<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) { let suggestion = AddLifetimeParamsSuggestion { tcx, sub, ty_sup, ty_sub, add_note: false }; suggestion.add_to_diagnostic(err); diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs index d3e28446ddef1..62c163f0b7f69 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs @@ -1,7 +1,7 @@ use crate::infer::error_reporting::TypeErrCtxt; use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::lexical_region_resolve::RegionResolutionError::*; -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::{Diag, ErrorGuaranteed}; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::Span; @@ -21,8 +21,11 @@ pub use static_impl_trait::{suggest_new_region_bound, HirTraitObjectVisitor, Tra pub use util::find_param_with_region; impl<'cx, 'tcx> TypeErrCtxt<'cx, 'tcx> { - pub fn try_report_nice_region_error(&'cx self, error: &RegionResolutionError<'tcx>) -> bool { - NiceRegionError::new(self, error.clone()).try_report().is_some() + pub fn try_report_nice_region_error( + &'cx self, + error: &RegionResolutionError<'tcx>, + ) -> Option { + NiceRegionError::new(self, error.clone()).try_report() } } @@ -50,7 +53,7 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> { self.cx.tcx } - pub fn try_report_from_nll(&self) -> Option> { + pub fn try_report_from_nll(&self) -> Option> { // Due to the improved diagnostics returned by the MIR borrow checker, only a subset of // the nice region errors are required when running under the MIR borrow checker. self.try_report_named_anon_conflict() diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs index ee892326dedfe..239c2db30e2d2 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -5,14 +5,14 @@ use crate::{ errors::ExplicitLifetimeRequired, infer::error_reporting::nice_region_error::find_anon_type::find_anon_type, }; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_middle::ty; use rustc_span::symbol::kw; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// When given a `ConcreteFailure` for a function with parameters containing a named region and /// an anonymous region, emit an descriptive diagnostic error. - pub(super) fn try_report_named_anon_conflict(&self) -> Option> { + pub(super) fn try_report_named_anon_conflict(&self) -> Option> { let (span, sub, sup) = self.regions()?; debug!( diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index b3b83c8ab957f..d6595a0c11458 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -8,7 +8,7 @@ use crate::infer::ValuePairs; use crate::infer::{SubregionOrigin, TypeTrace}; use crate::traits::{ObligationCause, ObligationCauseCode}; use rustc_data_structures::intern::Interned; -use rustc_errors::{DiagnosticBuilder, IntoDiagnosticArg}; +use rustc_errors::{Diag, IntoDiagnosticArg}; use rustc_hir::def::Namespace; use rustc_hir::def_id::DefId; use rustc_middle::ty::error::ExpectedFound; @@ -30,8 +30,8 @@ impl<'tcx, T> IntoDiagnosticArg for Highlighted<'tcx, T> where T: for<'a> Print<'tcx, FmtPrinter<'a, 'tcx>>, { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { - rustc_errors::DiagnosticArgValue::Str(self.to_string().into()) + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { + rustc_errors::DiagArgValue::Str(self.to_string().into()) } } @@ -57,7 +57,7 @@ where impl<'tcx> NiceRegionError<'_, 'tcx> { /// When given a `ConcreteFailure` for a function with arguments containing a named region and /// an anonymous region, emit a descriptive diagnostic error. - pub(super) fn try_report_placeholder_conflict(&self) -> Option> { + pub(super) fn try_report_placeholder_conflict(&self) -> Option> { match &self.error { /////////////////////////////////////////////////////////////////////////// // NB. The ordering of cases in this match is very @@ -193,7 +193,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { sub_placeholder: Option>, sup_placeholder: Option>, value_pairs: &ValuePairs<'tcx>, - ) -> Option> { + ) -> Option> { let (expected_args, found_args, trait_def_id) = match value_pairs { ValuePairs::PolyTraitRefs(ExpectedFound { expected, found }) if expected.def_id() == found.def_id() => @@ -236,7 +236,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { trait_def_id: DefId, expected_args: GenericArgsRef<'tcx>, actual_args: GenericArgsRef<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let span = cause.span(); let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) = diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs index e1dbf36607481..a3f306802de06 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs @@ -5,12 +5,12 @@ use crate::{ }, }; use rustc_data_structures::intern::Interned; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_middle::ty::{self, RePlaceholder, Region}; impl<'tcx> NiceRegionError<'_, 'tcx> { /// Emitted wwhen given a `ConcreteFailure` when relating two placeholders. - pub(super) fn try_report_placeholder_relation(&self) -> Option> { + pub(super) fn try_report_placeholder_relation(&self) -> Option> { match &self.error { Some(RegionResolutionError::ConcreteFailure( SubregionOrigin::RelateRegionParamBound(span), diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index 83e0b763d2448..33538309b042a 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -9,7 +9,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::{SubregionOrigin, TypeTrace}; use crate::traits::{ObligationCauseCode, UnifyReceiverContext}; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{AddToDiagnostic, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan}; +use rustc_errors::{AddToDiagnostic, Applicability, Diag, ErrorGuaranteed, MultiSpan}; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{walk_ty, Visitor}; use rustc_hir::{ @@ -261,7 +261,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { pub fn suggest_new_region_bound( tcx: TyCtxt<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, fn_returns: Vec<&rustc_hir::Ty<'_>>, lifetime_name: String, arg: Option, @@ -488,7 +488,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// `'static` obligation. Suggest relaxing that implicit bound. fn find_impl_on_dyn_trait( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ty: Ty<'_>, ctxt: &UnifyReceiverContext<'tcx>, ) -> bool { @@ -521,7 +521,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { fn suggest_constrain_dyn_trait_in_impl( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, found_dids: &FxIndexSet, ident: Ident, self_ty: &hir::Ty<'_>, diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index 0878505e85e57..2c369b5ad6085 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -5,7 +5,7 @@ use crate::errors::{ use crate::fluent_generated as fluent; use crate::infer::error_reporting::{note_and_explain_region, TypeErrCtxt}; use crate::infer::{self, SubregionOrigin}; -use rustc_errors::{AddToDiagnostic, DiagnosticBuilder}; +use rustc_errors::{AddToDiagnostic, Diag}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::traits::ObligationCauseCode; use rustc_middle::ty::error::TypeError; @@ -15,11 +15,7 @@ use rustc_span::symbol::kw; use super::ObligationCauseAsDiagArg; impl<'tcx> TypeErrCtxt<'_, 'tcx> { - pub(super) fn note_region_origin( - &self, - err: &mut DiagnosticBuilder<'_>, - origin: &SubregionOrigin<'tcx>, - ) { + pub(super) fn note_region_origin(&self, err: &mut Diag<'_>, origin: &SubregionOrigin<'tcx>) { match *origin { infer::Subtype(ref trace) => RegionOriginNote::WithRequirement { span: trace.cause.span, @@ -82,7 +78,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { origin: SubregionOrigin<'tcx>, sub: Region<'tcx>, sup: Region<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let mut err = match origin { infer::Subtype(box trace) => { let terr = TypeError::RegionsDoesNotOutlive(sup, sub); @@ -294,7 +290,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, trait_item_def_id: DefId, impl_item_def_id: LocalDefId, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) { // FIXME(compiler-errors): Right now this is only being used for region // predicate mismatches. Ideally, we'd use it for *all* predicate mismatches, @@ -354,7 +350,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { placeholder_origin: SubregionOrigin<'tcx>, sub: Region<'tcx>, sup: Region<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { // I can't think how to do better than this right now. -nikomatsakis debug!(?placeholder_origin, ?sub, ?sup, "report_placeholder_failure"); match placeholder_origin { diff --git a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs index 9df2f929501a6..1cbb4b2b23d68 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs @@ -1,6 +1,6 @@ use super::TypeErrCtxt; use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect}; -use rustc_errors::{pluralize, DiagnosticBuilder, MultiSpan}; +use rustc_errors::{pluralize, Diag, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_middle::traits::ObligationCauseCode; @@ -15,7 +15,7 @@ use rustc_span::{def_id::DefId, sym, BytePos, Span, Symbol}; impl<'tcx> TypeErrCtxt<'_, 'tcx> { pub fn note_and_explain_type_err( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, err: TypeError<'tcx>, cause: &ObligationCause<'tcx>, sp: Span, @@ -522,7 +522,7 @@ impl Trait for X { fn suggest_constraint( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, msg: impl Fn() -> String, body_owner_def_id: DefId, proj_ty: &ty::AliasTy<'tcx>, @@ -595,7 +595,7 @@ impl Trait for X { /// fn that returns the type. fn expected_projection( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, proj_ty: &ty::AliasTy<'tcx>, values: ExpectedFound>, body_owner_def_id: DefId, @@ -705,7 +705,7 @@ fn foo(&self) -> Self::T { String::new() } /// a return type. This can occur when dealing with `TryStream` (#71035). fn suggest_constraining_opaque_associated_type( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, msg: impl Fn() -> String, proj_ty: &ty::AliasTy<'tcx>, ty: Ty<'tcx>, @@ -740,7 +740,7 @@ fn foo(&self) -> Self::T { String::new() } fn point_at_methods_that_satisfy_associated_type( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, assoc_container_id: DefId, current_method_ident: Option, proj_ty_item_def_id: DefId, @@ -798,7 +798,7 @@ fn foo(&self) -> Self::T { String::new() } fn point_at_associated_type( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, body_owner_def_id: DefId, found: Ty<'tcx>, ) -> bool { @@ -879,7 +879,7 @@ fn foo(&self) -> Self::T { String::new() } /// type is defined on a supertrait of the one present in the bounds. fn constrain_generic_bound_associated_type_structured_suggestion( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, trait_ref: &ty::TraitRef<'tcx>, bounds: hir::GenericBounds<'_>, assoc: ty::AssocItem, @@ -916,7 +916,7 @@ fn foo(&self) -> Self::T { String::new() } /// associated type to a given type `ty`. fn constrain_associated_type_structured_suggestion( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, span: Span, assoc: ty::AssocItem, assoc_args: &[ty::GenericArg<'tcx>], diff --git a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs index f7102ab620539..cfe8b75bdd76b 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs @@ -1,7 +1,7 @@ use hir::def::CtorKind; use hir::intravisit::{walk_expr, walk_stmt, Visitor}; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_hir as hir; use rustc_middle::traits::{ IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode, @@ -76,7 +76,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { pub(super) fn suggest_boxing_for_return_impl_trait( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, return_sp: Span, arm_spans: impl Iterator, ) { @@ -100,7 +100,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, cause: &ObligationCause<'tcx>, exp_found: &ty::error::ExpectedFound>, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, ) { // Heavily inspired by `FnCtxt::suggest_compatible_variants`, with // some modifications due to that being in typeck and this being in infer. @@ -177,7 +177,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { cause: &ObligationCause<'tcx>, exp_span: Span, exp_found: &ty::error::ExpectedFound>, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, ) { debug!( "suggest_await_on_expect_found: exp_span={:?}, expected_ty={:?}, found_ty={:?}", @@ -258,7 +258,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, cause: &ObligationCause<'tcx>, exp_found: &ty::error::ExpectedFound>, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, ) { debug!( "suggest_accessing_field_where_appropriate(cause={:?}, exp_found={:?})", @@ -298,7 +298,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { cause: &ObligationCause<'tcx>, span: Span, exp_found: &ty::error::ExpectedFound>, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, ) { debug!("suggest_function_pointers(cause={:?}, exp_found={:?})", cause, exp_found); let ty::error::ExpectedFound { expected, found } = exp_found; @@ -532,7 +532,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { span: Span, hir: hir::Node<'_>, exp_found: &ty::error::ExpectedFound>, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, ) { // 0. Extract fn_decl from hir let hir::Node::Expr(hir::Expr { @@ -818,7 +818,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, blk: &'tcx hir::Block<'tcx>, expected_ty: Ty<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) -> bool { let diag = self.consider_returning_binding_diag(blk, expected_ty); match diag { diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index c30f42c1656e0..d7e16488508b5 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -23,7 +23,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::undo_log::Rollback; use rustc_data_structures::unify as ut; -use rustc_errors::{DiagCtxt, DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues}; use rustc_middle::infer::unify_key::ConstVariableValue; @@ -54,6 +54,7 @@ use self::region_constraints::{ RegionConstraintCollector, RegionConstraintStorage, RegionSnapshot, }; pub use self::relate::combine::CombineFields; +pub use self::relate::StructurallyRelateAliases; use self::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; pub mod at; @@ -1766,9 +1767,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { sp: Span, mk_diag: M, actual_ty: Ty<'tcx>, - ) -> DiagnosticBuilder<'tcx> + ) -> Diag<'tcx> where - M: FnOnce(String) -> DiagnosticBuilder<'tcx>, + M: FnOnce(String) -> Diag<'tcx>, { let actual_ty = self.resolve_vars_if_possible(actual_ty); debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty); @@ -1789,7 +1790,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { expected: Ty<'tcx>, actual: Ty<'tcx>, err: TypeError<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { self.report_and_explain_type_error(TypeTrace::types(cause, true, expected, actual), err) } @@ -1799,7 +1800,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { expected: ty::Const<'tcx>, actual: ty::Const<'tcx>, err: TypeError<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { self.report_and_explain_type_error(TypeTrace::consts(cause, true, expected, actual), err) } } diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index c0a99e5cc4177..8dd3a1f40cc10 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -62,6 +62,7 @@ use crate::infer::outlives::components::{push_outlives_components, Component}; use crate::infer::outlives::env::RegionBoundPairs; use crate::infer::outlives::verify::VerifyBoundCx; +use crate::infer::resolve::OpportunisticRegionResolver; use crate::infer::{ self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, UndoLog, VerifyBound, }; @@ -69,7 +70,9 @@ use crate::traits::{ObligationCause, ObligationCauseCode}; use rustc_data_structures::undo_log::UndoLogs; use rustc_middle::mir::ConstraintCategory; use rustc_middle::traits::query::NoSolution; -use rustc_middle::ty::{self, GenericArgsRef, Region, Ty, TyCtxt, TypeVisitableExt}; +use rustc_middle::ty::{ + self, GenericArgsRef, Region, Ty, TyCtxt, TypeFoldable as _, TypeVisitableExt, +}; use rustc_middle::ty::{GenericArgKind, PolyTypeOutlivesPredicate}; use rustc_span::DUMMY_SP; use smallvec::smallvec; @@ -176,6 +179,11 @@ impl<'tcx> InferCtxt<'tcx> { .map_err(|NoSolution| (outlives, origin.clone()))? .no_bound_vars() .expect("started with no bound vars, should end with no bound vars"); + // `TypeOutlives` is structural, so we should try to opportunistically resolve all + // region vids before processing regions, so we have a better chance to match clauses + // in our param-env. + let (sup_type, sub_region) = + (sup_type, sub_region).fold_with(&mut OpportunisticRegionResolver::new(self)); debug!(?sup_type, ?sub_region, ?origin); diff --git a/compiler/rustc_infer/src/infer/relate/combine.rs b/compiler/rustc_infer/src/infer/relate/combine.rs index f7690831c2acc..0852bb4f993b3 100644 --- a/compiler/rustc_infer/src/infer/relate/combine.rs +++ b/compiler/rustc_infer/src/infer/relate/combine.rs @@ -26,6 +26,7 @@ use super::equate::Equate; use super::glb::Glb; use super::lub::Lub; use super::sub::Sub; +use super::StructurallyRelateAliases; use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace}; use crate::traits::{Obligation, PredicateObligations}; use rustc_middle::infer::canonical::OriginalQueryValues; @@ -116,8 +117,15 @@ impl<'tcx> InferCtxt<'tcx> { } (_, ty::Alias(..)) | (ty::Alias(..), _) if self.next_trait_solver() => { - relation.register_type_relate_obligation(a, b); - Ok(a) + match relation.structurally_relate_aliases() { + StructurallyRelateAliases::Yes => { + ty::relate::structurally_relate_tys(relation, a, b) + } + StructurallyRelateAliases::No => { + relation.register_type_relate_obligation(a, b); + Ok(a) + } + } } // All other cases of inference are errors @@ -240,19 +248,26 @@ impl<'tcx> InferCtxt<'tcx> { (ty::ConstKind::Unevaluated(..), _) | (_, ty::ConstKind::Unevaluated(..)) if self.tcx.features().generic_const_exprs || self.next_trait_solver() => { - let (a, b) = if relation.a_is_expected() { (a, b) } else { (b, a) }; - - relation.register_predicates([if self.next_trait_solver() { - ty::PredicateKind::AliasRelate( - a.into(), - b.into(), - ty::AliasRelationDirection::Equate, - ) - } else { - ty::PredicateKind::ConstEquate(a, b) - }]); - - Ok(b) + match relation.structurally_relate_aliases() { + StructurallyRelateAliases::No => { + let (a, b) = if relation.a_is_expected() { (a, b) } else { (b, a) }; + + relation.register_predicates([if self.next_trait_solver() { + ty::PredicateKind::AliasRelate( + a.into(), + b.into(), + ty::AliasRelationDirection::Equate, + ) + } else { + ty::PredicateKind::ConstEquate(a, b) + }]); + + Ok(b) + } + StructurallyRelateAliases::Yes => { + ty::relate::structurally_relate_consts(relation, a, b) + } + } } _ => ty::relate::structurally_relate_consts(relation, a, b), } @@ -303,8 +318,12 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> { self.infcx.tcx } - pub fn equate<'a>(&'a mut self, a_is_expected: bool) -> Equate<'a, 'infcx, 'tcx> { - Equate::new(self, a_is_expected) + pub fn equate<'a>( + &'a mut self, + structurally_relate_aliases: StructurallyRelateAliases, + a_is_expected: bool, + ) -> Equate<'a, 'infcx, 'tcx> { + Equate::new(self, structurally_relate_aliases, a_is_expected) } pub fn sub<'a>(&'a mut self, a_is_expected: bool) -> Sub<'a, 'infcx, 'tcx> { @@ -335,6 +354,11 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> { fn param_env(&self) -> ty::ParamEnv<'tcx>; + /// Whether aliases should be related structurally. This is pretty much + /// always `No` unless you're equating in some specific locations of the + /// new solver. See the comments in these use-cases for more details. + fn structurally_relate_aliases(&self) -> StructurallyRelateAliases; + /// Register obligations that must hold in order for this relation to hold fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>); diff --git a/compiler/rustc_infer/src/infer/relate/equate.rs b/compiler/rustc_infer/src/infer/relate/equate.rs index aefa9a5a0d61c..43d6aef3e1532 100644 --- a/compiler/rustc_infer/src/infer/relate/equate.rs +++ b/compiler/rustc_infer/src/infer/relate/equate.rs @@ -1,4 +1,5 @@ use super::combine::{CombineFields, ObligationEmittingRelation}; +use super::StructurallyRelateAliases; use crate::infer::{DefineOpaqueTypes, SubregionOrigin}; use crate::traits::PredicateObligations; @@ -13,15 +14,17 @@ use rustc_span::Span; /// Ensures `a` is made equal to `b`. Returns `a` on success. pub struct Equate<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, + structurally_relate_aliases: StructurallyRelateAliases, a_is_expected: bool, } impl<'combine, 'infcx, 'tcx> Equate<'combine, 'infcx, 'tcx> { pub fn new( fields: &'combine mut CombineFields<'infcx, 'tcx>, + structurally_relate_aliases: StructurallyRelateAliases, a_is_expected: bool, ) -> Equate<'combine, 'infcx, 'tcx> { - Equate { fields, a_is_expected } + Equate { fields, structurally_relate_aliases, a_is_expected } } } @@ -99,7 +102,7 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> { &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), ) if a_def_id == b_def_id => { - self.fields.infcx.super_combine_tys(self, a, b)?; + infcx.super_combine_tys(self, a, b)?; } (&ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }), _) | (_, &ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. })) @@ -120,7 +123,7 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> { ); } _ => { - self.fields.infcx.super_combine_tys(self, a, b)?; + infcx.super_combine_tys(self, a, b)?; } } @@ -180,6 +183,10 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Equate<'_, '_, 'tcx> { self.fields.trace.span() } + fn structurally_relate_aliases(&self) -> StructurallyRelateAliases { + self.structurally_relate_aliases + } + fn param_env(&self) -> ty::ParamEnv<'tcx> { self.fields.param_env } diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs index c4c9ddb1ad8e6..e84d4ceaea899 100644 --- a/compiler/rustc_infer/src/infer/relate/generalize.rs +++ b/compiler/rustc_infer/src/infer/relate/generalize.rs @@ -1,5 +1,6 @@ use std::mem; +use super::StructurallyRelateAliases; use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind, TypeVariableValue}; use crate::infer::{InferCtxt, ObligationEmittingRelation, RegionVariableOrigin}; use rustc_data_structures::sso::SsoHashMap; @@ -26,13 +27,13 @@ impl<'tcx> InferCtxt<'tcx> { /// This is *not* expected to be used anywhere except for an implementation of /// `TypeRelation`. Do not use this, and instead please use `At::eq`, for all /// other usecases (i.e. setting the value of a type var). - #[instrument(level = "debug", skip(self, relation, target_is_expected))] + #[instrument(level = "debug", skip(self, relation))] pub fn instantiate_ty_var>( &self, relation: &mut R, target_is_expected: bool, target_vid: ty::TyVid, - ambient_variance: ty::Variance, + instantiation_variance: ty::Variance, source_ty: Ty<'tcx>, ) -> RelateResult<'tcx, ()> { debug_assert!(self.inner.borrow_mut().type_variables().probe(target_vid).is_unknown()); @@ -45,8 +46,14 @@ impl<'tcx> InferCtxt<'tcx> { // region/type inference variables. // // We then relate `generalized_ty <: source_ty`,adding constraints like `'x: '?2` and `?1 <: ?3`. - let Generalization { value_may_be_infer: generalized_ty, has_unconstrained_ty_var } = - self.generalize(relation.span(), target_vid, ambient_variance, source_ty)?; + let Generalization { value_may_be_infer: generalized_ty, has_unconstrained_ty_var } = self + .generalize( + relation.span(), + relation.structurally_relate_aliases(), + target_vid, + instantiation_variance, + source_ty, + )?; // Constrain `b_vid` to the generalized type `generalized_ty`. if let &ty::Infer(ty::TyVar(generalized_vid)) = generalized_ty.kind() { @@ -73,7 +80,7 @@ impl<'tcx> InferCtxt<'tcx> { // the alias can be normalized to something which does not // mention `?0`. if self.next_trait_solver() { - let (lhs, rhs, direction) = match ambient_variance { + let (lhs, rhs, direction) = match instantiation_variance { ty::Variance::Invariant => { (generalized_ty.into(), source_ty.into(), AliasRelationDirection::Equate) } @@ -106,22 +113,28 @@ impl<'tcx> InferCtxt<'tcx> { } } } else { - // HACK: make sure that we `a_is_expected` continues to be - // correct when relating the generalized type with the source. + // NOTE: The `instantiation_variance` is not the same variance as + // used by the relation. When instantiating `b`, `target_is_expected` + // is flipped and the `instantion_variance` is also flipped. To + // constrain the `generalized_ty` while using the original relation, + // we therefore only have to flip the arguments. + // + // ```ignore (not code) + // ?a rel B + // instantiate_ty_var(?a, B) # expected and variance not flipped + // B' rel B + // ``` + // or + // ```ignore (not code) + // A rel ?b + // instantiate_ty_var(?b, A) # expected and variance flipped + // A rel A' + // ``` if target_is_expected == relation.a_is_expected() { - relation.relate_with_variance( - ambient_variance, - ty::VarianceDiagInfo::default(), - generalized_ty, - source_ty, - )?; + relation.relate(generalized_ty, source_ty)?; } else { - relation.relate_with_variance( - ambient_variance.xform(ty::Contravariant), - ty::VarianceDiagInfo::default(), - source_ty, - generalized_ty, - )?; + debug!("flip relation"); + relation.relate(source_ty, generalized_ty)?; } } @@ -172,8 +185,14 @@ impl<'tcx> InferCtxt<'tcx> { ) -> RelateResult<'tcx, ()> { // FIXME(generic_const_exprs): Occurs check failures for unevaluated // constants and generic expressions are not yet handled correctly. - let Generalization { value_may_be_infer: generalized_ct, has_unconstrained_ty_var } = - self.generalize(relation.span(), target_vid, ty::Variance::Invariant, source_ct)?; + let Generalization { value_may_be_infer: generalized_ct, has_unconstrained_ty_var } = self + .generalize( + relation.span(), + relation.structurally_relate_aliases(), + target_vid, + ty::Variance::Invariant, + source_ct, + )?; debug_assert!(!generalized_ct.is_ct_infer()); if has_unconstrained_ty_var { @@ -211,6 +230,7 @@ impl<'tcx> InferCtxt<'tcx> { fn generalize> + Relate<'tcx>>( &self, span: Span, + structurally_relate_aliases: StructurallyRelateAliases, target_vid: impl Into, ambient_variance: ty::Variance, source_term: T, @@ -231,6 +251,7 @@ impl<'tcx> InferCtxt<'tcx> { let mut generalizer = Generalizer { infcx: self, span, + structurally_relate_aliases, root_vid, for_universe, ambient_variance, @@ -264,6 +285,10 @@ struct Generalizer<'me, 'tcx> { span: Span, + /// Whether aliases should be related structurally. If not, we have to + /// be careful when generalizing aliases. + structurally_relate_aliases: StructurallyRelateAliases, + /// The vid of the type variable that is in the process of being /// instantiated. If we find this within the value we are folding, /// that means we would have created a cyclic value. @@ -308,13 +333,30 @@ impl<'tcx> Generalizer<'_, 'tcx> { /// to normalize the alias after all. /// /// We handle this by lazily equating the alias and generalizing - /// it to an inference variable. + /// it to an inference variable. In the new solver, we always + /// generalize to an infer var unless the alias contains escaping + /// bound variables. /// - /// This is incomplete and will hopefully soon get fixed by #119106. + /// Correctly handling aliases with escaping bound variables is + /// difficult and currently incomplete in two opposite ways: + /// - if we get an occurs check failure in the alias, replace it with a new infer var. + /// This causes us to later emit an alias-relate goal and is incomplete in case the + /// alias normalizes to type containing one of the bound variables. + /// - if the alias contains an inference variable not nameable by `for_universe`, we + /// continue generalizing the alias. This ends up pulling down the universe of the + /// inference variable and is incomplete in case the alias would normalize to a type + /// which does not mention that inference variable. fn generalize_alias_ty( &mut self, alias: ty::AliasTy<'tcx>, ) -> Result, TypeError<'tcx>> { + if self.infcx.next_trait_solver() && !alias.has_escaping_bound_vars() { + return Ok(self.infcx.next_ty_var_in_universe( + TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span: self.span }, + self.for_universe, + )); + } + let is_nested_alias = mem::replace(&mut self.in_alias, true); let result = match self.relate(alias, alias) { Ok(alias) => Ok(alias.to_ty(self.tcx())), @@ -484,7 +526,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> { } } - ty::Alias(_, data) => self.generalize_alias_ty(data), + ty::Alias(_, data) => match self.structurally_relate_aliases { + StructurallyRelateAliases::No => self.generalize_alias_ty(data), + StructurallyRelateAliases::Yes => relate::structurally_relate_tys(self, t, t), + }, _ => relate::structurally_relate_tys(self, t, t), }?; diff --git a/compiler/rustc_infer/src/infer/relate/glb.rs b/compiler/rustc_infer/src/infer/relate/glb.rs index 6cf5135459967..52a2f4c73470c 100644 --- a/compiler/rustc_infer/src/infer/relate/glb.rs +++ b/compiler/rustc_infer/src/infer/relate/glb.rs @@ -6,6 +6,7 @@ use rustc_span::Span; use super::combine::{CombineFields, ObligationEmittingRelation}; use super::lattice::{self, LatticeDir}; +use super::StructurallyRelateAliases; use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin}; use crate::traits::{ObligationCause, PredicateObligations}; @@ -45,7 +46,9 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> { b: T, ) -> RelateResult<'tcx, T> { match variance { - ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b), + ty::Invariant => { + self.fields.equate(StructurallyRelateAliases::No, self.a_is_expected).relate(a, b) + } ty::Covariant => self.relate(a, b), // FIXME(#41044) -- not correct, need test ty::Bivariant => Ok(a), @@ -139,6 +142,10 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> { self.fields.trace.span() } + fn structurally_relate_aliases(&self) -> StructurallyRelateAliases { + StructurallyRelateAliases::No + } + fn param_env(&self) -> ty::ParamEnv<'tcx> { self.fields.param_env } diff --git a/compiler/rustc_infer/src/infer/relate/lub.rs b/compiler/rustc_infer/src/infer/relate/lub.rs index 5b4f80fd73a02..fa0da64ca65af 100644 --- a/compiler/rustc_infer/src/infer/relate/lub.rs +++ b/compiler/rustc_infer/src/infer/relate/lub.rs @@ -2,6 +2,7 @@ use super::combine::{CombineFields, ObligationEmittingRelation}; use super::lattice::{self, LatticeDir}; +use super::StructurallyRelateAliases; use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin}; use crate::traits::{ObligationCause, PredicateObligations}; @@ -45,7 +46,9 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> { b: T, ) -> RelateResult<'tcx, T> { match variance { - ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b), + ty::Invariant => { + self.fields.equate(StructurallyRelateAliases::No, self.a_is_expected).relate(a, b) + } ty::Covariant => self.relate(a, b), // FIXME(#41044) -- not correct, need test ty::Bivariant => Ok(a), @@ -139,6 +142,10 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> { self.fields.trace.span() } + fn structurally_relate_aliases(&self) -> StructurallyRelateAliases { + StructurallyRelateAliases::No + } + fn param_env(&self) -> ty::ParamEnv<'tcx> { self.fields.param_env } diff --git a/compiler/rustc_infer/src/infer/relate/mod.rs b/compiler/rustc_infer/src/infer/relate/mod.rs index 1207377e85712..8619cc502ad2c 100644 --- a/compiler/rustc_infer/src/infer/relate/mod.rs +++ b/compiler/rustc_infer/src/infer/relate/mod.rs @@ -9,3 +9,15 @@ mod higher_ranked; mod lattice; mod lub; mod sub; + +/// Whether aliases should be related structurally or not. Used +/// to adjust the behavior of generalization and combine. +/// +/// This should always be `No` unless in a few special-cases when +/// instantiating canonical responses and in the new solver. Each +/// such case should have a comment explaining why it is used. +#[derive(Debug, Copy, Clone)] +pub enum StructurallyRelateAliases { + Yes, + No, +} diff --git a/compiler/rustc_infer/src/infer/relate/sub.rs b/compiler/rustc_infer/src/infer/relate/sub.rs index 5bd3a238a67e8..2cc8d0d3b10b3 100644 --- a/compiler/rustc_infer/src/infer/relate/sub.rs +++ b/compiler/rustc_infer/src/infer/relate/sub.rs @@ -1,4 +1,5 @@ use super::combine::CombineFields; +use super::StructurallyRelateAliases; use crate::infer::{DefineOpaqueTypes, ObligationEmittingRelation, SubregionOrigin}; use crate::traits::{Obligation, PredicateObligations}; @@ -64,7 +65,9 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> { b: T, ) -> RelateResult<'tcx, T> { match variance { - ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b), + ty::Invariant => { + self.fields.equate(StructurallyRelateAliases::No, self.a_is_expected).relate(a, b) + } ty::Covariant => self.relate(a, b), ty::Bivariant => Ok(a), ty::Contravariant => self.with_expected_switched(|this| this.relate(b, a)), @@ -204,6 +207,10 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Sub<'_, '_, 'tcx> { self.fields.trace.span() } + fn structurally_relate_aliases(&self) -> StructurallyRelateAliases { + StructurallyRelateAliases::No + } + fn param_env(&self) -> ty::ParamEnv<'tcx> { self.fields.param_env } diff --git a/compiler/rustc_infer/src/traits/error_reporting/mod.rs b/compiler/rustc_infer/src/traits/error_reporting/mod.rs index 0253f5a2df2a2..890e25368bc75 100644 --- a/compiler/rustc_infer/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/traits/error_reporting/mod.rs @@ -2,7 +2,7 @@ use super::ObjectSafetyViolation; use crate::infer::InferCtxt; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan}; +use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan}; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::ty::print::with_no_trimmed_paths; @@ -18,7 +18,7 @@ impl<'tcx> InferCtxt<'tcx> { impl_item_def_id: LocalDefId, trait_item_def_id: DefId, requirement: &dyn fmt::Display, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let mut err = struct_span_code_err!( self.tcx.dcx(), error_span, @@ -45,7 +45,7 @@ pub fn report_object_safety_error<'tcx>( hir_id: Option, trait_def_id: DefId, violations: &[ObjectSafetyViolation], -) -> DiagnosticBuilder<'tcx> { +) -> Diag<'tcx> { let trait_str = tcx.def_path_str(trait_def_id); let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node { hir::Node::Item(item) => Some(item.ident.span), diff --git a/compiler/rustc_interface/src/callbacks.rs b/compiler/rustc_interface/src/callbacks.rs index 8c7e49b51f9b2..f44ae705a3c27 100644 --- a/compiler/rustc_interface/src/callbacks.rs +++ b/compiler/rustc_interface/src/callbacks.rs @@ -9,7 +9,7 @@ //! The functions in this file should fall back to the default set in their //! origin crate when the `TyCtxt` is not present in TLS. -use rustc_errors::{Diagnostic, TRACK_DIAGNOSTIC}; +use rustc_errors::{DiagInner, TRACK_DIAGNOSTIC}; use rustc_middle::dep_graph::{DepNodeExt, TaskDepsRef}; use rustc_middle::ty::tls; use rustc_query_system::dep_graph::dep_node::default_dep_kind_debug; @@ -29,7 +29,7 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) { /// This is a callback from `rustc_errors` as it cannot access the implicit state /// in `rustc_middle` otherwise. It is used when diagnostic messages are /// emitted and stores them in the current query, if there is one. -fn track_diagnostic(diagnostic: Diagnostic, f: &mut dyn FnMut(Diagnostic)) { +fn track_diagnostic(diagnostic: DiagInner, f: &mut dyn FnMut(DiagInner)) { tls::with_context_opt(|icx| { if let Some(icx) = icx { if let Some(diagnostics) = icx.diagnostics { diff --git a/compiler/rustc_lint/Cargo.toml b/compiler/rustc_lint/Cargo.toml index fa1133e7780ff..2271321b8bf22 100644 --- a/compiler/rustc_lint/Cargo.toml +++ b/compiler/rustc_lint/Cargo.toml @@ -23,6 +23,7 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_type_ir = { path = "../rustc_type_ir" } +smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tracing = "0.1" unicode-security = "0.1.0" # tidy-alphabetical-end diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 1548646c04a28..63e2fe47659db 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -244,9 +244,28 @@ lint_hidden_unicode_codepoints = unicode codepoint changing visible direction of lint_identifier_non_ascii_char = identifier contains non-ASCII characters lint_identifier_uncommon_codepoints = identifier contains {$codepoints_len -> - [one] an uncommon Unicode codepoint - *[other] uncommon Unicode codepoints + [one] { $identifier_type -> + [Exclusion] a character from an archaic script + [Technical] a character that is for non-linguistic, specialized usage + [Limited_Use] a character from a script in limited use + [Not_NFKC] a non normalized (NFKC) character + *[other] an uncommon character + } + *[other] { $identifier_type -> + [Exclusion] {$codepoints_len} characters from archaic scripts + [Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage + [Limited_Use] {$codepoints_len} characters from scripts in limited use + [Not_NFKC] {$codepoints_len} non normalized (NFKC) characters + *[other] uncommon characters + } }: {$codepoints} + .note = {$codepoints_len -> + [one] this character is + *[other] these characters are + } included in the{$identifier_type -> + [Restricted] {""} + *[other] {" "}{$identifier_type} + } Unicode general security profile lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level @@ -414,6 +433,29 @@ lint_non_fmt_panic_unused = } .add_fmt_suggestion = or add a "{"{"}{"}"}" format string to use the message literally +lint_non_local_definitions_cargo_update = the {$macro_kind} `{$macro_name}` may come from an old version of the `{$crate_name}` crate, try updating your dependency with `cargo update -p {$crate_name}` + +lint_non_local_definitions_deprecation = this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue + +lint_non_local_definitions_impl = non-local `impl` definition, they should be avoided as they go against expectation + .help = + move this `impl` block outside the of the current {$body_kind_descr} {$depth -> + [one] `{$body_name}` + *[other] `{$body_name}` and up {$depth} bodies + } + .non_local = an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block + .exception = one exception to the rule are anon-const (`const _: () = {"{"} ... {"}"}`) at top-level module and anon-const at the same nesting as the trait or type + .const_anon = use a const-anon item to suppress this lint + +lint_non_local_definitions_macro_rules = non-local `macro_rules!` definition, they should be avoided as they go against expectation + .help = + remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth -> + [one] `{$body_name}` + *[other] `{$body_name}` and up {$depth} bodies + } + .non_local = a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute + .exception = one exception to the rule are anon-const (`const _: () = {"{"} ... {"}"}`) at top-level module + lint_non_snake_case = {$sort} `{$name}` should have a snake case name .rename_or_convert_suggestion = rename the identifier or convert it to a snake case raw identifier .cannot_convert_note = `{$sc}` cannot be used as a raw identifier @@ -429,6 +471,7 @@ lint_non_upper_case_global = {$sort} `{$name}` should have an upper case name lint_noop_method_call = call to `.{$method}()` on a reference in this situation does nothing .suggestion = remove this redundant call .note = the type `{$orig_ty}` does not implement `{$trait_}`, so calling `{$method}` on `&{$orig_ty}` copies the reference, which does not do anything and can be removed + .derive_suggestion = if you meant to clone `{$orig_ty}`, implement `Clone` for it lint_only_cast_u8_to_char = only `u8` can be cast into `char` .suggestion = use a `char` literal instead diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 3a5c585366a31..993b1d739a13d 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -70,11 +70,15 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { // Check if the method call actually calls the libcore // `IntoIterator::into_iter`. - let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap(); - match cx.tcx.trait_of_item(def_id) { - Some(trait_id) if cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_id) => {} - _ => return, - }; + let trait_id = cx + .typeck_results() + .type_dependent_def_id(expr.hir_id) + .and_then(|did| cx.tcx.trait_of_item(did)); + if trait_id.is_none() + || !cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_id.unwrap()) + { + return; + } // As this is a method call expression, we have at least one argument. let receiver_ty = cx.typeck_results().expr_ty(receiver_arg); diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 92f7497362e03..9f73d2e681251 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1825,7 +1825,7 @@ impl KeywordIdents { match tt { // Only report non-raw idents. TokenTree::Token(token, _) => { - if let Some((ident, false)) = token.ident() { + if let Some((ident, token::IdentIsRaw::No)) = token.ident() { self.check_ident_token(cx, UnderMacro(true), ident); } } diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 5e27a0ed81884..ab76da36ee314 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -21,7 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sync; use rustc_data_structures::unord::UnordMap; -use rustc_errors::{DecorateLint, DiagnosticBuilder, DiagnosticMessage, MultiSpan}; +use rustc_errors::{DecorateLint, Diag, DiagnosticMessage, MultiSpan}; use rustc_feature::Features; use rustc_hir as hir; use rustc_hir::def::Res; @@ -338,7 +338,7 @@ impl LintStore { } /// Checks the name of a lint for its existence, and whether it was - /// renamed or removed. Generates a DiagnosticBuilder containing a + /// renamed or removed. Generates a `Diag` containing a /// warning for renamed and removed lints. This is over both lint /// names from attributes and those passed on the command line. Since /// it emits non-fatal warnings and there are *two* lint passes that @@ -537,7 +537,7 @@ pub trait LintContext { lint: &'static Lint, span: Option>, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), diagnostic: BuiltinLintDiagnostics, ) { // We first generate a blank diagnostic. @@ -560,7 +560,7 @@ pub trait LintContext { lint: &'static Lint, span: Option, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ); /// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`, @@ -585,7 +585,7 @@ pub trait LintContext { lint: &'static Lint, span: S, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { self.opt_span_lint(lint, Some(span), msg, decorate); } @@ -606,7 +606,7 @@ pub trait LintContext { &self, lint: &'static Lint, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { self.opt_span_lint(lint, None as Option, msg, decorate); } @@ -671,7 +671,7 @@ impl<'tcx> LintContext for LateContext<'tcx> { lint: &'static Lint, span: Option, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { let hir_id = self.last_node_with_lint_attrs; @@ -698,7 +698,7 @@ impl LintContext for EarlyContext<'_> { lint: &'static Lint, span: Option, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { self.builder.opt_span_lint(lint, span.map(|s| s.into()), msg, decorate) } diff --git a/compiler/rustc_lint/src/context/diagnostics.rs b/compiler/rustc_lint/src/context/diagnostics.rs index 86434002e2c66..71aef50391d5b 100644 --- a/compiler/rustc_lint/src/context/diagnostics.rs +++ b/compiler/rustc_lint/src/context/diagnostics.rs @@ -2,7 +2,7 @@ #![allow(rustc::untranslatable_diagnostic)] use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS; -use rustc_errors::{add_elided_lifetime_in_path_suggestion, DiagnosticBuilder}; +use rustc_errors::{add_elided_lifetime_in_path_suggestion, Diag}; use rustc_errors::{Applicability, SuggestionStyle}; use rustc_middle::middle::stability; use rustc_session::config::ExpectedValues; @@ -12,11 +12,7 @@ use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::symbol::{sym, Symbol}; use rustc_span::BytePos; -pub(super) fn builtin( - sess: &Session, - diagnostic: BuiltinLintDiagnostics, - db: &mut DiagnosticBuilder<'_, ()>, -) { +pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag: &mut Diag<'_, ()>) { match diagnostic { BuiltinLintDiagnostics::UnicodeTextFlow(span, content) => { let spans: Vec<_> = content @@ -32,22 +28,22 @@ pub(super) fn builtin( 1 => ("an ", ""), _ => ("", "s"), }; - db.span_label( + diag.span_label( span, format!( "this comment contains {an}invisible unicode text flow control codepoint{s}", ), ); for (c, span) in &spans { - db.span_label(*span, format!("{c:?}")); + diag.span_label(*span, format!("{c:?}")); } - db.note( + diag.note( "these kind of unicode codepoints change the way text flows on \ applications that support them, but can cause confusion because they \ change the order of characters on the screen", ); if !spans.is_empty() { - db.multipart_suggestion_with_style( + diag.multipart_suggestion_with_style( "if their presence wasn't intentional, you can remove them", spans.into_iter().map(|(_, span)| (span, "".to_string())).collect(), Applicability::MachineApplicable, @@ -67,16 +63,16 @@ pub(super) fn builtin( } Err(_) => ("crate::".to_string(), Applicability::HasPlaceholders), }; - db.span_suggestion(span, "use `crate`", sugg, app); + diag.span_suggestion(span, "use `crate`", sugg, app); } BuiltinLintDiagnostics::ProcMacroDeriveResolutionFallback(span) => { - db.span_label( + diag.span_label( span, "names from parent modules are not accessible without an explicit import", ); } BuiltinLintDiagnostics::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => { - db.span_note(span_def, "the macro is defined here"); + diag.span_note(span_def, "the macro is defined here"); } BuiltinLintDiagnostics::ElidedLifetimesInPaths( n, @@ -86,7 +82,7 @@ pub(super) fn builtin( ) => { add_elided_lifetime_in_path_suggestion( sess.source_map(), - db, + diag, n, path_span, incl_angl_brckt, @@ -94,11 +90,11 @@ pub(super) fn builtin( ); } BuiltinLintDiagnostics::UnknownCrateTypes(span, note, sugg) => { - db.span_suggestion(span, note, sugg, Applicability::MaybeIncorrect); + diag.span_suggestion(span, note, sugg, Applicability::MaybeIncorrect); } BuiltinLintDiagnostics::UnusedImports(message, replaces, in_test_module) => { if !replaces.is_empty() { - db.tool_only_multipart_suggestion( + diag.tool_only_multipart_suggestion( message, replaces, Applicability::MachineApplicable, @@ -106,7 +102,7 @@ pub(super) fn builtin( } if let Some(span) = in_test_module { - db.span_help( + diag.span_help( sess.source_map().guess_head_span(span), "consider adding a `#[cfg(test)]` to the containing module", ); @@ -115,19 +111,19 @@ pub(super) fn builtin( BuiltinLintDiagnostics::RedundantImport(spans, ident) => { for (span, is_imported) in spans { let introduced = if is_imported { "imported" } else { "defined" }; - db.span_label(span, format!("the item `{ident}` is already {introduced} here")); + diag.span_label(span, format!("the item `{ident}` is already {introduced} here")); } } BuiltinLintDiagnostics::DeprecatedMacro(suggestion, span) => { - stability::deprecation_suggestion(db, "macro", suggestion, span) + stability::deprecation_suggestion(diag, "macro", suggestion, span) } BuiltinLintDiagnostics::UnusedDocComment(span) => { - db.span_label(span, "rustdoc does not generate documentation for macro invocations"); - db.help("to document an item produced by a macro, \ + diag.span_label(span, "rustdoc does not generate documentation for macro invocations"); + diag.help("to document an item produced by a macro, \ the macro must produce the documentation as part of its expansion"); } BuiltinLintDiagnostics::PatternsInFnsWithoutBody(span, ident) => { - db.span_suggestion( + diag.span_suggestion( span, "remove `mut` from the parameter", ident, @@ -135,17 +131,17 @@ pub(super) fn builtin( ); } BuiltinLintDiagnostics::MissingAbi(span, default_abi) => { - db.span_label(span, "ABI should be specified here"); - db.help(format!("the default ABI is {}", default_abi.name())); + diag.span_label(span, "ABI should be specified here"); + diag.help(format!("the default ABI is {}", default_abi.name())); } BuiltinLintDiagnostics::LegacyDeriveHelpers(span) => { - db.span_label(span, "the attribute is introduced here"); + diag.span_label(span, "the attribute is introduced here"); } BuiltinLintDiagnostics::ProcMacroBackCompat(note) => { - db.note(note); + diag.note(note); } BuiltinLintDiagnostics::OrPatternsBackCompat(span, suggestion) => { - db.span_suggestion( + diag.span_suggestion( span, "use pat_param to preserve semantics", suggestion, @@ -153,8 +149,8 @@ pub(super) fn builtin( ); } BuiltinLintDiagnostics::ReservedPrefix(span) => { - db.span_label(span, "unknown prefix"); - db.span_suggestion_verbose( + diag.span_label(span, "unknown prefix"); + diag.span_suggestion_verbose( span.shrink_to_hi(), "insert whitespace here to avoid this being parsed as a prefix in Rust 2021", " ", @@ -162,19 +158,19 @@ pub(super) fn builtin( ); } BuiltinLintDiagnostics::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => { - db.span_note( + diag.span_note( invoc_span, format!("the built-in attribute `{attr_name}` will be ignored, since it's applied to the macro invocation `{macro_name}`") ); } BuiltinLintDiagnostics::TrailingMacro(is_trailing, name) => { if is_trailing { - db.note("macro invocations at the end of a block are treated as expressions"); - db.note(format!("to ignore the value produced by the macro, add a semicolon after the invocation of `{name}`")); + diag.note("macro invocations at the end of a block are treated as expressions"); + diag.note(format!("to ignore the value produced by the macro, add a semicolon after the invocation of `{name}`")); } } BuiltinLintDiagnostics::BreakWithLabelAndLoop(span) => { - db.multipart_suggestion( + diag.multipart_suggestion( "wrap this expression in parentheses", vec![ (span.shrink_to_lo(), "(".to_string()), @@ -184,8 +180,8 @@ pub(super) fn builtin( ); } BuiltinLintDiagnostics::NamedAsmLabel(help) => { - db.help(help); - db.note("see the asm section of Rust By Example for more information"); + diag.help(help); + diag.note("see the asm section of Rust By Example for more information"); } BuiltinLintDiagnostics::UnexpectedCfgName((name, name_span), value) => { #[allow(rustc::potential_query_instability)] @@ -212,7 +208,7 @@ pub(super) fn builtin( let mut is_feature_cfg = name == sym::feature; if is_feature_cfg && is_from_cargo { - db.help("consider defining some features in `Cargo.toml`"); + diag.help("consider defining some features in `Cargo.toml`"); // Suggest the most probable if we found one } else if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) { if let Some(ExpectedValues::Some(best_match_values)) = @@ -227,7 +223,7 @@ pub(super) fn builtin( let mut should_print_possibilities = true; if let Some((value, value_span)) = value { if best_match_values.contains(&Some(value)) { - db.span_suggestion( + diag.span_suggestion( name_span, "there is a config with a similar name and value", best_match, @@ -235,7 +231,7 @@ pub(super) fn builtin( ); should_print_possibilities = false; } else if best_match_values.contains(&None) { - db.span_suggestion( + diag.span_suggestion( name_span.to(value_span), "there is a config with a similar name and no value", best_match, @@ -243,14 +239,14 @@ pub(super) fn builtin( ); should_print_possibilities = false; } else if let Some(first_value) = possibilities.first() { - db.span_suggestion( + diag.span_suggestion( name_span.to(value_span), "there is a config with a similar name and different values", format!("{best_match} = \"{first_value}\""), Applicability::MaybeIncorrect, ); } else { - db.span_suggestion( + diag.span_suggestion( name_span.to(value_span), "there is a config with a similar name and different values", best_match, @@ -258,7 +254,7 @@ pub(super) fn builtin( ); }; } else { - db.span_suggestion( + diag.span_suggestion( name_span, "there is a config with a similar name", best_match, @@ -268,12 +264,12 @@ pub(super) fn builtin( if !possibilities.is_empty() && should_print_possibilities { let possibilities = possibilities.join("`, `"); - db.help(format!( + diag.help(format!( "expected values for `{best_match}` are: `{possibilities}`" )); } } else { - db.span_suggestion( + diag.span_suggestion( name_span, "there is a config with a similar name", best_match, @@ -286,7 +282,7 @@ pub(super) fn builtin( if !names_possibilities.is_empty() && names_possibilities.len() <= 3 { names_possibilities.sort(); for cfg_name in names_possibilities.iter() { - db.span_suggestion( + diag.span_suggestion( name_span, "found config with similar value", format!("{cfg_name} = \"{name}\""), @@ -304,7 +300,7 @@ pub(super) fn builtin( // so the diagnostic produced can take a lot of space. To avoid // cloging the user output we only want to print that diagnostic // once. - db.help_once(format!("expected names are: `{possibilities}`")); + diag.help_once(format!("expected names are: `{possibilities}`")); } } @@ -317,12 +313,12 @@ pub(super) fn builtin( if is_from_cargo { if !is_feature_cfg { - db.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`")); + diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`")); } - db.note("see for more information about checking conditional configuration"); + diag.note("see for more information about checking conditional configuration"); } else { - db.help(format!("to expect this configuration use `--check-cfg={inst}`")); - db.note("see for more information about checking conditional configuration"); + diag.help(format!("to expect this configuration use `--check-cfg={inst}`")); + diag.note("see for more information about checking conditional configuration"); } } BuiltinLintDiagnostics::UnexpectedCfgValue((name, name_span), value) => { @@ -356,14 +352,14 @@ pub(super) fn builtin( let possibilities = possibilities.join("`, `"); let none = if have_none_possibility { "(none), " } else { "" }; - db.note(format!("expected values for `{name}` are: {none}`{possibilities}`")); + diag.note(format!("expected values for `{name}` are: {none}`{possibilities}`")); } if let Some((value, value_span)) = value { // Suggest the most probable if we found one if let Some(best_match) = find_best_match_for_name(&possibilities, value, None) { - db.span_suggestion( + diag.span_suggestion( value_span, "there is a expected value with a similar name", format!("\"{best_match}\""), @@ -371,7 +367,7 @@ pub(super) fn builtin( ); } } else if let &[first_possibility] = &possibilities[..] { - db.span_suggestion( + diag.span_suggestion( name_span.shrink_to_hi(), "specify a config value", format!(" = \"{first_possibility}\""), @@ -379,9 +375,9 @@ pub(super) fn builtin( ); } } else if have_none_possibility { - db.note(format!("no expected value for `{name}`")); + diag.note(format!("no expected value for `{name}`")); if let Some((_value, value_span)) = value { - db.span_suggestion( + diag.span_suggestion( name_span.shrink_to_hi().to(value_span), "remove the value", "", @@ -389,14 +385,14 @@ pub(super) fn builtin( ); } } else { - db.note(format!("no expected values for `{name}`")); + diag.note(format!("no expected values for `{name}`")); let sp = if let Some((_value, value_span)) = value { name_span.to(value_span) } else { name_span }; - db.span_suggestion(sp, "remove the condition", "", Applicability::MaybeIncorrect); + diag.span_suggestion(sp, "remove the condition", "", Applicability::MaybeIncorrect); } // We don't want to suggest adding values to well known names @@ -415,28 +411,30 @@ pub(super) fn builtin( if is_from_cargo { if name == sym::feature { if let Some((value, _value_span)) = value { - db.help(format!("consider adding `{value}` as a feature in `Cargo.toml`")); + diag.help(format!( + "consider adding `{value}` as a feature in `Cargo.toml`" + )); } else { - db.help("consider defining some features in `Cargo.toml`"); + diag.help("consider defining some features in `Cargo.toml`"); } } else if !is_cfg_a_well_know_name { - db.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`")); + diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`")); } - db.note("see for more information about checking conditional configuration"); + diag.note("see for more information about checking conditional configuration"); } else { if !is_cfg_a_well_know_name { - db.help(format!("to expect this configuration use `--check-cfg={inst}`")); + diag.help(format!("to expect this configuration use `--check-cfg={inst}`")); } - db.note("see for more information about checking conditional configuration"); + diag.note("see for more information about checking conditional configuration"); } } BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(new_span, suggestion) => { - db.multipart_suggestion( + diag.multipart_suggestion( "move it to the end of the type declaration", - vec![(db.span.primary_span().unwrap(), "".to_string()), (new_span, suggestion)], + vec![(diag.span.primary_span().unwrap(), "".to_string()), (new_span, suggestion)], Applicability::MachineApplicable, ); - db.note( + diag.note( "see issue #89122 for more information", ); } @@ -446,8 +444,8 @@ pub(super) fn builtin( deletion_span, } => { debug!(?param_span, ?use_span, ?deletion_span); - db.span_label(param_span, "this lifetime..."); - db.span_label(use_span, "...is used only here"); + diag.span_label(param_span, "this lifetime..."); + diag.span_label(use_span, "...is used only here"); if let Some(deletion_span) = deletion_span { let msg = "elide the single-use lifetime"; let (use_span, replace_lt) = if elide { @@ -468,7 +466,7 @@ pub(super) fn builtin( } else { vec![(deletion_span, String::new()), (use_span, replace_lt)] }; - db.multipart_suggestion(msg, suggestions, Applicability::MachineApplicable); + diag.multipart_suggestion(msg, suggestions, Applicability::MachineApplicable); } } BuiltinLintDiagnostics::SingleUseLifetime { @@ -478,7 +476,7 @@ pub(super) fn builtin( } => { debug!(?deletion_span); if let Some(deletion_span) = deletion_span { - db.span_suggestion( + diag.span_suggestion( deletion_span, "elide the unused lifetime", "", @@ -493,7 +491,7 @@ pub(super) fn builtin( named_arg_name, is_formatting_arg, } => { - db.span_label( + diag.span_label( named_arg_sp, "this named argument is referred to by position in formatting string", ); @@ -501,7 +499,7 @@ pub(super) fn builtin( let msg = format!( "this formatting argument uses named argument `{named_arg_name}` by position" ); - db.span_label(positional_arg_for_msg, msg); + diag.span_label(positional_arg_for_msg, msg); } if let Some(positional_arg_to_replace) = position_sp_to_replace { @@ -514,7 +512,7 @@ pub(super) fn builtin( } else { positional_arg_to_replace }; - db.span_suggestion_verbose( + diag.span_suggestion_verbose( span_to_replace, "use the named argument by name to avoid ambiguity", name, @@ -523,22 +521,22 @@ pub(super) fn builtin( } } BuiltinLintDiagnostics::ByteSliceInPackedStructWithDerive => { - db.help("consider implementing the trait by hand, or remove the `packed` attribute"); + diag.help("consider implementing the trait by hand, or remove the `packed` attribute"); } BuiltinLintDiagnostics::UnusedExternCrate { removal_span } => { - db.span_suggestion(removal_span, "remove it", "", Applicability::MachineApplicable); + diag.span_suggestion(removal_span, "remove it", "", Applicability::MachineApplicable); } BuiltinLintDiagnostics::ExternCrateNotIdiomatic { vis_span, ident_span } => { let suggestion_span = vis_span.between(ident_span); - db.span_suggestion_verbose( + diag.span_suggestion_verbose( suggestion_span, "convert it to a `use`", if vis_span.is_empty() { "use " } else { " use " }, Applicability::MachineApplicable, ); } - BuiltinLintDiagnostics::AmbiguousGlobImports { diag } => { - rustc_errors::report_ambiguity_error(db, diag); + BuiltinLintDiagnostics::AmbiguousGlobImports { diag: ambiguity } => { + rustc_errors::report_ambiguity_error(diag, ambiguity); } BuiltinLintDiagnostics::AmbiguousGlobReexports { name, @@ -546,11 +544,11 @@ pub(super) fn builtin( first_reexport_span, duplicate_reexport_span, } => { - db.span_label( + diag.span_label( first_reexport_span, format!("the name `{name}` in the {namespace} namespace is first re-exported here"), ); - db.span_label( + diag.span_label( duplicate_reexport_span, format!( "but the name `{name}` in the {namespace} namespace is also re-exported here" @@ -563,11 +561,11 @@ pub(super) fn builtin( glob_reexport_span, private_item_span, } => { - db.span_note(glob_reexport_span, format!("the name `{name}` in the {namespace} namespace is supposed to be publicly re-exported here")); - db.span_note(private_item_span, "but the private item here shadows it".to_owned()); + diag.span_note(glob_reexport_span, format!("the name `{name}` in the {namespace} namespace is supposed to be publicly re-exported here")); + diag.span_note(private_item_span, "but the private item here shadows it".to_owned()); } BuiltinLintDiagnostics::UnusedQualifications { removal_span } => { - db.span_suggestion_verbose( + diag.span_suggestion_verbose( removal_span, "remove the unnecessary path segments", "", @@ -575,7 +573,7 @@ pub(super) fn builtin( ); } BuiltinLintDiagnostics::AssociatedConstElidedLifetime { elided, span } => { - db.span_suggestion_verbose( + diag.span_suggestion_verbose( if elided { span.shrink_to_hi() } else { span }, "use the `'static` lifetime", if elided { "'static " } else { "'static" }, @@ -583,8 +581,10 @@ pub(super) fn builtin( ); } BuiltinLintDiagnostics::RedundantImportVisibility { max_vis, span } => { - db.span_note(span, format!("the most public imported item is `{max_vis}`")); - db.help("reduce the glob import's visibility or increase visibility of imported items"); + diag.span_note(span, format!("the most public imported item is `{max_vis}`")); + diag.help( + "reduce the glob import's visibility or increase visibility of imported items", + ); } } } diff --git a/compiler/rustc_lint/src/errors.rs b/compiler/rustc_lint/src/errors.rs index bcff20fc26043..3be792a9e4f27 100644 --- a/compiler/rustc_lint/src/errors.rs +++ b/compiler/rustc_lint/src/errors.rs @@ -1,7 +1,5 @@ use crate::fluent_generated as fluent; -use rustc_errors::{ - codes::*, AddToDiagnostic, DiagnosticBuilder, EmissionGuarantee, SubdiagnosticMessageOp, -}; +use rustc_errors::{codes::*, AddToDiagnostic, Diag, EmissionGuarantee, SubdiagnosticMessageOp}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_session::lint::Level; use rustc_span::{Span, Symbol}; @@ -28,7 +26,7 @@ pub enum OverruledAttributeSub { impl AddToDiagnostic for OverruledAttributeSub { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { match self { diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 596221a8455c5..a071fa488bc47 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -4,7 +4,6 @@ use crate::lints::{ BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag, TykindKind, UntranslatableDiag, - UntranslatableDiagnosticTrivial, }; use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc_ast as ast; @@ -361,15 +360,7 @@ declare_tool_lint! { report_in_external_macro: true } -declare_tool_lint! { - /// The `untranslatable_diagnostic_trivial` lint detects diagnostics created using only static strings. - pub rustc::UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL, - Deny, - "prevent creation of diagnostics which cannot be translated, which use only static strings", - report_in_external_macro: true -} - -declare_lint_pass!(Diagnostics => [ UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL, UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL ]); +declare_lint_pass!(Diagnostics => [UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL]); impl LateLintPass<'_> for Diagnostics { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { @@ -425,78 +416,6 @@ impl LateLintPass<'_> for Diagnostics { } } -impl EarlyLintPass for Diagnostics { - #[allow(unused_must_use)] - fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) { - // Looking for a straight chain of method calls from 'struct_span_err' to 'emit'. - let ast::StmtKind::Semi(expr) = &stmt.kind else { - return; - }; - let ast::ExprKind::MethodCall(meth) = &expr.kind else { - return; - }; - if meth.seg.ident.name != sym::emit || !meth.args.is_empty() { - return; - } - let mut segments = vec![]; - let mut cur = &meth.receiver; - let fake = &[].into(); - loop { - match &cur.kind { - ast::ExprKind::Call(func, args) => { - if let ast::ExprKind::Path(_, path) = &func.kind { - segments.push((path.segments.last().unwrap().ident.name, args)) - } - break; - } - ast::ExprKind::MethodCall(method) => { - segments.push((method.seg.ident.name, &method.args)); - cur = &method.receiver; - } - ast::ExprKind::MacCall(mac) => { - segments.push((mac.path.segments.last().unwrap().ident.name, fake)); - break; - } - _ => { - break; - } - } - } - segments.reverse(); - if segments.is_empty() { - return; - } - if segments[0].0.as_str() != "struct_span_err" { - return; - } - if !segments.iter().all(|(name, args)| { - let arg = match name.as_str() { - "struct_span_err" | "span_note" | "span_label" | "span_help" if args.len() == 2 => { - &args[1] - } - "note" | "help" if args.len() == 1 => &args[0], - _ => { - return false; - } - }; - if let ast::ExprKind::Lit(lit) = arg.kind - && let ast::token::LitKind::Str = lit.kind - { - true - } else { - false - } - }) { - return; - } - cx.emit_span_lint( - UNTRANSLATABLE_DIAGNOSTIC_TRIVIAL, - stmt.span, - UntranslatableDiagnosticTrivial, - ); - } -} - declare_tool_lint! { /// The `bad_opt_access` lint detects accessing options by field instead of /// the wrapper function. diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index c1a083bde8d4d..ad4a0fc47db4e 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -16,7 +16,7 @@ use crate::{ use rustc_ast as ast; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxIndexMap; -use rustc_errors::{DecorateLint, DiagnosticBuilder, DiagnosticMessage, MultiSpan}; +use rustc_errors::{DecorateLint, Diag, DiagnosticMessage, MultiSpan}; use rustc_feature::{Features, GateIssue}; use rustc_hir as hir; use rustc_hir::intravisit::{self, Visitor}; @@ -1107,7 +1107,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { lint: &'static Lint, span: Option, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { let (level, src) = self.lint_level(lint); lint_level(self.sess, lint, level, src, span, msg, decorate) diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index d8e12c04f7536..250c4adb948e2 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -31,6 +31,7 @@ #![feature(array_windows)] #![feature(box_patterns)] #![feature(control_flow_enum)] +#![feature(extract_if)] #![feature(generic_nonzero)] #![feature(if_let_guard)] #![feature(iter_order_by)] @@ -70,6 +71,7 @@ mod methods; mod multiple_supertrait_upcastable; mod non_ascii_idents; mod non_fmt_panic; +mod non_local_def; mod nonstandard_style; mod noop_method_call; mod opaque_hidden_inferred_bound; @@ -105,6 +107,7 @@ use methods::*; use multiple_supertrait_upcastable::*; use non_ascii_idents::*; use non_fmt_panic::NonPanicFmt; +use non_local_def::*; use nonstandard_style::*; use noop_method_call::*; use opaque_hidden_inferred_bound::*; @@ -229,6 +232,7 @@ late_lint_methods!( MissingDebugImplementations: MissingDebugImplementations, MissingDoc: MissingDoc, AsyncFnInTrait: AsyncFnInTrait, + NonLocalDefinitions: NonLocalDefinitions::default(), ] ] ); @@ -527,6 +531,11 @@ fn register_builtins(store: &mut LintStore) { "no longer needed, see #93367 \ for more information", ); + store.register_removed( + "const_patterns_without_partial_eq", + "converted into hard error, see RFC #3535 \ + for more information", + ); } fn register_internals(store: &mut LintStore) { @@ -541,7 +550,6 @@ fn register_internals(store: &mut LintStore) { store.register_lints(&TyTyKind::get_lints()); store.register_late_mod_pass(|_| Box::new(TyTyKind)); store.register_lints(&Diagnostics::get_lints()); - store.register_early_pass(|| Box::new(Diagnostics)); store.register_late_mod_pass(|_| Box::new(Diagnostics)); store.register_lints(&BadOptAccess::get_lints()); store.register_late_mod_pass(|_| Box::new(BadOptAccess)); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index f067c365170ae..a9a2592ac7abf 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -5,8 +5,8 @@ use std::num::NonZero; use crate::errors::RequestedLevel; use crate::fluent_generated as fluent; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DecorateLint, DiagnosticBuilder, DiagnosticMessage, - DiagnosticStyledString, EmissionGuarantee, SubdiagnosticMessageOp, SuggestionStyle, + codes::*, AddToDiagnostic, Applicability, DecorateLint, Diag, DiagStyledString, + DiagnosticMessage, EmissionGuarantee, SubdiagnosticMessageOp, SuggestionStyle, }; use rustc_hir::def_id::DefId; use rustc_macros::{LintDiagnostic, Subdiagnostic}; @@ -137,7 +137,7 @@ pub struct BuiltinMissingDebugImpl<'a> { // Needed for def_path_str impl<'a> DecorateLint<'a, ()> for BuiltinMissingDebugImpl<'_> { - fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) { diag.arg("debug", self.tcx.def_path_str(self.def_id)); } @@ -242,7 +242,7 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> { } impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.span_label(self.label, fluent::lint_label); rustc_session::parse::add_feature_diagnostics( diag, @@ -273,7 +273,7 @@ pub struct SuggestChangingAssocTypes<'a, 'b> { impl<'a, 'b> AddToDiagnostic for SuggestChangingAssocTypes<'a, 'b> { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { // Access to associates types should use `::Assoc`, which does not need a @@ -282,7 +282,7 @@ impl<'a, 'b> AddToDiagnostic for SuggestChangingAssocTypes<'a, 'b> { // We use a HIR visitor to walk the type. use rustc_hir::intravisit::{self, Visitor}; struct WalkAssocTypes<'a, 'b, G: EmissionGuarantee> { - err: &'a mut DiagnosticBuilder<'b, G>, + err: &'a mut Diag<'b, G>, } impl<'a, 'b, G: EmissionGuarantee> Visitor<'_> for WalkAssocTypes<'a, 'b, G> { fn visit_qpath( @@ -329,7 +329,7 @@ pub struct BuiltinTypeAliasGenericBoundsSuggestion { impl AddToDiagnostic for BuiltinTypeAliasGenericBoundsSuggestion { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { diag.multipart_suggestion( @@ -424,7 +424,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> { } impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("ty", self.ty); diag.span_label(self.label, fluent::lint_builtin_unpermitted_type_init_label); if let InhabitedPredicate::True = self.ty.inhabited_predicate(self.tcx) { @@ -450,7 +450,7 @@ pub struct BuiltinUnpermittedTypeInitSub { impl AddToDiagnostic for BuiltinUnpermittedTypeInitSub { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { let mut err = self.err; @@ -505,12 +505,12 @@ pub struct BuiltinClashingExternSub<'a> { impl AddToDiagnostic for BuiltinClashingExternSub<'_> { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { - let mut expected_str = DiagnosticStyledString::new(); + let mut expected_str = DiagStyledString::new(); expected_str.push(self.expected.fn_sig(self.tcx).to_string(), false); - let mut found_str = DiagnosticStyledString::new(); + let mut found_str = DiagStyledString::new(); found_str.push(self.found.fn_sig(self.tcx).to_string(), true); diag.note_expected_found(&"", expected_str, &"", found_str); } @@ -787,7 +787,7 @@ pub struct HiddenUnicodeCodepointsDiagLabels { impl AddToDiagnostic for HiddenUnicodeCodepointsDiagLabels { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { for (c, span) in self.spans { @@ -805,7 +805,7 @@ pub enum HiddenUnicodeCodepointsDiagSub { impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { match self { @@ -923,10 +923,6 @@ pub struct DiagOutOfImpl; #[diag(lint_untranslatable_diag)] pub struct UntranslatableDiag; -#[derive(LintDiagnostic)] -#[diag(lint_trivial_untranslatable_diag)] -pub struct UntranslatableDiagnosticTrivial; - #[derive(LintDiagnostic)] #[diag(lint_bad_opt_access)] pub struct BadOptAccessDiag<'a> { @@ -957,7 +953,7 @@ pub struct NonBindingLetSub { impl AddToDiagnostic for NonBindingLetSub { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { let can_suggest_binding = self.drop_fn_start_end.is_some() || !self.is_assign_desugar; @@ -1129,9 +1125,11 @@ pub struct IdentifierNonAsciiChar; #[derive(LintDiagnostic)] #[diag(lint_identifier_uncommon_codepoints)] +#[note] pub struct IdentifierUncommonCodepoints { pub codepoints: Vec, pub codepoints_len: usize, + pub identifier_type: &'static str, } #[derive(LintDiagnostic)] @@ -1162,7 +1160,7 @@ pub struct NonFmtPanicUnused { // Used because of two suggestions based on one Option impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("count", self.count); diag.note(fluent::lint_note); if let Some(span) = self.suggestion { @@ -1241,7 +1239,7 @@ pub enum NonSnakeCaseDiagSub { impl AddToDiagnostic for NonSnakeCaseDiagSub { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { match self { @@ -1314,6 +1312,12 @@ pub struct NoopMethodCallDiag<'a> { pub trait_: Symbol, #[suggestion(code = "", applicability = "machine-applicable")] pub label: Span, + #[suggestion( + lint_derive_suggestion, + code = "#[derive(Clone)]\n", + applicability = "maybe-incorrect" + )] + pub suggest_derive: Option, } #[derive(LintDiagnostic)] @@ -1328,6 +1332,45 @@ pub struct SuspiciousDoubleRefCloneDiag<'a> { pub ty: Ty<'a>, } +// non_local_defs.rs +#[derive(LintDiagnostic)] +pub enum NonLocalDefinitionsDiag { + #[diag(lint_non_local_definitions_impl)] + #[help] + #[note(lint_non_local)] + #[note(lint_exception)] + #[note(lint_non_local_definitions_deprecation)] + Impl { + depth: u32, + body_kind_descr: &'static str, + body_name: String, + #[subdiagnostic] + cargo_update: Option, + #[suggestion(lint_const_anon, code = "_", applicability = "machine-applicable")] + const_anon: Option, + }, + #[diag(lint_non_local_definitions_macro_rules)] + #[help] + #[note(lint_non_local)] + #[note(lint_exception)] + #[note(lint_non_local_definitions_deprecation)] + MacroRules { + depth: u32, + body_kind_descr: &'static str, + body_name: String, + #[subdiagnostic] + cargo_update: Option, + }, +} + +#[derive(Subdiagnostic)] +#[note(lint_non_local_definitions_cargo_update)] +pub struct NonLocalDefinitionsCargoUpdateNote { + pub macro_kind: &'static str, + pub macro_name: Symbol, + pub crate_name: Symbol, +} + // pass_by_value.rs #[derive(LintDiagnostic)] #[diag(lint_pass_by_value)] @@ -1355,7 +1398,7 @@ pub struct DropTraitConstraintsDiag<'a> { // Needed for def_path_str impl<'a> DecorateLint<'a, ()> for DropTraitConstraintsDiag<'_> { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("predicate", self.predicate); diag.arg("needs_drop", self.tcx.def_path_str(self.def_id)); } @@ -1372,7 +1415,7 @@ pub struct DropGlue<'a> { // Needed for def_path_str impl<'a> DecorateLint<'a, ()> for DropGlue<'_> { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("needs_drop", self.tcx.def_path_str(self.def_id)); } @@ -1438,7 +1481,7 @@ pub enum OverflowingBinHexSign { impl AddToDiagnostic for OverflowingBinHexSign { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { match self { @@ -1647,7 +1690,7 @@ pub struct ImproperCTypes<'a> { // Used because of the complexity of Option, DiagnosticMessage, and Option impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("ty", self.ty); diag.arg("desc", self.desc); diag.span_label(self.label, fluent::lint_label); @@ -1790,7 +1833,7 @@ pub enum UnusedDefSuggestion { // Needed because of def_path_str impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.arg("pre", self.pre); diag.arg("post", self.post); diag.arg("def", self.cx.tcx.def_path_str(self.def_id)); @@ -1873,7 +1916,7 @@ pub struct AsyncFnInTraitDiag { } impl<'a> DecorateLint<'a, ()> for AsyncFnInTraitDiag { - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.note(fluent::lint_note); if let Some(sugg) = self.sugg { diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect); diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs index e112cd6915c35..5e66ade035774 100644 --- a/compiler/rustc_lint/src/non_ascii_idents.rs +++ b/compiler/rustc_lint/src/non_ascii_idents.rs @@ -7,6 +7,7 @@ use rustc_ast as ast; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::unord::UnordMap; use rustc_span::symbol::Symbol; +use unicode_security::general_security_profile::IdentifierType; declare_lint! { /// The `non_ascii_idents` lint detects non-ASCII identifiers. @@ -189,17 +190,47 @@ impl EarlyLintPass for NonAsciiIdents { if check_uncommon_codepoints && !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed) { - let codepoints: Vec<_> = symbol_str + let mut chars: Vec<_> = symbol_str .chars() - .filter(|c| !GeneralSecurityProfile::identifier_allowed(*c)) + .map(|c| (c, GeneralSecurityProfile::identifier_type(c))) .collect(); - let codepoints_len = codepoints.len(); - cx.emit_span_lint( - UNCOMMON_CODEPOINTS, - sp, - IdentifierUncommonCodepoints { codepoints, codepoints_len }, - ); + for (id_ty, id_ty_descr) in [ + (IdentifierType::Exclusion, "Exclusion"), + (IdentifierType::Technical, "Technical"), + (IdentifierType::Limited_Use, "Limited_Use"), + (IdentifierType::Not_NFKC, "Not_NFKC"), + ] { + let codepoints: Vec<_> = + chars.extract_if(|(_, ty)| *ty == Some(id_ty)).collect(); + if codepoints.is_empty() { + continue; + } + cx.emit_span_lint( + UNCOMMON_CODEPOINTS, + sp, + IdentifierUncommonCodepoints { + codepoints_len: codepoints.len(), + codepoints: codepoints.into_iter().map(|(c, _)| c).collect(), + identifier_type: id_ty_descr, + }, + ); + } + + let remaining = chars + .extract_if(|(c, _)| !GeneralSecurityProfile::identifier_allowed(*c)) + .collect::>(); + if !remaining.is_empty() { + cx.emit_span_lint( + UNCOMMON_CODEPOINTS, + sp, + IdentifierUncommonCodepoints { + codepoints_len: remaining.len(), + codepoints: remaining.into_iter().map(|(c, _)| c).collect(), + identifier_type: "Restricted", + }, + ); + } } } diff --git a/compiler/rustc_lint/src/non_local_def.rs b/compiler/rustc_lint/src/non_local_def.rs new file mode 100644 index 0000000000000..6cb6fd1cbd550 --- /dev/null +++ b/compiler/rustc_lint/src/non_local_def.rs @@ -0,0 +1,222 @@ +use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, Path, QPath, TyKind}; +use rustc_span::def_id::{DefId, LOCAL_CRATE}; +use rustc_span::{sym, symbol::kw, ExpnKind, MacroKind}; + +use smallvec::{smallvec, SmallVec}; + +use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag}; +use crate::{LateContext, LateLintPass, LintContext}; + +declare_lint! { + /// The `non_local_definitions` lint checks for `impl` blocks and `#[macro_export]` + /// macro inside bodies (functions, enum discriminant, ...). + /// + /// ### Example + /// + /// ```rust + /// trait MyTrait {} + /// struct MyStruct; + /// + /// fn foo() { + /// impl MyTrait for MyStruct {} + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Creating non-local definitions go against expectation and can create discrepancies + /// in tooling. It should be avoided. It may become deny-by-default in edition 2024 + /// and higher, see see the tracking issue . + /// + /// An `impl` definition is non-local if it is nested inside an item and neither + /// the type nor the trait are at the same nesting level as the `impl` block. + /// + /// All nested bodies (functions, enum discriminant, array length, consts) (expect for + /// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked. + pub NON_LOCAL_DEFINITIONS, + Warn, + "checks for non-local definitions", + report_in_external_macro +} + +#[derive(Default)] +pub struct NonLocalDefinitions { + body_depth: u32, +} + +impl_lint_pass!(NonLocalDefinitions => [NON_LOCAL_DEFINITIONS]); + +// FIXME(Urgau): Figure out how to handle modules nested in bodies. +// It's currently not handled by the current logic because modules are not bodies. +// They don't even follow the correct order (check_body -> check_mod -> check_body_post) +// instead check_mod is called after every body has been handled. + +impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions { + fn check_body(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) { + self.body_depth += 1; + } + + fn check_body_post(&mut self, _cx: &LateContext<'tcx>, _body: &'tcx Body<'tcx>) { + self.body_depth -= 1; + } + + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) { + if self.body_depth == 0 { + return; + } + + let parent = cx.tcx.parent(item.owner_id.def_id.into()); + let parent_def_kind = cx.tcx.def_kind(parent); + let parent_opt_item_name = cx.tcx.opt_item_name(parent); + + // Per RFC we (currently) ignore anon-const (`const _: Ty = ...`) in top-level module. + if self.body_depth == 1 + && parent_def_kind == DefKind::Const + && parent_opt_item_name == Some(kw::Underscore) + { + return; + } + + let cargo_update = || { + let oexpn = item.span.ctxt().outer_expn_data(); + if let Some(def_id) = oexpn.macro_def_id + && let ExpnKind::Macro(macro_kind, macro_name) = oexpn.kind + && def_id.krate != LOCAL_CRATE + && std::env::var_os("CARGO").is_some() + { + Some(NonLocalDefinitionsCargoUpdateNote { + macro_kind: macro_kind.descr(), + macro_name, + crate_name: cx.tcx.crate_name(def_id.krate), + }) + } else { + None + } + }; + + match item.kind { + ItemKind::Impl(impl_) => { + // The RFC states: + // + // > An item nested inside an expression-containing item (through any + // > level of nesting) may not define an impl Trait for Type unless + // > either the **Trait** or the **Type** is also nested inside the + // > same expression-containing item. + // + // To achieve this we get try to get the paths of the _Trait_ and + // _Type_, and we look inside thoses paths to try a find in one + // of them a type whose parent is the same as the impl definition. + // + // If that's the case this means that this impl block declaration + // is using local items and so we don't lint on it. + + // We also ignore anon-const in item by including the anon-const + // parent as well; and since it's quite uncommon, we use smallvec + // to avoid unnecessary heap allocations. + let local_parents: SmallVec<[DefId; 1]> = if parent_def_kind == DefKind::Const + && parent_opt_item_name == Some(kw::Underscore) + { + smallvec![parent, cx.tcx.parent(parent)] + } else { + smallvec![parent] + }; + + let self_ty_has_local_parent = match impl_.self_ty.kind { + TyKind::Path(QPath::Resolved(_, ty_path)) => { + path_has_local_parent(ty_path, cx, &*local_parents) + } + TyKind::TraitObject([principle_poly_trait_ref, ..], _, _) => { + path_has_local_parent( + principle_poly_trait_ref.trait_ref.path, + cx, + &*local_parents, + ) + } + TyKind::TraitObject([], _, _) + | TyKind::InferDelegation(_, _) + | TyKind::Slice(_) + | TyKind::Array(_, _) + | TyKind::Ptr(_) + | TyKind::Ref(_, _) + | TyKind::BareFn(_) + | TyKind::Never + | TyKind::Tup(_) + | TyKind::Path(_) + | TyKind::AnonAdt(_) + | TyKind::OpaqueDef(_, _, _) + | TyKind::Typeof(_) + | TyKind::Infer + | TyKind::Err(_) => false, + }; + + let of_trait_has_local_parent = impl_ + .of_trait + .map(|of_trait| path_has_local_parent(of_trait.path, cx, &*local_parents)) + .unwrap_or(false); + + // If none of them have a local parent (LOGICAL NOR) this means that + // this impl definition is a non-local definition and so we lint on it. + if !(self_ty_has_local_parent || of_trait_has_local_parent) { + let const_anon = if self.body_depth == 1 + && parent_def_kind == DefKind::Const + && parent_opt_item_name != Some(kw::Underscore) + && let Some(parent) = parent.as_local() + && let Node::Item(item) = cx.tcx.hir_node_by_def_id(parent) + && let ItemKind::Const(ty, _, _) = item.kind + && let TyKind::Tup(&[]) = ty.kind + { + Some(item.ident.span) + } else { + None + }; + + cx.emit_span_lint( + NON_LOCAL_DEFINITIONS, + item.span, + NonLocalDefinitionsDiag::Impl { + depth: self.body_depth, + body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent), + body_name: parent_opt_item_name + .map(|s| s.to_ident_string()) + .unwrap_or_else(|| "".to_string()), + cargo_update: cargo_update(), + const_anon, + }, + ) + } + } + ItemKind::Macro(_macro, MacroKind::Bang) + if cx.tcx.has_attr(item.owner_id.def_id, sym::macro_export) => + { + cx.emit_span_lint( + NON_LOCAL_DEFINITIONS, + item.span, + NonLocalDefinitionsDiag::MacroRules { + depth: self.body_depth, + body_kind_descr: cx.tcx.def_kind_descr(parent_def_kind, parent), + body_name: parent_opt_item_name + .map(|s| s.to_ident_string()) + .unwrap_or_else(|| "".to_string()), + cargo_update: cargo_update(), + }, + ) + } + _ => {} + } + } +} + +/// Given a path and a parent impl def id, this checks if the if parent resolution +/// def id correspond to the def id of the parent impl definition. +/// +/// Given this path, we will look at the path (and ignore any generic args): +/// +/// ```text +/// std::convert::PartialEq> +/// ^^^^^^^^^^^^^^^^^^^^^^^ +/// ``` +fn path_has_local_parent(path: &Path<'_>, cx: &LateContext<'_>, local_parents: &[DefId]) -> bool { + path.res.opt_def_id().is_some_and(|did| local_parents.contains(&cx.tcx.parent(did))) +} diff --git a/compiler/rustc_lint/src/noop_method_call.rs b/compiler/rustc_lint/src/noop_method_call.rs index 26c5e4fb4837d..970d411fb0657 100644 --- a/compiler/rustc_lint/src/noop_method_call.rs +++ b/compiler/rustc_lint/src/noop_method_call.rs @@ -121,10 +121,20 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall { let orig_ty = expr_ty.peel_refs(); if receiver_ty == expr_ty { + let suggest_derive = match orig_ty.kind() { + ty::Adt(def, _) => Some(cx.tcx.def_span(def.did()).shrink_to_lo()), + _ => None, + }; cx.emit_span_lint( NOOP_METHOD_CALL, span, - NoopMethodCallDiag { method: call.ident.name, orig_ty, trait_, label: span }, + NoopMethodCallDiag { + method: call.ident.name, + orig_ty, + trait_, + label: span, + suggest_derive, + }, ); } else { match name { diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index e4ebae2a97320..2ea891ce04d01 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1587,10 +1587,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } fn is_internal_abi(&self, abi: SpecAbi) -> bool { - matches!( - abi, - SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic | SpecAbi::PlatformIntrinsic - ) + matches!(abi, SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic) } /// Find any fn-ptr types with external ABIs in `ty`. diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 35ee0c530463b..3481c66da702e 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -758,7 +758,7 @@ trait UnusedDelimLint { } impl<'ast> Visitor<'ast> for ErrExprVisitor { fn visit_expr(&mut self, expr: &'ast ast::Expr) { - if let ExprKind::Err = expr.kind { + if let ExprKind::Err(_) = expr.kind { self.has_error = true; return; } diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 84a050a242a69..1cddb45428c8b 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -32,7 +32,6 @@ declare_lint_pass! { CONFLICTING_REPR_HINTS, CONST_EVALUATABLE_UNCHECKED, CONST_ITEM_MUTATION, - CONST_PATTERNS_WITHOUT_PARTIAL_EQ, DEAD_CODE, DEPRECATED, DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, @@ -2342,57 +2341,6 @@ declare_lint! { }; } -declare_lint! { - /// The `const_patterns_without_partial_eq` lint detects constants that are used in patterns, - /// whose type does not implement `PartialEq`. - /// - /// ### Example - /// - /// ```rust,compile_fail - /// #![deny(const_patterns_without_partial_eq)] - /// - /// trait EnumSetType { - /// type Repr; - /// } - /// - /// enum Enum8 { } - /// impl EnumSetType for Enum8 { - /// type Repr = u8; - /// } - /// - /// #[derive(PartialEq, Eq)] - /// struct EnumSet { - /// __enumset_underlying: T::Repr, - /// } - /// - /// const CONST_SET: EnumSet = EnumSet { __enumset_underlying: 3 }; - /// - /// fn main() { - /// match CONST_SET { - /// CONST_SET => { /* ok */ } - /// _ => panic!("match fell through?"), - /// } - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// Previous versions of Rust accepted constants in patterns, even if those constants' types - /// did not have `PartialEq` implemented. The compiler falls back to comparing the value - /// field-by-field. In the future we'd like to ensure that pattern matching always - /// follows `PartialEq` semantics, so that trait bound will become a requirement for - /// matching on constants. - pub CONST_PATTERNS_WITHOUT_PARTIAL_EQ, - Warn, - "constant in pattern does not implement `PartialEq`", - @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, - reference: "issue #116122 ", - }; -} - declare_lint! { /// The `ambiguous_associated_items` lint detects ambiguity between /// [associated items] and [enum variants]. diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index d4e5c78c492c7..fc590001c0d50 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -69,7 +69,7 @@ pub enum Applicability { } /// Each lint expectation has a `LintExpectationId` assigned by the `LintLevelsBuilder`. -/// Expected `Diagnostic`s get the lint level `Expect` which stores the `LintExpectationId` +/// Expected diagnostics get the lint level `Expect` which stores the `LintExpectationId` /// to match it with the actual expectation later on. /// /// The `LintExpectationId` has to be stable between compilations, as diagnostic @@ -683,7 +683,7 @@ pub struct BufferedEarlyLint { /// `rustc_lint::early::EarlyContextAndPass::check_id`. pub lint_id: LintId, - /// Customization of the `DiagnosticBuilder<'_>` for the lint. + /// Customization of the `Diag<'_>` for the lint. pub diagnostic: BuiltinLintDiagnostics, } diff --git a/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp index 54fdc84c77d26..40723ff9f5ef2 100644 --- a/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp @@ -67,7 +67,7 @@ typedef RustArchiveIterator *LLVMRustArchiveIteratorRef; extern "C" LLVMRustArchiveRef LLVMRustOpenArchive(char *Path) { ErrorOr> BufOr = - MemoryBuffer::getFile(Path, -1, false); + MemoryBuffer::getFile(Path, /*IsText*/false, /*RequiresNullTerminator=*/false); if (!BufOr) { LLVMRustSetLastError(BufOr.getError().message().c_str()); return nullptr; diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index af2353fbb19c5..cb7cce4da0d5e 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -1262,7 +1262,7 @@ enum class LLVMRustDiagnosticLevel { extern "C" void LLVMRustUnpackInlineAsmDiagnostic(LLVMDiagnosticInfoRef DI, LLVMRustDiagnosticLevel *LevelOut, - unsigned *CookieOut, + uint64_t *CookieOut, LLVMTwineRef *MessageOut) { // Undefined to call this not on an inline assembly diagnostic! llvm::DiagnosticInfoInlineAsm *IA = diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic.rs b/compiler/rustc_macros/src/diagnostics/diagnostic.rs index 027c97330b117..5659569c6450c 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic.rs @@ -51,7 +51,7 @@ impl<'a> DiagnosticDerive<'a> { Some(slug) => { slugs.borrow_mut().push(slug.clone()); quote! { - let mut diag = rustc_errors::DiagnosticBuilder::new( + let mut diag = rustc_errors::Diag::new( dcx, level, crate::fluent_generated::#slug @@ -83,7 +83,7 @@ impl<'a> DiagnosticDerive<'a> { self, dcx: &'_sess rustc_errors::DiagCtxt, level: rustc_errors::Level - ) -> rustc_errors::DiagnosticBuilder<'_sess, G> { + ) -> rustc_errors::Diag<'_sess, G> { #implementation } } @@ -160,7 +160,7 @@ impl<'a> LintDiagnosticDerive<'a> { #[track_caller] fn decorate_lint<'__b>( self, - diag: &'__b mut rustc_errors::DiagnosticBuilder<'__a, ()> + diag: &'__b mut rustc_errors::Diag<'__a, ()> ) { #implementation; } diff --git a/compiler/rustc_macros/src/diagnostics/error.rs b/compiler/rustc_macros/src/diagnostics/error.rs index 84b18a6202814..13138ee4ab725 100644 --- a/compiler/rustc_macros/src/diagnostics/error.rs +++ b/compiler/rustc_macros/src/diagnostics/error.rs @@ -14,7 +14,7 @@ impl DiagnosticDeriveError { match self { DiagnosticDeriveError::SynError(e) => e.to_compile_error(), DiagnosticDeriveError::ErrorHandled => { - // Return ! to avoid having to create a blank DiagnosticBuilder to return when an + // Return ! to avoid having to create a blank Diag to return when an // error has already been emitted to the compiler. quote! { { unreachable!(); } diff --git a/compiler/rustc_macros/src/diagnostics/mod.rs b/compiler/rustc_macros/src/diagnostics/mod.rs index 33dffe6998a1e..044bbadf41c5a 100644 --- a/compiler/rustc_macros/src/diagnostics/mod.rs +++ b/compiler/rustc_macros/src/diagnostics/mod.rs @@ -55,7 +55,8 @@ use synstructure::Structure; /// /// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`: /// -pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream { +pub fn session_diagnostic_derive(mut s: Structure<'_>) -> TokenStream { + s.underscore_const(true); DiagnosticDerive::new(s).into_tokens() } @@ -101,7 +102,8 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// /// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`: /// -pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream { +pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream { + s.underscore_const(true); LintDiagnosticDerive::new(s).into_tokens() } @@ -151,6 +153,7 @@ pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream { /// /// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident }); /// ``` -pub fn session_subdiagnostic_derive(s: Structure<'_>) -> TokenStream { +pub fn session_subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream { + s.underscore_const(true); SubdiagnosticDeriveBuilder::new().into_tokens(s) } diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index 323614c222f2e..6cbebcc7320d1 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -89,7 +89,7 @@ impl SubdiagnosticDeriveBuilder { gen impl rustc_errors::AddToDiagnostic for @Self { fn add_to_diagnostic_with<__G, __F>( self, - #diag: &mut rustc_errors::DiagnosticBuilder<'_, __G>, + #diag: &mut rustc_errors::Diag<'_, __G>, #f: __F ) where __G: rustc_errors::EmissionGuarantee, @@ -108,7 +108,7 @@ impl SubdiagnosticDeriveBuilder { /// only to be able to destructure and split `self.builder` and the `self.structure` up to avoid a /// double mut borrow later on. struct SubdiagnosticDeriveVariantBuilder<'parent, 'a> { - /// The identifier to use for the generated `DiagnosticBuilder` instance. + /// The identifier to use for the generated `Diag` instance. parent: &'parent SubdiagnosticDeriveBuilder, /// Info for the current variant (or the type if not an enum). diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index a6396ba687d11..6b3210cad7be6 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -74,6 +74,8 @@ fn hash_stable_derive_with_mode( HashStableMode::Generic | HashStableMode::NoContext => parse_quote!(__CTX), }; + s.underscore_const(true); + // no_context impl is able to derive by-field, which is closer to a perfect derive. s.add_bounds(match mode { HashStableMode::Normal | HashStableMode::Generic => synstructure::AddBounds::Generics, diff --git a/compiler/rustc_macros/src/lift.rs b/compiler/rustc_macros/src/lift.rs index 3dedd88fb19b6..f7a84ba1510d0 100644 --- a/compiler/rustc_macros/src/lift.rs +++ b/compiler/rustc_macros/src/lift.rs @@ -4,6 +4,7 @@ use syn::parse_quote; pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream { s.add_bounds(synstructure::AddBounds::Generics); s.bind_with(|_| synstructure::BindStyle::Move); + s.underscore_const(true); let tcx: syn::Lifetime = parse_quote!('tcx); let newtcx: syn::GenericParam = parse_quote!('__lifted); diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 98b53945b9115..5fa11d22f0e75 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -15,6 +15,7 @@ pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_type_ir::codec::TyDecoder #bound }); s.add_bounds(synstructure::AddBounds::Fields); + s.underscore_const(true); decodable_body(s, decoder_ty) } @@ -26,6 +27,7 @@ pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: s.add_impl_generic(parse_quote! { '__a }); let decoder_ty = quote! { DecodeContext<'__a, 'tcx> }; s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); decodable_body(s, decoder_ty) } @@ -34,6 +36,7 @@ pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke let decoder_ty = quote! { __D }; s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_span::SpanDecoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); decodable_body(s, decoder_ty) } @@ -42,12 +45,13 @@ pub fn decodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macr let decoder_ty = quote! { __D }; s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_serialize::Decoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); decodable_body(s, decoder_ty) } fn decodable_body( - s: synstructure::Structure<'_>, + mut s: synstructure::Structure<'_>, decoder_ty: TokenStream, ) -> proc_macro2::TokenStream { if let syn::Data::Union(_) = s.ast().data { @@ -93,6 +97,7 @@ fn decodable_body( } } }; + s.underscore_const(true); s.bound_impl( quote!(::rustc_serialize::Decodable<#decoder_ty>), @@ -130,6 +135,7 @@ pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: let encoder_ty = quote! { __E }; s.add_impl_generic(parse_quote! {#encoder_ty: ::rustc_type_ir::codec::TyEncoder #bound }); s.add_bounds(synstructure::AddBounds::Fields); + s.underscore_const(true); encodable_body(s, encoder_ty, false) } @@ -141,6 +147,7 @@ pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: s.add_impl_generic(parse_quote! { '__a }); let encoder_ty = quote! { EncodeContext<'__a, 'tcx> }; s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); encodable_body(s, encoder_ty, true) } @@ -149,6 +156,7 @@ pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke let encoder_ty = quote! { __E }; s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_span::SpanEncoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); encodable_body(s, encoder_ty, false) } @@ -157,6 +165,7 @@ pub fn encodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macr let encoder_ty = quote! { __E }; s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder}); s.add_bounds(synstructure::AddBounds::Generics); + s.underscore_const(true); encodable_body(s, encoder_ty, false) } @@ -170,6 +179,7 @@ fn encodable_body( panic!("cannot derive on union") } + s.underscore_const(true); s.bind_with(|binding| { // Handle the lack of a blanket reference impl. if let syn::Type::Reference(_) = binding.ast().ty { diff --git a/compiler/rustc_macros/src/type_foldable.rs b/compiler/rustc_macros/src/type_foldable.rs index 5ee4d8793135c..5617c53b119ee 100644 --- a/compiler/rustc_macros/src/type_foldable.rs +++ b/compiler/rustc_macros/src/type_foldable.rs @@ -6,6 +6,8 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:: panic!("cannot derive on union") } + s.underscore_const(true); + if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") { s.add_impl_generic(parse_quote! { 'tcx }); } diff --git a/compiler/rustc_macros/src/type_visitable.rs b/compiler/rustc_macros/src/type_visitable.rs index dcd505a105e57..c8430380345b4 100644 --- a/compiler/rustc_macros/src/type_visitable.rs +++ b/compiler/rustc_macros/src/type_visitable.rs @@ -6,6 +6,8 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: panic!("cannot derive on union") } + s.underscore_const(true); + // ignore fields with #[type_visitable(ignore)] s.filter(|bi| { let mut ignored = false; diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 9a05d9ac0def1..b18ec85ca1177 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -3,9 +3,7 @@ use std::{ path::{Path, PathBuf}, }; -use rustc_errors::{ - codes::*, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level, -}; +use rustc_errors::{codes::*, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level}; use rustc_macros::Diagnostic; use rustc_session::config; use rustc_span::{sym, Span, Symbol}; @@ -498,8 +496,8 @@ pub(crate) struct MultipleCandidates { } impl IntoDiagnostic<'_, G> for MultipleCandidates { - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::metadata_multiple_candidates); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::metadata_multiple_candidates); diag.arg("crate_name", self.crate_name); diag.arg("flavor", self.flavor); diag.code(E0464); @@ -597,8 +595,8 @@ pub struct InvalidMetadataFiles { impl IntoDiagnostic<'_, G> for InvalidMetadataFiles { #[track_caller] - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::metadata_invalid_meta_files); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::metadata_invalid_meta_files); diag.arg("crate_name", self.crate_name); diag.arg("add_info", self.add_info); diag.code(E0786); @@ -626,8 +624,8 @@ pub struct CannotFindCrate { impl IntoDiagnostic<'_, G> for CannotFindCrate { #[track_caller] - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::metadata_cannot_find_crate); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::metadata_cannot_find_crate); diag.arg("crate_name", self.crate_name); diag.arg("current_crate", self.current_crate); diag.arg("add_info", self.add_info); diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index 15f56db6278b1..90e68a6b5b916 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -220,7 +220,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::memmap::Mmap; use rustc_data_structures::owned_slice::slice_owned; use rustc_data_structures::svh::Svh; -use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; +use rustc_errors::{DiagArgValue, IntoDiagnosticArg}; use rustc_fs_util::try_canonicalize; use rustc_session::config; use rustc_session::cstore::CrateSource; @@ -291,11 +291,11 @@ impl fmt::Display for CrateFlavor { } impl IntoDiagnosticArg for CrateFlavor { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { match self { - CrateFlavor::Rlib => DiagnosticArgValue::Str(Cow::Borrowed("rlib")), - CrateFlavor::Rmeta => DiagnosticArgValue::Str(Cow::Borrowed("rmeta")), - CrateFlavor::Dylib => DiagnosticArgValue::Str(Cow::Borrowed("dylib")), + CrateFlavor::Rlib => DiagArgValue::Str(Cow::Borrowed("rlib")), + CrateFlavor::Rmeta => DiagArgValue::Str(Cow::Borrowed("rmeta")), + CrateFlavor::Dylib => DiagArgValue::Str(Cow::Borrowed("dylib")), } } } diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 5e20a03bbc0cd..cdcc586b09e70 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -99,7 +99,7 @@ impl<'tcx> Collector<'tcx> { let sess = self.tcx.sess; - if matches!(abi, Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic) { + if matches!(abi, Abi::Rust | Abi::RustIntrinsic) { return; } diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 82e56c9cbe205..5a24a7ab0bd55 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -17,6 +17,7 @@ rustc-rayon-core = { version = "0.5.0", optional = true } rustc_apfloat = "0.2.0" rustc_arena = { path = "../rustc_arena" } rustc_ast = { path = "../rustc_ast" } +rustc_ast_ir = { path = "../rustc_ast_ir" } rustc_attr = { path = "../rustc_attr" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs index 3ebbcd650302f..0f6ec656932ce 100644 --- a/compiler/rustc_middle/src/error.rs +++ b/compiler/rustc_middle/src/error.rs @@ -1,6 +1,6 @@ use std::fmt; -use rustc_errors::{codes::*, DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage}; +use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagnosticMessage}; use rustc_macros::Diagnostic; use rustc_span::{Span, Symbol}; @@ -94,14 +94,14 @@ pub(super) struct ConstNotUsedTraitAlias { pub struct CustomSubdiagnostic<'a> { pub msg: fn() -> DiagnosticMessage, - pub add_args: Box, + pub add_args: Box, } impl<'a> CustomSubdiagnostic<'a> { pub fn label(x: fn() -> DiagnosticMessage) -> Self { Self::label_and_then(x, |_| {}) } - pub fn label_and_then( + pub fn label_and_then( msg: fn() -> DiagnosticMessage, f: F, ) -> Self { diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 9c0846e9fb199..c3e4a03ad1677 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -24,6 +24,8 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] +#![cfg_attr(bootstrap, feature(exhaustive_patterns))] +#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))] #![feature(rustdoc_internals)] #![feature(allocator_api)] #![feature(array_windows)] @@ -32,7 +34,6 @@ #![feature(core_intrinsics)] #![feature(const_type_name)] #![feature(discriminant_kind)] -#![feature(exhaustive_patterns)] #![feature(coroutines)] #![feature(generic_nonzero)] #![feature(if_let_guard)] diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 1e9e9947db53f..6a3522553c451 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -2,7 +2,7 @@ use std::cmp; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sorted_map::SortedMap; -use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, MultiSpan}; +use rustc_errors::{Diag, DiagnosticMessage, MultiSpan}; use rustc_hir::{HirId, ItemLocalId}; use rustc_session::lint::{ builtin::{self, FORBIDDEN_LINT_GROUPS}, @@ -204,7 +204,7 @@ pub fn explain_lint_level_source( lint: &'static Lint, level: Level, src: LintLevelSource, - err: &mut DiagnosticBuilder<'_, ()>, + err: &mut Diag<'_, ()>, ) { let name = lint.name_lower(); if let Level::Allow = level { @@ -260,8 +260,7 @@ pub fn explain_lint_level_source( /// /// ## `decorate` /// -/// It is not intended to call `emit`/`cancel` on the `DiagnosticBuilder` passed -/// in the `decorate` callback. +/// It is not intended to call `emit`/`cancel` on the `Diag` passed in the `decorate` callback. #[track_caller] pub fn lint_level( sess: &Session, @@ -270,7 +269,7 @@ pub fn lint_level( src: LintLevelSource, span: Option, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { // Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to // the "real" work. @@ -282,7 +281,7 @@ pub fn lint_level( src: LintLevelSource, span: Option, msg: impl Into, - decorate: Box FnOnce(&'b mut DiagnosticBuilder<'a, ()>)>, + decorate: Box FnOnce(&'b mut Diag<'a, ()>)>, ) { // Check for future incompatibility lints and issue a stronger warning. let future_incompatible = lint.future_incompatible; @@ -314,7 +313,7 @@ pub fn lint_level( // // We can also not mark the lint expectation as fulfilled here right away, as it // can still be cancelled in the decorate function. All of this means that we simply - // create a `DiagnosticBuilder` and continue as we would for warnings. + // create a `Diag` and continue as we would for warnings. rustc_errors::Level::Expect(expect_id) } Level::ForceWarn(Some(expect_id)) => rustc_errors::Level::ForceWarning(Some(expect_id)), @@ -322,7 +321,7 @@ pub fn lint_level( Level::Warn => rustc_errors::Level::Warning, Level::Deny | Level::Forbid => rustc_errors::Level::Error, }; - let mut err = DiagnosticBuilder::new(sess.dcx(), err_level, ""); + let mut err = Diag::new(sess.dcx(), err_level, ""); if let Some(span) = span { err.span(span); } diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 5f3ecf3441624..31f986403ab9d 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -9,7 +9,7 @@ use rustc_attr::{ self as attr, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability, }; use rustc_data_structures::unord::UnordMap; -use rustc_errors::{Applicability, DiagnosticBuilder}; +use rustc_errors::{Applicability, Diag}; use rustc_feature::GateIssue; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap}; @@ -125,7 +125,7 @@ pub fn report_unstable( } pub fn deprecation_suggestion( - diag: &mut DiagnosticBuilder<'_, ()>, + diag: &mut Diag<'_, ()>, kind: &str, suggestion: Option, span: Span, diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 125fac48df877..f344dd5a8c362 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -4,15 +4,15 @@ use crate::error; use crate::mir::{ConstAlloc, ConstValue}; use crate::ty::{layout, tls, Ty, TyCtxt, ValTree}; +use rustc_ast_ir::Mutability; use rustc_data_structures::sync::Lock; use rustc_errors::{ - DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, + DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, }; use rustc_macros::HashStable; use rustc_session::CtfeBacktrace; use rustc_span::{def_id::DefId, Span, DUMMY_SP}; use rustc_target::abi::{call, Align, Size, VariantIdx, WrappingRange}; -use rustc_type_ir::Mutability; use std::borrow::Cow; use std::{any::Any, backtrace::Backtrace, fmt}; @@ -237,8 +237,8 @@ pub enum InvalidMetaKind { } impl IntoDiagnosticArg for InvalidMetaKind { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Borrowed(match self { + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(match self { InvalidMetaKind::SliceTooBig => "slice_too_big", InvalidMetaKind::TooBig => "too_big", })) @@ -271,8 +271,8 @@ pub struct Misalignment { macro_rules! impl_into_diagnostic_arg_through_debug { ($($ty:ty),*$(,)?) => {$( impl IntoDiagnosticArg for $ty { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Owned(format!("{self:?}"))) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Owned(format!("{self:?}"))) } } )*} @@ -373,8 +373,8 @@ pub enum PointerKind { } impl IntoDiagnosticArg for PointerKind { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str( + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str( match self { Self::Ref(_) => "ref", Self::Box => "box", @@ -493,7 +493,7 @@ pub trait MachineStopType: Any + fmt::Debug + Send { fn diagnostic_message(&self) -> DiagnosticMessage; /// Add diagnostic arguments by passing name and value pairs to `adder`, which are passed to /// fluent for formatting the translated diagnostic message. - fn add_args(self: Box, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)); + fn add_args(self: Box, adder: &mut dyn FnMut(DiagArgName, DiagArgValue)); } impl dyn MachineStopType { diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 3017f912ef027..5ce2e26a0bce3 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -15,7 +15,7 @@ use crate::ty::{GenericArg, GenericArgsRef}; use rustc_data_structures::captures::Captures; use rustc_errors::{ - DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, + DiagArgName, DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, }; use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index 91b7952bec5e8..4c7df0a7ae219 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -292,7 +292,7 @@ impl AssertKind { } } - pub fn add_args(self, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) + pub fn add_args(self, adder: &mut dyn FnMut(DiagArgName, DiagArgValue)) where O: fmt::Debug, { diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index f4dfbe059ebcd..9c7c46f2ad24b 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -233,7 +233,7 @@ impl<'sess> OnDiskCache<'sess> { for (index, file) in files.iter().enumerate() { let index = SourceFileIndex(index as u32); - let file_ptr: *const SourceFile = &**file as *const _; + let file_ptr: *const SourceFile = std::ptr::addr_of!(**file); file_to_file_index.insert(file_ptr, index); let source_file_id = EncodedSourceFileId::new(tcx, file); file_index_to_stable_id.insert(index, source_file_id); @@ -835,7 +835,7 @@ pub struct CacheEncoder<'a, 'tcx> { impl<'a, 'tcx> CacheEncoder<'a, 'tcx> { #[inline] fn source_file_index(&mut self, source_file: Lrc) -> SourceFileIndex { - self.file_to_file_index[&(&*source_file as *const SourceFile)] + self.file_to_file_index[&std::ptr::addr_of!(*source_file)] } /// Encode something with additional information that allows to do some diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index e1e5d68148fe8..2ad592174f1ea 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -9,7 +9,7 @@ //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; -use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; +use rustc_errors::{DiagArgValue, IntoDiagnosticArg}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::RangeEnd; @@ -674,7 +674,7 @@ impl<'tcx> Pat<'tcx> { } impl<'tcx> IntoDiagnosticArg for Pat<'tcx> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { format!("{self}").into_diagnostic_arg() } } diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index b3c09d1d15234..a6e4702d81950 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -16,7 +16,7 @@ use crate::ty::GenericArgsRef; use crate::ty::{self, AdtKind, Ty}; use rustc_data_structures::sync::Lrc; -use rustc_errors::{Applicability, DiagnosticBuilder, EmissionGuarantee}; +use rustc_errors::{Applicability, Diag, EmissionGuarantee}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID}; @@ -908,7 +908,7 @@ pub enum ObjectSafetyViolationSolution { } impl ObjectSafetyViolationSolution { - pub fn add_to(self, err: &mut DiagnosticBuilder<'_, G>) { + pub fn add_to(self, err: &mut Diag<'_, G>) { match self { ObjectSafetyViolationSolution::None => {} ObjectSafetyViolationSolution::AddSelfOrMakeSized { diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs index e3050007c7b3c..8e9751f45294c 100644 --- a/compiler/rustc_middle/src/traits/select.rs +++ b/compiler/rustc_middle/src/traits/select.rs @@ -139,7 +139,7 @@ pub enum SelectionCandidate<'tcx> { /// generated for an `async ||` expression. AsyncClosureCandidate, - /// Implementation of the the `AsyncFnKindHelper` helper trait, which + /// Implementation of the `AsyncFnKindHelper` helper trait, which /// is used internally to delay computation for async closures until after /// upvar analysis is performed in HIR typeck. AsyncFnKindHelperCandidate, diff --git a/compiler/rustc_middle/src/traits/solve/inspect.rs b/compiler/rustc_middle/src/traits/solve/inspect.rs index e94ad4aa539b6..90180af3b167f 100644 --- a/compiler/rustc_middle/src/traits/solve/inspect.rs +++ b/compiler/rustc_middle/src/traits/solve/inspect.rs @@ -58,8 +58,6 @@ pub struct GoalEvaluation<'tcx> { pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>, pub kind: GoalEvaluationKind<'tcx>, pub evaluation: CanonicalGoalEvaluation<'tcx>, - /// The nested goals from instantiating the query response. - pub returned_goals: Vec>>, } #[derive(Eq, PartialEq)] diff --git a/compiler/rustc_middle/src/traits/solve/inspect/format.rs b/compiler/rustc_middle/src/traits/solve/inspect/format.rs index 54db8dbd33606..89c5eb517e565 100644 --- a/compiler/rustc_middle/src/traits/solve/inspect/format.rs +++ b/compiler/rustc_middle/src/traits/solve/inspect/format.rs @@ -48,20 +48,7 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> { }, }; writeln!(self.f, "{}: {:?}", goal_text, eval.uncanonicalized_goal)?; - self.nested(|this| this.format_canonical_goal_evaluation(&eval.evaluation))?; - if eval.returned_goals.len() > 0 { - writeln!(self.f, "NESTED GOALS ADDED TO CALLER: [")?; - self.nested(|this| { - for goal in eval.returned_goals.iter() { - writeln!(this.f, "ADDED GOAL: {goal:?},")?; - } - Ok(()) - })?; - - writeln!(self.f, "]") - } else { - Ok(()) - } + self.nested(|this| this.format_canonical_goal_evaluation(&eval.evaluation)) } pub(super) fn format_canonical_goal_evaluation( diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index d07a53ee6794d..2e1c7df6454aa 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -7,6 +7,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; use rustc_data_structures::stable_hasher::HashingControls; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def_id::DefId; @@ -475,7 +476,11 @@ impl<'tcx> AdtDef<'tcx> { } #[inline] - pub fn eval_explicit_discr(self, tcx: TyCtxt<'tcx>, expr_did: DefId) -> Option> { + pub fn eval_explicit_discr( + self, + tcx: TyCtxt<'tcx>, + expr_did: DefId, + ) -> Result, ErrorGuaranteed> { assert!(self.is_enum()); let param_env = tcx.param_env(expr_did); let repr_type = self.repr().discr_type(); @@ -484,22 +489,24 @@ impl<'tcx> AdtDef<'tcx> { let ty = repr_type.to_ty(tcx); if let Some(b) = val.try_to_bits_for_ty(tcx, param_env, ty) { trace!("discriminants: {} ({:?})", b, repr_type); - Some(Discr { val: b, ty }) + Ok(Discr { val: b, ty }) } else { info!("invalid enum discriminant: {:#?}", val); - tcx.dcx().emit_err(crate::error::ConstEvalNonIntError { + let guar = tcx.dcx().emit_err(crate::error::ConstEvalNonIntError { span: tcx.def_span(expr_did), }); - None + Err(guar) } } Err(err) => { - let msg = match err { - ErrorHandled::Reported(..) => "enum discriminant evaluation failed", - ErrorHandled::TooGeneric(..) => "enum discriminant depends on generics", + let guar = match err { + ErrorHandled::Reported(info, _) => info.into(), + ErrorHandled::TooGeneric(..) => tcx.dcx().span_delayed_bug( + tcx.def_span(expr_did), + "enum discriminant depends on generics", + ), }; - tcx.dcx().span_delayed_bug(tcx.def_span(expr_did), msg); - None + Err(guar) } } } @@ -516,7 +523,7 @@ impl<'tcx> AdtDef<'tcx> { self.variants().iter_enumerated().map(move |(i, v)| { let mut discr = prev_discr.map_or(initial, |d| d.wrap_incr(tcx)); if let VariantDiscr::Explicit(expr_did) = v.discr { - if let Some(new_discr) = self.eval_explicit_discr(tcx, expr_did) { + if let Ok(new_discr) = self.eval_explicit_discr(tcx, expr_did) { discr = new_discr; } } @@ -544,9 +551,13 @@ impl<'tcx> AdtDef<'tcx> { ) -> Discr<'tcx> { assert!(self.is_enum()); let (val, offset) = self.discriminant_def_for_variant(variant_index); - let explicit_value = val - .and_then(|expr_did| self.eval_explicit_discr(tcx, expr_did)) - .unwrap_or_else(|| self.repr().discr_type().initial_discriminant(tcx)); + let explicit_value = if let Some(expr_did) = val + && let Ok(val) = self.eval_explicit_discr(tcx, expr_did) + { + val + } else { + self.repr().discr_type().initial_discriminant(tcx) + }; explicit_value.checked_add(tcx, offset as u128).0 } diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 5d50510338c61..221a9ceee1ab6 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -1,6 +1,6 @@ use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; -use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; +use rustc_errors::{DiagArgValue, IntoDiagnosticArg}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_target::abi::Size; use std::fmt; @@ -117,8 +117,8 @@ impl std::fmt::Debug for ConstInt { impl IntoDiagnosticArg for ConstInt { // FIXME this simply uses the Debug impl, but we could probably do better by converting both // to an inherent method that returns `Cow`. - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(format!("{self:?}").into()) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(format!("{self:?}").into()) } } diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index 603d7f46aabe0..b35682df2c8f3 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -15,7 +15,7 @@ pub struct UnevaluatedConst<'tcx> { } impl rustc_errors::IntoDiagnosticArg for UnevaluatedConst<'_> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { format!("{self:?}").into_diagnostic_arg() } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9d59f779470f6..c6359dae1abc8 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -43,9 +43,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, WorkerLocal}; #[cfg(parallel_compiler)] use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_data_structures::unord::UnordSet; -use rustc_errors::{ - DecorateLint, DiagCtxt, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, MultiSpan, -}; +use rustc_errors::{DecorateLint, Diag, DiagCtxt, DiagnosticMessage, ErrorGuaranteed, MultiSpan}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; @@ -2117,7 +2115,7 @@ impl<'tcx> TyCtxt<'tcx> { hir_id: HirId, span: impl Into, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { let (level, src) = self.lint_level_at_node(lint, hir_id); lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate); @@ -2147,7 +2145,7 @@ impl<'tcx> TyCtxt<'tcx> { lint: &'static Lint, id: HirId, msg: impl Into, - decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { let (level, src) = self.lint_level_at_node(lint, id); lint_level(self.sess, lint, level, src, None, msg, decorate); diff --git a/compiler/rustc_middle/src/ty/context/tls.rs b/compiler/rustc_middle/src/ty/context/tls.rs index 9de77b9fda11a..788ccd5dbbdc7 100644 --- a/compiler/rustc_middle/src/ty/context/tls.rs +++ b/compiler/rustc_middle/src/ty/context/tls.rs @@ -3,7 +3,7 @@ use super::{GlobalCtxt, TyCtxt}; use crate::dep_graph::TaskDepsRef; use crate::query::plumbing::QueryJobId; use rustc_data_structures::sync::{self, Lock}; -use rustc_errors::Diagnostic; +use rustc_errors::DiagInner; #[cfg(not(parallel_compiler))] use std::cell::Cell; use std::mem; @@ -26,7 +26,7 @@ pub struct ImplicitCtxt<'a, 'tcx> { /// Where to store diagnostics for the current query job, if any. /// This is updated by `JobOwner::start` in `ty::query::plumbing` when executing a query. - pub diagnostics: Option<&'a Lock>>, + pub diagnostics: Option<&'a Lock>>, /// Used to prevent queries from calling too deeply. pub query_depth: usize, diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index f379cf27a5f74..712fbf2444053 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -11,7 +11,7 @@ use crate::ty::{ }; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::{Applicability, DiagnosticArgValue, DiagnosticBuilder, IntoDiagnosticArg}; +use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagnosticArg}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; @@ -20,7 +20,7 @@ use rustc_span::{BytePos, Span}; use rustc_type_ir::TyKind::*; impl<'tcx> IntoDiagnosticArg for Ty<'tcx> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } @@ -111,7 +111,7 @@ where pub fn suggest_arbitrary_trait_bound<'tcx>( tcx: TyCtxt<'tcx>, generics: &hir::Generics<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: PolyTraitPredicate<'tcx>, associated_ty: Option<(&'static str, Ty<'tcx>)>, ) -> bool { @@ -216,7 +216,7 @@ fn suggest_changing_unsized_bound( pub fn suggest_constraining_type_param( tcx: TyCtxt<'_>, generics: &hir::Generics<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, param_name: &str, constraint: &str, def_id: Option, @@ -235,7 +235,7 @@ pub fn suggest_constraining_type_param( pub fn suggest_constraining_type_params<'a>( tcx: TyCtxt<'_>, generics: &hir::Generics<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, param_names_and_constraints: impl Iterator)>, span_to_replace: Option, ) -> bool { diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 813a7a64daf00..c87ef870a084e 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -7,7 +7,7 @@ use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor}; use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt}; use rustc_data_structures::intern::Interned; -use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; +use rustc_errors::{DiagArgValue, IntoDiagnosticArg}; use rustc_hir::def_id::DefId; use rustc_macros::HashStable; use rustc_serialize::{Decodable, Encodable}; @@ -56,7 +56,7 @@ unsafe impl<'tcx> Sync for GenericArg<'tcx> where } impl<'tcx> IntoDiagnosticArg for GenericArg<'tcx> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index c1e33fe114fb5..62d5a8fa4dfb8 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -5,8 +5,7 @@ use crate::ty::normalize_erasing_regions::NormalizationError; use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_error_messages::DiagnosticMessage; use rustc_errors::{ - DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, - IntoDiagnosticArg, Level, + Diag, DiagArgValue, DiagCtxt, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level, }; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -253,7 +252,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> { } impl<'tcx> IntoDiagnosticArg for LayoutError<'tcx> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } @@ -1244,7 +1243,6 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option, abi: SpecAbi) -> | RiscvInterruptS | CCmseNonSecureCall | Wasm - | PlatformIntrinsic | Unadjusted => false, Rust | RustCall | RustCold | RustIntrinsic => { tcx.sess.panic_strategy() == PanicStrategy::Unwind @@ -1263,7 +1261,7 @@ pub enum FnAbiError<'tcx> { } impl<'a, 'b, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FnAbiError<'b> { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { match self { Self::Layout(e) => e.into_diagnostic().into_diagnostic(dcx, level), Self::AdjustForForeignAbi(call::AdjustForForeignAbiError::Unsupported { diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 4f9c9d85763a2..336c2dce1141c 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -61,7 +61,7 @@ impl List { // length) that is 64-byte aligned, thus featuring the necessary // trailing padding for elements with up to 64-byte alignment. static EMPTY_SLICE: InOrder = InOrder(0, MaxAlign); - unsafe { &*(&EMPTY_SLICE as *const _ as *const List) } + unsafe { &*(std::ptr::addr_of!(EMPTY_SLICE) as *const List) } } pub fn len(&self) -> usize { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 30409e990e13c..d97f0e4c32196 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -32,6 +32,7 @@ pub use generic_args::*; pub use generics::*; use rustc_ast as ast; use rustc_ast::node_id::NodeMap; +pub use rustc_ast_ir::{Movability, Mutability}; use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::intern::Interned; @@ -39,7 +40,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::tagged_ptr::CopyTaggedPtr; use rustc_data_structures::unord::UnordMap; -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, StashKey}; +use rustc_errors::{Diag, ErrorGuaranteed, StashKey}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap, LocalDefIdSet}; @@ -845,7 +846,7 @@ impl<'tcx> OpaqueHiddenType<'tcx> { other: &Self, opaque_def_id: LocalDefId, tcx: TyCtxt<'tcx>, - ) -> Result, ErrorGuaranteed> { + ) -> Result, ErrorGuaranteed> { if let Some(diag) = tcx .sess .dcx() diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index b63f9c6dfa01a..8dd95daed36a7 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -1,6 +1,6 @@ use rustc_data_structures::captures::Captures; use rustc_data_structures::intern::Interned; -use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; +use rustc_errors::{DiagArgValue, IntoDiagnosticArg}; use rustc_hir::def_id::DefId; use rustc_hir::LangItem; use rustc_span::Span; @@ -121,14 +121,14 @@ impl<'tcx> Predicate<'tcx> { } impl rustc_errors::IntoDiagnosticArg for Predicate<'_> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { - rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string())) + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { + rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string())) } } impl rustc_errors::IntoDiagnosticArg for Clause<'_> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { - rustc_errors::DiagnosticArgValue::Str(std::borrow::Cow::Owned(self.to_string())) + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { + rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(self.to_string())) } } @@ -408,7 +408,7 @@ impl<'tcx> PolyTraitRef<'tcx> { } impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } @@ -454,7 +454,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> { } impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 19f8ba124f143..520fc1dd7aa4d 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -139,7 +139,7 @@ pub trait Printer<'tcx>: Sized { _, hir::CoroutineSource::Closure, )) = self.tcx().coroutine_kind(def_id) - && args.len() >= parent_args.len() + 1 + && args.len() > parent_args.len() { return self.path_generic_args( |cx| cx.print_def_path(def_id, parent_args), diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 1910841f2684e..bbe06c0935231 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -715,13 +715,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { p!(print_def_path(def_id, &[])); } ty::Alias(ty::Projection | ty::Inherent | ty::Weak, ref data) => { - if !(self.should_print_verbose() || with_no_queries()) - && self.tcx().is_impl_trait_in_trait(data.def_id) - { - return self.pretty_print_opaque_impl_type(data.def_id, data.args); - } else { - p!(print(data)) - } + p!(print(data)) } ty::Placeholder(placeholder) => match placeholder.bound.kind { ty::BoundTyKind::Anon => p!(write("{placeholder:?}")), @@ -2725,7 +2719,7 @@ where pub struct TraitRefPrintOnlyTraitPath<'tcx>(ty::TraitRef<'tcx>); impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintOnlyTraitPath<'tcx> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { self.to_string().into_diagnostic_arg() } } @@ -2742,7 +2736,7 @@ impl<'tcx> fmt::Debug for TraitRefPrintOnlyTraitPath<'tcx> { pub struct TraitRefPrintSugared<'tcx>(ty::TraitRef<'tcx>); impl<'tcx> rustc_errors::IntoDiagnosticArg for TraitRefPrintSugared<'tcx> { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { self.to_string().into_diagnostic_arg() } } @@ -3053,7 +3047,17 @@ define_print_and_forward_display! { if let DefKind::Impl { of_trait: false } = cx.tcx().def_kind(cx.tcx().parent(self.def_id)) { p!(pretty_print_inherent_projection(self)) } else { - p!(print_def_path(self.def_id, self.args)); + // If we're printing verbosely, or don't want to invoke queries + // (`is_impl_trait_in_trait`), then fall back to printing the def path. + // This is likely what you want if you're debugging the compiler anyways. + if !(cx.should_print_verbose() || with_no_queries()) + && cx.tcx().is_impl_trait_in_trait(self.def_id) + { + return cx.pretty_print_opaque_impl_type(self.def_id, self.args); + } else { + p!(print_def_path(self.def_id, self.args)); + } + } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index a581712526752..27c78d18d1922 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -14,7 +14,7 @@ use crate::ty::{List, ParamEnv}; use hir::def::DefKind; use rustc_data_structures::captures::Captures; use rustc_errors::{ - DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan, + DiagArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg, MultiSpan, }; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -1100,7 +1100,7 @@ impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T> where T: IntoDiagnosticArg, { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.value.into_diagnostic_arg() } } @@ -1310,7 +1310,7 @@ impl<'tcx> FnSig<'tcx> { } impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 72a1905c147ae..5ead620927cd9 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1643,7 +1643,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool { /// Determines whether an item is an intrinsic by Abi. or by whether it has a `rustc_intrinsic` attribute pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { - if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic) + if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic) || tcx.has_attr(def_id, sym::rustc_intrinsic) { Some(tcx.item_name(def_id.into())) diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index f9a8795f5d6ef..641a278c1d3da 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -1150,39 +1150,61 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// the value, we will set and generate a branch to the appropriate /// pre-binding block. /// - /// If we find that *NONE* of the candidates apply, we branch to the - /// `otherwise_block`, setting it to `Some` if required. In principle, this - /// means that the input list was not exhaustive, though at present we - /// sometimes are not smart enough to recognize all exhaustive inputs. + /// If we find that *NONE* of the candidates apply, we branch to `otherwise_block`. /// /// It might be surprising that the input can be non-exhaustive. /// Indeed, initially, it is not, because all matches are /// exhaustive in Rust. But during processing we sometimes divide /// up the list of candidates and recurse with a non-exhaustive - /// list. This is important to keep the size of the generated code - /// under control. See [`Builder::test_candidates`] for more details. + /// list. This is how our lowering approach (called "backtracking + /// automaton" in the literature) works. + /// See [`Builder::test_candidates`] for more details. /// /// If `fake_borrows` is `Some`, then places which need fake borrows /// will be added to it. /// - /// For an example of a case where we set `otherwise_block`, even for an - /// exhaustive match, consider: - /// + /// For an example of how we use `otherwise_block`, consider: /// ``` - /// # fn foo(x: (bool, bool)) { - /// match x { - /// (true, true) => (), - /// (_, false) => (), - /// (false, true) => (), + /// # fn foo((x, y): (bool, bool)) -> u32 { + /// match (x, y) { + /// (true, true) => 1, + /// (_, false) => 2, + /// (false, true) => 3, /// } /// # } /// ``` + /// For this match, we generate something like: + /// ``` + /// # fn foo((x, y): (bool, bool)) -> u32 { + /// if x { + /// if y { + /// return 1 + /// } else { + /// // continue + /// } + /// } else { + /// // continue + /// } + /// if y { + /// if x { + /// // This is actually unreachable because the `(true, true)` case was handled above. + /// // continue + /// } else { + /// return 3 + /// } + /// } else { + /// return 2 + /// } + /// // this is the final `otherwise_block`, which is unreachable because the match was exhaustive. + /// unreachable!() + /// # } + /// ``` + /// + /// Every `continue` is an instance of branching to some `otherwise_block` somewhere deep within + /// the algorithm. For more details on why we lower like this, see [`Builder::test_candidates`]. /// - /// For this match, we check if `x.0` matches `true` (for the first - /// arm). If it doesn't match, we check `x.1`. If `x.1` is `true` we check - /// if `x.0` matches `false` (for the third arm). In the (impossible at - /// runtime) case when `x.0` is now `true`, we branch to - /// `otherwise_block`. + /// Note how we test `x` twice. This is the tradeoff of backtracking automata: we prefer smaller + /// code size at the expense of non-optimal code paths. #[instrument(skip(self, fake_borrows), level = "debug")] fn match_candidates<'pat>( &mut self, @@ -1557,18 +1579,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - /// This is the most subtle part of the matching algorithm. At - /// this point, the input candidates have been fully simplified, - /// and so we know that all remaining match-pairs require some - /// sort of test. To decide what test to perform, we take the highest - /// priority candidate (the first one in the list, as of January 2021) - /// and extract the first match-pair from the list. From this we decide - /// what kind of test is needed using [`Builder::test`], defined in the - /// [`test` module](mod@test). + /// Pick a test to run. Which test doesn't matter as long as it is guaranteed to fully match at + /// least one match pair. We currently simply pick the test corresponding to the first match + /// pair of the first candidate in the list. /// - /// *Note:* taking the first match pair is somewhat arbitrary, and - /// we might do better here by choosing more carefully what to - /// test. + /// *Note:* taking the first match pair is somewhat arbitrary, and we might do better here by + /// choosing more carefully what to test. /// /// For example, consider the following possible match-pairs: /// @@ -1580,121 +1596,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// [`Switch`]: TestKind::Switch /// [`SwitchInt`]: TestKind::SwitchInt /// [`Range`]: TestKind::Range - /// - /// Once we know what sort of test we are going to perform, this - /// test may also help us winnow down our candidates. So we walk over - /// the candidates (from high to low priority) and check. This - /// gives us, for each outcome of the test, a transformed list of - /// candidates. For example, if we are testing `x.0`'s variant, - /// and we have a candidate `(x.0 @ Some(v), x.1 @ 22)`, - /// then we would have a resulting candidate of `((x.0 as Some).0 @ v, x.1 @ 22)`. - /// Note that the first match-pair is now simpler (and, in fact, irrefutable). - /// - /// But there may also be candidates that the test just doesn't - /// apply to. The classical example involves wildcards: - /// - /// ``` - /// # let (x, y, z) = (true, true, true); - /// match (x, y, z) { - /// (true , _ , true ) => true, // (0) - /// (_ , true , _ ) => true, // (1) - /// (false, false, _ ) => false, // (2) - /// (true , _ , false) => false, // (3) - /// } - /// # ; - /// ``` - /// - /// In that case, after we test on `x`, there are 2 overlapping candidate - /// sets: - /// - /// - If the outcome is that `x` is true, candidates 0, 1, and 3 - /// - If the outcome is that `x` is false, candidates 1 and 2 - /// - /// Here, the traditional "decision tree" method would generate 2 - /// separate code-paths for the 2 separate cases. - /// - /// In some cases, this duplication can create an exponential amount of - /// code. This is most easily seen by noticing that this method terminates - /// with precisely the reachable arms being reachable - but that problem - /// is trivially NP-complete: - /// - /// ```ignore (illustrative) - /// match (var0, var1, var2, var3, ...) { - /// (true , _ , _ , false, true, ...) => false, - /// (_ , true, true , false, _ , ...) => false, - /// (false, _ , false, false, _ , ...) => false, - /// ... - /// _ => true - /// } - /// ``` - /// - /// Here the last arm is reachable only if there is an assignment to - /// the variables that does not match any of the literals. Therefore, - /// compilation would take an exponential amount of time in some cases. - /// - /// That kind of exponential worst-case might not occur in practice, but - /// our simplistic treatment of constants and guards would make it occur - /// in very common situations - for example [#29740]: - /// - /// ```ignore (illustrative) - /// match x { - /// "foo" if foo_guard => ..., - /// "bar" if bar_guard => ..., - /// "baz" if baz_guard => ..., - /// ... - /// } - /// ``` - /// - /// [#29740]: https://github.com/rust-lang/rust/issues/29740 - /// - /// Here we first test the match-pair `x @ "foo"`, which is an [`Eq` test]. - /// - /// [`Eq` test]: TestKind::Eq - /// - /// It might seem that we would end up with 2 disjoint candidate - /// sets, consisting of the first candidate or the other two, but our - /// algorithm doesn't reason about `"foo"` being distinct from the other - /// constants; it considers the latter arms to potentially match after - /// both outcomes, which obviously leads to an exponential number - /// of tests. - /// - /// To avoid these kinds of problems, our algorithm tries to ensure - /// the amount of generated tests is linear. When we do a k-way test, - /// we return an additional "unmatched" set alongside the obvious `k` - /// sets. When we encounter a candidate that would be present in more - /// than one of the sets, we put it and all candidates below it into the - /// "unmatched" set. This ensures these `k+1` sets are disjoint. - /// - /// After we perform our test, we branch into the appropriate candidate - /// set and recurse with `match_candidates`. These sub-matches are - /// obviously non-exhaustive - as we discarded our otherwise set - so - /// we set their continuation to do `match_candidates` on the - /// "unmatched" set (which is again non-exhaustive). - /// - /// If you apply this to the above test, you basically wind up - /// with an if-else-if chain, testing each candidate in turn, - /// which is precisely what we want. - /// - /// In addition to avoiding exponential-time blowups, this algorithm - /// also has the nice property that each guard and arm is only generated - /// once. - fn test_candidates<'pat, 'b, 'c>( + fn pick_test( &mut self, - span: Span, - scrutinee_span: Span, - mut candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>], - start_block: BasicBlock, - otherwise_block: BasicBlock, + candidates: &mut [&mut Candidate<'_, 'tcx>], fake_borrows: &mut Option>>, - ) { - // extract the match-pair from the highest priority candidate + ) -> (PlaceBuilder<'tcx>, Test<'tcx>) { + // Extract the match-pair from the highest priority candidate let match_pair = &candidates.first().unwrap().match_pairs[0]; let mut test = self.test(match_pair); let match_place = match_pair.place.clone(); - // most of the time, the test to perform is simply a function - // of the main candidate; but for a test like SwitchInt, we - // may want to add cases based on the candidates that are + debug!(?test, ?match_pair); + // Most of the time, the test to perform is simply a function of the main candidate; but for + // a test like SwitchInt, we may want to add cases based on the candidates that are // available match test.kind { TestKind::SwitchInt { switch_ty: _, ref mut options } => { @@ -1721,20 +1635,58 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fb.insert(resolved_place); } - // perform the test, branching to one of N blocks. For each of - // those N possible outcomes, create a (initially empty) - // vector of candidates. Those are the candidates that still - // apply if the test has that particular outcome. - debug!("test_candidates: test={:?} match_pair={:?}", test, match_pair); + (match_place, test) + } + + /// Given a test, we sort the input candidates into several buckets. If a candidate only matches + /// in one of the branches of `test`, we move it there. If it could match in more than one of + /// the branches of `test`, we stop sorting candidates. + /// + /// This returns a pair of + /// - the candidates that weren't sorted; + /// - for each possible outcome of the test, the candidates that match in that outcome. + /// + /// Moreover, we transform the branched candidates to reflect the fact that we know which + /// outcome of `test` occurred. + /// + /// For example: + /// ``` + /// # let (x, y, z) = (true, true, true); + /// match (x, y, z) { + /// (true , _ , true ) => true, // (0) + /// (false, false, _ ) => false, // (1) + /// (_ , true , _ ) => true, // (2) + /// (true , _ , false) => false, // (3) + /// } + /// # ; + /// ``` + /// + /// Assume we are testing on `x`. There are 2 overlapping candidate sets: + /// - If the outcome is that `x` is true, candidates 0, 2, and 3 + /// - If the outcome is that `x` is false, candidates 1 and 2 + /// + /// Following our algorithm, candidate 0 is sorted into outcome `x == true`, candidate 1 goes + /// into outcome `x == false`, and candidate 2 and 3 remain unsorted. + /// + /// The sorted candidates are transformed: + /// - candidate 0 becomes `[z @ true]` since we know that `x` was `true`; + /// - candidate 1 becomes `[y @ false]` since we know that `x` was `false`. + fn sort_candidates<'b, 'c, 'pat>( + &mut self, + match_place: &PlaceBuilder<'tcx>, + test: &Test<'tcx>, + mut candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>], + ) -> (&'b mut [&'c mut Candidate<'pat, 'tcx>], Vec>>) { + // For each of the N possible outcomes, create a (initially empty) vector of candidates. + // Those are the candidates that apply if the test has that particular outcome. let mut target_candidates: Vec>> = vec![]; target_candidates.resize_with(test.targets(), Default::default); let total_candidate_count = candidates.len(); - // Sort the candidates into the appropriate vector in - // `target_candidates`. Note that at some point we may - // encounter a candidate where the test is not relevant; at - // that point, we stop sorting. + // Sort the candidates into the appropriate vector in `target_candidates`. Note that at some + // point we may encounter a candidate where the test is not relevant; at that point, we stop + // sorting. while let Some(candidate) = candidates.first_mut() { let Some(idx) = self.sort_candidate(&match_place, &test, candidate) else { break; @@ -1743,7 +1695,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { target_candidates[idx].push(candidate); candidates = rest; } - // at least the first candidate ought to be tested + + // At least the first candidate ought to be tested assert!( total_candidate_count > candidates.len(), "{total_candidate_count}, {candidates:#?}" @@ -1751,16 +1704,130 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug!("tested_candidates: {}", total_candidate_count - candidates.len()); debug!("untested_candidates: {}", candidates.len()); + (candidates, target_candidates) + } + + /// This is the most subtle part of the match lowering algorithm. At this point, the input + /// candidates have been fully simplified, so all remaining match-pairs require some sort of + /// test. + /// + /// Once we pick what sort of test we are going to perform, this test will help us winnow down + /// our candidates. So we walk over the candidates (from high to low priority) and check. We + /// compute, for each outcome of the test, a transformed list of candidates. If a candidate + /// matches in a single branch of our test, we add it to the corresponding outcome. We also + /// transform it to record the fact that we know which outcome occurred. + /// + /// For example, if we are testing `x.0`'s variant, and we have a candidate `(x.0 @ Some(v), x.1 + /// @ 22)`, then we would have a resulting candidate of `((x.0 as Some).0 @ v, x.1 @ 22)` in the + /// branch corresponding to `Some`. To ensure we make progress, we always pick a test that + /// results in simplifying the first candidate. + /// + /// But there may also be candidates that the test doesn't + /// apply to. The classical example is wildcards: + /// + /// ``` + /// # let (x, y, z) = (true, true, true); + /// match (x, y, z) { + /// (true , _ , true ) => true, // (0) + /// (false, false, _ ) => false, // (1) + /// (_ , true , _ ) => true, // (2) + /// (true , _ , false) => false, // (3) + /// } + /// # ; + /// ``` + /// + /// Here, the traditional "decision tree" method would generate 2 separate code-paths for the 2 + /// possible values of `x`. This would however duplicate some candidates, which would need to be + /// lowered several times. + /// + /// In some cases, this duplication can create an exponential amount of + /// code. This is most easily seen by noticing that this method terminates + /// with precisely the reachable arms being reachable - but that problem + /// is trivially NP-complete: + /// + /// ```ignore (illustrative) + /// match (var0, var1, var2, var3, ...) { + /// (true , _ , _ , false, true, ...) => false, + /// (_ , true, true , false, _ , ...) => false, + /// (false, _ , false, false, _ , ...) => false, + /// ... + /// _ => true + /// } + /// ``` + /// + /// Here the last arm is reachable only if there is an assignment to + /// the variables that does not match any of the literals. Therefore, + /// compilation would take an exponential amount of time in some cases. + /// + /// In rustc, we opt instead for the "backtracking automaton" approach. This guarantees we never + /// duplicate a candidate (except in the presence of or-patterns). In fact this guarantee is + /// ensured by the fact that we carry around `&mut Candidate`s which can't be duplicated. + /// + /// To make this work, whenever we decide to perform a test, if we encounter a candidate that + /// could match in more than one branch of the test, we stop. We generate code for the test and + /// for the candidates in its branches; the remaining candidates will be tested if the + /// candidates in the branches fail to match. + /// + /// For example, if we test on `x` in the following: + /// ``` + /// # fn foo((x, y, z): (bool, bool, bool)) -> u32 { + /// match (x, y, z) { + /// (true , _ , true ) => 0, + /// (false, false, _ ) => 1, + /// (_ , true , _ ) => 2, + /// (true , _ , false) => 3, + /// } + /// # } + /// ``` + /// this function generates code that looks more of less like: + /// ``` + /// # fn foo((x, y, z): (bool, bool, bool)) -> u32 { + /// if x { + /// match (y, z) { + /// (_, true) => return 0, + /// _ => {} // continue matching + /// } + /// } else { + /// match (y, z) { + /// (false, _) => return 1, + /// _ => {} // continue matching + /// } + /// } + /// // the block here is `remainder_start` + /// match (x, y, z) { + /// (_ , true , _ ) => 2, + /// (true , _ , false) => 3, + /// _ => unreachable!(), + /// } + /// # } + /// ``` + fn test_candidates<'pat, 'b, 'c>( + &mut self, + span: Span, + scrutinee_span: Span, + candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>], + start_block: BasicBlock, + otherwise_block: BasicBlock, + fake_borrows: &mut Option>>, + ) { + // Extract the match-pair from the highest priority candidate and build a test from it. + let (match_place, test) = self.pick_test(candidates, fake_borrows); + + // For each of the N possible test outcomes, build the vector of candidates that applies if + // the test has that particular outcome. + let (remaining_candidates, target_candidates) = + self.sort_candidates(&match_place, &test, candidates); + // The block that we should branch to if none of the // `target_candidates` match. - let remainder_start = if !candidates.is_empty() { + let remainder_start = if !remaining_candidates.is_empty() { let remainder_start = self.cfg.start_new_block(); self.match_candidates( span, scrutinee_span, remainder_start, otherwise_block, - candidates, + remaining_candidates, fake_borrows, ); remainder_start diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 241b6c6cb2cad..1ce8da162bfa5 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -4,7 +4,7 @@ use crate::build::ExprCategory; use crate::errors::*; use rustc_middle::thir::visit::Visitor; -use rustc_errors::DiagnosticArgValue; +use rustc_errors::DiagArgValue; use rustc_hir as hir; use rustc_middle::mir::BorrowKind; use rustc_middle::thir::*; @@ -703,12 +703,12 @@ impl UnsafeOpKind { UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe { span, function: with_no_trimmed_paths!(tcx.def_path_str(*function)), - missing_target_features: DiagnosticArgValue::StrListSepByAnd( + missing_target_features: DiagArgValue::StrListSepByAnd( missing.iter().map(|feature| Cow::from(feature.to_string())).collect(), ), missing_target_features_count: missing.len(), note: if build_enabled.is_empty() { None } else { Some(()) }, - build_target_features: DiagnosticArgValue::StrListSepByAnd( + build_target_features: DiagArgValue::StrListSepByAnd( build_enabled .iter() .map(|feature| Cow::from(feature.to_string())) @@ -868,12 +868,12 @@ impl UnsafeOpKind { { dcx.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span, - missing_target_features: DiagnosticArgValue::StrListSepByAnd( + missing_target_features: DiagArgValue::StrListSepByAnd( missing.iter().map(|feature| Cow::from(feature.to_string())).collect(), ), missing_target_features_count: missing.len(), note: if build_enabled.is_empty() { None } else { Some(()) }, - build_target_features: DiagnosticArgValue::StrListSepByAnd( + build_target_features: DiagArgValue::StrListSepByAnd( build_enabled .iter() .map(|feature| Cow::from(feature.to_string())) @@ -887,12 +887,12 @@ impl UnsafeOpKind { CallToFunctionWith { function, missing, build_enabled } => { dcx.emit_err(CallToFunctionWithRequiresUnsafe { span, - missing_target_features: DiagnosticArgValue::StrListSepByAnd( + missing_target_features: DiagArgValue::StrListSepByAnd( missing.iter().map(|feature| Cow::from(feature.to_string())).collect(), ), missing_target_features_count: missing.len(), note: if build_enabled.is_empty() { None } else { Some(()) }, - build_target_features: DiagnosticArgValue::StrListSepByAnd( + build_target_features: DiagArgValue::StrListSepByAnd( build_enabled .iter() .map(|feature| Cow::from(feature.to_string())) diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 48b93ce0ac5cb..d889f89f281f3 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -1,8 +1,8 @@ use crate::fluent_generated as fluent; -use rustc_errors::DiagnosticArgValue; +use rustc_errors::DiagArgValue; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, - IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, + Level, MultiSpan, SubdiagnosticMessageOp, }; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::{self, Ty}; @@ -127,11 +127,11 @@ pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe { #[label] pub span: Span, pub function: String, - pub missing_target_features: DiagnosticArgValue, + pub missing_target_features: DiagArgValue, pub missing_target_features_count: usize, #[note] pub note: Option<()>, - pub build_target_features: DiagnosticArgValue, + pub build_target_features: DiagArgValue, pub build_target_features_count: usize, #[subdiagnostic] pub unsafe_not_inherited_note: Option, @@ -379,11 +379,11 @@ pub struct CallToFunctionWithRequiresUnsafe { #[label] pub span: Span, pub function: String, - pub missing_target_features: DiagnosticArgValue, + pub missing_target_features: DiagArgValue, pub missing_target_features_count: usize, #[note] pub note: Option<()>, - pub build_target_features: DiagnosticArgValue, + pub build_target_features: DiagArgValue, pub build_target_features_count: usize, #[subdiagnostic] pub unsafe_not_inherited_note: Option, @@ -397,11 +397,11 @@ pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed { #[label] pub span: Span, pub function: String, - pub missing_target_features: DiagnosticArgValue, + pub missing_target_features: DiagArgValue, pub missing_target_features_count: usize, #[note] pub note: Option<()>, - pub build_target_features: DiagnosticArgValue, + pub build_target_features: DiagArgValue, pub build_target_features_count: usize, #[subdiagnostic] pub unsafe_not_inherited_note: Option, @@ -422,7 +422,7 @@ pub struct UnsafeNotInheritedLintNote { impl AddToDiagnostic for UnsafeNotInheritedLintNote { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { diag.span_note(self.signature_span, fluent::mir_build_unsafe_fn_safe_body); @@ -464,12 +464,9 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> { impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new( - dcx, - level, - fluent::mir_build_non_exhaustive_patterns_type_not_empty, - ); + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = + Diag::new(dcx, level, fluent::mir_build_non_exhaustive_patterns_type_not_empty); diag.span(self.span); diag.code(E0004); let peeled_ty = self.ty.peel_refs(); @@ -767,6 +764,14 @@ pub struct TypeNotStructural<'tcx> { pub non_sm_ty: Ty<'tcx>, } +#[derive(Diagnostic)] +#[diag(mir_build_non_partial_eq_match)] +pub struct TypeNotPartialEq<'tcx> { + #[primary_span] + pub span: Span, + pub non_peq_ty: Ty<'tcx>, +} + #[derive(Diagnostic)] #[diag(mir_build_invalid_pattern)] pub struct InvalidPattern<'tcx> { @@ -822,12 +827,6 @@ pub struct NontrivialStructuralMatch<'tcx> { pub non_sm_ty: Ty<'tcx>, } -#[derive(LintDiagnostic)] -#[diag(mir_build_non_partial_eq_match)] -pub struct NonPartialEqMatch<'tcx> { - pub non_peq_ty: Ty<'tcx>, -} - #[derive(Diagnostic)] #[diag(mir_build_pattern_not_covered, code = E0005)] pub(crate) struct PatternNotCovered<'s, 'tcx> { @@ -871,7 +870,7 @@ pub struct Variant { impl<'tcx> AddToDiagnostic for AdtDefinedHere<'tcx> { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { diag.arg("ty", self.ty); 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 a0235f20a0570..cf12b4fb912cd 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -11,7 +11,7 @@ use rustc_ast::Mutability; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::{ - codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, + codes::*, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, }; use rustc_hir as hir; use rustc_hir::def::*; @@ -64,7 +64,7 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err visitor.error } -fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBuilder<'_> { +fn create_e0004(sess: &Session, sp: Span, error_message: String) -> Diag<'_> { struct_span_code_err!(sess.dcx(), sp, E0004, "{}", &error_message) } diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index c77c80d9f4b29..09727f9b71bef 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -16,7 +16,7 @@ use std::cell::Cell; use super::PatCtxt; use crate::errors::{ - IndirectStructuralMatch, InvalidPattern, NaNPattern, NonPartialEqMatch, PointerPattern, + IndirectStructuralMatch, InvalidPattern, NaNPattern, PointerPattern, TypeNotPartialEq, TypeNotStructural, UnionPattern, UnsizedPattern, }; @@ -208,15 +208,12 @@ impl<'tcx> ConstToPat<'tcx> { ); } - // Always check for `PartialEq`, even if we emitted other lints. (But not if there were - // any errors.) This ensures it shows up in cargo's future-compat reports as well. + // Always check for `PartialEq` if we had no other errors yet. if !self.type_has_partial_eq_impl(cv.ty()) { - self.tcx().emit_node_span_lint( - lint::builtin::CONST_PATTERNS_WITHOUT_PARTIAL_EQ, - self.id, - self.span, - NonPartialEqMatch { non_peq_ty: cv.ty() }, - ); + let err = TypeNotPartialEq { span: self.span, non_peq_ty: cv.ty() }; + let e = self.tcx().dcx().emit_err(err); + let kind = PatKind::Error(e); + return Box::new(Pat { span: self.span, ty: cv.ty(), kind }); } } diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 0329e1d3096dc..0b03cb52373a4 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -223,19 +223,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // If we are handling a range with associated constants (e.g. // `Foo::<'a>::A..=Foo::B`), we need to put the ascriptions for the associated // constants somewhere. Have them on the range pattern. - for ascr in [lo_ascr, hi_ascr] { - if let Some(ascription) = ascr { - kind = PatKind::AscribeUserType { - ascription, - subpattern: Box::new(Pat { span, ty, kind }), - }; - } + for ascription in [lo_ascr, hi_ascr].into_iter().flatten() { + kind = PatKind::AscribeUserType { + ascription, + subpattern: Box::new(Pat { span, ty, kind }), + }; } - for inline_const in [lo_inline, hi_inline] { - if let Some(def) = inline_const { - kind = - PatKind::InlineConstant { def, subpattern: Box::new(Pat { span, ty, kind }) }; - } + for def in [lo_inline, hi_inline].into_iter().flatten() { + kind = PatKind::InlineConstant { def, subpattern: Box::new(Pat { span, ty, kind }) }; } Ok(kind) } diff --git a/compiler/rustc_mir_transform/src/coverage/graph.rs b/compiler/rustc_mir_transform/src/coverage/graph.rs index c6badbe78a49f..c97192435ce48 100644 --- a/compiler/rustc_mir_transform/src/coverage/graph.rs +++ b/compiler/rustc_mir_transform/src/coverage/graph.rs @@ -52,19 +52,18 @@ impl CoverageGraph { } } - let mut basic_coverage_blocks = - Self { bcbs, bb_to_bcb, successors, predecessors, dominators: None }; - let dominators = dominators::dominators(&basic_coverage_blocks); - basic_coverage_blocks.dominators = Some(dominators); + let mut this = Self { bcbs, bb_to_bcb, successors, predecessors, dominators: None }; + + this.dominators = Some(dominators::dominators(&this)); // The coverage graph's entry-point node (bcb0) always starts with bb0, // which never has predecessors. Any other blocks merged into bcb0 can't // have multiple (coverage-relevant) predecessors, so bcb0 always has // zero in-edges. - assert!(basic_coverage_blocks[START_BCB].leader_bb() == mir::START_BLOCK); - assert!(basic_coverage_blocks.predecessors[START_BCB].is_empty()); + assert!(this[START_BCB].leader_bb() == mir::START_BLOCK); + assert!(this.predecessors[START_BCB].is_empty()); - basic_coverage_blocks + this } fn compute_basic_coverage_blocks( diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 98fb1d8e1c940..4260a6f0c6f79 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -90,23 +90,23 @@ pub(super) fn generate_coverage_spans( struct CurrCovspan { span: Span, bcb: BasicCoverageBlock, - is_closure: bool, + is_hole: bool, } impl CurrCovspan { - fn new(span: Span, bcb: BasicCoverageBlock, is_closure: bool) -> Self { - Self { span, bcb, is_closure } + fn new(span: Span, bcb: BasicCoverageBlock, is_hole: bool) -> Self { + Self { span, bcb, is_hole } } fn into_prev(self) -> PrevCovspan { - let Self { span, bcb, is_closure } = self; - PrevCovspan { span, bcb, merged_spans: vec![span], is_closure } + let Self { span, bcb, is_hole } = self; + PrevCovspan { span, bcb, merged_spans: vec![span], is_hole } } fn into_refined(self) -> RefinedCovspan { - // This is only called in cases where `curr` is a closure span that has + // This is only called in cases where `curr` is a hole span that has // been carved out of `prev`. - debug_assert!(self.is_closure); + debug_assert!(self.is_hole); self.into_prev().into_refined() } } @@ -118,12 +118,12 @@ struct PrevCovspan { /// List of all the original spans from MIR that have been merged into this /// span. Mainly used to precisely skip over gaps when truncating a span. merged_spans: Vec, - is_closure: bool, + is_hole: bool, } impl PrevCovspan { fn is_mergeable(&self, other: &CurrCovspan) -> bool { - self.bcb == other.bcb && !self.is_closure && !other.is_closure + self.bcb == other.bcb && !self.is_hole && !other.is_hole } fn merge_from(&mut self, other: &CurrCovspan) { @@ -142,8 +142,8 @@ impl PrevCovspan { } fn refined_copy(&self) -> RefinedCovspan { - let &Self { span, bcb, merged_spans: _, is_closure } = self; - RefinedCovspan { span, bcb, is_closure } + let &Self { span, bcb, merged_spans: _, is_hole } = self; + RefinedCovspan { span, bcb, is_hole } } fn into_refined(self) -> RefinedCovspan { @@ -156,12 +156,12 @@ impl PrevCovspan { struct RefinedCovspan { span: Span, bcb: BasicCoverageBlock, - is_closure: bool, + is_hole: bool, } impl RefinedCovspan { fn is_mergeable(&self, other: &Self) -> bool { - self.bcb == other.bcb && !self.is_closure && !other.is_closure + self.bcb == other.bcb && !self.is_hole && !other.is_hole } fn merge_from(&mut self, other: &Self) { @@ -176,16 +176,16 @@ impl RefinedCovspan { /// * Remove duplicate source code coverage regions /// * Merge spans that represent continuous (both in source code and control flow), non-branching /// execution -/// * Carve out (leave uncovered) any span that will be counted by another MIR (notably, closures) +/// * Carve out (leave uncovered) any "hole" spans that need to be left blank +/// (e.g. closures that will be counted by their own MIR body) struct SpansRefiner { /// The initial set of coverage spans, sorted by `Span` (`lo` and `hi`) and by relative /// dominance between the `BasicCoverageBlock`s of equal `Span`s. sorted_spans_iter: std::vec::IntoIter, - /// The current coverage span to compare to its `prev`, to possibly merge, discard, force the - /// discard of the `prev` (and or `pending_dups`), or keep both (with `prev` moved to - /// `pending_dups`). If `curr` is not discarded or merged, it becomes `prev` for the next - /// iteration. + /// The current coverage span to compare to its `prev`, to possibly merge, discard, + /// or cause `prev` to be modified or discarded. + /// If `curr` is not discarded or merged, it becomes `prev` for the next iteration. some_curr: Option, /// The coverage span from a prior iteration; typically assigned from that iteration's `curr`. @@ -229,7 +229,7 @@ impl SpansRefiner { let curr = self.curr(); if prev.is_mergeable(curr) { - debug!(" same bcb (and neither is a closure), merge with prev={prev:?}"); + debug!(?prev, "curr will be merged into prev"); let curr = self.take_curr(); self.prev_mut().merge_from(&curr); } else if prev.span.hi() <= curr.span.lo() { @@ -238,15 +238,13 @@ impl SpansRefiner { ); let prev = self.take_prev().into_refined(); self.refined_spans.push(prev); - } else if prev.is_closure { + } else if prev.is_hole { // drop any equal or overlapping span (`curr`) and keep `prev` to test again in the // next iter - debug!( - " curr overlaps a closure (prev). Drop curr and keep prev for next iter. prev={prev:?}", - ); + debug!(?prev, "prev (a hole) overlaps curr, so discarding curr"); self.take_curr(); // Discards curr. - } else if curr.is_closure { - self.carve_out_span_for_closure(); + } else if curr.is_hole { + self.carve_out_span_for_hole(); } else { self.cutoff_prev_at_overlapping_curr(); } @@ -270,10 +268,9 @@ impl SpansRefiner { } }); - // Remove spans derived from closures, originally added to ensure the coverage - // regions for the current function leave room for the closure's own coverage regions - // (injected separately, from the closure's own MIR). - self.refined_spans.retain(|covspan| !covspan.is_closure); + // Discard hole spans, since their purpose was to carve out chunks from + // other spans, but we don't want the holes themselves in the final mappings. + self.refined_spans.retain(|covspan| !covspan.is_hole); self.refined_spans } @@ -316,48 +313,43 @@ impl SpansRefiner { { // Skip curr because prev has already advanced beyond the end of curr. // This can only happen if a prior iteration updated `prev` to skip past - // a region of code, such as skipping past a closure. - debug!( - " prev.span starts after curr.span, so curr will be dropped (skipping past \ - closure?); prev={prev:?}", - ); + // a region of code, such as skipping past a hole. + debug!(?prev, "prev.span starts after curr.span, so curr will be dropped"); } else { - self.some_curr = Some(CurrCovspan::new(curr.span, curr.bcb, curr.is_closure)); + self.some_curr = Some(CurrCovspan::new(curr.span, curr.bcb, curr.is_hole)); return true; } } false } - /// If `prev`s span extends left of the closure (`curr`), carve out the closure's span from - /// `prev`'s span. (The closure's coverage counters will be injected when processing the - /// closure's own MIR.) Add the portion of the span to the left of the closure; and if the span - /// extends to the right of the closure, update `prev` to that portion of the span. For any - /// `pending_dups`, repeat the same process. - fn carve_out_span_for_closure(&mut self) { + /// If `prev`s span extends left of the hole (`curr`), carve out the hole's span from + /// `prev`'s span. Add the portion of the span to the left of the hole; and if the span + /// extends to the right of the hole, update `prev` to that portion of the span. + fn carve_out_span_for_hole(&mut self) { let prev = self.prev(); let curr = self.curr(); let left_cutoff = curr.span.lo(); let right_cutoff = curr.span.hi(); - let has_pre_closure_span = prev.span.lo() < right_cutoff; - let has_post_closure_span = prev.span.hi() > right_cutoff; - - if has_pre_closure_span { - let mut pre_closure = self.prev().refined_copy(); - pre_closure.span = pre_closure.span.with_hi(left_cutoff); - debug!(" prev overlaps a closure. Adding span for pre_closure={:?}", pre_closure); - self.refined_spans.push(pre_closure); + let has_pre_hole_span = prev.span.lo() < right_cutoff; + let has_post_hole_span = prev.span.hi() > right_cutoff; + + if has_pre_hole_span { + let mut pre_hole = prev.refined_copy(); + pre_hole.span = pre_hole.span.with_hi(left_cutoff); + debug!(?pre_hole, "prev overlaps a hole; adding pre-hole span"); + self.refined_spans.push(pre_hole); } - if has_post_closure_span { - // Mutate `prev.span` to start after the closure (and discard curr). + if has_post_hole_span { + // Mutate `prev.span` to start after the hole (and discard curr). self.prev_mut().span = self.prev().span.with_lo(right_cutoff); - debug!(" Mutated prev.span to start after the closure. prev={:?}", self.prev()); + debug!(prev=?self.prev(), "mutated prev to start after the hole"); // Prevent this curr from becoming prev. - let closure_covspan = self.take_curr().into_refined(); - self.refined_spans.push(closure_covspan); // since self.prev() was already updated + let hole_covspan = self.take_curr().into_refined(); + self.refined_spans.push(hole_covspan); // since self.prev() was already updated } } diff --git a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs index b91ab811918a7..099a354f45dd1 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs @@ -52,14 +52,14 @@ pub(super) fn mir_to_initial_sorted_coverage_spans( // - Span A extends further left, or // - Both have the same start and span A extends further right .then_with(|| Ord::cmp(&a.span.hi(), &b.span.hi()).reverse()) - // If two spans have the same lo & hi, put closure spans first, - // as they take precedence over non-closure spans. - .then_with(|| Ord::cmp(&a.is_closure, &b.is_closure).reverse()) + // If two spans have the same lo & hi, put hole spans first, + // as they take precedence over non-hole spans. + .then_with(|| Ord::cmp(&a.is_hole, &b.is_hole).reverse()) // After deduplication, we want to keep only the most-dominated BCB. .then_with(|| basic_coverage_blocks.cmp_in_dominator_order(a.bcb, b.bcb).reverse()) }); - // Among covspans with the same span, keep only one. Closure spans take + // Among covspans with the same span, keep only one. Hole spans take // precedence, otherwise keep the one with the most-dominated BCB. // (Ideally we should try to preserve _all_ non-dominating BCBs, but that // requires a lot more complexity in the span refiner, for little benefit.) @@ -78,8 +78,8 @@ pub(super) fn mir_to_initial_sorted_coverage_spans( fn remove_unwanted_macro_spans(initial_spans: &mut Vec) { let mut seen_macro_spans = FxHashSet::default(); initial_spans.retain(|covspan| { - // Ignore (retain) closure spans and non-macro-expansion spans. - if covspan.is_closure || covspan.visible_macro.is_none() { + // Ignore (retain) hole spans and non-macro-expansion spans. + if covspan.is_hole || covspan.visible_macro.is_none() { return true; } @@ -96,7 +96,7 @@ fn split_visible_macro_spans(initial_spans: &mut Vec) { let mut extra_spans = vec![]; initial_spans.retain(|covspan| { - if covspan.is_closure { + if covspan.is_hole { return true; } @@ -112,7 +112,7 @@ fn split_visible_macro_spans(initial_spans: &mut Vec) { return true; } - assert!(!covspan.is_closure); + assert!(!covspan.is_hole); extra_spans.push(SpanFromMir::new(before, covspan.visible_macro, covspan.bcb, false)); extra_spans.push(SpanFromMir::new(after, covspan.visible_macro, covspan.bcb, false)); false // Discard the original covspan that we just split. @@ -148,6 +148,8 @@ fn bcb_to_initial_coverage_spans<'a, 'tcx>( let expn_span = filtered_statement_span(statement)?; let (span, visible_macro) = unexpand(expn_span)?; + // A statement that looks like the assignment of a closure expression + // is treated as a "hole" span, to be carved out of other spans. Some(SpanFromMir::new(span, visible_macro, bcb, is_closure_like(statement))) }); @@ -336,7 +338,10 @@ pub(super) struct SpanFromMir { pub(super) span: Span, visible_macro: Option, pub(super) bcb: BasicCoverageBlock, - pub(super) is_closure: bool, + /// If true, this covspan represents a "hole" that should be carved out + /// from other spans, e.g. because it represents a closure expression that + /// will be instrumented separately as its own function. + pub(super) is_hole: bool, } impl SpanFromMir { @@ -348,8 +353,8 @@ impl SpanFromMir { span: Span, visible_macro: Option, bcb: BasicCoverageBlock, - is_closure: bool, + is_hole: bool, ) -> Self { - Self { span, visible_macro, bcb, is_closure } + Self { span, visible_macro, bcb, is_hole } } } diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index 9dc7a50eca9f5..6e635529d9667 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -42,7 +42,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{ fn add_args( self: Box, - _: &mut dyn FnMut(rustc_errors::DiagnosticArgName, rustc_errors::DiagnosticArgValue), + _: &mut dyn FnMut(rustc_errors::DiagArgName, rustc_errors::DiagArgValue), ) {} } throw_machine_stop!(Zst) diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs index af2d7d4946fc7..f3eff247bc705 100644 --- a/compiler/rustc_mir_transform/src/errors.rs +++ b/compiler/rustc_mir_transform/src/errors.rs @@ -1,8 +1,8 @@ use std::borrow::Cow; use rustc_errors::{ - codes::*, Applicability, DecorateLint, DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, - DiagnosticMessage, EmissionGuarantee, IntoDiagnostic, Level, + codes::*, Applicability, DecorateLint, Diag, DiagArgValue, DiagCtxt, DiagnosticMessage, + EmissionGuarantee, IntoDiagnostic, Level, }; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails}; @@ -64,8 +64,8 @@ pub(crate) struct RequiresUnsafe { // but this would result in a lot of duplication. impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for RequiresUnsafe { #[track_caller] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::mir_transform_requires_unsafe); + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { + let mut diag = Diag::new(dcx, level, fluent::mir_transform_requires_unsafe); diag.code(E0133); diag.span(self.span); diag.span_label(self.span, self.details.label()); @@ -90,7 +90,7 @@ impl RequiresUnsafeDetail { // FIXME: make this translatable #[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::untranslatable_diagnostic)] - fn add_subdiagnostics(&self, diag: &mut DiagnosticBuilder<'_, G>) { + fn add_subdiagnostics(&self, diag: &mut Diag<'_, G>) { use UnsafetyViolationDetails::*; match self.violation { CallToUnsafeFunction => { @@ -127,7 +127,7 @@ impl RequiresUnsafeDetail { diag.help(fluent::mir_transform_target_feature_call_help); diag.arg( "missing_target_features", - DiagnosticArgValue::StrListSepByAnd( + DiagArgValue::StrListSepByAnd( missing.iter().map(|feature| Cow::from(feature.to_string())).collect(), ), ); @@ -136,7 +136,7 @@ impl RequiresUnsafeDetail { diag.note(fluent::mir_transform_target_feature_call_note); diag.arg( "build_target_features", - DiagnosticArgValue::StrListSepByAnd( + DiagArgValue::StrListSepByAnd( build_enabled .iter() .map(|feature| Cow::from(feature.to_string())) @@ -183,7 +183,7 @@ pub(crate) struct UnsafeOpInUnsafeFn { impl<'a> DecorateLint<'a, ()> for UnsafeOpInUnsafeFn { #[track_caller] - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { let desc = diag.dcx.eagerly_translate_to_string(self.details.label(), [].into_iter()); diag.arg("details", desc); diag.span_label(self.details.span, self.details.label()); @@ -216,7 +216,7 @@ pub(crate) enum AssertLintKind { } impl<'a, P: std::fmt::Debug> DecorateLint<'a, ()> for AssertLint

{ - fn decorate_lint<'b>(self, diag: &'b mut DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { let message = self.assert_kind.diagnostic_message(); self.assert_kind.add_args(&mut |name, value| { diag.arg(name, value); @@ -270,7 +270,7 @@ pub(crate) struct MustNotSupend<'tcx, 'a> { // Needed for def_path_str impl<'a> DecorateLint<'a, ()> for MustNotSupend<'_, '_> { - fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>) { + fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) { diag.span_label(self.yield_sp, fluent::_subdiag::label); if let Some(reason) = self.reason { diag.subdiagnostic(diag.dcx, reason); diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 663abbece851d..d9387ecd14c4d 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -10,6 +10,10 @@ use rustc_target::spec::PanicStrategy; use crate::errors; +/// Some of the functions declared as "may unwind" by `fn_can_unwind` can't actually unwind. In +/// particular, `extern "C"` is still considered as can-unwind on stable, but we need to to consider +/// it cannot-unwind here. So below we check `fn_can_unwind() && abi_can_unwind()` before concluding +/// that a function call can unwind. fn abi_can_unwind(abi: Abi) -> bool { use Abi::*; match abi { @@ -33,10 +37,8 @@ fn abi_can_unwind(abi: Abi) -> bool { | RiscvInterruptS | CCmseNonSecureCall | Wasm - | RustIntrinsic - | PlatformIntrinsic | Unadjusted => false, - Rust | RustCall | RustCold => true, + RustIntrinsic | Rust | RustCall | RustCold => unreachable!(), // these ABIs are already skipped earlier } } @@ -82,14 +84,16 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { let sig = ty.fn_sig(tcx); // Rust calls cannot themselves create foreign unwinds. - if let Abi::Rust | Abi::RustCall | Abi::RustCold = sig.abi() { + // We assume this is true for intrinsics as well. + if let Abi::RustIntrinsic | Abi::Rust | Abi::RustCall | Abi::RustCold = sig.abi() { continue; }; let fn_def_id = match ty.kind() { ty::FnPtr(_) => None, &ty::FnDef(def_id, _) => { - // Rust calls cannot themselves create foreign unwinds. + // Rust calls cannot themselves create foreign unwinds (even if they use a non-Rust ABI). + // So the leak of the foreign unwind into Rust can only be elsewhere, not here. if !tcx.is_foreign_item(def_id) { continue; } diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 2009539d4d084..36546a03cdfc5 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -421,6 +421,10 @@ impl<'tcx> Inliner<'tcx> { callee_attrs: &CodegenFnAttrs, cross_crate_inlinable: bool, ) -> Result<(), &'static str> { + if self.tcx.has_attr(callsite.callee.def_id(), sym::rustc_no_mir_inline) { + return Err("#[rustc_no_mir_inline]"); + } + if let InlineAttr::Never = callee_attrs.inline { return Err("never inline hint"); } diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index a9cd688c31551..7cab665099482 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -585,20 +585,32 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { val.into() } - Aggregate(ref kind, ref fields) => Value::Aggregate { - fields: fields - .iter() - .map(|field| self.eval_operand(field).map_or(Value::Uninit, Value::Immediate)) - .collect(), - variant: match **kind { - AggregateKind::Adt(_, variant, _, _, _) => variant, - AggregateKind::Array(_) - | AggregateKind::Tuple - | AggregateKind::Closure(_, _) - | AggregateKind::Coroutine(_, _) - | AggregateKind::CoroutineClosure(_, _) => VariantIdx::new(0), - }, - }, + Aggregate(ref kind, ref fields) => { + // Do not const pop union fields as they can be + // made to produce values that don't match their + // underlying layout's type (see ICE #121534). + // If the last element of the `Adt` tuple + // is `Some` it indicates the ADT is a union + if let AggregateKind::Adt(_, _, _, _, Some(_)) = **kind { + return None; + }; + Value::Aggregate { + fields: fields + .iter() + .map(|field| { + self.eval_operand(field).map_or(Value::Uninit, Value::Immediate) + }) + .collect(), + variant: match **kind { + AggregateKind::Adt(_, variant, _, _, _) => variant, + AggregateKind::Array(_) + | AggregateKind::Tuple + | AggregateKind::Closure(_, _) + | AggregateKind::Coroutine(_, _) + | AggregateKind::CoroutineClosure(_, _) => VariantIdx::new(0), + }, + } + } Repeat(ref op, n) => { trace!(?op, ?n); diff --git a/compiler/rustc_mir_transform/src/promote_consts.rs b/compiler/rustc_mir_transform/src/promote_consts.rs index 577b8f2080fcd..2e11da4d585ef 100644 --- a/compiler/rustc_mir_transform/src/promote_consts.rs +++ b/compiler/rustc_mir_transform/src/promote_consts.rs @@ -482,17 +482,40 @@ impl<'tcx> Validator<'_, 'tcx> { match op { BinOp::Div | BinOp::Rem => { if lhs_ty.is_integral() { + let sz = lhs_ty.primitive_size(self.tcx); // Integer division: the RHS must be a non-zero const. - let const_val = match rhs { + let rhs_val = match rhs { Operand::Constant(c) => { - c.const_.try_eval_bits(self.tcx, self.param_env) + c.const_.try_eval_scalar_int(self.tcx, self.param_env) } _ => None, }; - match const_val { + match rhs_val.map(|x| x.try_to_uint(sz).unwrap()) { + // for the zero test, int vs uint does not matter Some(x) if x != 0 => {} // okay _ => return Err(Unpromotable), // value not known or 0 -- not okay } + // Furthermore, for signed divison, we also have to exclude `int::MIN / -1`. + if lhs_ty.is_signed() { + match rhs_val.map(|x| x.try_to_int(sz).unwrap()) { + Some(-1) | None => { + // The RHS is -1 or unknown, so we have to be careful. + // But is the LHS int::MIN? + let lhs_val = match lhs { + Operand::Constant(c) => c + .const_ + .try_eval_scalar_int(self.tcx, self.param_env), + _ => None, + }; + let lhs_min = sz.signed_int_min(); + match lhs_val.map(|x| x.try_to_int(sz).unwrap()) { + Some(x) if x != lhs_min => {} // okay + _ => return Err(Unpromotable), // value not known or int::MIN -- not okay + } + } + _ => {} + } + } } } // The remaining operations can never fail. diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index e4c306791462d..1303ac9939c64 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use crate::fluent_generated as fluent; -use rustc_errors::{DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level}; +use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level}; use rustc_macros::{Diagnostic, LintDiagnostic}; use rustc_span::{Span, Symbol}; @@ -48,9 +48,8 @@ pub struct UnusedGenericParamsHint { impl IntoDiagnostic<'_, G> for UnusedGenericParamsHint { #[track_caller] - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = - DiagnosticBuilder::new(dcx, level, fluent::monomorphize_unused_generic_params); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::monomorphize_unused_generic_params); diag.span(self.span); for (span, name) in self.param_spans.into_iter().zip(self.param_names) { // FIXME: I can figure out how to do a label with a fluent string with a fixed message, diff --git a/compiler/rustc_next_trait_solver/src/canonicalizer.rs b/compiler/rustc_next_trait_solver/src/canonicalizer.rs index cd434fecce2cb..7b73e2aebf039 100644 --- a/compiler/rustc_next_trait_solver/src/canonicalizer.rs +++ b/compiler/rustc_next_trait_solver/src/canonicalizer.rs @@ -108,21 +108,22 @@ impl<'a, Infcx: InferCtxtLike, I: Interner> Canonicalizer<'a, Infc // universes `n`, this algorithm compresses them in place so that: // // - the new universe indices are as small as possible - // - we only create a new universe if we would otherwise put a placeholder in - // the same compressed universe as an existential which cannot name it + // - we create a new universe if we would otherwise + // 1. put existentials from a different universe into the same one + // 2. put a placeholder in the same universe as an existential which cannot name it // // Let's walk through an example: // - var_infos: [E0, U1, E5, U2, E2, E6, U6], curr_compressed_uv: 0, next_orig_uv: 0 // - var_infos: [E0, U1, E5, U2, E2, E6, U6], curr_compressed_uv: 0, next_orig_uv: 1 // - var_infos: [E0, U1, E5, U2, E2, E6, U6], curr_compressed_uv: 1, next_orig_uv: 2 // - var_infos: [E0, U1, E5, U1, E1, E6, U6], curr_compressed_uv: 1, next_orig_uv: 5 - // - var_infos: [E0, U1, E1, U1, E1, E6, U6], curr_compressed_uv: 1, next_orig_uv: 6 - // - var_infos: [E0, U1, E1, U1, E1, E2, U2], curr_compressed_uv: 2, next_orig_uv: - + // - var_infos: [E0, U1, E2, U1, E1, E6, U6], curr_compressed_uv: 2, next_orig_uv: 6 + // - var_infos: [E0, U1, E1, U1, E1, E3, U3], curr_compressed_uv: 2, next_orig_uv: - // // This algorithm runs in `O(n²)` where `n` is the number of different universe // indices in the input. This should be fine as `n` is expected to be small. let mut curr_compressed_uv = ty::UniverseIndex::ROOT; - let mut existential_in_new_uv = false; + let mut existential_in_new_uv = None; let mut next_orig_uv = Some(ty::UniverseIndex::ROOT); while let Some(orig_uv) = next_orig_uv.take() { let mut update_uv = |var: &mut CanonicalVarInfo, orig_uv, is_existential| { @@ -131,14 +132,29 @@ impl<'a, Infcx: InferCtxtLike, I: Interner> Canonicalizer<'a, Infc Ordering::Less => (), // Already updated Ordering::Equal => { if is_existential { - existential_in_new_uv = true; - } else if existential_in_new_uv { + if existential_in_new_uv.is_some_and(|uv| uv < orig_uv) { + // Condition 1. + // + // We already put an existential from a outer universe + // into the current compressed universe, so we need to + // create a new one. + curr_compressed_uv = curr_compressed_uv.next_universe(); + } + + // `curr_compressed_uv` will now contain an existential from + // `orig_uv`. Trying to canonicalizing an existential from + // a higher universe has to therefore use a new compressed + // universe. + existential_in_new_uv = Some(orig_uv); + } else if existential_in_new_uv.is_some() { + // Condition 2. + // // `var` is a placeholder from a universe which is not nameable // by an existential which we already put into the compressed // universe `curr_compressed_uv`. We therefore have to create a // new universe for `var`. curr_compressed_uv = curr_compressed_uv.next_universe(); - existential_in_new_uv = false; + existential_in_new_uv = None; } *var = var.with_updated_universe(curr_compressed_uv); @@ -174,8 +190,14 @@ impl<'a, Infcx: InferCtxtLike, I: Interner> Canonicalizer<'a, Infc } } + // We uniquify regions and always put them into their own universe + let mut first_region = true; for var in var_infos.iter_mut() { if var.is_region() { + if first_region { + first_region = false; + curr_compressed_uv = curr_compressed_uv.next_universe(); + } assert!(var.is_existential()); *var = var.with_updated_universe(curr_compressed_uv); } diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 2c76e55a46d69..91dbf0321d2c6 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -3,8 +3,8 @@ use std::borrow::Cow; use rustc_ast::token::Token; use rustc_ast::{Path, Visibility}; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, - IntoDiagnostic, Level, SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, + Level, SubdiagnosticMessageOp, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_session::errors::ExprParenthesesNeeded; @@ -557,14 +557,6 @@ pub(crate) struct CatchAfterTry { pub span: Span, } -#[derive(Diagnostic)] -#[diag(parse_gen_fn)] -#[help] -pub(crate) struct GenFn { - #[primary_span] - pub span: Span, -} - #[derive(Diagnostic)] #[diag(parse_comma_after_base_struct)] #[note] @@ -1075,10 +1067,10 @@ pub(crate) struct ExpectedIdentifier { impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier { #[track_caller] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { let token_descr = TokenDescription::from_token(&self.token); - let mut diag = DiagnosticBuilder::new( + let mut diag = Diag::new( dcx, level, match token_descr { @@ -1135,10 +1127,10 @@ pub(crate) struct ExpectedSemi { impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi { #[track_caller] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { let token_descr = TokenDescription::from_token(&self.token); - let mut diag = DiagnosticBuilder::new( + let mut diag = Diag::new( dcx, level, match token_descr { @@ -1477,7 +1469,7 @@ pub(crate) struct FnTraitMissingParen { impl AddToDiagnostic for FnTraitMissingParen { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _: F, ) { diag.span_label(self.span, crate::fluent_generated::parse_fn_trait_missing_paren); diff --git a/compiler/rustc_parse/src/lexer/diagnostics.rs b/compiler/rustc_parse/src/lexer/diagnostics.rs index 52a029b20f6e4..993ff1b97f5e8 100644 --- a/compiler/rustc_parse/src/lexer/diagnostics.rs +++ b/compiler/rustc_parse/src/lexer/diagnostics.rs @@ -1,6 +1,6 @@ use super::UnmatchedDelim; use rustc_ast::token::Delimiter; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_span::source_map::SourceMap; use rustc_span::Span; @@ -30,10 +30,7 @@ pub fn same_indentation_level(sm: &SourceMap, open_sp: Span, close_sp: Span) -> // When we get a `)` or `]` for `{`, we should emit help message here // it's more friendly compared to report `unmatched error` in later phase -pub fn report_missing_open_delim( - err: &mut DiagnosticBuilder<'_>, - unmatched_delims: &[UnmatchedDelim], -) -> bool { +pub fn report_missing_open_delim(err: &mut Diag<'_>, unmatched_delims: &[UnmatchedDelim]) -> bool { let mut reported_missing_open = false; for unmatch_brace in unmatched_delims.iter() { if let Some(delim) = unmatch_brace.found_delim @@ -55,7 +52,7 @@ pub fn report_missing_open_delim( } pub fn report_suspicious_mismatch_block( - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, diag_info: &TokenTreeDiagInfo, sm: &SourceMap, delim: Delimiter, diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index c768ea93b5fec..4cfd061ebd921 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -4,10 +4,10 @@ use crate::errors; use crate::lexer::unicode_chars::UNICODE_ARRAY; use crate::make_unclosed_delims_error; use rustc_ast::ast::{self, AttrStyle}; -use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind}; +use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::util::unicode::contains_text_flow_control_chars; -use rustc_errors::{codes::*, Applicability, DiagCtxt, DiagnosticBuilder, StashKey}; +use rustc_errors::{codes::*, Applicability, Diag, DiagCtxt, StashKey}; use rustc_lexer::unescape::{self, EscapeError, Mode}; use rustc_lexer::{Base, DocStyle, RawStrError}; use rustc_lexer::{Cursor, LiteralKind}; @@ -47,7 +47,7 @@ pub(crate) fn parse_token_trees<'sess, 'src>( mut src: &'src str, mut start_pos: BytePos, override_span: Option, -) -> Result>> { +) -> Result>> { // Skip `#!`, if present. if let Some(shebang_len) = rustc_lexer::strip_shebang(src) { src = &src[shebang_len..]; @@ -181,7 +181,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> { self.dcx().emit_err(errors::CannotBeRawIdent { span, ident: sym }); } self.sess.raw_identifier_spans.push(span); - token::Ident(sym, true) + token::Ident(sym, IdentIsRaw::Yes) } rustc_lexer::TokenKind::UnknownPrefix => { self.report_unknown_prefix(start); @@ -201,7 +201,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> { let span = self.mk_sp(start, self.pos); self.sess.bad_unicode_identifiers.borrow_mut().entry(sym).or_default() .push(span); - token::Ident(sym, false) + token::Ident(sym, IdentIsRaw::No) } // split up (raw) c string literals to an ident and a string literal when edition < 2021. rustc_lexer::TokenKind::Literal { @@ -339,7 +339,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> { let sym = nfc_normalize(self.str_from(start)); let span = self.mk_sp(start, self.pos); self.sess.symbol_gallery.insert(sym, span); - token::Ident(sym, false) + token::Ident(sym, IdentIsRaw::No) } /// Detect usages of Unicode codepoints changing the direction of the text on screen and loudly @@ -501,9 +501,11 @@ impl<'sess, 'src> StringReader<'sess, 'src> { (kind, self.symbol_from_to(start, end)) } rustc_lexer::LiteralKind::Float { base, empty_exponent } => { + let mut kind = token::Float; if empty_exponent { let span = self.mk_sp(start, self.pos); - self.dcx().emit_err(errors::EmptyExponentFloat { span }); + let guar = self.dcx().emit_err(errors::EmptyExponentFloat { span }); + kind = token::Err(guar); } let base = match base { Base::Hexadecimal => Some("hexadecimal"), @@ -513,9 +515,11 @@ impl<'sess, 'src> StringReader<'sess, 'src> { }; if let Some(base) = base { let span = self.mk_sp(start, end); - self.dcx().emit_err(errors::FloatLiteralUnsupportedBase { span, base }); + let guar = + self.dcx().emit_err(errors::FloatLiteralUnsupportedBase { span, base }); + kind = token::Err(guar) } - (token::Float, self.symbol_from_to(start, end)) + (kind, self.symbol_from_to(start, end)) } } } diff --git a/compiler/rustc_parse/src/lexer/unicode_chars.rs b/compiler/rustc_parse/src/lexer/unicode_chars.rs index a136abaa28bb8..3b4e05332fac9 100644 --- a/compiler/rustc_parse/src/lexer/unicode_chars.rs +++ b/compiler/rustc_parse/src/lexer/unicode_chars.rs @@ -307,7 +307,7 @@ pub(crate) const UNICODE_ARRAY: &[(char, &str, &str)] = &[ // fancier error recovery to it, as there will be less overall work to do this way. const ASCII_ARRAY: &[(&str, &str, Option)] = &[ (" ", "Space", None), - ("_", "Underscore", Some(token::Ident(kw::Underscore, false))), + ("_", "Underscore", Some(token::Ident(kw::Underscore, token::IdentIsRaw::No))), ("-", "Minus/Hyphen", Some(token::BinOp(token::Minus))), (",", "Comma", Some(token::Comma)), (";", "Semicolon", Some(token::Semi)), diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 5bd8bb72bd665..53bcb35101e2e 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -18,7 +18,7 @@ use rustc_ast::tokenstream::TokenStream; use rustc_ast::{AttrItem, Attribute, MetaItem}; use rustc_ast_pretty::pprust; use rustc_data_structures::sync::Lrc; -use rustc_errors::{DiagnosticBuilder, FatalError, PResult}; +use rustc_errors::{Diag, FatalError, PResult}; use rustc_session::parse::ParseSess; use rustc_span::{FileName, SourceFile, Span}; @@ -41,8 +41,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" } // uses a HOF to parse anything, and includes file and // `source_str`. -/// A variant of 'panictry!' that works on a `Vec` instead of a single -/// `DiagnosticBuilder`. +/// A variant of 'panictry!' that works on a `Vec` instead of a single `Diag`. macro_rules! panictry_buffer { ($e:expr) => {{ use std::result::Result::{Err, Ok}; @@ -108,7 +107,7 @@ pub fn maybe_new_parser_from_source_str( sess: &ParseSess, name: FileName, source: String, -) -> Result, Vec>> { +) -> Result, Vec>> { maybe_source_file_to_parser(sess, sess.source_map().new_source_file(name, source)) } @@ -132,7 +131,7 @@ pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option, -) -> Result, Vec>> { +) -> Result, Vec>> { 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); @@ -160,7 +159,7 @@ fn maybe_file_to_stream<'sess>( sess: &'sess ParseSess, source_file: Lrc, override_span: Option, -) -> Result>> { +) -> Result>> { let src = source_file.src.as_ref().unwrap_or_else(|| { sess.dcx.bug(format!( "cannot lex `source_file` without source: {}", diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index 6545429b95bc7..685af6546f5f5 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -8,7 +8,7 @@ use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle use rustc_ast as ast; use rustc_ast::attr; use rustc_ast::token::{self, Delimiter, Nonterminal}; -use rustc_errors::{codes::*, DiagnosticBuilder, PResult}; +use rustc_errors::{codes::*, Diag, PResult}; use rustc_span::{sym, BytePos, Span}; use thin_vec::ThinVec; use tracing::debug; @@ -141,7 +141,7 @@ impl<'a> Parser<'a> { fn annotate_following_item_if_applicable( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, attr_type: OuterAttributeType, ) -> Option { diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 0cc2170714c49..2a8cb74337b53 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -21,6 +21,8 @@ use crate::errors::{ use crate::fluent_generated as fluent; use crate::parser; use crate::parser::attr::InnerAttrPolicy; +use ast::token::IdentIsRaw; +use parser::Recovered; use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Lit, LitKind, Token, TokenKind}; @@ -34,8 +36,8 @@ use rustc_ast::{ use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{ - pluralize, AddToDiagnostic, Applicability, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, - FatalError, PErr, PResult, + pluralize, AddToDiagnostic, Applicability, Diag, DiagCtxt, ErrorGuaranteed, FatalError, PErr, + PResult, }; use rustc_session::errors::ExprParenthesesNeeded; use rustc_span::source_map::Spanned; @@ -208,11 +210,11 @@ struct MultiSugg { } impl MultiSugg { - fn emit(self, err: &mut DiagnosticBuilder<'_>) { + fn emit(self, err: &mut Diag<'_>) { err.multipart_suggestion(self.msg, self.patches, self.applicability); } - fn emit_verbose(self, err: &mut DiagnosticBuilder<'_>) { + fn emit_verbose(self, err: &mut Diag<'_>) { err.multipart_suggestion_verbose(self.msg, self.patches, self.applicability); } } @@ -264,7 +266,7 @@ impl<'a> Parser<'a> { pub(super) fn expected_ident_found( &mut self, recover: bool, - ) -> PResult<'a, (Ident, /* is_raw */ bool)> { + ) -> PResult<'a, (Ident, IdentIsRaw)> { if let TokenKind::DocComment(..) = self.prev_token.kind { return Err(self.dcx().create_err(DocCommentDoesNotDocumentAnything { span: self.prev_token.span, @@ -290,11 +292,11 @@ impl<'a> Parser<'a> { let bad_token = self.token.clone(); // suggest prepending a keyword in identifier position with `r#` - let suggest_raw = if let Some((ident, false)) = self.token.ident() + let suggest_raw = if let Some((ident, IdentIsRaw::No)) = self.token.ident() && ident.is_raw_guess() && self.look_ahead(1, |t| valid_follow.contains(&t.kind)) { - recovered_ident = Some((ident, true)); + recovered_ident = Some((ident, IdentIsRaw::Yes)); // `Symbol::to_string()` is different from `Symbol::into_diagnostic_arg()`, // which uses `Symbol::to_ident_string()` and "helpfully" adds an implicit `r#` @@ -320,7 +322,7 @@ impl<'a> Parser<'a> { let help_cannot_start_number = self.is_lit_bad_ident().map(|(len, valid_portion)| { let (invalid, valid) = self.token.span.split_at(len as u32); - recovered_ident = Some((Ident::new(valid_portion, valid), false)); + recovered_ident = Some((Ident::new(valid_portion, valid), IdentIsRaw::No)); HelpIdentifierStartsWithNumber { num_span: invalid } }); @@ -399,7 +401,7 @@ impl<'a> Parser<'a> { } } - pub(super) fn expected_ident_found_err(&mut self) -> DiagnosticBuilder<'a> { + pub(super) fn expected_ident_found_err(&mut self) -> Diag<'a> { self.expected_ident_found(false).unwrap_err() } @@ -429,7 +431,7 @@ impl<'a> Parser<'a> { &mut self, edible: &[TokenKind], inedible: &[TokenKind], - ) -> PResult<'a, bool /* recovered */> { + ) -> PResult<'a, Recovered> { debug!("expected_one_of_not_found(edible: {:?}, inedible: {:?})", edible, inedible); fn tokens_to_string(tokens: &[TokenType]) -> String { let mut i = tokens.iter(); @@ -532,7 +534,7 @@ impl<'a> Parser<'a> { sugg: ExpectedSemiSugg::ChangeToSemi(self.token.span), }); self.bump(); - return Ok(true); + return Ok(Recovered::Yes); } else if self.look_ahead(0, |t| { t == &token::CloseDelim(Delimiter::Brace) || ((t.can_begin_expr() || t.can_begin_item()) @@ -556,7 +558,7 @@ impl<'a> Parser<'a> { unexpected_token_label: Some(self.token.span), sugg: ExpectedSemiSugg::AddSemi(span), }); - return Ok(true); + return Ok(Recovered::Yes); } } @@ -653,9 +655,9 @@ impl<'a> Parser<'a> { // positive for a `cr#` that wasn't intended to start a c-string literal, but identifying // that in the parser requires unbounded lookahead, so we only add a hint to the existing // error rather than replacing it entirely. - if ((self.prev_token.kind == TokenKind::Ident(sym::c, false) + if ((self.prev_token.kind == TokenKind::Ident(sym::c, IdentIsRaw::No) && matches!(&self.token.kind, TokenKind::Literal(token::Lit { kind: token::Str, .. }))) - || (self.prev_token.kind == TokenKind::Ident(sym::cr, false) + || (self.prev_token.kind == TokenKind::Ident(sym::cr, IdentIsRaw::No) && matches!( &self.token.kind, TokenKind::Literal(token::Lit { kind: token::Str, .. }) | token::Pound @@ -711,7 +713,7 @@ impl<'a> Parser<'a> { if self.check_too_many_raw_str_terminators(&mut err) { if expected.contains(&TokenType::Token(token::Semi)) && self.eat(&token::Semi) { err.emit(); - return Ok(true); + return Ok(Recovered::Yes); } else { return Err(err); } @@ -742,7 +744,8 @@ impl<'a> Parser<'a> { Err(err) } - pub(super) fn attr_on_non_tail_expr(&self, expr: &Expr) { + /// The user has written `#[attr] expr` which is unsupported. (#106020) + pub(super) fn attr_on_non_tail_expr(&self, expr: &Expr) -> ErrorGuaranteed { // Missing semicolon typo error. let span = self.prev_token.span.shrink_to_hi(); let mut err = self.dcx().create_err(ExpectedSemi { @@ -785,6 +788,8 @@ impl<'a> Parser<'a> { ], Applicability::MachineApplicable, ); + + // Special handling for `#[cfg(...)]` chains let mut snapshot = self.create_snapshot_for_diagnostic(); if let [attr] = &expr.attrs[..] && let ast::AttrKind::Normal(attr_kind) = &attr.kind @@ -795,9 +800,8 @@ impl<'a> Parser<'a> { { Ok(next_attr) => next_attr, Err(inner_err) => { - err.cancel(); inner_err.cancel(); - return; + return err.emit(); } } && let ast::AttrKind::Normal(next_attr_kind) = next_attr.kind @@ -808,9 +812,8 @@ impl<'a> Parser<'a> { let next_expr = match snapshot.parse_expr() { Ok(next_expr) => next_expr, Err(inner_err) => { - err.cancel(); inner_err.cancel(); - return; + return err.emit(); } }; // We have for sure @@ -843,10 +846,10 @@ impl<'a> Parser<'a> { ); } } - err.emit(); + err.emit() } - fn check_too_many_raw_str_terminators(&mut self, err: &mut DiagnosticBuilder<'_>) -> bool { + fn check_too_many_raw_str_terminators(&mut self, err: &mut Diag<'_>) -> bool { let sm = self.sess.source_map(); match (&self.prev_token.kind, &self.token.kind) { ( @@ -919,10 +922,10 @@ impl<'a> Parser<'a> { // fn foo() -> Foo { Path { // field: value, // } } - err.delay_as_bug(); + let guar = err.delay_as_bug(); self.restore_snapshot(snapshot); let mut tail = self.mk_block( - thin_vec![self.mk_stmt_err(expr.span)], + thin_vec![self.mk_stmt_err(expr.span, guar)], s, lo.to(self.prev_token.span), ); @@ -980,7 +983,7 @@ impl<'a> Parser<'a> { pub(super) fn recover_closure_body( &mut self, - mut err: DiagnosticBuilder<'a>, + mut err: Diag<'a>, before: token::Token, prev: token::Token, token: token::Token, @@ -988,7 +991,7 @@ impl<'a> Parser<'a> { decl_hi: Span, ) -> PResult<'a, P> { err.span_label(lo.to(decl_hi), "while parsing the body of this closure"); - match before.kind { + let guar = match before.kind { token::OpenDelim(Delimiter::Brace) if !matches!(token.kind, token::OpenDelim(Delimiter::Brace)) => { @@ -1002,8 +1005,9 @@ impl<'a> Parser<'a> { ], Applicability::MaybeIncorrect, ); - err.emit(); + let guar = err.emit(); self.eat_to_tokens(&[&token::CloseDelim(Delimiter::Brace)]); + guar } token::OpenDelim(Delimiter::Parenthesis) if !matches!(token.kind, token::OpenDelim(Delimiter::Brace)) => @@ -1020,7 +1024,7 @@ impl<'a> Parser<'a> { ], Applicability::MaybeIncorrect, ); - err.emit(); + err.emit() } _ if !matches!(token.kind, token::OpenDelim(Delimiter::Brace)) => { // We don't have a heuristic to correctly identify where the block @@ -1033,8 +1037,8 @@ impl<'a> Parser<'a> { return Err(err); } _ => return Err(err), - } - Ok(self.mk_expr_err(lo.to(self.token.span))) + }; + Ok(self.mk_expr_err(lo.to(self.token.span), guar)) } /// Eats and discards tokens until one of `kets` is encountered. Respects token trees, @@ -1210,9 +1214,9 @@ impl<'a> Parser<'a> { /// encounter a parse error when encountering the first `,`. pub(super) fn check_mistyped_turbofish_with_multiple_type_params( &mut self, - mut e: DiagnosticBuilder<'a>, + mut e: Diag<'a>, expr: &mut P, - ) -> PResult<'a, ()> { + ) -> PResult<'a, ErrorGuaranteed> { if let ExprKind::Binary(binop, _, _) = &expr.kind && let ast::BinOpKind::Lt = binop.node && self.eat(&token::Comma) @@ -1223,7 +1227,7 @@ impl<'a> Parser<'a> { |p| p.parse_generic_arg(None), ); match x { - Ok((_, _, false)) => { + Ok((_, _, Recovered::No)) => { if self.eat(&token::Gt) { // We made sense of it. Improve the error message. e.span_suggestion_verbose( @@ -1237,9 +1241,9 @@ impl<'a> Parser<'a> { // The subsequent expression is valid. Mark // `expr` as erroneous and emit `e` now, but // return `Ok` so parsing can continue. - e.emit(); - *expr = self.mk_expr_err(expr.span.to(self.prev_token.span)); - return Ok(()); + let guar = e.emit(); + *expr = self.mk_expr_err(expr.span.to(self.prev_token.span), guar); + return Ok(guar); } Err(err) => { err.cancel(); @@ -1247,7 +1251,7 @@ impl<'a> Parser<'a> { } } } - Ok((_, _, true)) => {} + Ok((_, _, Recovered::Yes)) => {} Err(err) => { err.cancel(); } @@ -1258,7 +1262,7 @@ impl<'a> Parser<'a> { /// Suggest add the missing `let` before the identifier in stmt /// `a: Ty = 1` -> `let a: Ty = 1` - pub(super) fn suggest_add_missing_let_for_stmt(&mut self, err: &mut DiagnosticBuilder<'a>) { + pub(super) fn suggest_add_missing_let_for_stmt(&mut self, err: &mut Diag<'a>) { if self.token == token::Colon { let prev_span = self.prev_token.span.shrink_to_lo(); let snapshot = self.create_snapshot_for_diagnostic(); @@ -1286,7 +1290,7 @@ impl<'a> Parser<'a> { err: &mut ComparisonOperatorsCannotBeChained, inner_op: &Expr, outer_op: &Spanned, - ) -> bool /* advanced the cursor */ { + ) -> Recovered { if let ExprKind::Binary(op, l1, r1) = &inner_op.kind { if let ExprKind::Field(_, ident) = l1.kind && ident.as_str().parse::().is_err() @@ -1294,7 +1298,7 @@ impl<'a> Parser<'a> { { // The parser has encountered `foo.bar Parser<'a> { span: inner_op.span.shrink_to_hi(), middle_term: expr_to_str(r1), }); - false // Keep the current parse behavior, where the AST is `(x < y) < z`. + Recovered::No // Keep the current parse behavior, where the AST is `(x < y) < z`. } // `x == y < z` (BinOpKind::Eq, AssocOp::Less | AssocOp::LessEqual | AssocOp::Greater | AssocOp::GreaterEqual) => { @@ -1327,12 +1331,12 @@ impl<'a> Parser<'a> { left: r1.span.shrink_to_lo(), right: r2.span.shrink_to_hi(), }); - true + Recovered::Yes } Err(expr_err) => { expr_err.cancel(); self.restore_snapshot(snapshot); - false + Recovered::Yes } } } @@ -1347,19 +1351,19 @@ impl<'a> Parser<'a> { left: l1.span.shrink_to_lo(), right: r1.span.shrink_to_hi(), }); - true + Recovered::Yes } Err(expr_err) => { expr_err.cancel(); self.restore_snapshot(snapshot); - false + Recovered::No } } } - _ => false, + _ => Recovered::No, }; } - false + Recovered::No } /// Produces an error if comparison operators are chained (RFC #558). @@ -1391,7 +1395,8 @@ impl<'a> Parser<'a> { outer_op.node, ); - let mk_err_expr = |this: &Self, span| Ok(Some(this.mk_expr(span, ExprKind::Err))); + let mk_err_expr = + |this: &Self, span, guar| Ok(Some(this.mk_expr(span, ExprKind::Err(guar)))); match &inner_op.kind { ExprKind::Binary(op, l1, r1) if op.node.is_comparison() => { @@ -1441,11 +1446,11 @@ impl<'a> Parser<'a> { match self.parse_expr() { Ok(_) => { // 99% certain that the suggestion is correct, continue parsing. - self.dcx().emit_err(err); + let guar = self.dcx().emit_err(err); // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, inner_op.span.to(self.prev_token.span)) + mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar) } Err(expr_err) => { expr_err.cancel(); @@ -1469,11 +1474,11 @@ impl<'a> Parser<'a> { match self.consume_fn_args() { Err(()) => Err(self.dcx().create_err(err)), Ok(()) => { - self.dcx().emit_err(err); + let guar = self.dcx().emit_err(err); // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, inner_op.span.to(self.prev_token.span)) + mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar) } } } else { @@ -1487,10 +1492,11 @@ impl<'a> Parser<'a> { // If it looks like a genuine attempt to chain operators (as opposed to a // misformatted turbofish, for instance), suggest a correct form. - if self.attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op) - { - self.dcx().emit_err(err); - mk_err_expr(self, inner_op.span.to(self.prev_token.span)) + let recovered = self + .attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op); + if matches!(recovered, Recovered::Yes) { + let guar = self.dcx().emit_err(err); + mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar) } else { // These cases cause too many knock-down errors, bail out (#61329). Err(self.dcx().create_err(err)) @@ -1499,9 +1505,9 @@ impl<'a> Parser<'a> { } let recover = self.attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op); - self.dcx().emit_err(err); - if recover { - return mk_err_expr(self, inner_op.span.to(self.prev_token.span)); + let guar = self.dcx().emit_err(err); + if matches!(recover, Recovered::Yes) { + return mk_err_expr(self, inner_op.span.to(self.prev_token.span), guar); } } _ => {} @@ -1677,7 +1683,7 @@ impl<'a> Parser<'a> { ); err.span_label(op_span, format!("not a valid {} operator", kind.fixity)); - let help_base_case = |mut err: DiagnosticBuilder<'_, _>, base| { + let help_base_case = |mut err: Diag<'_, _>, base| { err.help(format!("use `{}= 1` instead", kind.op.chr())); err.emit(); Ok(base) @@ -1838,12 +1844,9 @@ impl<'a> Parser<'a> { } } - /// Creates a `DiagnosticBuilder` for an unexpected token `t` and tries to recover if it is a + /// Creates a `Diag` for an unexpected token `t` and tries to recover if it is a /// closing delimiter. - pub(super) fn unexpected_try_recover( - &mut self, - t: &TokenKind, - ) -> PResult<'a, bool /* recovered */> { + pub(super) fn unexpected_try_recover(&mut self, t: &TokenKind) -> PResult<'a, Recovered> { let token_str = pprust::token_kind_to_string(t); let this_token_str = super::token_descr(&self.token); let (prev_sp, sp) = match (&self.token.kind, self.subparser_name) { @@ -1925,8 +1928,8 @@ impl<'a> Parser<'a> { } else { self.recover_await_prefix(await_sp)? }; - let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question); - let expr = self.mk_expr(lo.to(sp), ExprKind::Err); + let (sp, guar) = self.error_on_incorrect_await(lo, hi, &expr, is_question); + let expr = self.mk_expr_err(lo.to(sp), guar); self.maybe_recover_from_bad_qpath(expr) } @@ -1955,21 +1958,27 @@ impl<'a> Parser<'a> { Ok((expr.span, expr, is_question)) } - fn error_on_incorrect_await(&self, lo: Span, hi: Span, expr: &Expr, is_question: bool) -> Span { + fn error_on_incorrect_await( + &self, + lo: Span, + hi: Span, + expr: &Expr, + is_question: bool, + ) -> (Span, ErrorGuaranteed) { let span = lo.to(hi); let applicability = match expr.kind { ExprKind::Try(_) => Applicability::MaybeIncorrect, // `await ?` _ => Applicability::MachineApplicable, }; - self.dcx().emit_err(IncorrectAwait { + let guar = self.dcx().emit_err(IncorrectAwait { span, sugg_span: (span, applicability), expr: self.span_to_snippet(expr.span).unwrap_or_else(|_| pprust::expr_to_string(expr)), question_mark: if is_question { "?" } else { "" }, }); - span + (span, guar) } /// If encountering `future.await()`, consumes and emits an error. @@ -2013,8 +2022,8 @@ impl<'a> Parser<'a> { ); } err.span_suggestion(lo.shrink_to_lo(), format!("{prefix}you can still access the deprecated `try!()` macro using the \"raw identifier\" syntax"), "r#", Applicability::MachineApplicable); - err.emit(); - Ok(self.mk_expr_err(lo.to(hi))) + let guar = err.emit(); + Ok(self.mk_expr_err(lo.to(hi), guar)) } else { Err(self.expected_expression_found()) // The user isn't trying to invoke the try! macro } @@ -2059,10 +2068,10 @@ impl<'a> Parser<'a> { lo: Span, err: PErr<'a>, ) -> P { - err.emit(); + let guar = err.emit(); // Recover from parse error, callers expect the closing delim to be consumed. self.consume_block(delim, ConsumeClosingDelim::Yes); - self.mk_expr(lo.to(self.prev_token.span), ExprKind::Err) + self.mk_expr(lo.to(self.prev_token.span), ExprKind::Err(guar)) } /// Eats tokens until we can be relatively sure we reached the end of the @@ -2179,7 +2188,7 @@ impl<'a> Parser<'a> { pub(super) fn parameter_without_type( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, pat: P, require_name: bool, first_param: bool, @@ -2336,7 +2345,7 @@ impl<'a> Parser<'a> { } } - pub(super) fn expected_expression_found(&self) -> DiagnosticBuilder<'a> { + pub(super) fn expected_expression_found(&self) -> Diag<'a> { let (span, msg) = match (&self.token.kind, self.subparser_name) { (&token::Eof, Some(origin)) => { let sp = self.prev_token.span.shrink_to_hi(); @@ -2549,9 +2558,10 @@ impl<'a> Parser<'a> { } _ => None, }; - self.dcx().emit_err(UnexpectedConstParamDeclaration { span: param.span(), sugg }); + let guar = + self.dcx().emit_err(UnexpectedConstParamDeclaration { span: param.span(), sugg }); - let value = self.mk_expr_err(param.span()); + let value = self.mk_expr_err(param.span(), guar); Some(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value })) } @@ -2585,11 +2595,7 @@ impl<'a> Parser<'a> { /// When encountering code like `foo::< bar + 3 >` or `foo::< bar - baz >` we suggest /// `foo::<{ bar + 3 }>` and `foo::<{ bar - baz }>`, respectively. We only provide a suggestion /// if we think that the resulting expression would be well formed. - pub fn recover_const_arg( - &mut self, - start: Span, - mut err: DiagnosticBuilder<'a>, - ) -> PResult<'a, GenericArg> { + pub fn recover_const_arg(&mut self, start: Span, mut err: Diag<'a>) -> PResult<'a, GenericArg> { let is_op_or_dot = AssocOp::from_token(&self.token) .and_then(|op| { if let AssocOp::Greater @@ -2630,8 +2636,8 @@ impl<'a> Parser<'a> { "=", Applicability::MaybeIncorrect, ); - let value = self.mk_expr_err(start.to(expr.span)); - err.emit(); + let guar = err.emit(); + let value = self.mk_expr_err(start.to(expr.span), guar); return Ok(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value })); } else if token::Colon == snapshot.token.kind && expr.span.lo() == snapshot.token.span.hi() @@ -2690,19 +2696,15 @@ impl<'a> Parser<'a> { } /// Creates a dummy const argument, and reports that the expression must be enclosed in braces - pub fn dummy_const_arg_needs_braces( - &self, - mut err: DiagnosticBuilder<'a>, - span: Span, - ) -> GenericArg { + pub fn dummy_const_arg_needs_braces(&self, mut err: Diag<'a>, span: Span) -> GenericArg { err.multipart_suggestion( "expressions must be enclosed in braces to be used as const generic \ arguments", vec![(span.shrink_to_lo(), "{ ".to_string()), (span.shrink_to_hi(), " }".to_string())], Applicability::MaybeIncorrect, ); - let value = self.mk_expr_err(span); - err.emit(); + let guar = err.emit(); + let value = self.mk_expr_err(span, guar); GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value }) } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 8826c06bebde7..f5a7bfd42ff42 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3,13 +3,14 @@ use super::diagnostics::SnapshotParser; use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{ - AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions, - SemiColonMode, SeqSep, TokenExpectType, TokenType, TrailingToken, + AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Recovered, Restrictions, + SemiColonMode, SeqSep, TokenExpectType, TokenType, Trailing, TrailingToken, }; use crate::errors; use crate::maybe_recover_from_interpolated_ty_qpath; use ast::mut_visit::{noop_visit_expr, MutVisitor}; +use ast::token::IdentIsRaw; use ast::{CoroutineKind, ForLoopKind, GenBlockKind, Pat, Path, PathSegment}; use core::mem; use rustc_ast::ptr::P; @@ -25,7 +26,7 @@ use rustc_ast::{Arm, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLim use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind}; use rustc_ast_pretty::pprust; use rustc_data_structures::stack::ensure_sufficient_stack; -use rustc_errors::{AddToDiagnostic, Applicability, DiagnosticBuilder, PResult, StashKey}; +use rustc_errors::{AddToDiagnostic, Applicability, Diag, PResult, StashKey}; use rustc_lexer::unescape::unescape_char; use rustc_macros::Subdiagnostic; use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded}; @@ -33,7 +34,7 @@ use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_span::source_map::{self, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::{BytePos, Pos, Span}; +use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span}; use thin_vec::{thin_vec, ThinVec}; /// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression @@ -126,13 +127,13 @@ impl<'a> Parser<'a> { match self.parse_expr_res(restrictions, None) { Ok(expr) => Ok(expr), Err(err) => match self.token.ident() { - Some((Ident { name: kw::Underscore, .. }, false)) + Some((Ident { name: kw::Underscore, .. }, IdentIsRaw::No)) if self.may_recover() && self.look_ahead(1, |t| t == &token::Comma) => { // Special-case handling of `foo(_, _, _)` - err.emit(); + let guar = err.emit(); self.bump(); - Ok(self.mk_expr(self.prev_token.span, ExprKind::Err)) + Ok(self.mk_expr(self.prev_token.span, ExprKind::Err(guar))) } _ => Err(err), }, @@ -457,7 +458,9 @@ impl<'a> Parser<'a> { return None; } (Some(op), _) => (op, self.token.span), - (None, Some((Ident { name: sym::and, span }, false))) if self.may_recover() => { + (None, Some((Ident { name: sym::and, span }, IdentIsRaw::No))) + if self.may_recover() => + { self.dcx().emit_err(errors::InvalidLogicalOperator { span: self.token.span, incorrect: "and".into(), @@ -465,7 +468,7 @@ impl<'a> Parser<'a> { }); (AssocOp::LAnd, span) } - (None, Some((Ident { name: sym::or, span }, false))) if self.may_recover() => { + (None, Some((Ident { name: sym::or, span }, IdentIsRaw::No))) if self.may_recover() => { self.dcx().emit_err(errors::InvalidLogicalOperator { span: self.token.span, incorrect: "or".into(), @@ -664,8 +667,8 @@ impl<'a> Parser<'a> { let (span, _) = self.parse_expr_prefix_common(box_kw)?; let inner_span = span.with_lo(box_kw.hi()); let code = self.sess.source_map().span_to_snippet(inner_span).unwrap(); - self.dcx().emit_err(errors::BoxSyntaxRemoved { span: span, code: code.trim() }); - Ok((span, ExprKind::Err)) + let guar = self.dcx().emit_err(errors::BoxSyntaxRemoved { span: span, code: code.trim() }); + Ok((span, ExprKind::Err(guar))) } fn is_mistaken_not_ident_negation(&self) -> bool { @@ -742,7 +745,7 @@ impl<'a> Parser<'a> { ( // `foo: ` ExprKind::Path(None, ast::Path { segments, .. }), - token::Ident(kw::For | kw::Loop | kw::While, false), + token::Ident(kw::For | kw::Loop | kw::While, IdentIsRaw::No), ) if segments.len() == 1 => { let snapshot = self.create_snapshot_for_diagnostic(); let label = Label { @@ -857,13 +860,13 @@ impl<'a> Parser<'a> { ExprKind::MethodCall(_) => "a method call", ExprKind::Call(_, _) => "a function call", ExprKind::Await(_, _) => "`.await`", - ExprKind::Err => return Ok(with_postfix), + ExprKind::Err(_) => return Ok(with_postfix), _ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"), } ); let mut err = self.dcx().struct_span_err(span, msg); - let suggest_parens = |err: &mut DiagnosticBuilder<'_>| { + let suggest_parens = |err: &mut Diag<'_>| { let suggestions = vec![ (span.shrink_to_lo(), "(".to_string()), (span.shrink_to_hi(), ")".to_string()), @@ -955,19 +958,20 @@ impl<'a> Parser<'a> { fn parse_expr_dot_or_call_with_(&mut self, mut e: P, lo: Span) -> PResult<'a, P> { loop { - let has_question = if self.prev_token.kind == TokenKind::Ident(kw::Return, false) { - // we are using noexpect here because we don't expect a `?` directly after a `return` - // which could be suggested otherwise - self.eat_noexpect(&token::Question) - } else { - self.eat(&token::Question) - }; + let has_question = + if self.prev_token.kind == TokenKind::Ident(kw::Return, IdentIsRaw::No) { + // we are using noexpect here because we don't expect a `?` directly after a `return` + // which could be suggested otherwise + self.eat_noexpect(&token::Question) + } else { + self.eat(&token::Question) + }; if has_question { // `expr?` e = self.mk_expr(lo.to(self.prev_token.span), ExprKind::Try(e)); continue; } - let has_dot = if self.prev_token.kind == TokenKind::Ident(kw::Return, false) { + let has_dot = if self.prev_token.kind == TokenKind::Ident(kw::Return, IdentIsRaw::No) { // we are using noexpect here because we don't expect a `.` directly after a `return` // which could be suggested otherwise self.eat_noexpect(&token::Dot) @@ -1126,19 +1130,19 @@ impl<'a> Parser<'a> { // 1. DestructuredFloat::TrailingDot(sym, ident_span, dot_span) => { assert!(suffix.is_none()); - self.token = Token::new(token::Ident(sym, false), ident_span); + self.token = Token::new(token::Ident(sym, IdentIsRaw::No), ident_span); let next_token = (Token::new(token::Dot, dot_span), self.token_spacing); self.parse_expr_tuple_field_access(lo, base, sym, None, Some(next_token)) } // 1.2 | 1.2e3 DestructuredFloat::MiddleDot(symbol1, ident1_span, dot_span, symbol2, ident2_span) => { - self.token = Token::new(token::Ident(symbol1, false), ident1_span); + self.token = Token::new(token::Ident(symbol1, IdentIsRaw::No), ident1_span); // This needs to be `Spacing::Alone` to prevent regressions. // See issue #76399 and PR #76285 for more details let next_token1 = (Token::new(token::Dot, dot_span), Spacing::Alone); let base1 = self.parse_expr_tuple_field_access(lo, base, symbol1, None, Some(next_token1)); - let next_token2 = Token::new(token::Ident(symbol2, false), ident2_span); + let next_token2 = Token::new(token::Ident(symbol2, IdentIsRaw::No), ident2_span); self.bump_with((next_token2, self.token_spacing)); // `.` self.parse_expr_tuple_field_access(lo, base1, symbol2, suffix, None) } @@ -1311,7 +1315,7 @@ impl<'a> Parser<'a> { let fields: Vec<_> = fields.into_iter().filter(|field| !field.is_shorthand).collect(); - if !fields.is_empty() && + let guar = if !fields.is_empty() && // `token.kind` should not be compared here. // This is because the `snapshot.token.kind` is treated as the same as // that of the open delim in `TokenTreesReader::parse_token_tree`, even @@ -1334,11 +1338,11 @@ impl<'a> Parser<'a> { .collect(), }, }) - .emit(); + .emit() } else { - err.emit(); - } - Ok(self.mk_expr_err(span)) + err.emit() + }; + Ok(self.mk_expr_err(span, guar)) } Ok(_) => Err(err), Err(err2) => { @@ -1555,7 +1559,7 @@ impl<'a> Parser<'a> { return Ok(self.recover_seq_parse_error(Delimiter::Parenthesis, lo, err)); } }; - let kind = if es.len() == 1 && !trailing_comma { + let kind = if es.len() == 1 && matches!(trailing_comma, Trailing::No) { // `(e)` is parenthesized `e`. ExprKind::Paren(es.into_iter().next().unwrap()) } else { @@ -1680,13 +1684,13 @@ impl<'a> Parser<'a> { && (self.check_noexpect(&TokenKind::Comma) || self.check_noexpect(&TokenKind::Gt)) { // We're probably inside of a `Path<'a>` that needs a turbofish - self.dcx().emit_err(errors::UnexpectedTokenAfterLabel { + let guar = self.dcx().emit_err(errors::UnexpectedTokenAfterLabel { span: self.token.span, remove_label: None, enclose_in_block: None, }); consume_colon = false; - Ok(self.mk_expr_err(lo)) + Ok(self.mk_expr_err(lo, guar)) } else { let mut err = errors::UnexpectedTokenAfterLabel { span: self.token.span, @@ -1755,7 +1759,7 @@ impl<'a> Parser<'a> { &self, ident: Ident, mk_lit_char: impl FnOnce(Symbol, Span) -> L, - err: impl FnOnce(&Self) -> DiagnosticBuilder<'a>, + err: impl FnOnce(&Self) -> Diag<'a>, ) -> L { assert!(could_be_unclosed_char_literal(ident)); if let Some(diag) = self.dcx().steal_diagnostic(ident.span, StashKey::LifetimeIsChar) { @@ -1946,7 +1950,7 @@ impl<'a> Parser<'a> { self.bump(); // `builtin` self.bump(); // `#` - let Some((ident, false)) = self.token.ident() else { + let Some((ident, IdentIsRaw::No)) = self.token.ident() else { let err = self.dcx().create_err(errors::ExpectedBuiltinIdent { span: self.token.span }); return Err(err); }; @@ -2035,7 +2039,7 @@ impl<'a> Parser<'a> { ) -> PResult<'a, L> { if let token::Interpolated(nt) = &self.token.kind && let token::NtExpr(e) | token::NtLiteral(e) = &nt.0 - && matches!(e.kind, ExprKind::Err) + && matches!(e.kind, ExprKind::Err(_)) { let mut err = self .dcx() @@ -2203,7 +2207,7 @@ impl<'a> Parser<'a> { let mut snapshot = self.create_snapshot_for_diagnostic(); match snapshot.parse_expr_array_or_repeat(Delimiter::Brace) { Ok(arr) => { - self.dcx().emit_err(errors::ArrayBracketsInsteadOfSpaces { + let guar = self.dcx().emit_err(errors::ArrayBracketsInsteadOfSpaces { span: arr.span, sub: errors::ArrayBracketsInsteadOfSpacesSugg { left: lo, @@ -2212,7 +2216,7 @@ impl<'a> Parser<'a> { }); self.restore_snapshot(snapshot); - Some(self.mk_expr_err(arr.span)) + Some(self.mk_expr_err(arr.span, guar)) } Err(e) => { e.cancel(); @@ -2366,7 +2370,10 @@ impl<'a> Parser<'a> { // It is likely that the closure body is a block but where the // braces have been removed. We will recover and eat the next // statements later in the parsing process. - body = self.mk_expr_err(body.span); + body = self.mk_expr_err( + body.span, + self.dcx().span_delayed_bug(body.span, "recovered a closure body as a block"), + ); } let body_span = body.span; @@ -2481,7 +2488,7 @@ impl<'a> Parser<'a> { ExprKind::Binary(Spanned { span: binop_span, .. }, _, right) if let ExprKind::Block(_, None) = right.kind => { - this.dcx().emit_err(errors::IfExpressionMissingThenBlock { + let guar = this.dcx().emit_err(errors::IfExpressionMissingThenBlock { if_span: lo, missing_then_block_sub: errors::IfExpressionMissingThenBlockSub::UnfinishedCondition( @@ -2489,14 +2496,14 @@ impl<'a> Parser<'a> { ), let_else_sub: None, }); - std::mem::replace(right, this.mk_expr_err(binop_span.shrink_to_hi())) + std::mem::replace(right, this.mk_expr_err(binop_span.shrink_to_hi(), guar)) } ExprKind::Block(_, None) => { - this.dcx().emit_err(errors::IfExpressionMissingCondition { + let guar = this.dcx().emit_err(errors::IfExpressionMissingCondition { if_span: lo.with_neighbor(cond.span).shrink_to_hi(), block_span: self.sess.source_map().start_point(cond_span), }); - std::mem::replace(&mut cond, this.mk_expr_err(cond_span.shrink_to_hi())) + std::mem::replace(&mut cond, this.mk_expr_err(cond_span.shrink_to_hi(), guar)) } _ => { return None; @@ -2516,14 +2523,14 @@ impl<'a> Parser<'a> { let let_else_sub = matches!(cond.kind, ExprKind::Let(..)) .then(|| errors::IfExpressionLetSomeSub { if_span: lo.until(cond_span) }); - self.dcx().emit_err(errors::IfExpressionMissingThenBlock { + let guar = self.dcx().emit_err(errors::IfExpressionMissingThenBlock { if_span: lo, missing_then_block_sub: errors::IfExpressionMissingThenBlockSub::AddThenBlock( cond_span.shrink_to_hi(), ), let_else_sub, }); - self.mk_block_err(cond_span.shrink_to_hi()) + self.mk_block_err(cond_span.shrink_to_hi(), guar) } } else { let attrs = self.parse_outer_attributes()?; // For recovery. @@ -2681,23 +2688,20 @@ impl<'a> Parser<'a> { branch_span: Span, attrs: AttrWrapper, ) { - if attrs.is_empty() { - return; + if !attrs.is_empty() + && let [x0 @ xn] | [x0, .., xn] = &*attrs.take_for_recovery(self.sess) + { + let attributes = x0.span.to(xn.span); + let last = xn.span; + let ctx = if is_ctx_else { "else" } else { "if" }; + self.dcx().emit_err(errors::OuterAttributeNotAllowedOnIfElse { + last, + branch_span, + ctx_span, + ctx: ctx.to_string(), + attributes, + }); } - - let attrs: &[ast::Attribute] = &attrs.take_for_recovery(self.sess); - let (attributes, last) = match attrs { - [] => return, - [x0 @ xn] | [x0, .., xn] => (x0.span.to(xn.span), xn.span), - }; - let ctx = if is_ctx_else { "else" } else { "if" }; - self.dcx().emit_err(errors::OuterAttributeNotAllowedOnIfElse { - last, - branch_span, - ctx_span, - ctx: ctx.to_string(), - attributes, - }); } fn error_on_extra_if(&mut self, cond: &P) -> PResult<'a, ()> { @@ -2793,9 +2797,10 @@ impl<'a> Parser<'a> { && !matches!(self.token.kind, token::OpenDelim(Delimiter::Brace)) && self.may_recover() { - self.dcx() + let guar = self + .dcx() .emit_err(errors::MissingExpressionInForLoop { span: expr.span.shrink_to_lo() }); - let err_expr = self.mk_expr(expr.span, ExprKind::Err); + let err_expr = self.mk_expr(expr.span, ExprKind::Err(guar)); let block = self.mk_block(thin_vec![], BlockCheckMode::Default, self.prev_token.span); return Ok(self.mk_expr( lo.to(self.prev_token.span), @@ -2920,7 +2925,7 @@ impl<'a> Parser<'a> { attrs: Default::default(), pat: self.mk_pat(span, ast::PatKind::Err(guar)), guard: None, - body: Some(self.mk_expr_err(span)), + body: Some(self.mk_expr_err(span, guar)), span, id: DUMMY_NODE_ID, is_placeholder: false, @@ -2955,7 +2960,7 @@ impl<'a> Parser<'a> { let err = |this: &Parser<'_>, stmts: Vec| { let span = stmts[0].span.to(stmts[stmts.len() - 1].span); - this.dcx().emit_err(errors::MatchArmBodyWithoutBraces { + let guar = this.dcx().emit_err(errors::MatchArmBodyWithoutBraces { statements: span, arrow: arrow_span, num_statements: stmts.len(), @@ -2968,7 +2973,7 @@ impl<'a> Parser<'a> { errors::MatchArmBodyWithoutBracesSugg::UseComma { semicolon: semi_sp } }, }); - this.mk_expr_err(span) + this.mk_expr_err(span, guar) }; // We might have either a `,` -> `;` typo, or a block without braces. We need // a more subtle parsing strategy. @@ -3087,10 +3092,10 @@ impl<'a> Parser<'a> { if !require_comma { arm_body = Some(expr); this.eat(&token::Comma); - Ok(false) + Ok(Recovered::No) } else if let Some(body) = this.parse_arm_body_missing_braces(&expr, arrow_span) { arm_body = Some(body); - Ok(true) + Ok(Recovered::Yes) } else { let expr_span = expr.span; arm_body = Some(expr); @@ -3171,7 +3176,7 @@ impl<'a> Parser<'a> { this.dcx().emit_err(errors::MissingCommaAfterMatchArm { span: arm_span.shrink_to_hi(), }); - return Ok(true); + return Ok(Recovered::Yes); } Err(err) }); @@ -3429,14 +3434,20 @@ impl<'a> Parser<'a> { pth: ast::Path, recover: bool, close_delim: Delimiter, - ) -> PResult<'a, (ThinVec, ast::StructRest, bool)> { + ) -> PResult< + 'a, + ( + ThinVec, + ast::StructRest, + Option, /* async blocks are forbidden in Rust 2015 */ + ), + > { let mut fields = ThinVec::new(); let mut base = ast::StructRest::None; - let mut recover_async = false; + let mut recovered_async = None; let in_if_guard = self.restrictions.contains(Restrictions::IN_IF_GUARD); - let mut async_block_err = |e: &mut DiagnosticBuilder<'_>, span: Span| { - recover_async = true; + let async_block_err = |e: &mut Diag<'_>, span: Span| { errors::AsyncBlockIn2015 { span }.add_to_diagnostic(e); errors::HelpUseLatestEdition::new().add_to_diagnostic(e); }; @@ -3461,9 +3472,34 @@ impl<'a> Parser<'a> { break; } - let recovery_field = self.find_struct_error_after_field_looking_code(); + // Peek the field's ident before parsing its expr in order to emit better diagnostics. + let peek = self + .token + .ident() + .filter(|(ident, is_raw)| { + (!ident.is_reserved() || matches!(is_raw, IdentIsRaw::Yes)) + && self.look_ahead(1, |tok| *tok == token::Colon) + }) + .map(|(ident, _)| ident); + + // We still want a field even if its expr didn't parse. + let field_ident = |this: &Self, guar: ErrorGuaranteed| { + peek.map(|ident| { + let span = ident.span; + ExprField { + ident, + span, + expr: this.mk_expr_err(span, guar), + is_shorthand: false, + attrs: AttrVec::new(), + id: DUMMY_NODE_ID, + is_placeholder: false, + } + }) + }; + let parsed_field = match self.parse_expr_field() { - Ok(f) => Some(f), + Ok(f) => Ok(f), Err(mut e) => { if pth == kw::Async { async_block_err(&mut e, pth.span); @@ -3495,7 +3531,10 @@ impl<'a> Parser<'a> { return Err(e); } - e.emit(); + let guar = e.emit(); + if pth == kw::Async { + recovered_async = Some(guar); + } // If the next token is a comma, then try to parse // what comes next as additional fields, rather than @@ -3507,18 +3546,20 @@ impl<'a> Parser<'a> { } } - None + Err(guar) } }; - let is_shorthand = parsed_field.as_ref().is_some_and(|f| f.is_shorthand); + let is_shorthand = parsed_field.as_ref().is_ok_and(|f| f.is_shorthand); // A shorthand field can be turned into a full field with `:`. // We should point this out. self.check_or_expected(!is_shorthand, TokenType::Token(token::Colon)); match self.expect_one_of(&[token::Comma], &[token::CloseDelim(close_delim)]) { Ok(_) => { - if let Some(f) = parsed_field.or(recovery_field) { + if let Some(f) = + parsed_field.or_else(|guar| field_ident(self, guar).ok_or(guar)).ok() + { // Only include the field if there's no parse error for the field name. fields.push(f); } @@ -3528,8 +3569,7 @@ impl<'a> Parser<'a> { async_block_err(&mut e, pth.span); } else { e.span_label(pth.span, "while parsing this struct"); - if let Some(f) = recovery_field { - fields.push(f); + if peek.is_some() { e.span_suggestion( self.prev_token.span.shrink_to_hi(), "try adding a comma", @@ -3541,13 +3581,18 @@ impl<'a> Parser<'a> { if !recover { return Err(e); } - e.emit(); + let guar = e.emit(); + if pth == kw::Async { + recovered_async = Some(guar); + } else if let Some(f) = field_ident(self, guar) { + fields.push(f); + } self.recover_stmt_(SemiColonMode::Comma, BlockMode::Ignore); self.eat(&token::Comma); } } } - Ok((fields, base, recover_async)) + Ok((fields, base, recovered_async)) } /// Precondition: already parsed the '{'. @@ -3558,39 +3603,18 @@ impl<'a> Parser<'a> { recover: bool, ) -> PResult<'a, P> { let lo = pth.span; - let (fields, base, recover_async) = + let (fields, base, recovered_async) = self.parse_struct_fields(pth.clone(), recover, Delimiter::Brace)?; let span = lo.to(self.token.span); self.expect(&token::CloseDelim(Delimiter::Brace))?; - let expr = if recover_async { - ExprKind::Err + let expr = if let Some(guar) = recovered_async { + ExprKind::Err(guar) } else { ExprKind::Struct(P(ast::StructExpr { qself, path: pth, fields, rest: base })) }; Ok(self.mk_expr(span, expr)) } - /// Use in case of error after field-looking code: `S { foo: () with a }`. - fn find_struct_error_after_field_looking_code(&self) -> Option { - match self.token.ident() { - Some((ident, is_raw)) - if (is_raw || !ident.is_reserved()) - && self.look_ahead(1, |t| *t == token::Colon) => - { - Some(ast::ExprField { - ident, - span: self.token.span, - expr: self.mk_expr_err(self.token.span), - is_shorthand: false, - attrs: AttrVec::new(), - id: DUMMY_NODE_ID, - is_placeholder: false, - }) - } - _ => None, - } - } - fn recover_struct_comma_after_dotdot(&mut self, span: Span) { if self.token != token::Comma { return; @@ -3714,8 +3738,8 @@ impl<'a> Parser<'a> { limits: RangeLimits, ) -> ExprKind { if end.is_none() && limits == RangeLimits::Closed { - self.inclusive_range_with_incorrect_end(); - ExprKind::Err + let guar = self.inclusive_range_with_incorrect_end(); + ExprKind::Err(guar) } else { ExprKind::Range(start, end, limits) } @@ -3752,8 +3776,8 @@ impl<'a> Parser<'a> { self.mk_expr_with_attrs(span, kind, AttrVec::new()) } - pub(super) fn mk_expr_err(&self, span: Span) -> P { - self.mk_expr(span, ExprKind::Err) + pub(super) fn mk_expr_err(&self, span: Span, guar: ErrorGuaranteed) -> P { + self.mk_expr(span, ExprKind::Err(guar)) } /// Create expression span ensuring the span of the parent node @@ -3945,7 +3969,8 @@ impl MutVisitor for CondChecker<'_> { | ExprKind::Become(_) | ExprKind::IncludedBytes(_) | ExprKind::FormatArgs(_) - | ExprKind::Err => { + | ExprKind::Err(_) + | ExprKind::Dummy => { // These would forbid any let expressions they contain already. } } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 77381ef46262f..a678194372e9b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1,8 +1,12 @@ use super::diagnostics::{dummy_arg, ConsumeClosingDelim}; use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; -use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken}; +use super::{ + AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Recovered, Trailing, + TrailingToken, +}; use crate::errors::{self, MacroExpandsToAdtField}; use crate::fluent_generated as fluent; +use ast::token::IdentIsRaw; use rustc_ast::ast::*; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, TokenKind}; @@ -1076,7 +1080,7 @@ impl<'a> Parser<'a> { fn parse_ident_or_underscore(&mut self) -> PResult<'a, Ident> { match self.token.ident() { - Some((ident @ Ident { name: kw::Underscore, .. }, false)) => { + Some((ident @ Ident { name: kw::Underscore, .. }, IdentIsRaw::No)) => { self.bump(); Ok(ident) } @@ -1453,7 +1457,7 @@ impl<'a> Parser<'a> { let (variants, _) = if self.token == TokenKind::Semi { self.dcx().emit_err(errors::UseEmptyBlockNotSemi { span: self.token.span }); self.bump(); - (thin_vec![], false) + (thin_vec![], Trailing::No) } else { self.parse_delim_comma_seq(Delimiter::Brace, |p| p.parse_enum_variant(id.span)) .map_err(|mut err| { @@ -1530,10 +1534,10 @@ impl<'a> Parser<'a> { err.span_label(span, "while parsing this enum"); err.help(help); err.emit(); - (thin_vec![], true) + (thin_vec![], Recovered::Yes) } }; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } else if this.check(&token::OpenDelim(Delimiter::Parenthesis)) { let body = match this.parse_tuple_struct_body() { Ok(body) => body, @@ -1618,7 +1622,7 @@ impl<'a> Parser<'a> { class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } // No `where` so: `struct Foo;` } else if self.eat(&token::Semi) { @@ -1630,7 +1634,7 @@ impl<'a> Parser<'a> { class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } // Tuple-style struct definition with optional where-clause. } else if self.token == token::OpenDelim(Delimiter::Parenthesis) { let body = VariantData::Tuple(self.parse_tuple_struct_body()?, DUMMY_NODE_ID); @@ -1659,14 +1663,14 @@ impl<'a> Parser<'a> { class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } else if self.token == token::OpenDelim(Delimiter::Brace) { let (fields, recovered) = self.parse_record_struct_body( "union", class_name.span, generics.where_clause.has_where_token, )?; - VariantData::Struct { fields, recovered } + VariantData::Struct { fields, recovered: recovered.into() } } else { let token_str = super::token_descr(&self.token); let msg = format!("expected `where` or `{{` after union name, found {token_str}"); @@ -1683,14 +1687,14 @@ impl<'a> Parser<'a> { adt_ty: &str, ident_span: Span, parsed_where: bool, - ) -> PResult<'a, (ThinVec, /* recovered */ bool)> { + ) -> PResult<'a, (ThinVec, Recovered)> { let mut fields = ThinVec::new(); - let mut recovered = false; + let mut recovered = Recovered::No; if self.eat(&token::OpenDelim(Delimiter::Brace)) { while self.token != token::CloseDelim(Delimiter::Brace) { let field = self.parse_field_def(adt_ty).map_err(|e| { self.consume_block(Delimiter::Brace, ConsumeClosingDelim::No); - recovered = true; + recovered = Recovered::Yes; e }); match field { @@ -1962,7 +1966,7 @@ impl<'a> Parser<'a> { let (ident, is_raw) = self.ident_or_err(true)?; if ident.name == kw::Underscore { self.sess.gated_spans.gate(sym::unnamed_fields, lo); - } else if !is_raw && ident.is_reserved() { + } else if matches!(is_raw, IdentIsRaw::No) && ident.is_reserved() { let snapshot = self.create_snapshot_for_diagnostic(); let err = if self.check_fn_front_matter(false, Case::Sensitive) { let inherited_vis = Visibility { @@ -2324,11 +2328,11 @@ impl<'a> Parser<'a> { let _ = self.parse_expr()?; self.expect_semi()?; // `;` let span = eq_sp.to(self.prev_token.span); - self.dcx().emit_err(errors::FunctionBodyEqualsExpr { + let guar = self.dcx().emit_err(errors::FunctionBodyEqualsExpr { span, sugg: errors::FunctionBodyEqualsExprSugg { eq: eq_sp, semi: self.prev_token.span }, }); - (AttrVec::new(), Some(self.mk_block_err(span))) + (AttrVec::new(), Some(self.mk_block_err(span, guar))) } else { let expected = if req_body { &[token::OpenDelim(Delimiter::Brace)][..] @@ -2461,8 +2465,8 @@ impl<'a> Parser<'a> { // `self.expected_tokens`, therefore, do not use `self.unexpected()` which doesn't // account for this. match self.expect_one_of(&[], &[]) { - Ok(true) => {} - Ok(false) => unreachable!(), + Ok(Recovered::Yes) => {} + Ok(Recovered::No) => unreachable!(), Err(mut err) => { // Qualifier keywords ordering check enum WrongKw { @@ -2740,7 +2744,7 @@ impl<'a> Parser<'a> { fn parse_self_param(&mut self) -> PResult<'a, Option> { // Extract an identifier *after* having confirmed that the token is one. let expect_self_ident = |this: &mut Self| match this.token.ident() { - Some((ident, false)) => { + Some((ident, IdentIsRaw::No)) => { this.bump(); ident } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index dea2b9e6ca70b..8542ea6231038 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -11,6 +11,7 @@ mod stmt; mod ty; use crate::lexer::UnmatchedDelim; +use ast::token::IdentIsRaw; pub use attr_wrapper::AttrWrapper; pub use diagnostics::AttemptLocalParseRecovery; pub(crate) use expr::ForbiddenLetReason; @@ -32,7 +33,7 @@ use rustc_ast::{HasAttrs, HasTokens, Unsafe, Visibility, VisibilityKind}; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashMap; use rustc_errors::PResult; -use rustc_errors::{Applicability, DiagnosticBuilder, FatalError, MultiSpan}; +use rustc_errors::{Applicability, Diag, FatalError, MultiSpan}; use rustc_session::parse::ParseSess; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; @@ -357,6 +358,25 @@ pub enum FollowedByType { No, } +/// Whether a function performed recovery +#[derive(Copy, Clone, Debug)] +pub enum Recovered { + No, + Yes, +} + +impl From for bool { + fn from(r: Recovered) -> bool { + matches!(r, Recovered::Yes) + } +} + +#[derive(Copy, Clone, Debug)] +pub enum Trailing { + No, + Yes, +} + #[derive(Clone, Copy, PartialEq, Eq)] pub enum TokenDescription { ReservedIdentifier, @@ -455,11 +475,11 @@ impl<'a> Parser<'a> { } /// Expects and consumes the token `t`. Signals an error if the next token is not `t`. - pub fn expect(&mut self, t: &TokenKind) -> PResult<'a, bool /* recovered */> { + pub fn expect(&mut self, t: &TokenKind) -> PResult<'a, Recovered> { if self.expected_tokens.is_empty() { if self.token == *t { self.bump(); - Ok(false) + Ok(Recovered::No) } else { self.unexpected_try_recover(t) } @@ -475,13 +495,13 @@ impl<'a> Parser<'a> { &mut self, edible: &[TokenKind], inedible: &[TokenKind], - ) -> PResult<'a, bool /* recovered */> { + ) -> PResult<'a, Recovered> { if edible.contains(&self.token.kind) { self.bump(); - Ok(false) + Ok(Recovered::No) } else if inedible.contains(&self.token.kind) { // leave it in the input - Ok(false) + Ok(Recovered::No) } else if self.token.kind != token::Eof && self.last_unexpected_token_span == Some(self.token.span) { @@ -499,7 +519,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> { let (ident, is_raw) = self.ident_or_err(recover)?; - if !is_raw && ident.is_reserved() { + if matches!(is_raw, IdentIsRaw::No) && ident.is_reserved() { let err = self.expected_ident_found_err(); if recover { err.emit(); @@ -511,7 +531,7 @@ impl<'a> Parser<'a> { Ok(ident) } - fn ident_or_err(&mut self, recover: bool) -> PResult<'a, (Ident, /* is_raw */ bool)> { + fn ident_or_err(&mut self, recover: bool) -> PResult<'a, (Ident, IdentIsRaw)> { match self.token.ident() { Some(ident) => Ok(ident), None => self.expected_ident_found(recover), @@ -568,7 +588,7 @@ impl<'a> Parser<'a> { } if case == Case::Insensitive - && let Some((ident, /* is_raw */ false)) = self.token.ident() + && let Some((ident, IdentIsRaw::No)) = self.token.ident() && ident.as_str().to_lowercase() == kw.as_str().to_lowercase() { true @@ -598,7 +618,7 @@ impl<'a> Parser<'a> { } if case == Case::Insensitive - && let Some((ident, /* is_raw */ false)) = self.token.ident() + && let Some((ident, IdentIsRaw::No)) = self.token.ident() && ident.as_str().to_lowercase() == kw.as_str().to_lowercase() { self.dcx().emit_err(errors::KwBadCase { span: ident.span, kw: kw.as_str() }); @@ -783,10 +803,10 @@ impl<'a> Parser<'a> { sep: SeqSep, expect: TokenExpectType, mut f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */, bool /* recovered */)> { + ) -> PResult<'a, (ThinVec, Trailing, Recovered)> { let mut first = true; - let mut recovered = false; - let mut trailing = false; + let mut recovered = Recovered::No; + let mut trailing = Trailing::No; let mut v = ThinVec::new(); while !self.expect_any_with_type(kets, expect) { @@ -800,12 +820,12 @@ impl<'a> Parser<'a> { } else { // check for separator match self.expect(t) { - Ok(false) /* not recovered */ => { + Ok(Recovered::No) => { self.current_closure.take(); } - Ok(true) /* recovered */ => { + Ok(Recovered::Yes) => { self.current_closure.take(); - recovered = true; + recovered = Recovered::Yes; break; } Err(mut expect_err) => { @@ -900,7 +920,7 @@ impl<'a> Parser<'a> { } } if sep.trailing_sep_allowed && self.expect_any_with_type(kets, expect) { - trailing = true; + trailing = Trailing::Yes; break; } @@ -914,7 +934,7 @@ impl<'a> Parser<'a> { fn recover_missing_braces_around_closure_body( &mut self, closure_spans: ClosureSpans, - mut expect_err: DiagnosticBuilder<'_>, + mut expect_err: Diag<'_>, ) -> PResult<'a, ()> { let initial_semicolon = self.token.span; @@ -978,7 +998,7 @@ impl<'a> Parser<'a> { ket: &TokenKind, sep: SeqSep, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */, bool /* recovered */)> { + ) -> PResult<'a, (ThinVec, Trailing, Recovered)> { self.parse_seq_to_before_tokens(&[ket], sep, TokenExpectType::Expect, f) } @@ -990,9 +1010,9 @@ impl<'a> Parser<'a> { ket: &TokenKind, sep: SeqSep, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?; - if !recovered { + if matches!(recovered, Recovered::No) { self.eat(ket); } Ok((val, trailing)) @@ -1007,7 +1027,7 @@ impl<'a> Parser<'a> { ket: &TokenKind, sep: SeqSep, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { self.expect(bra)?; self.parse_seq_to_end(ket, sep, f) } @@ -1019,7 +1039,7 @@ impl<'a> Parser<'a> { &mut self, delim: Delimiter, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { self.parse_unspanned_seq( &token::OpenDelim(delim), &token::CloseDelim(delim), @@ -1034,7 +1054,7 @@ impl<'a> Parser<'a> { fn parse_paren_comma_seq( &mut self, f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, - ) -> PResult<'a, (ThinVec, bool /* trailing */)> { + ) -> PResult<'a, (ThinVec, Trailing)> { self.parse_delim_comma_seq(Delimiter::Parenthesis, f) } @@ -1502,7 +1522,7 @@ impl<'a> Parser<'a> { pub(crate) fn make_unclosed_delims_error( unmatched: UnmatchedDelim, sess: &ParseSess, -) -> Option> { +) -> Option> { // `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to // `unmatched_delims` only for error recovery in the `Parser`. let found_delim = unmatched.found_delim?; diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 071d6b72f3b96..f1572a18a8be0 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -201,6 +201,6 @@ impl<'a> Parser<'a> { /// The token is an identifier, but not `_`. /// We prohibit passing `_` to macros expecting `ident` for now. -fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { +fn get_macro_ident(token: &Token) -> Option<(Ident, token::IdentIsRaw)> { token.ident().filter(|(ident, _)| ident.name != kw::Underscore) } diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 75fc013d3e6fe..7aeab6488a5ea 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -1,4 +1,4 @@ -use super::{ForceCollect, Parser, PathStyle, Restrictions, TrailingToken}; +use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing, TrailingToken}; use crate::errors::{ self, AmbiguousRangePattern, DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed, DotDotDotRestPattern, EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt, @@ -20,7 +20,7 @@ use rustc_ast::{ PatField, PatFieldsRest, PatKind, Path, QSelf, RangeEnd, RangeSyntax, }; use rustc_ast_pretty::pprust; -use rustc_errors::{Applicability, DiagnosticBuilder, PResult}; +use rustc_errors::{Applicability, Diag, PResult}; use rustc_session::errors::ExprParenthesesNeeded; use rustc_span::source_map::{respan, Spanned}; use rustc_span::symbol::{kw, sym, Ident}; @@ -311,7 +311,7 @@ impl<'a> Parser<'a> { matches!( &token.uninterpolate().kind, token::FatArrow // e.g. `a | => 0,`. - | token::Ident(kw::If, false) // e.g. `a | if expr`. + | token::Ident(kw::If, token::IdentIsRaw::No) // e.g. `a | if expr`. | token::Eq // e.g. `let a | = 0`. | token::Semi // e.g. `let a |;`. | token::Colon // e.g. `let a | :`. @@ -388,7 +388,7 @@ impl<'a> Parser<'a> { // Parse `?`, `.f`, `(arg0, arg1, ...)` or `[expr]` until they've all been eaten. if let Ok(expr) = snapshot .parse_expr_dot_or_call_with( - self.mk_expr_err(pat_span), // equivalent to transforming the parsed pattern into an `Expr` + self.mk_expr(pat_span, ExprKind::Dummy), // equivalent to transforming the parsed pattern into an `Expr` pat_span, AttrVec::new(), ) @@ -566,7 +566,7 @@ impl<'a> Parser<'a> { match self.parse_literal_maybe_minus() { Ok(begin) => { let begin = match self.maybe_recover_trailing_expr(begin.span, false) { - Some(_) => self.mk_expr_err(begin.span), + Some(guar) => self.mk_expr_err(begin.span, guar), None => begin, }; @@ -696,7 +696,9 @@ impl<'a> Parser<'a> { // Here, `(pat,)` is a tuple pattern. // For backward compatibility, `(..)` is a tuple pattern as well. - Ok(if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) { + let paren_pattern = + fields.len() == 1 && !(matches!(trailing_comma, Trailing::Yes) || fields[0].is_rest()); + if paren_pattern { let pat = fields.into_iter().next().unwrap(); let close_paren = self.prev_token.span; @@ -714,10 +716,10 @@ impl<'a> Parser<'a> { }, }); - self.parse_pat_range_begin_with(begin.clone(), form)? + self.parse_pat_range_begin_with(begin.clone(), form) } // recover ranges with parentheses around the `(start)..` - PatKind::Err(_) + PatKind::Err(guar) if self.may_recover() && let Some(form) = self.parse_range_end() => { @@ -729,15 +731,15 @@ impl<'a> Parser<'a> { }, }); - self.parse_pat_range_begin_with(self.mk_expr(pat.span, ExprKind::Err), form)? + self.parse_pat_range_begin_with(self.mk_expr_err(pat.span, *guar), form) } // (pat) with optional parentheses - _ => PatKind::Paren(pat), + _ => Ok(PatKind::Paren(pat)), } } else { - PatKind::Tuple(fields) - }) + Ok(PatKind::Tuple(fields)) + } } /// Parse a mutable binding with the `mut` token already eaten. @@ -830,7 +832,7 @@ impl<'a> Parser<'a> { fn fatal_unexpected_non_pat( &mut self, - err: DiagnosticBuilder<'a>, + err: Diag<'a>, expected: Option, ) -> PResult<'a, P> { err.cancel(); @@ -884,7 +886,7 @@ impl<'a> Parser<'a> { Ok(PatKind::Range(Some(begin), end, re)) } - pub(super) fn inclusive_range_with_incorrect_end(&mut self) { + pub(super) fn inclusive_range_with_incorrect_end(&mut self) -> ErrorGuaranteed { let tok = &self.token; let span = self.prev_token.span; // If the user typed "..==" instead of "..=", we want to give them @@ -903,15 +905,13 @@ impl<'a> Parser<'a> { let _ = self.parse_pat_range_end().map_err(|e| e.cancel()); } - self.dcx().emit_err(InclusiveRangeExtraEquals { span: span_with_eq }); + self.dcx().emit_err(InclusiveRangeExtraEquals { span: span_with_eq }) } token::Gt if no_space => { let after_pat = span.with_hi(span.hi() - rustc_span::BytePos(1)).shrink_to_hi(); - self.dcx().emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span, after_pat }); - } - _ => { - self.dcx().emit_err(InclusiveRangeNoEnd { span }); + self.dcx().emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span, after_pat }) } + _ => self.dcx().emit_err(InclusiveRangeNoEnd { span }), } } @@ -985,7 +985,7 @@ impl<'a> Parser<'a> { } Ok(match recovered { - Some(_) => self.mk_expr_err(bound.span), + Some(guar) => self.mk_expr_err(bound.span, guar), None => bound, }) } @@ -1153,7 +1153,7 @@ impl<'a> Parser<'a> { let mut fields = ThinVec::new(); let mut etc = PatFieldsRest::None; let mut ate_comma = true; - let mut delayed_err: Option> = None; + let mut delayed_err: Option> = None; let mut first_etc_and_maybe_comma_span = None; let mut last_non_comma_dotdot_span = None; @@ -1316,11 +1316,7 @@ impl<'a> Parser<'a> { /// If the user writes `S { ref field: name }` instead of `S { field: ref name }`, we suggest /// the correct code. - fn recover_misplaced_pattern_modifiers( - &self, - fields: &ThinVec, - err: &mut DiagnosticBuilder<'a>, - ) { + fn recover_misplaced_pattern_modifiers(&self, fields: &ThinVec, err: &mut Diag<'a>) { if let Some(last) = fields.iter().last() && last.is_shorthand && let PatKind::Ident(binding, ident, None) = last.pat.kind diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 681039999a652..6e7bbe7e06d42 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -2,6 +2,7 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; use crate::errors::PathSingleColon; use crate::{errors, maybe_whole}; +use ast::token::IdentIsRaw; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token, TokenKind}; use rustc_ast::{ @@ -390,7 +391,7 @@ impl<'a> Parser<'a> { pub(super) fn parse_path_segment_ident(&mut self) -> PResult<'a, Ident> { match self.token.ident() { - Some((ident, false)) if ident.is_path_segment_keyword() => { + Some((ident, IdentIsRaw::No)) if ident.is_path_segment_keyword() => { self.bump(); Ok(ident) } diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 1bae5b3224035..9fe74e80a2b5e 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -11,6 +11,7 @@ use crate::errors; use crate::maybe_whole; use crate::errors::MalformedLoopLabel; +use crate::parser::Recovered; use ast::Label; use rustc_ast as ast; use rustc_ast::ptr::P; @@ -19,9 +20,9 @@ use rustc_ast::util::classify; use rustc_ast::{AttrStyle, AttrVec, LocalKind, MacCall, MacCallStmt, MacStmtStyle}; use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Stmt}; use rustc_ast::{StmtKind, DUMMY_NODE_ID}; -use rustc_errors::{Applicability, DiagnosticBuilder, PResult}; +use rustc_errors::{Applicability, Diag, PResult}; use rustc_span::symbol::{kw, sym, Ident}; -use rustc_span::{BytePos, Span}; +use rustc_span::{BytePos, ErrorGuaranteed, Span}; use std::borrow::Cow; use std::mem; @@ -229,8 +230,7 @@ impl<'a> Parser<'a> { /// Also error if the previous token was a doc comment. fn error_outer_attrs(&self, attrs: AttrWrapper) { if !attrs.is_empty() - && let attrs = attrs.take_for_recovery(self.sess) - && let attrs @ [.., last] = &*attrs + && let attrs @ [.., last] = &*attrs.take_for_recovery(self.sess) { if last.is_doc_comment() { self.dcx().emit_err(errors::DocCommentDoesNotDocumentAnything { @@ -447,10 +447,7 @@ impl<'a> Parser<'a> { Ok(block) } - fn error_block_no_opening_brace_msg( - &mut self, - msg: Cow<'static, str>, - ) -> DiagnosticBuilder<'a> { + fn error_block_no_opening_brace_msg(&mut self, msg: Cow<'static, str>) -> Diag<'a> { let sp = self.token.span; let mut e = self.dcx().struct_span_err(sp, msg); let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon; @@ -609,9 +606,9 @@ impl<'a> Parser<'a> { } } - err.emit(); + let guar = err.emit(); self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); - Some(self.mk_stmt_err(self.token.span)) + Some(self.mk_stmt_err(self.token.span, guar)) } Ok(stmt) => stmt, Err(err) => return Err(err), @@ -650,10 +647,10 @@ impl<'a> Parser<'a> { .contains(&self.token.kind) => { // The user has written `#[attr] expr` which is unsupported. (#106020) - self.attr_on_non_tail_expr(&expr); + let guar = self.attr_on_non_tail_expr(&expr); // We already emitted an error, so don't emit another type error let sp = expr.span.to(self.prev_token.span); - *expr = self.mk_expr_err(sp); + *expr = self.mk_expr_err(sp, guar); } // Expression without semicolon. @@ -661,15 +658,22 @@ impl<'a> Parser<'a> { if self.token != token::Eof && classify::expr_requires_semi_to_be_stmt(expr) => { // Just check for errors and recover; do not eat semicolon yet. - // `expect_one_of` returns PResult<'a, bool /* recovered */> let expect_result = self.expect_one_of(&[], &[token::Semi, token::CloseDelim(Delimiter::Brace)]); + // Try to both emit a better diagnostic, and avoid further errors by replacing + // the `expr` with `ExprKind::Err`. let replace_with_err = 'break_recover: { match expect_result { - // Recover from parser, skip type error to avoid extra errors. - Ok(true) => true, + Ok(Recovered::No) => None, + Ok(Recovered::Yes) => { + // Skip type error to avoid extra errors. + let guar = self + .dcx() + .span_delayed_bug(self.prev_token.span, "expected `;` or `}`"); + Some(guar) + } Err(e) => { if self.recover_colon_as_semi() { // recover_colon_as_semi has already emitted a nicer error. @@ -677,7 +681,7 @@ impl<'a> Parser<'a> { add_semi_to_stmt = true; eat_semi = false; - break 'break_recover false; + break 'break_recover None; } match &expr.kind { @@ -691,7 +695,7 @@ impl<'a> Parser<'a> { token.kind, token::Ident( kw::For | kw::Loop | kw::While, - false + token::IdentIsRaw::No ) | token::OpenDelim(Delimiter::Brace) ) }) @@ -705,13 +709,13 @@ impl<'a> Parser<'a> { }; match self.parse_expr_labeled(label, false) { Ok(labeled_expr) => { - e.delay_as_bug(); + e.cancel(); self.dcx().emit_err(MalformedLoopLabel { span: label.ident.span, correct_label: label.ident, }); *expr = labeled_expr; - break 'break_recover false; + break 'break_recover None; } Err(err) => { err.cancel(); @@ -723,26 +727,26 @@ impl<'a> Parser<'a> { _ => {} } - if let Err(e) = - self.check_mistyped_turbofish_with_multiple_type_params(e, expr) - { - if recover.no() { - return Err(e); - } - e.emit(); - self.recover_stmt(); - } - - true + let res = + self.check_mistyped_turbofish_with_multiple_type_params(e, expr); + + Some(if recover.no() { + res? + } else { + res.unwrap_or_else(|e| { + let guar = e.emit(); + self.recover_stmt(); + guar + }) + }) } - Ok(false) => false, } }; - if replace_with_err { + if let Some(guar) = replace_with_err { // We already emitted an error, so don't emit another type error let sp = expr.span.to(self.prev_token.span); - *expr = self.mk_expr_err(sp); + *expr = self.mk_expr_err(sp, guar); } } StmtKind::Expr(_) | StmtKind::MacCall(_) => {} @@ -791,11 +795,11 @@ impl<'a> Parser<'a> { Stmt { id: DUMMY_NODE_ID, kind, span } } - pub(super) fn mk_stmt_err(&self, span: Span) -> Stmt { - self.mk_stmt(span, StmtKind::Expr(self.mk_expr_err(span))) + pub(super) fn mk_stmt_err(&self, span: Span, guar: ErrorGuaranteed) -> Stmt { + self.mk_stmt(span, StmtKind::Expr(self.mk_expr_err(span, guar))) } - pub(super) fn mk_block_err(&self, span: Span) -> P { - self.mk_block(thin_vec![self.mk_stmt_err(span)], BlockCheckMode::Default, span) + pub(super) fn mk_block_err(&self, span: Span, guar: ErrorGuaranteed) -> P { + self.mk_block(thin_vec![self.mk_stmt_err(span, guar)], BlockCheckMode::Default, span) } } diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 23a92e6dd3dd3..e3fe535bd5f8d 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -1,4 +1,4 @@ -use super::{Parser, PathStyle, TokenType}; +use super::{Parser, PathStyle, TokenType, Trailing}; use crate::errors::{ self, DynAfterMut, ExpectedFnPathFoundFnKeyword, ExpectedMutOrConstInRawPointerType, @@ -415,7 +415,7 @@ impl<'a> Parser<'a> { Ok(ty) })?; - if ts.len() == 1 && !trailing { + if ts.len() == 1 && matches!(trailing, Trailing::No) { let ty = ts.into_iter().next().unwrap().into_inner(); let maybe_bounds = allow_plus == AllowPlus::Yes && self.token.is_like_plus(); match ty.kind { diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index b0982029657bc..73c92708eb39c 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -88,9 +88,9 @@ pub fn parse_meta<'a>(sess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Meta // results in `ast::ExprKind::Err`. In that case we delay // the error because an earlier error will have already // been reported. - let msg = format!("attribute value must be a literal"); + let msg = "attribute value must be a literal"; let mut err = sess.dcx.struct_span_err(expr.span, msg); - if let ast::ExprKind::Err = expr.kind { + if let ast::ExprKind::Err(_) = expr.kind { err.downgrade_to_delayed_bug(); } return Err(err); diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 648ef9d51deaa..c223b8475288b 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -187,7 +187,7 @@ passes_doc_attr_not_crate_level = `#![doc({$attr_name} = "...")]` isn't allowed as a crate-level attribute passes_doc_cfg_hide_takes_list = - `#[doc(cfg_hide(...)]` takes a list of attributes + `#[doc(cfg_hide(...))]` takes a list of attributes passes_doc_expect_str = doc {$attr_name} attribute expects a string: #[doc({$attr_name} = "a")] diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d8ae82d11bcf4..c12d35ec73c99 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -80,7 +80,7 @@ pub(crate) enum ProcMacroKind { } impl IntoDiagnosticArg for ProcMacroKind { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { match self { ProcMacroKind::Attribute => "attribute proc macro", ProcMacroKind::Derive => "derive proc macro", @@ -1389,7 +1389,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { if target == Target::ForeignMod && let hir::Node::Item(item) = self.tcx.hir_node(hir_id) && let Item { kind: ItemKind::ForeignMod { abi, .. }, .. } = item - && !matches!(abi, Abi::Rust | Abi::RustIntrinsic | Abi::PlatformIntrinsic) + && !matches!(abi, Abi::Rust | Abi::RustIntrinsic) { return; } @@ -2071,7 +2071,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { ) -> bool { if let Target::ForeignFn = target && let hir::Node::Item(Item { - kind: ItemKind::ForeignMod { abi: Abi::RustIntrinsic | Abi::PlatformIntrinsic, .. }, + kind: ItemKind::ForeignMod { abi: Abi::RustIntrinsic, .. }, .. }) = self.tcx.parent_hir_node(hir_id) { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 982def54d3077..5f412bde2eec1 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -6,8 +6,8 @@ use std::{ use crate::fluent_generated as fluent; use rustc_ast::Label; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DiagCtxt, DiagnosticBuilder, DiagnosticSymbolList, - EmissionGuarantee, IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, DiagSymbolList, EmissionGuarantee, + IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessageOp, }; use rustc_hir::{self as hir, ExprKind, Target}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; @@ -864,9 +864,8 @@ pub struct ItemFollowingInnerAttr { impl IntoDiagnostic<'_, G> for InvalidAttrAtCrateLevel { #[track_caller] - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = - DiagnosticBuilder::new(dcx, level, fluent::passes_invalid_attr_at_crate_level); + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::passes_invalid_attr_at_crate_level); diag.span(self.span); diag.arg("name", self.name); // Only emit an error with a suggestion if we can create a string out @@ -1015,8 +1014,8 @@ pub struct BreakNonLoop<'a> { impl<'a, G: EmissionGuarantee> IntoDiagnostic<'_, G> for BreakNonLoop<'a> { #[track_caller] - fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::passes_break_non_loop); + fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::passes_break_non_loop); diag.span(self.span); diag.code(E0571); diag.arg("kind", self.kind); @@ -1159,8 +1158,8 @@ pub struct NakedFunctionsAsmBlock { impl IntoDiagnostic<'_, G> for NakedFunctionsAsmBlock { #[track_caller] - fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::passes_naked_functions_asm_block); + fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::passes_naked_functions_asm_block); diag.span(self.span); diag.code(E0787); for span in self.multiple_asms.iter() { @@ -1270,8 +1269,8 @@ pub struct NoMainErr { impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for NoMainErr { #[track_caller] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { - let mut diag = DiagnosticBuilder::new(dcx, level, fluent::passes_no_main_function); + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { + let mut diag = Diag::new(dcx, level, fluent::passes_no_main_function); diag.span(DUMMY_SP); diag.code(E0601); diag.arg("crate_name", self.crate_name); @@ -1328,8 +1327,8 @@ pub struct DuplicateLangItem { impl IntoDiagnostic<'_, G> for DuplicateLangItem { #[track_caller] - fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = DiagnosticBuilder::new( + fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new( dcx, level, match self.duplicate { @@ -1566,7 +1565,7 @@ pub enum MultipleDeadCodes<'tcx> { num: usize, descr: &'tcx str, participle: &'tcx str, - name_list: DiagnosticSymbolList, + name_list: DiagSymbolList, #[subdiagnostic] parent_info: Option>, #[subdiagnostic] @@ -1578,7 +1577,7 @@ pub enum MultipleDeadCodes<'tcx> { num: usize, descr: &'tcx str, participle: &'tcx str, - name_list: DiagnosticSymbolList, + name_list: DiagSymbolList, #[subdiagnostic] change_fields_suggestion: ChangeFieldsToBeOfUnitType, #[subdiagnostic] @@ -1602,7 +1601,7 @@ pub struct ParentInfo<'tcx> { #[note(passes_ignored_derived_impls)] pub struct IgnoredDerivedImpls { pub name: Symbol, - pub trait_list: DiagnosticSymbolList, + pub trait_list: DiagSymbolList, pub trait_list_len: usize, } @@ -1755,7 +1754,7 @@ pub struct UnusedVariableStringInterp { impl AddToDiagnostic for UnusedVariableStringInterp { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { diag.span_label(self.lit, crate::fluent_generated::passes_maybe_string_interpolation); diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs index 96429bb778882..be6ba585d2004 100644 --- a/compiler/rustc_passes/src/hir_stats.rs +++ b/compiler/rustc_passes/src/hir_stats.rs @@ -589,7 +589,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { If, While, ForLoop, Loop, Match, Closure, Block, Await, TryBlock, Assign, AssignOp, Field, Index, Range, Underscore, Path, AddrOf, Break, Continue, Ret, InlineAsm, FormatArgs, OffsetOf, MacCall, Struct, Repeat, Paren, Try, Yield, Yeet, - Become, IncludedBytes, Gen, Err + Become, IncludedBytes, Gen, Err, Dummy ] ); ast_visit::walk_expr(self, e) diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 19272b52b32e6..05c833cdfb657 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -173,10 +173,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { // If the current node is a function, has const stability attributes and if it doesn not have an intrinsic ABI, // check if the function/method is const or the parent impl block is const if let (Some(const_span), Some(fn_sig)) = (const_span, fn_sig) { - if fn_sig.header.abi != Abi::RustIntrinsic - && fn_sig.header.abi != Abi::PlatformIntrinsic - && !fn_sig.header.is_const() - { + if fn_sig.header.abi != Abi::RustIntrinsic && !fn_sig.header.is_const() { if !self.in_trait_impl || (self.in_trait_impl && !self.tcx.is_const_fn_raw(def_id.to_def_id())) { diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 24824682b74cd..b1f910b947a93 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -694,18 +694,14 @@ impl Clone for Constructor { fn clone(&self) -> Self { match self { Constructor::Struct => Constructor::Struct, - Constructor::Variant(idx) => Constructor::Variant(idx.clone()), + Constructor::Variant(idx) => Constructor::Variant(*idx), Constructor::Ref => Constructor::Ref, - Constructor::Slice(slice) => Constructor::Slice(slice.clone()), + Constructor::Slice(slice) => Constructor::Slice(*slice), Constructor::UnionField => Constructor::UnionField, - Constructor::Bool(b) => Constructor::Bool(b.clone()), - Constructor::IntRange(range) => Constructor::IntRange(range.clone()), - Constructor::F32Range(lo, hi, end) => { - Constructor::F32Range(lo.clone(), hi.clone(), end.clone()) - } - Constructor::F64Range(lo, hi, end) => { - Constructor::F64Range(lo.clone(), hi.clone(), end.clone()) - } + Constructor::Bool(b) => Constructor::Bool(*b), + Constructor::IntRange(range) => Constructor::IntRange(*range), + Constructor::F32Range(lo, hi, end) => Constructor::F32Range(lo.clone(), *hi, *end), + Constructor::F64Range(lo, hi, end) => Constructor::F64Range(lo.clone(), *hi, *end), Constructor::Str(value) => Constructor::Str(value.clone()), Constructor::Opaque(inner) => Constructor::Opaque(inner.clone()), Constructor::Or => Constructor::Or, @@ -944,7 +940,7 @@ impl ConstructorSet { } ConstructorSet::Variants { variants, non_exhaustive } => { let mut seen_set = index::IdxSet::new_empty(variants.len()); - for idx in seen.iter().map(|c| c.as_variant().unwrap()) { + for idx in seen.iter().filter_map(|c| c.as_variant()) { seen_set.insert(idx); } let mut skipped_a_hidden_variant = false; @@ -973,7 +969,7 @@ impl ConstructorSet { ConstructorSet::Bool => { let mut seen_false = false; let mut seen_true = false; - for b in seen.iter().map(|ctor| ctor.as_bool().unwrap()) { + for b in seen.iter().filter_map(|ctor| ctor.as_bool()) { if b { seen_true = true; } else { @@ -993,7 +989,7 @@ impl ConstructorSet { } ConstructorSet::Integers { range_1, range_2 } => { let seen_ranges: Vec<_> = - seen.iter().map(|ctor| *ctor.as_int_range().unwrap()).collect(); + seen.iter().filter_map(|ctor| ctor.as_int_range()).copied().collect(); for (seen, splitted_range) in range_1.split(seen_ranges.iter().cloned()) { match seen { Presence::Unseen => missing.push(IntRange(splitted_range)), @@ -1010,7 +1006,7 @@ impl ConstructorSet { } } ConstructorSet::Slice { array_len, subtype_is_empty } => { - let seen_slices = seen.iter().map(|c| c.as_slice().unwrap()); + let seen_slices = seen.iter().filter_map(|c| c.as_slice()); let base_slice = Slice::new(*array_len, VarLen(0, 0)); for (seen, splitted_slice) in base_slice.split(seen_slices) { let ctor = Slice(splitted_slice); diff --git a/compiler/rustc_pattern_analysis/src/errors.rs b/compiler/rustc_pattern_analysis/src/errors.rs index 27619b74a665b..2d592b35159dd 100644 --- a/compiler/rustc_pattern_analysis/src/errors.rs +++ b/compiler/rustc_pattern_analysis/src/errors.rs @@ -1,4 +1,4 @@ -use rustc_errors::{AddToDiagnostic, DiagnosticBuilder, EmissionGuarantee, SubdiagnosticMessageOp}; +use rustc_errors::{AddToDiagnostic, Diag, EmissionGuarantee, SubdiagnosticMessageOp}; use rustc_macros::{LintDiagnostic, Subdiagnostic}; use rustc_middle::thir::Pat; use rustc_middle::ty::Ty; @@ -64,7 +64,7 @@ pub struct Overlap<'tcx> { impl<'tcx> AddToDiagnostic for Overlap<'tcx> { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _: F, ) { let Overlap { span, range } = self; diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index a24da44876606..f672051be5af2 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -1189,6 +1189,25 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> { } Ok(matrix) } + + /// Recover row usefulness and intersection information from a processed specialized matrix. + /// `specialized` must come from `self.specialize_constructor`. + fn unspecialize(&mut self, specialized: Self) { + for child_row in specialized.rows() { + let parent_row_id = child_row.parent_row; + let parent_row = &mut self.rows[parent_row_id]; + // A parent row is useful if any of its children is. + parent_row.useful |= child_row.useful; + for child_intersection in child_row.intersects.iter() { + // Convert the intersecting ids into ids for the parent matrix. + let parent_intersection = specialized.rows[child_intersection].parent_row; + // Note: self-intersection can happen with or-patterns. + if parent_intersection != parent_row_id { + parent_row.intersects.insert(parent_intersection); + } + } + } + } } /// Pretty-printer for matrices of patterns, example: @@ -1558,21 +1577,6 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>( // Accumulate the found witnesses. ret.extend(witnesses); - for child_row in spec_matrix.rows() { - let parent_row_id = child_row.parent_row; - let parent_row = &mut matrix.rows[parent_row_id]; - // A parent row is useful if any of its children is. - parent_row.useful |= child_row.useful; - for child_intersection in child_row.intersects.iter() { - // Convert the intersecting ids into ids for the parent matrix. - let parent_intersection = spec_matrix.rows[child_intersection].parent_row; - // Note: self-intersection can happen with or-patterns. - if parent_intersection != parent_row_id { - parent_row.intersects.insert(parent_intersection); - } - } - } - // Detect ranges that overlap on their endpoints. if let Constructor::IntRange(overlap_range) = ctor { if overlap_range.is_singleton() @@ -1582,6 +1586,8 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>( collect_overlapping_range_endpoints(mcx, overlap_range, matrix, &spec_matrix); } } + + matrix.unspecialize(spec_matrix); } // Record usefulness in the patterns. diff --git a/compiler/rustc_privacy/src/errors.rs b/compiler/rustc_privacy/src/errors.rs index 01c6d18c0e1be..ee04c335f2bd1 100644 --- a/compiler/rustc_privacy/src/errors.rs +++ b/compiler/rustc_privacy/src/errors.rs @@ -1,4 +1,4 @@ -use rustc_errors::{codes::*, DiagnosticArgFromDisplay}; +use rustc_errors::{codes::*, DiagArgFromDisplay}; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; @@ -36,7 +36,7 @@ pub struct ItemIsPrivate<'a> { #[label] pub span: Span, pub kind: &'a str, - pub descr: DiagnosticArgFromDisplay<'a>, + pub descr: DiagArgFromDisplay<'a>, } #[derive(Diagnostic)] @@ -55,7 +55,7 @@ pub struct InPublicInterface<'a> { pub span: Span, pub vis_descr: &'static str, pub kind: &'a str, - pub descr: DiagnosticArgFromDisplay<'a>, + pub descr: DiagArgFromDisplay<'a>, #[label(privacy_visibility_label)] pub vis_span: Span, } @@ -72,7 +72,7 @@ pub struct ReportEffectiveVisibility { #[diag(privacy_from_private_dep_in_public_interface)] pub struct FromPrivateDependencyInPublicInterface<'a> { pub kind: &'a str, - pub descr: DiagnosticArgFromDisplay<'a>, + pub descr: DiagArgFromDisplay<'a>, pub krate: Symbol, } @@ -82,7 +82,7 @@ pub struct UnnameableTypesLint<'a> { #[label] pub span: Span, pub kind: &'a str, - pub descr: DiagnosticArgFromDisplay<'a>, + pub descr: DiagArgFromDisplay<'a>, pub reachable_vis: &'a str, pub reexported_vis: &'a str, } @@ -96,11 +96,11 @@ pub struct PrivateInterfacesOrBoundsLint<'a> { #[label(privacy_item_label)] pub item_span: Span, pub item_kind: &'a str, - pub item_descr: DiagnosticArgFromDisplay<'a>, + pub item_descr: DiagArgFromDisplay<'a>, pub item_vis_descr: &'a str, #[note(privacy_ty_note)] pub ty_span: Span, pub ty_kind: &'a str, - pub ty_descr: DiagnosticArgFromDisplay<'a>, + pub ty_descr: DiagArgFromDisplay<'a>, pub ty_vis_descr: &'a str, } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 9d8a9f5fce3e4..1c6bd88712821 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -988,7 +988,10 @@ impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> { fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { if let hir::ExprKind::Struct(qpath, fields, ref base) = expr.kind { let res = self.typeck_results().qpath_res(qpath, expr.hir_id); - let adt = self.typeck_results().expr_ty(expr).ty_adt_def().unwrap(); + let Some(adt) = self.typeck_results().expr_ty(expr).ty_adt_def() else { + self.tcx.dcx().span_delayed_bug(expr.span, "no adt_def for expression"); + return; + }; let variant = adt.variant_of_res(res); if let Some(base) = *base { // If the expression uses FRU we need to make sure all the unmentioned fields diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 5917d79983d02..c7baca86d93b3 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -7,7 +7,7 @@ use crate::rustc_middle::ty::TyEncoder; use crate::QueryConfigRestored; use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; use rustc_data_structures::sync::Lock; -use rustc_errors::Diagnostic; +use rustc_errors::DiagInner; use rustc_index::Idx; use rustc_middle::dep_graph::dep_kinds; @@ -125,7 +125,7 @@ impl QueryContext for QueryCtxt<'_> { self, token: QueryJobId, depth_limit: bool, - diagnostics: Option<&Lock>>, + diagnostics: Option<&Lock>>, compute: impl FnOnce() -> R, ) -> R { // The `TyCtxt` stored in TLS has the same global interner lifetime diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index bf89bc7f7c3c4..1a54a2293573b 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -4,7 +4,7 @@ use crate::query::plumbing::CycleError; use crate::query::DepKind; use crate::query::{QueryContext, QueryStackFrame}; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::{DiagCtxt, DiagnosticBuilder}; +use rustc_errors::{Diag, DiagCtxt}; use rustc_hir::def::DefKind; use rustc_session::Session; use rustc_span::Span; @@ -559,7 +559,7 @@ pub fn deadlock(query_map: QueryMap, registry: &rayon_core::Registry) { pub fn report_cycle<'a>( sess: &'a Session, CycleError { usage, cycle: stack }: &CycleError, -) -> DiagnosticBuilder<'a> { +) -> Diag<'a> { assert!(!stack.is_empty()); let span = stack[0].query.default_span(stack[1 % stack.len()].span); diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs index 02b3c740b631b..0aefe553a3435 100644 --- a/compiler/rustc_query_system/src/query/mod.rs +++ b/compiler/rustc_query_system/src/query/mod.rs @@ -21,7 +21,7 @@ use crate::dep_graph::DepKind; use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; use rustc_data_structures::stable_hasher::Hash64; use rustc_data_structures::sync::Lock; -use rustc_errors::Diagnostic; +use rustc_errors::DiagInner; use rustc_hir::def::DefKind; use rustc_span::def_id::DefId; use rustc_span::Span; @@ -89,7 +89,7 @@ pub struct QuerySideEffects { /// Stores any diagnostics emitted during query execution. /// These diagnostics will be re-emitted if we mark /// the query as green. - pub(super) diagnostics: ThinVec, + pub(super) diagnostics: ThinVec, } impl QuerySideEffects { @@ -135,7 +135,7 @@ pub trait QueryContext: HasDepContext { self, token: QueryJobId, depth_limit: bool, - diagnostics: Option<&Lock>>, + diagnostics: Option<&Lock>>, compute: impl FnOnce() -> R, ) -> R; diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 754757b5de539..e4c596b10b875 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -19,7 +19,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::sync::Lock; #[cfg(parallel_compiler)] use rustc_data_structures::{outline, sync}; -use rustc_errors::{DiagnosticBuilder, FatalError, StashKey}; +use rustc_errors::{Diag, FatalError, StashKey}; use rustc_span::{Span, DUMMY_SP}; use std::cell::Cell; use std::collections::hash_map::Entry; @@ -124,7 +124,7 @@ fn handle_cycle_error( query: Q, qcx: Qcx, cycle_error: &CycleError, - error: DiagnosticBuilder<'_>, + error: Diag<'_>, ) -> Q::Value where Q: QueryConfig, diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index d64a3b43aad31..e4298a981292a 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -6,8 +6,8 @@ use rustc_ast::{MetaItemKind, NestedMetaItem}; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{ - codes::*, pluralize, report_ambiguity_error, struct_span_code_err, Applicability, DiagCtxt, - DiagnosticBuilder, ErrorGuaranteed, MultiSpan, SuggestionStyle, + codes::*, pluralize, report_ambiguity_error, struct_span_code_err, Applicability, Diag, + DiagCtxt, ErrorGuaranteed, MultiSpan, SuggestionStyle, }; use rustc_feature::BUILTIN_ATTRIBUTES; use rustc_hir::def::Namespace::{self, *}; @@ -360,7 +360,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { /// ``` fn add_suggestion_for_rename_of_use( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, name: Symbol, import: Import<'_>, binding_span: Span, @@ -436,7 +436,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { /// as characters expected by span manipulations won't be present. fn add_suggestion_for_duplicate_nested_use( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, import: Import<'_>, binding_span: Span, ) { @@ -554,15 +554,19 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { /// /// This takes the error provided, combines it with the span and any additional spans inside the /// error and emits it. - pub(crate) fn report_error(&mut self, span: Span, resolution_error: ResolutionError<'a>) { - self.into_struct_error(span, resolution_error).emit(); + pub(crate) fn report_error( + &mut self, + span: Span, + resolution_error: ResolutionError<'a>, + ) -> ErrorGuaranteed { + self.into_struct_error(span, resolution_error).emit() } pub(crate) fn into_struct_error( &mut self, span: Span, resolution_error: ResolutionError<'a>, - ) -> DiagnosticBuilder<'_> { + ) -> Diag<'_> { match resolution_error { ResolutionError::GenericParamsFromOuterItem(outer_res, has_generic_params, def_kind) => { use errs::GenericParamsFromOuterItemLabel as Label; @@ -1111,7 +1115,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { suggestions.extend( tmp_suggestions .into_iter() - .filter(|s| use_prelude || this.is_builtin_macro(s.res)), + .filter(|s| use_prelude.into() || this.is_builtin_macro(s.res)), ); } } @@ -1290,10 +1294,20 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let mut path_segments = path_segments.clone(); path_segments.push(ast::PathSegment::from_ident(ident)); + let alias_import = if let NameBindingKind::Import { import, .. } = + name_binding.kind + && let ImportKind::ExternCrate { source: Some(_), .. } = import.kind + && import.parent_scope.expansion == parent_scope.expansion + { + true + } else { + false + }; + let is_extern_crate_that_also_appears_in_prelude = name_binding.is_extern_crate() && lookup_ident.span.at_least_rust_2018(); - if !is_extern_crate_that_also_appears_in_prelude { + if !is_extern_crate_that_also_appears_in_prelude || alias_import { // add the module to the lookup if seen_modules.insert(module.def_id()) { if via_import { &mut worklist_via_import } else { &mut worklist } @@ -1399,7 +1413,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { pub(crate) fn unresolved_macro_suggestions( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, macro_kind: MacroKind, parent_scope: &ParentScope<'a>, ident: Ident, @@ -1515,7 +1529,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { pub(crate) fn add_typo_suggestion( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, suggestion: Option, span: Span, ) -> bool { @@ -2461,7 +2475,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { /// Finds a cfg-ed out item inside `module` with the matching name. pub(crate) fn find_cfg_stripped( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, segment: &Symbol, module: DefId, ) { @@ -2670,7 +2684,7 @@ pub(crate) enum DiagnosticMode { pub(crate) fn import_candidates( tcx: TyCtxt<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, // This is `None` if all placement locations are inside expansions use_placement_span: Option, candidates: &[ImportSuggestion], @@ -2696,7 +2710,7 @@ pub(crate) fn import_candidates( /// found and suggested, returns `true`, otherwise returns `false`. fn show_candidates( tcx: TyCtxt<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, // This is `None` if all placement locations are inside expansions use_placement_span: Option, candidates: &[ImportSuggestion], diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index adc4cd911a79e..6f23f53199664 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -7,32 +7,6 @@ use rustc_span::{ use crate::{late::PatternSource, Res}; -#[derive(Diagnostic)] -#[diag(resolve_parent_module_reset_for_binding, code = E0637)] -pub(crate) struct ParentModuleResetForBinding; - -#[derive(Diagnostic)] -#[diag(resolve_ampersand_used_without_explicit_lifetime_name, code = E0637)] -#[note] -pub(crate) struct AmpersandUsedWithoutExplicitLifetimeName(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_underscore_lifetime_name_cannot_be_used_here, code = E0637)] -#[note] -pub(crate) struct UnderscoreLifetimeNameCannotBeUsedHere(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_crate_may_not_be_imported)] -pub(crate) struct CrateMayNotBeImported(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_crate_root_imports_must_be_named_explicitly)] -pub(crate) struct CrateRootNamesMustBeNamedExplicitly(#[primary_span] pub(crate) Span); - -#[derive(Diagnostic)] -#[diag(resolve_crate_root_imports_must_be_named_explicitly)] -pub(crate) struct ResolutionError(#[primary_span] pub(crate) Span); - #[derive(Diagnostic)] #[diag(resolve_generic_params_from_outer_item, code = E0401)] pub(crate) struct GenericParamsFromOuterItem { @@ -467,19 +441,6 @@ pub(crate) struct UnreachableLabelSubLabelUnreachable { pub(crate) ident_span: Span, } -#[derive(Diagnostic)] -#[diag(resolve_trait_impl_mismatch)] -pub(crate) struct TraitImplMismatch { - #[primary_span] - #[label] - pub(crate) span: Span, - pub(crate) name: Symbol, - pub(crate) kind: String, - #[label(resolve_label_trait_item)] - pub(crate) trait_item_span: Span, - pub(crate) trait_path: String, -} - #[derive(Diagnostic)] #[diag(resolve_invalid_asm_sym)] #[help] diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 4583f991cabd5..c17ea00ec8094 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1,4 +1,5 @@ use rustc_ast::{self as ast, NodeId}; +use rustc_errors::ErrorGuaranteed; use rustc_hir::def::{DefKind, Namespace, NonMacroAttrKind, PartialRes, PerNS}; use rustc_middle::bug; use rustc_middle::ty; @@ -23,6 +24,18 @@ use Namespace::*; type Visibility = ty::Visibility; +#[derive(Copy, Clone)] +pub enum UsePrelude { + No, + Yes, +} + +impl From for bool { + fn from(up: UsePrelude) -> bool { + matches!(up, UsePrelude::Yes) + } +} + impl<'a, 'tcx> Resolver<'a, 'tcx> { /// A generic scope visitor. /// Visits scopes in order to resolve some identifier in them or perform other actions. @@ -32,12 +45,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { scope_set: ScopeSet<'a>, parent_scope: &ParentScope<'a>, ctxt: SyntaxContext, - mut visitor: impl FnMut( - &mut Self, - Scope<'a>, - /*use_prelude*/ bool, - SyntaxContext, - ) -> Option, + mut visitor: impl FnMut(&mut Self, Scope<'a>, UsePrelude, SyntaxContext) -> Option, ) -> Option { // General principles: // 1. Not controlled (user-defined) names should have higher priority than controlled names @@ -133,6 +141,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { }; if visit { + let use_prelude = if use_prelude { UsePrelude::Yes } else { UsePrelude::No }; if let break_result @ Some(..) = visitor(self, scope, use_prelude, ctxt) { return break_result; } @@ -579,7 +588,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { None, ignore_binding, ) { - if use_prelude || this.is_builtin_macro(binding.res()) { + if matches!(use_prelude, UsePrelude::Yes) + || this.is_builtin_macro(binding.res()) + { result = Ok((binding, Flags::MISC_FROM_PRELUDE)); } } @@ -1056,7 +1067,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { original_rib_ident_def: Ident, all_ribs: &[Rib<'a>], ) -> Res { - const CG_BUG_STR: &str = "min_const_generics resolve check didn't stop compilation"; debug!("validate_res_from_ribs({:?})", res); let ribs = &all_ribs[rib_index + 1..]; @@ -1199,8 +1209,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } }; - self.report_error(span, error); - self.dcx().span_delayed_bug(span, CG_BUG_STR); + let _: ErrorGuaranteed = self.report_error(span, error); } return Res::Err; diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 2f4da29133f1b..4057e9b8a0ef4 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -17,7 +17,7 @@ use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; use rustc_ast::*; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_errors::{ - codes::*, struct_span_code_err, Applicability, DiagnosticArgValue, IntoDiagnosticArg, StashKey, + codes::*, struct_span_code_err, Applicability, DiagArgValue, IntoDiagnosticArg, StashKey, }; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS}; @@ -90,8 +90,8 @@ impl PatternSource { } impl IntoDiagnosticArg for PatternSource { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { - DiagnosticArgValue::Str(Cow::Borrowed(self.descr())) + fn into_diagnostic_arg(self) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(self.descr())) } } diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 335bf0949d62e..327884c8414a4 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -18,8 +18,8 @@ use rustc_ast::{ use rustc_ast_pretty::pprust::where_bound_predicate_to_string; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, - MultiSpan, SuggestionStyle, + codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, + SuggestionStyle, }; use rustc_hir as hir; use rustc_hir::def::{self, CtorKind, CtorOf, DefKind}; @@ -426,7 +426,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { span: Span, source: PathSource<'_>, res: Option, - ) -> (DiagnosticBuilder<'tcx>, Vec) { + ) -> (Diag<'tcx>, Vec) { debug!(?res, ?source); let base_error = self.make_base_error(path, span, source, res); @@ -498,7 +498,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn detect_assoc_type_constraint_meant_as_path( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, base_error: &BaseError, ) { let Some(ty) = self.diagnostic_metadata.current_type_path else { @@ -539,12 +539,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } } - fn suggest_self_or_self_ref( - &mut self, - err: &mut DiagnosticBuilder<'_>, - path: &[Segment], - span: Span, - ) { + fn suggest_self_or_self_ref(&mut self, err: &mut Diag<'_>, path: &[Segment], span: Span) { if !self.self_type_is_available() { return; } @@ -589,7 +584,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn try_lookup_name_relaxed( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, path: &[Segment], following_seg: Option<&Segment>, @@ -793,7 +788,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_trait_and_bounds( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, res: Option, span: Span, @@ -870,7 +865,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_typo( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, path: &[Segment], following_seg: Option<&Segment>, @@ -910,7 +905,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_shadowed( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, path: &[Segment], following_seg: Option<&Segment>, @@ -943,7 +938,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn err_code_special_cases( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, path: &[Segment], span: Span, @@ -988,7 +983,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { /// Emit special messages for unresolved `Self` and `self`. fn suggest_self_ty( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, path: &[Segment], span: Span, @@ -1015,7 +1010,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_self_value( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, path: &[Segment], span: Span, @@ -1097,7 +1092,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_at_operator_in_slice_pat_with_range( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, path: &[Segment], ) { let Some(pat) = self.diagnostic_metadata.current_pat else { return }; @@ -1136,7 +1131,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_swapping_misplaced_self_ty_and_trait( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, res: Option, span: Span, @@ -1162,7 +1157,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } } - fn suggest_bare_struct_literal(&mut self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_bare_struct_literal(&mut self, err: &mut Diag<'_>) { if let Some(span) = self.diagnostic_metadata.current_block_could_be_bare_struct_literal { err.multipart_suggestion( "you might have meant to write a `struct` literal", @@ -1177,7 +1172,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_changing_type_to_const_param( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, res: Option, source: PathSource<'_>, span: Span, @@ -1229,7 +1224,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_pattern_match_with_let( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, span: Span, ) -> bool { @@ -1284,11 +1279,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } /// Given `where ::Baz: String`, suggest `where T: Bar`. - fn restrict_assoc_type_in_where_clause( - &mut self, - span: Span, - err: &mut DiagnosticBuilder<'_>, - ) -> bool { + fn restrict_assoc_type_in_where_clause(&mut self, span: Span, err: &mut Diag<'_>) -> bool { // Detect that we are actually in a `where` predicate. let (bounded_ty, bounds, where_span) = if let Some(ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate { @@ -1421,7 +1412,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { /// Returns `true` if able to provide context-dependent help. fn smart_resolve_context_dependent_help( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, source: PathSource<'_>, path: &[Segment], @@ -1432,52 +1423,50 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { let ns = source.namespace(); let is_expected = &|res| source.is_expected(res); - let path_sep = - |this: &mut Self, err: &mut DiagnosticBuilder<'_>, expr: &Expr, kind: DefKind| { - const MESSAGE: &str = "use the path separator to refer to an item"; + let path_sep = |this: &mut Self, err: &mut Diag<'_>, expr: &Expr, kind: DefKind| { + const MESSAGE: &str = "use the path separator to refer to an item"; - let (lhs_span, rhs_span) = match &expr.kind { - ExprKind::Field(base, ident) => (base.span, ident.span), - ExprKind::MethodCall(box MethodCall { receiver, span, .. }) => { - (receiver.span, *span) - } - _ => return false, - }; + let (lhs_span, rhs_span) = match &expr.kind { + ExprKind::Field(base, ident) => (base.span, ident.span), + ExprKind::MethodCall(box MethodCall { receiver, span, .. }) => { + (receiver.span, *span) + } + _ => return false, + }; - if lhs_span.eq_ctxt(rhs_span) { - err.span_suggestion( - lhs_span.between(rhs_span), - MESSAGE, - "::", - Applicability::MaybeIncorrect, - ); - true - } else if kind == DefKind::Struct - && let Some(lhs_source_span) = lhs_span.find_ancestor_inside(expr.span) - && let Ok(snippet) = - this.r.tcx.sess.source_map().span_to_snippet(lhs_source_span) - { - // The LHS is a type that originates from a macro call. - // We have to add angle brackets around it. + if lhs_span.eq_ctxt(rhs_span) { + err.span_suggestion( + lhs_span.between(rhs_span), + MESSAGE, + "::", + Applicability::MaybeIncorrect, + ); + true + } else if kind == DefKind::Struct + && let Some(lhs_source_span) = lhs_span.find_ancestor_inside(expr.span) + && let Ok(snippet) = this.r.tcx.sess.source_map().span_to_snippet(lhs_source_span) + { + // The LHS is a type that originates from a macro call. + // We have to add angle brackets around it. - err.span_suggestion_verbose( - lhs_source_span.until(rhs_span), - MESSAGE, - format!("<{snippet}>::"), - Applicability::MaybeIncorrect, - ); - true - } else { - // Either we were unable to obtain the source span / the snippet or - // the LHS originates from a macro call and it is not a type and thus - // there is no way to replace `.` with `::` and still somehow suggest - // valid Rust code. + err.span_suggestion_verbose( + lhs_source_span.until(rhs_span), + MESSAGE, + format!("<{snippet}>::"), + Applicability::MaybeIncorrect, + ); + true + } else { + // Either we were unable to obtain the source span / the snippet or + // the LHS originates from a macro call and it is not a type and thus + // there is no way to replace `.` with `::` and still somehow suggest + // valid Rust code. - false - } - }; + false + } + }; - let find_span = |source: &PathSource<'_>, err: &mut DiagnosticBuilder<'_>| { + let find_span = |source: &PathSource<'_>, err: &mut Diag<'_>| { match source { PathSource::Expr(Some(Expr { span, kind: ExprKind::Call(_, _), .. })) | PathSource::TupleStruct(span, _) => { @@ -1582,7 +1571,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { None => ("/* fields */".to_string(), Applicability::HasPlaceholders), }; let pad = match field_ids { - Some(field_ids) if field_ids.is_empty() => "", + Some([]) => "", _ => " ", }; err.span_suggestion( @@ -1833,7 +1822,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_alternative_construction_methods( &mut self, def_id: DefId, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, path_span: Span, call_span: Span, args: &[P], @@ -2263,11 +2252,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { // try to give a suggestion for this pattern: `name = blah`, which is common in other languages // suggest `let name = blah` to introduce a new binding - fn let_binding_suggestion( - &mut self, - err: &mut DiagnosticBuilder<'_>, - ident_span: Span, - ) -> bool { + fn let_binding_suggestion(&mut self, err: &mut Diag<'_>, ident_span: Span) -> bool { if let Some(Expr { kind: ExprKind::Assign(lhs, ..), .. }) = self.diagnostic_metadata.in_assignment && let ast::ExprKind::Path(None, ref path) = lhs.kind @@ -2368,7 +2353,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { /// Adds a suggestion for using an enum's variant when an enum is used instead. fn suggest_using_enum_variant( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, source: PathSource<'_>, def_id: DefId, span: Span, @@ -2744,9 +2729,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn suggest_introducing_lifetime( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, name: Option<&str>, - suggest: impl Fn(&mut DiagnosticBuilder<'_>, bool, Span, Cow<'static, str>, String) -> bool, + suggest: impl Fn(&mut Diag<'_>, bool, Span, Cow<'static, str>, String) -> bool, ) { let mut suggest_note = true; for rib in self.lifetime_ribs.iter().rev() { @@ -2904,7 +2889,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { fn add_missing_lifetime_specifiers_label( &mut self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, lifetime_refs: Vec, function_param_lifetimes: Option<(Vec, Vec)>, ) { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index a9b6703f3ab68..0434ff171934e 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -37,7 +37,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::intern::Interned; use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{FreezeReadGuard, Lrc}; -use rustc_errors::{Applicability, DiagnosticBuilder, ErrCode}; +use rustc_errors::{Applicability, Diag, ErrCode}; use rustc_expand::base::{DeriveResolutions, SyntaxExtension, SyntaxExtensionKind}; use rustc_feature::BUILTIN_ATTRIBUTES; use rustc_hir::def::Namespace::{self, *}; @@ -733,7 +733,7 @@ struct PrivacyError<'a> { #[derive(Debug)] struct UseError<'a> { - err: DiagnosticBuilder<'a>, + err: Diag<'a>, /// Candidates which user could `use` to access the missing type. candidates: Vec, /// The `DefId` of the module to place the use-statements in. diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 0a330da87b0cd..dadbcff6f68cd 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -11,7 +11,7 @@ use crate::{EarlyDiagCtxt, Session}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey}; use rustc_errors::emitter::HumanReadableErrorType; -use rustc_errors::{ColorConfig, DiagCtxtFlags, DiagnosticArgValue, IntoDiagnosticArg}; +use rustc_errors::{ColorConfig, DiagArgValue, DiagCtxtFlags, IntoDiagnosticArg}; use rustc_feature::UnstableFeatures; use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION}; use rustc_span::source_map::FilePathMapping; @@ -3099,7 +3099,7 @@ impl fmt::Display for CrateType { } impl IntoDiagnosticArg for CrateType { - fn into_diagnostic_arg(self) -> DiagnosticArgValue { + fn into_diagnostic_arg(self) -> DiagArgValue { self.to_string().into_diagnostic_arg() } } diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 73373e9ba5874..903d429d3a518 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -3,7 +3,7 @@ use std::num::NonZero; use rustc_ast::token; use rustc_ast::util::literal::LitError; use rustc_errors::{ - codes::*, DiagCtxt, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, + codes::*, Diag, DiagCtxt, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, IntoDiagnostic, Level, MultiSpan, }; use rustc_macros::Diagnostic; @@ -19,8 +19,8 @@ pub struct FeatureGateError { impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FeatureGateError { #[track_caller] - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> { - DiagnosticBuilder::new(dcx, level, self.explain).with_span(self.span).with_code(E0658) + fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { + Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658) } } diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index b011ca4dd5051..752bb05f3d79d 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -15,8 +15,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc}; use rustc_errors::{emitter::SilentEmitter, DiagCtxt}; use rustc_errors::{ - fallback_fluent_bundle, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, MultiSpan, - StashKey, + fallback_fluent_bundle, Diag, DiagnosticMessage, EmissionGuarantee, MultiSpan, StashKey, }; use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures}; use rustc_span::edition::Edition; @@ -86,7 +85,7 @@ pub fn feature_err( feature: Symbol, span: impl Into, explain: impl Into, -) -> DiagnosticBuilder<'_> { +) -> Diag<'_> { feature_err_issue(sess, feature, span, GateIssue::Language, explain) } @@ -101,7 +100,7 @@ pub fn feature_err_issue( span: impl Into, issue: GateIssue, explain: impl Into, -) -> DiagnosticBuilder<'_> { +) -> Diag<'_> { let span = span.into(); // Cancel an earlier warning for this same error, if it exists. @@ -158,7 +157,7 @@ pub fn feature_warn_issue( /// Adds the diagnostics for a feature to an existing error. pub fn add_feature_diagnostics( - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, sess: &Session, feature: Symbol, ) { @@ -171,7 +170,7 @@ pub fn add_feature_diagnostics( /// Almost always, you want to use this for a language feature. If so, prefer /// `add_feature_diagnostics`. pub fn add_feature_diagnostics_for_issue( - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, sess: &Session, feature: Symbol, issue: GateIssue, diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 02c7a0c6371f9..e9db96dc3562a 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -22,8 +22,8 @@ use rustc_errors::emitter::{DynEmitter, HumanEmitter, HumanReadableErrorType}; use rustc_errors::json::JsonEmitter; use rustc_errors::registry::Registry; use rustc_errors::{ - codes::*, fallback_fluent_bundle, DiagCtxt, DiagnosticBuilder, DiagnosticMessage, - ErrorGuaranteed, FatalAbort, FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl, + codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagnosticMessage, ErrorGuaranteed, + FatalAbort, FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl, }; use rustc_macros::HashStable_Generic; pub use rustc_span::def_id::StableCrateId; @@ -111,7 +111,7 @@ impl Mul for Limit { } impl rustc_errors::IntoDiagnosticArg for Limit { - fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue { + fn into_diagnostic_arg(self) -> rustc_errors::DiagArgValue { self.to_string().into_diagnostic_arg() } } @@ -308,7 +308,7 @@ impl Session { &'a self, err: impl IntoDiagnostic<'a>, feature: Symbol, - ) -> DiagnosticBuilder<'a> { + ) -> Diag<'a> { let mut err = self.dcx().create_err(err); if err.code.is_none() { err.code(E0658); @@ -1264,7 +1264,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) { // LLVM CFI using rustc LTO requires a single codegen unit. if sess.is_sanitizer_cfi_enabled() && sess.lto() == config::Lto::Fat - && !(sess.codegen_units().as_usize() == 1) + && (sess.codegen_units().as_usize() != 1) { sess.dcx().emit_err(errors::SanitizerCfiRequiresSingleCodegenUnit); } @@ -1442,10 +1442,7 @@ impl EarlyDiagCtxt { #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] - pub fn early_struct_fatal( - &self, - msg: impl Into, - ) -> DiagnosticBuilder<'_, FatalAbort> { + pub fn early_struct_fatal(&self, msg: impl Into) -> Diag<'_, FatalAbort> { self.dcx.struct_fatal(msg) } diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index 6bbfcff5e87cc..2cc9bc31873a4 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -457,7 +457,6 @@ impl RustcInternal for Abi { Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind }, Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic, Abi::RustCall => rustc_target::spec::abi::Abi::RustCall, - Abi::PlatformIntrinsic => rustc_target::spec::abi::Abi::PlatformIntrinsic, Abi::Unadjusted => rustc_target::spec::abi::Abi::Unadjusted, Abi::RustCold => rustc_target::spec::abi::Abi::RustCold, Abi::RiscvInterruptM => rustc_target::spec::abi::Abi::RiscvInterruptM, diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs index b95186b0a1c5b..540bc48354866 100644 --- a/compiler/rustc_smir/src/rustc_smir/context.rs +++ b/compiler/rustc_smir/src/rustc_smir/context.rs @@ -208,11 +208,10 @@ impl<'tcx> Context for TablesWrapper<'tcx> { let crates: Vec = [LOCAL_CRATE] .iter() .chain(tables.tcx.crates(()).iter()) - .map(|crate_num| { + .filter_map(|crate_num| { let crate_name = tables.tcx.crate_name(*crate_num).to_string(); (name == crate_name).then(|| smir_crate(tables.tcx, *crate_num)) }) - .flatten() .collect(); crates } diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index 29081418200e7..a066b9ed3aa2d 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -833,7 +833,6 @@ impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi { abi::Abi::System { unwind } => Abi::System { unwind }, abi::Abi::RustIntrinsic => Abi::RustIntrinsic, abi::Abi::RustCall => Abi::RustCall, - abi::Abi::PlatformIntrinsic => Abi::PlatformIntrinsic, abi::Abi::Unadjusted => Abi::Unadjusted, abi::Abi::RustCold => Abi::RustCold, abi::Abi::RiscvInterruptM => Abi::RiscvInterruptM, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 46472a131ff4b..f52f187973fa0 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -487,6 +487,7 @@ symbols! { call_once, caller_location, capture_disjoint_fields, + catch_unwind, cause, cdylib, ceilf32, @@ -759,8 +760,36 @@ symbols! { f, f16c_target_feature, f32, + f32_legacy_const_digits, + f32_legacy_const_epsilon, + f32_legacy_const_infinity, + f32_legacy_const_mantissa_dig, + f32_legacy_const_max, + f32_legacy_const_max_10_exp, + f32_legacy_const_max_exp, + f32_legacy_const_min, + f32_legacy_const_min_10_exp, + f32_legacy_const_min_exp, + f32_legacy_const_min_positive, + f32_legacy_const_nan, + f32_legacy_const_neg_infinity, + f32_legacy_const_radix, f32_nan, f64, + f64_legacy_const_digits, + f64_legacy_const_epsilon, + f64_legacy_const_infinity, + f64_legacy_const_mantissa_dig, + f64_legacy_const_max, + f64_legacy_const_max_10_exp, + f64_legacy_const_max_exp, + f64_legacy_const_min, + f64_legacy_const_min_10_exp, + f64_legacy_const_min_exp, + f64_legacy_const_min_positive, + f64_legacy_const_nan, + f64_legacy_const_neg_infinity, + f64_legacy_const_radix, f64_nan, fabsf32, fabsf64, @@ -812,6 +841,7 @@ symbols! { format_placeholder, format_unsafe_arg, freeze, + freeze_impls, freg, frem_algebraic, frem_fast, @@ -866,11 +896,36 @@ symbols! { hwaddress, i, i128, + i128_legacy_const_max, + i128_legacy_const_min, + i128_legacy_fn_max_value, + i128_legacy_fn_min_value, + i128_legacy_mod, i128_type, i16, + i16_legacy_const_max, + i16_legacy_const_min, + i16_legacy_fn_max_value, + i16_legacy_fn_min_value, + i16_legacy_mod, i32, + i32_legacy_const_max, + i32_legacy_const_min, + i32_legacy_fn_max_value, + i32_legacy_fn_min_value, + i32_legacy_mod, i64, + i64_legacy_const_max, + i64_legacy_const_min, + i64_legacy_fn_max_value, + i64_legacy_fn_min_value, + i64_legacy_mod, i8, + i8_legacy_const_max, + i8_legacy_const_min, + i8_legacy_fn_max_value, + i8_legacy_fn_min_value, + i8_legacy_mod, ident, if_let, if_let_guard, @@ -1441,6 +1496,7 @@ symbols! { rustc_mir, rustc_must_implement_one_of, rustc_never_returns_null_ptr, + rustc_no_mir_inline, rustc_nonnull_optimization_guaranteed, rustc_nounwind, rustc_object_lifetime_default, @@ -1635,6 +1691,7 @@ symbols! { suggestion, sym, sync, + synthetic, t32, target, target_abi, @@ -1713,10 +1770,35 @@ symbols! { type_name, type_privacy_lints, u128, + u128_legacy_const_max, + u128_legacy_const_min, + u128_legacy_fn_max_value, + u128_legacy_fn_min_value, + u128_legacy_mod, u16, + u16_legacy_const_max, + u16_legacy_const_min, + u16_legacy_fn_max_value, + u16_legacy_fn_min_value, + u16_legacy_mod, u32, + u32_legacy_const_max, + u32_legacy_const_min, + u32_legacy_fn_max_value, + u32_legacy_fn_min_value, + u32_legacy_mod, u64, + u64_legacy_const_max, + u64_legacy_const_min, + u64_legacy_fn_max_value, + u64_legacy_fn_min_value, + u64_legacy_mod, u8, + u8_legacy_const_max, + u8_legacy_const_min, + u8_legacy_fn_max_value, + u8_legacy_fn_min_value, + u8_legacy_mod, unaligned_volatile_load, unaligned_volatile_store, unboxed_closures, @@ -1801,6 +1883,7 @@ symbols! { vtable_align, vtable_size, warn, + wasip2, wasm_abi, wasm_import_module, wasm_target_feature, diff --git a/compiler/rustc_symbol_mangling/src/errors.rs b/compiler/rustc_symbol_mangling/src/errors.rs index 2d076f7b22546..b84e2f7b4eab0 100644 --- a/compiler/rustc_symbol_mangling/src/errors.rs +++ b/compiler/rustc_symbol_mangling/src/errors.rs @@ -1,6 +1,6 @@ //! Errors emitted by symbol_mangling. -use rustc_errors::{DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic, Level}; +use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level}; use rustc_span::Span; use std::fmt; @@ -14,11 +14,11 @@ pub struct TestOutput { // natural language, and (b) it's only used in tests. So we construct it // manually and avoid the fluent machinery. impl IntoDiagnostic<'_, G> for TestOutput { - fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { + fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> Diag<'_, G> { let TestOutput { span, kind, content } = self; #[allow(rustc::untranslatable_diagnostic)] - DiagnosticBuilder::new(dcx, level, format!("{kind}({content})")).with_span(span) + Diag::new(dcx, level, format!("{kind}({content})")).with_span(span) } } diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index 04c5e60aa6ba1..8019d2b80cde0 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -9,9 +9,10 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] +#![cfg_attr(bootstrap, feature(exhaustive_patterns))] +#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))] #![feature(rustdoc_internals)] #![feature(assert_matches)] -#![feature(exhaustive_patterns)] #![feature(iter_intersperse)] #![feature(let_chains)] #![cfg_attr(bootstrap, feature(min_specialization))] diff --git a/compiler/rustc_target/src/spec/abi/mod.rs b/compiler/rustc_target/src/spec/abi/mod.rs index 6231787bb9fdb..388e76d83e243 100644 --- a/compiler/rustc_target/src/spec/abi/mod.rs +++ b/compiler/rustc_target/src/spec/abi/mod.rs @@ -54,7 +54,6 @@ pub enum Abi { }, RustIntrinsic, RustCall, - PlatformIntrinsic, Unadjusted, /// For things unlikely to be called, where reducing register pressure in /// `extern "Rust"` callers is worth paying extra cost in the callee. @@ -129,7 +128,6 @@ const AbiDatas: &[AbiData] = &[ AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" }, AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" }, AbiData { abi: Abi::RustCall, name: "rust-call" }, - AbiData { abi: Abi::PlatformIntrinsic, name: "platform-intrinsic" }, AbiData { abi: Abi::Unadjusted, name: "unadjusted" }, AbiData { abi: Abi::RustCold, name: "rust-cold" }, AbiData { abi: Abi::RiscvInterruptM, name: "riscv-interrupt-m" }, @@ -199,10 +197,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { feature: sym::intrinsics, explain: "intrinsics are subject to change", }), - "platform-intrinsic" => Err(AbiDisabled::Unstable { - feature: sym::platform_intrinsics, - explain: "platform intrinsics are experimental and possibly buggy", - }), "vectorcall" => Err(AbiDisabled::Unstable { feature: sym::abi_vectorcall, explain: "vectorcall is experimental and subject to change", @@ -299,11 +293,10 @@ impl Abi { System { unwind: true } => 28, RustIntrinsic => 29, RustCall => 30, - PlatformIntrinsic => 31, - Unadjusted => 32, - RustCold => 33, - RiscvInterruptM => 34, - RiscvInterruptS => 35, + Unadjusted => 31, + RustCold => 32, + RiscvInterruptM => 33, + RiscvInterruptS => 34, }; debug_assert!( AbiDatas diff --git a/compiler/rustc_target/src/spec/base/apple/tests.rs b/compiler/rustc_target/src/spec/base/apple/tests.rs index f13058ebc82ad..097039d6c7382 100644 --- a/compiler/rustc_target/src/spec/base/apple/tests.rs +++ b/compiler/rustc_target/src/spec/base/apple/tests.rs @@ -14,7 +14,7 @@ fn simulator_targets_set_abi() { aarch64_apple_watchos_sim::target(), ]; - for target in all_sim_targets { + for target in &all_sim_targets { assert_eq!(target.abi, "sim") } } diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d04bcb2d78aac..651d563227750 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1575,6 +1575,7 @@ supported_targets! { ("wasm32-unknown-emscripten", wasm32_unknown_emscripten), ("wasm32-unknown-unknown", wasm32_unknown_unknown), ("wasm32-wasi", wasm32_wasi), + ("wasm32-wasip2", wasm32_wasip2), ("wasm32-wasi-preview1-threads", wasm32_wasi_preview1_threads), ("wasm64-unknown-unknown", wasm64_unknown_unknown), @@ -2448,7 +2449,6 @@ impl Target { | System { .. } | RustIntrinsic | RustCall - | PlatformIntrinsic | Unadjusted | Cdecl { .. } | RustCold => true, diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs index 22f6ee8105576..70e40f60f22a0 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_freebsd.rs @@ -8,8 +8,7 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".into(), + env: "gnu".into(), features: "+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs index 84d9ceac04d46..ca0db5e564001 100644 --- a/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv6_unknown_netbsd_eabihf.rs @@ -8,8 +8,6 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".into(), features: "+v6,+vfp2,-d32".into(), max_atomic_width: Some(64), mcount: "__mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs index 9f4a432c6fa5f..61b6d7a63e358 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_freebsd.rs @@ -8,8 +8,7 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: change env to "gnu" when cfg_target_abi becomes stable - env: "gnueabihf".into(), + env: "gnu".into(), features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "\u{1}__gnu_mcount_nc".into(), diff --git a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs index e5518c6daecf0..7afdb87b62eee 100644 --- a/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/targets/armv7_unknown_netbsd_eabihf.rs @@ -8,8 +8,6 @@ pub fn target() -> Target { arch: "arm".into(), options: TargetOptions { abi: "eabihf".into(), - // FIXME: remove env when cfg_target_abi becomes stable - env: "eabihf".into(), features: "+v7,+vfp3,-d32,+thumb2,-neon".into(), max_atomic_width: Some(64), mcount: "__mcount".into(), diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs index 574dc658b78c5..69bba4775b4ab 100644 --- a/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_netbsd.rs @@ -4,7 +4,7 @@ pub fn target() -> Target { let mut base = base::netbsd::opts(); base.cpu = "pentium".into(); base.max_atomic_width = Some(64); - base.stack_probes = StackProbeType::Call; + base.stack_probes = StackProbeType::Inline; Target { llvm_target: "i586-unknown-netbsdelf".into(), diff --git a/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs b/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs new file mode 100644 index 0000000000000..30f7636f0bbe5 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs @@ -0,0 +1,64 @@ +//! The `wasm32-wasip2` target is the next evolution of the +//! wasm32-wasi target. While the wasi specification is still under +//! active development, the {review 2 iteration is considered an "island +//! of stability" that should allow users to rely on it indefinitely. +//! +//! The `wasi` target is a proposal to define a standardized set of WebAssembly +//! component imports that allow it to interoperate with the host system in a +//! standardized way. This set of imports is intended to empower WebAssembly +//! binaries with host capabilities such as filesystem access, network access, etc. +//! +//! Wasi Preview 2 relies on the WebAssembly component model which is an extension of +//! the core WebAssembly specification which allows interoperability between WebAssembly +//! modules (known as "components") through high-level, shared-nothing APIs instead of the +//! low-level, shared-everything linear memory model of the core WebAssembly specification. +//! +//! You can see more about wasi at and the component model at +//! . + +use crate::spec::crt_objects; +use crate::spec::LinkSelfContainedDefault; +use crate::spec::{base, Target}; + +pub fn target() -> Target { + let mut options = base::wasm::options(); + + options.os = "wasi".into(); + options.env = "p2".into(); + options.linker = Some("wasm-component-ld".into()); + + options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained(); + options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained(); + + // FIXME: Figure out cases in which WASM needs to link with a native toolchain. + options.link_self_contained = LinkSelfContainedDefault::True; + + // Right now this is a bit of a workaround but we're currently saying that + // the target by default has a static crt which we're taking as a signal + // for "use the bundled crt". If that's turned off then the system's crt + // will be used, but this means that default usage of this target doesn't + // need an external compiler but it's still interoperable with an external + // compiler if configured correctly. + options.crt_static_default = true; + options.crt_static_respected = true; + + // Allow `+crt-static` to create a "cdylib" output which is just a wasm file + // without a main function. + options.crt_static_allows_dylibs = true; + + // WASI's `sys::args::init` function ignores its arguments; instead, + // `args::args()` makes the WASI API calls itself. + options.main_needs_argc_argv = false; + + // And, WASI mangles the name of "main" to distinguish between different + // signatures. + options.entry_name = "__main_void".into(); + + Target { + llvm_target: "wasm32-unknown-unknown".into(), + pointer_width: 32, + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".into(), + arch: "wasm32".into(), + options, + } +} diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index 10911c0d002b8..95667de79a6bd 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -1,7 +1,7 @@ use crate::fluent_generated as fluent; use rustc_errors::{ - codes::*, AddToDiagnostic, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, - IntoDiagnostic, Level, SubdiagnosticMessageOp, + codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, + Level, SubdiagnosticMessageOp, }; use rustc_macros::Diagnostic; use rustc_middle::ty::{self, ClosureKind, PolyTraitRef, Ty}; @@ -59,9 +59,8 @@ pub struct NegativePositiveConflict<'tcx> { impl IntoDiagnostic<'_, G> for NegativePositiveConflict<'_> { #[track_caller] - fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> { - let mut diag = - DiagnosticBuilder::new(dcx, level, fluent::trait_selection_negative_positive_conflict); + fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> { + let mut diag = Diag::new(dcx, level, fluent::trait_selection_negative_positive_conflict); diag.arg("trait_desc", self.trait_desc.print_only_trait_path().to_string()); diag.arg("self_desc", self.self_ty.map_or_else(|| "none".to_string(), |ty| ty.to_string())); diag.span(self.impl_span); @@ -104,7 +103,7 @@ pub enum AdjustSignatureBorrow { impl AddToDiagnostic for AdjustSignatureBorrow { fn add_to_diagnostic_with>( self, - diag: &mut DiagnosticBuilder<'_, G>, + diag: &mut Diag<'_, G>, _f: F, ) { match self { diff --git a/compiler/rustc_trait_selection/src/solve/alias_relate.rs b/compiler/rustc_trait_selection/src/solve/alias_relate.rs index 81be5c091644e..afd9d95cb570e 100644 --- a/compiler/rustc_trait_selection/src/solve/alias_relate.rs +++ b/compiler/rustc_trait_selection/src/solve/alias_relate.rs @@ -8,8 +8,9 @@ //! //! (1.) If we end up with two rigid aliases, then we relate them structurally. //! -//! (2.) If we end up with an infer var and a rigid alias, then -//! we assign the alias to the infer var. +//! (2.) If we end up with an infer var and a rigid alias, then we instantiate +//! the infer var with the constructor of the alias and then recursively relate +//! the terms. //! //! (3.) Otherwise, if we end with two rigid (non-projection) or infer types, //! relate them structurally. @@ -53,22 +54,15 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } - (Some(_), None) => { - if rhs.is_infer() { - self.relate(param_env, lhs, variance, rhs)?; - self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) - } else { - Err(NoSolution) - } - } - (None, Some(_)) => { - if lhs.is_infer() { - self.relate(param_env, lhs, variance, rhs)?; - self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) - } else { - Err(NoSolution) - } + (Some(alias), None) => { + self.relate_rigid_alias_non_alias(param_env, alias, variance, rhs) } + (None, Some(alias)) => self.relate_rigid_alias_non_alias( + param_env, + alias, + variance.xform(ty::Variance::Contravariant), + lhs, + ), (Some(alias_lhs), Some(alias_rhs)) => { self.relate(param_env, alias_lhs, variance, alias_rhs)?; @@ -77,6 +71,39 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { } } + /// Relate a rigid alias with another type. This is the same as + /// an ordinary relate except that we treat the outer most alias + /// constructor as rigid. + #[instrument(level = "debug", skip(self, param_env), ret)] + fn relate_rigid_alias_non_alias( + &mut self, + param_env: ty::ParamEnv<'tcx>, + alias: ty::AliasTy<'tcx>, + variance: ty::Variance, + term: ty::Term<'tcx>, + ) -> QueryResult<'tcx> { + // NOTE: this check is purely an optimization, the structural eq would + // always fail if the term is not an inference variable. + if term.is_infer() { + let tcx = self.tcx(); + // We need to relate `alias` to `term` treating only the outermost + // constructor as rigid, relating any contained generic arguments as + // normal. We do this by first structurally equating the `term` + // with the alias constructor instantiated with unconstrained infer vars, + // and then relate this with the whole `alias`. + // + // Alternatively we could modify `Equate` for this case by adding another + // variant to `StructurallyRelateAliases`. + let identity_args = self.fresh_args_for_item(alias.def_id); + let rigid_ctor = ty::AliasTy::new(tcx, alias.def_id, identity_args); + self.eq_structurally_relating_aliases(param_env, term, rigid_ctor.to_ty(tcx).into())?; + self.eq(param_env, alias, rigid_ctor)?; + self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) + } else { + Err(NoSolution) + } + } + // FIXME: This needs a name that reflects that it's okay to bottom-out with an inference var. /// Normalize the `term` to equate it later. #[instrument(level = "debug", skip(self, param_env), ret)] @@ -105,6 +132,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { } } + #[instrument(level = "debug", skip(self, param_env), ret)] fn try_normalize_ty_recur( &mut self, param_env: ty::ParamEnv<'tcx>, @@ -128,10 +156,9 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { ); this.add_goal(GoalSource::Misc, normalizes_to_goal); this.try_evaluate_added_goals()?; - let ty = this.resolve_vars_if_possible(normalized_ty); - Ok(this.try_normalize_ty_recur(param_env, depth + 1, ty)) + Ok(this.resolve_vars_if_possible(normalized_ty)) }) { - Ok(ty) => ty, + Ok(ty) => self.try_normalize_ty_recur(param_env, depth + 1, ty), Err(NoSolution) => Some(ty), } } diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs index 8e66b1d580f90..4c4cd2af779bd 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs @@ -777,6 +777,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { // FIXME(@lcnr): The current structure here makes me unhappy and feels ugly. idk how // to improve this however. However, this should make it fairly straightforward to refine // the filtering going forward, so it seems alright-ish for now. + #[instrument(level = "debug", skip(self, goal))] fn discard_impls_shadowed_by_env>( &mut self, goal: Goal<'tcx, G>, @@ -799,7 +800,10 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { // This feels dangerous. Certainty::Yes => { candidates.retain(|c| match c.source { - CandidateSource::Impl(_) | CandidateSource::BuiltinImpl(_) => false, + CandidateSource::Impl(_) | CandidateSource::BuiltinImpl(_) => { + debug!(?c, "discard impl candidate"); + false + } CandidateSource::ParamEnv(_) | CandidateSource::AliasBound => true, }); } @@ -807,6 +811,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { // to be ambig and wait for inference constraints. See // tests/ui/traits/next-solver/env-shadows-impls/ambig-env-no-shadow.rs Certainty::Maybe(cause) => { + debug!(?cause, "force ambiguity"); *candidates = self.forced_ambiguity(cause); } } diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs index 1a6aa3f144c3e..251b0a193f1bb 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs @@ -18,7 +18,7 @@ use rustc_infer::infer::canonical::query_response::make_query_region_constraints use rustc_infer::infer::canonical::CanonicalVarValues; use rustc_infer::infer::canonical::{CanonicalExt, QueryRegionConstraints}; use rustc_infer::infer::resolve::EagerResolver; -use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk}; +use rustc_infer::infer::{InferCtxt, InferOk}; use rustc_middle::infer::canonical::Canonical; use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::solve::{ @@ -80,7 +80,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { /// the values inferred while solving the instantiated goal. /// - `external_constraints`: additional constraints which aren't expressible /// using simple unification of inference variables. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "debug", skip(self), ret)] pub(in crate::solve) fn evaluate_added_goals_and_make_canonical_response( &mut self, certainty: Certainty, @@ -191,7 +191,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { param_env: ty::ParamEnv<'tcx>, original_values: Vec>, response: CanonicalResponse<'tcx>, - ) -> Result<(Certainty, Vec>>), NoSolution> { + ) -> Certainty { let instantiation = Self::compute_query_response_instantiation_values( self.infcx, &original_values, @@ -201,15 +201,13 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { let Response { var_values, external_constraints, certainty } = response.instantiate(self.tcx(), &instantiation); - let nested_goals = - Self::unify_query_var_values(self.infcx, param_env, &original_values, var_values)?; + Self::unify_query_var_values(self.infcx, param_env, &original_values, var_values); let ExternalConstraintsData { region_constraints, opaque_types } = external_constraints.deref(); self.register_region_constraints(region_constraints); - self.register_opaque_types(param_env, opaque_types)?; - - Ok((certainty, nested_goals)) + self.register_new_opaque_types(param_env, opaque_types); + certainty } /// This returns the canoncial variable values to instantiate the bound variables of @@ -296,32 +294,36 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { CanonicalVarValues { var_values } } - #[instrument(level = "debug", skip(infcx, param_env), ret)] + /// Unify the `original_values` with the `var_values` returned by the canonical query.. + /// + /// This assumes that this unification will always succeed. This is the case when + /// applying a query response right away. However, calling a canonical query, doing any + /// other kind of trait solving, and only then instantiating the result of the query + /// can cause the instantiation to fail. This is not supported and we ICE in this case. + /// + /// We always structurally instantiate aliases. Relating aliases needs to be different + /// depending on whether the alias is *rigid* or not. We're only really able to tell + /// whether an alias is rigid by using the trait solver. When instantiating a response + /// from the solver we assume that the solver correctly handled aliases and therefore + /// always relate them structurally here. + #[instrument(level = "debug", skip(infcx), ret)] fn unify_query_var_values( infcx: &InferCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, original_values: &[ty::GenericArg<'tcx>], var_values: CanonicalVarValues<'tcx>, - ) -> Result>>, NoSolution> { + ) { assert_eq!(original_values.len(), var_values.len()); - let mut nested_goals = vec![]; + let cause = ObligationCause::dummy(); for (&orig, response) in iter::zip(original_values, var_values.var_values) { - nested_goals.extend( - infcx - .at(&ObligationCause::dummy(), param_env) - .eq(DefineOpaqueTypes::No, orig, response) - .map(|InferOk { value: (), obligations }| { - obligations.into_iter().map(|o| Goal::from(o)) - }) - .map_err(|e| { - debug!(?e, "failed to equate"); - NoSolution - })?, - ); + let InferOk { value: (), obligations } = infcx + .at(&cause, param_env) + .trace(orig, response) + .eq_structurally_relating_aliases(orig, response) + .unwrap(); + assert!(obligations.is_empty()); } - - Ok(nested_goals) } fn register_region_constraints(&mut self, region_constraints: &QueryRegionConstraints<'tcx>) { @@ -333,21 +335,17 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { } } - for member_constraint in ®ion_constraints.member_constraints { - // FIXME: Deal with member constraints :< - let _ = member_constraint; - } + assert!(region_constraints.member_constraints.is_empty()); } - fn register_opaque_types( + fn register_new_opaque_types( &mut self, param_env: ty::ParamEnv<'tcx>, opaque_types: &[(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)], - ) -> Result<(), NoSolution> { + ) { for &(key, ty) in opaque_types { - self.insert_hidden_type(key, param_env, ty)?; + self.insert_hidden_type(key, param_env, ty).unwrap(); } - Ok(()) } } @@ -366,19 +364,21 @@ impl<'tcx> inspect::ProofTreeBuilder<'tcx> { ) } + /// Instantiate a `CanonicalState`. This assumes that unifying the var values + /// trivially succeeds. Adding any inference constraints which weren't present when + /// originally computing the canonical query can result in bugs. pub fn instantiate_canonical_state>>( infcx: &InferCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, original_values: &[ty::GenericArg<'tcx>], state: inspect::CanonicalState<'tcx, T>, - ) -> Result<(Vec>>, T), NoSolution> { + ) -> T { let instantiation = EvalCtxt::compute_query_response_instantiation_values(infcx, original_values, &state); let inspect::State { var_values, data } = state.instantiate(infcx.tcx, &instantiation); - let nested_goals = - EvalCtxt::unify_query_var_values(infcx, param_env, original_values, var_values)?; - Ok((nested_goals, data)) + EvalCtxt::unify_query_var_values(infcx, param_env, original_values, var_values); + data } } diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs index 5c1e8bf616fd4..ed428bb8e6629 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs @@ -17,8 +17,8 @@ use rustc_middle::traits::solve::{ }; use rustc_middle::traits::{specialization_graph, DefiningAnchor}; use rustc_middle::ty::{ - self, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable, - TypeVisitableExt, TypeVisitor, + self, InferCtxtLike, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, + TypeVisitable, TypeVisitableExt, TypeVisitor, }; use rustc_session::config::DumpSolverProofTree; use rustc_span::DUMMY_SP; @@ -142,10 +142,7 @@ impl<'tcx> InferCtxt<'tcx> { &self, goal: Goal<'tcx, ty::Predicate<'tcx>>, generate_proof_tree: GenerateProofTree, - ) -> ( - Result<(bool, Certainty, Vec>>), NoSolution>, - Option>, - ) { + ) -> (Result<(bool, Certainty), NoSolution>, Option>) { EvalCtxt::enter_root(self, generate_proof_tree, |ecx| { ecx.evaluate_goal(GoalEvaluationKind::Root, GoalSource::Misc, goal) }) @@ -327,7 +324,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { goal_evaluation_kind: GoalEvaluationKind, source: GoalSource, goal: Goal<'tcx, ty::Predicate<'tcx>>, - ) -> Result<(bool, Certainty, Vec>>), NoSolution> { + ) -> Result<(bool, Certainty), NoSolution> { let (orig_values, canonical_goal) = self.canonicalize_goal(goal); let mut goal_evaluation = self.inspect.new_goal_evaluation(goal, &orig_values, goal_evaluation_kind); @@ -345,26 +342,13 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { Ok(response) => response, }; - let (certainty, has_changed, nested_goals) = match self - .instantiate_response_discarding_overflow( - goal.param_env, - source, - orig_values, - canonical_response, - ) { - Err(e) => { - self.inspect.goal_evaluation(goal_evaluation); - return Err(e); - } - Ok(response) => response, - }; - goal_evaluation.returned_goals(&nested_goals); + let (certainty, has_changed) = self.instantiate_response_discarding_overflow( + goal.param_env, + source, + orig_values, + canonical_response, + ); self.inspect.goal_evaluation(goal_evaluation); - - if !has_changed && !nested_goals.is_empty() { - bug!("an unchanged goal shouldn't have any side-effects on instantiation"); - } - // FIXME: We previously had an assert here that checked that recomputing // a goal after applying its constraints did not change its response. // @@ -375,7 +359,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { // Once we have decided on how to handle trait-system-refactor-initiative#75, // we should re-add an assert here. - Ok((has_changed, certainty, nested_goals)) + Ok((has_changed, certainty)) } fn instantiate_response_discarding_overflow( @@ -384,7 +368,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { source: GoalSource, original_values: Vec>, response: CanonicalResponse<'tcx>, - ) -> Result<(Certainty, bool, Vec>>), NoSolution> { + ) -> (Certainty, bool) { // The old solver did not evaluate nested goals when normalizing. // It returned the selection constraints allowing a `Projection` // obligation to not hold in coherence while avoiding the fatal error @@ -405,14 +389,14 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { }; if response.value.certainty == Certainty::OVERFLOW && !keep_overflow_constraints() { - Ok((Certainty::OVERFLOW, false, Vec::new())) + (Certainty::OVERFLOW, false) } else { let has_changed = !response.value.var_values.is_identity_modulo_regions() || !response.value.external_constraints.opaque_types.is_empty(); - let (certainty, nested_goals) = - self.instantiate_and_apply_query_response(param_env, original_values, response)?; - Ok((certainty, has_changed, nested_goals)) + let certainty = + self.instantiate_and_apply_query_response(param_env, original_values, response); + (certainty, has_changed) } } @@ -537,12 +521,11 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { ty::NormalizesTo { alias: goal.predicate.alias, term: unconstrained_rhs }, ); - let (_, certainty, instantiate_goals) = self.evaluate_goal( + let (_, certainty) = self.evaluate_goal( GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::Yes }, GoalSource::Misc, unconstrained_goal, )?; - self.nested_goals.goals.extend(with_misc_source(instantiate_goals)); // Finally, equate the goal's RHS with the unconstrained var. // We put the nested goals from this into goals instead of @@ -573,12 +556,11 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> { } for (source, goal) in goals.goals.drain(..) { - let (has_changed, certainty, instantiate_goals) = self.evaluate_goal( + let (has_changed, certainty) = self.evaluate_goal( GoalEvaluationKind::Nested { is_normalizes_to_hack: IsNormalizesToHack::No }, source, goal, )?; - self.nested_goals.goals.extend(with_misc_source(instantiate_goals)); if has_changed { unchanged_certainty = None; } @@ -626,76 +608,101 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { /// Is the projection predicate is of the form `exists ::Assoc = T`. /// - /// This is the case if the `term` is an inference variable in the innermost universe - /// and does not occur in any other part of the predicate. + /// This is the case if the `term` does not occur in any other part of the predicate + /// and is able to name all other placeholder and inference variables. #[instrument(level = "debug", skip(self), ret)] pub(super) fn term_is_fully_unconstrained( &self, goal: Goal<'tcx, ty::NormalizesTo<'tcx>>, ) -> bool { - let term_is_infer = match goal.predicate.term.unpack() { + let universe_of_term = match goal.predicate.term.unpack() { ty::TermKind::Ty(ty) => { if let &ty::Infer(ty::TyVar(vid)) = ty.kind() { - match self.infcx.probe_ty_var(vid) { - Ok(value) => bug!("resolved var in query: {goal:?} {value:?}"), - Err(universe) => universe == self.infcx.universe(), - } + self.infcx.universe_of_ty(vid).unwrap() } else { - false + return false; } } ty::TermKind::Const(ct) => { if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = ct.kind() { - match self.infcx.probe_const_var(vid) { - Ok(value) => bug!("resolved var in query: {goal:?} {value:?}"), - Err(universe) => universe == self.infcx.universe(), - } + self.infcx.universe_of_ct(vid).unwrap() } else { - false + return false; } } }; - // Guard against `>::Assoc = ?0>`. - struct ContainsTerm<'a, 'tcx> { + struct ContainsTermOrNotNameable<'a, 'tcx> { term: ty::Term<'tcx>, + universe_of_term: ty::UniverseIndex, infcx: &'a InferCtxt<'tcx>, } - impl<'tcx> TypeVisitor> for ContainsTerm<'_, 'tcx> { + + impl<'a, 'tcx> ContainsTermOrNotNameable<'a, 'tcx> { + fn check_nameable(&self, universe: ty::UniverseIndex) -> ControlFlow<()> { + if self.universe_of_term.can_name(universe) { + ControlFlow::Continue(()) + } else { + ControlFlow::Break(()) + } + } + } + + impl<'tcx> TypeVisitor> for ContainsTermOrNotNameable<'_, 'tcx> { type BreakTy = (); fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { - if let Some(vid) = t.ty_vid() - && let ty::TermKind::Ty(term) = self.term.unpack() - && let Some(term_vid) = term.ty_vid() - && self.infcx.root_var(vid) == self.infcx.root_var(term_vid) - { - ControlFlow::Break(()) - } else if t.has_non_region_infer() { - t.super_visit_with(self) - } else { - ControlFlow::Continue(()) + match *t.kind() { + ty::Infer(ty::TyVar(vid)) => { + if let ty::TermKind::Ty(term) = self.term.unpack() + && let Some(term_vid) = term.ty_vid() + && self.infcx.root_var(vid) == self.infcx.root_var(term_vid) + { + ControlFlow::Break(()) + } else { + self.check_nameable(self.infcx.universe_of_ty(vid).unwrap()) + } + } + ty::Placeholder(p) => self.check_nameable(p.universe), + _ => { + if t.has_non_region_infer() || t.has_placeholders() { + t.super_visit_with(self) + } else { + ControlFlow::Continue(()) + } + } } } fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow { - if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = c.kind() - && let ty::TermKind::Const(term) = self.term.unpack() - && let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind() - && self.infcx.root_const_var(vid) == self.infcx.root_const_var(term_vid) - { - ControlFlow::Break(()) - } else if c.has_non_region_infer() { - c.super_visit_with(self) - } else { - ControlFlow::Continue(()) + match c.kind() { + ty::ConstKind::Infer(ty::InferConst::Var(vid)) => { + if let ty::TermKind::Const(term) = self.term.unpack() + && let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind() + && self.infcx.root_const_var(vid) == self.infcx.root_const_var(term_vid) + { + ControlFlow::Break(()) + } else { + self.check_nameable(self.infcx.universe_of_ct(vid).unwrap()) + } + } + ty::ConstKind::Placeholder(p) => self.check_nameable(p.universe), + _ => { + if c.has_non_region_infer() || c.has_placeholders() { + c.super_visit_with(self) + } else { + ControlFlow::Continue(()) + } + } } } } - let mut visitor = ContainsTerm { infcx: self.infcx, term: goal.predicate.term }; - - term_is_infer - && goal.predicate.alias.visit_with(&mut visitor).is_continue() + let mut visitor = ContainsTermOrNotNameable { + infcx: self.infcx, + universe_of_term, + term: goal.predicate.term, + }; + goal.predicate.alias.visit_with(&mut visitor).is_continue() && goal.param_env.visit_with(&mut visitor).is_continue() } @@ -718,6 +725,26 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { }) } + /// This sohuld only be used when we're either instantiating a previously + /// unconstrained "return value" or when we're sure that all aliases in + /// the types are rigid. + #[instrument(level = "debug", skip(self, param_env), ret)] + pub(super) fn eq_structurally_relating_aliases>( + &mut self, + param_env: ty::ParamEnv<'tcx>, + lhs: T, + rhs: T, + ) -> Result<(), NoSolution> { + let cause = ObligationCause::dummy(); + let InferOk { value: (), obligations } = self + .infcx + .at(&cause, param_env) + .trace(lhs, rhs) + .eq_structurally_relating_aliases(lhs, rhs)?; + assert!(obligations.is_empty()); + Ok(()) + } + #[instrument(level = "debug", skip(self, param_env), ret)] pub(super) fn sub>( &mut self, diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs index 7196a5af259fe..3262d64cb7d5f 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs @@ -58,44 +58,26 @@ impl<'tcx> InferCtxt<'tcx> { } let candidate = candidates.pop().unwrap(); - let (certainty, nested_goals) = ecx - .instantiate_and_apply_query_response( - trait_goal.param_env, - orig_values, - candidate.result, - ) - .map_err(|_| SelectionError::Unimplemented)?; - - Ok(Some((candidate, certainty, nested_goals))) + let certainty = ecx.instantiate_and_apply_query_response( + trait_goal.param_env, + orig_values, + candidate.result, + ); + + Ok(Some((candidate, certainty))) }); - let (candidate, certainty, nested_goals) = match result { - Ok(Some((candidate, certainty, nested_goals))) => { - (candidate, certainty, nested_goals) - } + let (candidate, certainty) = match result { + Ok(Some(result)) => result, Ok(None) => return Ok(None), Err(e) => return Err(e), }; - let nested_obligations: Vec<_> = nested_goals - .into_iter() - .map(|goal| { - Obligation::new( - self.tcx, - ObligationCause::dummy(), - goal.param_env, - goal.predicate, - ) - }) - .collect(); - let goal = self.resolve_vars_if_possible(trait_goal); match (certainty, candidate.source) { // Rematching the implementation will instantiate the same nested goals that // would have caused the ambiguity, so we can still make progress here regardless. - (_, CandidateSource::Impl(def_id)) => { - rematch_impl(self, goal, def_id, nested_obligations) - } + (_, CandidateSource::Impl(def_id)) => rematch_impl(self, goal, def_id), // If an unsize goal is ambiguous, then we can manually rematch it to make // selection progress for coercion during HIR typeck. If it is *not* ambiguous, @@ -108,20 +90,20 @@ impl<'tcx> InferCtxt<'tcx> { | (Certainty::Yes, CandidateSource::BuiltinImpl(src @ BuiltinImplSource::Misc)) if self.tcx.lang_items().unsize_trait() == Some(goal.predicate.def_id()) => { - rematch_unsize(self, goal, nested_obligations, src, certainty) + rematch_unsize(self, goal, src, certainty) } // Technically some builtin impls have nested obligations, but if // `Certainty::Yes`, then they should've all been verified and don't // need re-checking. (Certainty::Yes, CandidateSource::BuiltinImpl(src)) => { - Ok(Some(ImplSource::Builtin(src, nested_obligations))) + Ok(Some(ImplSource::Builtin(src, vec![]))) } // It's fine not to do anything to rematch these, since there are no // nested obligations. (Certainty::Yes, CandidateSource::ParamEnv(_) | CandidateSource::AliasBound) => { - Ok(Some(ImplSource::Param(nested_obligations))) + Ok(Some(ImplSource::Param(vec![]))) } (Certainty::Maybe(_), _) => Ok(None), @@ -192,19 +174,16 @@ fn rematch_impl<'tcx>( infcx: &InferCtxt<'tcx>, goal: Goal<'tcx, ty::TraitPredicate<'tcx>>, impl_def_id: DefId, - mut nested: Vec>, ) -> SelectionResult<'tcx, Selection<'tcx>> { let args = infcx.fresh_args_for_item(DUMMY_SP, impl_def_id); let impl_trait_ref = infcx.tcx.impl_trait_ref(impl_def_id).unwrap().instantiate(infcx.tcx, args); - nested.extend( - infcx - .at(&ObligationCause::dummy(), goal.param_env) - .eq(DefineOpaqueTypes::No, goal.predicate.trait_ref, impl_trait_ref) - .map_err(|_| SelectionError::Unimplemented)? - .into_obligations(), - ); + let mut nested = infcx + .at(&ObligationCause::dummy(), goal.param_env) + .eq(DefineOpaqueTypes::No, goal.predicate.trait_ref, impl_trait_ref) + .map_err(|_| SelectionError::Unimplemented)? + .into_obligations(); nested.extend( infcx.tcx.predicates_of(impl_def_id).instantiate(infcx.tcx, args).into_iter().map( @@ -221,11 +200,11 @@ fn rematch_impl<'tcx>( fn rematch_unsize<'tcx>( infcx: &InferCtxt<'tcx>, goal: Goal<'tcx, ty::TraitPredicate<'tcx>>, - mut nested: Vec>, source: BuiltinImplSource, certainty: Certainty, ) -> SelectionResult<'tcx, Selection<'tcx>> { let tcx = infcx.tcx; + let mut nested = vec![]; let a_ty = structurally_normalize(goal.predicate.self_ty(), infcx, goal.param_env, &mut nested); let b_ty = structurally_normalize( goal.predicate.trait_ref.args.type_at(1), diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index 97f715b6386c2..c1b07765e5011 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -2,7 +2,6 @@ use std::mem; use rustc_infer::infer::InferCtxt; use rustc_infer::traits::solve::MaybeCause; -use rustc_infer::traits::Obligation; use rustc_infer::traits::{ query::NoSolution, FulfillmentError, FulfillmentErrorCode, MismatchedProjectionTypes, PredicateObligation, SelectionError, TraitEngine, @@ -11,7 +10,7 @@ use rustc_middle::ty; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use super::eval_ctxt::GenerateProofTree; -use super::{Certainty, Goal, InferCtxtEvalExt}; +use super::{Certainty, InferCtxtEvalExt}; /// A trait engine using the new trait solver. /// @@ -48,11 +47,11 @@ impl<'tcx> FulfillmentCtxt<'tcx> { &self, infcx: &InferCtxt<'tcx>, obligation: &PredicateObligation<'tcx>, - result: &Result<(bool, Certainty, Vec>>), NoSolution>, + result: &Result<(bool, Certainty), NoSolution>, ) { if let Some(inspector) = infcx.obligation_inspector.get() { let result = match result { - Ok((_, c, _)) => Ok(*c), + Ok((_, c)) => Ok(*c), Err(NoSolution) => Err(NoSolution), }; (inspector)(infcx, &obligation, result); @@ -80,13 +79,13 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> { .evaluate_root_goal(obligation.clone().into(), GenerateProofTree::IfEnabled) .0 { - Ok((_, Certainty::Maybe(MaybeCause::Ambiguity), _)) => { + Ok((_, Certainty::Maybe(MaybeCause::Ambiguity))) => { FulfillmentErrorCode::Ambiguity { overflow: false } } - Ok((_, Certainty::Maybe(MaybeCause::Overflow), _)) => { + Ok((_, Certainty::Maybe(MaybeCause::Overflow))) => { FulfillmentErrorCode::Ambiguity { overflow: true } } - Ok((_, Certainty::Yes, _)) => { + Ok((_, Certainty::Yes)) => { bug!("did not expect successful goal when collecting ambiguity errors") } Err(_) => { @@ -120,7 +119,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> { let goal = obligation.clone().into(); let result = infcx.evaluate_root_goal(goal, GenerateProofTree::IfEnabled).0; self.inspect_evaluated_obligation(infcx, &obligation, &result); - let (changed, certainty, nested_goals) = match result { + let (changed, certainty) = match result { Ok(result) => result, Err(NoSolution) => { errors.push(FulfillmentError { @@ -178,16 +177,6 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> { continue; } }; - // Push any nested goals that we get from unifying our canonical response - // with our obligation onto the fulfillment context. - self.obligations.extend(nested_goals.into_iter().map(|goal| { - Obligation::new( - infcx.tcx, - obligation.cause.clone(), - goal.param_env, - goal.predicate, - ) - })); has_changed |= changed; match certainty { Certainty::Yes => {} diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs index c5d4ce33d8617..52b900af85328 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs @@ -63,21 +63,12 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> { infcx.probe(|_| { let mut instantiated_goals = vec![]; for goal in &self.nested_goals { - let goal = match ProofTreeBuilder::instantiate_canonical_state( + let goal = ProofTreeBuilder::instantiate_canonical_state( infcx, self.goal.goal.param_env, self.goal.orig_values, *goal, - ) { - Ok((_goals, goal)) => goal, - Err(NoSolution) => { - warn!( - "unexpected failure when instantiating {:?}: {:?}", - goal, self.nested_goals - ); - return ControlFlow::Continue(()); - } - }; + ); instantiated_goals.push(goal); } diff --git a/compiler/rustc_trait_selection/src/solve/inspect/build.rs b/compiler/rustc_trait_selection/src/solve/inspect/build.rs index b587a93b24c4f..f7b310a7abe27 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/build.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/build.rs @@ -87,7 +87,6 @@ struct WipGoalEvaluation<'tcx> { pub uncanonicalized_goal: Goal<'tcx, ty::Predicate<'tcx>>, pub kind: WipGoalEvaluationKind<'tcx>, pub evaluation: Option>, - pub returned_goals: Vec>>, } impl<'tcx> WipGoalEvaluation<'tcx> { @@ -103,7 +102,6 @@ impl<'tcx> WipGoalEvaluation<'tcx> { } }, evaluation: self.evaluation.unwrap().finalize(), - returned_goals: self.returned_goals, } } } @@ -312,7 +310,6 @@ impl<'tcx> ProofTreeBuilder<'tcx> { } }, evaluation: None, - returned_goals: vec![], }) } @@ -369,17 +366,6 @@ impl<'tcx> ProofTreeBuilder<'tcx> { } } - pub fn returned_goals(&mut self, goals: &[Goal<'tcx, ty::Predicate<'tcx>>]) { - if let Some(this) = self.as_mut() { - match this { - DebugSolver::GoalEvaluation(evaluation) => { - assert!(evaluation.returned_goals.is_empty()); - evaluation.returned_goals.extend(goals); - } - _ => unreachable!(), - } - } - } pub fn goal_evaluation(&mut self, goal_evaluation: ProofTreeBuilder<'tcx>) { if let Some(this) = self.as_mut() { match (this, *goal_evaluation.state.unwrap()) { diff --git a/compiler/rustc_trait_selection/src/solve/mod.rs b/compiler/rustc_trait_selection/src/solve/mod.rs index 8b163d47d3475..51094b781c0cf 100644 --- a/compiler/rustc_trait_selection/src/solve/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/mod.rs @@ -267,6 +267,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { /// This function is necessary in nearly all cases before matching on a type. /// Not doing so is likely to be incomplete and therefore unsound during /// coherence. + #[instrument(level = "debug", skip(self, param_env), ret)] fn structurally_normalize_ty( &mut self, param_env: ty::ParamEnv<'tcx>, diff --git a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs index 5f62583115675..aa8cc3667cd7b 100644 --- a/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs @@ -68,6 +68,34 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { kind => bug!("unknown DefKind {} in projection goal: {goal:#?}", kind.descr(def_id)), } } + + /// When normalizing an associated item, constrain the result to `term`. + /// + /// While `NormalizesTo` goals have the normalized-to term as an argument, + /// this argument is always fully unconstrained for associated items. + /// It is therefore appropriate to instead think of these `NormalizesTo` goals + /// as function returning a term after normalizing. + /// + /// When equating an inference variable and an alias, we tend to emit `alias-relate` + /// goals and only actually instantiate the inference variable with an alias if the + /// alias is rigid. However, this means that constraining the expected term of + /// such goals ends up fully structurally normalizing the resulting type instead of + /// only by one step. To avoid this we instead use structural equality here, resulting + /// in each `NormalizesTo` only projects by a single step. + /// + /// Not doing so, currently causes issues because trying to normalize an opaque type + /// during alias-relate doesn't actually constrain the opaque if the concrete type + /// is an inference variable. This means that `NormalizesTo` for associated types + /// normalizing to an opaque type always resulted in ambiguity, breaking tests e.g. + /// tests/ui/type-alias-impl-trait/issue-78450.rs. + pub fn instantiate_normalizes_to_term( + &mut self, + goal: Goal<'tcx, NormalizesTo<'tcx>>, + term: ty::Term<'tcx>, + ) { + self.eq_structurally_relating_aliases(goal.param_env, goal.predicate.term, term) + .expect("expected goal term to be fully unconstrained"); + } } impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { @@ -104,8 +132,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { goal.predicate.alias, assumption_projection_pred.projection_ty, )?; - ecx.eq(goal.param_env, goal.predicate.term, assumption_projection_pred.term) - .expect("expected goal term to be fully unconstrained"); + + ecx.instantiate_normalizes_to_term(goal, assumption_projection_pred.term); // Add GAT where clauses from the trait's definition ecx.add_goals( @@ -192,8 +220,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { "cannot project to an associated function" ), }; - ecx.eq(goal.param_env, goal.predicate.term, error_term) - .expect("expected goal term to be fully unconstrained"); + ecx.instantiate_normalizes_to_term(goal, error_term); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) }; @@ -248,8 +275,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { ty::AssocKind::Fn => unreachable!("we should never project to a fn"), }; - ecx.eq(goal.param_env, goal.predicate.term, term.instantiate(tcx, args)) - .expect("expected goal term to be fully unconstrained"); + ecx.instantiate_normalizes_to_term(goal, term.instantiate(tcx, args)); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) }) } @@ -456,7 +482,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { borrow_region.expect_region(), ); - ecx.eq(goal.param_env, goal.predicate.term.ty().unwrap(), upvars_ty)?; + ecx.instantiate_normalizes_to_term(goal, upvars_ty.into()); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } @@ -543,8 +569,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { ), }; - ecx.eq(goal.param_env, goal.predicate.term, metadata_ty.into()) - .expect("expected goal term to be fully unconstrained"); + ecx.instantiate_normalizes_to_term(goal, metadata_ty.into()); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) }) } @@ -627,20 +652,22 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { } ecx.probe_misc_candidate("builtin AsyncIterator kind").enter(|ecx| { + let expected_ty = ecx.next_ty_infer(); // Take `AsyncIterator` and turn it into the corresponding // coroutine yield ty `Poll>`. - let expected_ty = Ty::new_adt( + let wrapped_expected_ty = Ty::new_adt( tcx, tcx.adt_def(tcx.require_lang_item(LangItem::Poll, None)), tcx.mk_args(&[Ty::new_adt( tcx, tcx.adt_def(tcx.require_lang_item(LangItem::Option, None)), - tcx.mk_args(&[goal.predicate.term.into()]), + tcx.mk_args(&[expected_ty.into()]), ) .into()]), ); let yield_ty = args.as_coroutine().yield_ty(); - ecx.eq(goal.param_env, expected_ty, yield_ty)?; + ecx.eq(goal.param_env, wrapped_expected_ty, yield_ty)?; + ecx.instantiate_normalizes_to_term(goal, expected_ty.into()); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) }) } @@ -742,8 +769,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> { }; ecx.probe_misc_candidate("builtin discriminant kind").enter(|ecx| { - ecx.eq(goal.param_env, goal.predicate.term, discriminant_ty.into()) - .expect("expected goal term to be fully unconstrained"); + ecx.instantiate_normalizes_to_term(goal, discriminant_ty.into()); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) }) } diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 3619d02438da1..6778cb7b7a98f 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -18,7 +18,7 @@ use crate::traits::{ Obligation, ObligationCause, PredicateObligation, PredicateObligations, SelectionContext, }; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{DiagnosticBuilder, EmissionGuarantee}; +use rustc_errors::{Diag, EmissionGuarantee}; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt}; @@ -58,7 +58,7 @@ pub struct OverlapResult<'tcx> { pub involves_placeholder: bool, } -pub fn add_placeholder_note(err: &mut DiagnosticBuilder<'_, G>) { +pub fn add_placeholder_note(err: &mut Diag<'_, G>) { err.note( "this behavior recently changed as a result of a bug fix; \ see rust-lang/rust#56105 for details", @@ -320,22 +320,25 @@ fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>( let mut errors = fulfill_cx.select_where_possible(infcx); errors.pop().map(|err| err.obligation) } else { - obligations.iter().cloned().find(|obligation| { - // We use `evaluate_root_obligation` to correctly track intercrate - // ambiguity clauses. We cannot use this in the new solver. - let evaluation_result = selcx.evaluate_root_obligation(obligation); - - match evaluation_result { - Ok(result) => !result.may_apply(), - // If overflow occurs, we need to conservatively treat the goal as possibly holding, - // since there can be instantiations of this goal that don't overflow and result in - // success. This isn't much of a problem in the old solver, since we treat overflow - // fatally (this still can be encountered: ), - // but in the new solver, this is very important for correctness, since overflow - // *must* be treated as ambiguity for completeness. - Err(_overflow) => false, - } - }) + obligations + .iter() + .find(|obligation| { + // We use `evaluate_root_obligation` to correctly track intercrate + // ambiguity clauses. We cannot use this in the new solver. + let evaluation_result = selcx.evaluate_root_obligation(obligation); + + match evaluation_result { + Ok(result) => !result.may_apply(), + // If overflow occurs, we need to conservatively treat the goal as possibly holding, + // since there can be instantiations of this goal that don't overflow and result in + // success. This isn't much of a problem in the old solver, since we treat overflow + // fatally (this still can be encountered: ), + // but in the new solver, this is very important for correctness, since overflow + // *must* be treated as ambiguity for completeness. + Err(_overflow) => false, + } + }) + .cloned() } } @@ -598,9 +601,24 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>( trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental) } +#[derive(Debug, Copy, Clone)] +pub enum IsFirstInputType { + No, + Yes, +} + +impl From for IsFirstInputType { + fn from(b: bool) -> IsFirstInputType { + match b { + false => IsFirstInputType::No, + true => IsFirstInputType::Yes, + } + } +} + #[derive(Debug)] pub enum OrphanCheckErr<'tcx> { - NonLocalInputType(Vec<(Ty<'tcx>, bool /* Is this the first input type? */)>), + NonLocalInputType(Vec<(Ty<'tcx>, IsFirstInputType)>), UncoveredTy(Ty<'tcx>, Option>), } @@ -751,7 +769,7 @@ struct OrphanChecker<'tcx, F> { /// Ignore orphan check failures and exclusively search for the first /// local type. search_first_local_ty: bool, - non_local_tys: Vec<(Ty<'tcx>, bool)>, + non_local_tys: Vec<(Ty<'tcx>, IsFirstInputType)>, } impl<'tcx, F, E> OrphanChecker<'tcx, F> @@ -769,7 +787,7 @@ where } fn found_non_local_ty(&mut self, t: Ty<'tcx>) -> ControlFlow> { - self.non_local_tys.push((t, self.in_self_ty)); + self.non_local_tys.push((t, self.in_self_ty.into())); ControlFlow::Continue(()) } diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 1aaadf6cf044a..e789e9c2b6e16 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -107,6 +107,15 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { self.register_infer_ok_obligations(infer_ok) } + pub fn deeply_normalize>>( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + value: T, + ) -> Result>> { + self.infcx.at(cause, param_env).deeply_normalize(value, &mut **self.engine.borrow_mut()) + } + /// Makes `expected <: actual`. pub fn eq_exp( &self, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs index 4788ecbe3e290..cbe2ec0f0eb8c 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/infer_ctxt_ext.rs @@ -1,7 +1,7 @@ use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use crate::infer::InferCtxt; use crate::traits::{Obligation, ObligationCause, ObligationCtxt}; -use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, Diag}; use rustc_hir as hir; use rustc_hir::Node; use rustc_middle::ty::{self, Ty}; @@ -88,7 +88,7 @@ impl<'tcx> InferCtxt<'tcx> { found_args: Vec, is_closure: bool, closure_arg_span: Option, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let kind = if is_closure { "closure" } else { "function" }; let args_str = |arguments: &[ArgKind], other: &[ArgKind]| { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 8ae31392b40e6..bca7b2327495c 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -13,8 +13,8 @@ use hir::def::CtorOf; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, EmissionGuarantee, - MultiSpan, Style, SuggestionStyle, + codes::*, pluralize, struct_span_code_err, Applicability, Diag, EmissionGuarantee, MultiSpan, + Style, SuggestionStyle, }; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -121,7 +121,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>( item_id: LocalDefId, hir_generics: &hir::Generics<'tcx>, msg: &str, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, fn_sig: Option<&hir::FnSig<'_>>, projection: Option<&ty::AliasTy<'_>>, trait_pred: ty::PolyTraitPredicate<'tcx>, @@ -240,7 +240,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>( impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_restricting_param_bound( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, associated_ty: Option<(&'static str, Ty<'tcx>)>, mut body_id: LocalDefId, @@ -450,7 +450,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_dereferences( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool { let mut code = obligation.cause.code(); @@ -743,23 +743,22 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn get_closure_name( &self, def_id: DefId, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, msg: Cow<'static, str>, ) -> Option { - let get_name = - |err: &mut DiagnosticBuilder<'_>, kind: &hir::PatKind<'_>| -> Option { - // Get the local name of this closure. This can be inaccurate because - // of the possibility of reassignment, but this should be good enough. - match &kind { - hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, ident, None) => { - Some(ident.name) - } - _ => { - err.note(msg); - None - } + let get_name = |err: &mut Diag<'_>, kind: &hir::PatKind<'_>| -> Option { + // Get the local name of this closure. This can be inaccurate because + // of the possibility of reassignment, but this should be good enough. + match &kind { + hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, ident, None) => { + Some(ident.name) } - }; + _ => { + err.note(msg); + None + } + } + }; let hir_id = self.tcx.local_def_id_to_hir_id(def_id.as_local()?); match self.tcx.parent_hir_node(hir_id) { @@ -779,7 +778,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_fn_call( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool { // It doesn't make sense to make this suggestion outside of typeck... @@ -895,7 +894,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn check_for_binding_assigned_block_without_tail_expression( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) { let mut span = obligation.cause.span; @@ -972,7 +971,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_add_clone_to_arg( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool { let self_ty = self.resolve_vars_if_possible(trait_pred.self_ty()); @@ -1157,7 +1156,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_add_reference_to_arg( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, poly_trait_pred: ty::PolyTraitPredicate<'tcx>, has_custom_message: bool, ) -> bool { @@ -1283,9 +1282,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { "the full type name has been written to '{}'", file.display() )); - err.note(format!( - "consider using `--verbose` to print full type name to the console" - )); + err.note( + "consider using `--verbose` to print full type name to the console", + ); } if imm_ref_self_ty_satisfies_pred && mut_ref_self_ty_satisfies_pred { @@ -1378,7 +1377,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // Suggest borrowing the type fn suggest_borrowing_for_object_cast( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>, self_ty: Ty<'tcx>, target_ty: Ty<'tcx>, @@ -1414,7 +1413,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_remove_reference( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool { let mut span = obligation.cause.span; @@ -1533,11 +1532,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { false } - fn suggest_remove_await( - &self, - obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, - ) { + fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diag<'_>) { let hir = self.tcx.hir(); if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code().peel_derives() && let hir::Node::Expr(expr) = self.tcx.hir_node(*hir_id) @@ -1607,7 +1602,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_change_mut( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) { let points_at_arg = matches!( @@ -1685,7 +1680,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_semicolon_removal( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool { @@ -1739,7 +1734,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// emitted. fn suggest_impl_trait( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) -> bool { @@ -1809,7 +1804,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn point_at_returns_when_relevant( &self, - err: &mut DiagnosticBuilder<'tcx>, + err: &mut Diag<'tcx>, obligation: &PredicateObligation<'tcx>, ) { match obligation.cause.code().peel_derives() { @@ -1850,7 +1845,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { cause: &ObligationCauseCode<'tcx>, found_node: Option>, param_env: ty::ParamEnv<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { pub(crate) fn build_fn_sig_ty<'tcx>( infcx: &InferCtxt<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>, @@ -1921,7 +1916,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn note_conflicting_fn_args( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, cause: &ObligationCauseCode<'tcx>, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -2076,7 +2071,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn note_conflicting_closure_bounds( &self, cause: &ObligationCauseCode<'tcx>, - err: &mut DiagnosticBuilder<'tcx>, + err: &mut Diag<'tcx>, ) { // First, look for an `ExprBindingObligation`, which means we can get // the uninstantiated predicate list of the called function. And check @@ -2128,7 +2123,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_fully_qualified_path( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, item_def_id: DefId, span: Span, trait_ref: DefId, @@ -2195,7 +2190,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { #[instrument(level = "debug", skip_all, fields(?obligation.predicate, ?obligation.cause.span))] fn maybe_note_obligation_cause_for_async_await( &self, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, obligation: &PredicateObligation<'tcx>, ) -> bool { let hir = self.tcx.hir(); @@ -2431,7 +2426,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { #[instrument(level = "debug", skip_all)] fn note_obligation_cause_for_async_await( &self, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, interior_or_upvar_span: CoroutineInteriorOrUpvar, is_async: bool, outer_coroutine: Option, @@ -2667,7 +2662,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn note_obligation_cause_code( &self, body_id: LocalDefId, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, predicate: T, param_env: ty::ParamEnv<'tcx>, cause_code: &ObligationCauseCode<'tcx>, @@ -2869,9 +2864,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { "the full name for the type has been written to '{}'", file.display(), )); - err.note(format!( - "consider using `--verbose` to print the full type name to the console" - )); + err.note( + "consider using `--verbose` to print the full type name to the console", + ); } } ObligationCauseCode::RepeatElementCopy { @@ -3339,9 +3334,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { "the full type name has been written to '{}'", file.display(), )); - err.note(format!( - "consider using `--verbose` to print the full type name to the console" - )); + err.note( + "consider using `--verbose` to print the full type name to the console", + ); } let mut parent_predicate = parent_trait_pred; let mut data = &data.derived; @@ -3395,9 +3390,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { "the full type name has been written to '{}'", file.display(), )); - err.note(format!( - "consider using `--verbose` to print the full type name to the console" - )); + err.note( + "consider using `--verbose` to print the full type name to the console", + ); } } // #74711: avoid a stack overflow @@ -3524,7 +3519,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { )] fn suggest_await_before_try( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>, trait_pred: ty::PolyTraitPredicate<'tcx>, span: Span, @@ -3582,7 +3577,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_floating_point_literal( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_ref: &ty::PolyTraitRef<'tcx>, ) { let rhs_span = match obligation.cause.code() { @@ -3606,7 +3601,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_derive( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) { let Some(diagnostic_name) = self.tcx.get_diagnostic_name(trait_pred.def_id()) else { @@ -3672,7 +3667,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_dereferencing_index( &self, obligation: &PredicateObligation<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_pred: ty::PolyTraitPredicate<'tcx>, ) { if let ObligationCauseCode::ImplDerivedObligation(_) = obligation.cause.code() @@ -3695,7 +3690,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn note_function_argument_obligation( &self, body_id: LocalDefId, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, arg_hir_id: HirId, parent_code: &ObligationCauseCode<'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -3881,7 +3876,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, failed_pred: ty::Predicate<'tcx>, param_env: ty::ParamEnv<'tcx>, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, expr: &hir::Expr<'_>, ) { let tcx = self.tcx; @@ -3959,7 +3954,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { param_env: ty::ParamEnv<'tcx>, path_segment: &hir::PathSegment<'_>, args: &[hir::Expr<'_>], - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, ) { let tcx = self.tcx; // Special case for iterator chains, we look at potential failures of `Iterator::Item` @@ -4060,7 +4055,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { typeck_results: &TypeckResults<'tcx>, type_diffs: Vec>, param_env: ty::ParamEnv<'tcx>, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, ) { let mut primary_spans = vec![]; let mut span_labels = vec![]; @@ -4296,7 +4291,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// the array into a slice. fn suggest_convert_to_slice( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>, candidate_impls: &[ImplCandidate<'tcx>], @@ -4368,7 +4363,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn explain_hrtb_projection( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, pred: ty::PolyTraitPredicate<'tcx>, param_env: ty::ParamEnv<'tcx>, cause: &ObligationCause<'tcx>, @@ -4434,7 +4429,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn suggest_desugaring_async_fn_in_trait( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_ref: ty::PolyTraitRef<'tcx>, ) { // Don't suggest if RTN is active -- we should prefer a where-clause bound instead. @@ -4525,7 +4520,7 @@ fn hint_missing_borrow<'tcx>( found: Ty<'tcx>, expected: Ty<'tcx>, found_node: Node<'_>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) { if matches!(found_node, Node::TraitItem(..)) { return; @@ -4886,7 +4881,7 @@ pub fn suggest_desugaring_async_fn_to_impl_future_in_trait<'tcx>( /// they are not allowed and if possible suggest alternatives. fn point_at_assoc_type_restriction( tcx: TyCtxt<'_>, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, self_ty_str: &str, trait_name: &str, predicate: ty::Predicate<'_>, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 2b74b15ec9faa..dcbb63f00f78b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -21,8 +21,8 @@ use crate::traits::{ }; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, - FatalError, MultiSpan, StashKey, StringPart, + codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, FatalError, + MultiSpan, StashKey, StringPart, }; use rustc_hir as hir; use rustc_hir::def::{DefKind, Namespace, Res}; @@ -194,7 +194,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { cause: OverflowCause<'tcx>, span: Span, suggest_increasing_limit: bool, - mutate: impl FnOnce(&mut DiagnosticBuilder<'_>), + mutate: impl FnOnce(&mut Diag<'_>), ) -> ! { let mut err = self.build_overflow_error(cause, span, suggest_increasing_limit); mutate(&mut err); @@ -207,7 +207,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { cause: OverflowCause<'tcx>, span: Span, suggest_increasing_limit: bool, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { fn with_short_path<'tcx, T>(tcx: TyCtxt<'tcx>, value: T) -> String where T: fmt::Display + Print<'tcx, FmtPrinter<'tcx, 'tcx>>, @@ -303,7 +303,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ); } - fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>) { + fn suggest_new_overflow_limit(&self, err: &mut Diag<'_>) { let suggested_limit = match self.tcx.recursion_limit() { Limit(0) => Limit(2), limit => limit * 2, @@ -1055,7 +1055,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, obligation: &PredicateObligation<'tcx>, trait_ref: ty::TraitRef<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) -> bool { let span = obligation.cause.span; struct V<'v> { @@ -1267,7 +1267,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, ty: Ty<'tcx>, obligation: &PredicateObligation<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let span = obligation.cause.span; let mut diag = match ty.kind() { @@ -1845,7 +1845,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { impl_candidates: &[ImplCandidate<'tcx>], trait_ref: ty::PolyTraitRef<'tcx>, body_def_id: LocalDefId, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, other: bool, param_env: ty::ParamEnv<'tcx>, ) -> bool { @@ -1932,7 +1932,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } let other = if other { "other " } else { "" }; - let report = |candidates: Vec>, err: &mut DiagnosticBuilder<'_>| { + let report = |candidates: Vec>, err: &mut Diag<'_>| { if candidates.is_empty() { return false; } @@ -2067,7 +2067,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { obligation: &PredicateObligation<'tcx>, trait_predicate: ty::Binder<'tcx, ty::TraitPredicate<'tcx>>, body_def_id: LocalDefId, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) { // This is *almost* equivalent to // `obligation.cause.code().peel_derives()`, but it gives us the @@ -2138,7 +2138,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// a probable version mismatch is added to `err` fn note_version_mismatch( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, trait_ref: &ty::PolyTraitRef<'tcx>, ) -> bool { let get_trait_impls = |trait_def_id| { @@ -2607,7 +2607,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn annotate_source_of_ambiguity( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ambiguities: &[ambiguity::Ambiguity], predicate: ty::Predicate<'tcx>, ) { @@ -2750,11 +2750,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { }) } - fn note_obligation_cause( - &self, - err: &mut DiagnosticBuilder<'_>, - obligation: &PredicateObligation<'tcx>, - ) { + fn note_obligation_cause(&self, err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>) { // First, attempt to add note to this error with an async-await-specific // message, and fall back to regular note otherwise. if !self.maybe_note_obligation_cause_for_async_await(err, obligation) { @@ -2783,7 +2779,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { #[instrument(level = "debug", skip_all)] fn suggest_unsized_bound_if_applicable( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>, ) { let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) = @@ -2809,12 +2805,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } #[instrument(level = "debug", skip_all)] - fn maybe_suggest_unsized_generics( - &self, - err: &mut DiagnosticBuilder<'_>, - span: Span, - node: Node<'tcx>, - ) { + fn maybe_suggest_unsized_generics(&self, err: &mut Diag<'_>, span: Span, node: Node<'tcx>) { let Some(generics) = node.generics() else { return; }; @@ -2866,7 +2857,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn maybe_indirection_for_unsized( &self, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, item: &Item<'tcx>, param: &GenericParam<'tcx>, ) -> bool { @@ -3060,7 +3051,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn add_tuple_trait_message( &self, obligation_cause_code: &ObligationCauseCode<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, ) { match obligation_cause_code { ObligationCauseCode::RustCall => { @@ -3085,7 +3076,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { obligation: &PredicateObligation<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>, trait_predicate: &ty::PolyTraitPredicate<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, span: Span, is_fn_trait: bool, suggested: bool, @@ -3166,7 +3157,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn add_help_message_for_fn_trait( &self, trait_ref: ty::PolyTraitRef<'tcx>, - err: &mut DiagnosticBuilder<'_>, + err: &mut Diag<'_>, implemented_kind: ty::ClosureKind, params: ty::Binder<'tcx, Ty<'tcx>>, ) { @@ -3222,7 +3213,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { fn maybe_add_note_for_unsatisfied_const( &self, _trait_predicate: &ty::PolyTraitPredicate<'tcx>, - _err: &mut DiagnosticBuilder<'_>, + _err: &mut Diag<'_>, _span: Span, ) -> UnsatisfiedConst { let unsatisfied_const = UnsatisfiedConst(false); @@ -3237,7 +3228,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { found_kind: ty::ClosureKind, kind: ty::ClosureKind, trait_prefix: &'static str, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let closure_span = self.tcx.def_span(closure_def_id); let mut err = ClosureKindMismatch { @@ -3280,7 +3271,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>, expected_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>, terr: TypeError<'tcx>, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let self_ty = found_trait_ref.self_ty().skip_binder(); let (cause, terr) = if let ty::Closure(def_id, _) = self_ty.kind() { ( @@ -3300,7 +3291,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, obligation: &PredicateObligation<'tcx>, def_id: DefId, - ) -> DiagnosticBuilder<'tcx> { + ) -> Diag<'tcx> { let name = match self.tcx.opaque_type_origin(def_id.expect_local()) { hir::OpaqueTyOrigin::FnReturn(_) | hir::OpaqueTyOrigin::AsyncFn(_) => { "opaque type".to_string() @@ -3341,7 +3332,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { span: Span, found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>, expected_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>, - ) -> Result, ErrorGuaranteed> { + ) -> Result, ErrorGuaranteed> { let found_trait_ref = self.resolve_vars_if_possible(found_trait_ref); let expected_trait_ref = self.resolve_vars_if_possible(expected_trait_ref); @@ -3440,7 +3431,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, obligation: &PredicateObligation<'tcx>, span: Span, - ) -> Result, ErrorGuaranteed> { + ) -> Result, ErrorGuaranteed> { if !self.tcx.features().generic_const_exprs { let guar = self .dcx() diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index cac5379674790..32447aca390a4 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -42,7 +42,7 @@ use std::fmt::Debug; use std::ops::ControlFlow; pub use self::coherence::{add_placeholder_note, orphan_check, overlapping_impls}; -pub use self::coherence::{OrphanCheckErr, OverlapResult}; +pub use self::coherence::{IsFirstInputType, OrphanCheckErr, OverlapResult}; pub use self::engine::{ObligationCtxt, TraitEngineExt}; pub use self::fulfill::{FulfillmentContext, PendingPredicateObligation}; pub use self::normalize::NormalizeExt; @@ -172,9 +172,7 @@ fn do_normalize_predicates<'tcx>( // the normalized predicates. let errors = infcx.resolve_regions(&outlives_env); if !errors.is_empty() { - // @lcnr: Let's still ICE here for now. I want a test case - // for that. - tcx.dcx().span_bug( + tcx.dcx().span_delayed_bug( span, format!("failed region resolution while normalizing {elaborated_env:?}: {errors:?}"), ); diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index f8de19043e1bc..68c03e3c73e74 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1031,12 +1031,9 @@ fn assemble_candidates_from_impls<'cx, 'tcx>( { candidate_set.mark_ambiguous(); true - } else if obligation.predicate.args.type_at(0).to_opt_closure_kind().is_some() - && obligation.predicate.args.type_at(1).to_opt_closure_kind().is_some() - { - true } else { - false + obligation.predicate.args.type_at(0).to_opt_closure_kind().is_some() + && obligation.predicate.args.type_at(1).to_opt_closure_kind().is_some() } } else if lang_items.discriminant_kind_trait() == Some(trait_ref.def_id) { match self_ty.kind() { diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index f76be87694886..d316149731e14 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -934,7 +934,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn)) } ty::Closure(_, args) => { - let sig = args.as_closure().sig(); + let args = args.as_closure(); + let sig = args.sig(); let trait_ref = sig.map_bound(|sig| { ty::TraitRef::new( self.tcx(), @@ -950,7 +951,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::TraitRef::new(tcx, future_trait_def_id, [sig.output()]) }), )); - (trait_ref, Ty::from_closure_kind(tcx, ty::ClosureKind::Fn)) + (trait_ref, args.kind_ty()) } _ => bug!("expected callable type for AsyncFn candidate"), }; diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index a4499d438c1b5..7dbea0cdb90c9 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -29,7 +29,7 @@ use crate::traits::ProjectionCacheKey; use crate::traits::Unimplemented; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::stack::ensure_sufficient_stack; -use rustc_errors::{DiagnosticBuilder, EmissionGuarantee}; +use rustc_errors::{Diag, EmissionGuarantee}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_infer::infer::BoundRegionConversionTime; @@ -69,10 +69,7 @@ pub enum IntercrateAmbiguityCause<'tcx> { impl<'tcx> IntercrateAmbiguityCause<'tcx> { /// Emits notes when the overlap is caused by complex intercrate ambiguities. /// See #23980 for details. - pub fn add_intercrate_ambiguity_hint( - &self, - err: &mut DiagnosticBuilder<'_, G>, - ) { + pub fn add_intercrate_ambiguity_hint(&self, err: &mut Diag<'_, G>) { err.note(self.intercrate_ambiguity_hint()); } diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index 56bc2f2cf25ab..b329739609c98 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -20,7 +20,7 @@ use crate::traits::{ self, coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt, }; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{codes::*, DelayDm, DiagnosticBuilder, EmissionGuarantee}; +use rustc_errors::{codes::*, DelayDm, Diag, EmissionGuarantee}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{GenericArgs, GenericArgsRef}; @@ -392,14 +392,14 @@ fn report_conflicting_impls<'tcx>( ) -> Result<(), ErrorGuaranteed> { let impl_span = tcx.def_span(impl_def_id); - // Work to be done after we've built the DiagnosticBuilder. We have to define it - // now because the lint emit methods don't return back the DiagnosticBuilder - // that's passed in. + // Work to be done after we've built the Diag. We have to define it now + // because the lint emit methods don't return back the Diag that's passed + // in. fn decorate<'tcx, G: EmissionGuarantee>( tcx: TyCtxt<'tcx>, overlap: &OverlapError<'tcx>, impl_span: Span, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut Diag<'_, G>, ) { if (overlap.trait_ref, overlap.self_ty).references_error() { err.downgrade_to_delayed_bug(); diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index d66c4004ef5b1..6e01e0b76aafa 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -3,7 +3,7 @@ use std::collections::BTreeMap; use super::NormalizeExt; use super::{ObligationCause, PredicateObligation, SelectionContext}; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir::def_id::DefId; use rustc_infer::infer::{InferCtxt, InferOk}; use rustc_middle::ty::GenericArgsRef; @@ -46,7 +46,7 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> { /// trait aliases. pub fn label_with_exp_info( &self, - diag: &mut DiagnosticBuilder<'_>, + diag: &mut Diag<'_>, top_label: &'static str, use_desc: &str, ) { diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 638c9a53d22ab..43042dbd36641 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -312,7 +312,7 @@ fn fn_sig_for_fn_abi<'tcx>( fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv { use rustc_target::spec::abi::Abi::*; match tcx.sess.target.adjust_abi(abi, c_variadic) { - RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::Rust, + RustIntrinsic | Rust | RustCall => Conv::Rust, // This is intentionally not using `Conv::Cold`, as that has to preserve // even SIMD registers, which is generally not a good trade-off. @@ -605,7 +605,7 @@ fn fn_abi_new_uncached<'tcx>( let linux_powerpc_gnu_like = target.os == "linux" && target.arch == "powerpc" && target_env_gnu_like; use SpecAbi::*; - let rust_abi = matches!(sig.abi, RustIntrinsic | PlatformIntrinsic | Rust | RustCall); + let rust_abi = matches!(sig.abi, RustIntrinsic | Rust | RustCall); let is_drop_in_place = fn_def_id.is_some() && fn_def_id == cx.tcx.lang_items().drop_in_place_fn(); @@ -713,11 +713,7 @@ fn fn_abi_adjust_for_abi<'tcx>( return Ok(()); } - if abi == SpecAbi::Rust - || abi == SpecAbi::RustCall - || abi == SpecAbi::RustIntrinsic - || abi == SpecAbi::PlatformIntrinsic - { + if abi == SpecAbi::Rust || abi == SpecAbi::RustCall || abi == SpecAbi::RustIntrinsic { // Look up the deduced parameter attributes for this function, if we have its def ID and // we're optimizing in non-incremental mode. We'll tag its parameters with those attributes // as appropriate. @@ -753,12 +749,11 @@ fn fn_abi_adjust_for_abi<'tcx>( // target feature sets. Some more information about this // issue can be found in #44367. // - // Note that the platform intrinsic ABI is exempt here as + // Note that the intrinsic ABI is exempt here as // that's how we connect up to LLVM and it's unstable // anyway, we control all calls to it in libstd. Abi::Vector { .. } - if abi != SpecAbi::PlatformIntrinsic - && cx.tcx.sess.target.simd_types_indirect => + if abi != SpecAbi::RustIntrinsic && cx.tcx.sess.target.simd_types_indirect => { arg.make_indirect(); return; diff --git a/compiler/rustc_type_ir/Cargo.toml b/compiler/rustc_type_ir/Cargo.toml index 59966423f7fb7..79ff60802d28e 100644 --- a/compiler/rustc_type_ir/Cargo.toml +++ b/compiler/rustc_type_ir/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" # tidy-alphabetical-start bitflags = "2.4.1" derivative = "2.2.0" +rustc_ast_ir = { path = "../rustc_ast_ir" } rustc_data_structures = { path = "../rustc_data_structures", optional = true } rustc_index = { path = "../rustc_index", default-features = false } rustc_macros = { path = "../rustc_macros", optional = true } @@ -25,4 +26,5 @@ nightly = [ "rustc_span", "rustc_data_structures", "rustc_macros", + "rustc_ast_ir/nightly" ] diff --git a/compiler/rustc_type_ir/src/macros.rs b/compiler/rustc_type_ir/src/macros.rs index 82bb1bf291667..231546287d027 100644 --- a/compiler/rustc_type_ir/src/macros.rs +++ b/compiler/rustc_type_ir/src/macros.rs @@ -51,6 +51,6 @@ TrivialTypeTraversalImpls! { crate::DebruijnIndex, crate::AliasRelationDirection, crate::UniverseIndex, - crate::Mutability, - crate::Movability, + rustc_ast_ir::Mutability, + rustc_ast_ir::Movability, } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 9f715a01d44fa..a4d67169bc75c 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -11,67 +11,7 @@ use crate::{DebruijnIndex, DebugWithInfcx, InferCtxtLike, WithInfcx}; use self::TyKind::*; -/// The movability of a coroutine / closure literal: -/// whether a coroutine contains self-references, causing it to be `!Unpin`. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))] -pub enum Movability { - /// May contain self-references, `!Unpin`. - Static, - /// Must not contain self-references, `Unpin`. - Movable, -} - -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))] -pub enum Mutability { - // N.B. Order is deliberate, so that Not < Mut - Not, - Mut, -} - -impl Mutability { - pub fn invert(self) -> Self { - match self { - Mutability::Mut => Mutability::Not, - Mutability::Not => Mutability::Mut, - } - } - - /// Returns `""` (empty string) or `"mut "` depending on the mutability. - pub fn prefix_str(self) -> &'static str { - match self { - Mutability::Mut => "mut ", - Mutability::Not => "", - } - } - - /// Returns `"&"` or `"&mut "` depending on the mutability. - pub fn ref_prefix_str(self) -> &'static str { - match self { - Mutability::Not => "&", - Mutability::Mut => "&mut ", - } - } - - /// Returns `""` (empty string) or `"mutably "` depending on the mutability. - pub fn mutably_str(self) -> &'static str { - match self { - Mutability::Not => "", - Mutability::Mut => "mutably ", - } - } - - /// Return `true` if self is mutable - pub fn is_mut(self) -> bool { - matches!(self, Self::Mut) - } - - /// Return `true` if self is **not** mutable - pub fn is_not(self) -> bool { - matches!(self, Self::Not) - } -} +use rustc_ast_ir::Mutability; /// Specifies how a trait object is represented. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] diff --git a/compiler/stable_mir/src/compiler_interface.rs b/compiler/stable_mir/src/compiler_interface.rs index 6272f793f40cc..0f7d8d7e083bf 100644 --- a/compiler/stable_mir/src/compiler_interface.rs +++ b/compiler/stable_mir/src/compiler_interface.rs @@ -208,7 +208,7 @@ where if TLV.is_set() { Err(Error::from("StableMIR already running")) } else { - let ptr: *const () = &context as *const &_ as _; + let ptr: *const () = std::ptr::addr_of!(context) as _; TLV.set(&Cell::new(ptr), || Ok(f())) } } diff --git a/compiler/stable_mir/src/ty.rs b/compiler/stable_mir/src/ty.rs index 658e8aa28b544..ed4a4290246b0 100644 --- a/compiler/stable_mir/src/ty.rs +++ b/compiler/stable_mir/src/ty.rs @@ -906,7 +906,6 @@ pub enum Abi { System { unwind: bool }, RustIntrinsic, RustCall, - PlatformIntrinsic, Unadjusted, RustCold, RiscvInterruptM, diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index 3b29c144a89f8..0421a12b3a952 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -176,7 +176,7 @@ impl ThinBox { fn with_header(&self) -> &WithHeader<::Metadata> { // SAFETY: both types are transparent to `NonNull` - unsafe { &*((&self.ptr) as *const WithOpaqueHeader as *const WithHeader<_>) } + unsafe { &*(core::ptr::addr_of!(self.ptr) as *const WithHeader<_>) } } } diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 80be4ee57c5c0..271ea88fff652 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -2916,7 +2916,7 @@ impl<'a, K, V> Cursor<'a, K, V> { } } - /// Returns a reference to the the key and value of the next element without + /// Returns a reference to the key and value of the next element without /// moving the cursor. /// /// If the cursor is at the end of the map then `None` is returned @@ -2925,7 +2925,7 @@ impl<'a, K, V> Cursor<'a, K, V> { self.clone().next() } - /// Returns a reference to the the key and value of the previous element + /// Returns a reference to the key and value of the previous element /// without moving the cursor. /// /// If the cursor is at the start of the map then `None` is returned. @@ -2958,7 +2958,7 @@ impl<'a, K, V, A> CursorMut<'a, K, V, A> { Some((&*k, v)) } - /// Returns a reference to the the key and value of the next element without + /// Returns a reference to the key and value of the next element without /// moving the cursor. /// /// If the cursor is at the end of the map then `None` is returned @@ -2968,7 +2968,7 @@ impl<'a, K, V, A> CursorMut<'a, K, V, A> { Some((&*k, v)) } - /// Returns a reference to the the key and value of the previous element + /// Returns a reference to the key and value of the previous element /// without moving the cursor. /// /// If the cursor is at the start of the map then `None` is returned. @@ -3056,7 +3056,7 @@ impl<'a, K, V, A> CursorMutKey<'a, K, V, A> { } } - /// Returns a reference to the the key and value of the next element without + /// Returns a reference to the key and value of the next element without /// moving the cursor. /// /// If the cursor is at the end of the map then `None` is returned @@ -3068,7 +3068,7 @@ impl<'a, K, V, A> CursorMutKey<'a, K, V, A> { Some(kv) } - /// Returns a reference to the the key and value of the previous element + /// Returns a reference to the key and value of the previous element /// without moving the cursor. /// /// If the cursor is at the start of the map then `None` is returned. diff --git a/library/alloc/src/ffi/c_str.rs b/library/alloc/src/ffi/c_str.rs index 9419b0cfb24fa..61ec04a4849d0 100644 --- a/library/alloc/src/ffi/c_str.rs +++ b/library/alloc/src/ffi/c_str.rs @@ -11,7 +11,7 @@ use core::borrow::Borrow; use core::ffi::{c_char, CStr}; use core::fmt; use core::mem; -use core::num::NonZeroU8; +use core::num::NonZero; use core::ops; use core::ptr; use core::slice; @@ -795,22 +795,22 @@ impl From> for CString { } #[stable(feature = "cstring_from_vec_of_nonzerou8", since = "1.43.0")] -impl From> for CString { - /// Converts a [Vec]<[NonZeroU8]> into a [`CString`] without +impl From>> for CString { + /// Converts a [Vec]<[NonZero]<[u8]>> into a [`CString`] without /// copying nor checking for inner nul bytes. #[inline] - fn from(v: Vec) -> CString { + fn from(v: Vec>) -> CString { unsafe { - // Transmute `Vec` to `Vec`. + // Transmute `Vec>` to `Vec`. let v: Vec = { // SAFETY: - // - transmuting between `NonZeroU8` and `u8` is sound; - // - `alloc::Layout == alloc::Layout`. - let (ptr, len, cap): (*mut NonZeroU8, _, _) = Vec::into_raw_parts(v); + // - transmuting between `NonZero` and `u8` is sound; + // - `alloc::Layout> == alloc::Layout`. + let (ptr, len, cap): (*mut NonZero, _, _) = Vec::into_raw_parts(v); Vec::from_raw_parts(ptr.cast::(), len, cap) }; // SAFETY: `v` cannot contain nul bytes, given the type-level - // invariant of `NonZeroU8`. + // invariant of `NonZero`. Self::_from_vec_unchecked(v) } } diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index b84273848ee95..28695ade5bf55 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -92,6 +92,7 @@ #![warn(multiple_supertrait_upcastable)] #![allow(internal_features)] #![allow(rustdoc::redundant_explicit_links)] +#![deny(ffi_unwind_calls)] // // Library features: // tidy-alphabetical-start @@ -151,6 +152,7 @@ #![feature(set_ptr_value)] #![feature(sized_type_properties)] #![feature(slice_from_ptr_range)] +#![feature(slice_index_methods)] #![feature(slice_ptr_get)] #![feature(slice_ptr_len)] #![feature(slice_range)] diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index c3d0019be3975..084157b97ab41 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1969,7 +1969,7 @@ impl Rc { // Copy value as bytes ptr::copy_nonoverlapping( - &*src as *const T as *const u8, + core::ptr::addr_of!(*src) as *const u8, ptr::addr_of_mut!((*ptr).value) as *mut u8, value_size, ); @@ -2440,7 +2440,7 @@ impl fmt::Debug for Rc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Rc { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&(&**self as *const T), f) + fmt::Pointer::fmt(&core::ptr::addr_of!(**self), f) } } diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 6dadbc8e36428..98ded7f6cdf5b 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -54,7 +54,7 @@ use core::ops::Add; use core::ops::AddAssign; #[cfg(not(no_global_oom_handling))] use core::ops::Bound::{Excluded, Included, Unbounded}; -use core::ops::{self, Index, IndexMut, Range, RangeBounds}; +use core::ops::{self, Range, RangeBounds}; use core::ptr; use core::slice; use core::str::pattern::Pattern; @@ -864,7 +864,7 @@ impl String { } } - /// Decomposes a `String` into its raw components. + /// Decomposes a `String` into its raw components: `(pointer, length, capacity)`. /// /// Returns the raw pointer to the underlying data, the length of /// the string (in bytes), and the allocated capacity of the data @@ -896,7 +896,7 @@ impl String { self.vec.into_raw_parts() } - /// Creates a new `String` from a length, capacity, and pointer. + /// Creates a new `String` from a pointer, a length and a capacity. /// /// # Safety /// @@ -2433,100 +2433,26 @@ impl AddAssign<&str> for String { } #[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index> for String { - type Output = str; +impl ops::Index for String +where + I: slice::SliceIndex, +{ + type Output = I::Output; #[inline] - fn index(&self, index: ops::Range) -> &str { - &self[..][index] + fn index(&self, index: I) -> &I::Output { + index.index(self.as_str()) } } -#[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index> for String { - type Output = str; - #[inline] - fn index(&self, index: ops::RangeTo) -> &str { - &self[..][index] - } -} #[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index> for String { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeFrom) -> &str { - &self[..][index] - } -} -#[stable(feature = "rust1", since = "1.0.0")] -impl ops::Index for String { - type Output = str; - - #[inline] - fn index(&self, _index: ops::RangeFull) -> &str { - unsafe { str::from_utf8_unchecked(&self.vec) } - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::Index> for String { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeInclusive) -> &str { - Index::index(&**self, index) - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::Index> for String { - type Output = str; - - #[inline] - fn index(&self, index: ops::RangeToInclusive) -> &str { - Index::index(&**self, index) - } -} - -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::Range) -> &mut str { - &mut self[..][index] - } -} -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::RangeTo) -> &mut str { - &mut self[..][index] - } -} -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::RangeFrom) -> &mut str { - &mut self[..][index] - } -} -#[stable(feature = "derefmut_for_string", since = "1.3.0")] -impl ops::IndexMut for String { - #[inline] - fn index_mut(&mut self, _index: ops::RangeFull) -> &mut str { - unsafe { str::from_utf8_unchecked_mut(&mut *self.vec) } - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::IndexMut> for String { - #[inline] - fn index_mut(&mut self, index: ops::RangeInclusive) -> &mut str { - IndexMut::index_mut(&mut **self, index) - } -} -#[stable(feature = "inclusive_range", since = "1.26.0")] -impl ops::IndexMut> for String { +impl ops::IndexMut for String +where + I: slice::SliceIndex, +{ #[inline] - fn index_mut(&mut self, index: ops::RangeToInclusive) -> &mut str { - IndexMut::index_mut(&mut **self, index) + fn index_mut(&mut self, index: I) -> &mut I::Output { + index.index_mut(self.as_mut_str()) } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 524aa35e04529..00f47f5c6e0ed 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1914,7 +1914,7 @@ impl Arc { // Copy value as bytes ptr::copy_nonoverlapping( - &*src as *const T as *const u8, + core::ptr::addr_of!(*src) as *const u8, ptr::addr_of_mut!((*ptr).data) as *mut u8, value_size, ); @@ -3265,7 +3265,7 @@ impl fmt::Debug for Arc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Arc { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Pointer::fmt(&(&**self as *const T), f) + fmt::Pointer::fmt(&core::ptr::addr_of!(**self), f) } } diff --git a/library/alloc/src/vec/is_zero.rs b/library/alloc/src/vec/is_zero.rs index cb9adf05c25b0..bcc5bf4d65bb4 100644 --- a/library/alloc/src/vec/is_zero.rs +++ b/library/alloc/src/vec/is_zero.rs @@ -1,4 +1,4 @@ -use core::num::{Saturating, Wrapping}; +use core::num::{NonZero, Saturating, Wrapping}; use crate::boxed::Box; @@ -69,7 +69,7 @@ unsafe impl IsZero for [T; N] { } // This is recursive macro. -macro_rules! impl_for_tuples { +macro_rules! impl_is_zero_tuples { // Stopper () => { // No use for implementing for empty tuple because it is ZST. @@ -88,11 +88,11 @@ macro_rules! impl_for_tuples { } } - impl_for_tuples!($($rest),*); + impl_is_zero_tuples!($($rest),*); } } -impl_for_tuples!(A, B, C, D, E, F, G, H); +impl_is_zero_tuples!(A, B, C, D, E, F, G, H); // `Option<&T>` and `Option>` are guaranteed to represent `None` as null. // For fat pointers, the bytes that would be the pointer metadata in the `Some` @@ -115,16 +115,15 @@ unsafe impl IsZero for Option> { } } -// `Option` and similar have a representation guarantee that +// `Option>` and similar have a representation guarantee that // they're the same size as the corresponding `u32` type, as well as a guarantee -// that transmuting between `NonZeroU32` and `Option` works. +// that transmuting between `NonZero` and `Option>` works. // While the documentation officially makes it UB to transmute from `None`, // we're the standard library so we can make extra inferences, and we know that // the only niche available to represent `None` is the one that's all zeros. - -macro_rules! impl_is_zero_option_of_nonzero { - ($($t:ident,)+) => {$( - unsafe impl IsZero for Option { +macro_rules! impl_is_zero_option_of_nonzero_int { + ($($t:ty),+ $(,)?) => {$( + unsafe impl IsZero for Option> { #[inline] fn is_zero(&self) -> bool { self.is_none() @@ -133,23 +132,10 @@ macro_rules! impl_is_zero_option_of_nonzero { )+}; } -impl_is_zero_option_of_nonzero!( - NonZeroU8, - NonZeroU16, - NonZeroU32, - NonZeroU64, - NonZeroU128, - NonZeroI8, - NonZeroI16, - NonZeroI32, - NonZeroI64, - NonZeroI128, - NonZeroUsize, - NonZeroIsize, -); - -macro_rules! impl_is_zero_option_of_num { - ($($t:ty,)+) => {$( +impl_is_zero_option_of_nonzero_int!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize); + +macro_rules! impl_is_zero_option_of_int { + ($($t:ty),+ $(,)?) => {$( unsafe impl IsZero for Option<$t> { #[inline] fn is_zero(&self) -> bool { @@ -163,7 +149,7 @@ macro_rules! impl_is_zero_option_of_num { )+}; } -impl_is_zero_option_of_num!(u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, usize, isize,); +impl_is_zero_option_of_int!(u8, u16, u32, u64, u128, i8, i16, i32, i64, i128, usize, isize); unsafe impl IsZero for Wrapping { #[inline] @@ -179,8 +165,8 @@ unsafe impl IsZero for Saturating { } } -macro_rules! impl_for_optional_bool { - ($($t:ty,)+) => {$( +macro_rules! impl_is_zero_option_of_bool { + ($($t:ty),+ $(,)?) => {$( unsafe impl IsZero for $t { #[inline] fn is_zero(&self) -> bool { @@ -194,9 +180,10 @@ macro_rules! impl_for_optional_bool { } )+}; } -impl_for_optional_bool! { + +impl_is_zero_option_of_bool! { Option, Option>, Option>>, - // Could go further, but not worth the metadata overhead + // Could go further, but not worth the metadata overhead. } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index b59699219eb84..7bd19875584a3 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -481,7 +481,7 @@ impl Vec { Self::with_capacity_in(capacity, Global) } - /// Creates a `Vec` directly from a pointer, a capacity, and a length. + /// Creates a `Vec` directly from a pointer, a length, and a capacity. /// /// # Safety /// @@ -672,7 +672,7 @@ impl Vec { Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 } } - /// Creates a `Vec` directly from a pointer, a capacity, a length, + /// Creates a `Vec` directly from a pointer, a length, a capacity, /// and an allocator. /// /// # Safety @@ -786,7 +786,7 @@ impl Vec { unsafe { Vec { buf: RawVec::from_raw_parts_in(ptr, capacity, alloc), len: length } } } - /// Decomposes a `Vec` into its raw components. + /// Decomposes a `Vec` into its raw components: `(pointer, length, capacity)`. /// /// Returns the raw pointer to the underlying data, the length of /// the vector (in elements), and the allocated capacity of the @@ -824,7 +824,7 @@ impl Vec { (me.as_mut_ptr(), me.len(), me.capacity()) } - /// Decomposes a `Vec` into its raw components. + /// Decomposes a `Vec` into its raw components: `(pointer, length, capacity, allocator)`. /// /// Returns the raw pointer to the underlying data, the length of the vector (in elements), /// the allocated capacity of the data (in elements), and the allocator. These are the same diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 743f07644e354..42663ff2b53f0 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -511,7 +511,7 @@ impl [T; N] { /// # Examples /// /// ``` - /// #![feature(array_try_map)] + /// #![feature(array_try_map, generic_nonzero)] /// let a = ["1", "2", "3"]; /// let b = a.try_map(|v| v.parse::()).unwrap().map(|v| v + 1); /// assert_eq!(b, [2, 3, 4]); @@ -520,12 +520,12 @@ impl [T; N] { /// let b = a.try_map(|v| v.parse::()); /// assert!(b.is_err()); /// - /// use std::num::NonZeroU32; + /// use std::num::NonZero; /// let z = [1, 2, 0, 3, 4]; - /// assert_eq!(z.try_map(NonZeroU32::new), None); + /// assert_eq!(z.try_map(NonZero::new), None); /// let a = [1, 2, 3]; - /// let b = a.try_map(NonZeroU32::new); - /// let c = b.map(|x| x.map(NonZeroU32::get)); + /// let b = a.try_map(NonZero::new); + /// let c = b.map(|x| x.map(NonZero::get)); /// assert_eq!(c, Some(a)); /// ``` #[unstable(feature = "array_try_map", issue = "79711")] diff --git a/library/core/src/cmp/bytewise.rs b/library/core/src/cmp/bytewise.rs index b19eef8e25587..a06a5227fe285 100644 --- a/library/core/src/cmp/bytewise.rs +++ b/library/core/src/cmp/bytewise.rs @@ -1,5 +1,4 @@ -use crate::num::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize}; -use crate::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; +use crate::num::NonZero; /// Types where `==` & `!=` are equivalent to comparing their underlying bytes. /// @@ -36,18 +35,18 @@ is_bytewise_comparable!(bool, char, super::Ordering); // SAFETY: Similarly, the `NonZero` type has a niche, but no undef and no pointers, // and they compare like their underlying numeric type. is_bytewise_comparable!( - NonZeroU8, - NonZeroU16, - NonZeroU32, - NonZeroU64, - NonZeroU128, - NonZeroUsize, - NonZeroI8, - NonZeroI16, - NonZeroI32, - NonZeroI64, - NonZeroI128, - NonZeroIsize, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, + NonZero, ); // SAFETY: The `NonZero` type has the "null" optimization guaranteed, and thus @@ -55,18 +54,18 @@ is_bytewise_comparable!( // The way `PartialOrd` is defined for `Option` means that this wouldn't work // for `<` or `>` on the signed types, but since we only do `==` it's fine. is_bytewise_comparable!( - Option, - Option, - Option, - Option, - Option, - Option, - Option, - Option, - Option, - Option, - Option, - Option, + Option>, + Option>, + Option>, + Option>, + Option>, + Option>, + Option>, + Option>, + Option>, + Option>, + Option>, + Option>, ); macro_rules! is_bytewise_comparable_array_length { diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 45f6e375e8942..85740dce8668c 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -396,6 +396,7 @@ pub trait AsMut { /// For example, take this code: /// /// ``` +/// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))] /// struct Wrapper(Vec); /// impl From> for Vec { /// fn from(w: Wrapper) -> Vec { diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 248943cf02260..20186a2de0fd8 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -4,6 +4,7 @@ use crate::ffi::c_char; use crate::fmt; use crate::intrinsics; use crate::ops; +use crate::ptr::addr_of; use crate::slice; use crate::slice::memchr; use crate::str; @@ -603,7 +604,7 @@ impl CStr { pub const fn to_bytes_with_nul(&self) -> &[u8] { // SAFETY: Transmuting a slice of `c_char`s to a slice of `u8`s // is safe on all supported targets. - unsafe { &*(&self.inner as *const [c_char] as *const [u8]) } + unsafe { &*(addr_of!(self.inner) as *const [u8]) } } /// Yields a &[str] slice if the `CStr` contains valid UTF-8. diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index 153971a59c5c9..bfdd28a7399fd 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -454,6 +454,7 @@ pub trait Hasher { /// ``` /// #![feature(hasher_prefixfree_extras)] /// # // Stubs to make the `impl` below pass the compiler + /// # #![cfg_attr(not(bootstrap), allow(non_local_definitions))] /// # struct MyCollection(Option); /// # impl MyCollection { /// # fn len(&self) -> usize { todo!() } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index e42b2315ea5d7..96e667d63c5f3 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -44,6 +44,15 @@ //! * Sequentially consistent - sequentially consistent operations are //! guaranteed to happen in order. This is the standard mode for working //! with atomic types and is equivalent to Java's `volatile`. +//! +//! # Unwinding +//! +//! Rust intrinsics may, in general, unwind. If an intrinsic can never unwind, add the +//! `#[rustc_nounwind]` attribute so that the compiler can make use of this fact. +//! +//! However, even for intrinsics that may unwind, rustc assumes that a Rust intrinsics will never +//! initiate a foreign (non-Rust) unwind, and thus for panic=abort we can always assume that these +//! intrinsics cannot unwind. #![unstable( feature = "core_intrinsics", @@ -75,6 +84,9 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { unsafe { crate::ptr::drop_in_place(to_drop) } } +#[cfg(bootstrap)] +pub use self::r#try as catch_unwind; + extern "rust-intrinsic" { // N.B., these intrinsics take raw pointers because they mutate aliased // memory, which is not valid for either `&` or `&mut`. @@ -689,6 +701,7 @@ extern "rust-intrinsic" { /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_min`]. + #[rustc_nounwind] pub fn atomic_min_acqrel(dst: *mut T, src: T) -> T; /// Minimum with the current value using a signed comparison. /// @@ -2382,16 +2395,24 @@ extern "rust-intrinsic" { #[rustc_nounwind] pub fn variant_count() -> usize; - /// Rust's "try catch" construct which invokes the function pointer `try_fn` - /// with the data pointer `data`. - /// - /// The third argument is a function called if a panic occurs. This function - /// takes the data pointer and a pointer to the target-specific exception - /// object that was caught. For more information see the compiler's - /// source as well as std's catch implementation. + /// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the + /// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs. /// /// `catch_fn` must not unwind. + /// + /// The third argument is a function called if an unwind occurs (both Rust unwinds and foreign + /// unwinds). This function takes the data pointer and a pointer to the target-specific + /// exception object that was caught. For more information, see the compiler's source as well as + /// std's `catch_unwind` implementation. + /// + /// The stable version of this intrinsic is `std::panic::catch_unwind`. + #[rustc_nounwind] + #[cfg(not(bootstrap))] + pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; + + /// For bootstrap only, see `catch_unwind`. #[rustc_nounwind] + #[cfg(bootstrap)] pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; /// Emits a `!nontemporal` store according to LLVM (see their docs). @@ -2706,13 +2727,25 @@ pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) macro_rules! assert_unsafe_precondition { ($message:expr, ($($name:ident:$ty:ty = $arg:expr),*$(,)?) => $e:expr $(,)?) => { { + // #[cfg(bootstrap)] (this comment) // When the standard library is compiled with debug assertions, we want the check to inline for better performance. // This is important when working on the compiler, which is compiled with debug assertions locally. // When not compiled with debug assertions (so the precompiled std) we outline the check to minimize the compile // time impact when debug assertions are disabled. - // It is not clear whether that is the best solution, see #120848. - #[cfg_attr(debug_assertions, inline(always))] - #[cfg_attr(not(debug_assertions), inline(never))] + // The proper solution to this is the `#[rustc_no_mir_inline]` below, but we still want decent performance for cfg(bootstrap). + #[cfg_attr(all(debug_assertions, bootstrap), inline(always))] + #[cfg_attr(all(not(debug_assertions), bootstrap), inline(never))] + + // This check is inlineable, but not by the MIR inliner. + // The reason for this is that the MIR inliner is in an exceptionally bad position + // to think about whether or not to inline this. In MIR, this call is gated behind `debug_assertions`, + // which will codegen to `false` in release builds. Inlining the check would be wasted work in that case and + // would be bad for compile times. + // + // LLVM on the other hand sees the constant branch, so if it's `false`, it can immediately delete it without + // inlining the check. If it's `true`, it can inline it and get significantly better performance. + #[cfg_attr(not(bootstrap), rustc_no_mir_inline)] + #[cfg_attr(not(bootstrap), inline)] #[rustc_nounwind] fn precondition_check($($name:$ty),*) { if !$e { diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index d8a1ad778d752..2eaca3b6fe4d5 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -2,7 +2,11 @@ //! //! In this module, a "vector" is any `repr(simd)` type. -extern "platform-intrinsic" { +// Temporary macro while we switch the ABI from "platform-intrinsics" to "intrinsics". +#[rustfmt::skip] +macro_rules! declare_intrinsics { +($abi:tt) => { +extern $abi { /// Insert an element into a vector, returning the updated vector. /// /// `T` must be a vector with element type `U`. @@ -10,6 +14,7 @@ extern "platform-intrinsic" { /// # Safety /// /// `idx` must be in-bounds of the vector. + #[rustc_nounwind] pub fn simd_insert(x: T, idx: u32, val: U) -> T; /// Extract an element from a vector. @@ -19,21 +24,25 @@ extern "platform-intrinsic" { /// # Safety /// /// `idx` must be in-bounds of the vector. + #[rustc_nounwind] pub fn simd_extract(x: T, idx: u32) -> U; /// Add two simd vectors elementwise. /// /// `T` must be a vector of integer or floating point primitive types. + #[rustc_nounwind] pub fn simd_add(x: T, y: T) -> T; /// Subtract `rhs` from `lhs` elementwise. /// /// `T` must be a vector of integer or floating point primitive types. + #[rustc_nounwind] pub fn simd_sub(lhs: T, rhs: T) -> T; /// Multiply two simd vectors elementwise. /// /// `T` must be a vector of integer or floating point primitive types. + #[rustc_nounwind] pub fn simd_mul(x: T, y: T) -> T; /// Divide `lhs` by `rhs` elementwise. @@ -43,6 +52,7 @@ extern "platform-intrinsic" { /// # Safety /// For integers, `rhs` must not contain any zero elements. /// Additionally for signed integers, `::MIN / -1` is undefined behavior. + #[rustc_nounwind] pub fn simd_div(lhs: T, rhs: T) -> T; /// Remainder of two vectors elementwise @@ -52,6 +62,7 @@ extern "platform-intrinsic" { /// # Safety /// For integers, `rhs` must not contain any zero elements. /// Additionally for signed integers, `::MIN / -1` is undefined behavior. + #[rustc_nounwind] pub fn simd_rem(lhs: T, rhs: T) -> T; /// Elementwise vector left shift, with UB on overflow. @@ -63,6 +74,7 @@ extern "platform-intrinsic" { /// # Safety /// /// Each element of `rhs` must be less than `::BITS`. + #[rustc_nounwind] pub fn simd_shl(lhs: T, rhs: T) -> T; /// Elementwise vector right shift, with UB on overflow. @@ -74,21 +86,25 @@ extern "platform-intrinsic" { /// # Safety /// /// Each element of `rhs` must be less than `::BITS`. + #[rustc_nounwind] pub fn simd_shr(lhs: T, rhs: T) -> T; /// Elementwise vector "and". /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_and(x: T, y: T) -> T; /// Elementwise vector "or". /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_or(x: T, y: T) -> T; /// Elementwise vector "exclusive or". /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_xor(x: T, y: T) -> T; /// Numerically cast a vector, elementwise. @@ -109,6 +125,7 @@ extern "platform-intrinsic" { /// * Not be `NaN` /// * Not be infinite /// * Be representable in the return type, after truncating off its fractional part + #[rustc_nounwind] pub fn simd_cast(x: T) -> U; /// Numerically cast a vector, elementwise. @@ -122,6 +139,7 @@ extern "platform-intrinsic" { /// When casting floats to integers, the result is truncated. /// When casting integers to floats, the result is rounded. /// Otherwise, truncates or extends the value, maintaining the sign for signed integers. + #[rustc_nounwind] pub fn simd_as(x: T) -> U; /// Elementwise negation of a vector. @@ -129,11 +147,13 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// Rust panics for `-::Min` due to overflow, but it is not UB with this intrinsic. + #[rustc_nounwind] pub fn simd_neg(x: T) -> T; /// Elementwise absolute value of a vector. /// /// `T` must be a vector of floating-point primitive types. + #[rustc_nounwind] pub fn simd_fabs(x: T) -> T; /// Elementwise minimum of a vector. @@ -141,6 +161,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of floating-point primitive types. /// /// Follows IEEE-754 `minNum` semantics. + #[rustc_nounwind] pub fn simd_fmin(x: T, y: T) -> T; /// Elementwise maximum of a vector. @@ -148,6 +169,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of floating-point primitive types. /// /// Follows IEEE-754 `maxNum` semantics. + #[rustc_nounwind] pub fn simd_fmax(x: T, y: T) -> T; /// Tests elementwise equality of two vectors. @@ -157,6 +179,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_eq(x: T, y: T) -> U; /// Tests elementwise inequality equality of two vectors. @@ -166,6 +189,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_ne(x: T, y: T) -> U; /// Tests if `x` is less than `y`, elementwise. @@ -175,6 +199,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_lt(x: T, y: T) -> U; /// Tests if `x` is less than or equal to `y`, elementwise. @@ -184,6 +209,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_le(x: T, y: T) -> U; /// Tests if `x` is greater than `y`, elementwise. @@ -193,6 +219,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_gt(x: T, y: T) -> U; /// Tests if `x` is greater than or equal to `y`, elementwise. @@ -202,6 +229,7 @@ extern "platform-intrinsic" { /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// /// Returns `0` for false and `!0` for true. + #[rustc_nounwind] pub fn simd_ge(x: T, y: T) -> U; /// Shuffle two vectors by const indices. @@ -216,6 +244,7 @@ extern "platform-intrinsic" { /// Returns a new vector such that element `i` is selected from `xy[idx[i]]`, where `xy` /// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds /// of `xy`. + #[rustc_nounwind] pub fn simd_shuffle(x: T, y: T, idx: U) -> V; /// Shuffle two vectors by const indices. @@ -227,6 +256,7 @@ extern "platform-intrinsic" { /// Returns a new vector such that element `i` is selected from `xy[IDX[i]]`, where `xy` /// is the concatenation of `x` and `y`. It is a compile-time error if `IDX[i]` is out-of-bounds /// of `xy`. + #[rustc_nounwind] pub fn simd_shuffle_generic(x: T, y: T) -> U; /// Read a vector of pointers. @@ -249,6 +279,7 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_gather(val: T, ptr: U, mask: V) -> T; /// Write to a vector of pointers. @@ -271,6 +302,7 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_scatter(val: T, ptr: U, mask: V); /// Read a vector of pointers. @@ -292,6 +324,7 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_masked_load(mask: V, ptr: U, val: T) -> T; /// Write to a vector of pointers. @@ -312,11 +345,13 @@ extern "platform-intrinsic" { /// type). /// /// `mask` must only contain `0` or `!0` values. + #[rustc_nounwind] pub fn simd_masked_store(mask: V, ptr: U, val: T); /// Add two simd vectors elementwise, with saturation. /// /// `T` must be a vector of integer primitive types. + #[rustc_nounwind] pub fn simd_saturating_add(x: T, y: T) -> T; /// Subtract two simd vectors elementwise, with saturation. @@ -324,6 +359,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer primitive types. /// /// Subtract `rhs` from `lhs`. + #[rustc_nounwind] pub fn simd_saturating_sub(lhs: T, rhs: T) -> T; /// Add elements within a vector from left to right. @@ -333,6 +369,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// Starting with the value `y`, add the elements of `x` and accumulate. + #[rustc_nounwind] pub fn simd_reduce_add_ordered(x: T, y: U) -> U; /// Add elements within a vector in arbitrary order. May also be re-associated with @@ -341,6 +378,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_add_unordered(x: T) -> U; /// Multiply elements within a vector from left to right. @@ -350,6 +388,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// Starting with the value `y`, multiply the elements of `x` and accumulate. + #[rustc_nounwind] pub fn simd_reduce_mul_ordered(x: T, y: U) -> U; /// Add elements within a vector in arbitrary order. May also be re-associated with @@ -358,6 +397,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_mul_unordered(x: T) -> U; /// Check if all mask values are true. @@ -366,6 +406,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `x` must contain only `0` or `!0`. + #[rustc_nounwind] pub fn simd_reduce_all(x: T) -> bool; /// Check if all mask values are true. @@ -374,6 +415,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `x` must contain only `0` or `!0`. + #[rustc_nounwind] pub fn simd_reduce_any(x: T) -> bool; /// Return the maximum element of a vector. @@ -383,6 +425,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// For floating-point values, uses IEEE-754 `maxNum`. + #[rustc_nounwind] pub fn simd_reduce_max(x: T) -> U; /// Return the minimum element of a vector. @@ -392,6 +435,7 @@ extern "platform-intrinsic" { /// `U` must be the element type of `T`. /// /// For floating-point values, uses IEEE-754 `minNum`. + #[rustc_nounwind] pub fn simd_reduce_min(x: T) -> U; /// Logical "and" all elements together. @@ -399,6 +443,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_and(x: T) -> U; /// Logical "or" all elements together. @@ -406,6 +451,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_or(x: T) -> U; /// Logical "exclusive or" all elements together. @@ -413,6 +459,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of integer or floating-point primitive types. /// /// `U` must be the element type of `T`. + #[rustc_nounwind] pub fn simd_reduce_xor(x: T) -> U; /// Truncate an integer vector to a bitmask. @@ -441,6 +488,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `x` must contain only `0` and `!0`. + #[rustc_nounwind] pub fn simd_bitmask(x: T) -> U; /// Select elements from a mask. @@ -455,6 +503,7 @@ extern "platform-intrinsic" { /// /// # Safety /// `mask` must only contain `0` and `!0`. + #[rustc_nounwind] pub fn simd_select(mask: M, if_true: T, if_false: T) -> T; /// Select elements from a bitmask. @@ -471,6 +520,7 @@ extern "platform-intrinsic" { /// /// # Safety /// Padding bits must be all zero. + #[rustc_nounwind] pub fn simd_select_bitmask(m: M, yes: T, no: T) -> T; /// Elementwise calculates the offset from a pointer vector, potentially wrapping. @@ -480,11 +530,13 @@ extern "platform-intrinsic" { /// `U` must be a vector of `isize` or `usize` with the same number of elements as `T`. /// /// Operates as if by `::wrapping_offset`. + #[rustc_nounwind] pub fn simd_arith_offset(ptr: T, offset: U) -> T; /// Cast a vector of pointers. /// /// `T` and `U` must be vectors of pointers with the same number of elements. + #[rustc_nounwind] pub fn simd_cast_ptr(ptr: T) -> U; /// Expose a vector of pointers as a vector of addresses. @@ -492,6 +544,7 @@ extern "platform-intrinsic" { /// `T` must be a vector of pointers. /// /// `U` must be a vector of `usize` with the same length as `T`. + #[rustc_nounwind] pub fn simd_expose_addr(ptr: T) -> U; /// Create a vector of pointers from a vector of addresses. @@ -499,92 +552,117 @@ extern "platform-intrinsic" { /// `T` must be a vector of `usize`. /// /// `U` must be a vector of pointers, with the same length as `T`. + #[rustc_nounwind] pub fn simd_from_exposed_addr(addr: T) -> U; /// Swap bytes of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_bswap(x: T) -> T; /// Reverse bits of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_bitreverse(x: T) -> T; /// Count the leading zeros of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_ctlz(x: T) -> T; /// Count the trailing zeros of each element. /// /// `T` must be a vector of integers. + #[rustc_nounwind] pub fn simd_cttz(x: T) -> T; /// Round up each element to the next highest integer-valued float. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_ceil(x: T) -> T; /// Round down each element to the next lowest integer-valued float. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_floor(x: T) -> T; /// Round each element to the closest integer-valued float. /// Ties are resolved by rounding away from 0. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_round(x: T) -> T; /// Return the integer part of each element as an integer-valued float. /// In other words, non-integer values are truncated towards zero. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_trunc(x: T) -> T; /// Takes the square root of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fsqrt(x: T) -> T; /// Computes `(x*y) + z` for each element, but without any intermediate rounding. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fma(x: T, y: T, z: T) -> T; // Computes the sine of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fsin(a: T) -> T; // Computes the cosine of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fcos(a: T) -> T; // Computes the exponential function of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fexp(a: T) -> T; // Computes 2 raised to the power of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_fexp2(a: T) -> T; // Computes the base 10 logarithm of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_flog10(a: T) -> T; // Computes the base 2 logarithm of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_flog2(a: T) -> T; // Computes the natural logarithm of each element. /// /// `T` must be a vector of floats. + #[rustc_nounwind] pub fn simd_flog(a: T) -> T; } +} +} + +#[cfg(bootstrap)] +declare_intrinsics!("platform-intrinsic"); +#[cfg(not(bootstrap))] +declare_intrinsics!("rust-intrinsic"); diff --git a/library/core/src/iter/adapters/filter_map.rs b/library/core/src/iter/adapters/filter_map.rs index 64bd5b3e2b668..1a5f9e6265454 100644 --- a/library/core/src/iter/adapters/filter_map.rs +++ b/library/core/src/iter/adapters/filter_map.rs @@ -2,6 +2,7 @@ use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedF use crate::mem::{ManuallyDrop, MaybeUninit}; use crate::num::NonZero; use crate::ops::{ControlFlow, Try}; +use crate::ptr::addr_of; use crate::{array, fmt}; /// An iterator that uses `f` to both filter and map elements from `iter`. @@ -98,9 +99,8 @@ where // SAFETY: Loop conditions ensure the index is in bounds. unsafe { - let opt_payload_at: *const MaybeUninit = (&val as *const Option) - .byte_add(core::mem::offset_of!(Option, Some.0)) - .cast(); + let opt_payload_at: *const MaybeUninit = + addr_of!(val).byte_add(core::mem::offset_of!(Option, Some.0)).cast(); let dst = guard.array.as_mut_ptr().add(idx); crate::ptr::copy_nonoverlapping(opt_payload_at, dst, 1); crate::mem::forget(val); diff --git a/library/core/src/iter/traits/double_ended.rs b/library/core/src/iter/traits/double_ended.rs index 48aae73d928a0..35092ec51cdd9 100644 --- a/library/core/src/iter/traits/double_ended.rs +++ b/library/core/src/iter/traits/double_ended.rs @@ -100,7 +100,7 @@ pub trait DoubleEndedIterator: Iterator { /// to `n` times until [`None`] is encountered. /// /// `advance_back_by(n)` will return `Ok(())` if the iterator successfully advances by - /// `n` elements, or a `Err(NonZeroUsize)` with value `k` if [`None`] is encountered, where `k` + /// `n` elements, or a `Err(NonZero)` with value `k` if [`None`] is encountered, where `k` /// is remaining number of steps that could not be advanced because the iterator ran out. /// If `self` is empty and `n` is non-zero, then this returns `Err(n)`. /// Otherwise, `k` is always less than `n`. @@ -118,8 +118,8 @@ pub trait DoubleEndedIterator: Iterator { /// Basic usage: /// /// ``` - /// #![feature(iter_advance_by)] - /// use std::num::NonZeroUsize; + /// #![feature(generic_nonzero, iter_advance_by)] + /// use std::num::NonZero; /// /// let a = [3, 4, 5, 6]; /// let mut iter = a.iter(); @@ -127,7 +127,7 @@ pub trait DoubleEndedIterator: Iterator { /// assert_eq!(iter.advance_back_by(2), Ok(())); /// assert_eq!(iter.next_back(), Some(&4)); /// assert_eq!(iter.advance_back_by(0), Ok(())); - /// assert_eq!(iter.advance_back_by(100), Err(NonZeroUsize::new(99).unwrap())); // only `&3` was skipped + /// assert_eq!(iter.advance_back_by(100), Err(NonZero::new(99).unwrap())); // only `&3` was skipped /// ``` /// /// [`Ok(())`]: Ok diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 522e75a5683b2..3267cea38b743 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -304,7 +304,7 @@ pub trait Iterator { /// times until [`None`] is encountered. /// /// `advance_by(n)` will return `Ok(())` if the iterator successfully advances by - /// `n` elements, or a `Err(NonZeroUsize)` with value `k` if [`None`] is encountered, + /// `n` elements, or a `Err(NonZero)` with value `k` if [`None`] is encountered, /// where `k` is remaining number of steps that could not be advanced because the iterator ran out. /// If `self` is empty and `n` is non-zero, then this returns `Err(n)`. /// Otherwise, `k` is always less than `n`. @@ -319,8 +319,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// #![feature(iter_advance_by)] - /// use std::num::NonZeroUsize; + /// #![feature(generic_nonzero, iter_advance_by)] + /// use std::num::NonZero; /// /// let a = [1, 2, 3, 4]; /// let mut iter = a.iter(); @@ -328,7 +328,7 @@ pub trait Iterator { /// assert_eq!(iter.advance_by(2), Ok(())); /// assert_eq!(iter.next(), Some(&3)); /// assert_eq!(iter.advance_by(0), Ok(())); - /// assert_eq!(iter.advance_by(100), Err(NonZeroUsize::new(99).unwrap())); // only `&4` was skipped + /// assert_eq!(iter.advance_by(100), Err(NonZero::new(99).unwrap())); // only `&4` was skipped /// ``` #[inline] #[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")] @@ -2967,17 +2967,18 @@ pub trait Iterator { /// assert!(result.is_err()); /// ``` /// - /// This also supports other types which implement `Try`, not just `Result`. + /// This also supports other types which implement [`Try`], not just [`Result`]. + /// /// ``` - /// #![feature(try_find)] + /// #![feature(generic_nonzero, try_find)] + /// use std::num::NonZero; /// - /// use std::num::NonZeroU32; - /// let a = [3, 5, 7, 4, 9, 0, 11]; - /// let result = a.iter().try_find(|&&x| NonZeroU32::new(x).map(|y| y.is_power_of_two())); + /// let a = [3, 5, 7, 4, 9, 0, 11u32]; + /// let result = a.iter().try_find(|&&x| NonZero::new(x).map(|y| y.is_power_of_two())); /// assert_eq!(result, Some(Some(&4))); - /// let result = a.iter().take(3).try_find(|&&x| NonZeroU32::new(x).map(|y| y.is_power_of_two())); + /// let result = a.iter().take(3).try_find(|&&x| NonZero::new(x).map(|y| y.is_power_of_two())); /// assert_eq!(result, Some(None)); - /// let result = a.iter().rev().try_find(|&&x| NonZeroU32::new(x).map(|y| y.is_power_of_two())); + /// let result = a.iter().rev().try_find(|&&x| NonZero::new(x).map(|y| y.is_power_of_two())); /// assert_eq!(result, None); /// ``` #[inline] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 456d88122af64..6ea7fda15389d 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -106,6 +106,7 @@ #![allow(incomplete_features)] #![warn(multiple_supertrait_upcastable)] #![allow(internal_features)] +#![deny(ffi_unwind_calls)] // Do not check link redundancy on bootstraping phase #![allow(rustdoc::redundant_explicit_links)] // @@ -201,6 +202,8 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(platform_intrinsics))] +#![cfg_attr(not(bootstrap), feature(freeze_impls))] #![feature(abi_unadjusted)] #![feature(adt_const_params)] #![feature(allow_internal_unsafe)] @@ -245,7 +248,6 @@ #![feature(never_type)] #![feature(no_core)] #![feature(no_sanitize)] -#![feature(platform_intrinsics)] #![feature(prelude_import)] #![feature(repr_simd)] #![feature(rustc_allow_const_fn_unstable)] diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 2e22129d7b64d..a56a2578c2241 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -810,15 +810,21 @@ pub trait DiscriminantKind { type Discriminant: Clone + Copy + Debug + Eq + PartialEq + Hash + Send + Sync + Unpin; } -/// Compiler-internal trait used to determine whether a type contains +/// Used to determine whether a type contains /// any `UnsafeCell` internally, but not through an indirection. /// This affects, for example, whether a `static` of that type is /// placed in read-only static memory or writable static memory. +/// This can be used to declare that a constant with a generic type +/// will not contain interior mutability, and subsequently allow +/// placing the constant behind references. #[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} +#[unstable(feature = "freeze", issue = "121675")] +pub unsafe auto trait Freeze {} +#[unstable(feature = "freeze", issue = "121675")] impl !Freeze for UnsafeCell {} marker_impls! { + #[unstable(feature = "freeze", issue = "121675")] unsafe Freeze for {T: ?Sized} PhantomData, {T: ?Sized} *const T, diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 8943e2f0e2ab5..295b88361cfbb 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -23,7 +23,7 @@ mod private { /// A marker trait for primitive types which can be zero. /// -/// This is an implementation detail for [`NonZero`](NonZero) which may disappear or be replaced at any time. +/// This is an implementation detail for [NonZero]\ which may disappear or be replaced at any time. #[unstable( feature = "nonzero_internals", reason = "implementation detail which may disappear or be replaced at any time", @@ -507,18 +507,16 @@ macro_rules! nonzero_integer { /// Basic usage: /// /// ``` - /// #![feature(non_zero_count_ones)] + /// #![feature(generic_nonzero, non_zero_count_ones)] /// # fn main() { test().unwrap(); } /// # fn test() -> Option<()> { /// # use std::num::*; /// # - /// let one = NonZeroU32::new(1)?; - /// let three = NonZeroU32::new(3)?; - #[doc = concat!("let a = ", stringify!($Ty), "::new(0b100_0000)?;")] - #[doc = concat!("let b = ", stringify!($Ty), "::new(0b100_0011)?;")] + #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b100_0000)?;")] + #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b100_0011)?;")] /// - /// assert_eq!(a.count_ones(), one); - /// assert_eq!(b.count_ones(), three); + /// assert_eq!(a.count_ones(), NonZero::new(1)?); + /// assert_eq!(b.count_ones(), NonZero::new(3)?); /// # Some(()) /// # } /// ``` @@ -530,7 +528,7 @@ macro_rules! nonzero_integer { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn count_ones(self) -> NonZeroU32 { + pub const fn count_ones(self) -> NonZero { // SAFETY: // `self` is non-zero, which means it has at least one bit set, which means // that the result of `count_ones` is non-zero. diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 53c9ae498c081..5027e326a9d7a 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -558,6 +558,7 @@ use crate::panicking::{panic, panic_str}; use crate::pin::Pin; use crate::{ cmp, convert, hint, mem, + num::NonZero, ops::{self, ControlFlow, Deref, DerefMut}, slice, }; @@ -2194,18 +2195,18 @@ macro_rules! non_zero_option { } non_zero_option! { - #[stable(feature = "nonzero", since = "1.28.0")] crate::num::NonZeroU8; - #[stable(feature = "nonzero", since = "1.28.0")] crate::num::NonZeroU16; - #[stable(feature = "nonzero", since = "1.28.0")] crate::num::NonZeroU32; - #[stable(feature = "nonzero", since = "1.28.0")] crate::num::NonZeroU64; - #[stable(feature = "nonzero", since = "1.28.0")] crate::num::NonZeroU128; - #[stable(feature = "nonzero", since = "1.28.0")] crate::num::NonZeroUsize; - #[stable(feature = "signed_nonzero", since = "1.34.0")] crate::num::NonZeroI8; - #[stable(feature = "signed_nonzero", since = "1.34.0")] crate::num::NonZeroI16; - #[stable(feature = "signed_nonzero", since = "1.34.0")] crate::num::NonZeroI32; - #[stable(feature = "signed_nonzero", since = "1.34.0")] crate::num::NonZeroI64; - #[stable(feature = "signed_nonzero", since = "1.34.0")] crate::num::NonZeroI128; - #[stable(feature = "signed_nonzero", since = "1.34.0")] crate::num::NonZeroIsize; + #[stable(feature = "nonzero", since = "1.28.0")] NonZero; + #[stable(feature = "nonzero", since = "1.28.0")] NonZero; + #[stable(feature = "nonzero", since = "1.28.0")] NonZero; + #[stable(feature = "nonzero", since = "1.28.0")] NonZero; + #[stable(feature = "nonzero", since = "1.28.0")] NonZero; + #[stable(feature = "nonzero", since = "1.28.0")] NonZero; + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZero; + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZero; + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZero; + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZero; + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZero; + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZero; } #[stable(feature = "nonnull", since = "1.25.0")] diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index eb3f93a6e9657..15da4171bda21 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -1577,8 +1577,7 @@ mod prim_ref {} /// - Any two types with size 0 and alignment 1 are ABI-compatible. /// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-trivial field, i.e., the /// unique field that doesn't have size 0 and alignment 1 (if there is such a field). -/// - `i32` is ABI-compatible with `NonZeroI32`, and similar for all other integer types with their -/// matching `NonZero*` type. +/// - `i32` is ABI-compatible with `NonZero`, and similar for all other integer types. /// - If `T` is guaranteed to be subject to the [null pointer /// optimization](option/index.html#representation), then `T` and `Option` are ABI-compatible. /// @@ -1613,9 +1612,9 @@ mod prim_ref {} /// type in the function pointer to the type at the function declaration, and the return value is /// [`transmute`d][mem::transmute] from the type in the declaration to the type in the /// pointer. All the usual caveats and concerns around transmutation apply; for instance, if the -/// function expects a `NonZeroI32` and the function pointer uses the ABI-compatible type -/// `Option`, and the value used for the argument is `None`, then this call is Undefined -/// Behavior since transmuting `None::` to `NonZeroI32` violates the non-zero +/// function expects a `NonZero` and the function pointer uses the ABI-compatible type +/// `Option>`, and the value used for the argument is `None`, then this call is Undefined +/// Behavior since transmuting `None::>` to `NonZero` violates the non-zero /// requirement. /// /// #### Requirements concerning target features diff --git a/library/core/src/ptr/alignment.rs b/library/core/src/ptr/alignment.rs index 6dfecb5a826af..bd58c167c2e06 100644 --- a/library/core/src/ptr/alignment.rs +++ b/library/core/src/ptr/alignment.rs @@ -1,5 +1,5 @@ use crate::convert::{TryFrom, TryInto}; -use crate::num::{NonZero, NonZeroUsize}; +use crate::num::NonZero; use crate::{cmp, fmt, hash, mem, num}; /// A type storing a `usize` which is a power of two, and thus @@ -87,7 +87,7 @@ impl Alignment { unsafe { mem::transmute::(align) } } - /// Returns the alignment as a [`usize`] + /// Returns the alignment as a [`usize`]. #[unstable(feature = "ptr_alignment_type", issue = "102070")] #[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")] #[inline] @@ -95,11 +95,11 @@ impl Alignment { self.0 as usize } - /// Returns the alignment as a [`NonZeroUsize`] + /// Returns the alignment as a [NonZero]<[usize]>. #[unstable(feature = "ptr_alignment_type", issue = "102070")] #[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")] #[inline] - pub const fn as_nonzero(self) -> NonZeroUsize { + pub const fn as_nonzero(self) -> NonZero { // SAFETY: All the discriminants are non-zero. unsafe { NonZero::new_unchecked(self.as_usize()) } } @@ -164,11 +164,11 @@ impl fmt::Debug for Alignment { } #[unstable(feature = "ptr_alignment_type", issue = "102070")] -impl TryFrom for Alignment { +impl TryFrom> for Alignment { type Error = num::TryFromIntError; #[inline] - fn try_from(align: NonZeroUsize) -> Result { + fn try_from(align: NonZero) -> Result { align.get().try_into() } } @@ -184,9 +184,9 @@ impl TryFrom for Alignment { } #[unstable(feature = "ptr_alignment_type", issue = "102070")] -impl From for NonZeroUsize { +impl From for NonZero { #[inline] - fn from(align: Alignment) -> NonZeroUsize { + fn from(align: Alignment) -> NonZero { align.as_nonzero() } } diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 90b3341f0ad4d..fc5b08c9801a8 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -1553,7 +1553,7 @@ pub const unsafe fn write_unaligned(dst: *mut T, src: T) { // `dst` cannot overlap `src` because the caller has mutable access // to `dst` while `src` is owned by this function. unsafe { - copy_nonoverlapping(&src as *const T as *const u8, dst as *mut u8, mem::size_of::()); + copy_nonoverlapping(addr_of!(src) as *const u8, dst as *mut u8, mem::size_of::()); // We are calling the intrinsic directly to avoid function calls in the generated code. intrinsics::forget(src); } diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 098ec23385567..acb8c552a6338 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -5,7 +5,7 @@ use crate::intrinsics; use crate::intrinsics::assert_unsafe_precondition; use crate::marker::Unsize; use crate::mem::{MaybeUninit, SizedTypeProperties}; -use crate::num::{NonZero, NonZeroUsize}; +use crate::num::NonZero; use crate::ops::{CoerceUnsized, DispatchFromDyn}; use crate::ptr; use crate::ptr::Unique; @@ -291,7 +291,7 @@ impl NonNull { #[must_use] #[inline] #[unstable(feature = "strict_provenance", issue = "95228")] - pub fn addr(self) -> NonZeroUsize { + pub fn addr(self) -> NonZero { // SAFETY: The pointer is guaranteed by the type to be non-null, // meaning that the address will be non-zero. unsafe { NonZero::new_unchecked(self.pointer.addr()) } @@ -306,7 +306,7 @@ impl NonNull { #[must_use] #[inline] #[unstable(feature = "strict_provenance", issue = "95228")] - pub fn with_addr(self, addr: NonZeroUsize) -> Self { + pub fn with_addr(self, addr: NonZero) -> Self { // SAFETY: The result of `ptr::from::with_addr` is non-null because `addr` is guaranteed to be non-zero. unsafe { NonNull::new_unchecked(self.pointer.with_addr(addr.get()) as *mut _) } } @@ -320,7 +320,7 @@ impl NonNull { #[must_use] #[inline] #[unstable(feature = "strict_provenance", issue = "95228")] - pub fn map_addr(self, f: impl FnOnce(NonZeroUsize) -> NonZeroUsize) -> Self { + pub fn map_addr(self, f: impl FnOnce(NonZero) -> NonZero) -> Self { self.with_addr(f(self.addr())) } diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 031666fb012e2..1ad81fcfcfeed 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -146,6 +146,9 @@ impl [T] { /// ``` /// let a = [1, 2, 3]; /// assert!(!a.is_empty()); + /// + /// let b: &[i32] = &[]; + /// assert!(b.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_slice_is_empty", since = "1.39.0")] @@ -185,6 +188,9 @@ impl [T] { /// *first = 5; /// } /// assert_eq!(x, &[5, 1, 2]); + /// + /// let y: &mut [i32] = &mut []; + /// assert_eq!(None, y.first_mut()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")] @@ -297,7 +303,7 @@ impl [T] { if let [.., last] = self { Some(last) } else { None } } - /// Returns a mutable reference to the last item in the slice. + /// Returns a mutable reference to the last item in the slice, or `None` if it is empty. /// /// # Examples /// @@ -308,6 +314,9 @@ impl [T] { /// *last = 10; /// } /// assert_eq!(x, &[0, 1, 10]); + /// + /// let y: &mut [i32] = &mut []; + /// assert_eq!(None, y.last_mut()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_slice_first_last", issue = "83570")] diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 00b4405faaefb..19627f28e64f8 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -5,10 +5,10 @@ use crate::fmt::{self, Write}; use crate::iter::{Chain, FlatMap, Flatten}; use crate::iter::{Copied, Filter, FusedIterator, Map, TrustedLen}; use crate::iter::{TrustedRandomAccess, TrustedRandomAccessNoCoerce}; +use crate::num::NonZero; use crate::ops::Try; use crate::option; use crate::slice::{self, Split as SliceSplit}; -use core::num::{NonZero, NonZeroUsize}; use super::from_utf8_unchecked; use super::pattern::Pattern; @@ -51,7 +51,7 @@ impl<'a> Iterator for Chars<'a> { } #[inline] - fn advance_by(&mut self, mut remainder: usize) -> Result<(), NonZeroUsize> { + fn advance_by(&mut self, mut remainder: usize) -> Result<(), NonZero> { const CHUNK_SIZE: usize = 32; if remainder >= CHUNK_SIZE { diff --git a/library/core/tests/iter/adapters/step_by.rs b/library/core/tests/iter/adapters/step_by.rs index b4d61d28cb2e0..29adf0b42fae3 100644 --- a/library/core/tests/iter/adapters/step_by.rs +++ b/library/core/tests/iter/adapters/step_by.rs @@ -49,6 +49,7 @@ fn test_iterator_step_by_nth() { } #[test] +#[cfg_attr(not(bootstrap), allow(non_local_definitions))] fn test_iterator_step_by_nth_overflow() { #[cfg(target_pointer_width = "16")] type Bigger = u32; diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs index 6c008ab2cb196..d02dc45da34c2 100644 --- a/library/core/tests/result.rs +++ b/library/core/tests/result.rs @@ -195,6 +195,7 @@ pub fn test_unwrap_or_default() { } #[test] +#[cfg_attr(not(bootstrap), allow(non_local_definitions))] pub fn test_into_ok() { fn infallible_op() -> Result { Ok(666) @@ -217,6 +218,7 @@ pub fn test_into_ok() { } #[test] +#[cfg_attr(not(bootstrap), allow(non_local_definitions))] pub fn test_into_err() { fn until_error_op() -> Result { Err(666) diff --git a/library/panic_unwind/src/miri.rs b/library/panic_unwind/src/miri.rs index d941b73b5fac1..4d21e846010e9 100644 --- a/library/panic_unwind/src/miri.rs +++ b/library/panic_unwind/src/miri.rs @@ -8,14 +8,14 @@ type Payload = Box>; extern "Rust" { /// Miri-provided extern function to begin unwinding. - fn miri_start_panic(payload: *mut u8) -> !; + fn miri_start_unwind(payload: *mut u8) -> !; } pub unsafe fn panic(payload: Box) -> u32 { - // The payload we pass to `miri_start_panic` will be exactly the argument we get + // The payload we pass to `miri_start_unwind` will be exactly the argument we get // in `cleanup` below. So we just box it up once, to get something pointer-sized. let payload_box: Payload = Box::new(payload); - miri_start_panic(Box::into_raw(payload_box) as *mut u8) + miri_start_unwind(Box::into_raw(payload_box) as *mut u8) } pub unsafe fn cleanup(payload_box: *mut u8) -> Box { diff --git a/library/panic_unwind/src/seh.rs b/library/panic_unwind/src/seh.rs index c4f4d2fbec915..e63749c77cef3 100644 --- a/library/panic_unwind/src/seh.rs +++ b/library/panic_unwind/src/seh.rs @@ -49,7 +49,7 @@ use alloc::boxed::Box; use core::any::Any; use core::mem::{self, ManuallyDrop}; -use core::ptr; +use core::ptr::{addr_of, addr_of_mut}; use libc::{c_int, c_uint, c_void}; // NOTE(nbdd0121): The `canary` field is part of stable ABI. @@ -135,7 +135,7 @@ mod imp { macro_rules! ptr { (0) => (0); ($e:expr) => { - (($e as usize) - (&imp::__ImageBase as *const _ as usize)) as u32 + (($e as usize) - (addr_of!(imp::__ImageBase) as usize)) as u32 } } } @@ -220,7 +220,7 @@ extern "C" { // This is fine since the MSVC runtime uses string comparison on the type name // to match TypeDescriptors rather than pointer equality. static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor { - pVFTable: unsafe { &TYPE_INFO_VTABLE } as *const _ as *const _, + pVFTable: unsafe { addr_of!(TYPE_INFO_VTABLE) } as *const _, spare: core::ptr::null_mut(), name: TYPE_NAME, }; @@ -261,9 +261,6 @@ cfg_if::cfg_if! { } } -// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint -#[cfg_attr(bootstrap, allow(static_mut_ref))] -#[cfg_attr(not(bootstrap), allow(static_mut_refs))] pub unsafe fn panic(data: Box) -> u32 { use core::intrinsics::atomic_store_seqcst; @@ -274,8 +271,9 @@ pub unsafe fn panic(data: Box) -> u32 { // The ManuallyDrop is needed here since we don't want Exception to be // dropped when unwinding. Instead it will be dropped by exception_cleanup // which is invoked by the C++ runtime. - let mut exception = ManuallyDrop::new(Exception { canary: &TYPE_DESCRIPTOR, data: Some(data) }); - let throw_ptr = &mut exception as *mut _ as *mut _; + let mut exception = + ManuallyDrop::new(Exception { canary: addr_of!(TYPE_DESCRIPTOR), data: Some(data) }); + let throw_ptr = addr_of_mut!(exception) as *mut _; // This... may seems surprising, and justifiably so. On 32-bit MSVC the // pointers between these structure are just that, pointers. On 64-bit MSVC, @@ -298,23 +296,23 @@ pub unsafe fn panic(data: Box) -> u32 { // In any case, we basically need to do something like this until we can // express more operations in statics (and we may never be able to). atomic_store_seqcst( - &mut THROW_INFO.pmfnUnwind as *mut _ as *mut u32, + addr_of_mut!(THROW_INFO.pmfnUnwind) as *mut u32, ptr!(exception_cleanup) as u32, ); atomic_store_seqcst( - &mut THROW_INFO.pCatchableTypeArray as *mut _ as *mut u32, - ptr!(&CATCHABLE_TYPE_ARRAY as *const _) as u32, + addr_of_mut!(THROW_INFO.pCatchableTypeArray) as *mut u32, + ptr!(addr_of!(CATCHABLE_TYPE_ARRAY)) as u32, ); atomic_store_seqcst( - &mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0] as *mut _ as *mut u32, - ptr!(&CATCHABLE_TYPE as *const _) as u32, + addr_of_mut!(CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]) as *mut u32, + ptr!(addr_of!(CATCHABLE_TYPE)) as u32, ); atomic_store_seqcst( - &mut CATCHABLE_TYPE.pType as *mut _ as *mut u32, - ptr!(&TYPE_DESCRIPTOR as *const _) as u32, + addr_of_mut!(CATCHABLE_TYPE.pType) as *mut u32, + ptr!(addr_of!(TYPE_DESCRIPTOR)) as u32, ); atomic_store_seqcst( - &mut CATCHABLE_TYPE.copyFunction as *mut _ as *mut u32, + addr_of_mut!(CATCHABLE_TYPE.copyFunction) as *mut u32, ptr!(exception_copy) as u32, ); @@ -322,12 +320,9 @@ pub unsafe fn panic(data: Box) -> u32 { fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8) -> !; } - _CxxThrowException(throw_ptr, &mut THROW_INFO as *mut _ as *mut _); + _CxxThrowException(throw_ptr, addr_of_mut!(THROW_INFO) as *mut _); } -// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint -#[cfg_attr(bootstrap, allow(static_mut_ref))] -#[cfg_attr(not(bootstrap), allow(static_mut_refs))] pub unsafe fn cleanup(payload: *mut u8) -> Box { // A null payload here means that we got here from the catch (...) of // __rust_try. This happens when a non-Rust foreign exception is caught. @@ -335,8 +330,8 @@ pub unsafe fn cleanup(payload: *mut u8) -> Box { super::__rust_foreign_exception(); } let exception = payload as *mut Exception; - let canary = ptr::addr_of!((*exception).canary).read(); - if !ptr::eq(canary, &TYPE_DESCRIPTOR) { + let canary = addr_of!((*exception).canary).read(); + if !core::ptr::eq(canary, addr_of!(TYPE_DESCRIPTOR)) { // A foreign Rust exception. super::__rust_foreign_exception(); } diff --git a/library/proc_macro/src/bridge/symbol.rs b/library/proc_macro/src/bridge/symbol.rs index 712f6b4545828..02225d20b26e1 100644 --- a/library/proc_macro/src/bridge/symbol.rs +++ b/library/proc_macro/src/bridge/symbol.rs @@ -136,7 +136,7 @@ thread_local! { arena: arena::Arena::new(), names: fxhash::FxHashMap::default(), strings: Vec::new(), - // Start with a base of 1 to make sure that `NonZeroU32` works. + // Start with a base of 1 to make sure that `NonZero` works. sym_base: NonZero::new(1).unwrap(), }); } diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index d05458a6944ac..610966625b535 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -36,6 +36,7 @@ #![feature(strict_provenance)] #![recursion_limit = "256"] #![allow(internal_features)] +#![deny(ffi_unwind_calls)] #[unstable(feature = "proc_macro_internals", issue = "27812")] #[doc(hidden)] diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 5bd20ebe208c0..1f2b8d3007dd9 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -258,6 +258,9 @@ fn _var(key: &OsStr) -> Result { /// None => println!("{key} is not defined in the environment.") /// } /// ``` +/// +/// If expecting a delimited variable (such as `PATH`), [`split_paths`] +/// can be used to separate items. #[must_use] #[stable(feature = "env", since = "1.0.0")] pub fn var_os>(key: K) -> Option { @@ -441,6 +444,16 @@ pub struct SplitPaths<'a> { /// Returns an iterator over the paths contained in `unparsed`. The iterator /// element type is [`PathBuf`]. /// +/// On most Unix platforms, the separator is `:` and on Windows it is `;`. This +/// also performs unquoting on Windows. +/// +/// [`join_paths`] can be used to recombine elements. +/// +/// # Panics +/// +/// This will panic on systems where there is no delimited `PATH` variable, +/// such as UEFI. +/// /// # Examples /// /// ``` @@ -456,6 +469,7 @@ pub struct SplitPaths<'a> { /// None => println!("{key} is not defined in the environment.") /// } /// ``` +#[doc(alias = "PATH")] #[stable(feature = "env", since = "1.0.0")] pub fn split_paths + ?Sized>(unparsed: &T) -> SplitPaths<'_> { SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) } @@ -496,7 +510,8 @@ pub struct JoinPathsError { /// /// Returns an [`Err`] (containing an error message) if one of the input /// [`Path`]s contains an invalid character for constructing the `PATH` -/// variable (a double quote on Windows or a colon on Unix). +/// variable (a double quote on Windows or a colon on Unix), or if the system +/// does not have a `PATH`-like variable (e.g. UEFI or WASI). /// /// # Examples /// @@ -550,6 +565,7 @@ pub struct JoinPathsError { /// ``` /// /// [`env::split_paths()`]: split_paths +#[doc(alias = "PATH")] #[stable(feature = "env", since = "1.0.0")] pub fn join_paths(paths: I) -> Result where diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs index 818571ddaaa16..f810611a02ecb 100644 --- a/library/std/src/ffi/mod.rs +++ b/library/std/src/ffi/mod.rs @@ -169,6 +169,7 @@ pub use core::ffi::FromBytesUntilNulError; pub use core::ffi::{CStr, FromBytesWithNulError}; #[stable(feature = "rust1", since = "1.0.0")] +#[doc(inline)] pub use self::os_str::{OsStr, OsString}; #[stable(feature = "core_ffi_c", since = "1.64.0")] @@ -188,4 +189,5 @@ pub use core::ffi::c_void; )] pub use core::ffi::{VaList, VaListImpl}; -mod os_str; +#[unstable(feature = "os_str_display", issue = "120048")] +pub mod os_str; diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index bbcbbc5284339..e44da8e637e98 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -1,3 +1,5 @@ +//! The [`OsStr`] and [`OsString`] types and associated utilities. + #[cfg(test)] mod tests; @@ -1147,6 +1149,32 @@ impl OsStr { pub fn eq_ignore_ascii_case>(&self, other: S) -> bool { self.inner.eq_ignore_ascii_case(&other.as_ref().inner) } + + /// Returns an object that implements [`Display`] for safely printing an + /// [`OsStr`] that may contain non-Unicode data. This may perform lossy + /// conversion, depending on the platform. If you would like an + /// implementation which escapes the [`OsStr`] please use [`Debug`] + /// instead. + /// + /// [`Display`]: fmt::Display + /// [`Debug`]: fmt::Debug + /// + /// # Examples + /// + /// ``` + /// #![feature(os_str_display)] + /// use std::ffi::OsStr; + /// + /// let s = OsStr::new("Hello, world!"); + /// println!("{}", s.display()); + /// ``` + #[unstable(feature = "os_str_display", issue = "120048")] + #[must_use = "this does not display the `OsStr`; \ + it returns an object that can be displayed"] + #[inline] + pub fn display(&self) -> Display<'_> { + Display { os_str: self } + } } #[stable(feature = "box_from_os_str", since = "1.17.0")] @@ -1441,9 +1469,42 @@ impl fmt::Debug for OsStr { } } -impl OsStr { - pub(crate) fn display(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(&self.inner, formatter) +/// Helper struct for safely printing an [`OsStr`] with [`format!`] and `{}`. +/// +/// An [`OsStr`] might contain non-Unicode data. This `struct` implements the +/// [`Display`] trait in a way that mitigates that. It is created by the +/// [`display`](OsStr::display) method on [`OsStr`]. This may perform lossy +/// conversion, depending on the platform. If you would like an implementation +/// which escapes the [`OsStr`] please use [`Debug`] instead. +/// +/// # Examples +/// +/// ``` +/// #![feature(os_str_display)] +/// use std::ffi::OsStr; +/// +/// let s = OsStr::new("Hello, world!"); +/// println!("{}", s.display()); +/// ``` +/// +/// [`Display`]: fmt::Display +/// [`format!`]: crate::format +#[unstable(feature = "os_str_display", issue = "120048")] +pub struct Display<'a> { + os_str: &'a OsStr, +} + +#[unstable(feature = "os_str_display", issue = "120048")] +impl fmt::Debug for Display<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self.os_str, f) + } +} + +#[unstable(feature = "os_str_display", issue = "120048")] +impl fmt::Display for Display<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&self.os_str.inner, f) } } diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs index c053e047b1a63..6f8d5e3777568 100644 --- a/library/std/src/io/error/repr_bitpacked.rs +++ b/library/std/src/io/error/repr_bitpacked.rs @@ -73,7 +73,7 @@ //! union Repr { //! // holds integer (Simple/Os) variants, and //! // provides access to the tag bits. -//! bits: NonZeroU64, +//! bits: NonZero, //! // Tag is 0, so this is stored untagged. //! msg: &'static SimpleMessage, //! // Tagged (offset) `Box` pointer. @@ -93,7 +93,7 @@ //! `io::Result<()>` and `io::Result` larger, which defeats part of //! the motivation of this bitpacking. //! -//! Storing everything in a `NonZeroUsize` (or some other integer) would be a +//! Storing everything in a `NonZero` (or some other integer) would be a //! bit more traditional for pointer tagging, but it would lose provenance //! information, couldn't be constructed from a `const fn`, and would probably //! run into other issues as well. diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 261b570dee74f..455de6d98bae6 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -11,8 +11,9 @@ use crate::fs::File; use crate::io::{ self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines, SpecReadByte, }; +use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sync::atomic::{AtomicBool, Ordering}; -use crate::sync::{Arc, Mutex, MutexGuard, OnceLock, ReentrantMutex, ReentrantMutexGuard}; +use crate::sync::{Arc, Mutex, MutexGuard, OnceLock, ReentrantLock, ReentrantLockGuard}; use crate::sys::stdio; type LocalStream = Arc>>; @@ -545,7 +546,7 @@ pub struct Stdout { // FIXME: this should be LineWriter or BufWriter depending on the state of // stdout (tty or not). Note that if this is not line buffered it // should also flush-on-panic or some form of flush-on-abort. - inner: &'static ReentrantMutex>>, + inner: &'static ReentrantLock>>, } /// A locked reference to the [`Stdout`] handle. @@ -567,10 +568,10 @@ pub struct Stdout { #[must_use = "if unused stdout will immediately unlock"] #[stable(feature = "rust1", since = "1.0.0")] pub struct StdoutLock<'a> { - inner: ReentrantMutexGuard<'a, RefCell>>, + inner: ReentrantLockGuard<'a, RefCell>>, } -static STDOUT: OnceLock>>> = OnceLock::new(); +static STDOUT: OnceLock>>> = OnceLock::new(); /// Constructs a new handle to the standard output of the current process. /// @@ -624,7 +625,7 @@ static STDOUT: OnceLock>>> = OnceLo pub fn stdout() -> Stdout { Stdout { inner: STDOUT - .get_or_init(|| ReentrantMutex::new(RefCell::new(LineWriter::new(stdout_raw())))), + .get_or_init(|| ReentrantLock::new(RefCell::new(LineWriter::new(stdout_raw())))), } } @@ -635,7 +636,7 @@ pub fn cleanup() { let mut initialized = false; let stdout = STDOUT.get_or_init(|| { initialized = true; - ReentrantMutex::new(RefCell::new(LineWriter::with_capacity(0, stdout_raw()))) + ReentrantLock::new(RefCell::new(LineWriter::with_capacity(0, stdout_raw()))) }); if !initialized { @@ -678,6 +679,12 @@ impl Stdout { } } +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for Stdout {} + +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl RefUnwindSafe for Stdout {} + #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stdout { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -737,6 +744,12 @@ impl Write for &Stdout { } } +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for StdoutLock<'_> {} + +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl RefUnwindSafe for StdoutLock<'_> {} + #[stable(feature = "rust1", since = "1.0.0")] impl Write for StdoutLock<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { @@ -786,7 +799,7 @@ impl fmt::Debug for StdoutLock<'_> { /// standard library or via raw Windows API calls, will fail. #[stable(feature = "rust1", since = "1.0.0")] pub struct Stderr { - inner: &'static ReentrantMutex>, + inner: &'static ReentrantLock>, } /// A locked reference to the [`Stderr`] handle. @@ -808,7 +821,7 @@ pub struct Stderr { #[must_use = "if unused stderr will immediately unlock"] #[stable(feature = "rust1", since = "1.0.0")] pub struct StderrLock<'a> { - inner: ReentrantMutexGuard<'a, RefCell>, + inner: ReentrantLockGuard<'a, RefCell>, } /// Constructs a new handle to the standard error of the current process. @@ -862,8 +875,8 @@ pub fn stderr() -> Stderr { // Note that unlike `stdout()` we don't use `at_exit` here to register a // destructor. Stderr is not buffered, so there's no need to run a // destructor for flushing the buffer - static INSTANCE: ReentrantMutex> = - ReentrantMutex::new(RefCell::new(stderr_raw())); + static INSTANCE: ReentrantLock> = + ReentrantLock::new(RefCell::new(stderr_raw())); Stderr { inner: &INSTANCE } } @@ -898,6 +911,12 @@ impl Stderr { } } +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for Stderr {} + +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl RefUnwindSafe for Stderr {} + #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stderr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -957,6 +976,12 @@ impl Write for &Stderr { } } +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for StderrLock<'_> {} + +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl RefUnwindSafe for StderrLock<'_> {} + #[stable(feature = "rust1", since = "1.0.0")] impl Write for StderrLock<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c6cd2c6786ad6..288cce3aa085e 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -270,6 +270,7 @@ // // Language features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(platform_intrinsics))] #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] @@ -301,7 +302,6 @@ #![feature(negative_impls)] #![feature(never_type)] #![feature(no_sanitize)] -#![feature(platform_intrinsics)] #![feature(prelude_import)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs index 6e11b92b618a3..bebf3a797d813 100644 --- a/library/std/src/os/mod.rs +++ b/library/std/src/os/mod.rs @@ -85,6 +85,9 @@ pub mod linux; #[cfg(any(target_os = "wasi", doc))] pub mod wasi; +#[cfg(any(all(target_os = "wasi", target_env = "p2"), doc))] +pub mod wasip2; + // windows #[cfg(not(all( doc, diff --git a/library/std/src/os/net/linux_ext/tcp.rs b/library/std/src/os/net/linux_ext/tcp.rs index 5e9ee65a4152e..ff29afe7ed311 100644 --- a/library/std/src/os/net/linux_ext/tcp.rs +++ b/library/std/src/os/net/linux_ext/tcp.rs @@ -53,6 +53,51 @@ pub trait TcpStreamExt: Sealed { /// ``` #[unstable(feature = "tcp_quickack", issue = "96256")] fn quickack(&self) -> io::Result; + + /// A socket listener will be awakened solely when data arrives. + /// + /// The `accept` argument set the delay in seconds until the + /// data is available to read, reducing the number of short lived + /// connections without data to process. + /// Contrary to other platforms `SO_ACCEPTFILTER` feature equivalent, there is + /// no necessity to set it after the `listen` call. + /// + /// See [`man 7 tcp`](https://man7.org/linux/man-pages/man7/tcp.7.html) + /// + /// # Examples + /// + /// ```no run + /// #![feature(tcp_deferaccept)] + /// use std::net::TcpStream; + /// use std::os::linux::net::TcpStreamExt; + /// + /// let stream = TcpStream::connect("127.0.0.1:8080") + /// .expect("Couldn't connect to the server..."); + /// stream.set_deferaccept(1).expect("set_deferaccept call failed"); + /// ``` + #[unstable(feature = "tcp_deferaccept", issue = "119639")] + #[cfg(target_os = "linux")] + fn set_deferaccept(&self, accept: u32) -> io::Result<()>; + + /// Gets the accept delay value (in seconds) of the `TCP_DEFER_ACCEPT` option. + /// + /// For more information about this option, see [`TcpStreamExt::set_deferaccept`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(tcp_deferaccept)] + /// use std::net::TcpStream; + /// use std::os::linux::net::TcpStreamExt; + /// + /// let stream = TcpStream::connect("127.0.0.1:8080") + /// .expect("Couldn't connect to the server..."); + /// stream.set_deferaccept(1).expect("set_deferaccept call failed"); + /// assert_eq!(stream.deferaccept().unwrap_or(0), 1); + /// ``` + #[unstable(feature = "tcp_deferaccept", issue = "119639")] + #[cfg(target_os = "linux")] + fn deferaccept(&self) -> io::Result; } #[unstable(feature = "tcp_quickack", issue = "96256")] @@ -67,4 +112,14 @@ impl TcpStreamExt for net::TcpStream { fn quickack(&self) -> io::Result { self.as_inner().as_inner().quickack() } + + #[cfg(target_os = "linux")] + fn set_deferaccept(&self, accept: u32) -> io::Result<()> { + self.as_inner().as_inner().set_deferaccept(accept) + } + + #[cfg(target_os = "linux")] + fn deferaccept(&self) -> io::Result { + self.as_inner().as_inner().deferaccept() + } } diff --git a/library/std/src/os/net/linux_ext/tests.rs b/library/std/src/os/net/linux_ext/tests.rs index 2db4deed03630..f8dbbfc18e28e 100644 --- a/library/std/src/os/net/linux_ext/tests.rs +++ b/library/std/src/os/net/linux_ext/tests.rs @@ -26,3 +26,29 @@ fn quickack() { t!(stream.set_quickack(false)); assert_eq!(false, t!(stream.quickack())); } + +#[test] +#[cfg(target_os = "linux")] +fn deferaccept() { + use crate::{ + net::{test::next_test_ip4, TcpListener, TcpStream}, + os::net::linux_ext::tcp::TcpStreamExt, + }; + + macro_rules! t { + ($e:expr) => { + match $e { + Ok(t) => t, + Err(e) => panic!("received error for `{}`: {}", stringify!($e), e), + } + }; + } + + let addr = next_test_ip4(); + let _listener = t!(TcpListener::bind(&addr)); + let stream = t!(TcpStream::connect(&("localhost", addr.port()))); + stream.set_deferaccept(1).expect("set_deferaccept failed"); + assert_eq!(stream.deferaccept().unwrap(), 1); + stream.set_deferaccept(0).expect("set_deferaccept failed"); + assert_eq!(stream.deferaccept().unwrap(), 0); +} diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index 6c99e8c36203a..9757653e02c06 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -21,7 +21,7 @@ mod libc { fn sun_path_offset(addr: &libc::sockaddr_un) -> usize { // Work with an actual instance of the type since using a null pointer is UB let base = (addr as *const libc::sockaddr_un).addr(); - let path = (&addr.sun_path as *const libc::c_char).addr(); + let path = core::ptr::addr_of!(addr.sun_path).addr(); path - base } @@ -98,7 +98,7 @@ impl SocketAddr { unsafe { let mut addr: libc::sockaddr_un = mem::zeroed(); let mut len = mem::size_of::() as libc::socklen_t; - cvt(f(&mut addr as *mut _ as *mut _, &mut len))?; + cvt(f(core::ptr::addr_of_mut!(addr) as *mut _, &mut len))?; SocketAddr::from_parts(addr, len) } } diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index 218536689fdbe..1d279d6adbc25 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -37,7 +37,7 @@ pub(super) fn recv_vectored_with_ancillary_from( unsafe { let mut msg_name: libc::sockaddr_un = zeroed(); let mut msg: libc::msghdr = zeroed(); - msg.msg_name = &mut msg_name as *mut _ as *mut _; + msg.msg_name = core::ptr::addr_of_mut!(msg_name) as *mut _; msg.msg_namelen = size_of::() as libc::socklen_t; msg.msg_iov = bufs.as_mut_ptr().cast(); msg.msg_iovlen = bufs.len() as _; @@ -70,7 +70,7 @@ pub(super) fn send_vectored_with_ancillary_to( if let Some(path) = path { sockaddr_un(path)? } else { (zeroed(), 0) }; let mut msg: libc::msghdr = zeroed(); - msg.msg_name = &mut msg_name as *mut _ as *mut _; + msg.msg_name = core::ptr::addr_of_mut!(msg_name) as *mut _; msg.msg_namelen = msg_namelen; msg.msg_iov = bufs.as_ptr() as *mut _; msg.msg_iovlen = bufs.len() as _; diff --git a/library/std/src/os/unix/net/datagram.rs b/library/std/src/os/unix/net/datagram.rs index 3b7b610fdf96c..0b4d955294ca5 100644 --- a/library/std/src/os/unix/net/datagram.rs +++ b/library/std/src/os/unix/net/datagram.rs @@ -91,7 +91,7 @@ impl UnixDatagram { let socket = UnixDatagram::unbound()?; let (addr, len) = sockaddr_un(path.as_ref())?; - cvt(libc::bind(socket.as_raw_fd(), &addr as *const _ as *const _, len as _))?; + cvt(libc::bind(socket.as_raw_fd(), core::ptr::addr_of!(addr) as *const _, len as _))?; Ok(socket) } @@ -124,7 +124,7 @@ impl UnixDatagram { let socket = UnixDatagram::unbound()?; cvt(libc::bind( socket.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len as _, ))?; Ok(socket) @@ -206,7 +206,7 @@ impl UnixDatagram { unsafe { let (addr, len) = sockaddr_un(path.as_ref())?; - cvt(libc::connect(self.as_raw_fd(), &addr as *const _ as *const _, len))?; + cvt(libc::connect(self.as_raw_fd(), core::ptr::addr_of!(addr) as *const _, len))?; } Ok(()) } @@ -238,7 +238,7 @@ impl UnixDatagram { unsafe { cvt(libc::connect( self.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len, ))?; } @@ -505,7 +505,7 @@ impl UnixDatagram { buf.as_ptr() as *const _, buf.len(), MSG_NOSIGNAL, - &addr as *const _ as *const _, + core::ptr::addr_of!(addr) as *const _, len, ))?; Ok(count as usize) @@ -540,7 +540,7 @@ impl UnixDatagram { buf.as_ptr() as *const _, buf.len(), MSG_NOSIGNAL, - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len, ))?; Ok(count as usize) diff --git a/library/std/src/os/unix/net/listener.rs b/library/std/src/os/unix/net/listener.rs index d64a43bc20bab..31286a906ea99 100644 --- a/library/std/src/os/unix/net/listener.rs +++ b/library/std/src/os/unix/net/listener.rs @@ -99,7 +99,11 @@ impl UnixListener { )))] const backlog: libc::c_int = libc::SOMAXCONN; - cvt(libc::bind(inner.as_inner().as_raw_fd(), &addr as *const _ as *const _, len as _))?; + cvt(libc::bind( + inner.as_inner().as_raw_fd(), + core::ptr::addr_of!(addr) as *const _, + len as _, + ))?; cvt(libc::listen(inner.as_inner().as_raw_fd(), backlog))?; Ok(UnixListener(inner)) @@ -139,7 +143,7 @@ impl UnixListener { const backlog: libc::c_int = 128; cvt(libc::bind( inner.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len as _, ))?; cvt(libc::listen(inner.as_raw_fd(), backlog))?; @@ -174,7 +178,7 @@ impl UnixListener { pub fn accept(&self) -> io::Result<(UnixStream, SocketAddr)> { let mut storage: libc::sockaddr_un = unsafe { mem::zeroed() }; let mut len = mem::size_of_val(&storage) as libc::socklen_t; - let sock = self.0.accept(&mut storage as *mut _ as *mut _, &mut len)?; + let sock = self.0.accept(core::ptr::addr_of_mut!(storage) as *mut _, &mut len)?; let addr = SocketAddr::from_parts(storage, len)?; Ok((UnixStream(sock), addr)) } diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index e117f616cafd4..b1cd504e21939 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -96,7 +96,7 @@ impl UnixStream { let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?; let (addr, len) = sockaddr_un(path.as_ref())?; - cvt(libc::connect(inner.as_raw_fd(), &addr as *const _ as *const _, len))?; + cvt(libc::connect(inner.as_raw_fd(), core::ptr::addr_of!(addr) as *const _, len))?; Ok(UnixStream(inner)) } } @@ -130,7 +130,7 @@ impl UnixStream { let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?; cvt(libc::connect( inner.as_raw_fd(), - &socket_addr.addr as *const _ as *const _, + core::ptr::addr_of!(socket_addr.addr) as *const _, socket_addr.len, ))?; Ok(UnixStream(inner)) diff --git a/library/std/src/os/unix/ucred.rs b/library/std/src/os/unix/ucred.rs index 6a0cc2d2c48ff..6efa74182cc0b 100644 --- a/library/std/src/os/unix/ucred.rs +++ b/library/std/src/os/unix/ucred.rs @@ -62,7 +62,7 @@ pub mod impl_linux { socket.as_raw_fd(), SOL_SOCKET, SO_PEERCRED, - &mut ucred as *mut ucred as *mut c_void, + core::ptr::addr_of_mut!(ucred) as *mut c_void, &mut ucred_size, ); @@ -122,7 +122,7 @@ pub mod impl_mac { socket.as_raw_fd(), SOL_LOCAL, LOCAL_PEERPID, - &mut pid as *mut pid_t as *mut c_void, + core::ptr::addr_of_mut!(pid) as *mut c_void, &mut pid_size, ); diff --git a/library/std/src/os/wasi/mod.rs b/library/std/src/os/wasi/mod.rs index bbaf328f457e4..e36b93e60ea1c 100644 --- a/library/std/src/os/wasi/mod.rs +++ b/library/std/src/os/wasi/mod.rs @@ -28,7 +28,8 @@ //! [`OsStr`]: crate::ffi::OsStr //! [`OsString`]: crate::ffi::OsString -#![stable(feature = "rust1", since = "1.0.0")] +#![cfg_attr(not(target_env = "p2"), stable(feature = "rust1", since = "1.0.0"))] +#![cfg_attr(target_env = "p2", unstable(feature = "wasip2", issue = "none"))] #![deny(unsafe_op_in_unsafe_fn)] #![doc(cfg(target_os = "wasi"))] diff --git a/library/std/src/os/wasip2/mod.rs b/library/std/src/os/wasip2/mod.rs new file mode 100644 index 0000000000000..1d44dd72814b8 --- /dev/null +++ b/library/std/src/os/wasip2/mod.rs @@ -0,0 +1,5 @@ +//! Platform-specific extensions to `std` for Preview 2 of the WebAssembly System Interface (WASI). +//! +//! This module is currently empty, but will be filled over time as wasi-libc support for WASI Preview 2 is stabilized. + +#![stable(feature = "raw_ext", since = "1.1.0")] diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 3728d5b64b865..3d576af681e03 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -6,7 +6,7 @@ use crate::any::Any; use crate::collections; use crate::panicking; use crate::sync::atomic::{AtomicU8, Ordering}; -use crate::sync::{Mutex, RwLock}; +use crate::sync::{Condvar, Mutex, RwLock}; use crate::thread::Result; #[doc(hidden)] @@ -67,11 +67,15 @@ pub fn panic_any(msg: M) -> ! { impl UnwindSafe for Mutex {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for RwLock {} +#[stable(feature = "catch_unwind", since = "1.9.0")] +impl UnwindSafe for Condvar {} #[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] impl RefUnwindSafe for Mutex {} #[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] impl RefUnwindSafe for RwLock {} +#[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] +impl RefUnwindSafe for Condvar {} // https://github.com/rust-lang/rust/issues/62301 #[stable(feature = "hashbrown", since = "1.36.0")] diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index c8306c1b597a3..464a46264cbdd 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -337,9 +337,6 @@ pub mod panic_count { #[doc(hidden)] #[cfg(not(feature = "panic_immediate_abort"))] #[unstable(feature = "update_panic_count", issue = "none")] -// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint -#[cfg_attr(bootstrap, allow(static_mut_ref))] -#[cfg_attr(not(bootstrap), allow(static_mut_refs))] pub mod panic_count { use crate::cell::Cell; use crate::sync::atomic::{AtomicUsize, Ordering}; @@ -505,18 +502,18 @@ pub unsafe fn r#try R>(f: F) -> Result> // method of calling a catch panic whilst juggling ownership. let mut data = Data { f: ManuallyDrop::new(f) }; - let data_ptr = &mut data as *mut _ as *mut u8; + let data_ptr = core::ptr::addr_of_mut!(data) as *mut u8; // SAFETY: // // Access to the union's fields: this is `std` and we know that the `r#try` // intrinsic fills in the `r` or `p` union field based on its return value. // - // The call to `intrinsics::r#try` is made safe by: + // The call to `intrinsics::catch_unwind` is made safe by: // - `do_call`, the first argument, can be called with the initial `data_ptr`. // - `do_catch`, the second argument, can be called with the `data_ptr` as well. // See their safety preconditions for more information unsafe { - return if intrinsics::r#try(do_call::, data_ptr, do_catch::) == 0 { + return if intrinsics::catch_unwind(do_call::, data_ptr, do_catch::) == 0 { Ok(ManuallyDrop::into_inner(data.r)) } else { Err(ManuallyDrop::into_inner(data.p)) @@ -543,7 +540,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // Its must contains a valid `f` (type: F) value that can be use to fill // `data.r`. // - // This function cannot be marked as `unsafe` because `intrinsics::r#try` + // This function cannot be marked as `unsafe` because `intrinsics::catch_unwind` // expects normal function pointers. #[inline] fn do_call R, R>(data: *mut u8) { @@ -565,7 +562,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // Since this uses `cleanup` it also hinges on a correct implementation of // `__rustc_panic_cleanup`. // - // This function cannot be marked as `unsafe` because `intrinsics::r#try` + // This function cannot be marked as `unsafe` because `intrinsics::catch_unwind` // expects normal function pointers. #[inline] #[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 89fbd5c4c6454..56ea51226f9d5 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -84,7 +84,7 @@ use crate::rc::Rc; use crate::str::FromStr; use crate::sync::Arc; -use crate::ffi::{OsStr, OsString}; +use crate::ffi::{os_str, OsStr, OsString}; use crate::sys; use crate::sys::path::{is_sep_byte, is_verbatim_sep, parse_prefix, MAIN_SEP_STR}; @@ -2726,7 +2726,7 @@ impl Path { it returns an object that can be displayed"] #[inline] pub fn display(&self) -> Display<'_> { - Display { path: self } + Display { inner: self.inner.display() } } /// Queries the file system to get information about a file, directory, etc. @@ -3033,20 +3033,20 @@ impl fmt::Debug for Path { /// [`format!`]: crate::format #[stable(feature = "rust1", since = "1.0.0")] pub struct Display<'a> { - path: &'a Path, + inner: os_str::Display<'a>, } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(&self.path, f) + fmt::Debug::fmt(&self.inner, f) } } #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.path.inner.display(f) + fmt::Display::fmt(&self.inner, f) } } diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 669affa266a4d..b84d5f11954de 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -111,7 +111,7 @@ use crate::ffi::OsStr; use crate::fmt; use crate::fs; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; -use crate::num::NonZeroI32; +use crate::num::NonZero; use crate::path::Path; use crate::str; use crate::sys::pipe::{read2, AnonPipe}; @@ -1775,9 +1775,9 @@ impl ExitStatusError { self.code_nonzero().map(Into::into) } - /// Reports the exit code, if applicable, from an `ExitStatusError`, as a `NonZero` + /// Reports the exit code, if applicable, from an `ExitStatusError`, as a [`NonZero`]. /// - /// This is exactly like [`code()`](Self::code), except that it returns a `NonZeroI32`. + /// This is exactly like [`code()`](Self::code), except that it returns a [NonZero]<[i32]>. /// /// Plain `code`, returning a plain integer, is provided because it is often more convenient. /// The returned value from `code()` is indeed also nonzero; use `code_nonzero()` when you want @@ -1786,17 +1786,17 @@ impl ExitStatusError { /// # Examples /// /// ``` - /// #![feature(exit_status_error)] + /// #![feature(exit_status_error, generic_nonzero)] /// # if cfg!(unix) { - /// use std::num::NonZeroI32; + /// use std::num::NonZero; /// use std::process::Command; /// /// let bad = Command::new("false").status().unwrap().exit_ok().unwrap_err(); - /// assert_eq!(bad.code_nonzero().unwrap(), NonZeroI32::try_from(1).unwrap()); + /// assert_eq!(bad.code_nonzero().unwrap(), NonZero::new(1).unwrap()); /// # } // cfg!(unix) /// ``` #[must_use] - pub fn code_nonzero(&self) -> Option { + pub fn code_nonzero(&self) -> Option> { self.0.code() } diff --git a/library/std/src/sync/barrier.rs b/library/std/src/sync/barrier.rs index ed3c55120847f..764fa284794e1 100644 --- a/library/std/src/sync/barrier.rs +++ b/library/std/src/sync/barrier.rs @@ -81,8 +81,10 @@ impl Barrier { /// let barrier = Barrier::new(10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_stable(feature = "const_barrier", since = "CURRENT_RUSTC_VERSION")] #[must_use] - pub fn new(n: usize) -> Barrier { + #[inline] + pub const fn new(n: usize) -> Barrier { Barrier { lock: Mutex::new(BarrierState { count: 0, generation_id: 0 }), cvar: Condvar::new(), diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index f6a7c0a9f7549..e8c35bd48a70b 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -165,6 +165,8 @@ pub use core::sync::Exclusive; pub use self::barrier::{Barrier, BarrierWaitResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::condvar::{Condvar, WaitTimeoutResult}; +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +pub use self::mutex::MappedMutexGuard; #[stable(feature = "rust1", since = "1.0.0")] pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] @@ -172,6 +174,8 @@ pub use self::mutex::{Mutex, MutexGuard}; pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult}; +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; @@ -180,7 +184,8 @@ pub use self::lazy_lock::LazyLock; #[stable(feature = "once_cell", since = "1.70.0")] pub use self::once_lock::OnceLock; -pub(crate) use self::remutex::{ReentrantMutex, ReentrantMutexGuard}; +#[unstable(feature = "reentrant_lock", issue = "121440")] +pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard}; pub mod mpsc; @@ -192,5 +197,5 @@ mod mutex; pub(crate) mod once; mod once_lock; mod poison; -mod remutex; +mod reentrant_lock; mod rwlock; diff --git a/library/std/src/sync/mpmc/list.rs b/library/std/src/sync/mpmc/list.rs index 406a331a30961..9e7148c716cda 100644 --- a/library/std/src/sync/mpmc/list.rs +++ b/library/std/src/sync/mpmc/list.rs @@ -547,7 +547,10 @@ impl Channel { } let mut head = self.head.index.load(Ordering::Acquire); - let mut block = self.head.block.load(Ordering::Acquire); + // The channel may be uninitialized, so we have to swap to avoid overwriting any sender's attempts + // to initalize the first block before noticing that the receivers disconnected. Late allocations + // will be deallocated by the sender in Drop. + let mut block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel); // If we're going to be dropping messages we need to synchronize with initialization if head >> SHIFT != tail >> SHIFT { @@ -588,8 +591,8 @@ impl Channel { drop(Box::from_raw(block)); } } + head &= !MARK_BIT; - self.head.block.store(ptr::null_mut(), Ordering::Release); self.head.index.store(head, Ordering::Release); } diff --git a/library/std/src/sync/mpmc/zero.rs b/library/std/src/sync/mpmc/zero.rs index 33f768dcbe902..1b82713edc748 100644 --- a/library/std/src/sync/mpmc/zero.rs +++ b/library/std/src/sync/mpmc/zero.rs @@ -182,7 +182,11 @@ impl Channel { // Prepare for blocking until a receiver wakes us up. let oper = Operation::hook(token); let mut packet = Packet::::message_on_stack(msg); - inner.senders.register_with_packet(oper, &mut packet as *mut Packet as *mut (), cx); + inner.senders.register_with_packet( + oper, + core::ptr::addr_of_mut!(packet) as *mut (), + cx, + ); inner.receivers.notify(); drop(inner); @@ -251,7 +255,7 @@ impl Channel { let mut packet = Packet::::empty_on_stack(); inner.receivers.register_with_packet( oper, - &mut packet as *mut Packet as *mut (), + core::ptr::addr_of_mut!(packet) as *mut (), cx, ); inner.senders.notify(); diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index 920143b7ac7b2..fa91f9d907aff 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -3,7 +3,10 @@ mod tests; use crate::cell::UnsafeCell; use crate::fmt; +use crate::marker::PhantomData; +use crate::mem::ManuallyDrop; use crate::ops::{Deref, DerefMut}; +use crate::ptr::NonNull; use crate::sync::{poison, LockResult, TryLockError, TryLockResult}; use crate::sys::locks as sys; @@ -213,6 +216,47 @@ impl !Send for MutexGuard<'_, T> {} #[stable(feature = "mutexguard", since = "1.19.0")] unsafe impl Sync for MutexGuard<'_, T> {} +/// An RAII mutex guard returned by `MutexGuard::map`, which can point to a +/// subfield of the protected data. When this structure is dropped (falls out +/// of scope), the lock will be unlocked. +/// +/// The main difference between `MappedMutexGuard` and [`MutexGuard`] is that the +/// former cannot be used with [`Condvar`], since that +/// could introduce soundness issues if the locked object is modified by another +/// thread while the `Mutex` is unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// [`Deref`] and [`DerefMut`] implementations. +/// +/// This structure is created by the [`map`] and [`try_map`] methods on +/// [`MutexGuard`]. +/// +/// [`map`]: MutexGuard::map +/// [`try_map`]: MutexGuard::try_map +/// [`Condvar`]: crate::sync::Condvar +#[must_use = "if unused the Mutex will immediately unlock"] +#[must_not_suspend = "holding a MappedMutexGuard across suspend \ + points can cause deadlocks, delays, \ + and cause Futures to not implement `Send`"] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +#[clippy::has_significant_drop] +pub struct MappedMutexGuard<'a, T: ?Sized + 'a> { + // NB: we use a pointer instead of `&'a mut T` to avoid `noalias` violations, because a + // `MappedMutexGuard` argument doesn't hold uniqueness for its whole scope, only until it drops. + // `NonNull` is covariant over `T`, so we add a `PhantomData<&'a mut T>` field + // below for the correct variance over `T` (invariance). + data: NonNull, + inner: &'a sys::Mutex, + poison_flag: &'a poison::Flag, + poison: poison::Guard, + _variance: PhantomData<&'a mut T>, +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl !Send for MappedMutexGuard<'_, T> {} +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +unsafe impl Sync for MappedMutexGuard<'_, T> {} + impl Mutex { /// Creates a new mutex in an unlocked state ready for use. /// @@ -550,3 +594,178 @@ pub fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a sys::Mutex { pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Flag { &guard.lock.poison } + +impl<'a, T: ?Sized> MutexGuard<'a, T> { + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MutexGuard::map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn map(orig: Self, f: F) -> MappedMutexGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + // SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { &mut *orig.lock.data.get() })); + let orig = ManuallyDrop::new(orig); + MappedMutexGuard { + data, + inner: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MutexGuard::try_map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + // SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { &mut *orig.lock.data.get() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedMutexGuard { + data, + inner: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), + } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl Deref for MappedMutexGuard<'_, T> { + type Target = T; + + fn deref(&self) -> &T { + unsafe { self.data.as_ref() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl DerefMut for MappedMutexGuard<'_, T> { + fn deref_mut(&mut self) -> &mut T { + unsafe { self.data.as_mut() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl Drop for MappedMutexGuard<'_, T> { + #[inline] + fn drop(&mut self) { + unsafe { + self.poison_flag.done(&self.poison); + self.inner.unlock(); + } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl fmt::Debug for MappedMutexGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&**self, f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl fmt::Display for MappedMutexGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +impl<'a, T: ?Sized> MappedMutexGuard<'a, T> { + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedMutexGuard::map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn map(mut orig: Self, f: F) -> MappedMutexGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + // SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_mut() })); + let orig = ManuallyDrop::new(orig); + MappedMutexGuard { + data, + inner: orig.inner, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedMutexGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `Mutex` is already locked, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedMutexGuard::try_map(...)`. A method would interfere with methods of the + /// same name on the contents of the `MutexGuard` used through `Deref`. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn try_map(mut orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + // SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_mut() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedMutexGuard { + data, + inner: orig.inner, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), + } + } +} diff --git a/library/std/src/sync/mutex/tests.rs b/library/std/src/sync/mutex/tests.rs index 1786a3c09ffb5..19ec096c59334 100644 --- a/library/std/src/sync/mutex/tests.rs +++ b/library/std/src/sync/mutex/tests.rs @@ -1,6 +1,6 @@ use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::mpsc::channel; -use crate::sync::{Arc, Condvar, Mutex}; +use crate::sync::{Arc, Condvar, MappedMutexGuard, Mutex, MutexGuard, TryLockError}; use crate::thread; struct Packet(Arc<(Mutex, Condvar)>); @@ -188,6 +188,21 @@ fn test_mutex_arc_poison() { assert!(arc.is_poisoned()); } +#[test] +fn test_mutex_arc_poison_mapped() { + let arc = Arc::new(Mutex::new(1)); + assert!(!arc.is_poisoned()); + let arc2 = arc.clone(); + let _ = thread::spawn(move || { + let lock = arc2.lock().unwrap(); + let lock = MutexGuard::map(lock, |val| val); + assert_eq!(*lock, 2); // deliberate assertion failure to poison the mutex + }) + .join(); + assert!(arc.lock().is_err()); + assert!(arc.is_poisoned()); +} + #[test] fn test_mutex_arc_nested() { // Tests nested mutexes and access @@ -236,3 +251,77 @@ fn test_mutex_unsized() { let comp: &[i32] = &[4, 2, 5]; assert_eq!(&*mutex.lock().unwrap(), comp); } + +#[test] +fn test_mapping_mapped_guard() { + let arr = [0; 4]; + let mut lock = Mutex::new(arr); + let guard = lock.lock().unwrap(); + let guard = MutexGuard::map(guard, |arr| &mut arr[..2]); + let mut guard = MappedMutexGuard::map(guard, |slice| &mut slice[1..]); + assert_eq!(guard.len(), 1); + guard[0] = 42; + drop(guard); + assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); +} + +#[test] +fn panic_while_mapping_unlocked_poison() { + let lock = Mutex::new(()); + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let _guard = MutexGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MutexGuard::map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MutexGuard::map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let _guard = MutexGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MutexGuard::try_map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MutexGuard::try_map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let guard = MutexGuard::map::<(), _>(guard, |val| val); + let _guard = MappedMutexGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MappedMutexGuard::map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MappedMutexGuard::map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.lock().unwrap(); + let guard = MutexGuard::map::<(), _>(guard, |val| val); + let _guard = MappedMutexGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_lock() { + Ok(_) => panic!("panicking in a MappedMutexGuard::try_map closure should poison the Mutex"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MappedMutexGuard::try_map closure should unlock the mutex") + } + Err(TryLockError::Poisoned(_)) => {} + } + + drop(lock); +} diff --git a/library/std/src/sync/poison.rs b/library/std/src/sync/poison.rs index 1e978bec4b44b..3c51389fa3498 100644 --- a/library/std/src/sync/poison.rs +++ b/library/std/src/sync/poison.rs @@ -78,6 +78,7 @@ impl Flag { } } +#[derive(Clone)] pub struct Guard { #[cfg(panic = "unwind")] panicking: bool, diff --git a/library/std/src/sync/reentrant_lock.rs b/library/std/src/sync/reentrant_lock.rs new file mode 100644 index 0000000000000..9a44998ebf644 --- /dev/null +++ b/library/std/src/sync/reentrant_lock.rs @@ -0,0 +1,320 @@ +#[cfg(all(test, not(target_os = "emscripten")))] +mod tests; + +use crate::cell::UnsafeCell; +use crate::fmt; +use crate::ops::Deref; +use crate::panic::{RefUnwindSafe, UnwindSafe}; +use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed}; +use crate::sys::locks as sys; + +/// A re-entrant mutual exclusion lock +/// +/// This lock will block *other* threads waiting for the lock to become +/// available. The thread which has already locked the mutex can lock it +/// multiple times without blocking, preventing a common source of deadlocks. +/// +/// # Examples +/// +/// Allow recursively calling a function needing synchronization from within +/// a callback (this is how [`StdoutLock`](crate::io::StdoutLock) is currently +/// implemented): +/// +/// ``` +/// #![feature(reentrant_lock)] +/// +/// use std::cell::RefCell; +/// use std::sync::ReentrantLock; +/// +/// pub struct Log { +/// data: RefCell, +/// } +/// +/// impl Log { +/// pub fn append(&self, msg: &str) { +/// self.data.borrow_mut().push_str(msg); +/// } +/// } +/// +/// static LOG: ReentrantLock = ReentrantLock::new(Log { data: RefCell::new(String::new()) }); +/// +/// pub fn with_log(f: impl FnOnce(&Log) -> R) -> R { +/// let log = LOG.lock(); +/// f(&*log) +/// } +/// +/// with_log(|log| { +/// log.append("Hello"); +/// with_log(|log| log.append(" there!")); +/// }); +/// ``` +/// +// # Implementation details +// +// The 'owner' field tracks which thread has locked the mutex. +// +// We use current_thread_unique_ptr() as the thread identifier, +// which is just the address of a thread local variable. +// +// If `owner` is set to the identifier of the current thread, +// we assume the mutex is already locked and instead of locking it again, +// we increment `lock_count`. +// +// When unlocking, we decrement `lock_count`, and only unlock the mutex when +// it reaches zero. +// +// `lock_count` is protected by the mutex and only accessed by the thread that has +// locked the mutex, so needs no synchronization. +// +// `owner` can be checked by other threads that want to see if they already +// hold the lock, so needs to be atomic. If it compares equal, we're on the +// same thread that holds the mutex and memory access can use relaxed ordering +// since we're not dealing with multiple threads. If it's not equal, +// synchronization is left to the mutex, making relaxed memory ordering for +// the `owner` field fine in all cases. +#[unstable(feature = "reentrant_lock", issue = "121440")] +pub struct ReentrantLock { + mutex: sys::Mutex, + owner: AtomicUsize, + lock_count: UnsafeCell, + data: T, +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +unsafe impl Send for ReentrantLock {} +#[unstable(feature = "reentrant_lock", issue = "121440")] +unsafe impl Sync for ReentrantLock {} + +// Because of the `UnsafeCell`, these traits are not implemented automatically +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl UnwindSafe for ReentrantLock {} +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl RefUnwindSafe for ReentrantLock {} + +/// An RAII implementation of a "scoped lock" of a re-entrant lock. When this +/// structure is dropped (falls out of scope), the lock will be unlocked. +/// +/// The data protected by the mutex can be accessed through this guard via its +/// [`Deref`] implementation. +/// +/// This structure is created by the [`lock`](ReentrantLock::lock) method on +/// [`ReentrantLock`]. +/// +/// # Mutability +/// +/// Unlike [`MutexGuard`](super::MutexGuard), `ReentrantLockGuard` does not +/// implement [`DerefMut`](crate::ops::DerefMut), because implementation of +/// the trait would violate Rust’s reference aliasing rules. Use interior +/// mutability (usually [`RefCell`](crate::cell::RefCell)) in order to mutate +/// the guarded data. +#[must_use = "if unused the ReentrantLock will immediately unlock"] +#[unstable(feature = "reentrant_lock", issue = "121440")] +pub struct ReentrantLockGuard<'a, T: ?Sized + 'a> { + lock: &'a ReentrantLock, +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl !Send for ReentrantLockGuard<'_, T> {} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl ReentrantLock { + /// Creates a new re-entrant lock in an unlocked state ready for use. + /// + /// # Examples + /// + /// ``` + /// #![feature(reentrant_lock)] + /// use std::sync::ReentrantLock; + /// + /// let lock = ReentrantLock::new(0); + /// ``` + pub const fn new(t: T) -> ReentrantLock { + ReentrantLock { + mutex: sys::Mutex::new(), + owner: AtomicUsize::new(0), + lock_count: UnsafeCell::new(0), + data: t, + } + } + + /// Consumes this lock, returning the underlying data. + /// + /// # Examples + /// + /// ``` + /// #![feature(reentrant_lock)] + /// + /// use std::sync::ReentrantLock; + /// + /// let lock = ReentrantLock::new(0); + /// assert_eq!(lock.into_inner(), 0); + /// ``` + pub fn into_inner(self) -> T { + self.data + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl ReentrantLock { + /// Acquires the lock, blocking the current thread until it is able to do + /// so. + /// + /// This function will block the caller until it is available to acquire + /// the lock. Upon returning, the thread is the only thread with the lock + /// held. When the thread calling this method already holds the lock, the + /// call succeeds without blocking. + /// + /// # Examples + /// + /// ``` + /// #![feature(reentrant_lock)] + /// use std::cell::Cell; + /// use std::sync::{Arc, ReentrantLock}; + /// use std::thread; + /// + /// let lock = Arc::new(ReentrantLock::new(Cell::new(0))); + /// let c_lock = Arc::clone(&lock); + /// + /// thread::spawn(move || { + /// c_lock.lock().set(10); + /// }).join().expect("thread::spawn failed"); + /// assert_eq!(lock.lock().get(), 10); + /// ``` + pub fn lock(&self) -> ReentrantLockGuard<'_, T> { + let this_thread = current_thread_unique_ptr(); + // Safety: We only touch lock_count when we own the lock. + unsafe { + if self.owner.load(Relaxed) == this_thread { + self.increment_lock_count().expect("lock count overflow in reentrant mutex"); + } else { + self.mutex.lock(); + self.owner.store(this_thread, Relaxed); + debug_assert_eq!(*self.lock_count.get(), 0); + *self.lock_count.get() = 1; + } + } + ReentrantLockGuard { lock: self } + } + + /// Returns a mutable reference to the underlying data. + /// + /// Since this call borrows the `ReentrantLock` mutably, no actual locking + /// needs to take place -- the mutable borrow statically guarantees no locks + /// exist. + /// + /// # Examples + /// + /// ``` + /// #![feature(reentrant_lock)] + /// use std::sync::ReentrantLock; + /// + /// let mut lock = ReentrantLock::new(0); + /// *lock.get_mut() = 10; + /// assert_eq!(*lock.lock(), 10); + /// ``` + pub fn get_mut(&mut self) -> &mut T { + &mut self.data + } + + /// Attempts to acquire this lock. + /// + /// If the lock could not be acquired at this time, then `None` is returned. + /// Otherwise, an RAII guard is returned. + /// + /// This function does not block. + pub(crate) fn try_lock(&self) -> Option> { + let this_thread = current_thread_unique_ptr(); + // Safety: We only touch lock_count when we own the lock. + unsafe { + if self.owner.load(Relaxed) == this_thread { + self.increment_lock_count()?; + Some(ReentrantLockGuard { lock: self }) + } else if self.mutex.try_lock() { + self.owner.store(this_thread, Relaxed); + debug_assert_eq!(*self.lock_count.get(), 0); + *self.lock_count.get() = 1; + Some(ReentrantLockGuard { lock: self }) + } else { + None + } + } + } + + unsafe fn increment_lock_count(&self) -> Option<()> { + *self.lock_count.get() = (*self.lock_count.get()).checked_add(1)?; + Some(()) + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl fmt::Debug for ReentrantLock { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut d = f.debug_struct("ReentrantLock"); + match self.try_lock() { + Some(v) => d.field("data", &&*v), + None => d.field("data", &format_args!("")), + }; + d.finish_non_exhaustive() + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl Default for ReentrantLock { + fn default() -> Self { + Self::new(T::default()) + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl From for ReentrantLock { + fn from(t: T) -> Self { + Self::new(t) + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl Deref for ReentrantLockGuard<'_, T> { + type Target = T; + + fn deref(&self) -> &T { + &self.lock.data + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl fmt::Debug for ReentrantLockGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl fmt::Display for ReentrantLockGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "reentrant_lock", issue = "121440")] +impl Drop for ReentrantLockGuard<'_, T> { + #[inline] + fn drop(&mut self) { + // Safety: We own the lock. + unsafe { + *self.lock.lock_count.get() -= 1; + if *self.lock.lock_count.get() == 0 { + self.lock.owner.store(0, Relaxed); + self.lock.mutex.unlock(); + } + } + } +} + +/// Get an address that is unique per running thread. +/// +/// This can be used as a non-null usize-sized ID. +pub(crate) fn current_thread_unique_ptr() -> usize { + // Use a non-drop type to make sure it's still available during thread destruction. + thread_local! { static X: u8 = const { 0 } } + X.with(|x| <*const _>::addr(x)) +} diff --git a/library/std/src/sync/remutex/tests.rs b/library/std/src/sync/reentrant_lock/tests.rs similarity index 53% rename from library/std/src/sync/remutex/tests.rs rename to library/std/src/sync/reentrant_lock/tests.rs index fc553081d4227..d4c1d440c6109 100644 --- a/library/std/src/sync/remutex/tests.rs +++ b/library/std/src/sync/reentrant_lock/tests.rs @@ -1,17 +1,17 @@ -use super::{ReentrantMutex, ReentrantMutexGuard}; +use super::{ReentrantLock, ReentrantLockGuard}; use crate::cell::RefCell; use crate::sync::Arc; use crate::thread; #[test] fn smoke() { - let m = ReentrantMutex::new(()); + let l = ReentrantLock::new(()); { - let a = m.lock(); + let a = l.lock(); { - let b = m.lock(); + let b = l.lock(); { - let c = m.lock(); + let c = l.lock(); assert_eq!(*c, ()); } assert_eq!(*b, ()); @@ -22,15 +22,15 @@ fn smoke() { #[test] fn is_mutex() { - let m = Arc::new(ReentrantMutex::new(RefCell::new(0))); - let m2 = m.clone(); - let lock = m.lock(); + let l = Arc::new(ReentrantLock::new(RefCell::new(0))); + let l2 = l.clone(); + let lock = l.lock(); let child = thread::spawn(move || { - let lock = m2.lock(); + let lock = l2.lock(); assert_eq!(*lock.borrow(), 4950); }); for i in 0..100 { - let lock = m.lock(); + let lock = l.lock(); *lock.borrow_mut() += i; } drop(lock); @@ -39,20 +39,20 @@ fn is_mutex() { #[test] fn trylock_works() { - let m = Arc::new(ReentrantMutex::new(())); - let m2 = m.clone(); - let _lock = m.try_lock(); - let _lock2 = m.try_lock(); + let l = Arc::new(ReentrantLock::new(())); + let l2 = l.clone(); + let _lock = l.try_lock(); + let _lock2 = l.try_lock(); thread::spawn(move || { - let lock = m2.try_lock(); + let lock = l2.try_lock(); assert!(lock.is_none()); }) .join() .unwrap(); - let _lock3 = m.try_lock(); + let _lock3 = l.try_lock(); } -pub struct Answer<'a>(pub ReentrantMutexGuard<'a, RefCell>); +pub struct Answer<'a>(pub ReentrantLockGuard<'a, RefCell>); impl Drop for Answer<'_> { fn drop(&mut self) { *self.0.borrow_mut() = 42; diff --git a/library/std/src/sync/remutex.rs b/library/std/src/sync/remutex.rs deleted file mode 100644 index 0ced48d10b7c6..0000000000000 --- a/library/std/src/sync/remutex.rs +++ /dev/null @@ -1,178 +0,0 @@ -#[cfg(all(test, not(target_os = "emscripten")))] -mod tests; - -use crate::cell::UnsafeCell; -use crate::ops::Deref; -use crate::panic::{RefUnwindSafe, UnwindSafe}; -use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed}; -use crate::sys::locks as sys; - -/// A reentrant mutual exclusion -/// -/// This mutex will block *other* threads waiting for the lock to become -/// available. The thread which has already locked the mutex can lock it -/// multiple times without blocking, preventing a common source of deadlocks. -/// -/// This is used by stdout().lock() and friends. -/// -/// ## Implementation details -/// -/// The 'owner' field tracks which thread has locked the mutex. -/// -/// We use current_thread_unique_ptr() as the thread identifier, -/// which is just the address of a thread local variable. -/// -/// If `owner` is set to the identifier of the current thread, -/// we assume the mutex is already locked and instead of locking it again, -/// we increment `lock_count`. -/// -/// When unlocking, we decrement `lock_count`, and only unlock the mutex when -/// it reaches zero. -/// -/// `lock_count` is protected by the mutex and only accessed by the thread that has -/// locked the mutex, so needs no synchronization. -/// -/// `owner` can be checked by other threads that want to see if they already -/// hold the lock, so needs to be atomic. If it compares equal, we're on the -/// same thread that holds the mutex and memory access can use relaxed ordering -/// since we're not dealing with multiple threads. If it's not equal, -/// synchronization is left to the mutex, making relaxed memory ordering for -/// the `owner` field fine in all cases. -pub struct ReentrantMutex { - mutex: sys::Mutex, - owner: AtomicUsize, - lock_count: UnsafeCell, - data: T, -} - -unsafe impl Send for ReentrantMutex {} -unsafe impl Sync for ReentrantMutex {} - -impl UnwindSafe for ReentrantMutex {} -impl RefUnwindSafe for ReentrantMutex {} - -/// An RAII implementation of a "scoped lock" of a mutex. When this structure is -/// dropped (falls out of scope), the lock will be unlocked. -/// -/// The data protected by the mutex can be accessed through this guard via its -/// Deref implementation. -/// -/// # Mutability -/// -/// Unlike `MutexGuard`, `ReentrantMutexGuard` does not implement `DerefMut`, -/// because implementation of the trait would violate Rust’s reference aliasing -/// rules. Use interior mutability (usually `RefCell`) in order to mutate the -/// guarded data. -#[must_use = "if unused the ReentrantMutex will immediately unlock"] -pub struct ReentrantMutexGuard<'a, T: 'a> { - lock: &'a ReentrantMutex, -} - -impl !Send for ReentrantMutexGuard<'_, T> {} - -impl ReentrantMutex { - /// Creates a new reentrant mutex in an unlocked state. - pub const fn new(t: T) -> ReentrantMutex { - ReentrantMutex { - mutex: sys::Mutex::new(), - owner: AtomicUsize::new(0), - lock_count: UnsafeCell::new(0), - data: t, - } - } - - /// Acquires a mutex, blocking the current thread until it is able to do so. - /// - /// This function will block the caller until it is available to acquire the mutex. - /// Upon returning, the thread is the only thread with the mutex held. When the thread - /// calling this method already holds the lock, the call shall succeed without - /// blocking. - /// - /// # Errors - /// - /// If another user of this mutex panicked while holding the mutex, then - /// this call will return failure if the mutex would otherwise be - /// acquired. - pub fn lock(&self) -> ReentrantMutexGuard<'_, T> { - let this_thread = current_thread_unique_ptr(); - // Safety: We only touch lock_count when we own the lock. - unsafe { - if self.owner.load(Relaxed) == this_thread { - self.increment_lock_count(); - } else { - self.mutex.lock(); - self.owner.store(this_thread, Relaxed); - debug_assert_eq!(*self.lock_count.get(), 0); - *self.lock_count.get() = 1; - } - } - ReentrantMutexGuard { lock: self } - } - - /// Attempts to acquire this lock. - /// - /// If the lock could not be acquired at this time, then `Err` is returned. - /// Otherwise, an RAII guard is returned. - /// - /// This function does not block. - /// - /// # Errors - /// - /// If another user of this mutex panicked while holding the mutex, then - /// this call will return failure if the mutex would otherwise be - /// acquired. - pub fn try_lock(&self) -> Option> { - let this_thread = current_thread_unique_ptr(); - // Safety: We only touch lock_count when we own the lock. - unsafe { - if self.owner.load(Relaxed) == this_thread { - self.increment_lock_count(); - Some(ReentrantMutexGuard { lock: self }) - } else if self.mutex.try_lock() { - self.owner.store(this_thread, Relaxed); - debug_assert_eq!(*self.lock_count.get(), 0); - *self.lock_count.get() = 1; - Some(ReentrantMutexGuard { lock: self }) - } else { - None - } - } - } - - unsafe fn increment_lock_count(&self) { - *self.lock_count.get() = (*self.lock_count.get()) - .checked_add(1) - .expect("lock count overflow in reentrant mutex"); - } -} - -impl Deref for ReentrantMutexGuard<'_, T> { - type Target = T; - - fn deref(&self) -> &T { - &self.lock.data - } -} - -impl Drop for ReentrantMutexGuard<'_, T> { - #[inline] - fn drop(&mut self) { - // Safety: We own the lock. - unsafe { - *self.lock.lock_count.get() -= 1; - if *self.lock.lock_count.get() == 0 { - self.lock.owner.store(0, Relaxed); - self.lock.mutex.unlock(); - } - } - } -} - -/// Get an address that is unique per running thread. -/// -/// This can be used as a non-null usize-sized ID. -pub fn current_thread_unique_ptr() -> usize { - // Use a non-drop type to make sure it's still available during thread destruction. - thread_local! { static X: u8 = const { 0 } } - X.with(|x| <*const _>::addr(x)) -} diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index c5d846b85aa1e..0b3d25c329808 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -3,6 +3,8 @@ mod tests; use crate::cell::UnsafeCell; use crate::fmt; +use crate::marker::PhantomData; +use crate::mem::ManuallyDrop; use crate::ops::{Deref, DerefMut}; use crate::ptr::NonNull; use crate::sync::{poison, LockResult, TryLockError, TryLockResult}; @@ -105,7 +107,7 @@ unsafe impl Sync for RwLock {} #[cfg_attr(not(test), rustc_diagnostic_item = "RwLockReadGuard")] pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { // NB: we use a pointer instead of `&'a T` to avoid `noalias` violations, because a - // `Ref` argument doesn't hold immutability for its whole scope, only until it drops. + // `RwLockReadGuard` argument doesn't hold immutability for its whole scope, only until it drops. // `NonNull` is also covariant over `T`, just like we would have with `&T`. `NonNull` // is preferable over `const* T` to allow for niche optimization. data: NonNull, @@ -144,6 +146,67 @@ impl !Send for RwLockWriteGuard<'_, T> {} #[stable(feature = "rwlock_guard_sync", since = "1.23.0")] unsafe impl Sync for RwLockWriteGuard<'_, T> {} +/// RAII structure used to release the shared read access of a lock when +/// dropped, which can point to a subfield of the protected data. +/// +/// This structure is created by the [`map`] and [`try_map`] methods +/// on [`RwLockReadGuard`]. +/// +/// [`map`]: RwLockReadGuard::map +/// [`try_map`]: RwLockReadGuard::try_map +#[must_use = "if unused the RwLock will immediately unlock"] +#[must_not_suspend = "holding a MappedRwLockReadGuard across suspend \ + points can cause deadlocks, delays, \ + and cause Futures to not implement `Send`"] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +#[clippy::has_significant_drop] +pub struct MappedRwLockReadGuard<'a, T: ?Sized + 'a> { + // NB: we use a pointer instead of `&'a T` to avoid `noalias` violations, because a + // `MappedRwLockReadGuard` argument doesn't hold immutability for its whole scope, only until it drops. + // `NonNull` is also covariant over `T`, just like we would have with `&T`. `NonNull` + // is preferable over `const* T` to allow for niche optimization. + data: NonNull, + inner_lock: &'a sys::RwLock, +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl !Send for MappedRwLockReadGuard<'_, T> {} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +unsafe impl Sync for MappedRwLockReadGuard<'_, T> {} + +/// RAII structure used to release the exclusive write access of a lock when +/// dropped, which can point to a subfield of the protected data. +/// +/// This structure is created by the [`map`] and [`try_map`] methods +/// on [`RwLockWriteGuard`]. +/// +/// [`map`]: RwLockWriteGuard::map +/// [`try_map`]: RwLockWriteGuard::try_map +#[must_use = "if unused the RwLock will immediately unlock"] +#[must_not_suspend = "holding a MappedRwLockWriteGuard across suspend \ + points can cause deadlocks, delays, \ + and cause Future's to not implement `Send`"] +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +#[clippy::has_significant_drop] +pub struct MappedRwLockWriteGuard<'a, T: ?Sized + 'a> { + // NB: we use a pointer instead of `&'a mut T` to avoid `noalias` violations, because a + // `MappedRwLockWriteGuard` argument doesn't hold uniqueness for its whole scope, only until it drops. + // `NonNull` is covariant over `T`, so we add a `PhantomData<&'a mut T>` field + // below for the correct variance over `T` (invariance). + data: NonNull, + inner_lock: &'a sys::RwLock, + poison_flag: &'a poison::Flag, + poison: poison::Guard, + _variance: PhantomData<&'a mut T>, +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl !Send for MappedRwLockWriteGuard<'_, T> {} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +unsafe impl Sync for MappedRwLockWriteGuard<'_, T> {} + impl RwLock { /// Creates a new instance of an `RwLock` which is unlocked. /// @@ -557,12 +620,40 @@ impl fmt::Display for RwLockWriteGuard<'_, T> { } } +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl fmt::Debug for MappedRwLockReadGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl fmt::Display for MappedRwLockReadGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl fmt::Debug for MappedRwLockWriteGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl fmt::Display for MappedRwLockWriteGuard<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (**self).fmt(f) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Deref for RwLockReadGuard<'_, T> { type Target = T; fn deref(&self) -> &T { - // SAFETY: the conditions of `RwLockGuard::new` were satisfied when created. + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when created. unsafe { self.data.as_ref() } } } @@ -585,6 +676,37 @@ impl DerefMut for RwLockWriteGuard<'_, T> { } } +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl Deref for MappedRwLockReadGuard<'_, T> { + type Target = T; + + fn deref(&self) -> &T { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { self.data.as_ref() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl Deref for MappedRwLockWriteGuard<'_, T> { + type Target = T; + + fn deref(&self) -> &T { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { self.data.as_ref() } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl DerefMut for MappedRwLockWriteGuard<'_, T> { + fn deref_mut(&mut self) -> &mut T { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { self.data.as_mut() } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Drop for RwLockReadGuard<'_, T> { fn drop(&mut self) { @@ -605,3 +727,310 @@ impl Drop for RwLockWriteGuard<'_, T> { } } } + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl Drop for MappedRwLockReadGuard<'_, T> { + fn drop(&mut self) { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { + self.inner_lock.read_unlock(); + } + } +} + +#[unstable(feature = "mapped_lock_guards", issue = "117108")] +impl Drop for MappedRwLockWriteGuard<'_, T> { + fn drop(&mut self) { + self.poison_flag.done(&self.poison); + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + unsafe { + self.inner_lock.write_unlock(); + } + } +} + +impl<'a, T: ?Sized> RwLockReadGuard<'a, T> { + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockReadGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the `RwLockReadGuard` used through + /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> + where + F: FnOnce(&T) -> &U, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_ref() })); + let orig = ManuallyDrop::new(orig); + MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } + } + + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockReadGuard::try_map(...)`. A method would interfere with methods + /// of the same name on the contents of the `RwLockReadGuard` used through + /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&T) -> Option<&U>, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_ref() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + } + None => Err(orig), + } + } +} + +impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T> { + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data, + /// e.g. an enum variant. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockReadGuard::map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockReadGuard` + /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn map(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U> + where + F: FnOnce(&T) -> &U, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_ref() })); + let orig = ManuallyDrop::new(orig); + MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } + } + + /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. + /// The original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for reading, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockReadGuard::try_map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockReadGuard` + /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&T) -> Option<&U>, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockReadGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_ref() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + } + None => Err(orig), + } + } +} + +impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> { + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data, e.g. + /// an enum variant. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockWriteGuard::map(...)`. A method would interfere with methods of + /// the same name on the contents of the `RwLockWriteGuard` used through + /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn map(orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { &mut *orig.lock.data.get() })); + let orig = ManuallyDrop::new(orig); + MappedRwLockWriteGuard { + data, + inner_lock: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data. The + /// original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `RwLockWriteGuard::try_map(...)`. A method would interfere with methods + /// of the same name on the contents of the `RwLockWriteGuard` used through + /// `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn try_map(orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { &mut *orig.lock.data.get() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockWriteGuard { + data, + inner_lock: &orig.lock.inner, + poison_flag: &orig.lock.poison, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), + } + } +} + +impl<'a, T: ?Sized> MappedRwLockWriteGuard<'a, T> { + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data, + /// e.g. an enum variant. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockWriteGuard::map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockWriteGuard` + /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn map(mut orig: Self, f: F) -> MappedRwLockWriteGuard<'a, U> + where + F: FnOnce(&mut T) -> &mut U, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + let data = NonNull::from(f(unsafe { orig.data.as_mut() })); + let orig = ManuallyDrop::new(orig); + MappedRwLockWriteGuard { + data, + inner_lock: orig.inner_lock, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + } + } + + /// Makes a [`MappedRwLockWriteGuard`] for a component of the borrowed data. + /// The original guard is returned as an `Err(...)` if the closure returns + /// `None`. + /// + /// The `RwLock` is already locked for writing, so this cannot fail. + /// + /// This is an associated function that needs to be used as + /// `MappedRwLockWriteGuard::try_map(...)`. A method would interfere with + /// methods of the same name on the contents of the `MappedRwLockWriteGuard` + /// used through `Deref`. + /// + /// # Panics + /// + /// If the closure panics, the guard will be dropped (unlocked) and the RwLock will be poisoned. + #[doc(alias = "filter_map")] + #[unstable(feature = "mapped_lock_guards", issue = "117108")] + pub fn try_map(mut orig: Self, f: F) -> Result, Self> + where + F: FnOnce(&mut T) -> Option<&mut U>, + U: ?Sized, + { + // SAFETY: the conditions of `RwLockWriteGuard::new` were satisfied when the original guard + // was created, and have been upheld throughout `map` and/or `try_map`. + // The signature of the closure guarantees that it will not "leak" the lifetime of the reference + // passed to it. If the closure panics, the guard will be dropped. + match f(unsafe { orig.data.as_mut() }) { + Some(data) => { + let data = NonNull::from(data); + let orig = ManuallyDrop::new(orig); + Ok(MappedRwLockWriteGuard { + data, + inner_lock: orig.inner_lock, + poison_flag: orig.poison_flag, + poison: orig.poison.clone(), + _variance: PhantomData, + }) + } + None => Err(orig), + } + } +} diff --git a/library/std/src/sync/rwlock/tests.rs b/library/std/src/sync/rwlock/tests.rs index 1a9d3d3f12f3c..9cc5e7a3a60f1 100644 --- a/library/std/src/sync/rwlock/tests.rs +++ b/library/std/src/sync/rwlock/tests.rs @@ -1,6 +1,9 @@ use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::mpsc::channel; -use crate::sync::{Arc, RwLock, RwLockReadGuard, TryLockError}; +use crate::sync::{ + Arc, MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLock, RwLockReadGuard, RwLockWriteGuard, + TryLockError, +}; use crate::thread; use rand::Rng; @@ -55,6 +58,19 @@ fn test_rw_arc_poison_wr() { assert!(arc.read().is_err()); } +#[test] +fn test_rw_arc_poison_mapped_w_r() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.write().unwrap(); + let _lock = RwLockWriteGuard::map(lock, |val| val); + panic!(); + }) + .join(); + assert!(arc.read().is_err()); +} + #[test] fn test_rw_arc_poison_ww() { let arc = Arc::new(RwLock::new(1)); @@ -69,6 +85,20 @@ fn test_rw_arc_poison_ww() { assert!(arc.is_poisoned()); } +#[test] +fn test_rw_arc_poison_mapped_w_w() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.write().unwrap(); + let _lock = RwLockWriteGuard::map(lock, |val| val); + panic!(); + }) + .join(); + assert!(arc.write().is_err()); + assert!(arc.is_poisoned()); +} + #[test] fn test_rw_arc_no_poison_rr() { let arc = Arc::new(RwLock::new(1)); @@ -81,6 +111,21 @@ fn test_rw_arc_no_poison_rr() { let lock = arc.read().unwrap(); assert_eq!(*lock, 1); } + +#[test] +fn test_rw_arc_no_poison_mapped_r_r() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.read().unwrap(); + let _lock = RwLockReadGuard::map(lock, |val| val); + panic!(); + }) + .join(); + let lock = arc.read().unwrap(); + assert_eq!(*lock, 1); +} + #[test] fn test_rw_arc_no_poison_rw() { let arc = Arc::new(RwLock::new(1)); @@ -94,6 +139,20 @@ fn test_rw_arc_no_poison_rw() { assert_eq!(*lock, 1); } +#[test] +fn test_rw_arc_no_poison_mapped_r_w() { + let arc = Arc::new(RwLock::new(1)); + let arc2 = arc.clone(); + let _: Result<(), _> = thread::spawn(move || { + let lock = arc2.read().unwrap(); + let _lock = RwLockReadGuard::map(lock, |val| val); + panic!(); + }) + .join(); + let lock = arc.write().unwrap(); + assert_eq!(*lock, 1); +} + #[test] fn test_rw_arc() { let arc = Arc::new(RwLock::new(0)); @@ -179,6 +238,16 @@ fn test_rwlock_try_write() { } drop(read_guard); + let mapped_read_guard = RwLockReadGuard::map(lock.read().unwrap(), |_| &()); + + let write_result = lock.try_write(); + match write_result { + Err(TryLockError::WouldBlock) => (), + Ok(_) => assert!(false, "try_write should not succeed while mapped_read_guard is in scope"), + Err(_) => assert!(false, "unexpected error"), + } + + drop(mapped_read_guard); } #[test] @@ -257,3 +326,173 @@ fn test_read_guard_covariance() { } drop(lock); } + +#[test] +fn test_mapped_read_guard_covariance() { + fn do_stuff<'a>(_: MappedRwLockReadGuard<'_, &'a i32>, _: &'a i32) {} + let j: i32 = 5; + let lock = RwLock::new((&j, &j)); + { + let i = 6; + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map(guard, |(val, _val)| val); + do_stuff(guard, &i); + } + drop(lock); +} + +#[test] +fn test_mapping_mapped_guard() { + let arr = [0; 4]; + let mut lock = RwLock::new(arr); + let guard = lock.write().unwrap(); + let guard = RwLockWriteGuard::map(guard, |arr| &mut arr[..2]); + let mut guard = MappedRwLockWriteGuard::map(guard, |slice| &mut slice[1..]); + assert_eq!(guard.len(), 1); + guard[0] = 42; + drop(guard); + assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); + + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map(guard, |arr| &arr[..2]); + let guard = MappedRwLockReadGuard::map(guard, |slice| &slice[1..]); + assert_eq!(*guard, [42]); + drop(guard); + assert_eq!(*lock.get_mut().unwrap(), [0, 42, 0, 0]); +} + +#[test] +fn panic_while_mapping_read_unlocked_no_poison() { + let lock = RwLock::new(()); + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let _guard = RwLockReadGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockReadGuard::map closure should release the read lock") + } + Err(TryLockError::Poisoned(_)) => { + panic!("panicking in a RwLockReadGuard::map closure should not poison the RwLock") + } + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let _guard = RwLockReadGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockReadGuard::try_map closure should release the read lock") + } + Err(TryLockError::Poisoned(_)) => { + panic!("panicking in a RwLockReadGuard::try_map closure should not poison the RwLock") + } + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockReadGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => { + panic!("panicking in a MappedRwLockReadGuard::map closure should release the read lock") + } + Err(TryLockError::Poisoned(_)) => { + panic!("panicking in a MappedRwLockReadGuard::map closure should not poison the RwLock") + } + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.read().unwrap(); + let guard = RwLockReadGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockReadGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => {} + Err(TryLockError::WouldBlock) => panic!( + "panicking in a MappedRwLockReadGuard::try_map closure should release the read lock" + ), + Err(TryLockError::Poisoned(_)) => panic!( + "panicking in a MappedRwLockReadGuard::try_map closure should not poison the RwLock" + ), + } + + drop(lock); +} + +#[test] +fn panic_while_mapping_write_unlocked_poison() { + let lock = RwLock::new(()); + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let _guard = RwLockWriteGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => panic!("panicking in a RwLockWriteGuard::map closure should poison the RwLock"), + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockWriteGuard::map closure should release the write lock") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let _guard = RwLockWriteGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => { + panic!("panicking in a RwLockWriteGuard::try_map closure should poison the RwLock") + } + Err(TryLockError::WouldBlock) => { + panic!("panicking in a RwLockWriteGuard::try_map closure should release the write lock") + } + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let guard = RwLockWriteGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockWriteGuard::map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => { + panic!("panicking in a MappedRwLockWriteGuard::map closure should poison the RwLock") + } + Err(TryLockError::WouldBlock) => panic!( + "panicking in a MappedRwLockWriteGuard::map closure should release the write lock" + ), + Err(TryLockError::Poisoned(_)) => {} + } + + let _ = crate::panic::catch_unwind(|| { + let guard = lock.write().unwrap(); + let guard = RwLockWriteGuard::map::<(), _>(guard, |val| val); + let _guard = MappedRwLockWriteGuard::try_map::<(), _>(guard, |_| panic!()); + }); + + match lock.try_write() { + Ok(_) => panic!( + "panicking in a MappedRwLockWriteGuard::try_map closure should poison the RwLock" + ), + Err(TryLockError::WouldBlock) => panic!( + "panicking in a MappedRwLockWriteGuard::try_map closure should release the write lock" + ), + Err(TryLockError::Poisoned(_)) => {} + } + + drop(lock); +} diff --git a/library/std/src/sys/pal/sgx/rwlock/tests.rs b/library/std/src/sys/locks/rwlock/sgx/tests.rs similarity index 100% rename from library/std/src/sys/pal/sgx/rwlock/tests.rs rename to library/std/src/sys/locks/rwlock/sgx/tests.rs diff --git a/library/std/src/sys/pal/hermit/net.rs b/library/std/src/sys/pal/hermit/net.rs index 871a2ccdfa49c..1c53796f5d49c 100644 --- a/library/std/src/sys/pal/hermit/net.rs +++ b/library/std/src/sys/pal/hermit/net.rs @@ -207,7 +207,7 @@ impl Socket { buf.as_mut_ptr(), buf.len(), flags, - &mut storage as *mut _ as *mut _, + core::ptr::addr_of_mut!(storage) as *mut _, &mut addrlen, ) })?; @@ -323,7 +323,7 @@ impl Socket { netc::ioctl( self.as_raw_fd(), netc::FIONBIO, - &mut nonblocking as *mut _ as *mut core::ffi::c_void, + core::ptr::addr_of_mut!(nonblocking) as *mut core::ffi::c_void, ) }) .map(drop) diff --git a/library/std/src/sys/pal/hermit/time.rs b/library/std/src/sys/pal/hermit/time.rs index b0e9634d2299c..f289dafd8bc56 100644 --- a/library/std/src/sys/pal/hermit/time.rs +++ b/library/std/src/sys/pal/hermit/time.rs @@ -100,7 +100,7 @@ pub struct Instant(Timespec); impl Instant { pub fn now() -> Instant { let mut time: Timespec = Timespec::zero(); - let _ = unsafe { abi::clock_gettime(CLOCK_MONOTONIC, &mut time.t as *mut timespec) }; + let _ = unsafe { abi::clock_gettime(CLOCK_MONOTONIC, core::ptr::addr_of_mut!(time.t)) }; Instant(time) } @@ -197,7 +197,7 @@ pub const UNIX_EPOCH: SystemTime = SystemTime(Timespec::zero()); impl SystemTime { pub fn now() -> SystemTime { let mut time: Timespec = Timespec::zero(); - let _ = unsafe { abi::clock_gettime(CLOCK_REALTIME, &mut time.t as *mut timespec) }; + let _ = unsafe { abi::clock_gettime(CLOCK_REALTIME, core::ptr::addr_of_mut!(time.t)) }; SystemTime(time) } diff --git a/library/std/src/sys/pal/mod.rs b/library/std/src/sys/pal/mod.rs index 041b7c355822a..7c87deed3715a 100644 --- a/library/std/src/sys/pal/mod.rs +++ b/library/std/src/sys/pal/mod.rs @@ -40,6 +40,9 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "wasi")] { mod wasi; pub use self::wasi::*; + } else if #[cfg(all(target_os = "wasi", target_env = "p2"))] { + mod wasip2; + pub use self::wasip2::*; } else if #[cfg(target_family = "wasm")] { mod wasm; pub use self::wasm::*; diff --git a/library/std/src/sys/pal/sgx/abi/tls/mod.rs b/library/std/src/sys/pal/sgx/abi/tls/mod.rs index 6762a43b483a4..8a9ea4ac00df0 100644 --- a/library/std/src/sys/pal/sgx/abi/tls/mod.rs +++ b/library/std/src/sys/pal/sgx/abi/tls/mod.rs @@ -95,7 +95,7 @@ impl Tls { #[allow(unused)] pub unsafe fn activate_persistent(self: Box) { // FIXME: Needs safety information. See entry.S for `set_tls_ptr` definition. - unsafe { set_tls_ptr((&*self) as *const Tls as _) }; + unsafe { set_tls_ptr(core::ptr::addr_of!(*self) as _) }; mem::forget(self); } diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/pal/unix/fs.rs index c75323ef7757a..422a99380cc59 100644 --- a/library/std/src/sys/pal/unix/fs.rs +++ b/library/std/src/sys/pal/unix/fs.rs @@ -576,7 +576,7 @@ impl FileAttr { Ok(SystemTime::new(ext.stx_btime.tv_sec, ext.stx_btime.tv_nsec as i64)) } else { Err(io::const_io_error!( - io::ErrorKind::Uncategorized, + io::ErrorKind::Unsupported, "creation time is not available for the filesystem", )) }; @@ -1344,7 +1344,7 @@ impl File { } cvt(unsafe { libc::fsetattrlist( self.as_raw_fd(), - (&attrlist as *const libc::attrlist).cast::().cast_mut(), + core::ptr::addr_of!(attrlist).cast::().cast_mut(), buf.as_ptr().cast::().cast_mut(), num_times * mem::size_of::(), 0 @@ -1744,7 +1744,7 @@ fn open_from(from: &Path) -> io::Result<(crate::fs::File, crate::fs::Metadata)> #[cfg(target_os = "espidf")] fn open_to_and_set_permissions( to: &Path, - reader_metadata: crate::fs::Metadata, + _reader_metadata: crate::fs::Metadata, ) -> io::Result<(crate::fs::File, crate::fs::Metadata)> { use crate::fs::OpenOptions; let writer = OpenOptions::new().open(to)?; @@ -1918,7 +1918,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { copyfile_state_get( state.0, COPYFILE_STATE_COPIED, - &mut bytes_copied as *mut libc::off_t as *mut libc::c_void, + core::ptr::addr_of_mut!(bytes_copied) as *mut libc::c_void, ) })?; Ok(bytes_copied as u64) diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 04b8c5ca91604..23287258f2f87 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -38,7 +38,7 @@ pub mod thread_parking; pub mod time; #[cfg(target_os = "espidf")] -pub fn init(argc: isize, argv: *const *const u8, _sigpipe: u8) {} +pub fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {} #[cfg(not(target_os = "espidf"))] // SAFETY: must be called only once during runtime initialization. diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs index 1b6a6bb2c5c77..60546a3de4509 100644 --- a/library/std/src/sys/pal/unix/net.rs +++ b/library/std/src/sys/pal/unix/net.rs @@ -316,7 +316,7 @@ impl Socket { buf.as_mut_ptr() as *mut c_void, buf.len(), flags, - &mut storage as *mut _ as *mut _, + core::ptr::addr_of_mut!(storage) as *mut _, &mut addrlen, ) })?; @@ -441,6 +441,18 @@ impl Socket { Ok(raw != 0) } + // bionic libc makes no use of this flag + #[cfg(target_os = "linux")] + pub fn set_deferaccept(&self, accept: u32) -> io::Result<()> { + setsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT, accept as c_int) + } + + #[cfg(target_os = "linux")] + pub fn deferaccept(&self) -> io::Result { + let raw: c_int = getsockopt(self, libc::IPPROTO_TCP, libc::TCP_DEFER_ACCEPT)?; + Ok(raw as u32) + } + #[cfg(any(target_os = "android", target_os = "linux",))] pub fn set_passcred(&self, passcred: bool) -> io::Result<()> { setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int) diff --git a/library/std/src/sys/pal/unix/process/process_fuchsia.rs b/library/std/src/sys/pal/unix/process/process_fuchsia.rs index b6a74fb48318c..23c2be6adf9ee 100644 --- a/library/std/src/sys/pal/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/pal/unix/process/process_fuchsia.rs @@ -182,7 +182,7 @@ impl Process { zx_cvt(zx_object_get_info( self.handle.raw(), ZX_INFO_PROCESS, - &mut proc_info as *mut _ as *mut libc::c_void, + core::ptr::addr_of_mut!(proc_info) as *mut libc::c_void, mem::size_of::(), &mut actual, &mut avail, @@ -219,7 +219,7 @@ impl Process { zx_cvt(zx_object_get_info( self.handle.raw(), ZX_INFO_PROCESS, - &mut proc_info as *mut _ as *mut libc::c_void, + core::ptr::addr_of_mut!(proc_info) as *mut libc::c_void, mem::size_of::(), &mut actual, &mut avail, diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs index d5a77085725c5..97cbd1929d329 100644 --- a/library/std/src/sys/pal/unix/process/process_unix.rs +++ b/library/std/src/sys/pal/unix/process/process_unix.rs @@ -694,15 +694,15 @@ impl Command { let mut iov = [IoSlice::new(b"")]; let mut msg: libc::msghdr = mem::zeroed(); - msg.msg_iov = &mut iov as *mut _ as *mut _; + msg.msg_iov = core::ptr::addr_of_mut!(iov) as *mut _; msg.msg_iovlen = 1; // only attach cmsg if we successfully acquired the pidfd if pidfd >= 0 { msg.msg_controllen = mem::size_of_val(&cmsg.buf) as _; - msg.msg_control = &mut cmsg.buf as *mut _ as *mut _; + msg.msg_control = core::ptr::addr_of_mut!(cmsg.buf) as *mut _; - let hdr = CMSG_FIRSTHDR(&mut msg as *mut _ as *mut _); + let hdr = CMSG_FIRSTHDR(core::ptr::addr_of_mut!(msg) as *mut _); (*hdr).cmsg_level = SOL_SOCKET; (*hdr).cmsg_type = SCM_RIGHTS; (*hdr).cmsg_len = CMSG_LEN(SCM_MSG_LEN as _) as _; @@ -744,17 +744,17 @@ impl Command { let mut msg: libc::msghdr = mem::zeroed(); - msg.msg_iov = &mut iov as *mut _ as *mut _; + msg.msg_iov = core::ptr::addr_of_mut!(iov) as *mut _; msg.msg_iovlen = 1; msg.msg_controllen = mem::size_of::() as _; - msg.msg_control = &mut cmsg as *mut _ as *mut _; + msg.msg_control = core::ptr::addr_of_mut!(cmsg) as *mut _; match cvt_r(|| libc::recvmsg(sock.as_raw(), &mut msg, libc::MSG_CMSG_CLOEXEC)) { Err(_) => return -1, Ok(_) => {} } - let hdr = CMSG_FIRSTHDR(&mut msg as *mut _ as *mut _); + let hdr = CMSG_FIRSTHDR(core::ptr::addr_of_mut!(msg) as *mut _); if hdr.is_null() || (*hdr).cmsg_level != SOL_SOCKET || (*hdr).cmsg_type != SCM_RIGHTS diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 97976407bb40f..864de31c6ebfc 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -239,7 +239,7 @@ impl Thread { tv_nsec: nsecs, }; secs -= ts.tv_sec as u64; - let ts_ptr = &mut ts as *mut _; + let ts_ptr = core::ptr::addr_of_mut!(ts); if libc::nanosleep(ts_ptr, ts_ptr) == -1 { assert_eq!(os::errno(), libc::EINTR); secs += ts.tv_sec as u64; @@ -418,8 +418,8 @@ pub fn available_parallelism() -> io::Result> { libc::sysctl( mib.as_mut_ptr(), 2, - &mut cpus as *mut _ as *mut _, - &mut cpus_size as *mut _ as *mut _, + core::ptr::addr_of_mut!(cpus) as *mut _, + core::ptr::addr_of_mut!(cpus_size) as *mut _, ptr::null_mut(), 0, ) @@ -864,7 +864,7 @@ pub mod guard { .unwrap(); match sysctlbyname.get() { Some(fcn) => { - if fcn(oid.as_ptr(), &mut guard as *mut _ as *mut _, &mut size as *mut _ as *mut _, crate::ptr::null_mut(), 0) == 0 { + if fcn(oid.as_ptr(), core::ptr::addr_of_mut!(guard) as *mut _, core::ptr::addr_of_mut!(size) as *mut _, crate::ptr::null_mut(), 0) == 0 { return guard; } return 1; diff --git a/library/std/src/sys/pal/unix/thread_local_dtor.rs b/library/std/src/sys/pal/unix/thread_local_dtor.rs index 8857f96501c19..79b152cece945 100644 --- a/library/std/src/sys/pal/unix/thread_local_dtor.rs +++ b/library/std/src/sys/pal/unix/thread_local_dtor.rs @@ -58,7 +58,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { unsafe extern "C" fn(*mut libc::c_void), >(dtor), t.cast(), - &__dso_handle as *const _ as *mut _, + core::ptr::addr_of!(__dso_handle) as *mut _, ); } return; diff --git a/library/std/src/sys/pal/unix/time.rs b/library/std/src/sys/pal/unix/time.rs index f62eb828ee5d4..251a37d54dd88 100644 --- a/library/std/src/sys/pal/unix/time.rs +++ b/library/std/src/sys/pal/unix/time.rs @@ -10,7 +10,7 @@ pub const TIMESPEC_MAX: libc::timespec = // This additional constant is only used when calling // `libc::pthread_cond_timedwait`. #[cfg(target_os = "nto")] -pub(super) const TIMESPEC_MAX_CAPPED: libc::timespec = libc::timespec { +pub(in crate::sys) const TIMESPEC_MAX_CAPPED: libc::timespec = libc::timespec { tv_sec: (u64::MAX / NSEC_PER_SEC) as i64, tv_nsec: (u64::MAX % NSEC_PER_SEC) as i64, }; @@ -204,7 +204,7 @@ impl Timespec { // On QNX Neutrino, the maximum timespec for e.g. pthread_cond_timedwait // is 2^64 nanoseconds #[cfg(target_os = "nto")] - pub(super) fn to_timespec_capped(&self) -> Option { + pub(in crate::sys) fn to_timespec_capped(&self) -> Option { // Check if timeout in nanoseconds would fit into an u64 if (self.tv_nsec.0 as u64) .checked_add((self.tv_sec as u64).checked_mul(NSEC_PER_SEC)?) diff --git a/library/std/src/sys/pal/wasi/helpers.rs b/library/std/src/sys/pal/wasi/helpers.rs new file mode 100644 index 0000000000000..82149cef8fad1 --- /dev/null +++ b/library/std/src/sys/pal/wasi/helpers.rs @@ -0,0 +1,123 @@ +use crate::io as std_io; +use crate::mem; + +#[inline] +pub fn is_interrupted(errno: i32) -> bool { + errno == wasi::ERRNO_INTR.raw().into() +} + +pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind { + use std_io::ErrorKind; + + let Ok(errno) = u16::try_from(errno) else { + return ErrorKind::Uncategorized; + }; + + macro_rules! match_errno { + ($($($errno:ident)|+ => $errkind:ident),*, _ => $wildcard:ident $(,)?) => { + match errno { + $(e if $(e == ::wasi::$errno.raw())||+ => ErrorKind::$errkind),*, + _ => ErrorKind::$wildcard, + } + }; + } + + match_errno! { + ERRNO_2BIG => ArgumentListTooLong, + ERRNO_ACCES => PermissionDenied, + ERRNO_ADDRINUSE => AddrInUse, + ERRNO_ADDRNOTAVAIL => AddrNotAvailable, + ERRNO_AFNOSUPPORT => Unsupported, + ERRNO_AGAIN => WouldBlock, + // ALREADY => "connection already in progress", + // BADF => "bad file descriptor", + // BADMSG => "bad message", + ERRNO_BUSY => ResourceBusy, + // CANCELED => "operation canceled", + // CHILD => "no child processes", + ERRNO_CONNABORTED => ConnectionAborted, + ERRNO_CONNREFUSED => ConnectionRefused, + ERRNO_CONNRESET => ConnectionReset, + ERRNO_DEADLK => Deadlock, + // DESTADDRREQ => "destination address required", + ERRNO_DOM => InvalidInput, + // DQUOT => /* reserved */, + ERRNO_EXIST => AlreadyExists, + // FAULT => "bad address", + ERRNO_FBIG => FileTooLarge, + ERRNO_HOSTUNREACH => HostUnreachable, + // IDRM => "identifier removed", + // ILSEQ => "illegal byte sequence", + // INPROGRESS => "operation in progress", + ERRNO_INTR => Interrupted, + ERRNO_INVAL => InvalidInput, + ERRNO_IO => Uncategorized, + // ISCONN => "socket is connected", + ERRNO_ISDIR => IsADirectory, + ERRNO_LOOP => FilesystemLoop, + // MFILE => "file descriptor value too large", + ERRNO_MLINK => TooManyLinks, + // MSGSIZE => "message too large", + // MULTIHOP => /* reserved */, + ERRNO_NAMETOOLONG => InvalidFilename, + ERRNO_NETDOWN => NetworkDown, + // NETRESET => "connection aborted by network", + ERRNO_NETUNREACH => NetworkUnreachable, + // NFILE => "too many files open in system", + // NOBUFS => "no buffer space available", + ERRNO_NODEV => NotFound, + ERRNO_NOENT => NotFound, + // NOEXEC => "executable file format error", + // NOLCK => "no locks available", + // NOLINK => /* reserved */, + ERRNO_NOMEM => OutOfMemory, + // NOMSG => "no message of the desired type", + // NOPROTOOPT => "protocol not available", + ERRNO_NOSPC => StorageFull, + ERRNO_NOSYS => Unsupported, + ERRNO_NOTCONN => NotConnected, + ERRNO_NOTDIR => NotADirectory, + ERRNO_NOTEMPTY => DirectoryNotEmpty, + // NOTRECOVERABLE => "state not recoverable", + // NOTSOCK => "not a socket", + ERRNO_NOTSUP => Unsupported, + // NOTTY => "inappropriate I/O control operation", + ERRNO_NXIO => NotFound, + // OVERFLOW => "value too large to be stored in data type", + // OWNERDEAD => "previous owner died", + ERRNO_PERM => PermissionDenied, + ERRNO_PIPE => BrokenPipe, + // PROTO => "protocol error", + ERRNO_PROTONOSUPPORT => Unsupported, + // PROTOTYPE => "protocol wrong type for socket", + // RANGE => "result too large", + ERRNO_ROFS => ReadOnlyFilesystem, + ERRNO_SPIPE => NotSeekable, + ERRNO_SRCH => NotFound, + // STALE => /* reserved */, + ERRNO_TIMEDOUT => TimedOut, + ERRNO_TXTBSY => ResourceBusy, + ERRNO_XDEV => CrossesDevices, + ERRNO_NOTCAPABLE => PermissionDenied, + _ => Uncategorized, + } +} + +pub fn abort_internal() -> ! { + unsafe { libc::abort() } +} + +pub fn hashmap_random_keys() -> (u64, u64) { + let mut ret = (0u64, 0u64); + unsafe { + let base = &mut ret as *mut (u64, u64) as *mut u8; + let len = mem::size_of_val(&ret); + wasi::random_get(base, len).expect("random_get failure"); + } + return ret; +} + +#[inline] +pub(crate) fn err2io(err: wasi::Errno) -> std_io::Error { + std_io::Error::from_raw_os_error(err.raw().into()) +} diff --git a/library/std/src/sys/pal/wasi/mod.rs b/library/std/src/sys/pal/wasi/mod.rs index 084b8e0e21639..308dd29600488 100644 --- a/library/std/src/sys/pal/wasi/mod.rs +++ b/library/std/src/sys/pal/wasi/mod.rs @@ -14,9 +14,6 @@ //! compiling for wasm. That way it's a compile time error for something that's //! guaranteed to be a runtime error! -use crate::io as std_io; -use crate::mem; - #[path = "../unix/alloc.rs"] pub mod alloc; pub mod args; @@ -57,123 +54,12 @@ cfg_if::cfg_if! { mod common; pub use common::*; -#[inline] -pub fn is_interrupted(errno: i32) -> bool { - errno == wasi::ERRNO_INTR.raw().into() -} - -pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind { - use std_io::ErrorKind; - - let Ok(errno) = u16::try_from(errno) else { - return ErrorKind::Uncategorized; - }; - - macro_rules! match_errno { - ($($($errno:ident)|+ => $errkind:ident),*, _ => $wildcard:ident $(,)?) => { - match errno { - $(e if $(e == ::wasi::$errno.raw())||+ => ErrorKind::$errkind),*, - _ => ErrorKind::$wildcard, - } - }; - } - - match_errno! { - ERRNO_2BIG => ArgumentListTooLong, - ERRNO_ACCES => PermissionDenied, - ERRNO_ADDRINUSE => AddrInUse, - ERRNO_ADDRNOTAVAIL => AddrNotAvailable, - ERRNO_AFNOSUPPORT => Unsupported, - ERRNO_AGAIN => WouldBlock, - // ALREADY => "connection already in progress", - // BADF => "bad file descriptor", - // BADMSG => "bad message", - ERRNO_BUSY => ResourceBusy, - // CANCELED => "operation canceled", - // CHILD => "no child processes", - ERRNO_CONNABORTED => ConnectionAborted, - ERRNO_CONNREFUSED => ConnectionRefused, - ERRNO_CONNRESET => ConnectionReset, - ERRNO_DEADLK => Deadlock, - // DESTADDRREQ => "destination address required", - ERRNO_DOM => InvalidInput, - // DQUOT => /* reserved */, - ERRNO_EXIST => AlreadyExists, - // FAULT => "bad address", - ERRNO_FBIG => FileTooLarge, - ERRNO_HOSTUNREACH => HostUnreachable, - // IDRM => "identifier removed", - // ILSEQ => "illegal byte sequence", - // INPROGRESS => "operation in progress", - ERRNO_INTR => Interrupted, - ERRNO_INVAL => InvalidInput, - ERRNO_IO => Uncategorized, - // ISCONN => "socket is connected", - ERRNO_ISDIR => IsADirectory, - ERRNO_LOOP => FilesystemLoop, - // MFILE => "file descriptor value too large", - ERRNO_MLINK => TooManyLinks, - // MSGSIZE => "message too large", - // MULTIHOP => /* reserved */, - ERRNO_NAMETOOLONG => InvalidFilename, - ERRNO_NETDOWN => NetworkDown, - // NETRESET => "connection aborted by network", - ERRNO_NETUNREACH => NetworkUnreachable, - // NFILE => "too many files open in system", - // NOBUFS => "no buffer space available", - ERRNO_NODEV => NotFound, - ERRNO_NOENT => NotFound, - // NOEXEC => "executable file format error", - // NOLCK => "no locks available", - // NOLINK => /* reserved */, - ERRNO_NOMEM => OutOfMemory, - // NOMSG => "no message of the desired type", - // NOPROTOOPT => "protocol not available", - ERRNO_NOSPC => StorageFull, - ERRNO_NOSYS => Unsupported, - ERRNO_NOTCONN => NotConnected, - ERRNO_NOTDIR => NotADirectory, - ERRNO_NOTEMPTY => DirectoryNotEmpty, - // NOTRECOVERABLE => "state not recoverable", - // NOTSOCK => "not a socket", - ERRNO_NOTSUP => Unsupported, - // NOTTY => "inappropriate I/O control operation", - ERRNO_NXIO => NotFound, - // OVERFLOW => "value too large to be stored in data type", - // OWNERDEAD => "previous owner died", - ERRNO_PERM => PermissionDenied, - ERRNO_PIPE => BrokenPipe, - // PROTO => "protocol error", - ERRNO_PROTONOSUPPORT => Unsupported, - // PROTOTYPE => "protocol wrong type for socket", - // RANGE => "result too large", - ERRNO_ROFS => ReadOnlyFilesystem, - ERRNO_SPIPE => NotSeekable, - ERRNO_SRCH => NotFound, - // STALE => /* reserved */, - ERRNO_TIMEDOUT => TimedOut, - ERRNO_TXTBSY => ResourceBusy, - ERRNO_XDEV => CrossesDevices, - ERRNO_NOTCAPABLE => PermissionDenied, - _ => Uncategorized, - } -} - -pub fn abort_internal() -> ! { - unsafe { libc::abort() } -} - -pub fn hashmap_random_keys() -> (u64, u64) { - let mut ret = (0u64, 0u64); - unsafe { - let base = &mut ret as *mut (u64, u64) as *mut u8; - let len = mem::size_of_val(&ret); - wasi::random_get(base, len).expect("random_get failure"); - } - return ret; -} - -#[inline] -fn err2io(err: wasi::Errno) -> std_io::Error { - std_io::Error::from_raw_os_error(err.raw().into()) -} +mod helpers; +// These exports are listed individually to work around Rust's glob import +// conflict rules. If we glob export `helpers` and `common` together, then +// the compiler complains about conflicts. +pub use helpers::abort_internal; +pub use helpers::decode_error_kind; +use helpers::err2io; +pub use helpers::hashmap_random_keys; +pub use helpers::is_interrupted; diff --git a/library/std/src/sys/pal/wasip2/mod.rs b/library/std/src/sys/pal/wasip2/mod.rs new file mode 100644 index 0000000000000..b12a8d5ea11c7 --- /dev/null +++ b/library/std/src/sys/pal/wasip2/mod.rs @@ -0,0 +1,78 @@ +//! System bindings for the wasi preview 2 target. +//! +//! This is the next evolution of the original wasi target, and is intended to +//! replace that target over time. +//! +//! To begin with, this target mirrors the wasi target 1 to 1, but over +//! time this will change significantly. + +#[path = "../unix/alloc.rs"] +pub mod alloc; +#[path = "../wasi/args.rs"] +pub mod args; +#[path = "../unix/cmath.rs"] +pub mod cmath; +#[path = "../wasi/env.rs"] +pub mod env; +#[path = "../wasi/fd.rs"] +pub mod fd; +#[path = "../wasi/fs.rs"] +pub mod fs; +#[allow(unused)] +#[path = "../wasm/atomics/futex.rs"] +pub mod futex; +#[path = "../wasi/io.rs"] +pub mod io; + +#[path = "../wasi/net.rs"] +pub mod net; +#[path = "../wasi/os.rs"] +pub mod os; +#[path = "../unix/os_str.rs"] +pub mod os_str; +#[path = "../unix/path.rs"] +pub mod path; +#[path = "../unsupported/pipe.rs"] +pub mod pipe; +#[path = "../unsupported/process.rs"] +pub mod process; +#[path = "../wasi/stdio.rs"] +pub mod stdio; +#[path = "../wasi/thread.rs"] +pub mod thread; +#[path = "../unsupported/thread_local_dtor.rs"] +pub mod thread_local_dtor; +#[path = "../unsupported/thread_local_key.rs"] +pub mod thread_local_key; +#[path = "../wasi/time.rs"] +pub mod time; + +cfg_if::cfg_if! { + if #[cfg(target_feature = "atomics")] { + compile_error!("The wasm32-wasip2 target does not support atomics"); + } else { + #[path = "../unsupported/locks/mod.rs"] + pub mod locks; + #[path = "../unsupported/once.rs"] + pub mod once; + #[path = "../unsupported/thread_parking.rs"] + pub mod thread_parking; + } +} + +#[path = "../unsupported/common.rs"] +#[deny(unsafe_op_in_unsafe_fn)] +#[allow(unused)] +mod common; +pub use common::*; + +#[path = "../wasi/helpers.rs"] +mod helpers; +// These exports are listed individually to work around Rust's glob import +// conflict rules. If we glob export `helpers` and `common` together, then +// the compiler complains about conflicts. +pub use helpers::abort_internal; +pub use helpers::decode_error_kind; +use helpers::err2io; +pub use helpers::hashmap_random_keys; +pub use helpers::is_interrupted; diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs index 6b12d7db8b03a..b007796722baf 100644 --- a/library/std/src/sys/pal/windows/c.rs +++ b/library/std/src/sys/pal/windows/c.rs @@ -28,17 +28,14 @@ pub type SIZE_T = usize; pub type WORD = u16; pub type CHAR = c_char; pub type ULONG = c_ulong; -pub type ACCESS_MASK = DWORD; pub type LPCVOID = *const c_void; -pub type LPHANDLE = *mut HANDLE; pub type LPOVERLAPPED = *mut OVERLAPPED; pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; pub type LPVOID = *mut c_void; pub type LPWCH = *mut WCHAR; pub type LPWSTR = *mut WCHAR; -pub type PLARGE_INTEGER = *mut c_longlong; pub type PSRWLOCK = *mut SRWLOCK; pub type socklen_t = c_int; @@ -321,6 +318,21 @@ pub unsafe fn NtWriteFile( } } +// Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. +cfg_if::cfg_if! { +if #[cfg(not(target_vendor = "win7"))] { + #[cfg(target_arch = "x86")] + #[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")] + extern "system" { + pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; + } + #[cfg(not(target_arch = "x86"))] + #[link(name = "bcryptprimitives", kind = "raw-dylib")] + extern "system" { + pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; + } +}} + // Functions that aren't available on every version of Windows that we support, // but we still use them and just provide some form of a fallback implementation. compat_fn_with_fallback! { @@ -345,6 +357,19 @@ compat_fn_with_fallback! { } } +#[cfg(not(target_vendor = "win7"))] +#[link(name = "synchronization")] +extern "system" { + pub fn WaitOnAddress( + address: *const c_void, + compareaddress: *const c_void, + addresssize: usize, + dwmilliseconds: u32, + ) -> BOOL; + pub fn WakeByAddressSingle(address: *const c_void); +} + +#[cfg(target_vendor = "win7")] compat_fn_optional! { crate::sys::compat::load_synch_functions(); pub fn WaitOnAddress( @@ -356,30 +381,34 @@ compat_fn_optional! { pub fn WakeByAddressSingle(address: *const ::core::ffi::c_void); } +#[cfg(any(target_vendor = "win7", target_vendor = "uwp"))] compat_fn_with_fallback! { pub static NTDLL: &CStr = c"ntdll"; + #[cfg(target_vendor = "win7")] pub fn NtCreateKeyedEvent( - KeyedEventHandle: LPHANDLE, - DesiredAccess: ACCESS_MASK, + KeyedEventHandle: *mut HANDLE, + DesiredAccess: DWORD, ObjectAttributes: LPVOID, Flags: ULONG ) -> NTSTATUS { panic!("keyed events not available") } + #[cfg(target_vendor = "win7")] pub fn NtReleaseKeyedEvent( EventHandle: HANDLE, Key: LPVOID, Alertable: BOOLEAN, - Timeout: PLARGE_INTEGER + Timeout: *mut c_longlong ) -> NTSTATUS { panic!("keyed events not available") } + #[cfg(target_vendor = "win7")] pub fn NtWaitForKeyedEvent( EventHandle: HANDLE, Key: LPVOID, Alertable: BOOLEAN, - Timeout: PLARGE_INTEGER + Timeout: *mut c_longlong ) -> NTSTATUS { panic!("keyed events not available") } diff --git a/library/std/src/sys/pal/windows/c/bindings.txt b/library/std/src/sys/pal/windows/c/bindings.txt index 726f1c3df8294..ab2a8caf5dfd9 100644 --- a/library/std/src/sys/pal/windows/c/bindings.txt +++ b/library/std/src/sys/pal/windows/c/bindings.txt @@ -2180,10 +2180,6 @@ Windows.Win32.Networking.WinSock.WSATRY_AGAIN Windows.Win32.Networking.WinSock.WSATYPE_NOT_FOUND Windows.Win32.Networking.WinSock.WSAVERNOTSUPPORTED Windows.Win32.Security.Authentication.Identity.RtlGenRandom -Windows.Win32.Security.Cryptography.BCRYPT_ALG_HANDLE -Windows.Win32.Security.Cryptography.BCRYPT_USE_SYSTEM_PREFERRED_RNG -Windows.Win32.Security.Cryptography.BCryptGenRandom -Windows.Win32.Security.Cryptography.BCRYPTGENRANDOM_FLAGS Windows.Win32.Security.SECURITY_ATTRIBUTES Windows.Win32.Security.TOKEN_ACCESS_MASK Windows.Win32.Security.TOKEN_ACCESS_PSEUDO_HANDLE diff --git a/library/std/src/sys/pal/windows/c/windows_sys.rs b/library/std/src/sys/pal/windows/c/windows_sys.rs index c386b66a722df..8eb779373f7e4 100644 --- a/library/std/src/sys/pal/windows/c/windows_sys.rs +++ b/library/std/src/sys/pal/windows/c/windows_sys.rs @@ -15,15 +15,6 @@ extern "system" { pub fn RtlGenRandom(randombuffer: *mut ::core::ffi::c_void, randombufferlength: u32) -> BOOLEAN; } -#[link(name = "bcrypt")] -extern "system" { - pub fn BCryptGenRandom( - halgorithm: BCRYPT_ALG_HANDLE, - pbbuffer: *mut u8, - cbbuffer: u32, - dwflags: BCRYPTGENRANDOM_FLAGS, - ) -> NTSTATUS; -} #[link(name = "kernel32")] extern "system" { pub fn AcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> (); @@ -889,9 +880,6 @@ impl ::core::clone::Clone for ARM64_NT_NEON128_0 { *self } } -pub type BCRYPTGENRANDOM_FLAGS = u32; -pub type BCRYPT_ALG_HANDLE = *mut ::core::ffi::c_void; -pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: BCRYPTGENRANDOM_FLAGS = 2u32; pub const BELOW_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 16384u32; pub type BOOL = i32; pub type BOOLEAN = u8; diff --git a/library/std/src/sys/pal/windows/compat.rs b/library/std/src/sys/pal/windows/compat.rs index f60b3a2c700f2..f5d57a28db69a 100644 --- a/library/std/src/sys/pal/windows/compat.rs +++ b/library/std/src/sys/pal/windows/compat.rs @@ -21,7 +21,6 @@ use crate::ffi::{c_void, CStr}; use crate::ptr::NonNull; -use crate::sync::atomic::Ordering; use crate::sys::c; // This uses a static initializer to preload some imported functions. @@ -38,6 +37,7 @@ use crate::sys::c; // file an issue for discussion; currently we don't guarantee any functionality // before main. // See https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization?view=msvc-170 +#[cfg(target_vendor = "win7")] #[used] #[link_section = ".CRT$XCT"] static INIT_TABLE_ENTRY: unsafe extern "C" fn() = init; @@ -52,6 +52,7 @@ static INIT_TABLE_ENTRY: unsafe extern "C" fn() = init; /// negative performance impact in practical situations. /// /// Currently we only preload `WaitOnAddress` and `WakeByAddressSingle`. +#[cfg(target_vendor = "win7")] unsafe extern "C" fn init() { // In an exe this code is executed before main() so is single threaded. // In a DLL the system's loader lock will be held thereby synchronizing @@ -183,6 +184,7 @@ macro_rules! compat_fn_with_fallback { func($($argname),*) } } + #[allow(unused)] $(#[$meta])* $vis use $symbol::call as $symbol; )*) @@ -191,6 +193,7 @@ macro_rules! compat_fn_with_fallback { /// Optionally loaded functions. /// /// Actual loading of the function defers to $load_functions. +#[cfg(target_vendor = "win7")] macro_rules! compat_fn_optional { ($load_functions:expr; $( @@ -218,13 +221,19 @@ macro_rules! compat_fn_optional { NonNull::new(PTR.load(Ordering::Relaxed)).map(|f| unsafe { mem::transmute(f) }) } } + #[inline] + pub unsafe extern "system" fn $symbol($($argname: $argtype),*) $(-> $rettype)? { + $symbol::option().unwrap()($($argname),*) + } )+ ) } /// Load all needed functions from "api-ms-win-core-synch-l1-2-0". +#[cfg(target_vendor = "win7")] pub(super) fn load_synch_functions() { fn try_load() -> Option<()> { + use crate::sync::atomic::Ordering; const MODULE_NAME: &CStr = c"api-ms-win-core-synch-l1-2-0"; const WAIT_ON_ADDRESS: &CStr = c"WaitOnAddress"; const WAKE_BY_ADDRESS_SINGLE: &CStr = c"WakeByAddressSingle"; diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/pal/windows/fs.rs index b82a83ae7a3e8..3a9e7b4660b36 100644 --- a/library/std/src/sys/pal/windows/fs.rs +++ b/library/std/src/sys/pal/windows/fs.rs @@ -394,7 +394,7 @@ impl File { cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileBasicInfo, - &mut info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(info) as *mut c_void, size as c::DWORD, ))?; let mut attr = FileAttr { @@ -422,7 +422,7 @@ impl File { cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileStandardInfo, - &mut info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(info) as *mut c_void, size as c::DWORD, ))?; attr.file_size = info.AllocationSize as u64; @@ -638,7 +638,7 @@ impl File { cvt(c::GetFileInformationByHandleEx( self.handle.as_raw_handle(), c::FileBasicInfo, - &mut info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(info) as *mut c_void, size as c::DWORD, ))?; Ok(info) @@ -1438,7 +1438,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { pfrom.as_ptr(), pto.as_ptr(), Some(callback), - &mut size as *mut _ as *mut _, + core::ptr::addr_of_mut!(size) as *mut _, ptr::null_mut(), 0, ) diff --git a/library/std/src/sys/pal/windows/io.rs b/library/std/src/sys/pal/windows/io.rs index b73d9f3ff4c4a..77b8f3c410eb8 100644 --- a/library/std/src/sys/pal/windows/io.rs +++ b/library/std/src/sys/pal/windows/io.rs @@ -122,7 +122,7 @@ unsafe fn msys_tty_on(handle: c::HANDLE) -> bool { let res = c::GetFileInformationByHandleEx( handle, c::FileNameInfo, - &mut name_info as *mut _ as *mut c_void, + core::ptr::addr_of_mut!(name_info) as *mut c_void, size_of::() as u32, ); if res == 0 { diff --git a/library/std/src/sys/pal/windows/net.rs b/library/std/src/sys/pal/windows/net.rs index e37fbe9ef83e4..1e6169ea8ece0 100644 --- a/library/std/src/sys/pal/windows/net.rs +++ b/library/std/src/sys/pal/windows/net.rs @@ -310,7 +310,7 @@ impl Socket { buf.as_mut_ptr() as *mut _, length, flags, - &mut storage as *mut _ as *mut _, + core::ptr::addr_of_mut!(storage) as *mut _, &mut addrlen, ) }; diff --git a/library/std/src/sys/pal/windows/pipe.rs b/library/std/src/sys/pal/windows/pipe.rs index fd10df82d8b47..013f588676ae8 100644 --- a/library/std/src/sys/pal/windows/pipe.rs +++ b/library/std/src/sys/pal/windows/pipe.rs @@ -375,7 +375,7 @@ impl AnonPipe { let mut overlapped: c::OVERLAPPED = crate::mem::zeroed(); // `hEvent` is unused by `ReadFileEx` and `WriteFileEx`. // Therefore the documentation suggests using it to smuggle a pointer to the callback. - overlapped.hEvent = &mut async_result as *mut _ as *mut _; + overlapped.hEvent = core::ptr::addr_of_mut!(async_result) as *mut _; // Asynchronous read of the pipe. // If successful, `callback` will be called once it completes. diff --git a/library/std/src/sys/pal/windows/process.rs b/library/std/src/sys/pal/windows/process.rs index 6a94d37714038..e4ab2ca7da1ce 100644 --- a/library/std/src/sys/pal/windows/process.rs +++ b/library/std/src/sys/pal/windows/process.rs @@ -350,10 +350,10 @@ impl Command { StartupInfo: si, lpAttributeList: proc_thread_attribute_list.0.as_mut_ptr() as _, }; - si_ptr = &mut si_ex as *mut _ as _; + si_ptr = core::ptr::addr_of_mut!(si_ex) as _; } else { si.cb = mem::size_of::() as c::DWORD; - si_ptr = &mut si as *mut _ as _; + si_ptr = core::ptr::addr_of_mut!(si) as _; } unsafe { @@ -935,7 +935,7 @@ fn make_proc_thread_attribute_list( // It's theoretically possible for the attribute count to exceed a u32 value. // Therefore, we ensure that we don't add more attributes than the buffer was initialized for. for (&attribute, value) in attributes.iter().take(attribute_count as usize) { - let value_ptr = &*value.data as *const (dyn Send + Sync) as _; + let value_ptr = core::ptr::addr_of!(*value.data) as _; cvt(unsafe { c::UpdateProcThreadAttribute( proc_thread_attribute_list.0.as_mut_ptr() as _, diff --git a/library/std/src/sys/pal/windows/rand.rs b/library/std/src/sys/pal/windows/rand.rs index 5d8fd13785a09..e427546222aea 100644 --- a/library/std/src/sys/pal/windows/rand.rs +++ b/library/std/src/sys/pal/windows/rand.rs @@ -1,42 +1,27 @@ -use crate::mem; -use crate::ptr; use crate::sys::c; +use core::mem; +use core::ptr; +#[cfg(not(target_vendor = "win7"))] +#[inline] pub fn hashmap_random_keys() -> (u64, u64) { let mut v = (0, 0); - let ret = unsafe { - c::BCryptGenRandom( - ptr::null_mut(), - &mut v as *mut _ as *mut u8, - mem::size_of_val(&v) as c::ULONG, - c::BCRYPT_USE_SYSTEM_PREFERRED_RNG, - ) - }; - if c::nt_success(ret) { v } else { fallback_rng() } + let ret = unsafe { c::ProcessPrng(ptr::addr_of_mut!(v).cast::(), mem::size_of_val(&v)) }; + // ProcessPrng is documented as always returning `TRUE`. + // https://learn.microsoft.com/en-us/windows/win32/seccng/processprng#return-value + debug_assert_eq!(ret, c::TRUE); + v } -/// Generate random numbers using the fallback RNG function (RtlGenRandom) -/// -/// This is necessary because of a failure to load the SysWOW64 variant of the -/// bcryptprimitives.dll library from code that lives in bcrypt.dll -/// See -#[cfg(not(target_vendor = "uwp"))] -#[inline(never)] -fn fallback_rng() -> (u64, u64) { +#[cfg(target_vendor = "win7")] +pub fn hashmap_random_keys() -> (u64, u64) { use crate::ffi::c_void; use crate::io; let mut v = (0, 0); let ret = unsafe { - c::RtlGenRandom(&mut v as *mut _ as *mut c_void, mem::size_of_val(&v) as c::ULONG) + c::RtlGenRandom(ptr::addr_of_mut!(v).cast::(), mem::size_of_val(&v) as c::ULONG) }; - if ret != 0 { v } else { panic!("fallback RNG broken: {}", io::Error::last_os_error()) } -} - -/// We can't use RtlGenRandom with UWP, so there is no fallback -#[cfg(target_vendor = "uwp")] -#[inline(never)] -fn fallback_rng() -> (u64, u64) { - panic!("fallback RNG broken: RtlGenRandom() not supported on UWP"); + if ret != 0 { v } else { panic!("RNG broken: {}", io::Error::last_os_error()) } } diff --git a/library/std/src/sys/pal/windows/thread_parking.rs b/library/std/src/sys/pal/windows/thread_parking.rs index 343b530b15ef9..4b8102d505a1f 100644 --- a/library/std/src/sys/pal/windows/thread_parking.rs +++ b/library/std/src/sys/pal/windows/thread_parking.rs @@ -58,10 +58,9 @@ // [4]: Windows Internals, Part 1, ISBN 9780735671300 use crate::pin::Pin; -use crate::ptr; use crate::sync::atomic::{ - AtomicI8, AtomicPtr, - Ordering::{Acquire, Relaxed, Release}, + AtomicI8, + Ordering::{Acquire, Release}, }; use crate::sys::{c, dur2timeout}; use crate::time::Duration; @@ -111,26 +110,21 @@ impl Parker { return; } - if let Some(wait_on_address) = c::WaitOnAddress::option() { - loop { - // Wait for something to happen, assuming it's still set to PARKED. - wait_on_address(self.ptr(), &PARKED as *const _ as c::LPVOID, 1, c::INFINITE); - // Change NOTIFIED=>EMPTY but leave PARKED alone. - if self.state.compare_exchange(NOTIFIED, EMPTY, Acquire, Acquire).is_ok() { - // Actually woken up by unpark(). - return; - } else { - // Spurious wake up. We loop to try again. - } + #[cfg(target_vendor = "win7")] + if c::WaitOnAddress::option().is_none() { + return keyed_events::park(self); + } + + loop { + // Wait for something to happen, assuming it's still set to PARKED. + c::WaitOnAddress(self.ptr(), &PARKED as *const _ as c::LPVOID, 1, c::INFINITE); + // Change NOTIFIED=>EMPTY but leave PARKED alone. + if self.state.compare_exchange(NOTIFIED, EMPTY, Acquire, Acquire).is_ok() { + // Actually woken up by unpark(). + return; + } else { + // Spurious wake up. We loop to try again. } - } else { - // Wait for unpark() to produce this event. - c::NtWaitForKeyedEvent(keyed_event_handle(), self.ptr(), 0, ptr::null_mut()); - // Set the state back to EMPTY (from either PARKED or NOTIFIED). - // Note that we don't just write EMPTY, but use swap() to also - // include an acquire-ordered read to synchronize with unpark()'s - // release-ordered write. - self.state.swap(EMPTY, Acquire); } } @@ -144,47 +138,23 @@ impl Parker { return; } - if let Some(wait_on_address) = c::WaitOnAddress::option() { - // Wait for something to happen, assuming it's still set to PARKED. - wait_on_address(self.ptr(), &PARKED as *const _ as c::LPVOID, 1, dur2timeout(timeout)); - // Set the state back to EMPTY (from either PARKED or NOTIFIED). - // Note that we don't just write EMPTY, but use swap() to also - // include an acquire-ordered read to synchronize with unpark()'s - // release-ordered write. - if self.state.swap(EMPTY, Acquire) == NOTIFIED { - // Actually woken up by unpark(). - } else { - // Timeout or spurious wake up. - // We return either way, because we can't easily tell if it was the - // timeout or not. - } + #[cfg(target_vendor = "win7")] + if c::WaitOnAddress::option().is_none() { + return keyed_events::park_timeout(self, timeout); + } + + // Wait for something to happen, assuming it's still set to PARKED. + c::WaitOnAddress(self.ptr(), &PARKED as *const _ as c::LPVOID, 1, dur2timeout(timeout)); + // Set the state back to EMPTY (from either PARKED or NOTIFIED). + // Note that we don't just write EMPTY, but use swap() to also + // include an acquire-ordered read to synchronize with unpark()'s + // release-ordered write. + if self.state.swap(EMPTY, Acquire) == NOTIFIED { + // Actually woken up by unpark(). } else { - // Need to wait for unpark() using NtWaitForKeyedEvent. - let handle = keyed_event_handle(); - - // NtWaitForKeyedEvent uses a unit of 100ns, and uses negative - // values to indicate a relative time on the monotonic clock. - // This is documented here for the underlying KeWaitForSingleObject function: - // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-kewaitforsingleobject - let mut timeout = match i64::try_from((timeout.as_nanos() + 99) / 100) { - Ok(t) => -t, - Err(_) => i64::MIN, - }; - - // Wait for unpark() to produce this event. - let unparked = - c::NtWaitForKeyedEvent(handle, self.ptr(), 0, &mut timeout) == c::STATUS_SUCCESS; - - // Set the state back to EMPTY (from either PARKED or NOTIFIED). - let prev_state = self.state.swap(EMPTY, Acquire); - - if !unparked && prev_state == NOTIFIED { - // We were awoken by a timeout, not by unpark(), but the state - // was set to NOTIFIED, which means we *just* missed an - // unpark(), which is now blocked on us to wait for it. - // Wait for it to consume the event and unblock that thread. - c::NtWaitForKeyedEvent(handle, self.ptr(), 0, ptr::null_mut()); - } + // Timeout or spurious wake up. + // We return either way, because we can't easily tell if it was the + // timeout or not. } } @@ -198,56 +168,111 @@ impl Parker { // with park(). if self.state.swap(NOTIFIED, Release) == PARKED { unsafe { - if let Some(wake_by_address_single) = c::WakeByAddressSingle::option() { - wake_by_address_single(self.ptr()); - } else { - // If we run NtReleaseKeyedEvent before the waiting thread runs - // NtWaitForKeyedEvent, this (shortly) blocks until we can wake it up. - // If the waiting thread wakes up before we run NtReleaseKeyedEvent - // (e.g. due to a timeout), this blocks until we do wake up a thread. - // To prevent this thread from blocking indefinitely in that case, - // park_impl() will, after seeing the state set to NOTIFIED after - // waking up, call NtWaitForKeyedEvent again to unblock us. - c::NtReleaseKeyedEvent(keyed_event_handle(), self.ptr(), 0, ptr::null_mut()); + #[cfg(target_vendor = "win7")] + if c::WakeByAddressSingle::option().is_none() { + return keyed_events::unpark(self); } + c::WakeByAddressSingle(self.ptr()); } } } fn ptr(&self) -> c::LPVOID { - &self.state as *const _ as c::LPVOID + core::ptr::addr_of!(self.state) as c::LPVOID } } -fn keyed_event_handle() -> c::HANDLE { - const INVALID: c::HANDLE = ptr::without_provenance_mut(!0); - static HANDLE: AtomicPtr = AtomicPtr::new(INVALID); - match HANDLE.load(Relaxed) { - INVALID => { - let mut handle = c::INVALID_HANDLE_VALUE; - unsafe { - match c::NtCreateKeyedEvent( - &mut handle, - c::GENERIC_READ | c::GENERIC_WRITE, - ptr::null_mut(), - 0, - ) { - c::STATUS_SUCCESS => {} - r => panic!("Unable to create keyed event handle: error {r}"), +#[cfg(target_vendor = "win7")] +mod keyed_events { + use super::{Parker, EMPTY, NOTIFIED}; + use crate::sys::c; + use core::pin::Pin; + use core::ptr; + use core::sync::atomic::{ + AtomicPtr, + Ordering::{Acquire, Relaxed}, + }; + use core::time::Duration; + + pub unsafe fn park(parker: Pin<&Parker>) { + // Wait for unpark() to produce this event. + c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + // Set the state back to EMPTY (from either PARKED or NOTIFIED). + // Note that we don't just write EMPTY, but use swap() to also + // include an acquire-ordered read to synchronize with unpark()'s + // release-ordered write. + parker.state.swap(EMPTY, Acquire); + return; + } + pub unsafe fn park_timeout(parker: Pin<&Parker>, timeout: Duration) { + // Need to wait for unpark() using NtWaitForKeyedEvent. + let handle = keyed_event_handle(); + + // NtWaitForKeyedEvent uses a unit of 100ns, and uses negative + // values to indicate a relative time on the monotonic clock. + // This is documented here for the underlying KeWaitForSingleObject function: + // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-kewaitforsingleobject + let mut timeout = match i64::try_from((timeout.as_nanos() + 99) / 100) { + Ok(t) => -t, + Err(_) => i64::MIN, + }; + + // Wait for unpark() to produce this event. + let unparked = + c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, &mut timeout) == c::STATUS_SUCCESS; + + // Set the state back to EMPTY (from either PARKED or NOTIFIED). + let prev_state = parker.state.swap(EMPTY, Acquire); + + if !unparked && prev_state == NOTIFIED { + // We were awoken by a timeout, not by unpark(), but the state + // was set to NOTIFIED, which means we *just* missed an + // unpark(), which is now blocked on us to wait for it. + // Wait for it to consume the event and unblock that thread. + c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, ptr::null_mut()); + } + } + pub unsafe fn unpark(parker: Pin<&Parker>) { + // If we run NtReleaseKeyedEvent before the waiting thread runs + // NtWaitForKeyedEvent, this (shortly) blocks until we can wake it up. + // If the waiting thread wakes up before we run NtReleaseKeyedEvent + // (e.g. due to a timeout), this blocks until we do wake up a thread. + // To prevent this thread from blocking indefinitely in that case, + // park_impl() will, after seeing the state set to NOTIFIED after + // waking up, call NtWaitForKeyedEvent again to unblock us. + c::NtReleaseKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + } + + fn keyed_event_handle() -> c::HANDLE { + const INVALID: c::HANDLE = ptr::without_provenance_mut(!0); + static HANDLE: AtomicPtr = AtomicPtr::new(INVALID); + match HANDLE.load(Relaxed) { + INVALID => { + let mut handle = c::INVALID_HANDLE_VALUE; + unsafe { + match c::NtCreateKeyedEvent( + &mut handle, + c::GENERIC_READ | c::GENERIC_WRITE, + ptr::null_mut(), + 0, + ) { + c::STATUS_SUCCESS => {} + r => panic!("Unable to create keyed event handle: error {r}"), + } } - } - match HANDLE.compare_exchange(INVALID, handle, Relaxed, Relaxed) { - Ok(_) => handle, - Err(h) => { - // Lost the race to another thread initializing HANDLE before we did. - // Closing our handle and using theirs instead. - unsafe { - c::CloseHandle(handle); + match HANDLE.compare_exchange(INVALID, handle, Relaxed, Relaxed) { + Ok(_) => handle, + Err(h) => { + // Lost the race to another thread initializing HANDLE before we did. + // Closing our handle and using theirs instead. + unsafe { + c::CloseHandle(handle); + } + h } - h } } + handle => handle, } - handle => handle, } } diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index de7d31baaaf8c..581c46af0eacf 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -70,7 +70,7 @@ pub fn setsockopt( sock.as_raw(), level, option_name, - &option_value as *const T as *const _, + core::ptr::addr_of!(option_value) as *const _, mem::size_of::() as c::socklen_t, ))?; Ok(()) @@ -85,7 +85,7 @@ pub fn getsockopt(sock: &Socket, level: c_int, option_name: c_int) -> i sock.as_raw(), level, option_name, - &mut option_value as *mut T as *mut _, + core::ptr::addr_of_mut!(option_value) as *mut _, &mut option_len, ))?; Ok(option_value) @@ -99,7 +99,7 @@ where unsafe { let mut storage: c::sockaddr_storage = mem::zeroed(); let mut len = mem::size_of_val(&storage) as c::socklen_t; - cvt(f(&mut storage as *mut _ as *mut _, &mut len))?; + cvt(f(core::ptr::addr_of_mut!(storage) as *mut _, &mut len))?; sockaddr_to_addr(&storage, len as usize) } } @@ -444,7 +444,7 @@ impl TcpListener { pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; let mut len = mem::size_of_val(&storage) as c::socklen_t; - let sock = self.inner.accept(&mut storage as *mut _ as *mut _, &mut len)?; + let sock = self.inner.accept(core::ptr::addr_of_mut!(storage) as *mut _, &mut len)?; let addr = sockaddr_to_addr(&storage, len as usize)?; Ok((TcpStream { inner: sock }, addr)) } diff --git a/library/std/src/sys_common/once/queue.rs b/library/std/src/sys_common/once/queue.rs index 3cc1df113e3f1..730cdb768bd27 100644 --- a/library/std/src/sys_common/once/queue.rs +++ b/library/std/src/sys_common/once/queue.rs @@ -212,7 +212,7 @@ fn wait(state_and_queue: &AtomicPtr, mut current_state: *mut Masked) { signaled: AtomicBool::new(false), next: current_state.with_addr(current_state.addr() & !STATE_MASK) as *const Waiter, }; - let me = &node as *const Waiter as *const Masked as *mut Masked; + let me = core::ptr::addr_of!(node) as *const Masked as *mut Masked; // Try to slide in the node at the head of the linked list, making sure // that another thread didn't just replace the head of the linked list. diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index 34d30a259ee98..fbb882e640b64 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -180,8 +180,6 @@ impl fmt::Debug for LocalKey { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "thread_local_macro")] #[allow_internal_unstable(thread_local_internals)] -// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint -#[cfg_attr(not(bootstrap), allow(static_mut_refs))] macro_rules! thread_local { // empty (base case for the recursion) () => {}; diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 4f0f010984ab9..76af7fec92648 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -165,7 +165,7 @@ use crate::fmt; use crate::io; use crate::marker::PhantomData; use crate::mem::{self, forget}; -use crate::num::{NonZero, NonZeroU64, NonZeroUsize}; +use crate::num::NonZero; use crate::panic; use crate::panicking; use crate::pin::Pin; @@ -1222,7 +1222,7 @@ impl ThreadId { /// change across Rust versions. #[must_use] #[unstable(feature = "thread_id_value", issue = "67939")] - pub fn as_u64(&self) -> NonZeroU64 { + pub fn as_u64(&self) -> NonZero { self.0 } } @@ -1784,6 +1784,6 @@ fn _assert_sync_and_send() { #[doc(alias = "hardware_concurrency")] // Alias for C++ `std::thread::hardware_concurrency`. #[doc(alias = "num_cpus")] // Alias for a popular ecosystem crate which provides similar functionality. #[stable(feature = "available_parallelism", since = "1.59.0")] -pub fn available_parallelism() -> io::Result { +pub fn available_parallelism() -> io::Result> { imp::available_parallelism() } diff --git a/library/std/src/thread/scoped.rs b/library/std/src/thread/scoped.rs index ada69aa8269f6..7b11e7c17b187 100644 --- a/library/std/src/thread/scoped.rs +++ b/library/std/src/thread/scoped.rs @@ -311,7 +311,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> { /// Checks if the associated thread has finished running its main function. /// /// `is_finished` supports implementing a non-blocking join operation, by checking - /// `is_finished`, and calling `join` if it returns `false`. This function does not block. To + /// `is_finished`, and calling `join` if it returns `true`. This function does not block. To /// block while waiting on the thread to finish, use [`join`][Self::join]. /// /// This might return `true` for a brief moment after the thread's main diff --git a/library/stdarch b/library/stdarch index d5fab978fe1c2..56087ea170d87 160000 --- a/library/stdarch +++ b/library/stdarch @@ -1 +1 @@ -Subproject commit d5fab978fe1c2f0043db0451e9f4857eeba17437 +Subproject commit 56087ea170d878a7a57b3a5725e0c00f5f5cad70 diff --git a/library/test/src/helpers/concurrency.rs b/library/test/src/helpers/concurrency.rs index eb211157371b5..b395adcf885ce 100644 --- a/library/test/src/helpers/concurrency.rs +++ b/library/test/src/helpers/concurrency.rs @@ -1,10 +1,10 @@ //! Helper module which helps to determine amount of threads to be used //! during tests execution. -use std::{env, num::NonZeroUsize, thread}; +use std::{env, num::NonZero, thread}; pub fn get_concurrency() -> usize { if let Ok(value) = env::var("RUST_TEST_THREADS") { - match value.parse::().ok() { + match value.parse::>().ok() { Some(n) => n.get(), _ => panic!("RUST_TEST_THREADS is `{value}`, should be a positive integer."), } diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index da110f9924861..728c73d8c502a 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -17,6 +17,7 @@ #![unstable(feature = "test", issue = "50297")] #![doc(test(attr(deny(warnings))))] #![doc(rust_logo)] +#![feature(generic_nonzero)] #![feature(rustdoc_internals)] #![feature(internal_output_capture)] #![feature(staged_api)] diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index f5988a4df1364..a64f290463374 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -3,7 +3,7 @@ #![feature(link_cfg)] #![feature(staged_api)] #![feature(c_unwind)] -#![feature(cfg_target_abi)] +#![cfg_attr(bootstrap, feature(cfg_target_abi))] #![feature(strict_provenance)] #![cfg_attr(not(target_env = "msvc"), feature(libc))] #![allow(internal_features)] diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 1b5f6f9dde36c..527c408c89edd 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -219,14 +219,14 @@ if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", targe pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word { let mut val: _Unwind_Word = core::ptr::null(); _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - &mut val as *mut _ as *mut c_void); + core::ptr::addr_of_mut!(val) as *mut c_void); val } pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { let mut value = value; _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - &mut value as *mut _ as *mut c_void); + core::ptr::addr_of_mut!(value) as *mut c_void); } pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) diff --git a/src/bootstrap/defaults/config.compiler.toml b/src/bootstrap/defaults/config.compiler.toml index 178c6e9056c69..e276f12621188 100644 --- a/src/bootstrap/defaults/config.compiler.toml +++ b/src/bootstrap/defaults/config.compiler.toml @@ -19,9 +19,9 @@ lto = "off" frame-pointers = true [llvm] -# This enables debug-assertions in LLVM, -# catching logic errors in codegen much earlier in the process. -assertions = true +# Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true` +# because we don't provide ci-llvm on the `rustc-alt-builds` server. Therefore, it is kept off by default. +assertions = false # Enable warnings during the LLVM compilation (when LLVM is changed, causing a compilation) enable-warnings = true # Will download LLVM from CI if available on your platform. diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 3ac60f15ef67e..f6f4253a36435 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -367,7 +367,7 @@ impl Step for CodegenBackend { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustAnalyzer { pub target: TargetSelection, } @@ -441,7 +441,7 @@ impl Step for RustAnalyzer { macro_rules! tool_check_step { ($name:ident, $path:literal, $($alias:literal, )* $source_type:path $(, $default:literal )?) => { - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub target: TargetSelection, } diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index 4b993945f19fc..17ca92f25a928 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -14,7 +14,7 @@ use crate::utils::cache::Interned; use crate::utils::helpers::t; use crate::{Build, Compiler, Mode, Subcommand}; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CleanAll {} impl Step for CleanAll { diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index d349cd67fed2c..43ac71b112c0b 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -398,10 +398,13 @@ fn copy_self_contained_objects( let srcdir = builder .wasi_root(target) .unwrap_or_else(|| { - panic!("Target {:?} does not have a \"wasi-root\" key", target.triple) + panic!( + "Target {:?} does not have a \"wasi-root\" key in Config.toml", + target.triple + ) }) .join("lib") - .join(target.to_string().replace("-preview1", "")); + .join(target.to_string().replace("-preview1", "").replace("p2", "")); for &obj in &["libc.a", "crt1-command.o", "crt1-reactor.o"] { copy_and_stamp( builder, @@ -727,7 +730,7 @@ fn apple_darwin_sign_file(file_path: &Path) { assert!(status.success()); } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StartupObjects { pub compiler: Compiler, pub target: TargetSelection, @@ -1491,7 +1494,7 @@ pub fn compiler_file( PathBuf::from(out.trim()) } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Sysroot { pub compiler: Compiler, /// See [`Std::force_recompile`]. @@ -1653,7 +1656,7 @@ impl Step for Sysroot { } } -#[derive(Debug, Copy, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)] pub struct Assemble { /// The compiler which we will produce in this step. Assemble itself will /// take care of ensuring that the necessary prerequisites to do so exist, diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index d9ab18e7250b0..fe50a787f9f05 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -50,7 +50,7 @@ fn should_build_extended_tool(builder: &Builder<'_>, tool: &str) -> bool { builder.config.tools.as_ref().map_or(true, |tools| tools.contains(tool)) } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Docs { pub host: TargetSelection, } @@ -83,7 +83,7 @@ impl Step for Docs { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct JsonDocs { pub host: TargetSelection, } @@ -121,7 +121,7 @@ impl Step for JsonDocs { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustcDocs { pub host: TargetSelection, } @@ -308,7 +308,7 @@ fn make_win_dist( } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Mingw { pub host: TargetSelection, } @@ -348,7 +348,7 @@ impl Step for Mingw { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Rustc { pub compiler: Compiler, } @@ -476,7 +476,7 @@ impl Step for Rustc { let man_src = builder.src.join("src/doc/man"); let man_dst = image.join("share/man/man1"); - // don't use our `bootstrap::{copy, cp_r}`, because those try + // don't use our `bootstrap::{copy_internal, cp_r}`, because those try // to hardlink, and we don't want to edit the source templates for file_entry in builder.read_dir(&man_src) { let page_src = file_entry.path(); @@ -617,7 +617,7 @@ fn copy_target_libs(builder: &Builder<'_>, target: TargetSelection, image: &Path } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Std { pub compiler: Compiler, pub target: TargetSelection, @@ -664,7 +664,7 @@ impl Step for Std { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct RustcDev { pub compiler: Compiler, pub target: TargetSelection, @@ -723,7 +723,7 @@ impl Step for RustcDev { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Analysis { pub compiler: Compiler, pub target: TargetSelection, @@ -870,7 +870,7 @@ fn copy_src_dirs( } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Src; impl Step for Src { @@ -931,7 +931,7 @@ impl Step for Src { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct PlainSourceTarball; impl Step for PlainSourceTarball { @@ -1031,7 +1031,7 @@ impl Step for PlainSourceTarball { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub compiler: Compiler, pub target: TargetSelection, @@ -1080,7 +1080,7 @@ impl Step for Cargo { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Rls { pub compiler: Compiler, pub target: TargetSelection, @@ -1122,7 +1122,7 @@ impl Step for Rls { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzer { pub compiler: Compiler, pub target: TargetSelection, @@ -1164,7 +1164,7 @@ impl Step for RustAnalyzer { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Clippy { pub compiler: Compiler, pub target: TargetSelection, @@ -1212,7 +1212,7 @@ impl Step for Clippy { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Miri { pub compiler: Compiler, pub target: TargetSelection, @@ -1359,7 +1359,7 @@ impl Step for CodegenBackend { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Rustfmt { pub compiler: Compiler, pub target: TargetSelection, @@ -1404,7 +1404,7 @@ impl Step for Rustfmt { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct RustDemangler { pub compiler: Compiler, pub target: TargetSelection, @@ -1460,7 +1460,7 @@ impl Step for RustDemangler { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct Extended { stage: u32, host: TargetSelection, diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 7a122a8676ba7..a4903ce235365 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -32,7 +32,7 @@ macro_rules! submodule_helper { macro_rules! book { ($($name:ident, $path:expr, $book_name:expr $(, submodule $(= $submodule:literal)? )? ;)+) => { $( - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { target: TargetSelection, } @@ -86,7 +86,7 @@ book!( StyleGuide, "src/doc/style-guide", "style-guide"; ); -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct UnstableBook { target: TargetSelection, } @@ -160,7 +160,7 @@ impl Step for RustbookSrc

Send for Complex {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:133:5 + --> tests/ui/non_send_fields_in_send_ty.rs:133:5 | LL | field1: A, | ^^^^^^^^^ = help: add `P: Send` bound in `Send` impl error: some fields in `Complex>` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:141:1 + --> tests/ui/non_send_fields_in_send_ty.rs:141:1 | LL | unsafe impl Send for Complex> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field2` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:134:5 + --> tests/ui/non_send_fields_in_send_ty.rs:134:5 | LL | field2: B, | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/nonminimal_bool.rs b/src/tools/clippy/tests/ui/nonminimal_bool.rs index f7c3df7066f7d..908ef6cb2a02c 100644 --- a/src/tools/clippy/tests/ui/nonminimal_bool.rs +++ b/src/tools/clippy/tests/ui/nonminimal_bool.rs @@ -156,3 +156,20 @@ fn issue11932() { x % 3 == 0 }; } + +fn issue_5794() { + let a = 0; + if !(12 == a) {} //~ ERROR: this boolean expression can be simplified + if !(a == 12) {} //~ ERROR: this boolean expression can be simplified + if !(12 != a) {} //~ ERROR: this boolean expression can be simplified + if !(a != 12) {} //~ ERROR: this boolean expression can be simplified + + let b = true; + let c = false; + if !b == true {} //~ ERROR: this boolean expression can be simplified + if !b != true {} //~ ERROR: this boolean expression can be simplified + if true == !b {} //~ ERROR: this boolean expression can be simplified + if true != !b {} //~ ERROR: this boolean expression can be simplified + if !b == !c {} //~ ERROR: this boolean expression can be simplified + if !b != !c {} //~ ERROR: this boolean expression can be simplified +} diff --git a/src/tools/clippy/tests/ui/nonminimal_bool.stderr b/src/tools/clippy/tests/ui/nonminimal_bool.stderr index fd1568d94e3ec..954e23452665d 100644 --- a/src/tools/clippy/tests/ui/nonminimal_bool.stderr +++ b/src/tools/clippy/tests/ui/nonminimal_bool.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:18:13 + --> tests/ui/nonminimal_bool.rs:18:13 | LL | let _ = !true; | ^^^^^ help: try: `false` @@ -8,43 +8,43 @@ LL | let _ = !true; = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:21:13 + --> tests/ui/nonminimal_bool.rs:21:13 | LL | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:23:13 + --> tests/ui/nonminimal_bool.rs:23:13 | LL | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:25:13 + --> tests/ui/nonminimal_bool.rs:25:13 | LL | let _ = false || a; | ^^^^^^^^^^ help: try: `a` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:30:13 + --> tests/ui/nonminimal_bool.rs:30:13 | LL | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `a || !b` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:32:13 + --> tests/ui/nonminimal_bool.rs:32:13 | LL | let _ = !(!a || b); | ^^^^^^^^^^ help: try: `a && !b` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:34:13 + --> tests/ui/nonminimal_bool.rs:34:13 | LL | let _ = !a && !(b && c); | ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:43:13 + --> tests/ui/nonminimal_bool.rs:43:13 | LL | let _ = a == b && c == 5 && a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:45:13 + --> tests/ui/nonminimal_bool.rs:45:13 | LL | let _ = a == b || c == 5 || a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | let _ = a == b || c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:47:13 + --> tests/ui/nonminimal_bool.rs:47:13 | LL | let _ = a == b && c == 5 && b == a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:49:13 + --> tests/ui/nonminimal_bool.rs:49:13 | LL | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL | let _ = a != b || c != d; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:51:13 + --> tests/ui/nonminimal_bool.rs:51:13 | LL | let _ = a != b && !(a != b && c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,10 +109,109 @@ LL | let _ = a != b && c != d; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool.rs:82:8 + --> tests/ui/nonminimal_bool.rs:82:8 | LL | if matches!(true, true) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)` -error: aborting due to 13 previous errors +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:162:8 + | +LL | if !(12 == a) {} + | ^^^^^^^^^^ help: try: `12 != a` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:163:8 + | +LL | if !(a == 12) {} + | ^^^^^^^^^^ help: try: `a != 12` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:164:8 + | +LL | if !(12 != a) {} + | ^^^^^^^^^^ help: try: `12 == a` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:165:8 + | +LL | if !(a != 12) {} + | ^^^^^^^^^^ help: try: `a == 12` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:169:8 + | +LL | if !b == true {} + | ^^^^^^^^^^ help: try: `b != true` + +error: this comparison might be written more concisely + --> tests/ui/nonminimal_bool.rs:169:8 + | +LL | if !b == true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `b != true` + | + = note: `-D clippy::bool-comparison` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` + +error: equality checks against true are unnecessary + --> tests/ui/nonminimal_bool.rs:169:8 + | +LL | if !b == true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!b` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:170:8 + | +LL | if !b != true {} + | ^^^^^^^^^^ help: try: `b == true` + +error: inequality checks against true can be replaced by a negation + --> tests/ui/nonminimal_bool.rs:170:8 + | +LL | if !b != true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:171:8 + | +LL | if true == !b {} + | ^^^^^^^^^^ help: try: `true != b` + +error: this comparison might be written more concisely + --> tests/ui/nonminimal_bool.rs:171:8 + | +LL | if true == !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `true != b` + +error: equality checks against true are unnecessary + --> tests/ui/nonminimal_bool.rs:171:8 + | +LL | if true == !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!b` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:172:8 + | +LL | if true != !b {} + | ^^^^^^^^^^ help: try: `true == b` + +error: inequality checks against true can be replaced by a negation + --> tests/ui/nonminimal_bool.rs:172:8 + | +LL | if true != !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:173:8 + | +LL | if !b == !c {} + | ^^^^^^^^ help: try: `b == c` + +error: this boolean expression can be simplified + --> tests/ui/nonminimal_bool.rs:174:8 + | +LL | if !b != !c {} + | ^^^^^^^^ help: try: `b != c` + +error: aborting due to 29 previous errors diff --git a/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr b/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr index d47bbf7e0799a..ede88ba529cdc 100644 --- a/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr +++ b/src/tools/clippy/tests/ui/nonminimal_bool_methods.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:8:13 + --> tests/ui/nonminimal_bool_methods.rs:8:13 | LL | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` @@ -8,73 +8,73 @@ LL | let _ = !a.is_some(); = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:10:13 + --> tests/ui/nonminimal_bool_methods.rs:10:13 | LL | let _ = !a.is_none(); | ^^^^^^^^^^^^ help: try: `a.is_some()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:12:13 + --> tests/ui/nonminimal_bool_methods.rs:12:13 | LL | let _ = !b.is_err(); | ^^^^^^^^^^^ help: try: `b.is_ok()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:14:13 + --> tests/ui/nonminimal_bool_methods.rs:14:13 | LL | let _ = !b.is_ok(); | ^^^^^^^^^^ help: try: `b.is_err()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:16:13 + --> tests/ui/nonminimal_bool_methods.rs:16:13 | LL | let _ = !(a.is_some() && !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() || c` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:17:13 + --> tests/ui/nonminimal_bool_methods.rs:17:13 | LL | let _ = !(a.is_some() || !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() && c` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:18:26 + --> tests/ui/nonminimal_bool_methods.rs:18:26 | LL | let _ = !(!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:19:25 + --> tests/ui/nonminimal_bool_methods.rs:19:25 | LL | let _ = (!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:20:23 + --> tests/ui/nonminimal_bool_methods.rs:20:23 | LL | let _ = !c ^ c || !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:92:8 + --> tests/ui/nonminimal_bool_methods.rs:92:8 | LL | if !res.is_ok() {} | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:93:8 + --> tests/ui/nonminimal_bool_methods.rs:93:8 | LL | if !res.is_err() {} | ^^^^^^^^^^^^^ help: try: `res.is_ok()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:96:8 + --> tests/ui/nonminimal_bool_methods.rs:96:8 | LL | if !res.is_some() {} | ^^^^^^^^^^^^^^ help: try: `res.is_none()` error: this boolean expression can be simplified - --> $DIR/nonminimal_bool_methods.rs:97:8 + --> tests/ui/nonminimal_bool_methods.rs:97:8 | LL | if !res.is_none() {} | ^^^^^^^^^^^^^^ help: try: `res.is_some()` diff --git a/src/tools/clippy/tests/ui/numbered_fields.stderr b/src/tools/clippy/tests/ui/numbered_fields.stderr index 76f5e082f326c..96426cab1e623 100644 --- a/src/tools/clippy/tests/ui/numbered_fields.stderr +++ b/src/tools/clippy/tests/ui/numbered_fields.stderr @@ -1,5 +1,5 @@ error: used a field initializer for a tuple struct - --> $DIR/numbered_fields.rs:17:13 + --> tests/ui/numbered_fields.rs:17:13 | LL | let _ = TupleStruct { | _____________^ @@ -13,7 +13,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::init_numbered_fields)]` error: used a field initializer for a tuple struct - --> $DIR/numbered_fields.rs:24:13 + --> tests/ui/numbered_fields.rs:24:13 | LL | let _ = TupleStruct { | _____________^ diff --git a/src/tools/clippy/tests/ui/obfuscated_if_else.stderr b/src/tools/clippy/tests/ui/obfuscated_if_else.stderr index abf5adce44466..d4c2f9b331a82 100644 --- a/src/tools/clippy/tests/ui/obfuscated_if_else.stderr +++ b/src/tools/clippy/tests/ui/obfuscated_if_else.stderr @@ -1,5 +1,5 @@ error: use of `.then_some(..).unwrap_or(..)` can be written more clearly with `if .. else ..` - --> $DIR/obfuscated_if_else.rs:4:5 + --> tests/ui/obfuscated_if_else.rs:4:5 | LL | true.then_some("a").unwrap_or("b"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }` diff --git a/src/tools/clippy/tests/ui/octal_escapes.stderr b/src/tools/clippy/tests/ui/octal_escapes.stderr index d2161582b827d..7ed9ee3ae2f4f 100644 --- a/src/tools/clippy/tests/ui/octal_escapes.stderr +++ b/src/tools/clippy/tests/ui/octal_escapes.stderr @@ -1,5 +1,5 @@ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:5:17 + --> tests/ui/octal_escapes.rs:5:17 | LL | let _bad1 = "\033[0m"; | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _bad1 = "\x0033[0m"; | ~~~~~~~~~~~ error: octal-looking escape in byte string literal - --> $DIR/octal_escapes.rs:7:17 + --> tests/ui/octal_escapes.rs:7:17 | LL | let _bad2 = b"\033[0m"; | ^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _bad2 = b"\x0033[0m"; | ~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:9:17 + --> tests/ui/octal_escapes.rs:9:17 | LL | let _bad3 = "\\\033[0m"; | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _bad3 = "\\\x0033[0m"; | ~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:12:17 + --> tests/ui/octal_escapes.rs:12:17 | LL | let _bad4 = "\01234567"; | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _bad4 = "\x001234567"; | ~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:14:17 + --> tests/ui/octal_escapes.rs:14:17 | LL | let _bad5 = "\0\03"; | ^^^^^^^ @@ -81,7 +81,7 @@ LL | let _bad5 = "\0\x003"; | ~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:16:17 + --> tests/ui/octal_escapes.rs:16:17 | LL | let _bad6 = "Text-\055\077-MoreText"; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _bad6 = "Text-\x0055\x0077-MoreText"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:18:17 + --> tests/ui/octal_escapes.rs:18:17 | LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | let _bad7 = "EvenMoreText-\x001\x002-ShortEscapes"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:20:17 + --> tests/ui/octal_escapes.rs:20:17 | LL | let _bad8 = "锈\01锈"; | ^^^^^^^^^ @@ -129,7 +129,7 @@ LL | let _bad8 = "锈\x001锈"; | ~~~~~~~~~~~ error: octal-looking escape in string literal - --> $DIR/octal_escapes.rs:22:17 + --> tests/ui/octal_escapes.rs:22:17 | LL | let _bad9 = "锈\011锈"; | ^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/ok_expect.stderr b/src/tools/clippy/tests/ui/ok_expect.stderr index ac2b6dcc83b52..2fd4f007d06d9 100644 --- a/src/tools/clippy/tests/ui/ok_expect.stderr +++ b/src/tools/clippy/tests/ui/ok_expect.stderr @@ -1,5 +1,5 @@ error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:16:5 + --> tests/ui/ok_expect.rs:16:5 | LL | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | res.ok().expect("disaster!"); = help: to override `-D warnings` add `#[allow(clippy::ok_expect)]` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:23:5 + --> tests/ui/ok_expect.rs:23:5 | LL | res3.ok().expect("whoof"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | res3.ok().expect("whoof"); = help: you can call `expect()` directly on the `Result` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:26:5 + --> tests/ui/ok_expect.rs:26:5 | LL | res4.ok().expect("argh"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | res4.ok().expect("argh"); = help: you can call `expect()` directly on the `Result` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:29:5 + --> tests/ui/ok_expect.rs:29:5 | LL | res5.ok().expect("oops"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | res5.ok().expect("oops"); = help: you can call `expect()` directly on the `Result` error: called `ok().expect()` on a `Result` value - --> $DIR/ok_expect.rs:32:5 + --> tests/ui/ok_expect.rs:32:5 | LL | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ 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 85eee99c01c59..a3aee2697f380 100644 --- a/src/tools/clippy/tests/ui/only_used_in_recursion.stderr +++ b/src/tools/clippy/tests/ui/only_used_in_recursion.stderr @@ -1,11 +1,11 @@ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:11:27 + --> tests/ui/only_used_in_recursion.rs:11:27 | LL | fn _one_unused(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:13:53 + --> tests/ui/only_used_in_recursion.rs:13:53 | LL | if flag == 0 { 0 } else { _one_unused(flag - 1, a) } | ^ @@ -13,181 +13,181 @@ LL | if flag == 0 { 0 } else { _one_unused(flag - 1, a) } = 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 + --> tests/ui/only_used_in_recursion.rs:16:27 | LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:19:53 + --> tests/ui/only_used_in_recursion.rs:19:53 | LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:16:35 + --> tests/ui/only_used_in_recursion.rs:16:35 | LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:19:56 + --> tests/ui/only_used_in_recursion.rs:19:56 | LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:22:26 + --> tests/ui/only_used_in_recursion.rs:22:26 | LL | fn _with_calc(flag: u32, a: i64) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:27:32 + --> tests/ui/only_used_in_recursion.rs:27:32 | LL | _with_calc(flag - 1, (-a + 10) * 5) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:36:33 + --> tests/ui/only_used_in_recursion.rs:36:33 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:42:38 + --> tests/ui/only_used_in_recursion.rs:42:38 | LL | _used_with_unused(flag - 1, -a, a + b) | ^ ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:36:41 + --> tests/ui/only_used_in_recursion.rs:36:41 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:42:45 + --> tests/ui/only_used_in_recursion.rs:42:45 | LL | _used_with_unused(flag - 1, -a, a + b) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:46:35 + --> tests/ui/only_used_in_recursion.rs:46:35 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:52:39 + --> tests/ui/only_used_in_recursion.rs:52:39 | LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:46:43 + --> tests/ui/only_used_in_recursion.rs:46:43 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:52:43 + --> tests/ui/only_used_in_recursion.rs:52:43 | LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:56:30 + --> tests/ui/only_used_in_recursion.rs:56:30 | LL | fn _not_primitive(flag: u32, b: String) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:58:56 + --> tests/ui/only_used_in_recursion.rs:58:56 | LL | if flag == 0 { 0 } else { _not_primitive(flag - 1, b) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:64:29 + --> tests/ui/only_used_in_recursion.rs:64:29 | LL | fn _method(flag: usize, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:66:59 + --> tests/ui/only_used_in_recursion.rs:66:59 | LL | if flag == 0 { 0 } else { Self::_method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:69:22 + --> tests/ui/only_used_in_recursion.rs:69:22 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { | ^^^^ | note: parameter used here - --> $DIR/only_used_in_recursion.rs:72:35 + --> tests/ui/only_used_in_recursion.rs:72:35 | LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^^^^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:69:41 + --> tests/ui/only_used_in_recursion.rs:69:41 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:72:63 + --> tests/ui/only_used_in_recursion.rs:72:63 | LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:82:26 + --> tests/ui/only_used_in_recursion.rs:82:26 | LL | fn method(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:84:58 + --> tests/ui/only_used_in_recursion.rs:84:58 | LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:87:38 + --> tests/ui/only_used_in_recursion.rs:87:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:89:62 + --> tests/ui/only_used_in_recursion.rs:89:62 | LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:114:26 + --> tests/ui/only_used_in_recursion.rs:114:26 | LL | fn method(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:116:58 + --> tests/ui/only_used_in_recursion.rs:116:58 | LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion.rs:119:38 + --> tests/ui/only_used_in_recursion.rs:119:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion.rs:121:62 + --> tests/ui/only_used_in_recursion.rs:121:62 | LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ 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 3ddd9758c26fd..e39460c7e8f3e 100644 --- a/src/tools/clippy/tests/ui/only_used_in_recursion2.stderr +++ b/src/tools/clippy/tests/ui/only_used_in_recursion2.stderr @@ -1,11 +1,11 @@ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:3:35 + --> tests/ui/only_used_in_recursion2.rs:3:35 | LL | fn _with_inner(flag: u32, a: u32, b: u32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:11:52 + --> tests/ui/only_used_in_recursion2.rs:11:52 | LL | if flag == 0 { 0 } else { _with_inner(flag, a, b + x) } | ^ @@ -13,49 +13,49 @@ LL | if flag == 0 { 0 } else { _with_inner(flag, a, b + x) } = 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 + --> tests/ui/only_used_in_recursion2.rs:5:25 | LL | fn inner(flag: u32, a: u32) -> u32 { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:7:47 + --> tests/ui/only_used_in_recursion2.rs:7:47 | LL | if flag == 0 { 0 } else { inner(flag, a) } | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:14:34 + --> tests/ui/only_used_in_recursion2.rs:14:34 | LL | fn _with_closure(a: Option, b: u32, f: impl Fn(u32, u32) -> Option) -> u32 { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:17:32 + --> tests/ui/only_used_in_recursion2.rs:17:32 | LL | _with_closure(Some(x), b, f) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:65:37 + --> tests/ui/only_used_in_recursion2.rs:65:37 | LL | fn overwritten_param(flag: u32, mut a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:74:29 + --> tests/ui/only_used_in_recursion2.rs:74:29 | LL | overwritten_param(flag, a) | ^ error: parameter is only used in recursion - --> $DIR/only_used_in_recursion2.rs:77:32 + --> tests/ui/only_used_in_recursion2.rs:77:32 | LL | fn field_direct(flag: u32, mut a: (usize,)) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> $DIR/only_used_in_recursion2.rs:83:32 + --> tests/ui/only_used_in_recursion2.rs:83:32 | LL | field_direct(flag - 1, a) | ^ diff --git a/src/tools/clippy/tests/ui/op_ref.stderr b/src/tools/clippy/tests/ui/op_ref.stderr index f03e24b840054..c5b68730a8f26 100644 --- a/src/tools/clippy/tests/ui/op_ref.stderr +++ b/src/tools/clippy/tests/ui/op_ref.stderr @@ -1,5 +1,5 @@ error: needlessly taken reference of both operands - --> $DIR/op_ref.rs:11:15 + --> tests/ui/op_ref.rs:11:15 | LL | let foo = &5 - &6; | ^^^^^^^ @@ -12,7 +12,7 @@ LL | let foo = 5 - 6; | ~ ~ error: taken reference of right operand - --> $DIR/op_ref.rs:58:13 + --> tests/ui/op_ref.rs:58:13 | LL | let z = x & &y; | ^^^^-- @@ -20,7 +20,7 @@ LL | let z = x & &y; | help: use the right value directly: `y` error: taken reference of right operand - --> $DIR/op_ref.rs:92:17 + --> tests/ui/op_ref.rs:92:17 | LL | let _ = one * &self; | ^^^^^^----- @@ -28,7 +28,7 @@ LL | let _ = one * &self; | help: use the right value directly: `self` error: taken reference of right operand - --> $DIR/op_ref.rs:94:17 + --> tests/ui/op_ref.rs:94:17 | LL | let _ = two + &three; | ^^^^^^------ diff --git a/src/tools/clippy/tests/ui/open_options.stderr b/src/tools/clippy/tests/ui/open_options.stderr index 4f84d1d09f984..19755bce46c86 100644 --- a/src/tools/clippy/tests/ui/open_options.stderr +++ b/src/tools/clippy/tests/ui/open_options.stderr @@ -1,5 +1,5 @@ error: file opened with `truncate` and `read` - --> $DIR/open_options.rs:17:5 + --> tests/ui/open_options.rs:17:5 | LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,43 +8,43 @@ LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); = help: to override `-D warnings` add `#[allow(clippy::nonsensical_open_options)]` error: file opened with `append` and `truncate` - --> $DIR/open_options.rs:20:5 + --> tests/ui/open_options.rs:20:5 | LL | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method `read` is called more than once - --> $DIR/open_options.rs:23:35 + --> tests/ui/open_options.rs:23:35 | LL | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^ error: the method `create` is called more than once - --> $DIR/open_options.rs:28:10 + --> tests/ui/open_options.rs:28:10 | LL | .create(false) | ^^^^^^^^^^^^^ error: the method `write` is called more than once - --> $DIR/open_options.rs:31:36 + --> tests/ui/open_options.rs:31:36 | LL | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^ error: the method `append` is called more than once - --> $DIR/open_options.rs:33:37 + --> tests/ui/open_options.rs:33:37 | LL | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^ error: the method `truncate` is called more than once - --> $DIR/open_options.rs:35:39 + --> tests/ui/open_options.rs:35:39 | LL | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^ error: the method `read` is called more than once - --> $DIR/open_options.rs:38:41 + --> tests/ui/open_options.rs:38:41 | LL | std::fs::File::options().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/open_options_fixable.stderr b/src/tools/clippy/tests/ui/open_options_fixable.stderr index e327661713bfb..fc54320fc07d3 100644 --- a/src/tools/clippy/tests/ui/open_options_fixable.stderr +++ b/src/tools/clippy/tests/ui/open_options_fixable.stderr @@ -1,5 +1,5 @@ error: file opened with `create`, but `truncate` behavior not defined - --> $DIR/open_options_fixable.rs:5:24 + --> tests/ui/open_options_fixable.rs:5:24 | LL | OpenOptions::new().create(true).open("foo.txt"); | ^^^^^^^^^^^^- help: add: `.truncate(true)` diff --git a/src/tools/clippy/tests/ui/option_as_ref_cloned.stderr b/src/tools/clippy/tests/ui/option_as_ref_cloned.stderr index ea03da3b69fab..5892f2bdec56e 100644 --- a/src/tools/clippy/tests/ui/option_as_ref_cloned.stderr +++ b/src/tools/clippy/tests/ui/option_as_ref_cloned.stderr @@ -1,5 +1,5 @@ error: cloning an `Option<_>` using `.as_ref().cloned()` - --> $DIR/option_as_ref_cloned.rs:7:31 + --> tests/ui/option_as_ref_cloned.rs:7:31 | LL | let _: Option = x.as_ref().cloned(); | ^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | let _: Option = x.clone(); | ~~~~~ error: cloning an `Option<_>` using `.as_mut().cloned()` - --> $DIR/option_as_ref_cloned.rs:8:31 + --> tests/ui/option_as_ref_cloned.rs:8:31 | LL | let _: Option = x.as_mut().cloned(); | ^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _: Option = x.clone(); | ~~~~~ error: cloning an `Option<_>` using `.as_ref().cloned()` - --> $DIR/option_as_ref_cloned.rs:11:32 + --> tests/ui/option_as_ref_cloned.rs:11:32 | LL | let _: Option<&String> = y.as_ref().cloned(); | ^^^^^^^^^^^^^^^ 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 036b8c749e417..8b7f47a1b9af0 100644 --- a/src/tools/clippy/tests/ui/option_as_ref_deref.stderr +++ b/src/tools/clippy/tests/ui/option_as_ref_deref.stderr @@ -1,5 +1,5 @@ error: called `.as_ref().map(Deref::deref)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:11:13 + --> tests/ui/option_as_ref_deref.rs:11:13 | LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.clone().as_deref()` @@ -8,7 +8,7 @@ LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len); = help: to override `-D warnings` add `#[allow(clippy::option_as_ref_deref)]` error: called `.as_ref().map(Deref::deref)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:14:13 + --> tests/ui/option_as_ref_deref.rs:14:13 | LL | let _ = opt.clone() | _____________^ @@ -18,97 +18,97 @@ LL | | ) | |_________^ help: consider using as_deref: `opt.clone().as_deref()` error: called `.as_mut().map(DerefMut::deref_mut)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:20:13 + --> tests/ui/option_as_ref_deref.rs:20:13 | LL | let _ = opt.as_mut().map(DerefMut::deref_mut); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_ref().map(String::as_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:22:13 + --> tests/ui/option_as_ref_deref.rs:22:13 | LL | let _ = opt.as_ref().map(String::as_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_ref().map(|x| x.as_str())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:23:13 + --> tests/ui/option_as_ref_deref.rs:23:13 | LL | let _ = opt.as_ref().map(|x| x.as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_mut().map(String::as_mut_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:24:13 + --> tests/ui/option_as_ref_deref.rs:24:13 | LL | let _ = opt.as_mut().map(String::as_mut_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_mut().map(|x| x.as_mut_str())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:25:13 + --> tests/ui/option_as_ref_deref.rs:25:13 | LL | let _ = opt.as_mut().map(|x| x.as_mut_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_ref().map(CString::as_c_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:26:13 + --> tests/ui/option_as_ref_deref.rs:26:13 | LL | let _ = Some(CString::new(vec![]).unwrap()).as_ref().map(CString::as_c_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(CString::new(vec![]).unwrap()).as_deref()` error: called `.as_ref().map(OsString::as_os_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:27:13 + --> tests/ui/option_as_ref_deref.rs:27:13 | LL | let _ = Some(OsString::new()).as_ref().map(OsString::as_os_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(OsString::new()).as_deref()` error: called `.as_ref().map(PathBuf::as_path)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:28:13 + --> tests/ui/option_as_ref_deref.rs:28:13 | LL | let _ = Some(PathBuf::new()).as_ref().map(PathBuf::as_path); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(PathBuf::new()).as_deref()` error: called `.as_ref().map(Vec::as_slice)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:29:13 + --> tests/ui/option_as_ref_deref.rs:29:13 | LL | let _ = Some(Vec::<()>::new()).as_ref().map(Vec::as_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `Some(Vec::<()>::new()).as_deref()` error: called `.as_mut().map(Vec::as_mut_slice)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:30:13 + --> tests/ui/option_as_ref_deref.rs:30:13 | LL | let _ = Some(Vec::<()>::new()).as_mut().map(Vec::as_mut_slice); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `Some(Vec::<()>::new()).as_deref_mut()` error: called `.as_ref().map(|x| x.deref())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:32:13 + --> tests/ui/option_as_ref_deref.rs:32:13 | LL | let _ = opt.as_ref().map(|x| x.deref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_mut().map(|x| x.deref_mut())` on an `Option` value - --> $DIR/option_as_ref_deref.rs:33:13 + --> tests/ui/option_as_ref_deref.rs:33:13 | LL | let _ = opt.clone().as_mut().map(|x| x.deref_mut()).map(|x| x.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.clone().as_deref_mut()` error: called `.as_ref().map(|x| &**x)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:40:13 + --> tests/ui/option_as_ref_deref.rs:40:13 | LL | let _ = opt.as_ref().map(|x| &**x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_mut().map(|x| &mut **x)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:41:13 + --> tests/ui/option_as_ref_deref.rs:41:13 | LL | let _ = opt.as_mut().map(|x| &mut **x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref_mut: `opt.as_deref_mut()` error: called `.as_ref().map(std::ops::Deref::deref)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:44:13 + --> tests/ui/option_as_ref_deref.rs:44:13 | LL | let _ = opt.as_ref().map(std::ops::Deref::deref); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` error: called `.as_ref().map(String::as_str)` on an `Option` value - --> $DIR/option_as_ref_deref.rs:56:13 + --> tests/ui/option_as_ref_deref.rs:56:13 | LL | let _ = opt.as_ref().map(String::as_str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using as_deref: `opt.as_deref()` diff --git a/src/tools/clippy/tests/ui/option_env_unwrap.stderr b/src/tools/clippy/tests/ui/option_env_unwrap.stderr index de31d0c7f095f..169523269fbb5 100644 --- a/src/tools/clippy/tests/ui/option_env_unwrap.stderr +++ b/src/tools/clippy/tests/ui/option_env_unwrap.stderr @@ -1,5 +1,5 @@ error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:10:13 + --> tests/ui/option_env_unwrap.rs:10:13 | LL | let _ = option_env!("PATH").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = option_env!("PATH").unwrap(); = 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 + --> tests/ui/option_env_unwrap.rs:11:13 | LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = option_env!("PATH").expect("environment variable PATH isn't set = help: consider using the `env!` macro instead error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:12:13 + --> tests/ui/option_env_unwrap.rs:12:13 | LL | let _ = option_env!("__Y__do_not_use").unwrap(); // This test only works if you don't have a __Y__do_not_use env variable in your env... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = option_env!("__Y__do_not_use").unwrap(); // This test only work = help: consider using the `env!` macro instead error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:13:21 + --> tests/ui/option_env_unwrap.rs:13:21 | LL | let _ = inline!(option_env!($"PATH").unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = inline!(option_env!($"PATH").unwrap()); = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:14:21 + --> tests/ui/option_env_unwrap.rs:14:21 | LL | let _ = inline!(option_env!($"PATH").expect($"environment variable PATH isn't set")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | let _ = inline!(option_env!($"PATH").expect($"environment variable PATH = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:15:13 + --> tests/ui/option_env_unwrap.rs:15:13 | LL | let _ = external!(option_env!($"PATH").unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = external!(option_env!($"PATH").unwrap()); = note: this error originates in the macro `external` (in Nightly builds, run with -Z macro-backtrace for more info) error: this will panic at run-time if the environment variable doesn't exist at compile-time - --> $DIR/option_env_unwrap.rs:16:13 + --> tests/ui/option_env_unwrap.rs:16:13 | LL | let _ = external!(option_env!($"PATH").expect($"environment variable PATH isn't set")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/option_filter_map.stderr b/src/tools/clippy/tests/ui/option_filter_map.stderr index 6a0fc10822bdf..401ac2b2296da 100644 --- a/src/tools/clippy/tests/ui/option_filter_map.stderr +++ b/src/tools/clippy/tests/ui/option_filter_map.stderr @@ -1,5 +1,5 @@ error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:5:27 + --> tests/ui/option_filter_map.rs:5:27 | LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` @@ -8,37 +8,37 @@ LL | let _ = Some(Some(1)).filter(Option::is_some).map(Option::unwrap); = help: to override `-D warnings` add `#[allow(clippy::option_filter_map)]` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:7:27 + --> tests/ui/option_filter_map.rs:7:27 | LL | let _ = Some(Some(1)).filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:9:35 + --> tests/ui/option_filter_map.rs:9:35 | LL | let _ = Some(1).map(odds_out).filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:11:35 + --> tests/ui/option_filter_map.rs:11:35 | LL | let _ = Some(1).map(odds_out).filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:14:39 + --> tests/ui/option_filter_map.rs:14:39 | LL | let _ = vec![Some(1)].into_iter().filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:16:39 + --> tests/ui/option_filter_map.rs:16:39 | LL | let _ = vec![Some(1)].into_iter().filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:21:10 + --> tests/ui/option_filter_map.rs:21:10 | LL | .filter(Option::is_some) | __________^ @@ -47,7 +47,7 @@ LL | | .map(Option::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> $DIR/option_filter_map.rs:27:10 + --> tests/ui/option_filter_map.rs:27:10 | LL | .filter(|o| o.is_some()) | __________^ 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 e053d356ff24e..a794dca762f17 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.stderr +++ b/src/tools/clippy/tests/ui/option_if_let_else.stderr @@ -1,5 +1,5 @@ error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:10:5 + --> tests/ui/option_if_let_else.rs:10:5 | LL | / if let Some(x) = string { LL | | (true, x) @@ -12,19 +12,19 @@ LL | | } = 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:28:13 + --> tests/ui/option_if_let_else.rs:28:13 | LL | let _ = if let Some(s) = *string { s.len() } else { 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:29:13 + --> tests/ui/option_if_let_else.rs:29:13 | LL | let _ = if let Some(s) = &num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:30:13 + --> tests/ui/option_if_let_else.rs:30:13 | LL | let _ = if let Some(s) = &mut num { | _____________^ @@ -44,13 +44,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:36:13 + --> tests/ui/option_if_let_else.rs:36:13 | LL | let _ = if let Some(ref s) = num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:37:13 + --> tests/ui/option_if_let_else.rs:37:13 | LL | let _ = if let Some(mut s) = num { | _____________^ @@ -70,7 +70,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:43:13 + --> tests/ui/option_if_let_else.rs:43:13 | LL | let _ = if let Some(ref mut s) = num { | _____________^ @@ -90,7 +90,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:52:5 + --> tests/ui/option_if_let_else.rs:52:5 | LL | / if let Some(x) = arg { LL | | let y = x * x; @@ -109,7 +109,7 @@ LL + }) | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:65:13 + --> tests/ui/option_if_let_else.rs:65:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -121,7 +121,7 @@ LL | | }; | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:74:13 + --> tests/ui/option_if_let_else.rs:74:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x); | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:107:13 + --> tests/ui/option_if_let_else.rs:107:13 | LL | / if let Some(idx) = s.find('.') { LL | | vec![s[..idx].to_string(), s[idx..].to_string()] @@ -154,7 +154,7 @@ LL | | } | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:118:5 + --> tests/ui/option_if_let_else.rs:118:5 | LL | / if let Ok(binding) = variable { LL | | println!("Ok {binding}"); @@ -177,13 +177,13 @@ LL + }) | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:142:13 + --> tests/ui/option_if_let_else.rs:142:13 | LL | let _ = if let Some(x) = optional { x + 2 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:152:13 + --> tests/ui/option_if_let_else.rs:152:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -205,13 +205,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:180:13 + --> tests/ui/option_if_let_else.rs:180:13 | LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:184:13 + --> tests/ui/option_if_let_else.rs:184:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -231,7 +231,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:223:13 + --> tests/ui/option_if_let_else.rs:223:13 | LL | let _ = match s { | _____________^ @@ -241,7 +241,7 @@ LL | | }; | |_____^ help: try: `s.map_or(1, |string| string.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:227:13 + --> tests/ui/option_if_let_else.rs:227:13 | LL | let _ = match Some(10) { | _____________^ @@ -251,7 +251,7 @@ LL | | }; | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:233:13 + --> tests/ui/option_if_let_else.rs:233:13 | LL | let _ = match res { | _____________^ @@ -261,7 +261,7 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:237:13 + --> tests/ui/option_if_let_else.rs:237:13 | LL | let _ = match res { | _____________^ @@ -271,13 +271,13 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:241:13 + --> tests/ui/option_if_let_else.rs:241:13 | LL | let _ = if let Ok(a) = res { a + 1 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:258:17 + --> tests/ui/option_if_let_else.rs:258:17 | LL | let _ = match initial { | _________________^ @@ -287,7 +287,7 @@ LL | | }; | |_________^ help: try: `initial.as_ref().map_or(42, |value| do_something(value))` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:265:17 + --> tests/ui/option_if_let_else.rs:265:17 | LL | let _ = match initial { | _________________^ @@ -297,7 +297,7 @@ LL | | }; | |_________^ help: try: `initial.as_mut().map_or(42, |value| do_something2(value))` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:288:24 + --> tests/ui/option_if_let_else.rs:288:24 | LL | let mut _hashmap = if let Some(hm) = &opt { | ________________________^ @@ -308,7 +308,7 @@ LL | | }; | |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:294:19 + --> tests/ui/option_if_let_else.rs:294:19 | LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())` diff --git a/src/tools/clippy/tests/ui/option_map_or_err_ok.stderr b/src/tools/clippy/tests/ui/option_map_or_err_ok.stderr index 381601cb6b3aa..1971af80aa8d4 100644 --- a/src/tools/clippy/tests/ui/option_map_or_err_ok.stderr +++ b/src/tools/clippy/tests/ui/option_map_or_err_ok.stderr @@ -1,5 +1,5 @@ error: called `map_or(Err(_), Ok)` on an `Option` value - --> $DIR/option_map_or_err_ok.rs:5:13 + --> tests/ui/option_map_or_err_ok.rs:5:13 | LL | let _ = x.map_or(Err("a"), Ok); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok_or`: `x.ok_or("a")` 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 d58ff83c3da27..cba29861296f3 100644 --- a/src/tools/clippy/tests/ui/option_map_or_none.stderr +++ b/src/tools/clippy/tests/ui/option_map_or_none.stderr @@ -1,5 +1,5 @@ error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:10:26 + --> tests/ui/option_map_or_none.rs:10:26 | LL | let _: Option = opt.map_or(None, |x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `map`: `opt.map(|x| x + 1)` @@ -8,7 +8,7 @@ LL | let _: Option = opt.map_or(None, |x| Some(x + 1)); = help: to override `-D warnings` add `#[allow(clippy::option_map_or_none)]` error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:13:26 + --> tests/ui/option_map_or_none.rs:13:26 | LL | let _: Option = opt.map_or(None, |x| { | __________________________^ @@ -17,13 +17,13 @@ LL | | }); | |_________________________^ help: consider using `map`: `opt.map(|x| x + 1)` error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:17:26 + --> tests/ui/option_map_or_none.rs:17:26 | LL | let _: Option = opt.map_or(None, bar); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `and_then`: `opt.and_then(bar)` error: called `map_or(None, ..)` on an `Option` value - --> $DIR/option_map_or_none.rs:18:26 + --> tests/ui/option_map_or_none.rs:18:26 | LL | let _: Option = opt.map_or(None, |x| { | __________________________^ @@ -43,7 +43,7 @@ LL ~ }); | error: called `map_or(None, Some)` on a `Result` value - --> $DIR/option_map_or_none.rs:25:26 + --> tests/ui/option_map_or_none.rs:25:26 | LL | let _: Option = r.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `r.ok()` 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 34aca31e95c97..5fd3dfd071c2f 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 @@ -1,5 +1,5 @@ error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:37:5 + --> tests/ui/option_map_unit_fn_fixable.rs:37:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -10,7 +10,7 @@ LL | x.field.map(do_nothing); = 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 + --> tests/ui/option_map_unit_fn_fixable.rs:39:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -18,7 +18,7 @@ LL | x.field.map(do_nothing); | help: try: `if let Some(x_field) = x.field { do_nothing(x_field) }` error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:41:5 + --> tests/ui/option_map_unit_fn_fixable.rs:41:5 | LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- @@ -26,7 +26,7 @@ LL | x.field.map(diverge); | help: try: `if let Some(x_field) = x.field { diverge(x_field) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:47:5 + --> tests/ui/option_map_unit_fn_fixable.rs:47:5 | LL | x.field.map(|value| x.do_option_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -34,7 +34,7 @@ LL | x.field.map(|value| x.do_option_nothing(value + captured)); | help: try: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:49:5 + --> tests/ui/option_map_unit_fn_fixable.rs:49:5 | LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -42,7 +42,7 @@ LL | x.field.map(|value| { x.do_option_plus_one(value + captured); }); | help: try: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:52:5 + --> tests/ui/option_map_unit_fn_fixable.rs:52:5 | LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -50,7 +50,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | help: try: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:54:5 + --> tests/ui/option_map_unit_fn_fixable.rs:54:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -58,7 +58,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | help: try: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:56:5 + --> tests/ui/option_map_unit_fn_fixable.rs:56:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -66,7 +66,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | help: try: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:58:5 + --> tests/ui/option_map_unit_fn_fixable.rs:58:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -74,7 +74,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | help: try: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:61:5 + --> tests/ui/option_map_unit_fn_fixable.rs:61:5 | LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -82,7 +82,7 @@ LL | x.field.map(|value| diverge(value + captured)); | help: try: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:63:5 + --> tests/ui/option_map_unit_fn_fixable.rs:63:5 | LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -90,7 +90,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | help: try: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:65:5 + --> tests/ui/option_map_unit_fn_fixable.rs:65:5 | LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -98,7 +98,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | help: try: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:67:5 + --> tests/ui/option_map_unit_fn_fixable.rs:67:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -106,7 +106,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | help: try: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:72:5 + --> tests/ui/option_map_unit_fn_fixable.rs:72:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -114,7 +114,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | help: try: `if let Some(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:74:5 + --> tests/ui/option_map_unit_fn_fixable.rs:74:5 | LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -122,7 +122,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | help: try: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:76:5 + --> tests/ui/option_map_unit_fn_fixable.rs:76:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -130,7 +130,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | help: try: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:79:5 + --> tests/ui/option_map_unit_fn_fixable.rs:79:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -138,7 +138,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | help: try: `if let Some(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:81:5 + --> tests/ui/option_map_unit_fn_fixable.rs:81:5 | LL | option().map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^^- @@ -146,7 +146,7 @@ LL | option().map(do_nothing); | help: try: `if let Some(a) = option() { do_nothing(a) }` error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()` - --> $DIR/option_map_unit_fn_fixable.rs:83:5 + --> tests/ui/option_map_unit_fn_fixable.rs:83:5 | LL | option().map(|value| println!("{:?}", value)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- diff --git a/src/tools/clippy/tests/ui/option_map_unit_fn_unfixable.stderr b/src/tools/clippy/tests/ui/option_map_unit_fn_unfixable.stderr index a53f5889c58da..66271036113ca 100644 --- a/src/tools/clippy/tests/ui/option_map_unit_fn_unfixable.stderr +++ b/src/tools/clippy/tests/ui/option_map_unit_fn_unfixable.stderr @@ -1,23 +1,23 @@ error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:17:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:17:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:19:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:19:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:23:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:23:5 | LL | x.field.map(|value| { | ^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/option_map_unit_fn_unfixable.rs:27:5 + --> tests/ui/option_map_unit_fn_unfixable.rs:27:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^ not found in this scope diff --git a/src/tools/clippy/tests/ui/option_option.stderr b/src/tools/clippy/tests/ui/option_option.stderr index fcae9655dbf7f..0cd048e400e40 100644 --- a/src/tools/clippy/tests/ui/option_option.stderr +++ b/src/tools/clippy/tests/ui/option_option.stderr @@ -1,77 +1,77 @@ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:4:10 + --> tests/ui/option_option.rs:4:10 | LL | const C: Option> = None; | ^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/option_option.rs:1:9 + --> tests/ui/option_option.rs:1:9 | LL | #![deny(clippy::option_option)] | ^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:6:11 + --> tests/ui/option_option.rs:6:11 | LL | static S: Option> = None; | ^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:9:13 + --> tests/ui/option_option.rs:9:13 | LL | fn input(_: Option>) {} | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:12:16 + --> tests/ui/option_option.rs:12:16 | LL | fn output() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:17:27 + --> tests/ui/option_option.rs:17:27 | LL | fn output_nested() -> Vec>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:23:30 + --> tests/ui/option_option.rs:23:30 | LL | fn output_nested_nested() -> Option>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:29:8 + --> tests/ui/option_option.rs:29:8 | LL | x: Option>, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:34:23 + --> tests/ui/option_option.rs:34:23 | LL | fn struct_fn() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:41:22 + --> tests/ui/option_option.rs:41:22 | LL | fn trait_fn() -> Option>; | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:46:11 + --> tests/ui/option_option.rs:46:11 | LL | Tuple(Option>), | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:48:17 + --> tests/ui/option_option.rs:48:17 | LL | Struct { x: Option> }, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:90:14 + --> tests/ui/option_option.rs:90:14 | LL | foo: Option>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/or_fun_call.stderr b/src/tools/clippy/tests/ui/or_fun_call.stderr index afa4b7628112d..b5a30f2992316 100644 --- a/src/tools/clippy/tests/ui/or_fun_call.stderr +++ b/src/tools/clippy/tests/ui/or_fun_call.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:52:22 + --> tests/ui/or_fun_call.rs:52:22 | LL | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(make)` @@ -8,7 +8,7 @@ LL | with_constructor.unwrap_or(make()); = 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 + --> tests/ui/or_fun_call.rs:55:14 | LL | with_new.unwrap_or(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` @@ -17,175 +17,175 @@ LL | with_new.unwrap_or(Vec::new()); = 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 + --> tests/ui/or_fun_call.rs:58:21 | LL | with_const_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| Vec::with_capacity(12))` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:61:14 + --> tests/ui/or_fun_call.rs:61:14 | LL | with_err.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| make())` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:64:19 + --> tests/ui/or_fun_call.rs:64:19 | LL | with_err_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| Vec::with_capacity(12))` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:67:24 + --> tests/ui/or_fun_call.rs:67:24 | LL | with_default_trait.unwrap_or(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:70:23 + --> tests/ui/or_fun_call.rs:70:23 | LL | with_default_type.unwrap_or(u64::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:73:18 + --> tests/ui/or_fun_call.rs:73:18 | LL | self_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(::default)` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:76:18 + --> tests/ui/or_fun_call.rs:76:18 | LL | real_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:79:14 + --> tests/ui/or_fun_call.rs:79:14 | LL | with_vec.unwrap_or(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:82:21 + --> tests/ui/or_fun_call.rs:82:21 | LL | without_default.unwrap_or(Foo::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(Foo::new)` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:85:19 + --> tests/ui/or_fun_call.rs:85:19 | LL | map.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:88:23 + --> tests/ui/or_fun_call.rs:88:23 | LL | map_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:91:21 + --> tests/ui/or_fun_call.rs:91:21 | LL | btree.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` to construct default value - --> $DIR/or_fun_call.rs:94:25 + --> tests/ui/or_fun_call.rs:94:25 | LL | btree_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `unwrap_or` to construct default value - --> $DIR/or_fun_call.rs:97:21 + --> tests/ui/or_fun_call.rs:97:21 | LL | let _ = stringy.unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:105:21 + --> tests/ui/or_fun_call.rs:105:21 | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| map[&1])` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:107:21 + --> tests/ui/or_fun_call.rs:107:21 | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| map[&1])` error: use of `or` followed by a function call - --> $DIR/or_fun_call.rs:131:35 + --> tests/ui/or_fun_call.rs:131:35 | LL | let _ = Some("a".to_string()).or(Some("b".to_string())); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_else(|| Some("b".to_string()))` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:170:14 + --> tests/ui/or_fun_call.rs:170:14 | LL | None.unwrap_or(ptr_to_ref(s)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| ptr_to_ref(s))` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:176:14 + --> tests/ui/or_fun_call.rs:176:14 | LL | None.unwrap_or(unsafe { ptr_to_ref(s) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` error: use of `unwrap_or` followed by a function call - --> $DIR/or_fun_call.rs:178:14 + --> tests/ui/or_fun_call.rs:178:14 | LL | None.unwrap_or( unsafe { ptr_to_ref(s) } ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` error: use of `map_or` followed by a function call - --> $DIR/or_fun_call.rs:253:25 + --> tests/ui/or_fun_call.rs:253:25 | LL | let _ = Some(4).map_or(g(), |v| v); | ^^^^^^^^^^^^^^^^^^ help: try: `map_or_else(g, |v| v)` error: use of `map_or` followed by a function call - --> $DIR/or_fun_call.rs:254:25 + --> tests/ui/or_fun_call.rs:254:25 | LL | let _ = Some(4).map_or(g(), f); | ^^^^^^^^^^^^^^ help: try: `map_or_else(g, f)` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:285:18 + --> tests/ui/or_fun_call.rs:285:18 | LL | with_new.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:288:28 + --> tests/ui/or_fun_call.rs:288:28 | LL | with_default_trait.unwrap_or_else(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:291:27 + --> tests/ui/or_fun_call.rs:291:27 | LL | with_default_type.unwrap_or_else(u64::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:294:22 + --> tests/ui/or_fun_call.rs:294:22 | LL | real_default.unwrap_or_else(::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `or_insert_with` to construct default value - --> $DIR/or_fun_call.rs:297:23 + --> tests/ui/or_fun_call.rs:297:23 | LL | map.entry(42).or_insert_with(String::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert_with` to construct default value - --> $DIR/or_fun_call.rs:300:25 + --> tests/ui/or_fun_call.rs:300:25 | LL | btree.entry(42).or_insert_with(String::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/or_fun_call.rs:303:25 + --> tests/ui/or_fun_call.rs:303:25 | LL | let _ = stringy.unwrap_or_else(String::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` diff --git a/src/tools/clippy/tests/ui/or_then_unwrap.stderr b/src/tools/clippy/tests/ui/or_then_unwrap.stderr index 99e4488c040df..f454316068f26 100644 --- a/src/tools/clippy/tests/ui/or_then_unwrap.stderr +++ b/src/tools/clippy/tests/ui/or_then_unwrap.stderr @@ -1,5 +1,5 @@ error: found `.or(Some(…)).unwrap()` - --> $DIR/or_then_unwrap.rs:22:20 + --> tests/ui/or_then_unwrap.rs:22:20 | LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or("fallback")` @@ -8,13 +8,13 @@ LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint = help: to override `-D warnings` add `#[allow(clippy::or_then_unwrap)]` error: found `.or(Ok(…)).unwrap()` - --> $DIR/or_then_unwrap.rs:25:20 + --> tests/ui/or_then_unwrap.rs:25:20 | LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or("fallback")` error: found `.or(Some(…)).unwrap()` - --> $DIR/or_then_unwrap.rs:29:31 + --> tests/ui/or_then_unwrap.rs:29:31 | LL | let _ = option.map(|v| v).or(Some("fallback")).unwrap().to_string().chars(); // should trigger lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or("fallback")` 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 37db11caab8aa..8bf0152601dfd 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 @@ -1,5 +1,5 @@ error: range is out of bounds - --> $DIR/issue-3102.rs:9:13 + --> tests/ui/out_of_bounds_indexing/issue-3102.rs:9:13 | LL | &x[num..10]; | ^^ @@ -8,7 +8,7 @@ LL | &x[num..10]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> $DIR/issue-3102.rs:12:8 + --> tests/ui/out_of_bounds_indexing/issue-3102.rs:12:8 | LL | &x[10..num]; | ^^ 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 ddef38beb315a..87d1d574dcb85 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 @@ -1,5 +1,5 @@ error: range is out of bounds - --> $DIR/simple.rs:7:11 + --> tests/ui/out_of_bounds_indexing/simple.rs:7:11 | LL | &x[..=4]; | ^ @@ -8,31 +8,31 @@ LL | &x[..=4]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> $DIR/simple.rs:10:11 + --> tests/ui/out_of_bounds_indexing/simple.rs:10:11 | LL | &x[1..5]; | ^ error: range is out of bounds - --> $DIR/simple.rs:12:8 + --> tests/ui/out_of_bounds_indexing/simple.rs:12:8 | LL | &x[5..]; | ^ error: range is out of bounds - --> $DIR/simple.rs:14:10 + --> tests/ui/out_of_bounds_indexing/simple.rs:14:10 | LL | &x[..5]; | ^ error: range is out of bounds - --> $DIR/simple.rs:16:8 + --> tests/ui/out_of_bounds_indexing/simple.rs:16:8 | LL | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ error: range is out of bounds - --> $DIR/simple.rs:18:12 + --> tests/ui/out_of_bounds_indexing/simple.rs:18:12 | LL | &x[0..=4]; | ^ diff --git a/src/tools/clippy/tests/ui/overflow_check_conditional.stderr b/src/tools/clippy/tests/ui/overflow_check_conditional.stderr index b3cab8a210983..c14532bad5ab7 100644 --- a/src/tools/clippy/tests/ui/overflow_check_conditional.stderr +++ b/src/tools/clippy/tests/ui/overflow_check_conditional.stderr @@ -1,5 +1,5 @@ error: you are trying to use classic C overflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:5:8 + --> tests/ui/overflow_check_conditional.rs:5:8 | LL | if a + b < a {} | ^^^^^^^^^ @@ -8,43 +8,43 @@ LL | if a + b < a {} = 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 + --> tests/ui/overflow_check_conditional.rs:8:8 | LL | if a > a + b {} | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:10:8 + --> tests/ui/overflow_check_conditional.rs:10:8 | LL | if a + b < b {} | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:12:8 + --> tests/ui/overflow_check_conditional.rs:12:8 | LL | if b > a + b {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:14:8 + --> tests/ui/overflow_check_conditional.rs:14:8 | LL | if a - b > b {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:16:8 + --> tests/ui/overflow_check_conditional.rs:16:8 | LL | if b < a - b {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:18:8 + --> tests/ui/overflow_check_conditional.rs:18:8 | LL | if a - b > a {} | ^^^^^^^^^ error: you are trying to use classic C underflow conditions that will fail in Rust - --> $DIR/overflow_check_conditional.rs:20:8 + --> tests/ui/overflow_check_conditional.rs:20:8 | LL | if a < a - b {} | ^^^^^^^^^ 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 dc62d0e1dbd2d..21dd5ade53563 100644 --- a/src/tools/clippy/tests/ui/overly_complex_bool_expr.stderr +++ b/src/tools/clippy/tests/ui/overly_complex_bool_expr.stderr @@ -1,11 +1,11 @@ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:11:13 + --> tests/ui/overly_complex_bool_expr.rs:11:13 | LL | let _ = a && b || a; | ^^^^^^^^^^^ help: it would look like the following: `a` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:11:18 + --> tests/ui/overly_complex_bool_expr.rs:11:18 | LL | let _ = a && b || a; | ^ @@ -13,49 +13,49 @@ LL | let _ = a && b || a; = 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 + --> tests/ui/overly_complex_bool_expr.rs:14:13 | LL | let _ = false && a; | ^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:14:22 + --> tests/ui/overly_complex_bool_expr.rs:14:22 | LL | let _ = false && a; | ^ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:25:13 + --> tests/ui/overly_complex_bool_expr.rs:25:13 | LL | let _ = a == b && a != b; | ^^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:25:13 + --> tests/ui/overly_complex_bool_expr.rs:25:13 | LL | let _ = a == b && a != b; | ^^^^^^ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:27:13 + --> tests/ui/overly_complex_bool_expr.rs:27:13 | LL | let _ = a < b && a >= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:27:13 + --> tests/ui/overly_complex_bool_expr.rs:27:13 | LL | let _ = a < b && a >= b; | ^^^^^ error: this boolean expression contains a logic bug - --> $DIR/overly_complex_bool_expr.rs:29:13 + --> tests/ui/overly_complex_bool_expr.rs:29:13 | LL | let _ = a > b && a <= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/overly_complex_bool_expr.rs:29:13 + --> tests/ui/overly_complex_bool_expr.rs:29:13 | LL | let _ = a > b && a <= b; | ^^^^^ 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 d55c5cf36f626..cd2234bdfb13c 100644 --- a/src/tools/clippy/tests/ui/panic_in_result_fn.stderr +++ b/src/tools/clippy/tests/ui/panic_in_result_fn.stderr @@ -1,5 +1,5 @@ error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn.rs:6:5 + --> tests/ui/panic_in_result_fn.rs:6:5 | LL | / fn result_with_panic() -> Result // should emit lint LL | | @@ -10,7 +10,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn.rs:9:9 + --> tests/ui/panic_in_result_fn.rs:9:9 | LL | panic!("error"); | ^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | panic!("error"); = 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 + --> tests/ui/panic_in_result_fn.rs:53:1 | LL | / fn function_result_with_panic() -> Result // should emit lint LL | | @@ -29,7 +29,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn.rs:56:5 + --> tests/ui/panic_in_result_fn.rs:56:5 | LL | panic!("error"); | ^^^^^^^^^^^^^^^ 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 a80e6f27abcb4..cdb7762510d9c 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 @@ -1,5 +1,5 @@ error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn_assertions.rs:7:5 + --> tests/ui/panic_in_result_fn_assertions.rs:7:5 | LL | / fn result_with_assert_with_message(x: i32) -> Result // should emit lint LL | | @@ -11,7 +11,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn_assertions.rs:10:9 + --> tests/ui/panic_in_result_fn_assertions.rs:10:9 | LL | assert!(x == 5, "wrong argument"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | assert!(x == 5, "wrong argument"); = 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 + --> tests/ui/panic_in_result_fn_assertions.rs:14:5 | LL | / fn result_with_assert_eq(x: i32) -> Result // should emit lint LL | | @@ -31,13 +31,13 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn_assertions.rs:17:9 + --> tests/ui/panic_in_result_fn_assertions.rs:17:9 | LL | assert_eq!(x, 5); | ^^^^^^^^^^^^^^^^ error: used `panic!()` or assertion in a function that returns `Result` - --> $DIR/panic_in_result_fn_assertions.rs:21:5 + --> tests/ui/panic_in_result_fn_assertions.rs:21:5 | LL | / fn result_with_assert_ne(x: i32) -> Result // should emit lint LL | | @@ -49,7 +49,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> $DIR/panic_in_result_fn_assertions.rs:24:9 + --> tests/ui/panic_in_result_fn_assertions.rs:24:9 | LL | assert_ne!(x, 1); | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/panicking_macros.stderr b/src/tools/clippy/tests/ui/panicking_macros.stderr index 59ce57d0b3dae..06025859c0c6d 100644 --- a/src/tools/clippy/tests/ui/panicking_macros.stderr +++ b/src/tools/clippy/tests/ui/panicking_macros.stderr @@ -1,5 +1,5 @@ error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:23:5 + --> tests/ui/panicking_macros.rs:23:5 | LL | panic!(); | ^^^^^^^^ @@ -8,19 +8,19 @@ LL | panic!(); = help: to override `-D warnings` add `#[allow(clippy::panic)]` error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:26:5 + --> tests/ui/panicking_macros.rs:26:5 | LL | panic!("message"); | ^^^^^^^^^^^^^^^^^ error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:28:5 + --> tests/ui/panicking_macros.rs:28:5 | LL | panic!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:35:5 + --> tests/ui/panicking_macros.rs:35:5 | LL | todo!(); | ^^^^^^^ @@ -29,19 +29,19 @@ LL | todo!(); = help: to override `-D warnings` add `#[allow(clippy::todo)]` error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:38:5 + --> tests/ui/panicking_macros.rs:38:5 | LL | todo!("message"); | ^^^^^^^^^^^^^^^^ error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:40:5 + --> tests/ui/panicking_macros.rs:40:5 | LL | todo!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:47:5 + --> tests/ui/panicking_macros.rs:47:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ @@ -50,19 +50,19 @@ LL | unimplemented!(); = help: to override `-D warnings` add `#[allow(clippy::unimplemented)]` error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:50:5 + --> tests/ui/panicking_macros.rs:50:5 | LL | unimplemented!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:52:5 + --> tests/ui/panicking_macros.rs:52:5 | LL | unimplemented!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:59:5 + --> tests/ui/panicking_macros.rs:59:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ @@ -71,37 +71,37 @@ LL | unreachable!(); = help: to override `-D warnings` add `#[allow(clippy::unreachable)]` error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:62:5 + --> tests/ui/panicking_macros.rs:62:5 | LL | unreachable!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:64:5 + --> tests/ui/panicking_macros.rs:64:5 | LL | unreachable!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `panic` should not be present in production code - --> $DIR/panicking_macros.rs:71:5 + --> tests/ui/panicking_macros.rs:71:5 | LL | panic!(); | ^^^^^^^^ error: `todo` should not be present in production code - --> $DIR/panicking_macros.rs:73:5 + --> tests/ui/panicking_macros.rs:73:5 | LL | todo!(); | ^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panicking_macros.rs:75:5 + --> tests/ui/panicking_macros.rs:75:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> $DIR/panicking_macros.rs:77:5 + --> tests/ui/panicking_macros.rs:77:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/partial_pub_fields.stderr b/src/tools/clippy/tests/ui/partial_pub_fields.stderr index a152287403b75..af3b2f7587578 100644 --- a/src/tools/clippy/tests/ui/partial_pub_fields.stderr +++ b/src/tools/clippy/tests/ui/partial_pub_fields.stderr @@ -1,5 +1,5 @@ error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:10:9 + --> tests/ui/partial_pub_fields.rs:10:9 | LL | pub paths: HashMap, | ^^^ @@ -9,7 +9,7 @@ LL | pub paths: HashMap, = 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 + --> tests/ui/partial_pub_fields.rs:17:9 | LL | b: u8, | ^ @@ -17,7 +17,7 @@ LL | b: u8, = help: consider using public field here error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:21:27 + --> tests/ui/partial_pub_fields.rs:21:27 | LL | pub struct Point(i32, pub i32); | ^^^ @@ -25,7 +25,7 @@ LL | pub struct Point(i32, pub i32); = help: consider using private field here error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:26:9 + --> tests/ui/partial_pub_fields.rs:26:9 | LL | pub pos: u32, | ^^^ diff --git a/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr b/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr index 2210e706d930d..dc01a375060b9 100644 --- a/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr +++ b/src/tools/clippy/tests/ui/partialeq_ne_impl.stderr @@ -1,5 +1,5 @@ error: re-implementing `PartialEq::ne` is unnecessary - --> $DIR/partialeq_ne_impl.rs:9:5 + --> tests/ui/partialeq_ne_impl.rs:9:5 | LL | / fn ne(&self, _: &Foo) -> bool { LL | | diff --git a/src/tools/clippy/tests/ui/partialeq_to_none.stderr b/src/tools/clippy/tests/ui/partialeq_to_none.stderr index 50ce15001f40f..b588fbf32b606 100644 --- a/src/tools/clippy/tests/ui/partialeq_to_none.stderr +++ b/src/tools/clippy/tests/ui/partialeq_to_none.stderr @@ -1,5 +1,5 @@ error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:14:8 + --> tests/ui/partialeq_to_none.rs:14:8 | LL | if f != None { "yay" } else { "nay" } | ^^^^^^^^^ help: use `Option::is_some()` instead: `f.is_some()` @@ -8,55 +8,55 @@ LL | if f != None { "yay" } else { "nay" } = 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 + --> tests/ui/partialeq_to_none.rs:44:13 | LL | let _ = x == None; | ^^^^^^^^^ help: use `Option::is_none()` instead: `x.is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:45:13 + --> tests/ui/partialeq_to_none.rs:45:13 | LL | let _ = x != None; | ^^^^^^^^^ help: use `Option::is_some()` instead: `x.is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:46:13 + --> tests/ui/partialeq_to_none.rs:46:13 | LL | let _ = None == x; | ^^^^^^^^^ help: use `Option::is_none()` instead: `x.is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:47:13 + --> tests/ui/partialeq_to_none.rs:47:13 | LL | let _ = None != x; | ^^^^^^^^^ help: use `Option::is_some()` instead: `x.is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:49:8 + --> tests/ui/partialeq_to_none.rs:49:8 | LL | if foobar() == None {} | ^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `foobar().is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:51:8 + --> tests/ui/partialeq_to_none.rs:51:8 | LL | if bar().ok() != None {} | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `bar().ok().is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:53:13 + --> tests/ui/partialeq_to_none.rs:53:13 | LL | let _ = Some(1 + 2) != None; | ^^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `Some(1 + 2).is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:55:13 + --> tests/ui/partialeq_to_none.rs:55:13 | LL | let _ = { Some(0) } == None; | ^^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `{ Some(0) }.is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:57:13 + --> tests/ui/partialeq_to_none.rs:57:13 | LL | let _ = { | _____________^ @@ -78,31 +78,31 @@ LL ~ }.is_some(); | error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:67:13 + --> tests/ui/partialeq_to_none.rs:67:13 | LL | let _ = optref() == &&None; | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `optref().is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:68:13 + --> tests/ui/partialeq_to_none.rs:68:13 | LL | let _ = &&None != optref(); | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `optref().is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:69:13 + --> tests/ui/partialeq_to_none.rs:69:13 | LL | let _ = **optref() == None; | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_none()` instead: `optref().is_none()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:70:13 + --> tests/ui/partialeq_to_none.rs:70:13 | LL | let _ = &None != *optref(); | ^^^^^^^^^^^^^^^^^^ help: use `Option::is_some()` instead: `optref().is_some()` error: binary comparison to literal `Option::None` - --> $DIR/partialeq_to_none.rs:73:13 + --> tests/ui/partialeq_to_none.rs:73:13 | LL | let _ = None != *x; | ^^^^^^^^^^ help: use `Option::is_some()` instead: `(*x).is_some()` 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 f96ce0de77931..c9f36ecf48f60 100644 --- a/src/tools/clippy/tests/ui/path_buf_push_overwrite.stderr +++ b/src/tools/clippy/tests/ui/path_buf_push_overwrite.stderr @@ -1,5 +1,5 @@ error: calling `push` with '/' or '\' (file system root) will overwrite the previous path definition - --> $DIR/path_buf_push_overwrite.rs:6:12 + --> tests/ui/path_buf_push_overwrite.rs:6:12 | LL | x.push("/bar"); | ^^^^^^ help: try: `"bar"` diff --git a/src/tools/clippy/tests/ui/path_ends_with_ext.stderr b/src/tools/clippy/tests/ui/path_ends_with_ext.stderr index a73ab4d08e9c5..deab71ff76268 100644 --- a/src/tools/clippy/tests/ui/path_ends_with_ext.stderr +++ b/src/tools/clippy/tests/ui/path_ends_with_ext.stderr @@ -1,5 +1,5 @@ error: this looks like a failed attempt at checking for the file extension - --> $DIR/path_ends_with_ext.rs:11:5 + --> tests/ui/path_ends_with_ext.rs:11:5 | LL | path.ends_with(".md"); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `path.extension().is_some_and(|ext| ext == "md")` @@ -8,7 +8,7 @@ LL | path.ends_with(".md"); = help: to override `-D warnings` add `#[allow(clippy::path_ends_with_ext)]` error: this looks like a failed attempt at checking for the file extension - --> $DIR/path_ends_with_ext.rs:32:5 + --> tests/ui/path_ends_with_ext.rs:32:5 | LL | path.ends_with(".md") | ^^^^^^^^^^^^^^^^^^^^^ help: try: `path.extension().map_or(false, |ext| ext == "md")` 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 f21e1894af2a2..e795ded7386d2 100644 --- a/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.stderr +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/mutability.rs:9:9 + --> tests/ui/pattern_type_mismatch/mutability.rs:9:9 | LL | Some(_) => (), | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(_) => (), = 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 + --> tests/ui/pattern_type_mismatch/mutability.rs:16:9 | LL | Some(_) => (), | ^^^^^^^ 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 b72c24840d7d4..e1aec2497cd15 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 @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_alternatives.rs:15:12 + --> tests/ui/pattern_type_mismatch/pattern_alternatives.rs:15:12 | LL | if let Value::B | Value::A(_) = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | if let Value::B | Value::A(_) = ref_value {} = 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 + --> tests/ui/pattern_type_mismatch/pattern_alternatives.rs:17:34 | LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &Value::B | &Value::A(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_alternatives.rs:19:32 + --> tests/ui/pattern_type_mismatch/pattern_alternatives.rs:19:32 | LL | if let Value::B | Value::A(Some(_)) = *ref_value {} | ^^^^^^^ 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 c46c7de6dd658..e5d6e9ed6f819 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 @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:13:9 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:13:9 | LL | let Struct { .. } = ref_value; | ^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let Struct { .. } = ref_value; = 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 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:15:33 | LL | if let &Struct { ref_inner: Some(_) } = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &Struct { ref_inner: Some(_) } = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:17:32 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:17:32 | LL | if let Struct { ref_inner: Some(_) } = *ref_value {} | ^^^^^^^ @@ -25,7 +25,7 @@ LL | if let Struct { ref_inner: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:35:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:35:12 | LL | if let StructEnum::Var { .. } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let StructEnum::Var { .. } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:37:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:37:12 | LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:39:42 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:39:42 | LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:41:41 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:41:41 | LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} | ^^^^^^^ @@ -57,7 +57,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_structs.rs:43:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:43:12 | LL | if let StructEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^^ 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 b365731d5619c..9ecf12a1d639f 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 @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:11:9 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:11:9 | LL | let TupleStruct(_) = ref_value; | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let TupleStruct(_) = ref_value; = 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 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:13:25 | LL | if let &TupleStruct(Some(_)) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let &TupleStruct(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:15:24 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:15:24 | LL | if let TupleStruct(Some(_)) = *ref_value {} | ^^^^^^^ @@ -25,7 +25,7 @@ LL | if let TupleStruct(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:33:12 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:33:12 | LL | if let TupleEnum::Var(_) = ref_value {} | ^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let TupleEnum::Var(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:35:28 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:35:28 | LL | if let &TupleEnum::Var(Some(_)) = ref_value {} | ^^^^^^^ @@ -41,7 +41,7 @@ LL | if let &TupleEnum::Var(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:37:27 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:37:27 | LL | if let TupleEnum::Var(Some(_)) = *ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let TupleEnum::Var(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:39:12 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:39:12 | LL | if let TupleEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | if let TupleEnum::Empty = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:55:9 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:55:9 | LL | let (_a, _b) = ref_value; | ^^^^^^^^ @@ -65,7 +65,7 @@ LL | let (_a, _b) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:57:18 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:57:18 | LL | if let &(_a, Some(_)) = ref_value {} | ^^^^^^^ @@ -73,7 +73,7 @@ LL | if let &(_a, Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/pattern_tuples.rs:59:17 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:59:17 | LL | if let (_a, Some(_)) = *ref_value {} | ^^^^^^^ 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 dfe4639c7746f..9186a01b9c75f 100644 --- a/src/tools/clippy/tests/ui/pattern_type_mismatch/syntax.stderr +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/syntax.stderr @@ -1,5 +1,5 @@ error: type of pattern does not match the expression type - --> $DIR/syntax.rs:11:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:11:9 | LL | Some(_) => (), | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(_) => (), = 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 + --> tests/ui/pattern_type_mismatch/syntax.rs:31:12 | LL | if let Some(_) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let Some(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:43:15 + --> tests/ui/pattern_type_mismatch/syntax.rs:43:15 | LL | while let Some(_) = ref_value { | ^^^^^^^ @@ -25,7 +25,7 @@ LL | while let Some(_) = ref_value { = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:62:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:62:9 | LL | for (_a, _b) in slice.iter() {} | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | for (_a, _b) in slice.iter() {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:73:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:73:9 | LL | let (_n, _m) = ref_value; | ^^^^^^^^ @@ -41,7 +41,7 @@ LL | let (_n, _m) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:83:12 + --> tests/ui/pattern_type_mismatch/syntax.rs:83:12 | LL | fn foo((_a, _b): &(i32, i32)) {} | ^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn foo((_a, _b): &(i32, i32)) {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:98:10 + --> tests/ui/pattern_type_mismatch/syntax.rs:98:10 | LL | foo(|(_a, _b)| ()); | ^^^^^^^^ @@ -57,7 +57,7 @@ LL | foo(|(_a, _b)| ()); = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:115:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:115:9 | LL | Some(_) => (), | ^^^^^^^ @@ -65,7 +65,7 @@ LL | Some(_) => (), = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> $DIR/syntax.rs:136:17 + --> tests/ui/pattern_type_mismatch/syntax.rs:136:17 | LL | Some(_) => (), | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/patterns.stderr b/src/tools/clippy/tests/ui/patterns.stderr index 2f608bbc18fae..fa4cf7f835622 100644 --- a/src/tools/clippy/tests/ui/patterns.stderr +++ b/src/tools/clippy/tests/ui/patterns.stderr @@ -1,5 +1,5 @@ error: the `y @ _` pattern can be written as just `y` - --> $DIR/patterns.rs:14:9 + --> tests/ui/patterns.rs:14:9 | LL | y @ _ => (), | ^^^^^ help: try: `y` @@ -8,13 +8,13 @@ LL | y @ _ => (), = 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 + --> tests/ui/patterns.rs:29:9 | LL | ref mut x @ _ => { | ^^^^^^^^^^^^^ help: try: `ref mut x` error: the `x @ _` pattern can be written as just `x` - --> $DIR/patterns.rs:37:9 + --> tests/ui/patterns.rs:37:9 | LL | ref x @ _ => println!("vec: {:?}", x), | ^^^^^^^^^ help: try: `ref x` 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 bd34463084a4a..4e0a8e39db7f0 100644 --- a/src/tools/clippy/tests/ui/permissions_set_readonly_false.stderr +++ b/src/tools/clippy/tests/ui/permissions_set_readonly_false.stderr @@ -1,5 +1,5 @@ error: call to `set_readonly` with argument `false` - --> $DIR/permissions_set_readonly_false.rs:19:5 + --> tests/ui/permissions_set_readonly_false.rs:19:5 | LL | permissions.set_readonly(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/precedence.stderr b/src/tools/clippy/tests/ui/precedence.stderr index bd0cbccc787c8..47e61326219d9 100644 --- a/src/tools/clippy/tests/ui/precedence.stderr +++ b/src/tools/clippy/tests/ui/precedence.stderr @@ -1,5 +1,5 @@ error: operator precedence can trip the unwary - --> $DIR/precedence.rs:16:5 + --> tests/ui/precedence.rs:16:5 | LL | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` @@ -8,67 +8,67 @@ LL | 1 << 2 + 3; = help: to override `-D warnings` add `#[allow(clippy::precedence)]` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:17:5 + --> tests/ui/precedence.rs:17:5 | LL | 1 + 2 << 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:18:5 + --> tests/ui/precedence.rs:18:5 | LL | 4 >> 1 + 1; | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:19:5 + --> tests/ui/precedence.rs:19:5 | LL | 1 + 3 >> 2; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:20:5 + --> tests/ui/precedence.rs:20:5 | LL | 1 ^ 1 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:21:5 + --> tests/ui/precedence.rs:21:5 | LL | 3 | 2 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:22:5 + --> tests/ui/precedence.rs:22:5 | LL | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:23:5 + --> tests/ui/precedence.rs:23:5 | LL | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:24:5 + --> tests/ui/precedence.rs:24:5 | LL | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:51:13 + --> tests/ui/precedence.rs:51:13 | LL | let _ = -1.0_f64.cos().cos(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().cos())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:52:13 + --> tests/ui/precedence.rs:52:13 | LL | let _ = -1.0_f64.cos().sin(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.cos().sin())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:53:13 + --> tests/ui/precedence.rs:53:13 | LL | let _ = -1.0_f64.sin().cos(); | ^^^^^^^^^^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1.0_f64.sin().cos())` diff --git a/src/tools/clippy/tests/ui/print.stderr b/src/tools/clippy/tests/ui/print.stderr index bb8d945081e16..a8374241c8312 100644 --- a/src/tools/clippy/tests/ui/print.stderr +++ b/src/tools/clippy/tests/ui/print.stderr @@ -1,5 +1,5 @@ error: use of `Debug`-based formatting - --> $DIR/print.rs:11:20 + --> tests/ui/print.rs:11:20 | LL | write!(f, "{:?}", 43.1415) | ^^^^ @@ -8,7 +8,7 @@ LL | write!(f, "{:?}", 43.1415) = help: to override `-D warnings` add `#[allow(clippy::use_debug)]` error: use of `println!` - --> $DIR/print.rs:25:5 + --> tests/ui/print.rs:25:5 | LL | println!("Hello"); | ^^^^^^^^^^^^^^^^^ @@ -17,37 +17,37 @@ LL | println!("Hello"); = help: to override `-D warnings` add `#[allow(clippy::print_stdout)]` error: use of `print!` - --> $DIR/print.rs:28:5 + --> tests/ui/print.rs:28:5 | LL | print!("Hello"); | ^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:31:5 + --> tests/ui/print.rs:31:5 | LL | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:34:5 + --> tests/ui/print.rs:34:5 | LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:34:19 + --> tests/ui/print.rs:34:19 | LL | print!("Hello {:?}", "World"); | ^^^^ error: use of `print!` - --> $DIR/print.rs:38:5 + --> tests/ui/print.rs:38:5 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:38:19 + --> tests/ui/print.rs:38:19 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^ 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 57f06dc1143f3..3fb6b3f9c9110 100644 --- a/src/tools/clippy/tests/ui/print_in_format_impl.stderr +++ b/src/tools/clippy/tests/ui/print_in_format_impl.stderr @@ -1,5 +1,5 @@ error: use of `print!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:20:9 + --> tests/ui/print_in_format_impl.rs:20:9 | LL | print!("{}", 1); | ^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` @@ -8,37 +8,37 @@ LL | print!("{}", 1); = 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 + --> tests/ui/print_in_format_impl.rs:23:9 | LL | println!("{}", 2); | ^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `eprint!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:25:9 + --> tests/ui/print_in_format_impl.rs:25:9 | LL | eprint!("{}", 3); | ^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` error: use of `eprintln!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:27:9 + --> tests/ui/print_in_format_impl.rs:27:9 | LL | eprintln!("{}", 4); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `println!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:30:13 + --> tests/ui/print_in_format_impl.rs:30:13 | LL | println!("nested"); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `print!` in `Display` impl - --> $DIR/print_in_format_impl.rs:44:9 + --> tests/ui/print_in_format_impl.rs:44:9 | LL | print!("Display"); | ^^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` error: use of `println!` in `Debug` impl - --> $DIR/print_in_format_impl.rs:55:9 + --> tests/ui/print_in_format_impl.rs:55:9 | LL | println!("UnnamedFormatter"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(..)` diff --git a/src/tools/clippy/tests/ui/print_literal.stderr b/src/tools/clippy/tests/ui/print_literal.stderr index 8c011d7bc0a6f..c4cbb8bed7074 100644 --- a/src/tools/clippy/tests/ui/print_literal.stderr +++ b/src/tools/clippy/tests/ui/print_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/print_literal.rs:27:24 + --> tests/ui/print_literal.rs:27:24 | LL | print!("Hello {}", "world"); | ^^^^^^^ @@ -13,7 +13,7 @@ LL + print!("Hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:30:36 + --> tests/ui/print_literal.rs:30:36 | LL | println!("Hello {} {}", world, "world"); | ^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {} world", world); | error: literal with an empty format string - --> $DIR/print_literal.rs:32:26 + --> tests/ui/print_literal.rs:32:26 | LL | println!("Hello {}", "world"); | ^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("Hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:34:26 + --> tests/ui/print_literal.rs:34:26 | LL | println!("{} {:.4}", "a literal", 5); | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("a literal {:.4}", 5); | error: literal with an empty format string - --> $DIR/print_literal.rs:40:25 + --> tests/ui/print_literal.rs:40:25 | LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!("hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:42:25 + --> tests/ui/print_literal.rs:42:25 | LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + println!("world hello"); | error: literal with an empty format string - --> $DIR/print_literal.rs:46:35 + --> tests/ui/print_literal.rs:46:35 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + println!("hello world"); | error: literal with an empty format string - --> $DIR/print_literal.rs:48:35 + --> tests/ui/print_literal.rs:48:35 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + println!("world hello"); | error: literal with an empty format string - --> $DIR/print_literal.rs:56:20 + --> tests/ui/print_literal.rs:56:20 | LL | println!("{}", "{} \x00 \u{ab123} \\\u{ab123} {:?}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + println!("{{}} \x00 \u{ab123} \\\u{ab123} {{:?}}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:57:20 + --> tests/ui/print_literal.rs:57:20 | LL | println!("{}", "\\\u{1234}"); | ^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + println!("\\\u{1234}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:61:20 + --> tests/ui/print_literal.rs:61:20 | LL | println!("{}", r"\u{ab123} \u{{"); | ^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + println!("\\u{{ab123}} \\u{{{{"); | error: literal with an empty format string - --> $DIR/print_literal.rs:62:21 + --> tests/ui/print_literal.rs:62:21 | LL | println!(r"{}", r"\u{ab123} \u{{"); | ^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + println!(r"\u{{ab123}} \u{{{{"); | error: literal with an empty format string - --> $DIR/print_literal.rs:63:20 + --> tests/ui/print_literal.rs:63:20 | LL | println!("{}", r"\{ab123} \u{{"); | ^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + println!("\\{{ab123}} \\u{{{{"); | error: literal with an empty format string - --> $DIR/print_literal.rs:64:20 + --> tests/ui/print_literal.rs:64:20 | LL | println!("{}", "\\u{ab123}"); | ^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL + println!("\\u{{ab123}}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:65:20 + --> tests/ui/print_literal.rs:65:20 | LL | println!("{}", "\\\\u{1234}"); | ^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + println!("\\\\u{{1234}}"); | error: literal with an empty format string - --> $DIR/print_literal.rs:67:35 + --> tests/ui/print_literal.rs:67:35 | LL | println!("mixed: {} {world}", "{hello}"); | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/print_stderr.stderr b/src/tools/clippy/tests/ui/print_stderr.stderr index 7de16331067ec..17019b886905a 100644 --- a/src/tools/clippy/tests/ui/print_stderr.stderr +++ b/src/tools/clippy/tests/ui/print_stderr.stderr @@ -1,5 +1,5 @@ error: use of `eprintln!` - --> $DIR/print_stderr.rs:4:5 + --> tests/ui/print_stderr.rs:4:5 | LL | eprintln!("Hello"); | ^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | eprintln!("Hello"); = help: to override `-D warnings` add `#[allow(clippy::print_stderr)]` error: use of `eprint!` - --> $DIR/print_stderr.rs:8:5 + --> tests/ui/print_stderr.rs:8:5 | LL | eprint!("World"); | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/print_with_newline.stderr b/src/tools/clippy/tests/ui/print_with_newline.stderr index 7ff6a5f060d0b..9b07299e61d36 100644 --- a/src/tools/clippy/tests/ui/print_with_newline.stderr +++ b/src/tools/clippy/tests/ui/print_with_newline.stderr @@ -1,5 +1,5 @@ error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:7:5 + --> tests/ui/print_with_newline.rs:7:5 | LL | print!("Hello\n"); | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("Hello"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:10:5 + --> tests/ui/print_with_newline.rs:10:5 | LL | print!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {}", "world"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:12:5 + --> tests/ui/print_with_newline.rs:12:5 | LL | print!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("Hello {} {}", "world", "#2"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:14:5 + --> tests/ui/print_with_newline.rs:14:5 | LL | print!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("{}", 1265); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:16:5 + --> tests/ui/print_with_newline.rs:16:5 | LL | print!("\n"); | ^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!(); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:39:5 + --> tests/ui/print_with_newline.rs:39:5 | LL | print!("\\\n"); | ^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + println!("\\"); | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:48:5 + --> tests/ui/print_with_newline.rs:48:5 | LL | / print!( LL | | @@ -90,7 +90,7 @@ LL ~ | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:53:5 + --> tests/ui/print_with_newline.rs:53:5 | LL | / print!( LL | | @@ -107,7 +107,7 @@ LL ~ | error: using `print!()` with a format string that ends in a single newline - --> $DIR/print_with_newline.rs:63:5 + --> tests/ui/print_with_newline.rs:63:5 | LL | print!("\\r\n"); | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/println_empty_string.stderr b/src/tools/clippy/tests/ui/println_empty_string.stderr index c89e64f665a75..17de05fa25a42 100644 --- a/src/tools/clippy/tests/ui/println_empty_string.stderr +++ b/src/tools/clippy/tests/ui/println_empty_string.stderr @@ -1,5 +1,5 @@ error: empty string literal in `println!` - --> $DIR/println_empty_string.rs:5:5 + --> tests/ui/println_empty_string.rs:5:5 | LL | println!(""); | ^^^^^^^^^--^ @@ -10,7 +10,7 @@ LL | println!(""); = help: to override `-D warnings` add `#[allow(clippy::println_empty_string)]` error: empty string literal in `println!` - --> $DIR/println_empty_string.rs:8:14 + --> tests/ui/println_empty_string.rs:8:14 | LL | _ => println!(""), | ^^^^^^^^^--^ @@ -18,7 +18,7 @@ LL | _ => println!(""), | help: remove the empty string error: empty string literal in `eprintln!` - --> $DIR/println_empty_string.rs:12:5 + --> tests/ui/println_empty_string.rs:12:5 | LL | eprintln!(""); | ^^^^^^^^^^--^ @@ -26,7 +26,7 @@ LL | eprintln!(""); | help: remove the empty string error: empty string literal in `eprintln!` - --> $DIR/println_empty_string.rs:15:14 + --> tests/ui/println_empty_string.rs:15:14 | LL | _ => eprintln!(""), | ^^^^^^^^^^--^ diff --git a/src/tools/clippy/tests/ui/proc_macro.stderr b/src/tools/clippy/tests/ui/proc_macro.stderr index 122374ea804dd..4314a5bb4d1cd 100644 --- a/src/tools/clippy/tests/ui/proc_macro.stderr +++ b/src/tools/clippy/tests/ui/proc_macro.stderr @@ -1,5 +1,5 @@ error: approximate value of `f{32, 64}::consts::PI` found - --> $DIR/proc_macro.rs:9:14 + --> tests/ui/proc_macro.rs:9:14 | LL | let _x = 3.14; | ^^^^ diff --git a/src/tools/clippy/tests/ui/ptr_arg.stderr b/src/tools/clippy/tests/ui/ptr_arg.stderr index 35bd850920590..0342130c992be 100644 --- a/src/tools/clippy/tests/ui/ptr_arg.stderr +++ b/src/tools/clippy/tests/ui/ptr_arg.stderr @@ -1,5 +1,5 @@ error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:14:14 + --> tests/ui/ptr_arg.rs:14:14 | LL | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` @@ -8,49 +8,49 @@ LL | fn do_vec(x: &Vec) { = 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 + --> tests/ui/ptr_arg.rs:20:18 | LL | fn do_vec_mut(x: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:25:19 + --> tests/ui/ptr_arg.rs:25:19 | LL | fn do_vec_mut2(x: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:31:14 + --> tests/ui/ptr_arg.rs:31:14 | LL | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:36:18 + --> tests/ui/ptr_arg.rs:36:18 | LL | fn do_str_mut(x: &mut String) { | ^^^^^^^^^^^ help: change this to: `&mut str` error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:41:15 + --> tests/ui/ptr_arg.rs:41:15 | LL | fn do_path(x: &PathBuf) { | ^^^^^^^^ help: change this to: `&Path` error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:46:19 + --> tests/ui/ptr_arg.rs:46:19 | LL | fn do_path_mut(x: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:55:18 + --> tests/ui/ptr_arg.rs:55:18 | LL | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:69:14 + --> tests/ui/ptr_arg.rs:69:14 | LL | fn cloned(x: &Vec) -> Vec { | ^^^^^^^^ @@ -68,7 +68,7 @@ LL ~ x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:79:18 + --> tests/ui/ptr_arg.rs:79:18 | LL | fn str_cloned(x: &String) -> String { | ^^^^^^^ @@ -85,7 +85,7 @@ LL ~ x.to_owned() | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:88:19 + --> tests/ui/ptr_arg.rs:88:19 | LL | fn path_cloned(x: &PathBuf) -> PathBuf { | ^^^^^^^^ @@ -102,7 +102,7 @@ LL ~ x.to_path_buf() | error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:97:44 + --> tests/ui/ptr_arg.rs:97:44 | LL | fn false_positive_capacity(x: &Vec, y: &String) { | ^^^^^^^ @@ -117,19 +117,19 @@ LL ~ let c = y; | error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:112:25 + --> tests/ui/ptr_arg.rs:112:25 | LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:142:66 + --> tests/ui/ptr_arg.rs:142:66 | LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec, _s: &String) {} | ^^^^^^^ help: change this to: `&str` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:172:21 + --> tests/ui/ptr_arg.rs:172:21 | LL | fn foo_vec(vec: &Vec) { | ^^^^^^^^ @@ -143,7 +143,7 @@ LL ~ let _ = vec.to_owned().clone(); | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:178:23 + --> tests/ui/ptr_arg.rs:178:23 | LL | fn foo_path(path: &PathBuf) { | ^^^^^^^^ @@ -157,7 +157,7 @@ LL ~ let _ = path.to_path_buf().clone(); | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:184:21 + --> tests/ui/ptr_arg.rs:184:21 | LL | fn foo_str(str: &PathBuf) { | ^^^^^^^^ @@ -171,43 +171,43 @@ LL ~ let _ = str.to_path_buf().clone(); | error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:191:29 + --> tests/ui/ptr_arg.rs:191:29 | LL | fn mut_vec_slice_methods(v: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:254:17 + --> tests/ui/ptr_arg.rs:254:17 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:254:35 + --> tests/ui/ptr_arg.rs:254:35 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^ help: change this to: `&mut str` error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do - --> $DIR/ptr_arg.rs:254:51 + --> tests/ui/ptr_arg.rs:254:51 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:280:39 + --> tests/ui/ptr_arg.rs:280:39 | LL | fn cow_elided_lifetime<'a>(input: &'a Cow) -> &'a str { | ^^^^^^^^^^^^ help: change this to: `&str` error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:286:36 + --> tests/ui/ptr_arg.rs:286:36 | LL | fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str { | ^^^^^^^^^^^^^^^^ help: change this to: `&str` error: using a reference to `Cow` is not recommended - --> $DIR/ptr_arg.rs:290:40 + --> tests/ui/ptr_arg.rs:290:40 | LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str { | ^^^^^^^^^^^^^^^^ help: change this to: `&str` diff --git a/src/tools/clippy/tests/ui/ptr_as_ptr.stderr b/src/tools/clippy/tests/ui/ptr_as_ptr.stderr index ef64347e9350c..e162f35baf551 100644 --- a/src/tools/clippy/tests/ui/ptr_as_ptr.stderr +++ b/src/tools/clippy/tests/ui/ptr_as_ptr.stderr @@ -1,5 +1,5 @@ error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:18:33 + --> tests/ui/ptr_as_ptr.rs:18:33 | LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::issue_11278_a::T) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `Box::into_raw(Box::new(o)).cast::>()` @@ -8,37 +8,37 @@ LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::i = 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 + --> tests/ui/ptr_as_ptr.rs:27:13 | LL | let _ = ptr as *const i32; | ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:28:13 + --> tests/ui/ptr_as_ptr.rs:28:13 | LL | let _ = mut_ptr as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:33:17 + --> tests/ui/ptr_as_ptr.rs:33:17 | LL | let _ = *ptr_ptr as *const i32; | ^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `(*ptr_ptr).cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:46:25 + --> tests/ui/ptr_as_ptr.rs:46:25 | LL | let _: *const i32 = ptr as *const _; | ^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:47:23 + --> tests/ui/ptr_as_ptr.rs:47:23 | LL | let _: *mut i32 = mut_ptr as _; | ^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:50:21 + --> tests/ui/ptr_as_ptr.rs:50:21 | LL | let _ = inline!($ptr as *const i32); | ^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `$ptr.cast::()` @@ -46,157 +46,157 @@ LL | let _ = inline!($ptr as *const i32); = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:71:13 + --> tests/ui/ptr_as_ptr.rs:71:13 | LL | let _ = ptr as *const i32; | ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:72:13 + --> tests/ui/ptr_as_ptr.rs:72:13 | LL | let _ = mut_ptr as *mut i32; | ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:79:9 + --> tests/ui/ptr_as_ptr.rs:79:9 | LL | ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:83:9 + --> tests/ui/ptr_as_ptr.rs:83:9 | LL | std::ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:88:9 + --> tests/ui/ptr_as_ptr.rs:88:9 | LL | ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:92:9 + --> tests/ui/ptr_as_ptr.rs:92:9 | LL | core::ptr::null_mut() as *mut u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:97:9 + --> tests/ui/ptr_as_ptr.rs:97:9 | LL | ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:101:9 + --> tests/ui/ptr_as_ptr.rs:101:9 | LL | std::ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:106:9 + --> tests/ui/ptr_as_ptr.rs:106:9 | LL | ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:110:9 + --> tests/ui/ptr_as_ptr.rs:110:9 | LL | core::ptr::null() as *const u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null::()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:117:9 + --> tests/ui/ptr_as_ptr.rs:117:9 | LL | ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:121:9 + --> tests/ui/ptr_as_ptr.rs:121:9 | LL | std::ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:126:9 + --> tests/ui/ptr_as_ptr.rs:126:9 | LL | ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:130:9 + --> tests/ui/ptr_as_ptr.rs:130:9 | LL | core::ptr::null_mut() as *mut _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:135:9 + --> tests/ui/ptr_as_ptr.rs:135:9 | LL | ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:139:9 + --> tests/ui/ptr_as_ptr.rs:139:9 | LL | std::ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:144:9 + --> tests/ui/ptr_as_ptr.rs:144:9 | LL | ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:148:9 + --> tests/ui/ptr_as_ptr.rs:148:9 | LL | core::ptr::null() as *const _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:155:9 + --> tests/ui/ptr_as_ptr.rs:155:9 | LL | ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:159:9 + --> tests/ui/ptr_as_ptr.rs:159:9 | LL | std::ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:164:9 + --> tests/ui/ptr_as_ptr.rs:164:9 | LL | ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:168:9 + --> tests/ui/ptr_as_ptr.rs:168:9 | LL | core::ptr::null_mut() as _ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:173:9 + --> tests/ui/ptr_as_ptr.rs:173:9 | LL | ptr::null() as _ | ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:177:9 + --> tests/ui/ptr_as_ptr.rs:177:9 | LL | std::ptr::null() as _ | ^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:182:9 + --> tests/ui/ptr_as_ptr.rs:182:9 | LL | ptr::null() as _ | ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()` error: `as` casting between raw pointers without changing its mutability - --> $DIR/ptr_as_ptr.rs:186:9 + --> tests/ui/ptr_as_ptr.rs:186:9 | LL | core::ptr::null() as _ | ^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()` diff --git a/src/tools/clippy/tests/ui/ptr_cast_constness.stderr b/src/tools/clippy/tests/ui/ptr_cast_constness.stderr index a4bf778ad19d1..8e2bec527ffb6 100644 --- a/src/tools/clippy/tests/ui/ptr_cast_constness.stderr +++ b/src/tools/clippy/tests/ui/ptr_cast_constness.stderr @@ -1,5 +1,5 @@ error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:10:41 + --> tests/ui/ptr_cast_constness.rs:10:41 | LL | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` @@ -8,37 +8,37 @@ LL | let _: &mut T = std::mem::transmute(p as *mut T); = 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 + --> tests/ui/ptr_cast_constness.rs:11:19 | LL | let _ = &mut *(p as *mut T); | ^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:26:17 + --> tests/ui/ptr_cast_constness.rs:26:17 | LL | let _ = *ptr_ptr as *mut u32; | ^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `(*ptr_ptr).cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:29:13 + --> tests/ui/ptr_cast_constness.rs:29:13 | LL | let _ = ptr as *mut u32; | ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:30:13 + --> tests/ui/ptr_cast_constness.rs:30:13 | LL | let _ = mut_ptr as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:59:13 + --> tests/ui/ptr_cast_constness.rs:59:13 | LL | let _ = ptr as *mut u32; | ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` error: `as` casting between raw pointers while changing only its constness - --> $DIR/ptr_cast_constness.rs:60:13 + --> tests/ui/ptr_cast_constness.rs:60:13 | LL | let _ = mut_ptr as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` diff --git a/src/tools/clippy/tests/ui/ptr_eq.stderr b/src/tools/clippy/tests/ui/ptr_eq.stderr index 2a384accac57f..bf8c2b5c08fb4 100644 --- a/src/tools/clippy/tests/ui/ptr_eq.stderr +++ b/src/tools/clippy/tests/ui/ptr_eq.stderr @@ -1,5 +1,5 @@ error: use `std::ptr::eq` when comparing raw pointers - --> $DIR/ptr_eq.rs:19:13 + --> tests/ui/ptr_eq.rs:19:13 | LL | let _ = a as *const _ as usize == b as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(a, b)` @@ -8,7 +8,7 @@ LL | let _ = a as *const _ as usize == b as *const _ as usize; = 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 + --> tests/ui/ptr_eq.rs:20:13 | LL | let _ = a as *const _ == b as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::eq(a, b)` diff --git a/src/tools/clippy/tests/ui/ptr_eq_no_std.stderr b/src/tools/clippy/tests/ui/ptr_eq_no_std.stderr index 3e289f5be613e..0463b75b720b9 100644 --- a/src/tools/clippy/tests/ui/ptr_eq_no_std.stderr +++ b/src/tools/clippy/tests/ui/ptr_eq_no_std.stderr @@ -1,5 +1,5 @@ error: use `core::ptr::eq` when comparing raw pointers - --> $DIR/ptr_eq_no_std.rs:31:13 + --> tests/ui/ptr_eq_no_std.rs:31:13 | LL | let _ = a as *const _ as usize == b as *const _ as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::eq(a, b)` @@ -8,7 +8,7 @@ LL | let _ = a as *const _ as usize == b as *const _ as usize; = help: to override `-D warnings` add `#[allow(clippy::ptr_eq)]` error: use `core::ptr::eq` when comparing raw pointers - --> $DIR/ptr_eq_no_std.rs:32:13 + --> tests/ui/ptr_eq_no_std.rs:32:13 | LL | let _ = a as *const _ == b as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::eq(a, b)` 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 e99053846795d..87ff10adc9467 100644 --- a/src/tools/clippy/tests/ui/ptr_offset_with_cast.stderr +++ b/src/tools/clippy/tests/ui/ptr_offset_with_cast.stderr @@ -1,5 +1,5 @@ error: use of `offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:12:17 + --> tests/ui/ptr_offset_with_cast.rs:12:17 | LL | let _ = ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` @@ -8,7 +8,7 @@ LL | let _ = ptr.offset(offset_usize as isize); = 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 + --> tests/ui/ptr_offset_with_cast.rs:16:17 | LL | let _ = ptr.wrapping_offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` diff --git a/src/tools/clippy/tests/ui/pub_use.stderr b/src/tools/clippy/tests/ui/pub_use.stderr index f6f5db9a18004..e332a864c5292 100644 --- a/src/tools/clippy/tests/ui/pub_use.stderr +++ b/src/tools/clippy/tests/ui/pub_use.stderr @@ -1,5 +1,5 @@ error: using `pub use` - --> $DIR/pub_use.rs:10:5 + --> tests/ui/pub_use.rs:10:5 | LL | pub use inner::Test; | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/pub_with_shorthand.stderr b/src/tools/clippy/tests/ui/pub_with_shorthand.stderr index 423b0508092f4..8978244c4c04a 100644 --- a/src/tools/clippy/tests/ui/pub_with_shorthand.stderr +++ b/src/tools/clippy/tests/ui/pub_with_shorthand.stderr @@ -1,5 +1,5 @@ error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:13:1 + --> tests/ui/pub_with_shorthand.rs:13:1 | LL | pub(self) fn a() {} | ^^^^^^^^^ help: add it: `pub(in self)` @@ -8,19 +8,19 @@ LL | pub(self) fn a() {} = help: to override `-D warnings` add `#[allow(clippy::pub_with_shorthand)]` error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:19:5 + --> tests/ui/pub_with_shorthand.rs:19:5 | LL | pub(super) fn e() {} | ^^^^^^^^^^ help: add it: `pub(in super)` error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:20:5 + --> tests/ui/pub_with_shorthand.rs:20:5 | LL | pub(self) fn f() {} | ^^^^^^^^^ help: add it: `pub(in self)` error: usage of `pub` without `in` - --> $DIR/pub_with_shorthand.rs:21:5 + --> tests/ui/pub_with_shorthand.rs:21:5 | LL | pub(crate) fn k() {} | ^^^^^^^^^^ help: add it: `pub(in crate)` diff --git a/src/tools/clippy/tests/ui/pub_without_shorthand.stderr b/src/tools/clippy/tests/ui/pub_without_shorthand.stderr index 4fb11cb3d4ad3..e37c731732ba5 100644 --- a/src/tools/clippy/tests/ui/pub_without_shorthand.stderr +++ b/src/tools/clippy/tests/ui/pub_without_shorthand.stderr @@ -1,5 +1,5 @@ error: usage of `pub` with `in` - --> $DIR/pub_without_shorthand.rs:14:1 + --> tests/ui/pub_without_shorthand.rs:14:1 | LL | pub(in self) fn b() {} | ^^^^^^^^^^^^ help: remove it: `pub(self)` @@ -8,13 +8,13 @@ LL | pub(in self) fn b() {} = help: to override `-D warnings` add `#[allow(clippy::pub_without_shorthand)]` error: usage of `pub` with `in` - --> $DIR/pub_without_shorthand.rs:18:5 + --> tests/ui/pub_without_shorthand.rs:18:5 | LL | pub(in super) fn d() {} | ^^^^^^^^^^^^^ help: remove it: `pub(super)` error: usage of `pub` with `in` - --> $DIR/pub_without_shorthand.rs:22:5 + --> tests/ui/pub_without_shorthand.rs:22:5 | LL | pub(in crate) fn m() {} | ^^^^^^^^^^^^^ help: remove it: `pub(crate)` diff --git a/src/tools/clippy/tests/ui/question_mark.stderr b/src/tools/clippy/tests/ui/question_mark.stderr index 7b7b85d08e63c..4fcccdf5512fc 100644 --- a/src/tools/clippy/tests/ui/question_mark.stderr +++ b/src/tools/clippy/tests/ui/question_mark.stderr @@ -1,5 +1,5 @@ error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:7:5 + --> tests/ui/question_mark.rs:7:5 | LL | / if a.is_none() { LL | | return None; @@ -10,7 +10,7 @@ LL | | } = 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 + --> tests/ui/question_mark.rs:52:9 | LL | / if (self.opt).is_none() { LL | | return None; @@ -18,7 +18,7 @@ LL | | } | |_________^ help: replace it with: `(self.opt)?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:56:9 + --> tests/ui/question_mark.rs:56:9 | LL | / if self.opt.is_none() { LL | | return None @@ -26,7 +26,7 @@ LL | | } | |_________^ help: replace it with: `self.opt?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:60:17 + --> tests/ui/question_mark.rs:60:17 | LL | let _ = if self.opt.is_none() { | _________________^ @@ -37,7 +37,7 @@ LL | | }; | |_________^ help: replace it with: `Some(self.opt?)` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:66:17 + --> tests/ui/question_mark.rs:66:17 | LL | let _ = if let Some(x) = self.opt { | _________________^ @@ -48,7 +48,7 @@ LL | | }; | |_________^ help: replace it with: `self.opt?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:83:9 + --> tests/ui/question_mark.rs:83:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -56,7 +56,7 @@ LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:91:9 + --> tests/ui/question_mark.rs:91:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -64,7 +64,7 @@ LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:99:9 + --> tests/ui/question_mark.rs:99:9 | LL | / if self.opt.is_none() { LL | | return None; @@ -72,7 +72,7 @@ LL | | } | |_________^ help: replace it with: `self.opt.as_ref()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:106:26 + --> tests/ui/question_mark.rs:106:26 | LL | let v: &Vec<_> = if let Some(ref v) = self.opt { | __________________________^ @@ -83,7 +83,7 @@ LL | | }; | |_________^ help: replace it with: `self.opt.as_ref()?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:116:17 + --> tests/ui/question_mark.rs:116:17 | LL | let v = if let Some(v) = self.opt { | _________________^ @@ -94,7 +94,7 @@ LL | | }; | |_________^ help: replace it with: `self.opt?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:131:5 + --> tests/ui/question_mark.rs:131:5 | LL | / if f().is_none() { LL | | return None; @@ -102,13 +102,13 @@ LL | | } | |_____^ help: replace it with: `f()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:143:13 + --> tests/ui/question_mark.rs:143:13 | LL | let _ = if let Ok(x) = x { x } else { return x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x?` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:145:5 + --> tests/ui/question_mark.rs:145:5 | LL | / if x.is_err() { LL | | return x; @@ -116,7 +116,7 @@ LL | | } | |_____^ help: replace it with: `x?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:213:5 + --> tests/ui/question_mark.rs:213:5 | LL | / if let Err(err) = func_returning_result() { LL | | return Err(err); @@ -124,7 +124,7 @@ LL | | } | |_____^ help: replace it with: `func_returning_result()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:220:5 + --> tests/ui/question_mark.rs:220:5 | LL | / if let Err(err) = func_returning_result() { LL | | return Err(err); @@ -132,7 +132,7 @@ LL | | } | |_____^ help: replace it with: `func_returning_result()?;` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:297:13 + --> tests/ui/question_mark.rs:297:13 | LL | / if a.is_none() { LL | | return None; diff --git a/src/tools/clippy/tests/ui/question_mark_used.stderr b/src/tools/clippy/tests/ui/question_mark_used.stderr index b4e256ddb9ebe..53cb59c021667 100644 --- a/src/tools/clippy/tests/ui/question_mark_used.stderr +++ b/src/tools/clippy/tests/ui/question_mark_used.stderr @@ -1,5 +1,5 @@ error: question mark operator was used - --> $DIR/question_mark_used.rs:11:5 + --> tests/ui/question_mark_used.rs:11:5 | LL | other_function()?; | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/range.stderr b/src/tools/clippy/tests/ui/range.stderr index 78ef17b5ba79d..8c71a209700e1 100644 --- a/src/tools/clippy/tests/ui/range.stderr +++ b/src/tools/clippy/tests/ui/range.stderr @@ -1,5 +1,5 @@ error: it is more idiomatic to use `v1.iter().enumerate()` - --> $DIR/range.rs:6:14 + --> tests/ui/range.rs:6:14 | LL | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/range_contains.stderr b/src/tools/clippy/tests/ui/range_contains.stderr index 349adea2193cc..58ed1292ac7c9 100644 --- a/src/tools/clippy/tests/ui/range_contains.stderr +++ b/src/tools/clippy/tests/ui/range_contains.stderr @@ -1,5 +1,5 @@ error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:13:5 + --> tests/ui/range_contains.rs:13:5 | LL | x >= 8 && x < 12; | ^^^^^^^^^^^^^^^^ help: use: `(8..12).contains(&x)` @@ -8,121 +8,121 @@ LL | x >= 8 && x < 12; = help: to override `-D warnings` add `#[allow(clippy::manual_range_contains)]` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:14:5 + --> tests/ui/range_contains.rs:14:5 | LL | x < 42 && x >= 21; | ^^^^^^^^^^^^^^^^^ help: use: `(21..42).contains(&x)` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:15:5 + --> tests/ui/range_contains.rs:15:5 | LL | 100 > x && 1 <= x; | ^^^^^^^^^^^^^^^^^ help: use: `(1..100).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:18:5 + --> tests/ui/range_contains.rs:18:5 | LL | x >= 9 && x <= 99; | ^^^^^^^^^^^^^^^^^ help: use: `(9..=99).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:19:5 + --> tests/ui/range_contains.rs:19:5 | LL | x <= 33 && x >= 1; | ^^^^^^^^^^^^^^^^^ help: use: `(1..=33).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:20:5 + --> tests/ui/range_contains.rs:20:5 | LL | 999 >= x && 1 <= x; | ^^^^^^^^^^^^^^^^^^ help: use: `(1..=999).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:23:5 + --> tests/ui/range_contains.rs:23:5 | LL | x < 8 || x >= 12; | ^^^^^^^^^^^^^^^^ help: use: `!(8..12).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:24:5 + --> tests/ui/range_contains.rs:24:5 | LL | x >= 42 || x < 21; | ^^^^^^^^^^^^^^^^^ help: use: `!(21..42).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:25:5 + --> tests/ui/range_contains.rs:25:5 | LL | 100 <= x || 1 > x; | ^^^^^^^^^^^^^^^^^ help: use: `!(1..100).contains(&x)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:28:5 + --> tests/ui/range_contains.rs:28:5 | LL | x < 9 || x > 99; | ^^^^^^^^^^^^^^^ help: use: `!(9..=99).contains(&x)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:29:5 + --> tests/ui/range_contains.rs:29:5 | LL | x > 33 || x < 1; | ^^^^^^^^^^^^^^^ help: use: `!(1..=33).contains(&x)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:30:5 + --> tests/ui/range_contains.rs:30:5 | LL | 999 < x || 1 > x; | ^^^^^^^^^^^^^^^^ help: use: `!(1..=999).contains(&x)` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:45:5 + --> tests/ui/range_contains.rs:45:5 | LL | y >= 0. && y < 1.; | ^^^^^^^^^^^^^^^^^ help: use: `(0. ..1.).contains(&y)` error: manual `!RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:46:5 + --> tests/ui/range_contains.rs:46:5 | LL | y < 0. || y > 1.; | ^^^^^^^^^^^^^^^^ help: use: `!(0. ..=1.).contains(&y)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:49:5 + --> tests/ui/range_contains.rs:49:5 | LL | x >= -10 && x <= 10; | ^^^^^^^^^^^^^^^^^^^ help: use: `(-10..=10).contains(&x)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:51:5 + --> tests/ui/range_contains.rs:51:5 | LL | y >= -3. && y <= 3.; | ^^^^^^^^^^^^^^^^^^^ help: use: `(-3. ..=3.).contains(&y)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:56:30 + --> tests/ui/range_contains.rs:56:30 | LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&z)` error: manual `RangeInclusive::contains` implementation - --> $DIR/range_contains.rs:56:5 + --> tests/ui/range_contains.rs:56:5 | LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&x)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:57:29 + --> tests/ui/range_contains.rs:57:29 | LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10); | ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&z)` error: manual `!Range::contains` implementation - --> $DIR/range_contains.rs:57:5 + --> tests/ui/range_contains.rs:57:5 | LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10); | ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&x)` error: manual `Range::contains` implementation - --> $DIR/range_contains.rs:76:5 + --> tests/ui/range_contains.rs:76:5 | LL | x >= 8 && x < 35; | ^^^^^^^^^^^^^^^^ help: use: `(8..35).contains(&x)` 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 c5c9b145db855..0b1883bc5ff22 100644 --- a/src/tools/clippy/tests/ui/range_plus_minus_one.stderr +++ b/src/tools/clippy/tests/ui/range_plus_minus_one.stderr @@ -1,5 +1,5 @@ error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:29:14 + --> tests/ui/range_plus_minus_one.rs:29:14 | LL | for _ in 0..3 + 1 {} | ^^^^^^^^ help: use: `0..=3` @@ -8,25 +8,25 @@ LL | for _ in 0..3 + 1 {} = 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 + --> tests/ui/range_plus_minus_one.rs:32:14 | LL | for _ in 0..1 + 5 {} | ^^^^^^^^ help: use: `0..=5` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:35:14 + --> tests/ui/range_plus_minus_one.rs:35:14 | LL | for _ in 1..1 + 1 {} | ^^^^^^^^ help: use: `1..=1` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:41:14 + --> tests/ui/range_plus_minus_one.rs:41:14 | LL | for _ in 0..(1 + f()) {} | ^^^^^^^^^^^^ help: use: `0..=f()` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:45:13 + --> tests/ui/range_plus_minus_one.rs:45:13 | LL | let _ = ..=11 - 1; | ^^^^^^^^^ help: use: `..11` @@ -35,25 +35,25 @@ LL | let _ = ..=11 - 1; = 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 + --> tests/ui/range_plus_minus_one.rs:46:13 | LL | let _ = ..=(11 - 1); | ^^^^^^^^^^^ help: use: `..11` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:47:13 + --> tests/ui/range_plus_minus_one.rs:47:13 | LL | let _ = (1..11 + 1); | ^^^^^^^^^^^ help: use: `(1..=11)` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:48:13 + --> tests/ui/range_plus_minus_one.rs:48:13 | LL | let _ = (f() + 1)..(f() + 1); | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:52:14 + --> tests/ui/range_plus_minus_one.rs:52:14 | LL | for _ in 1..ONE + ONE {} | ^^^^^^^^^^^^ help: use: `1..=ONE` diff --git a/src/tools/clippy/tests/ui/rc_buffer.stderr b/src/tools/clippy/tests/ui/rc_buffer.stderr index 04080326ae0f0..922f09288bf38 100644 --- a/src/tools/clippy/tests/ui/rc_buffer.stderr +++ b/src/tools/clippy/tests/ui/rc_buffer.stderr @@ -1,5 +1,5 @@ error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:11:11 + --> tests/ui/rc_buffer.rs:11:11 | LL | bad1: Rc, | ^^^^^^^^^^ help: try: `Rc` @@ -8,43 +8,43 @@ LL | bad1: Rc, = 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 + --> tests/ui/rc_buffer.rs:12:11 | LL | bad2: Rc, | ^^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:13:11 + --> tests/ui/rc_buffer.rs:13:11 | LL | bad3: Rc>, | ^^^^^^^^^^^ help: try: `Rc<[u8]>` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:14:11 + --> tests/ui/rc_buffer.rs:14:11 | LL | bad4: Rc, | ^^^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:20:17 + --> tests/ui/rc_buffer.rs:20:17 | LL | fn func_bad1(_: Rc) {} | ^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:21:17 + --> tests/ui/rc_buffer.rs:21:17 | LL | fn func_bad2(_: Rc) {} | ^^^^^^^^^^^ help: try: `Rc` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:22:17 + --> tests/ui/rc_buffer.rs:22:17 | LL | fn func_bad3(_: Rc>) {} | ^^^^^^^^^^^ help: try: `Rc<[u8]>` error: usage of `Rc` when T is a buffer type - --> $DIR/rc_buffer.rs:23:17 + --> tests/ui/rc_buffer.rs:23:17 | LL | fn func_bad4(_: Rc) {} | ^^^^^^^^^^^^ help: try: `Rc` diff --git a/src/tools/clippy/tests/ui/rc_buffer_arc.stderr b/src/tools/clippy/tests/ui/rc_buffer_arc.stderr index 52522dd725f4f..5ef5da2f67f84 100644 --- a/src/tools/clippy/tests/ui/rc_buffer_arc.stderr +++ b/src/tools/clippy/tests/ui/rc_buffer_arc.stderr @@ -1,5 +1,5 @@ error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:10:11 + --> tests/ui/rc_buffer_arc.rs:10:11 | LL | bad1: Arc, | ^^^^^^^^^^^ help: try: `Arc` @@ -8,43 +8,43 @@ LL | bad1: Arc, = 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 + --> tests/ui/rc_buffer_arc.rs:11:11 | LL | bad2: Arc, | ^^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:12:11 + --> tests/ui/rc_buffer_arc.rs:12:11 | LL | bad3: Arc>, | ^^^^^^^^^^^^ help: try: `Arc<[u8]>` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:13:11 + --> tests/ui/rc_buffer_arc.rs:13:11 | LL | bad4: Arc, | ^^^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:19:17 + --> tests/ui/rc_buffer_arc.rs:19:17 | LL | fn func_bad1(_: Arc) {} | ^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:20:17 + --> tests/ui/rc_buffer_arc.rs:20:17 | LL | fn func_bad2(_: Arc) {} | ^^^^^^^^^^^^ help: try: `Arc` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:21:17 + --> tests/ui/rc_buffer_arc.rs:21:17 | LL | fn func_bad3(_: Arc>) {} | ^^^^^^^^^^^^ help: try: `Arc<[u8]>` error: usage of `Arc` when T is a buffer type - --> $DIR/rc_buffer_arc.rs:22:17 + --> tests/ui/rc_buffer_arc.rs:22:17 | LL | fn func_bad4(_: Arc) {} | ^^^^^^^^^^^^^ help: try: `Arc` 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 5dc4b5a10e526..1078a97542f2c 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 @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:9:13 + --> tests/ui/rc_clone_in_vec_init/arc.rs:9:13 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:19:21 + --> tests/ui/rc_clone_in_vec_init/arc.rs:19:21 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:27:13 + --> tests/ui/rc_clone_in_vec_init/arc.rs:27:13 | LL | let v = vec![ | _____________^ @@ -77,7 +77,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/arc.rs:38:14 + --> tests/ui/rc_clone_in_vec_init/arc.rs:38:14 | LL | let v1 = vec![ | ______________^ 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 e6bc6f68b3e49..702266d62d2c3 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 @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:10:13 + --> tests/ui/rc_clone_in_vec_init/rc.rs:10:13 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:20:21 + --> tests/ui/rc_clone_in_vec_init/rc.rs:20:21 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:28:13 + --> tests/ui/rc_clone_in_vec_init/rc.rs:28:13 | LL | let v = vec![ | _____________^ @@ -77,7 +77,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/rc.rs:39:14 + --> tests/ui/rc_clone_in_vec_init/rc.rs:39:14 | LL | let v1 = vec![ | ______________^ 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 25d7dae72da30..68ca2a7eb848c 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 @@ -1,5 +1,5 @@ error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:10:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:10:13 | LL | let v = vec![SyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:13:14 + --> tests/ui/rc_clone_in_vec_init/weak.rs:13:14 | LL | let v2 = vec![UnSyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:17:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:17:13 | LL | let v = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:20:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:20:13 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:30:21 + --> tests/ui/rc_clone_in_vec_init/weak.rs:30:21 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:33:22 + --> tests/ui/rc_clone_in_vec_init/weak.rs:33:22 | LL | let v2 = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:41:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:41:13 | LL | let v = vec![ | _____________^ @@ -169,7 +169,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> $DIR/weak.rs:52:14 + --> tests/ui/rc_clone_in_vec_init/weak.rs:52:14 | LL | let v1 = vec![ | ______________^ diff --git a/src/tools/clippy/tests/ui/rc_mutex.stderr b/src/tools/clippy/tests/ui/rc_mutex.stderr index 50922fb67e492..9aa18336df00c 100644 --- a/src/tools/clippy/tests/ui/rc_mutex.stderr +++ b/src/tools/clippy/tests/ui/rc_mutex.stderr @@ -1,5 +1,5 @@ error: usage of `Rc>` - --> $DIR/rc_mutex.rs:8:10 + --> tests/ui/rc_mutex.rs:8:10 | LL | foo: Rc>, | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | foo: Rc>, = help: to override `-D warnings` add `#[allow(clippy::rc_mutex)]` error: usage of `Rc>` - --> $DIR/rc_mutex.rs:27:18 + --> tests/ui/rc_mutex.rs:27:18 | LL | fn test1(foo: Rc>) {} | ^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn test1(foo: Rc>) {} = help: consider using `Rc>` or `Arc>` instead error: usage of `Rc>` - --> $DIR/rc_mutex.rs:29:15 + --> tests/ui/rc_mutex.rs:29:15 | LL | fn test2(foo: Rc>) {} | ^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn test2(foo: Rc>) {} = help: consider using `Rc>` or `Arc>` instead error: usage of `Rc>` - --> $DIR/rc_mutex.rs:31:15 + --> tests/ui/rc_mutex.rs:31:15 | LL | fn test3(foo: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/read_line_without_trim.fixed b/src/tools/clippy/tests/ui/read_line_without_trim.fixed index 03a99b17dcee6..523ad55527479 100644 --- a/src/tools/clippy/tests/ui/read_line_without_trim.fixed +++ b/src/tools/clippy/tests/ui/read_line_without_trim.fixed @@ -31,4 +31,17 @@ fn main() { std::io::stdin().read_line(&mut input).unwrap(); // this is actually ok, so don't lint here let _x = input.parse::().unwrap(); + + // comparing with string literals + let mut input = String::new(); + std::io::stdin().read_line(&mut input).unwrap(); + if input.trim_end() == "foo" { + println!("This will never ever execute!"); + } + + let mut input = String::new(); + std::io::stdin().read_line(&mut input).unwrap(); + if input.trim_end().ends_with("foo") { + println!("Neither will this"); + } } diff --git a/src/tools/clippy/tests/ui/read_line_without_trim.rs b/src/tools/clippy/tests/ui/read_line_without_trim.rs index 65510aea0fd0a..e31ff0cde61de 100644 --- a/src/tools/clippy/tests/ui/read_line_without_trim.rs +++ b/src/tools/clippy/tests/ui/read_line_without_trim.rs @@ -31,4 +31,17 @@ fn main() { std::io::stdin().read_line(&mut input).unwrap(); // this is actually ok, so don't lint here let _x = input.parse::().unwrap(); + + // comparing with string literals + let mut input = String::new(); + std::io::stdin().read_line(&mut input).unwrap(); + if input == "foo" { + println!("This will never ever execute!"); + } + + let mut input = String::new(); + std::io::stdin().read_line(&mut input).unwrap(); + if input.ends_with("foo") { + println!("Neither will this"); + } } 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 8d46e0f790781..b54229f762a32 100644 --- a/src/tools/clippy/tests/ui/read_line_without_trim.stderr +++ b/src/tools/clippy/tests/ui/read_line_without_trim.stderr @@ -1,74 +1,102 @@ -error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:12:25 +error: calling `.parse()` on a string without trimming the trailing newline character + --> tests/ui/read_line_without_trim.rs:12:25 | LL | let _x: i32 = input.parse().unwrap(); | ----- ^^^^^^^ | | | help: try: `input.trim_end()` | -note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:11:5 +note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause the checking to always fail + --> tests/ui/read_line_without_trim.rs:11:5 | 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 +error: calling `.parse()` on a string without trimming the trailing newline character + --> tests/ui/read_line_without_trim.rs:16:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^ | | | help: try: `input.trim_end()` | -note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:15:5 +note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause the checking to always fail + --> tests/ui/read_line_without_trim.rs:15:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:20:20 +error: calling `.parse()` on a string without trimming the trailing newline character + --> tests/ui/read_line_without_trim.rs:20:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^ | | | help: try: `input.trim_end()` | -note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:19:5 +note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause the checking to always fail + --> tests/ui/read_line_without_trim.rs:19:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:24:20 +error: calling `.parse()` on a string without trimming the trailing newline character + --> tests/ui/read_line_without_trim.rs:24:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^ | | | help: try: `input.trim_end()` | -note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:23:5 +note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause the checking to always fail + --> tests/ui/read_line_without_trim.rs:23:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: calling `.parse()` without trimming the trailing newline character - --> $DIR/read_line_without_trim.rs:28:20 +error: calling `.parse()` on a string without trimming the trailing newline character + --> tests/ui/read_line_without_trim.rs:28:20 | LL | let _x = input.parse::().unwrap(); | ----- ^^^^^^^^^^^^^^^ | | | help: try: `input.trim_end()` | -note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause `.parse()` to fail - --> $DIR/read_line_without_trim.rs:27:5 +note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause the checking to always fail + --> tests/ui/read_line_without_trim.rs:27:5 | LL | std::io::stdin().read_line(&mut input).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +error: comparing a string literal without trimming the trailing newline character + --> tests/ui/read_line_without_trim.rs:38:8 + | +LL | if input == "foo" { + | -----^^^^^^^^^ + | | + | help: try: `input.trim_end()` + | +note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause the comparison to always fail + --> tests/ui/read_line_without_trim.rs:37:5 + | +LL | std::io::stdin().read_line(&mut input).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: checking the end of a string without trimming the trailing newline character + --> tests/ui/read_line_without_trim.rs:44:8 + | +LL | if input.ends_with("foo") { + | -----^^^^^^^^^^^^^^^^^ + | | + | help: try: `input.trim_end()` + | +note: call to `.read_line()` here, which leaves a trailing newline character in the buffer, which in turn will cause the parsing to always fail + --> tests/ui/read_line_without_trim.rs:43:5 + | +LL | std::io::stdin().read_line(&mut input).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors 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 e85aa051c34bc..e2356f1cb56be 100644 --- a/src/tools/clippy/tests/ui/read_zero_byte_vec.stderr +++ b/src/tools/clippy/tests/ui/read_zero_byte_vec.stderr @@ -1,5 +1,5 @@ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:21:5 + --> tests/ui/read_zero_byte_vec.rs:21:5 | LL | f.read_exact(&mut data).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data.resize(20, 0); f.read_exact(&mut data)` @@ -8,61 +8,61 @@ LL | f.read_exact(&mut data).unwrap(); = 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 + --> tests/ui/read_zero_byte_vec.rs:27:5 | LL | f.read_exact(&mut data2)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data2.resize(cap, 0); f.read_exact(&mut data2)` error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:32:5 + --> tests/ui/read_zero_byte_vec.rs:32:5 | LL | f.read_exact(&mut data3)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:37:13 + --> tests/ui/read_zero_byte_vec.rs:37:13 | LL | let _ = f.read(&mut data4)?; | ^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:43:9 + --> tests/ui/read_zero_byte_vec.rs:43:9 | LL | f.read(&mut data5) | ^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:50:9 + --> tests/ui/read_zero_byte_vec.rs:50:9 | LL | f.read(&mut data6) | ^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:84:9 + --> tests/ui/read_zero_byte_vec.rs:84:9 | LL | f.read(&mut v)?; | ^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:94:5 + --> tests/ui/read_zero_byte_vec.rs:94:5 | LL | r.read(&mut data).await.unwrap(); | ^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:99:5 + --> tests/ui/read_zero_byte_vec.rs:99:5 | LL | r.read_exact(&mut data2).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:106:5 + --> tests/ui/read_zero_byte_vec.rs:106:5 | LL | r.read(&mut data).await.unwrap(); | ^^^^^^^^^^^^^^^^^ error: reading zero byte data to `Vec` - --> $DIR/read_zero_byte_vec.rs:111:5 + --> tests/ui/read_zero_byte_vec.rs:111:5 | LL | r.read_exact(&mut data2).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/readonly_write_lock.stderr b/src/tools/clippy/tests/ui/readonly_write_lock.stderr index b4a093ce9c93f..6b1ef3c4720f0 100644 --- a/src/tools/clippy/tests/ui/readonly_write_lock.stderr +++ b/src/tools/clippy/tests/ui/readonly_write_lock.stderr @@ -1,5 +1,5 @@ error: this write lock is used only for reading - --> $DIR/readonly_write_lock.rs:16:22 + --> tests/ui/readonly_write_lock.rs:16:22 | LL | let writer = lock.write().unwrap(); | ^^^^^^^^^^^^ help: consider using a read lock instead: `lock.read()` @@ -8,7 +8,7 @@ LL | let writer = lock.write().unwrap(); = 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 + --> tests/ui/readonly_write_lock.rs:23:22 | LL | let writer = lock.write().unwrap(); | ^^^^^^^^^^^^ help: consider using a read lock instead: `lock.read()` diff --git a/src/tools/clippy/tests/ui/recursive_format_impl.stderr b/src/tools/clippy/tests/ui/recursive_format_impl.stderr index adb16f44a999e..f80aff01eb53e 100644 --- a/src/tools/clippy/tests/ui/recursive_format_impl.stderr +++ b/src/tools/clippy/tests/ui/recursive_format_impl.stderr @@ -1,5 +1,5 @@ error: using `self.to_string` in `fmt::Display` implementation will cause infinite recursion - --> $DIR/recursive_format_impl.rs:31:25 + --> tests/ui/recursive_format_impl.rs:31:25 | LL | write!(f, "{}", self.to_string()) | ^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | write!(f, "{}", self.to_string()) = 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 + --> tests/ui/recursive_format_impl.rs:77:9 | LL | write!(f, "{}", self) | ^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | write!(f, "{}", self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:87:9 + --> tests/ui/recursive_format_impl.rs:87:9 | LL | write!(f, "{}", &self) | ^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | write!(f, "{}", &self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Debug` in `impl Debug` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:94:9 + --> tests/ui/recursive_format_impl.rs:94:9 | LL | write!(f, "{:?}", &self) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | write!(f, "{:?}", &self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:104:9 + --> tests/ui/recursive_format_impl.rs:104:9 | LL | write!(f, "{}", &&&self) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | write!(f, "{}", &&&self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:179:9 + --> tests/ui/recursive_format_impl.rs:179:9 | LL | write!(f, "{}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | write!(f, "{}", &*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Debug` in `impl Debug` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:186:9 + --> tests/ui/recursive_format_impl.rs:186:9 | LL | write!(f, "{:?}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | write!(f, "{:?}", &*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:203:9 + --> tests/ui/recursive_format_impl.rs:203:9 | LL | write!(f, "{}", *self) | ^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | write!(f, "{}", *self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:220:9 + --> tests/ui/recursive_format_impl.rs:220:9 | LL | write!(f, "{}", **&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | write!(f, "{}", **&&*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> $DIR/recursive_format_impl.rs:237:9 + --> tests/ui/recursive_format_impl.rs:237:9 | LL | write!(f, "{}", &&**&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/redundant_allocation.stderr b/src/tools/clippy/tests/ui/redundant_allocation.stderr index d72f6b202ec23..8a043013e07a9 100644 --- a/src/tools/clippy/tests/ui/redundant_allocation.stderr +++ b/src/tools/clippy/tests/ui/redundant_allocation.stderr @@ -1,5 +1,5 @@ error: usage of `Box>` - --> $DIR/redundant_allocation.rs:16:30 + --> tests/ui/redundant_allocation.rs:16:30 | LL | pub fn box_test6(foo: Box>) {} | ^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | pub fn box_test6(foo: Box>) {} = help: to override `-D warnings` add `#[allow(clippy::redundant_allocation)]` error: usage of `Box>` - --> $DIR/redundant_allocation.rs:20:30 + --> tests/ui/redundant_allocation.rs:20:30 | LL | pub fn box_test7(foo: Box>) {} | ^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | pub fn box_test7(foo: Box>) {} = help: consider using just `Box` or `Arc` error: usage of `Box>>` - --> $DIR/redundant_allocation.rs:24:27 + --> tests/ui/redundant_allocation.rs:24:27 | LL | pub fn box_test8() -> Box>> { | ^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | pub fn box_test8() -> Box>> { = help: consider using just `Box>` or `Rc>` error: usage of `Box>` - --> $DIR/redundant_allocation.rs:30:30 + --> tests/ui/redundant_allocation.rs:30:30 | LL | pub fn box_test9(foo: Box>) -> Box>> { | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = help: consider using just `Box` or `Arc` error: usage of `Box>>` - --> $DIR/redundant_allocation.rs:30:46 + --> tests/ui/redundant_allocation.rs:30:46 | LL | pub fn box_test9(foo: Box>) -> Box>> { | ^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = help: consider using just `Box>` or `Arc>` error: usage of `Rc>` - --> $DIR/redundant_allocation.rs:45:24 + --> tests/ui/redundant_allocation.rs:45:24 | LL | pub fn rc_test5(a: Rc>) {} | ^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | pub fn rc_test5(a: Rc>) {} = help: consider using just `Rc` or `Box` error: usage of `Rc>` - --> $DIR/redundant_allocation.rs:49:24 + --> tests/ui/redundant_allocation.rs:49:24 | LL | pub fn rc_test7(a: Rc>) {} | ^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | pub fn rc_test7(a: Rc>) {} = help: consider using just `Rc` or `Arc` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:53:26 + --> tests/ui/redundant_allocation.rs:53:26 | LL | pub fn rc_test8() -> Rc>> { | ^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | pub fn rc_test8() -> Rc>> { = help: consider using just `Rc>` or `Box>` error: usage of `Rc>` - --> $DIR/redundant_allocation.rs:59:29 + --> tests/ui/redundant_allocation.rs:59:29 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { | ^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = help: consider using just `Rc` or `Arc` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:59:44 + --> tests/ui/redundant_allocation.rs:59:44 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { | ^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = help: consider using just `Rc>` or `Arc>` error: usage of `Arc>` - --> $DIR/redundant_allocation.rs:74:25 + --> tests/ui/redundant_allocation.rs:74:25 | LL | pub fn arc_test5(a: Arc>) {} | ^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | pub fn arc_test5(a: Arc>) {} = help: consider using just `Arc` or `Box` error: usage of `Arc>` - --> $DIR/redundant_allocation.rs:78:25 + --> tests/ui/redundant_allocation.rs:78:25 | LL | pub fn arc_test6(a: Arc>) {} | ^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | pub fn arc_test6(a: Arc>) {} = help: consider using just `Arc` or `Rc` error: usage of `Arc>>` - --> $DIR/redundant_allocation.rs:82:27 + --> tests/ui/redundant_allocation.rs:82:27 | LL | pub fn arc_test8() -> Arc>> { | ^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | pub fn arc_test8() -> Arc>> { = help: consider using just `Arc>` or `Box>` error: usage of `Arc>` - --> $DIR/redundant_allocation.rs:88:30 + --> tests/ui/redundant_allocation.rs:88:30 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { | ^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = help: consider using just `Arc` or `Rc` error: usage of `Arc>>` - --> $DIR/redundant_allocation.rs:88:45 + --> tests/ui/redundant_allocation.rs:88:45 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { | ^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = help: consider using just `Arc>` or `Rc>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:114:27 + --> tests/ui/redundant_allocation.rs:114:27 | LL | pub fn test_rc_box(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | pub fn test_rc_box(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:148:31 + --> tests/ui/redundant_allocation.rs:148:31 | LL | pub fn test_rc_box_str(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL | pub fn test_rc_box_str(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:151:33 + --> tests/ui/redundant_allocation.rs:151:33 | LL | pub fn test_rc_box_slice(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | pub fn test_rc_box_slice(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:154:32 + --> tests/ui/redundant_allocation.rs:154:32 | LL | pub fn test_rc_box_path(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^ @@ -172,7 +172,7 @@ LL | pub fn test_rc_box_path(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> $DIR/redundant_allocation.rs:157:34 + --> tests/ui/redundant_allocation.rs:157:34 | LL | pub fn test_rc_box_custom(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr b/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr index 603600f30227d..34a1a21bdadcd 100644 --- a/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr +++ b/src/tools/clippy/tests/ui/redundant_allocation_fixable.stderr @@ -1,5 +1,5 @@ error: usage of `Box<&T>` - --> $DIR/redundant_allocation_fixable.rs:23:30 + --> tests/ui/redundant_allocation_fixable.rs:23:30 | LL | pub fn box_test1(foo: Box<&T>) {} | ^^^^^^^ help: try: `&T` @@ -9,7 +9,7 @@ LL | pub fn box_test1(foo: Box<&T>) {} = help: to override `-D warnings` add `#[allow(clippy::redundant_allocation)]` error: usage of `Box<&MyStruct>` - --> $DIR/redundant_allocation_fixable.rs:25:27 + --> tests/ui/redundant_allocation_fixable.rs:25:27 | LL | pub fn box_test2(foo: Box<&MyStruct>) {} | ^^^^^^^^^^^^^^ help: try: `&MyStruct` @@ -17,7 +17,7 @@ LL | pub fn box_test2(foo: Box<&MyStruct>) {} = note: `&MyStruct` is already a pointer, `Box<&MyStruct>` allocates a pointer on the heap error: usage of `Box<&MyEnum>` - --> $DIR/redundant_allocation_fixable.rs:27:27 + --> tests/ui/redundant_allocation_fixable.rs:27:27 | LL | pub fn box_test3(foo: Box<&MyEnum>) {} | ^^^^^^^^^^^^ help: try: `&MyEnum` @@ -25,7 +25,7 @@ LL | pub fn box_test3(foo: Box<&MyEnum>) {} = note: `&MyEnum` is already a pointer, `Box<&MyEnum>` allocates a pointer on the heap error: usage of `Box>` - --> $DIR/redundant_allocation_fixable.rs:31:30 + --> tests/ui/redundant_allocation_fixable.rs:31:30 | LL | pub fn box_test5(foo: Box>) {} | ^^^^^^^^^^^ help: try: `Box` @@ -33,7 +33,7 @@ LL | pub fn box_test5(foo: Box>) {} = note: `Box` is already on the heap, `Box>` makes an extra allocation error: usage of `Rc<&T>` - --> $DIR/redundant_allocation_fixable.rs:40:29 + --> tests/ui/redundant_allocation_fixable.rs:40:29 | LL | pub fn rc_test1(foo: Rc<&T>) {} | ^^^^^^ help: try: `&T` @@ -41,7 +41,7 @@ LL | pub fn rc_test1(foo: Rc<&T>) {} = note: `&T` is already a pointer, `Rc<&T>` allocates a pointer on the heap error: usage of `Rc<&MyStruct>` - --> $DIR/redundant_allocation_fixable.rs:42:26 + --> tests/ui/redundant_allocation_fixable.rs:42:26 | LL | pub fn rc_test2(foo: Rc<&MyStruct>) {} | ^^^^^^^^^^^^^ help: try: `&MyStruct` @@ -49,7 +49,7 @@ LL | pub fn rc_test2(foo: Rc<&MyStruct>) {} = note: `&MyStruct` is already a pointer, `Rc<&MyStruct>` allocates a pointer on the heap error: usage of `Rc<&MyEnum>` - --> $DIR/redundant_allocation_fixable.rs:44:26 + --> tests/ui/redundant_allocation_fixable.rs:44:26 | LL | pub fn rc_test3(foo: Rc<&MyEnum>) {} | ^^^^^^^^^^^ help: try: `&MyEnum` @@ -57,7 +57,7 @@ LL | pub fn rc_test3(foo: Rc<&MyEnum>) {} = note: `&MyEnum` is already a pointer, `Rc<&MyEnum>` allocates a pointer on the heap error: usage of `Rc>` - --> $DIR/redundant_allocation_fixable.rs:48:24 + --> tests/ui/redundant_allocation_fixable.rs:48:24 | LL | pub fn rc_test6(a: Rc>) {} | ^^^^^^^^^^^^ help: try: `Rc` @@ -65,7 +65,7 @@ LL | pub fn rc_test6(a: Rc>) {} = note: `Rc` is already on the heap, `Rc>` makes an extra allocation error: usage of `Arc<&T>` - --> $DIR/redundant_allocation_fixable.rs:57:30 + --> tests/ui/redundant_allocation_fixable.rs:57:30 | LL | pub fn arc_test1(foo: Arc<&T>) {} | ^^^^^^^ help: try: `&T` @@ -73,7 +73,7 @@ LL | pub fn arc_test1(foo: Arc<&T>) {} = note: `&T` is already a pointer, `Arc<&T>` allocates a pointer on the heap error: usage of `Arc<&MyStruct>` - --> $DIR/redundant_allocation_fixable.rs:59:27 + --> tests/ui/redundant_allocation_fixable.rs:59:27 | LL | pub fn arc_test2(foo: Arc<&MyStruct>) {} | ^^^^^^^^^^^^^^ help: try: `&MyStruct` @@ -81,7 +81,7 @@ LL | pub fn arc_test2(foo: Arc<&MyStruct>) {} = note: `&MyStruct` is already a pointer, `Arc<&MyStruct>` allocates a pointer on the heap error: usage of `Arc<&MyEnum>` - --> $DIR/redundant_allocation_fixable.rs:61:27 + --> tests/ui/redundant_allocation_fixable.rs:61:27 | LL | pub fn arc_test3(foo: Arc<&MyEnum>) {} | ^^^^^^^^^^^^ help: try: `&MyEnum` @@ -89,7 +89,7 @@ LL | pub fn arc_test3(foo: Arc<&MyEnum>) {} = note: `&MyEnum` is already a pointer, `Arc<&MyEnum>` allocates a pointer on the heap error: usage of `Arc>` - --> $DIR/redundant_allocation_fixable.rs:65:25 + --> tests/ui/redundant_allocation_fixable.rs:65:25 | LL | pub fn arc_test7(a: Arc>) {} | ^^^^^^^^^^^^^^ help: try: `Arc` diff --git a/src/tools/clippy/tests/ui/redundant_as_str.stderr b/src/tools/clippy/tests/ui/redundant_as_str.stderr index 0ea42a94a81ed..f086de5fedebb 100644 --- a/src/tools/clippy/tests/ui/redundant_as_str.stderr +++ b/src/tools/clippy/tests/ui/redundant_as_str.stderr @@ -1,5 +1,5 @@ error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too - --> $DIR/redundant_as_str.rs:7:29 + --> tests/ui/redundant_as_str.rs:7:29 | LL | let _redundant = string.as_str().as_bytes(); | ^^^^^^^^^^^^^^^^^ help: try: `as_bytes` @@ -8,7 +8,7 @@ LL | let _redundant = string.as_str().as_bytes(); = help: to override `-D warnings` add `#[allow(clippy::redundant_as_str)]` error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too - --> $DIR/redundant_as_str.rs:8:29 + --> tests/ui/redundant_as_str.rs:8:29 | LL | let _redundant = string.as_str().is_empty(); | ^^^^^^^^^^^^^^^^^ help: try: `is_empty` diff --git a/src/tools/clippy/tests/ui/redundant_async_block.stderr b/src/tools/clippy/tests/ui/redundant_async_block.stderr index adb44d7a62ef4..c6a5e2f28adae 100644 --- a/src/tools/clippy/tests/ui/redundant_async_block.stderr +++ b/src/tools/clippy/tests/ui/redundant_async_block.stderr @@ -1,5 +1,5 @@ error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:13:13 + --> tests/ui/redundant_async_block.rs:13:13 | LL | let x = async { f.await }; | ^^^^^^^^^^^^^^^^^ help: you can reduce it to: `f` @@ -8,49 +8,49 @@ LL | let x = async { f.await }; = 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 + --> tests/ui/redundant_async_block.rs:20:16 | LL | let fut2 = async { fut1.await }; | ^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut1` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:24:16 + --> tests/ui/redundant_async_block.rs:24:16 | LL | let fut2 = async move { fut1.await }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut1` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:27:15 + --> tests/ui/redundant_async_block.rs:27:15 | LL | let fut = async { async { 42 }.await }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { 42 }` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:43:5 + --> tests/ui/redundant_async_block.rs:43:5 | LL | async move { fut.await } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:56:5 + --> tests/ui/redundant_async_block.rs:56:5 | LL | async move { fut.await } | ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `fut` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:61:5 + --> tests/ui/redundant_async_block.rs:61:5 | LL | async { f.await } | ^^^^^^^^^^^^^^^^^ help: you can reduce it to: `f` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:84:5 + --> tests/ui/redundant_async_block.rs:84:5 | LL | async { async { f().await + 1 }.await } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { f().await + 1 }` error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:147:13 + --> tests/ui/redundant_async_block.rs:147:13 | LL | async { async { 42 }.await } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { 42 }` @@ -61,7 +61,7 @@ LL | mac!() = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: this async expression only awaits a single future - --> $DIR/redundant_async_block.rs:167:13 + --> tests/ui/redundant_async_block.rs:167:13 | LL | async { async { $e }.await } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `async { $e }` 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 3a44636fc78ef..012ba550ca113 100644 --- a/src/tools/clippy/tests/ui/redundant_at_rest_pattern.stderr +++ b/src/tools/clippy/tests/ui/redundant_at_rest_pattern.stderr @@ -1,5 +1,5 @@ error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:9:12 + --> tests/ui/redundant_at_rest_pattern.rs:9:12 | LL | if let [a @ ..] = [()] {} | ^^^^^^^^ help: this is better represented with just the binding: `a` @@ -8,31 +8,31 @@ LL | if let [a @ ..] = [()] {} = 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 + --> tests/ui/redundant_at_rest_pattern.rs:10:12 | LL | if let [ref a @ ..] = [()] {} | ^^^^^^^^^^^^ help: this is better represented with just the binding: `ref a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:11:12 + --> tests/ui/redundant_at_rest_pattern.rs:11:12 | LL | if let [mut a @ ..] = [()] {} | ^^^^^^^^^^^^ help: this is better represented with just the binding: `mut a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:12:12 + --> tests/ui/redundant_at_rest_pattern.rs:12:12 | LL | if let [ref mut a @ ..] = [()] {} | ^^^^^^^^^^^^^^^^ help: this is better represented with just the binding: `ref mut a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:14:12 + --> tests/ui/redundant_at_rest_pattern.rs:14:12 | LL | if let [a @ ..] = &*v {} | ^^^^^^^^ help: this is better represented with just the binding: `a` error: using a rest pattern to bind an entire slice to a local - --> $DIR/redundant_at_rest_pattern.rs:16:12 + --> tests/ui/redundant_at_rest_pattern.rs:16:12 | LL | if let [a @ ..] = s {} | ^^^^^^^^ help: this is better represented with just the binding: `a` diff --git a/src/tools/clippy/tests/ui/redundant_clone.stderr b/src/tools/clippy/tests/ui/redundant_clone.stderr index 4115fcf21228b..3c37288f55078 100644 --- a/src/tools/clippy/tests/ui/redundant_clone.stderr +++ b/src/tools/clippy/tests/ui/redundant_clone.stderr @@ -1,11 +1,11 @@ error: redundant clone - --> $DIR/redundant_clone.rs:15:42 + --> tests/ui/redundant_clone.rs:15:42 | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:15:14 + --> tests/ui/redundant_clone.rs:15:14 | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,169 +13,169 @@ LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: redundant clone - --> $DIR/redundant_clone.rs:18:15 + --> tests/ui/redundant_clone.rs:18:15 | LL | let _s = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:18:14 + --> tests/ui/redundant_clone.rs:18:14 | LL | let _s = s.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:21:15 + --> tests/ui/redundant_clone.rs:21:15 | LL | let _s = s.to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:21:14 + --> tests/ui/redundant_clone.rs:21:14 | LL | let _s = s.to_string(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:24:15 + --> tests/ui/redundant_clone.rs:24:15 | LL | let _s = s.to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:24:14 + --> tests/ui/redundant_clone.rs:24:14 | LL | let _s = s.to_owned(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:26:42 + --> tests/ui/redundant_clone.rs:26:42 | LL | let _s = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:26:14 + --> tests/ui/redundant_clone.rs:26:14 | LL | let _s = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:28:42 + --> tests/ui/redundant_clone.rs:28:42 | LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:28:14 + --> tests/ui/redundant_clone.rs:28:14 | LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:30:29 + --> tests/ui/redundant_clone.rs:30:29 | LL | let _s = OsString::new().to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:30:14 + --> tests/ui/redundant_clone.rs:30:14 | LL | let _s = OsString::new().to_owned(); | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:32:29 + --> tests/ui/redundant_clone.rs:32:29 | LL | let _s = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:32:14 + --> tests/ui/redundant_clone.rs:32:14 | LL | let _s = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:43:19 + --> tests/ui/redundant_clone.rs:43:19 | LL | let _t = tup.0.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:43:14 + --> tests/ui/redundant_clone.rs:43:14 | LL | let _t = tup.0.clone(); | ^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:75:25 + --> tests/ui/redundant_clone.rs:75:25 | LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:75:24 + --> tests/ui/redundant_clone.rs:75:24 | LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } | ^ error: redundant clone - --> $DIR/redundant_clone.rs:132:15 + --> tests/ui/redundant_clone.rs:132:15 | LL | let _s = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:132:14 + --> tests/ui/redundant_clone.rs:132:14 | LL | let _s = s.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:133:15 + --> tests/ui/redundant_clone.rs:133:15 | LL | let _t = t.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:133:14 + --> tests/ui/redundant_clone.rs:133:14 | LL | let _t = t.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:143:19 + --> tests/ui/redundant_clone.rs:143:19 | LL | let _f = f.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:143:18 + --> tests/ui/redundant_clone.rs:143:18 | LL | let _f = f.clone(); | ^ error: redundant clone - --> $DIR/redundant_clone.rs:155:14 + --> tests/ui/redundant_clone.rs:155:14 | LL | let y = x.clone().join("matthias"); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated - --> $DIR/redundant_clone.rs:155:13 + --> tests/ui/redundant_clone.rs:155:13 | LL | let y = x.clone().join("matthias"); | ^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:209:11 + --> tests/ui/redundant_clone.rs:209:11 | LL | foo(&x.clone(), move || { | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:209:10 + --> tests/ui/redundant_clone.rs:209:10 | LL | foo(&x.clone(), move || { | ^ 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 be7a981dc27b8..038144a5d6134 100644 --- a/src/tools/clippy/tests/ui/redundant_closure_call_early.stderr +++ b/src/tools/clippy/tests/ui/redundant_closure_call_early.stderr @@ -1,5 +1,5 @@ error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_early.rs:9:17 + --> tests/ui/redundant_closure_call_early.rs:9:17 | LL | let mut k = (|m| m + 1)(i); | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let mut k = (|m| m + 1)(i); = 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 + --> tests/ui/redundant_closure_call_early.rs:14:9 | LL | k = (|a, b| a * b)(1, 5); | ^^^^^^^^^^^^^^^^^^^^ 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 028d383ad3546..000d81f811f10 100644 --- a/src/tools/clippy/tests/ui/redundant_closure_call_fixable.stderr +++ b/src/tools/clippy/tests/ui/redundant_closure_call_fixable.stderr @@ -1,5 +1,5 @@ error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:16:13 + --> tests/ui/redundant_closure_call_fixable.rs:16:13 | LL | let a = (|| 42)(); | ^^^^^^^^^ help: try doing something like: `42` @@ -8,7 +8,7 @@ LL | let a = (|| 42)(); = 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 + --> tests/ui/redundant_closure_call_fixable.rs:17:13 | LL | let b = (async || { | _____________^ @@ -28,7 +28,7 @@ LL ~ }; | error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:22:13 + --> tests/ui/redundant_closure_call_fixable.rs:22:13 | LL | let c = (|| { | _____________^ @@ -48,13 +48,13 @@ LL ~ }; | error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:27:13 + --> tests/ui/redundant_closure_call_fixable.rs:27:13 | LL | let d = (async || something().await)(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `async { something().await }` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:36:13 + --> tests/ui/redundant_closure_call_fixable.rs:36:13 | LL | (|| m!())() | ^^^^^^^^^^^ help: try doing something like: `m!()` @@ -65,7 +65,7 @@ LL | m2!(); = note: this error originates in the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:31:13 + --> tests/ui/redundant_closure_call_fixable.rs:31:13 | LL | (|| 0)() | ^^^^^^^^ help: try doing something like: `0` @@ -76,67 +76,67 @@ LL | m2!(); = note: this error originates in the macro `m` which comes from the expansion of the macro `m2` (in Nightly builds, run with -Z macro-backtrace for more info) error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:44:16 + --> tests/ui/redundant_closure_call_fixable.rs:44:16 | LL | assert_eq!((|| || 43)()(), 42); | ^^^^^^^^^^^^^^ help: try doing something like: `43` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:53:10 + --> tests/ui/redundant_closure_call_fixable.rs:53:10 | LL | dbg!((|| 42)()); | ^^^^^^^^^ help: try doing something like: `42` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:56:13 + --> tests/ui/redundant_closure_call_fixable.rs:56:13 | LL | let a = (|| || || 123)(); | ^^^^^^^^^^^^^^^^ help: try doing something like: `(|| || 123)` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:60:13 + --> tests/ui/redundant_closure_call_fixable.rs:60:13 | LL | let a = (|| || || || async || 1)()()()()(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `async { 1 }` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:69:13 + --> tests/ui/redundant_closure_call_fixable.rs:69:13 | LL | let a = (|| echo!(|| echo!(|| 1)))()()(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `1` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:71:13 + --> tests/ui/redundant_closure_call_fixable.rs:71:13 | LL | let a = (|| echo!((|| 123)))()(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `123` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:84:11 + --> tests/ui/redundant_closure_call_fixable.rs:84:11 | LL | bar()((|| || 42)()(), 5); | ^^^^^^^^^^^^^^ help: try doing something like: `42` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:85:9 + --> tests/ui/redundant_closure_call_fixable.rs:85:9 | LL | foo((|| || 42)()(), 5); | ^^^^^^^^^^^^^^ help: try doing something like: `42` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:89:5 + --> tests/ui/redundant_closure_call_fixable.rs:89:5 | LL | (|| async {})().await; | ^^^^^^^^^^^^^^^ help: try doing something like: `async {}` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:98:18 + --> tests/ui/redundant_closure_call_fixable.rs:98:18 | LL | spawn_on((|| async move {})()); | ^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `async move {}` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_fixable.rs:103:28 + --> tests/ui/redundant_closure_call_fixable.rs:103:28 | LL | std::convert::identity((|| 13_i32 + 36_i32)()).leading_zeros(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `13_i32 + 36_i32` 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 a89bfc7703de4..023e766a5d2b5 100644 --- a/src/tools/clippy/tests/ui/redundant_closure_call_late.stderr +++ b/src/tools/clippy/tests/ui/redundant_closure_call_late.stderr @@ -1,5 +1,5 @@ error: closure called just once immediately after it was declared - --> $DIR/redundant_closure_call_late.rs:16:5 + --> tests/ui/redundant_closure_call_late.rs:16:5 | LL | i = redun_closure(); | ^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | i = redun_closure(); = 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 + --> tests/ui/redundant_closure_call_late.rs:22:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ error: closure called just once immediately after it was declared - --> $DIR/redundant_closure_call_late.rs:25:5 + --> tests/ui/redundant_closure_call_late.rs:25:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/redundant_else.stderr b/src/tools/clippy/tests/ui/redundant_else.stderr index af33e05a608f3..b649a210b5fa6 100644 --- a/src/tools/clippy/tests/ui/redundant_else.stderr +++ b/src/tools/clippy/tests/ui/redundant_else.stderr @@ -1,5 +1,5 @@ error: redundant else block - --> $DIR/redundant_else.rs:10:16 + --> tests/ui/redundant_else.rs:10:16 | LL | } else { | ________________^ @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::redundant_else)]` error: redundant else block - --> $DIR/redundant_else.rs:18:16 + --> tests/ui/redundant_else.rs:18:16 | LL | } else { | ________________^ @@ -25,7 +25,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:28:16 + --> tests/ui/redundant_else.rs:28:16 | LL | } else { | ________________^ @@ -37,7 +37,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:38:12 + --> tests/ui/redundant_else.rs:38:12 | LL | } else { | ____________^ @@ -49,7 +49,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:46:16 + --> tests/ui/redundant_else.rs:46:16 | LL | } else { | ________________^ @@ -61,7 +61,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:57:16 + --> tests/ui/redundant_else.rs:57:16 | LL | } else { | ________________^ @@ -73,7 +73,7 @@ LL | | } = help: remove the `else` block and move the contents out error: redundant else block - --> $DIR/redundant_else.rs:67:16 + --> tests/ui/redundant_else.rs:67:16 | LL | } else { | ________________^ diff --git a/src/tools/clippy/tests/ui/redundant_field_names.stderr b/src/tools/clippy/tests/ui/redundant_field_names.stderr index 6eb1cc7531928..5323473620762 100644 --- a/src/tools/clippy/tests/ui/redundant_field_names.stderr +++ b/src/tools/clippy/tests/ui/redundant_field_names.stderr @@ -1,5 +1,5 @@ error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:33:9 + --> tests/ui/redundant_field_names.rs:33:9 | LL | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` @@ -8,43 +8,43 @@ LL | gender: gender, = 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 + --> tests/ui/redundant_field_names.rs:34:9 | LL | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:55:25 + --> tests/ui/redundant_field_names.rs:55:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:56:23 + --> tests/ui/redundant_field_names.rs:56:23 | LL | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:57:21 + --> tests/ui/redundant_field_names.rs:57:21 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:57:35 + --> tests/ui/redundant_field_names.rs:57:35 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:59:32 + --> tests/ui/redundant_field_names.rs:59:32 | LL | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:88:25 + --> tests/ui/redundant_field_names.rs:88:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` diff --git a/src/tools/clippy/tests/ui/redundant_guards.fixed b/src/tools/clippy/tests/ui/redundant_guards.fixed index aef26ef225c90..ded91e0837699 100644 --- a/src/tools/clippy/tests/ui/redundant_guards.fixed +++ b/src/tools/clippy/tests/ui/redundant_guards.fixed @@ -1,6 +1,6 @@ //@aux-build:proc_macros.rs #![feature(if_let_guard)] -#![allow(clippy::no_effect, unused)] +#![allow(clippy::no_effect, unused, clippy::single_match)] #![warn(clippy::redundant_guards)] #[macro_use] @@ -16,6 +16,7 @@ struct C(u32, u32); #[derive(PartialEq)] struct FloatWrapper(f32); + fn issue11304() { match 0.1 { x if x == 0.0 => todo!(), @@ -117,6 +118,14 @@ fn h(v: Option) { }; } +fn negative_literal(i: i32) { + match i { + -1 => {}, + 1 => {}, + _ => {}, + } +} + // Do not lint fn f(s: Option) { @@ -250,3 +259,49 @@ fn issue11807() { _ => {}, } } + +mod issue12243 { + pub const fn const_fn(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_fn(x: &str) { + match x { + "" => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + + struct Bar; + + impl Bar { + pub const fn const_bar(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_bar(x: &str) { + match x { + "" => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + } + + static FOO: () = { + match "" { + // Shouldn't lint. + x if x.is_empty() => {}, + _ => {}, + } + }; +} diff --git a/src/tools/clippy/tests/ui/redundant_guards.rs b/src/tools/clippy/tests/ui/redundant_guards.rs index 5d476f5b04035..2aaa2ace3982e 100644 --- a/src/tools/clippy/tests/ui/redundant_guards.rs +++ b/src/tools/clippy/tests/ui/redundant_guards.rs @@ -1,6 +1,6 @@ //@aux-build:proc_macros.rs #![feature(if_let_guard)] -#![allow(clippy::no_effect, unused)] +#![allow(clippy::no_effect, unused, clippy::single_match)] #![warn(clippy::redundant_guards)] #[macro_use] @@ -16,6 +16,7 @@ struct C(u32, u32); #[derive(PartialEq)] struct FloatWrapper(f32); + fn issue11304() { match 0.1 { x if x == 0.0 => todo!(), @@ -117,6 +118,14 @@ fn h(v: Option) { }; } +fn negative_literal(i: i32) { + match i { + i if i == -1 => {}, + i if i == 1 => {}, + _ => {}, + } +} + // Do not lint fn f(s: Option) { @@ -250,3 +259,49 @@ fn issue11807() { _ => {}, } } + +mod issue12243 { + pub const fn const_fn(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_fn(x: &str) { + match x { + y if y.is_empty() => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + + struct Bar; + + impl Bar { + pub const fn const_bar(x: &str) { + match x { + // Shouldn't lint. + y if y.is_empty() => {}, + _ => {}, + } + } + + pub fn non_const_bar(x: &str) { + match x { + y if y.is_empty() => {}, + //~^ ERROR: redundant guard + _ => {}, + } + } + } + + static FOO: () = { + match "" { + // Shouldn't lint. + x if x.is_empty() => {}, + _ => {}, + } + }; +} diff --git a/src/tools/clippy/tests/ui/redundant_guards.stderr b/src/tools/clippy/tests/ui/redundant_guards.stderr index f78d2a814f9b2..01ca91fcd09e8 100644 --- a/src/tools/clippy/tests/ui/redundant_guards.stderr +++ b/src/tools/clippy/tests/ui/redundant_guards.stderr @@ -1,5 +1,5 @@ error: redundant guard - --> $DIR/redundant_guards.rs:33:20 + --> tests/ui/redundant_guards.rs:34:20 | LL | C(x, y) if let 1 = y => .., | ^^^^^^^^^ @@ -13,7 +13,7 @@ LL + C(x, 1) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:39:20 + --> tests/ui/redundant_guards.rs:40:20 | LL | Some(x) if matches!(x, Some(1) if true) => .., | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | Some(Some(1)) if true => .., | ~~~~~~~ ~~~~~~~ error: redundant guard - --> $DIR/redundant_guards.rs:40:20 + --> tests/ui/redundant_guards.rs:41:20 | LL | Some(x) if matches!(x, Some(1)) => { | ^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL + Some(Some(1)) => { | error: redundant guard - --> $DIR/redundant_guards.rs:44:20 + --> tests/ui/redundant_guards.rs:45:20 | LL | Some(x) if let Some(1) = x => .., | ^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL + Some(Some(1)) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:45:20 + --> tests/ui/redundant_guards.rs:46:20 | LL | Some(x) if x == Some(2) => .., | ^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:46:20 + --> tests/ui/redundant_guards.rs:47:20 | LL | Some(x) if Some(2) == x => .., | ^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:71:20 + --> tests/ui/redundant_guards.rs:72:20 | LL | B { e } if matches!(e, Some(A(2))) => .., | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL + B { e: Some(A(2)) } => .., | error: redundant guard - --> $DIR/redundant_guards.rs:108:20 + --> tests/ui/redundant_guards.rs:109:20 | LL | E::A(y) if y == "not from an or pattern" => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL + E::A("not from an or pattern") => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:115:14 + --> tests/ui/redundant_guards.rs:116:14 | LL | x if matches!(x, Some(0)) => .., | ^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,31 @@ LL + Some(0) => .., | error: redundant guard - --> $DIR/redundant_guards.rs:165:28 + --> tests/ui/redundant_guards.rs:123:14 + | +LL | i if i == -1 => {}, + | ^^^^^^^ + | +help: try + | +LL - i if i == -1 => {}, +LL + -1 => {}, + | + +error: redundant guard + --> tests/ui/redundant_guards.rs:124:14 + | +LL | i if i == 1 => {}, + | ^^^^^^ + | +help: try + | +LL - i if i == 1 => {}, +LL + 1 => {}, + | + +error: redundant guard + --> tests/ui/redundant_guards.rs:174:28 | LL | Some(ref x) if x == &1 => {}, | ^^^^^^^ @@ -120,7 +144,7 @@ LL + Some(1) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:166:28 + --> tests/ui/redundant_guards.rs:175:28 | LL | Some(ref x) if &1 == x => {}, | ^^^^^^^ @@ -132,7 +156,7 @@ LL + Some(1) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:167:28 + --> tests/ui/redundant_guards.rs:176:28 | LL | Some(ref x) if let &2 = x => {}, | ^^^^^^^^^^ @@ -144,7 +168,7 @@ LL + Some(2) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:168:28 + --> tests/ui/redundant_guards.rs:177:28 | LL | Some(ref x) if matches!(x, &3) => {}, | ^^^^^^^^^^^^^^^ @@ -156,7 +180,7 @@ LL + Some(3) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:188:32 + --> tests/ui/redundant_guards.rs:197:32 | LL | B { ref c, .. } if c == &1 => {}, | ^^^^^^^ @@ -168,7 +192,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:189:32 + --> tests/ui/redundant_guards.rs:198:32 | LL | B { ref c, .. } if &1 == c => {}, | ^^^^^^^ @@ -180,7 +204,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:190:32 + --> tests/ui/redundant_guards.rs:199:32 | LL | B { ref c, .. } if let &1 = c => {}, | ^^^^^^^^^^ @@ -192,7 +216,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:191:32 + --> tests/ui/redundant_guards.rs:200:32 | LL | B { ref c, .. } if matches!(c, &1) => {}, | ^^^^^^^^^^^^^^^ @@ -204,7 +228,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:201:26 + --> tests/ui/redundant_guards.rs:210:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -216,7 +240,7 @@ LL + Some(Some("")) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:212:26 + --> tests/ui/redundant_guards.rs:221:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -228,7 +252,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:217:26 + --> tests/ui/redundant_guards.rs:226:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -240,7 +264,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:228:26 + --> tests/ui/redundant_guards.rs:237:26 | LL | Some(Some(x)) if x.starts_with(&[]) => {}, | ^^^^^^^^^^^^^^^^^^ @@ -252,7 +276,7 @@ LL + Some(Some([..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:233:26 + --> tests/ui/redundant_guards.rs:242:26 | LL | Some(Some(x)) if x.starts_with(&[1]) => {}, | ^^^^^^^^^^^^^^^^^^^ @@ -264,7 +288,7 @@ LL + Some(Some([1, ..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:238:26 + --> tests/ui/redundant_guards.rs:247:26 | LL | Some(Some(x)) if x.starts_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^^^ @@ -276,7 +300,7 @@ LL + Some(Some([1, 2, ..])) => {}, | error: redundant guard - --> $DIR/redundant_guards.rs:243:26 + --> tests/ui/redundant_guards.rs:252:26 | LL | Some(Some(x)) if x.ends_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^ @@ -287,5 +311,29 @@ LL - Some(Some(x)) if x.ends_with(&[1, 2]) => {}, LL + Some(Some([.., 1, 2])) => {}, | -error: aborting due to 24 previous errors +error: redundant guard + --> tests/ui/redundant_guards.rs:274:18 + | +LL | y if y.is_empty() => {}, + | ^^^^^^^^^^^^ + | +help: try + | +LL - y if y.is_empty() => {}, +LL + "" => {}, + | + +error: redundant guard + --> tests/ui/redundant_guards.rs:293:22 + | +LL | y if y.is_empty() => {}, + | ^^^^^^^^^^^^ + | +help: try + | +LL - y if y.is_empty() => {}, +LL + "" => {}, + | + +error: aborting due to 28 previous errors diff --git a/src/tools/clippy/tests/ui/redundant_locals.stderr b/src/tools/clippy/tests/ui/redundant_locals.stderr index 610d587ddadce..541b988eefe98 100644 --- a/src/tools/clippy/tests/ui/redundant_locals.stderr +++ b/src/tools/clippy/tests/ui/redundant_locals.stderr @@ -1,11 +1,11 @@ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:13:5 + --> tests/ui/redundant_locals.rs:13:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:12:9 + --> tests/ui/redundant_locals.rs:12:9 | LL | let x = 1; | ^ @@ -13,157 +13,157 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::redundant_locals)]` error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:18:5 + --> tests/ui/redundant_locals.rs:18:5 | LL | let mut x = x; | ^^^^^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:17:9 + --> tests/ui/redundant_locals.rs:17:9 | LL | let mut x = 1; | ^^^^^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:48:5 + --> tests/ui/redundant_locals.rs:48:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:47:14 + --> tests/ui/redundant_locals.rs:47:14 | LL | fn parameter(x: i32) { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:53:5 + --> tests/ui/redundant_locals.rs:53:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:52:9 + --> tests/ui/redundant_locals.rs:52:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:54:5 + --> tests/ui/redundant_locals.rs:54:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:53:9 + --> tests/ui/redundant_locals.rs:53:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:55:5 + --> tests/ui/redundant_locals.rs:55:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:54:9 + --> tests/ui/redundant_locals.rs:54:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:56:5 + --> tests/ui/redundant_locals.rs:56:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:55:9 + --> tests/ui/redundant_locals.rs:55:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:62:5 + --> tests/ui/redundant_locals.rs:62:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:60:9 + --> tests/ui/redundant_locals.rs:60:9 | LL | let a = 1; | ^ error: redundant redefinition of a binding `b` - --> $DIR/redundant_locals.rs:63:5 + --> tests/ui/redundant_locals.rs:63:5 | LL | let b = b; | ^^^^^^^^^^ | help: `b` is initially defined here - --> $DIR/redundant_locals.rs:61:9 + --> tests/ui/redundant_locals.rs:61:9 | LL | let b = 2; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:69:9 + --> tests/ui/redundant_locals.rs:69:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:68:13 + --> tests/ui/redundant_locals.rs:68:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:76:9 + --> tests/ui/redundant_locals.rs:76:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:75:13 + --> tests/ui/redundant_locals.rs:75:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:79:9 + --> tests/ui/redundant_locals.rs:79:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:78:6 + --> tests/ui/redundant_locals.rs:78:6 | LL | |x: i32| { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:98:9 + --> tests/ui/redundant_locals.rs:98:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:95:9 + --> tests/ui/redundant_locals.rs:95:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:153:5 + --> tests/ui/redundant_locals.rs:153:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:151:9 + --> tests/ui/redundant_locals.rs:151:9 | LL | let a = WithoutDrop(1); | ^ 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 28f0244b9e87b..1a99cb9fc32b5 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 @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:15:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:15:12 | LL | if let Ok(_) = m.lock() {} | -------^^^^^----------- help: try: `if m.lock().is_ok()` @@ -10,7 +10,7 @@ LL | if let Ok(_) = m.lock() {} = 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 + --> tests/ui/redundant_pattern_matching_drop_order.rs:16:12 | LL | if let Err(_) = Err::<(), _>(m.lock().unwrap().0) {} | -------^^^^^^------------------------------------ help: try: `if Err::<(), _>(m.lock().unwrap().0).is_err()` @@ -19,7 +19,7 @@ LL | if let Err(_) = Err::<(), _>(m.lock().unwrap().0) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:19:16 + --> tests/ui/redundant_pattern_matching_drop_order.rs:19:16 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} | -------^^^^^----------------------------------------- help: try: `if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok()` @@ -28,7 +28,7 @@ LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:21:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:21:12 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { | -------^^^^^----------------------------------------- help: try: `if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok()` @@ -37,31 +37,31 @@ LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:24:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:24:12 | LL | if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} | -------^^^^^----------------------------------------- help: try: `if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_drop_order.rs:25:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:25:12 | LL | if let Err(_) = Err::, _>(()) {} | -------^^^^^^------------------------------------------ help: try: `if Err::, _>(()).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_drop_order.rs:27:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:27:12 | LL | if let Ok(_) = Ok::<_, ()>(String::new()) {} | -------^^^^^----------------------------- help: try: `if Ok::<_, ()>(String::new()).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_drop_order.rs:28:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:28:12 | LL | if let Err(_) = Err::<(), _>((String::new(), ())) {} | -------^^^^^^------------------------------------ help: try: `if Err::<(), _>((String::new(), ())).is_err()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:31:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:31:12 | LL | if let Some(_) = Some(m.lock()) {} | -------^^^^^^^----------------- help: try: `if Some(m.lock()).is_some()` @@ -70,7 +70,7 @@ LL | if let Some(_) = Some(m.lock()) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:32:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:32:12 | LL | if let Some(_) = Some(m.lock().unwrap().0) {} | -------^^^^^^^---------------------------- help: try: `if Some(m.lock().unwrap().0).is_some()` @@ -79,7 +79,7 @@ LL | if let Some(_) = Some(m.lock().unwrap().0) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_drop_order.rs:35:16 + --> tests/ui/redundant_pattern_matching_drop_order.rs:35:16 | LL | if let None = None::> {} | -------^^^^------------------------------------ help: try: `if None::>.is_none()` @@ -88,7 +88,7 @@ LL | if let None = None::> {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_drop_order.rs:37:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:37:12 | LL | if let None = None::> { | -------^^^^------------------------------------ help: try: `if None::>.is_none()` @@ -97,25 +97,25 @@ LL | if let None = None::> { = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_drop_order.rs:41:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:41:12 | LL | if let None = None::> {} | -------^^^^------------------------------------ help: try: `if None::>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:43:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:43:12 | LL | if let Some(_) = Some(String::new()) {} | -------^^^^^^^---------------------- help: try: `if Some(String::new()).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_drop_order.rs:44:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:44:12 | LL | if let Some(_) = Some((String::new(), ())) {} | -------^^^^^^^---------------------------- help: try: `if Some((String::new(), ())).is_some()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:47:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:47:12 | LL | if let Ready(_) = Ready(m.lock()) {} | -------^^^^^^^^------------------ help: try: `if Ready(m.lock()).is_ready()` @@ -124,7 +124,7 @@ LL | if let Ready(_) = Ready(m.lock()) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:48:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:48:12 | LL | if let Ready(_) = Ready(m.lock().unwrap().0) {} | -------^^^^^^^^----------------------------- help: try: `if Ready(m.lock().unwrap().0).is_ready()` @@ -133,7 +133,7 @@ LL | if let Ready(_) = Ready(m.lock().unwrap().0) {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_drop_order.rs:51:16 + --> tests/ui/redundant_pattern_matching_drop_order.rs:51:16 | LL | if let Pending = Pending::> {} | -------^^^^^^^--------------------------------------- help: try: `if Pending::>.is_pending()` @@ -142,7 +142,7 @@ LL | if let Pending = Pending::> {} = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_drop_order.rs:53:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:53:12 | LL | if let Pending = Pending::> { | -------^^^^^^^--------------------------------------- help: try: `if Pending::>.is_pending()` @@ -151,19 +151,19 @@ LL | if let Pending = Pending::> { = note: add `#[allow(clippy::redundant_pattern_matching)]` if this is important error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_drop_order.rs:57:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:57:12 | LL | if let Pending = Pending::> {} | -------^^^^^^^--------------------------------------- help: try: `if Pending::>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:59:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:59:12 | LL | if let Ready(_) = Ready(String::new()) {} | -------^^^^^^^^----------------------- help: try: `if Ready(String::new()).is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_drop_order.rs:60:12 + --> tests/ui/redundant_pattern_matching_drop_order.rs:60:12 | LL | if let Ready(_) = Ready((String::new(), ())) {} | -------^^^^^^^^----------------------------- help: try: `if Ready((String::new(), ())).is_ready()` diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_if_let_true.stderr b/src/tools/clippy/tests/ui/redundant_pattern_matching_if_let_true.stderr index 211a332d79a66..43d5cd07cec77 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_if_let_true.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_if_let_true.stderr @@ -1,5 +1,5 @@ error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:22:8 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:22:8 | LL | if let true = k > 1 {} | ^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 1` @@ -8,37 +8,37 @@ LL | if let true = k > 1 {} = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:23:8 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:23:8 | LL | if let false = k > 5 {} | ^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `!(k > 5)` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:24:8 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:24:8 | LL | if let (true) = k > 1 {} | ^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 1` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:26:11 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:26:11 | LL | while let true = k > 1 { | ^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 1` error: using `if let` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:29:11 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:29:11 | LL | while let true = condition!() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `condition!()` error: using `matches!` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:33:5 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:33:5 | LL | matches!(k > 5, true); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `k > 5` error: using `matches!` to pattern match a bool - --> $DIR/redundant_pattern_matching_if_let_true.rs:34:5 + --> tests/ui/redundant_pattern_matching_if_let_true.rs:34:5 | LL | matches!(k > 5, false); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using the condition directly: `!(k > 5)` 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 54cefa5e82b1c..a4930ad839f91 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_ipaddr.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_ipaddr.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:15:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:15:12 | LL | if let V4(_) = &ipaddr {} | -------^^^^^---------- help: try: `if ipaddr.is_ipv4()` @@ -8,43 +8,43 @@ LL | if let V4(_) = &ipaddr {} = 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 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:17:12 | LL | if let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:19:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:19:12 | LL | if let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:22:8 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:22:8 | LL | if matches!(V4(Ipv4Addr::LOCALHOST), V4(_)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:25:8 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:25:8 | LL | if matches!(V6(Ipv6Addr::LOCALHOST), V6(_)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:27:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:27:15 | LL | while let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:29:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:29:15 | LL | while let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:39:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:39:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { LL | | V4(_) => true, @@ -53,7 +53,7 @@ LL | | }; | |_____^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:44:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:44:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { LL | | V4(_) => false, @@ -62,7 +62,7 @@ LL | | }; | |_____^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:49:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:49:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { LL | | V4(_) => false, @@ -71,7 +71,7 @@ LL | | }; | |_____^ help: try: `V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:54:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:54:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { LL | | V4(_) => true, @@ -80,49 +80,49 @@ LL | | }; | |_____^ help: try: `V6(Ipv6Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:59:20 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:59:20 | LL | let _ = if let V4(_) = V4(Ipv4Addr::LOCALHOST) { | -------^^^^^-------------------------- help: try: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:67:20 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:67:20 | LL | let _ = if let V4(_) = gen_ipaddr() { | -------^^^^^--------------- help: try: `if gen_ipaddr().is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:69:19 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:69:19 | LL | } else if let V6(_) = gen_ipaddr() { | -------^^^^^--------------- help: try: `if gen_ipaddr().is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:81:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:81:12 | LL | if let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:83:12 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:83:12 | LL | if let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | -------^^^^^-------------------------- help: try: `if V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:85:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:85:15 | LL | while let V4(_) = V4(Ipv4Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:87:15 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:87:15 | LL | while let V6(_) = V6(Ipv6Addr::LOCALHOST) {} | ----------^^^^^-------------------------- help: try: `while V6(Ipv6Addr::LOCALHOST).is_ipv6()` error: redundant pattern matching, consider using `is_ipv4()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:89:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:89:5 | LL | / match V4(Ipv4Addr::LOCALHOST) { LL | | V4(_) => true, @@ -131,7 +131,7 @@ LL | | }; | |_____^ help: try: `V4(Ipv4Addr::LOCALHOST).is_ipv4()` error: redundant pattern matching, consider using `is_ipv6()` - --> $DIR/redundant_pattern_matching_ipaddr.rs:94:5 + --> tests/ui/redundant_pattern_matching_ipaddr.rs:94:5 | LL | / match V6(Ipv6Addr::LOCALHOST) { LL | | V4(_) => false, 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 a75551c56f299..575f199be42c5 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:14:5 + --> tests/ui/redundant_pattern_matching_option.rs:14:5 | LL | matches!(maybe_some, None if !boolean) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_some.is_none() && (!boolean)` @@ -8,55 +8,55 @@ LL | matches!(maybe_some, None if !boolean) = 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 + --> tests/ui/redundant_pattern_matching_option.rs:18:13 | LL | let _ = matches!(maybe_some, None if boolean || boolean2); // guard needs parentheses | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_some.is_none() && (boolean || boolean2)` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:32:12 + --> tests/ui/redundant_pattern_matching_option.rs:32:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:34:12 + --> tests/ui/redundant_pattern_matching_option.rs:34:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:36:12 + --> tests/ui/redundant_pattern_matching_option.rs:36:12 | LL | if let Some(_) = Some(42) { | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:42:15 + --> tests/ui/redundant_pattern_matching_option.rs:42:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try: `while Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:44:15 + --> tests/ui/redundant_pattern_matching_option.rs:44:15 | LL | while let None = Some(42) {} | ----------^^^^----------- help: try: `while Some(42).is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:46:15 + --> tests/ui/redundant_pattern_matching_option.rs:46:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try: `while None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:49:15 + --> tests/ui/redundant_pattern_matching_option.rs:49:15 | LL | while let Some(_) = v.pop() { | ----------^^^^^^^---------- help: try: `while v.pop().is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:57:5 + --> tests/ui/redundant_pattern_matching_option.rs:57:5 | LL | / match Some(42) { LL | | Some(_) => true, @@ -65,7 +65,7 @@ LL | | }; | |_____^ help: try: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:62:5 + --> tests/ui/redundant_pattern_matching_option.rs:62:5 | LL | / match None::<()> { LL | | Some(_) => false, @@ -74,7 +74,7 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:67:13 + --> tests/ui/redundant_pattern_matching_option.rs:67:13 | LL | let _ = match None::<()> { | _____________^ @@ -84,55 +84,55 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:73:20 + --> tests/ui/redundant_pattern_matching_option.rs:73:20 | LL | let _ = if let Some(_) = opt { true } else { false }; | -------^^^^^^^------ help: try: `if opt.is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:79:20 + --> tests/ui/redundant_pattern_matching_option.rs:79:20 | LL | let _ = if let Some(_) = gen_opt() { | -------^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:81:19 + --> tests/ui/redundant_pattern_matching_option.rs:81:19 | LL | } else if let None = gen_opt() { | -------^^^^------------ help: try: `if gen_opt().is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:87:12 + --> tests/ui/redundant_pattern_matching_option.rs:87:12 | LL | if let Some(..) = gen_opt() {} | -------^^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:102:12 + --> tests/ui/redundant_pattern_matching_option.rs:102:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:104:12 + --> tests/ui/redundant_pattern_matching_option.rs:104:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:106:15 + --> tests/ui/redundant_pattern_matching_option.rs:106:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try: `while Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:108:15 + --> tests/ui/redundant_pattern_matching_option.rs:108:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try: `while None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:110:5 + --> tests/ui/redundant_pattern_matching_option.rs:110:5 | LL | / match Some(42) { LL | | Some(_) => true, @@ -141,7 +141,7 @@ LL | | }; | |_____^ help: try: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:115:5 + --> tests/ui/redundant_pattern_matching_option.rs:115:5 | LL | / match None::<()> { LL | | Some(_) => false, @@ -150,19 +150,19 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:123:12 + --> tests/ui/redundant_pattern_matching_option.rs:123:12 | LL | if let None = *(&None::<()>) {} | -------^^^^----------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:124:12 + --> tests/ui/redundant_pattern_matching_option.rs:124:12 | LL | if let None = *&None::<()> {} | -------^^^^--------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:130:5 + --> tests/ui/redundant_pattern_matching_option.rs:130:5 | LL | / match x { LL | | Some(_) => true, @@ -171,7 +171,7 @@ LL | | }; | |_____^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:135:5 + --> tests/ui/redundant_pattern_matching_option.rs:135:5 | LL | / match x { LL | | None => true, @@ -180,7 +180,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:140:5 + --> tests/ui/redundant_pattern_matching_option.rs:140:5 | LL | / match x { LL | | Some(_) => false, @@ -189,7 +189,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:145:5 + --> tests/ui/redundant_pattern_matching_option.rs:145:5 | LL | / match x { LL | | None => false, @@ -198,13 +198,13 @@ LL | | }; | |_____^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_option.rs:160:13 + --> tests/ui/redundant_pattern_matching_option.rs:160:13 | LL | let _ = matches!(x, Some(_)); | ^^^^^^^^^^^^^^^^^^^^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching_option.rs:162:13 + --> tests/ui/redundant_pattern_matching_option.rs:162:13 | LL | let _ = matches!(x, None); | ^^^^^^^^^^^^^^^^^ help: try: `x.is_none()` 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 de64331b4e8cf..2b0f087fb9939 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_poll.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_poll.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:15:12 + --> tests/ui/redundant_pattern_matching_poll.rs:15:12 | LL | if let Pending = Pending::<()> {} | -------^^^^^^^---------------- help: try: `if Pending::<()>.is_pending()` @@ -8,49 +8,49 @@ LL | if let Pending = Pending::<()> {} = 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 + --> tests/ui/redundant_pattern_matching_poll.rs:17:12 | LL | if let Ready(_) = Ready(42) {} | -------^^^^^^^^------------ help: try: `if Ready(42).is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:19:12 + --> tests/ui/redundant_pattern_matching_poll.rs:19:12 | LL | if let Ready(_) = Ready(42) { | -------^^^^^^^^------------ help: try: `if Ready(42).is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:26:8 + --> tests/ui/redundant_pattern_matching_poll.rs:26:8 | LL | if matches!(Ready(42), Ready(_)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:29:8 + --> tests/ui/redundant_pattern_matching_poll.rs:29:8 | LL | if matches!(Pending::<()>, Pending) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:31:15 + --> tests/ui/redundant_pattern_matching_poll.rs:31:15 | LL | while let Ready(_) = Ready(42) {} | ----------^^^^^^^^------------ help: try: `while Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:33:15 + --> tests/ui/redundant_pattern_matching_poll.rs:33:15 | LL | while let Pending = Ready(42) {} | ----------^^^^^^^------------ help: try: `while Ready(42).is_pending()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:35:15 + --> tests/ui/redundant_pattern_matching_poll.rs:35:15 | LL | while let Pending = Pending::<()> {} | ----------^^^^^^^---------------- help: try: `while Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:41:5 + --> tests/ui/redundant_pattern_matching_poll.rs:41:5 | LL | / match Ready(42) { LL | | Ready(_) => true, @@ -59,7 +59,7 @@ LL | | }; | |_____^ help: try: `Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:46:5 + --> tests/ui/redundant_pattern_matching_poll.rs:46:5 | LL | / match Pending::<()> { LL | | Ready(_) => false, @@ -68,7 +68,7 @@ LL | | }; | |_____^ help: try: `Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:51:13 + --> tests/ui/redundant_pattern_matching_poll.rs:51:13 | LL | let _ = match Pending::<()> { | _____________^ @@ -78,49 +78,49 @@ LL | | }; | |_____^ help: try: `Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:57:20 + --> tests/ui/redundant_pattern_matching_poll.rs:57:20 | LL | let _ = if let Ready(_) = poll { true } else { false }; | -------^^^^^^^^------- help: try: `if poll.is_ready()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:61:20 + --> tests/ui/redundant_pattern_matching_poll.rs:61:20 | LL | let _ = if let Ready(_) = gen_poll() { | -------^^^^^^^^------------- help: try: `if gen_poll().is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:63:19 + --> tests/ui/redundant_pattern_matching_poll.rs:63:19 | LL | } else if let Pending = gen_poll() { | -------^^^^^^^------------- help: try: `if gen_poll().is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:79:12 + --> tests/ui/redundant_pattern_matching_poll.rs:79:12 | LL | if let Ready(_) = Ready(42) {} | -------^^^^^^^^------------ help: try: `if Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:81:12 + --> tests/ui/redundant_pattern_matching_poll.rs:81:12 | LL | if let Pending = Pending::<()> {} | -------^^^^^^^---------------- help: try: `if Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:83:15 + --> tests/ui/redundant_pattern_matching_poll.rs:83:15 | LL | while let Ready(_) = Ready(42) {} | ----------^^^^^^^^------------ help: try: `while Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:85:15 + --> tests/ui/redundant_pattern_matching_poll.rs:85:15 | LL | while let Pending = Pending::<()> {} | ----------^^^^^^^---------------- help: try: `while Pending::<()>.is_pending()` error: redundant pattern matching, consider using `is_ready()` - --> $DIR/redundant_pattern_matching_poll.rs:87:5 + --> tests/ui/redundant_pattern_matching_poll.rs:87:5 | LL | / match Ready(42) { LL | | Ready(_) => true, @@ -129,7 +129,7 @@ LL | | }; | |_____^ help: try: `Ready(42).is_ready()` error: redundant pattern matching, consider using `is_pending()` - --> $DIR/redundant_pattern_matching_poll.rs:92:5 + --> tests/ui/redundant_pattern_matching_poll.rs:92:5 | LL | / match Pending::<()> { LL | | Ready(_) => false, 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 19e7f82298ea6..991e6225ecb6d 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_result.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_result.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:15:12 + --> tests/ui/redundant_pattern_matching_result.rs:15:12 | LL | if let Ok(_) = &result {} | -------^^^^^---------- help: try: `if result.is_ok()` @@ -8,31 +8,31 @@ LL | if let Ok(_) = &result {} = 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 + --> tests/ui/redundant_pattern_matching_result.rs:17:12 | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try: `if Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:19:12 + --> tests/ui/redundant_pattern_matching_result.rs:19:12 | LL | if let Err(_) = Err::(42) {} | -------^^^^^^---------------------- help: try: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:21:15 + --> tests/ui/redundant_pattern_matching_result.rs:21:15 | LL | while let Ok(_) = Ok::(10) {} | ----------^^^^^--------------------- help: try: `while Ok::(10).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:23:15 + --> tests/ui/redundant_pattern_matching_result.rs:23:15 | LL | while let Err(_) = Ok::(10) {} | ----------^^^^^^--------------------- help: try: `while Ok::(10).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:33:5 + --> tests/ui/redundant_pattern_matching_result.rs:33:5 | LL | / match Ok::(42) { LL | | Ok(_) => true, @@ -41,7 +41,7 @@ LL | | }; | |_____^ help: try: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:38:5 + --> tests/ui/redundant_pattern_matching_result.rs:38:5 | LL | / match Ok::(42) { LL | | Ok(_) => false, @@ -50,7 +50,7 @@ LL | | }; | |_____^ help: try: `Ok::(42).is_err()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:43:5 + --> tests/ui/redundant_pattern_matching_result.rs:43:5 | LL | / match Err::(42) { LL | | Ok(_) => false, @@ -59,7 +59,7 @@ LL | | }; | |_____^ help: try: `Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:48:5 + --> tests/ui/redundant_pattern_matching_result.rs:48:5 | LL | / match Err::(42) { LL | | Ok(_) => true, @@ -68,73 +68,73 @@ LL | | }; | |_____^ help: try: `Err::(42).is_ok()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:53:20 + --> tests/ui/redundant_pattern_matching_result.rs:53:20 | LL | let _ = if let Ok(_) = Ok::(4) { true } else { false }; | -------^^^^^--------------------- help: try: `if Ok::(4).is_ok()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:61:20 + --> tests/ui/redundant_pattern_matching_result.rs:61:20 | LL | let _ = if let Ok(_) = gen_res() { | -------^^^^^------------ help: try: `if gen_res().is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:63:19 + --> tests/ui/redundant_pattern_matching_result.rs:63:19 | LL | } else if let Err(_) = gen_res() { | -------^^^^^^------------ help: try: `if gen_res().is_err()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:86:19 + --> tests/ui/redundant_pattern_matching_result.rs:86:19 | LL | while let Some(_) = r#try!(result_opt()) {} | ----------^^^^^^^----------------------- help: try: `while r#try!(result_opt()).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:87:16 + --> tests/ui/redundant_pattern_matching_result.rs:87:16 | LL | if let Some(_) = r#try!(result_opt()) {} | -------^^^^^^^----------------------- help: try: `if r#try!(result_opt()).is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:93:12 + --> tests/ui/redundant_pattern_matching_result.rs:93:12 | LL | if let Some(_) = m!() {} | -------^^^^^^^------- help: try: `if m!().is_some()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching_result.rs:94:15 + --> tests/ui/redundant_pattern_matching_result.rs:94:15 | LL | while let Some(_) = m!() {} | ----------^^^^^^^------- help: try: `while m!().is_some()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:112:12 + --> tests/ui/redundant_pattern_matching_result.rs:112:12 | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try: `if Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:114:12 + --> tests/ui/redundant_pattern_matching_result.rs:114:12 | LL | if let Err(_) = Err::(42) {} | -------^^^^^^---------------------- help: try: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:116:15 + --> tests/ui/redundant_pattern_matching_result.rs:116:15 | LL | while let Ok(_) = Ok::(10) {} | ----------^^^^^--------------------- help: try: `while Ok::(10).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:118:15 + --> tests/ui/redundant_pattern_matching_result.rs:118:15 | LL | while let Err(_) = Ok::(10) {} | ----------^^^^^^--------------------- help: try: `while Ok::(10).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:120:5 + --> tests/ui/redundant_pattern_matching_result.rs:120:5 | LL | / match Ok::(42) { LL | | Ok(_) => true, @@ -143,7 +143,7 @@ LL | | }; | |_____^ help: try: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:125:5 + --> tests/ui/redundant_pattern_matching_result.rs:125:5 | LL | / match Err::(42) { LL | | Ok(_) => false, @@ -152,7 +152,7 @@ LL | | }; | |_____^ help: try: `Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:135:5 + --> tests/ui/redundant_pattern_matching_result.rs:135:5 | LL | / match x { LL | | Ok(_) => true, @@ -161,7 +161,7 @@ LL | | }; | |_____^ help: try: `x.is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:140:5 + --> tests/ui/redundant_pattern_matching_result.rs:140:5 | LL | / match x { LL | | Ok(_) => false, @@ -170,7 +170,7 @@ LL | | }; | |_____^ help: try: `x.is_err()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:145:5 + --> tests/ui/redundant_pattern_matching_result.rs:145:5 | LL | / match x { LL | | Err(_) => true, @@ -179,7 +179,7 @@ LL | | }; | |_____^ help: try: `x.is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:150:5 + --> tests/ui/redundant_pattern_matching_result.rs:150:5 | LL | / match x { LL | | Err(_) => false, @@ -188,13 +188,13 @@ LL | | }; | |_____^ help: try: `x.is_ok()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching_result.rs:171:13 + --> tests/ui/redundant_pattern_matching_result.rs:171:13 | LL | let _ = matches!(x, Ok(_)); | ^^^^^^^^^^^^^^^^^^ help: try: `x.is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching_result.rs:173:13 + --> tests/ui/redundant_pattern_matching_result.rs:173:13 | LL | let _ = matches!(x, Err(_)); | ^^^^^^^^^^^^^^^^^^^ help: try: `x.is_err()` diff --git a/src/tools/clippy/tests/ui/redundant_pub_crate.stderr b/src/tools/clippy/tests/ui/redundant_pub_crate.stderr index 5d7744aa86492..8f1005ab9b73c 100644 --- a/src/tools/clippy/tests/ui/redundant_pub_crate.stderr +++ b/src/tools/clippy/tests/ui/redundant_pub_crate.stderr @@ -1,5 +1,5 @@ error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:6:5 + --> tests/ui/redundant_pub_crate.rs:6:5 | LL | pub(crate) fn g() {} // private due to m1 | ----------^^^^^ @@ -10,7 +10,7 @@ LL | pub(crate) fn g() {} // private due to m1 = 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 + --> tests/ui/redundant_pub_crate.rs:11:9 | LL | pub(crate) fn g() {} // private due to m1_1 and m1 | ----------^^^^^ @@ -18,7 +18,7 @@ LL | pub(crate) fn g() {} // private due to m1_1 and m1 | help: consider using: `pub` error: pub(crate) module inside private module - --> $DIR/redundant_pub_crate.rs:15:5 + --> tests/ui/redundant_pub_crate.rs:15:5 | LL | pub(crate) mod m1_2 { | ----------^^^^^^^^^ @@ -26,7 +26,7 @@ LL | pub(crate) mod m1_2 { | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:18:9 + --> tests/ui/redundant_pub_crate.rs:18:9 | LL | pub(crate) fn g() {} // private due to m1_2 and m1 | ----------^^^^^ @@ -34,7 +34,7 @@ LL | pub(crate) fn g() {} // private due to m1_2 and m1 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:24:9 + --> tests/ui/redundant_pub_crate.rs:24:9 | LL | pub(crate) fn g() {} // private due to m1 | ----------^^^^^ @@ -42,7 +42,7 @@ LL | pub(crate) fn g() {} // private due to m1 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:31:5 + --> tests/ui/redundant_pub_crate.rs:31:5 | LL | pub(crate) fn g() {} // already crate visible due to m2 | ----------^^^^^ @@ -50,7 +50,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:36:9 + --> tests/ui/redundant_pub_crate.rs:36:9 | LL | pub(crate) fn g() {} // private due to m2_1 | ----------^^^^^ @@ -58,7 +58,7 @@ LL | pub(crate) fn g() {} // private due to m2_1 | help: consider using: `pub` error: pub(crate) module inside private module - --> $DIR/redundant_pub_crate.rs:40:5 + --> tests/ui/redundant_pub_crate.rs:40:5 | LL | pub(crate) mod m2_2 { | ----------^^^^^^^^^ @@ -66,7 +66,7 @@ LL | pub(crate) mod m2_2 { | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:43:9 + --> tests/ui/redundant_pub_crate.rs:43:9 | LL | pub(crate) fn g() {} // already crate visible due to m2_2 and m2 | ----------^^^^^ @@ -74,7 +74,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2_2 and m2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:49:9 + --> tests/ui/redundant_pub_crate.rs:49:9 | LL | pub(crate) fn g() {} // already crate visible due to m2 | ----------^^^^^ @@ -82,7 +82,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:61:9 + --> tests/ui/redundant_pub_crate.rs:61:9 | LL | pub(crate) fn g() {} // private due to m3_1 | ----------^^^^^ @@ -90,7 +90,7 @@ LL | pub(crate) fn g() {} // private due to m3_1 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:68:9 + --> tests/ui/redundant_pub_crate.rs:68:9 | LL | pub(crate) fn g() {} // already crate visible due to m3_2 | ----------^^^^^ @@ -98,7 +98,7 @@ LL | pub(crate) fn g() {} // already crate visible due to m3_2 | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:81:5 + --> tests/ui/redundant_pub_crate.rs:81:5 | LL | pub(crate) fn g() {} // private: not re-exported by `pub use m4::*` | ----------^^^^^ @@ -106,7 +106,7 @@ LL | pub(crate) fn g() {} // private: not re-exported by `pub use m4::*` | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:86:9 + --> tests/ui/redundant_pub_crate.rs:86:9 | LL | pub(crate) fn g() {} // private due to m4_1 | ----------^^^^^ @@ -114,7 +114,7 @@ LL | pub(crate) fn g() {} // private due to m4_1 | help: consider using: `pub` error: pub(crate) module inside private module - --> $DIR/redundant_pub_crate.rs:90:5 + --> tests/ui/redundant_pub_crate.rs:90:5 | LL | pub(crate) mod m4_2 { | ----------^^^^^^^^^ @@ -122,7 +122,7 @@ LL | pub(crate) mod m4_2 { | help: consider using: `pub` error: pub(crate) function inside private module - --> $DIR/redundant_pub_crate.rs:93:9 + --> tests/ui/redundant_pub_crate.rs:93:9 | LL | pub(crate) fn g() {} // private due to m4_2 | ----------^^^^^ diff --git a/src/tools/clippy/tests/ui/redundant_slicing.stderr b/src/tools/clippy/tests/ui/redundant_slicing.stderr index 05287c882f7e1..269a597b32267 100644 --- a/src/tools/clippy/tests/ui/redundant_slicing.stderr +++ b/src/tools/clippy/tests/ui/redundant_slicing.stderr @@ -1,5 +1,5 @@ error: redundant slicing of the whole range - --> $DIR/redundant_slicing.rs:8:13 + --> tests/ui/redundant_slicing.rs:8:13 | LL | let _ = &slice[..]; // Redundant slice | ^^^^^^^^^^ help: use the original value instead: `slice` @@ -8,13 +8,13 @@ LL | let _ = &slice[..]; // Redundant slice = help: to override `-D warnings` add `#[allow(clippy::redundant_slicing)]` error: redundant slicing of the whole range - --> $DIR/redundant_slicing.rs:12:13 + --> tests/ui/redundant_slicing.rs:12:13 | LL | let _ = &(&*v)[..]; // Outer borrow is redundant | ^^^^^^^^^^ help: use the original value instead: `(&*v)` error: redundant slicing of the whole range - --> $DIR/redundant_slicing.rs:29:13 + --> tests/ui/redundant_slicing.rs:29:13 | LL | let _ = &m!(slice)[..]; | ^^^^^^^^^^^^^^ help: use the original value instead: `slice` diff --git a/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr b/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr index 26f50345351fe..5c5e2f2a57360 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes.stderr @@ -1,5 +1,5 @@ error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:6:17 + --> tests/ui/redundant_static_lifetimes.rs:6:17 | LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` @@ -8,103 +8,103 @@ LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR: Consider removi = 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 + --> tests/ui/redundant_static_lifetimes.rs:10:21 | LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:12:32 + --> tests/ui/redundant_static_lifetimes.rs:12:32 | LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:12:47 + --> tests/ui/redundant_static_lifetimes.rs:12:47 | LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:14:17 + --> tests/ui/redundant_static_lifetimes.rs:14:17 | LL | const VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:16:20 + --> tests/ui/redundant_static_lifetimes.rs:16:20 | LL | const VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:18:19 + --> tests/ui/redundant_static_lifetimes.rs:18:19 | LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR: Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:20:19 + --> tests/ui/redundant_static_lifetimes.rs:20:19 | LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:22:19 + --> tests/ui/redundant_static_lifetimes.rs:22:19 | LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:24:25 + --> tests/ui/redundant_static_lifetimes.rs:24:25 | LL | static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR: Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:28:29 + --> tests/ui/redundant_static_lifetimes.rs:28:29 | LL | static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:30:25 + --> tests/ui/redundant_static_lifetimes.rs:30:25 | LL | static STATIC_VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:32:28 + --> tests/ui/redundant_static_lifetimes.rs:32:28 | LL | static STATIC_VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:34:27 + --> tests/ui/redundant_static_lifetimes.rs:34:27 | LL | static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR: Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:36:27 + --> tests/ui/redundant_static_lifetimes.rs:36:27 | LL | static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR: Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:38:27 + --> tests/ui/redundant_static_lifetimes.rs:38:27 | LL | static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR: Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:40:31 + --> tests/ui/redundant_static_lifetimes.rs:40:31 | LL | static mut STATIC_MUT_SLICE: &'static mut [u32] = &mut [0]; | -^^^^^^^---------- help: consider removing `'static`: `&mut [u32]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes.rs:69:16 + --> tests/ui/redundant_static_lifetimes.rs:69:16 | LL | static V: &'static u8 = &17; | -^^^^^^^--- help: consider removing `'static`: `&u8` 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 bf4d211200f3c..330703d9eff12 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes_multiple.stderr +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes_multiple.stderr @@ -1,5 +1,5 @@ error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:4:18 + --> tests/ui/redundant_static_lifetimes_multiple.rs:4:18 | LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` @@ -8,55 +8,55 @@ LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; = 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 + --> tests/ui/redundant_static_lifetimes_multiple.rs:4:30 | LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:9:29 + --> tests/ui/redundant_static_lifetimes_multiple.rs:9:29 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: constants have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:9:39 + --> tests/ui/redundant_static_lifetimes_multiple.rs:9:39 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:13:40 + --> tests/ui/redundant_static_lifetimes_multiple.rs:13:40 | LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:13:55 + --> tests/ui/redundant_static_lifetimes_multiple.rs:13:55 | LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:17:26 + --> tests/ui/redundant_static_lifetimes_multiple.rs:17:26 | LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:17:38 + --> tests/ui/redundant_static_lifetimes_multiple.rs:17:38 | LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:21:37 + --> tests/ui/redundant_static_lifetimes_multiple.rs:21:37 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: statics have by default a `'static` lifetime - --> $DIR/redundant_static_lifetimes_multiple.rs:21:47 + --> tests/ui/redundant_static_lifetimes_multiple.rs:21:47 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` diff --git a/src/tools/clippy/tests/ui/redundant_type_annotations.stderr b/src/tools/clippy/tests/ui/redundant_type_annotations.stderr index 48df465ad4971..4768f4d3c57ce 100644 --- a/src/tools/clippy/tests/ui/redundant_type_annotations.stderr +++ b/src/tools/clippy/tests/ui/redundant_type_annotations.stderr @@ -1,5 +1,5 @@ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:81:9 + --> tests/ui/redundant_type_annotations.rs:81:9 | LL | let v: u32 = self.return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,97 +8,97 @@ LL | let v: u32 = self.return_an_int(); = help: to override `-D warnings` add `#[allow(clippy::redundant_type_annotations)]` error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:84:9 + --> tests/ui/redundant_type_annotations.rs:84:9 | LL | let v: &u32 = self.return_a_ref(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:86:9 + --> tests/ui/redundant_type_annotations.rs:86:9 | LL | let v: &Slice = self.return_a_ref_to_struct(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:159:5 + --> tests/ui/redundant_type_annotations.rs:159:5 | LL | let _return: String = return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:162:5 + --> tests/ui/redundant_type_annotations.rs:162:5 | LL | let _return: Pie = return_a_struct(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:165:5 + --> tests/ui/redundant_type_annotations.rs:165:5 | LL | let _return: Pizza = return_an_enum(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:168:5 + --> tests/ui/redundant_type_annotations.rs:168:5 | LL | let _return: u32 = return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:171:5 + --> tests/ui/redundant_type_annotations.rs:171:5 | LL | let _return: String = String::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:174:5 + --> tests/ui/redundant_type_annotations.rs:174:5 | LL | let new_pie: Pie = Pie::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:177:5 + --> tests/ui/redundant_type_annotations.rs:177:5 | LL | let _return: u32 = new_pie.return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:180:5 + --> tests/ui/redundant_type_annotations.rs:180:5 | LL | let _return: u32 = Pie::associated_return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:183:5 + --> tests/ui/redundant_type_annotations.rs:183:5 | LL | let _return: String = Pie::associated_return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:190:5 + --> tests/ui/redundant_type_annotations.rs:190:5 | LL | let _var: u32 = u32::MAX; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:193:5 + --> tests/ui/redundant_type_annotations.rs:193:5 | LL | let _var: u32 = 5_u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:196:5 + --> tests/ui/redundant_type_annotations.rs:196:5 | LL | let _var: &str = "test"; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:199:5 + --> tests/ui/redundant_type_annotations.rs:199:5 | LL | let _var: &[u8; 4] = b"test"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> $DIR/redundant_type_annotations.rs:202:5 + --> tests/ui/redundant_type_annotations.rs:202:5 | LL | let _var: bool = false; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/ref_as_ptr.fixed b/src/tools/clippy/tests/ui/ref_as_ptr.fixed index 7a946393f259b..466a628a00265 100644 --- a/src/tools/clippy/tests/ui/ref_as_ptr.fixed +++ b/src/tools/clippy/tests/ui/ref_as_ptr.fixed @@ -1,55 +1,61 @@ #![warn(clippy::ref_as_ptr)] #![allow(clippy::unnecessary_mut_passed)] +fn f(_: T) {} + fn main() { - let _ = std::ptr::from_ref(&1u8); - let _ = std::ptr::from_ref::(&2u32); - let _ = std::ptr::from_ref::(&3.0f64); + f(std::ptr::from_ref(&1u8)); + f(std::ptr::from_ref::(&2u32)); + f(std::ptr::from_ref::(&3.0f64)); - let _ = std::ptr::from_ref(&4) as *const f32; - let _ = std::ptr::from_ref::(&5.0f32) as *const u32; + f(std::ptr::from_ref(&4) as *const f32); + f(std::ptr::from_ref::(&5.0f32) as *const u32); - let _ = std::ptr::from_ref(&mut 6u8); - let _ = std::ptr::from_ref::(&mut 7u32); - let _ = std::ptr::from_ref::(&mut 8.0f64); + f(std::ptr::from_ref(&mut 6u8)); + f(std::ptr::from_ref::(&mut 7u32)); + f(std::ptr::from_ref::(&mut 8.0f64)); - let _ = std::ptr::from_ref(&mut 9) as *const f32; - let _ = std::ptr::from_ref::(&mut 10.0f32) as *const u32; + f(std::ptr::from_ref(&mut 9) as *const f32); + f(std::ptr::from_ref::(&mut 10.0f32) as *const u32); - let _ = std::ptr::from_mut(&mut 11u8); - let _ = std::ptr::from_mut::(&mut 12u32); - let _ = std::ptr::from_mut::(&mut 13.0f64); + f(std::ptr::from_mut(&mut 11u8)); + f(std::ptr::from_mut::(&mut 12u32)); + f(std::ptr::from_mut::(&mut 13.0f64)); - let _ = std::ptr::from_mut(&mut 14) as *const f32; - let _ = std::ptr::from_mut::(&mut 15.0f32) as *const u32; + f(std::ptr::from_mut(&mut 14) as *const f32); + f(std::ptr::from_mut::(&mut 15.0f32) as *const u32); - let _ = std::ptr::from_ref(&1u8); - let _ = std::ptr::from_ref::(&2u32); - let _ = std::ptr::from_ref::(&3.0f64); + f(std::ptr::from_ref(&1u8)); + f(std::ptr::from_ref::(&2u32)); + f(std::ptr::from_ref::(&3.0f64)); - let _ = std::ptr::from_ref(&4) as *const f32; - let _ = std::ptr::from_ref::(&5.0f32) as *const u32; + f(std::ptr::from_ref(&4) as *const f32); + f(std::ptr::from_ref::(&5.0f32) as *const u32); let val = 1; - let _ = std::ptr::from_ref(&val); - let _ = std::ptr::from_ref::(&val); + f(std::ptr::from_ref(&val)); + f(std::ptr::from_ref::(&val)); - let _ = std::ptr::from_ref(&val) as *const f32; - let _ = std::ptr::from_ref::(&val) as *const f64; + f(std::ptr::from_ref(&val) as *const f32); + f(std::ptr::from_ref::(&val) as *const f64); let mut val: u8 = 2; - let _ = std::ptr::from_mut::(&mut val); - let _ = std::ptr::from_mut(&mut val); + f(std::ptr::from_mut::(&mut val)); + f(std::ptr::from_mut(&mut val)); + + f(std::ptr::from_ref::(&mut val)); + f(std::ptr::from_ref(&mut val)); - let _ = std::ptr::from_ref::(&mut val); - let _ = std::ptr::from_ref(&mut val); + f(std::ptr::from_ref::(&mut val) as *const f64); + f::<*const Option>(std::ptr::from_ref(&mut val) as *const _); - let _ = std::ptr::from_ref::(&mut val) as *const f64; - let _: *const Option = std::ptr::from_ref(&mut val) as *const _; + f(std::ptr::from_ref::<[usize; 7]>(&std::array::from_fn(|i| i * i))); + f(std::ptr::from_ref::<[usize; 8]>(&mut std::array::from_fn(|i| i * i))); + f(std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i))); - let _ = std::ptr::from_ref::<[usize; 7]>(&std::array::from_fn(|i| i * i)); - let _ = std::ptr::from_ref::<[usize; 8]>(&mut std::array::from_fn(|i| i * i)); - let _ = std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i)); + let _ = &String::new() as *const _; + let _ = &mut String::new() as *mut _; + const FOO: *const String = &String::new() as *const _; } #[clippy::msrv = "1.75"] @@ -58,8 +64,8 @@ fn _msrv_1_75() { let mut_val = &mut 42_i32; // `std::ptr::from_{ref, mut}` was stabilized in 1.76. Do not lint this - let _ = val as *const i32; - let _ = mut_val as *mut i32; + f(val as *const i32); + f(mut_val as *mut i32); } #[clippy::msrv = "1.76"] @@ -67,18 +73,18 @@ fn _msrv_1_76() { let val = &42_i32; let mut_val = &mut 42_i32; - let _ = std::ptr::from_ref::(val); - let _ = std::ptr::from_mut::(mut_val); + f(std::ptr::from_ref::(val)); + f(std::ptr::from_mut::(mut_val)); } fn foo(val: &[u8]) { - let _ = std::ptr::from_ref(val); - let _ = std::ptr::from_ref::<[u8]>(val); + f(std::ptr::from_ref(val)); + f(std::ptr::from_ref::<[u8]>(val)); } fn bar(val: &mut str) { - let _ = std::ptr::from_mut(val); - let _ = std::ptr::from_mut::(val); + f(std::ptr::from_mut(val)); + f(std::ptr::from_mut::(val)); } struct X<'a>(&'a i32); diff --git a/src/tools/clippy/tests/ui/ref_as_ptr.rs b/src/tools/clippy/tests/ui/ref_as_ptr.rs index 6f745505b4695..0fdc753dc225a 100644 --- a/src/tools/clippy/tests/ui/ref_as_ptr.rs +++ b/src/tools/clippy/tests/ui/ref_as_ptr.rs @@ -1,55 +1,61 @@ #![warn(clippy::ref_as_ptr)] #![allow(clippy::unnecessary_mut_passed)] +fn f(_: T) {} + fn main() { - let _ = &1u8 as *const _; - let _ = &2u32 as *const u32; - let _ = &3.0f64 as *const f64; + f(&1u8 as *const _); + f(&2u32 as *const u32); + f(&3.0f64 as *const f64); - let _ = &4 as *const _ as *const f32; - let _ = &5.0f32 as *const f32 as *const u32; + f(&4 as *const _ as *const f32); + f(&5.0f32 as *const f32 as *const u32); - let _ = &mut 6u8 as *const _; - let _ = &mut 7u32 as *const u32; - let _ = &mut 8.0f64 as *const f64; + f(&mut 6u8 as *const _); + f(&mut 7u32 as *const u32); + f(&mut 8.0f64 as *const f64); - let _ = &mut 9 as *const _ as *const f32; - let _ = &mut 10.0f32 as *const f32 as *const u32; + f(&mut 9 as *const _ as *const f32); + f(&mut 10.0f32 as *const f32 as *const u32); - let _ = &mut 11u8 as *mut _; - let _ = &mut 12u32 as *mut u32; - let _ = &mut 13.0f64 as *mut f64; + f(&mut 11u8 as *mut _); + f(&mut 12u32 as *mut u32); + f(&mut 13.0f64 as *mut f64); - let _ = &mut 14 as *mut _ as *const f32; - let _ = &mut 15.0f32 as *mut f32 as *const u32; + f(&mut 14 as *mut _ as *const f32); + f(&mut 15.0f32 as *mut f32 as *const u32); - let _ = &1u8 as *const _; - let _ = &2u32 as *const u32; - let _ = &3.0f64 as *const f64; + f(&1u8 as *const _); + f(&2u32 as *const u32); + f(&3.0f64 as *const f64); - let _ = &4 as *const _ as *const f32; - let _ = &5.0f32 as *const f32 as *const u32; + f(&4 as *const _ as *const f32); + f(&5.0f32 as *const f32 as *const u32); let val = 1; - let _ = &val as *const _; - let _ = &val as *const i32; + f(&val as *const _); + f(&val as *const i32); - let _ = &val as *const _ as *const f32; - let _ = &val as *const i32 as *const f64; + f(&val as *const _ as *const f32); + f(&val as *const i32 as *const f64); let mut val: u8 = 2; - let _ = &mut val as *mut u8; - let _ = &mut val as *mut _; + f(&mut val as *mut u8); + f(&mut val as *mut _); + + f(&mut val as *const u8); + f(&mut val as *const _); - let _ = &mut val as *const u8; - let _ = &mut val as *const _; + f(&mut val as *const u8 as *const f64); + f::<*const Option>(&mut val as *const _ as *const _); - let _ = &mut val as *const u8 as *const f64; - let _: *const Option = &mut val as *const _ as *const _; + f(&std::array::from_fn(|i| i * i) as *const [usize; 7]); + f(&mut std::array::from_fn(|i| i * i) as *const [usize; 8]); + f(&mut std::array::from_fn(|i| i * i) as *mut [usize; 9]); - let _ = &std::array::from_fn(|i| i * i) as *const [usize; 7]; - let _ = &mut std::array::from_fn(|i| i * i) as *const [usize; 8]; - let _ = &mut std::array::from_fn(|i| i * i) as *mut [usize; 9]; + let _ = &String::new() as *const _; + let _ = &mut String::new() as *mut _; + const FOO: *const String = &String::new() as *const _; } #[clippy::msrv = "1.75"] @@ -58,8 +64,8 @@ fn _msrv_1_75() { let mut_val = &mut 42_i32; // `std::ptr::from_{ref, mut}` was stabilized in 1.76. Do not lint this - let _ = val as *const i32; - let _ = mut_val as *mut i32; + f(val as *const i32); + f(mut_val as *mut i32); } #[clippy::msrv = "1.76"] @@ -67,18 +73,18 @@ fn _msrv_1_76() { let val = &42_i32; let mut_val = &mut 42_i32; - let _ = val as *const i32; - let _ = mut_val as *mut i32; + f(val as *const i32); + f(mut_val as *mut i32); } fn foo(val: &[u8]) { - let _ = val as *const _; - let _ = val as *const [u8]; + f(val as *const _); + f(val as *const [u8]); } fn bar(val: &mut str) { - let _ = val as *mut _; - let _ = val as *mut str; + f(val as *mut _); + f(val as *mut str); } struct X<'a>(&'a i32); diff --git a/src/tools/clippy/tests/ui/ref_as_ptr.stderr b/src/tools/clippy/tests/ui/ref_as_ptr.stderr index 371d42df528b9..c5e9af38aea09 100644 --- a/src/tools/clippy/tests/ui/ref_as_ptr.stderr +++ b/src/tools/clippy/tests/ui/ref_as_ptr.stderr @@ -1,266 +1,266 @@ error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:5:13 + --> tests/ui/ref_as_ptr.rs:7:7 | -LL | let _ = &1u8 as *const _; - | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` +LL | f(&1u8 as *const _); + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` | = note: `-D clippy::ref-as-ptr` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::ref_as_ptr)]` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:6:13 + --> tests/ui/ref_as_ptr.rs:8:7 | -LL | let _ = &2u32 as *const u32; - | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` +LL | f(&2u32 as *const u32); + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:7:13 + --> tests/ui/ref_as_ptr.rs:9:7 | -LL | let _ = &3.0f64 as *const f64; - | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` +LL | f(&3.0f64 as *const f64); + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:9:13 + --> tests/ui/ref_as_ptr.rs:11:7 | -LL | let _ = &4 as *const _ as *const f32; - | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` +LL | f(&4 as *const _ as *const f32); + | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:10:13 + --> tests/ui/ref_as_ptr.rs:12:7 | -LL | let _ = &5.0f32 as *const f32 as *const u32; - | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` +LL | f(&5.0f32 as *const f32 as *const u32); + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:12:13 + --> tests/ui/ref_as_ptr.rs:14:7 | -LL | let _ = &mut 6u8 as *const _; - | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 6u8)` +LL | f(&mut 6u8 as *const _); + | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 6u8)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:13:13 + --> tests/ui/ref_as_ptr.rs:15:7 | -LL | let _ = &mut 7u32 as *const u32; - | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 7u32)` +LL | f(&mut 7u32 as *const u32); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 7u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:14:13 + --> tests/ui/ref_as_ptr.rs:16:7 | -LL | let _ = &mut 8.0f64 as *const f64; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 8.0f64)` +LL | f(&mut 8.0f64 as *const f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 8.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:16:13 + --> tests/ui/ref_as_ptr.rs:18:7 | -LL | let _ = &mut 9 as *const _ as *const f32; - | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 9)` +LL | f(&mut 9 as *const _ as *const f32); + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut 9)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:17:13 + --> tests/ui/ref_as_ptr.rs:19:7 | -LL | let _ = &mut 10.0f32 as *const f32 as *const u32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 10.0f32)` +LL | f(&mut 10.0f32 as *const f32 as *const u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut 10.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:19:13 + --> tests/ui/ref_as_ptr.rs:21:7 | -LL | let _ = &mut 11u8 as *mut _; - | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 11u8)` +LL | f(&mut 11u8 as *mut _); + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 11u8)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:20:13 + --> tests/ui/ref_as_ptr.rs:22:7 | -LL | let _ = &mut 12u32 as *mut u32; - | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 12u32)` +LL | f(&mut 12u32 as *mut u32); + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 12u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:21:13 + --> tests/ui/ref_as_ptr.rs:23:7 | -LL | let _ = &mut 13.0f64 as *mut f64; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 13.0f64)` +LL | f(&mut 13.0f64 as *mut f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 13.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:23:13 + --> tests/ui/ref_as_ptr.rs:25:7 | -LL | let _ = &mut 14 as *mut _ as *const f32; - | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 14)` +LL | f(&mut 14 as *mut _ as *const f32); + | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut 14)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:24:13 + --> tests/ui/ref_as_ptr.rs:26:7 | -LL | let _ = &mut 15.0f32 as *mut f32 as *const u32; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 15.0f32)` +LL | f(&mut 15.0f32 as *mut f32 as *const u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut 15.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:26:13 + --> tests/ui/ref_as_ptr.rs:28:7 | -LL | let _ = &1u8 as *const _; - | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` +LL | f(&1u8 as *const _); + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&1u8)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:27:13 + --> tests/ui/ref_as_ptr.rs:29:7 | -LL | let _ = &2u32 as *const u32; - | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` +LL | f(&2u32 as *const u32); + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&2u32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:28:13 + --> tests/ui/ref_as_ptr.rs:30:7 | -LL | let _ = &3.0f64 as *const f64; - | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` +LL | f(&3.0f64 as *const f64); + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&3.0f64)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:30:13 + --> tests/ui/ref_as_ptr.rs:32:7 | -LL | let _ = &4 as *const _ as *const f32; - | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` +LL | f(&4 as *const _ as *const f32); + | ^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&4)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:31:13 + --> tests/ui/ref_as_ptr.rs:33:7 | -LL | let _ = &5.0f32 as *const f32 as *const u32; - | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` +LL | f(&5.0f32 as *const f32 as *const u32); + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&5.0f32)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:34:13 + --> tests/ui/ref_as_ptr.rs:36:7 | -LL | let _ = &val as *const _; - | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` +LL | f(&val as *const _); + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:35:13 + --> tests/ui/ref_as_ptr.rs:37:7 | -LL | let _ = &val as *const i32; - | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` +LL | f(&val as *const i32); + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:37:13 + --> tests/ui/ref_as_ptr.rs:39:7 | -LL | let _ = &val as *const _ as *const f32; - | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` +LL | f(&val as *const _ as *const f32); + | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:38:13 + --> tests/ui/ref_as_ptr.rs:40:7 | -LL | let _ = &val as *const i32 as *const f64; - | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` +LL | f(&val as *const i32 as *const f64); + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:41:13 + --> tests/ui/ref_as_ptr.rs:43:7 | -LL | let _ = &mut val as *mut u8; - | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut val)` +LL | f(&mut val as *mut u8); + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:42:13 + --> tests/ui/ref_as_ptr.rs:44:7 | -LL | let _ = &mut val as *mut _; - | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut val)` +LL | f(&mut val as *mut _); + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:44:13 + --> tests/ui/ref_as_ptr.rs:46:7 | -LL | let _ = &mut val as *const u8; - | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` +LL | f(&mut val as *const u8); + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:45:13 + --> tests/ui/ref_as_ptr.rs:47:7 | -LL | let _ = &mut val as *const _; - | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` +LL | f(&mut val as *const _); + | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:47:13 + --> tests/ui/ref_as_ptr.rs:49:7 | -LL | let _ = &mut val as *const u8 as *const f64; - | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` +LL | f(&mut val as *const u8 as *const f64); + | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:48:32 + --> tests/ui/ref_as_ptr.rs:50:28 | -LL | let _: *const Option = &mut val as *const _ as *const _; - | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` +LL | f::<*const Option>(&mut val as *const _ as *const _); + | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(&mut val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:50:13 + --> tests/ui/ref_as_ptr.rs:52:7 | -LL | let _ = &std::array::from_fn(|i| i * i) as *const [usize; 7]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 7]>(&std::array::from_fn(|i| i * i))` +LL | f(&std::array::from_fn(|i| i * i) as *const [usize; 7]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 7]>(&std::array::from_fn(|i| i * i))` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:51:13 + --> tests/ui/ref_as_ptr.rs:53:7 | -LL | let _ = &mut std::array::from_fn(|i| i * i) as *const [usize; 8]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 8]>(&mut std::array::from_fn(|i| i * i))` +LL | f(&mut std::array::from_fn(|i| i * i) as *const [usize; 8]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[usize; 8]>(&mut std::array::from_fn(|i| i * i))` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:52:13 + --> tests/ui/ref_as_ptr.rs:54:7 | -LL | let _ = &mut std::array::from_fn(|i| i * i) as *mut [usize; 9]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i))` +LL | f(&mut std::array::from_fn(|i| i * i) as *mut [usize; 9]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::<[usize; 9]>(&mut std::array::from_fn(|i| i * i))` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:70:13 + --> tests/ui/ref_as_ptr.rs:76:7 | -LL | let _ = val as *const i32; - | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(val)` +LL | f(val as *const i32); + | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:71:13 + --> tests/ui/ref_as_ptr.rs:77:7 | -LL | let _ = mut_val as *mut i32; - | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(mut_val)` +LL | f(mut_val as *mut i32); + | ^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(mut_val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:75:13 + --> tests/ui/ref_as_ptr.rs:81:7 | -LL | let _ = val as *const _; - | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(val)` +LL | f(val as *const _); + | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:76:13 + --> tests/ui/ref_as_ptr.rs:82:7 | -LL | let _ = val as *const [u8]; - | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[u8]>(val)` +LL | f(val as *const [u8]); + | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref::<[u8]>(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:80:13 + --> tests/ui/ref_as_ptr.rs:86:7 | -LL | let _ = val as *mut _; - | ^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(val)` +LL | f(val as *mut _); + | ^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:81:13 + --> tests/ui/ref_as_ptr.rs:87:7 | -LL | let _ = val as *mut str; - | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(val)` +LL | f(val as *mut str); + | ^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut::(val)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:88:9 + --> tests/ui/ref_as_ptr.rs:94:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:92:9 + --> tests/ui/ref_as_ptr.rs:98:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:100:9 + --> tests/ui/ref_as_ptr.rs:106:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:104:9 + --> tests/ui/ref_as_ptr.rs:110:9 | LL | self.0 as *const _ as *const _ | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_ref(self.0)` error: reference as raw pointer - --> $DIR/ref_as_ptr.rs:108:9 + --> tests/ui/ref_as_ptr.rs:114:9 | LL | self.0 as *mut _ as *mut _ | ^^^^^^^^^^^^^^^^ help: try: `std::ptr::from_mut(self.0)` 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 6e8b43a3e52a5..96886f80265d8 100644 --- a/src/tools/clippy/tests/ui/ref_binding_to_reference.stderr +++ b/src/tools/clippy/tests/ui/ref_binding_to_reference.stderr @@ -1,5 +1,5 @@ error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:31:14 + --> tests/ui/ref_binding_to_reference.rs:31:14 | LL | Some(ref x) => x, | ^^^^^ @@ -12,7 +12,7 @@ LL | Some(x) => &x, | ~ ~~ error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:39:14 + --> tests/ui/ref_binding_to_reference.rs:39:14 | LL | Some(ref x) => { | ^^^^^ @@ -27,7 +27,7 @@ LL ~ &x | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:50:14 + --> tests/ui/ref_binding_to_reference.rs:50:14 | LL | Some(ref x) => m2!(x), | ^^^^^ @@ -38,7 +38,7 @@ LL | Some(x) => m2!(&x), | ~ ~~ error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:56:15 + --> tests/ui/ref_binding_to_reference.rs:56:15 | LL | let _ = |&ref x: &&String| { | ^^^^^ @@ -51,7 +51,7 @@ LL ~ let _: &&String = &x; | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:63:12 + --> tests/ui/ref_binding_to_reference.rs:63:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { | ^^^^^ @@ -65,7 +65,7 @@ LL ~ x | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:71:11 + --> tests/ui/ref_binding_to_reference.rs:71:11 | LL | fn f(&ref x: &&String) { | ^^^^^ @@ -78,7 +78,7 @@ LL ~ let _: &&String = &x; | error: this pattern creates a reference to a reference - --> $DIR/ref_binding_to_reference.rs:80:11 + --> tests/ui/ref_binding_to_reference.rs:80:11 | LL | fn f(&ref x: &&String) { | ^^^^^ diff --git a/src/tools/clippy/tests/ui/ref_option_ref.stderr b/src/tools/clippy/tests/ui/ref_option_ref.stderr index 6a28a68dc2bbb..1cb64e1182a55 100644 --- a/src/tools/clippy/tests/ui/ref_option_ref.stderr +++ b/src/tools/clippy/tests/ui/ref_option_ref.stderr @@ -1,5 +1,5 @@ error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:10:23 + --> tests/ui/ref_option_ref.rs:10:23 | LL | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` @@ -8,61 +8,61 @@ LL | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); = 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 + --> tests/ui/ref_option_ref.rs:14:18 | LL | const REF_CONST: &Option<&i32> = &Some(CONST_THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:17:25 + --> tests/ui/ref_option_ref.rs:17:25 | LL | type RefOptRefU32<'a> = &'a Option<&'a u32>; | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:19:25 + --> tests/ui/ref_option_ref.rs:19:25 | LL | type RefOptRef<'a, T> = &'a Option<&'a T>; | ^^^^^^^^^^^^^^^^^ help: try: `Option<&'a T>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:22:14 + --> tests/ui/ref_option_ref.rs:22:14 | LL | fn foo(data: &Option<&u32>) {} | ^^^^^^^^^^^^^ help: try: `Option<&u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:25:23 + --> tests/ui/ref_option_ref.rs:25:23 | LL | fn bar(data: &u32) -> &Option<&u32> { | ^^^^^^^^^^^^^ help: try: `Option<&u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:31:11 + --> tests/ui/ref_option_ref.rs:31:11 | LL | data: &'a Option<&'a u32>, | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:35:32 + --> tests/ui/ref_option_ref.rs:35:32 | LL | struct StructTupleRef<'a>(u32, &'a Option<&'a u32>); | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:40:14 + --> tests/ui/ref_option_ref.rs:40:14 | LL | Variant2(&'a Option<&'a u32>), | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:50:14 + --> tests/ui/ref_option_ref.rs:50:14 | LL | type A = &'static Option<&'static Self>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'static Self>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> $DIR/ref_option_ref.rs:57:12 + --> tests/ui/ref_option_ref.rs:57:12 | LL | let x: &Option<&u32> = &None; | ^^^^^^^^^^^^^ help: try: `Option<&u32>` diff --git a/src/tools/clippy/tests/ui/ref_patterns.stderr b/src/tools/clippy/tests/ui/ref_patterns.stderr index 74892bac6e4f4..9e2d036e34838 100644 --- a/src/tools/clippy/tests/ui/ref_patterns.stderr +++ b/src/tools/clippy/tests/ui/ref_patterns.stderr @@ -1,5 +1,5 @@ error: usage of ref pattern - --> $DIR/ref_patterns.rs:8:14 + --> tests/ui/ref_patterns.rs:8:14 | LL | Some(ref opt) => {}, | ^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(ref opt) => {}, = help: to override `-D warnings` add `#[allow(clippy::ref_patterns)]` error: usage of ref pattern - --> $DIR/ref_patterns.rs:15:9 + --> tests/ui/ref_patterns.rs:15:9 | LL | let ref y = x; | ^^^^^ @@ -17,7 +17,7 @@ LL | let ref y = x; = help: consider using `&` for clarity instead error: usage of ref pattern - --> $DIR/ref_patterns.rs:19:21 + --> tests/ui/ref_patterns.rs:19:21 | LL | fn use_in_parameter(ref x: i32) {} | ^^^^^ diff --git a/src/tools/clippy/tests/ui/regex.stderr b/src/tools/clippy/tests/ui/regex.stderr index 6d98d691d6f0a..e936208d8d7b6 100644 --- a/src/tools/clippy/tests/ui/regex.stderr +++ b/src/tools/clippy/tests/ui/regex.stderr @@ -1,5 +1,5 @@ error: trivial regex - --> $DIR/regex.rs:19:45 + --> tests/ui/regex.rs:19:45 | LL | let pipe_in_wrong_position = Regex::new("|"); | ^^^ @@ -9,7 +9,7 @@ LL | let pipe_in_wrong_position = Regex::new("|"); = help: to override `-D warnings` add `#[allow(clippy::trivial_regex)]` error: trivial regex - --> $DIR/regex.rs:21:60 + --> tests/ui/regex.rs:21:60 | LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | ^^^ @@ -17,7 +17,7 @@ LL | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); = help: the regex is unlikely to be useful as it is error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:23:42 + --> tests/ui/regex.rs:23:42 | LL | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ @@ -26,7 +26,7 @@ LL | let wrong_char_ranice = Regex::new("[z-a]"); = 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:26:37 + --> tests/ui/regex.rs:26:37 | LL | let some_unicode = Regex::new("[é-è]"); | ^^^ @@ -35,13 +35,13 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:29:33 + --> tests/ui/regex.rs:29:33 | LL | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: trivial regex - --> $DIR/regex.rs:31:53 + --> tests/ui/regex.rs:31:53 | LL | let binary_pipe_in_wrong_position = BRegex::new("|"); | ^^^ @@ -52,7 +52,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:33:41 + --> tests/ui/regex.rs:33:41 | LL | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:34:56 + --> tests/ui/regex.rs:34:56 | LL | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:46:37 + --> tests/ui/regex.rs:46:37 | LL | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); | ^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ error: regex parse error: ( ^ error: unclosed group - --> $DIR/regex.rs:47:39 + --> tests/ui/regex.rs:47:39 | LL | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); | ^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ error: regex parse error: \b\c ^^ error: unrecognized escape sequence - --> $DIR/regex.rs:54:42 + --> tests/ui/regex.rs:54:42 | LL | let escaped_string_span = Regex::new("\\b\\c"); | ^^^^^^^^ @@ -96,19 +96,19 @@ LL | let escaped_string_span = Regex::new("\\b\\c"); = help: consider using a raw string literal: `r".."` error: regex syntax error: duplicate flag - --> $DIR/regex.rs:56:34 + --> tests/ui/regex.rs:56:34 | LL | let aux_span = Regex::new("(?ixi)"); | ^ ^ error: regex syntax error: pattern can match invalid UTF-8 - --> $DIR/regex.rs:62:53 + --> tests/ui/regex.rs:62:53 | LL | let invalid_utf8_should_lint = Regex::new("(?-u)."); | ^ error: trivial regex - --> $DIR/regex.rs:67:33 + --> tests/ui/regex.rs:67:33 | LL | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | let trivial_eq = Regex::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:70:48 + --> tests/ui/regex.rs:70:48 | LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ @@ -124,7 +124,7 @@ LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:73:42 + --> tests/ui/regex.rs:73:42 | LL | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ @@ -132,7 +132,7 @@ LL | let trivial_starts_with = Regex::new("^foobar"); = help: consider using `str::starts_with` error: trivial regex - --> $DIR/regex.rs:76:40 + --> tests/ui/regex.rs:76:40 | LL | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ @@ -140,7 +140,7 @@ LL | let trivial_ends_with = Regex::new("foobar$"); = help: consider using `str::ends_with` error: trivial regex - --> $DIR/regex.rs:79:39 + --> tests/ui/regex.rs:79:39 | LL | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ @@ -148,7 +148,7 @@ LL | let trivial_contains = Regex::new("foobar"); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:82:39 + --> tests/ui/regex.rs:82:39 | LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ @@ -156,7 +156,7 @@ LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:85:40 + --> tests/ui/regex.rs:85:40 | LL | let trivial_backslash = Regex::new("a\\.b"); | ^^^^^^^ @@ -164,7 +164,7 @@ LL | let trivial_backslash = Regex::new("a\\.b"); = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:89:36 + --> tests/ui/regex.rs:89:36 | LL | let trivial_empty = Regex::new(""); | ^^ @@ -172,7 +172,7 @@ LL | let trivial_empty = Regex::new(""); = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:92:36 + --> tests/ui/regex.rs:92:36 | LL | let trivial_empty = Regex::new("^"); | ^^^ @@ -180,7 +180,7 @@ LL | let trivial_empty = Regex::new("^"); = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:95:36 + --> tests/ui/regex.rs:95:36 | LL | let trivial_empty = Regex::new("^$"); | ^^^^ @@ -188,7 +188,7 @@ LL | let trivial_empty = Regex::new("^$"); = help: consider using `str::is_empty` error: trivial regex - --> $DIR/regex.rs:98:44 + --> tests/ui/regex.rs:98:44 | LL | let binary_trivial_empty = BRegex::new("^$"); | ^^^^ diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index f63ad82a75753..e6659b109e520 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -1,5 +1,5 @@ error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range` - --> $DIR/rename.rs:55:9 + --> tests/ui/rename.rs:55:9 | LL | #![warn(clippy::almost_complete_letter_range)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range` @@ -8,343 +8,343 @@ LL | #![warn(clippy::almost_complete_letter_range)] = 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:56:9 + --> tests/ui/rename.rs:56:9 | LL | #![warn(clippy::blacklisted_name)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names` error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_conditions` - --> $DIR/rename.rs:57:9 + --> tests/ui/rename.rs:57:9 | LL | #![warn(clippy::block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_conditions` - --> $DIR/rename.rs:58:9 + --> tests/ui/rename.rs:58:9 | LL | #![warn(clippy::block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::blocks_in_if_conditions` has been renamed to `clippy::blocks_in_conditions` - --> $DIR/rename.rs:59:9 + --> tests/ui/rename.rs:59:9 | LL | #![warn(clippy::blocks_in_if_conditions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions` error: lint `clippy::box_vec` has been renamed to `clippy::box_collection` - --> $DIR/rename.rs:60:9 + --> tests/ui/rename.rs:60:9 | LL | #![warn(clippy::box_vec)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection` error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` - --> $DIR/rename.rs:61:9 + --> tests/ui/rename.rs:61:9 | LL | #![warn(clippy::const_static_lifetime)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes` error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` - --> $DIR/rename.rs:62:9 + --> tests/ui/rename.rs:62:9 | LL | #![warn(clippy::cyclomatic_complexity)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity` error: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` - --> $DIR/rename.rs:63:9 + --> tests/ui/rename.rs:63:9 | LL | #![warn(clippy::derive_hash_xor_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods` - --> $DIR/rename.rs:64:9 + --> tests/ui/rename.rs:64:9 | LL | #![warn(clippy::disallowed_method)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods` error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` - --> $DIR/rename.rs:65:9 + --> tests/ui/rename.rs:65:9 | LL | #![warn(clippy::disallowed_type)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types` error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression` - --> $DIR/rename.rs:66:9 + --> tests/ui/rename.rs:66:9 | LL | #![warn(clippy::eval_order_dependence)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression` error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` - --> $DIR/rename.rs:67:9 + --> tests/ui/rename.rs:67:9 | LL | #![warn(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion` error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok` - --> $DIR/rename.rs:68:9 + --> tests/ui/rename.rs:68:9 | LL | #![warn(clippy::if_let_some_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok` error: lint `clippy::incorrect_clone_impl_on_copy_type` has been renamed to `clippy::non_canonical_clone_impl` - --> $DIR/rename.rs:69:9 + --> tests/ui/rename.rs:69:9 | LL | #![warn(clippy::incorrect_clone_impl_on_copy_type)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_clone_impl` error: lint `clippy::incorrect_partial_ord_impl_on_ord_type` has been renamed to `clippy::non_canonical_partial_ord_impl` - --> $DIR/rename.rs:70:9 + --> tests/ui/rename.rs:70:9 | LL | #![warn(clippy::incorrect_partial_ord_impl_on_ord_type)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_partial_ord_impl` error: lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects` - --> $DIR/rename.rs:71:9 + --> tests/ui/rename.rs:71:9 | LL | #![warn(clippy::integer_arithmetic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::arithmetic_side_effects` error: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr` - --> $DIR/rename.rs:72:9 + --> tests/ui/rename.rs:72:9 | LL | #![warn(clippy::logic_bug)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::overly_complex_bool_expr` error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` - --> $DIR/rename.rs:73:9 + --> tests/ui/rename.rs:73:9 | LL | #![warn(clippy::new_without_default_derive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default` error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map` - --> $DIR/rename.rs:74:9 + --> tests/ui/rename.rs:74:9 | LL | #![warn(clippy::option_and_then_some)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map` error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used` - --> $DIR/rename.rs:75:9 + --> tests/ui/rename.rs:75:9 | LL | #![warn(clippy::option_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:76:9 + --> tests/ui/rename.rs:76:9 | LL | #![warn(clippy::option_map_unwrap_or)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:77:9 + --> tests/ui/rename.rs:77:9 | LL | #![warn(clippy::option_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used` - --> $DIR/rename.rs:78:9 + --> tests/ui/rename.rs:78:9 | LL | #![warn(clippy::option_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow` - --> $DIR/rename.rs:79:9 + --> tests/ui/rename.rs:79:9 | LL | #![warn(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow` error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used` - --> $DIR/rename.rs:80:9 + --> tests/ui/rename.rs:80:9 | LL | #![warn(clippy::result_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` - --> $DIR/rename.rs:81:9 + --> tests/ui/rename.rs:81:9 | LL | #![warn(clippy::result_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used` - --> $DIR/rename.rs:82:9 + --> tests/ui/rename.rs:82:9 | LL | #![warn(clippy::result_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str` - --> $DIR/rename.rs:83:9 + --> tests/ui/rename.rs:83:9 | LL | #![warn(clippy::single_char_push_str)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str` error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` - --> $DIR/rename.rs:84:9 + --> tests/ui/rename.rs:84:9 | LL | #![warn(clippy::stutter)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl` - --> $DIR/rename.rs:85:9 + --> tests/ui/rename.rs:85:9 | LL | #![warn(clippy::to_string_in_display)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl` error: lint `clippy::unwrap_or_else_default` has been renamed to `clippy::unwrap_or_default` - --> $DIR/rename.rs:86:9 + --> tests/ui/rename.rs:86:9 | LL | #![warn(clippy::unwrap_or_else_default)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_or_default` error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters` - --> $DIR/rename.rs:87:9 + --> tests/ui/rename.rs:87:9 | LL | #![warn(clippy::zero_width_space)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters` error: lint `clippy::cast_ref_to_mut` has been renamed to `invalid_reference_casting` - --> $DIR/rename.rs:88:9 + --> tests/ui/rename.rs:88:9 | LL | #![warn(clippy::cast_ref_to_mut)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_reference_casting` error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op` - --> $DIR/rename.rs:89:9 + --> tests/ui/rename.rs:89:9 | LL | #![warn(clippy::clone_double_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `suspicious_double_ref_op` error: lint `clippy::cmp_nan` has been renamed to `invalid_nan_comparisons` - --> $DIR/rename.rs:90:9 + --> tests/ui/rename.rs:90:9 | LL | #![warn(clippy::cmp_nan)] | ^^^^^^^^^^^^^^^ help: use the new name: `invalid_nan_comparisons` error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` - --> $DIR/rename.rs:91:9 + --> tests/ui/rename.rs:91:9 | LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types` - --> $DIR/rename.rs:92:9 + --> tests/ui/rename.rs:92:9 | LL | #![warn(clippy::drop_copy)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types` error: lint `clippy::drop_ref` has been renamed to `dropping_references` - --> $DIR/rename.rs:93:9 + --> tests/ui/rename.rs:93:9 | LL | #![warn(clippy::drop_ref)] | ^^^^^^^^^^^^^^^^ help: use the new name: `dropping_references` error: lint `clippy::fn_null_check` has been renamed to `useless_ptr_null_checks` - --> $DIR/rename.rs:94:9 + --> tests/ui/rename.rs:94:9 | LL | #![warn(clippy::fn_null_check)] | ^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `useless_ptr_null_checks` error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:95:9 + --> tests/ui/rename.rs:95:9 | LL | #![warn(clippy::for_loop_over_option)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:96:9 + --> tests/ui/rename.rs:96:9 | LL | #![warn(clippy::for_loop_over_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` - --> $DIR/rename.rs:97:9 + --> tests/ui/rename.rs:97:9 | LL | #![warn(clippy::for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types` - --> $DIR/rename.rs:98:9 + --> tests/ui/rename.rs:98:9 | LL | #![warn(clippy::forget_copy)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types` error: lint `clippy::forget_ref` has been renamed to `forgetting_references` - --> $DIR/rename.rs:99:9 + --> tests/ui/rename.rs:99:9 | LL | #![warn(clippy::forget_ref)] | ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references` error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` - --> $DIR/rename.rs:100:9 + --> tests/ui/rename.rs:100:9 | LL | #![warn(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter` error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` - --> $DIR/rename.rs:101:9 + --> tests/ui/rename.rs:101:9 | LL | #![warn(clippy::invalid_atomic_ordering)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering` error: lint `clippy::invalid_ref` has been renamed to `invalid_value` - --> $DIR/rename.rs:102:9 + --> tests/ui/rename.rs:102:9 | LL | #![warn(clippy::invalid_ref)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value` error: lint `clippy::invalid_utf8_in_unchecked` has been renamed to `invalid_from_utf8_unchecked` - --> $DIR/rename.rs:103:9 + --> tests/ui/rename.rs:103:9 | LL | #![warn(clippy::invalid_utf8_in_unchecked)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_from_utf8_unchecked` error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop` - --> $DIR/rename.rs:104:9 + --> tests/ui/rename.rs:104:9 | LL | #![warn(clippy::let_underscore_drop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop` error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` - --> $DIR/rename.rs:105:9 + --> tests/ui/rename.rs:105:9 | LL | #![warn(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums` error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` - --> $DIR/rename.rs:106:9 + --> tests/ui/rename.rs:106:9 | LL | #![warn(clippy::panic_params)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally` - --> $DIR/rename.rs:107:9 + --> tests/ui/rename.rs:107:9 | LL | #![warn(clippy::positional_named_format_parameters)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally` error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` - --> $DIR/rename.rs:108:9 + --> tests/ui/rename.rs:108:9 | LL | #![warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` error: lint `clippy::undropped_manually_drops` has been renamed to `undropped_manually_drops` - --> $DIR/rename.rs:109:9 + --> tests/ui/rename.rs:109:9 | LL | #![warn(clippy::undropped_manually_drops)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `undropped_manually_drops` error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` - --> $DIR/rename.rs:110:9 + --> tests/ui/rename.rs:110:9 | LL | #![warn(clippy::unknown_clippy_lints)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints` error: lint `clippy::unused_label` has been renamed to `unused_labels` - --> $DIR/rename.rs:111:9 + --> tests/ui/rename.rs:111:9 | LL | #![warn(clippy::unused_label)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels` error: lint `clippy::vtable_address_comparisons` has been renamed to `ambiguous_wide_pointer_comparisons` - --> $DIR/rename.rs:112:9 + --> tests/ui/rename.rs:112:9 | LL | #![warn(clippy::vtable_address_comparisons)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `ambiguous_wide_pointer_comparisons` diff --git a/src/tools/clippy/tests/ui/renamed_builtin_attr.stderr b/src/tools/clippy/tests/ui/renamed_builtin_attr.stderr index 662188bbabc5a..f9108d169c718 100644 --- a/src/tools/clippy/tests/ui/renamed_builtin_attr.stderr +++ b/src/tools/clippy/tests/ui/renamed_builtin_attr.stderr @@ -1,5 +1,5 @@ error: usage of deprecated attribute - --> $DIR/renamed_builtin_attr.rs:1:11 + --> tests/ui/renamed_builtin_attr.rs:1:11 | LL | #[clippy::cyclomatic_complexity = "1"] | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `cognitive_complexity` diff --git a/src/tools/clippy/tests/ui/repeat_once.stderr b/src/tools/clippy/tests/ui/repeat_once.stderr index 895729390785a..6996dc5eee7d3 100644 --- a/src/tools/clippy/tests/ui/repeat_once.stderr +++ b/src/tools/clippy/tests/ui/repeat_once.stderr @@ -1,5 +1,5 @@ error: calling `repeat(1)` on slice - --> $DIR/repeat_once.rs:9:13 + --> tests/ui/repeat_once.rs:9:13 | LL | let a = [1; 5].repeat(1); | ^^^^^^^^^^^^^^^^ help: consider using `.to_vec()` instead: `[1; 5].to_vec()` @@ -8,31 +8,31 @@ LL | let a = [1; 5].repeat(1); = help: to override `-D warnings` add `#[allow(clippy::repeat_once)]` error: calling `repeat(1)` on slice - --> $DIR/repeat_once.rs:10:13 + --> tests/ui/repeat_once.rs:10:13 | LL | let b = slice.repeat(1); | ^^^^^^^^^^^^^^^ help: consider using `.to_vec()` instead: `slice.to_vec()` error: calling `repeat(1)` on str - --> $DIR/repeat_once.rs:11:13 + --> tests/ui/repeat_once.rs:11:13 | LL | let c = "hello".repeat(N); | ^^^^^^^^^^^^^^^^^ help: consider using `.to_string()` instead: `"hello".to_string()` error: calling `repeat(1)` on str - --> $DIR/repeat_once.rs:12:13 + --> tests/ui/repeat_once.rs:12:13 | LL | let d = "hi".repeat(1); | ^^^^^^^^^^^^^^ help: consider using `.to_string()` instead: `"hi".to_string()` error: calling `repeat(1)` on str - --> $DIR/repeat_once.rs:13:13 + --> tests/ui/repeat_once.rs:13:13 | LL | let e = s.repeat(1); | ^^^^^^^^^^^ help: consider using `.to_string()` instead: `s.to_string()` error: calling `repeat(1)` on a string literal - --> $DIR/repeat_once.rs:14:13 + --> tests/ui/repeat_once.rs:14:13 | LL | let f = string.repeat(1); | ^^^^^^^^^^^^^^^^ help: consider using `.clone()` instead: `string.clone()` diff --git a/src/tools/clippy/tests/ui/repeat_vec_with_capacity.stderr b/src/tools/clippy/tests/ui/repeat_vec_with_capacity.stderr index 10b5f121420e1..cec9c6ea84a27 100644 --- a/src/tools/clippy/tests/ui/repeat_vec_with_capacity.stderr +++ b/src/tools/clippy/tests/ui/repeat_vec_with_capacity.stderr @@ -1,5 +1,5 @@ error: repeating `Vec::with_capacity` using `vec![x; n]`, which does not retain capacity - --> $DIR/repeat_vec_with_capacity.rs:5:9 + --> tests/ui/repeat_vec_with_capacity.rs:5:9 | LL | vec![Vec::<()>::with_capacity(42); 123]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | (0..123).map(|_| Vec::<()>::with_capacity(42)).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: repeating `Vec::with_capacity` using `vec![x; n]`, which does not retain capacity - --> $DIR/repeat_vec_with_capacity.rs:11:9 + --> tests/ui/repeat_vec_with_capacity.rs:11:9 | LL | vec![Vec::<()>::with_capacity(42); n]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | (0..n).map(|_| Vec::<()>::with_capacity(42)).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: repeating `Vec::with_capacity` using `iter::repeat`, which does not retain capacity - --> $DIR/repeat_vec_with_capacity.rs:26:9 + --> tests/ui/repeat_vec_with_capacity.rs:26:9 | LL | std::iter::repeat(Vec::<()>::with_capacity(42)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/repl_uninit.stderr b/src/tools/clippy/tests/ui/repl_uninit.stderr index c82f29adb5ac4..645c4a16a07eb 100644 --- a/src/tools/clippy/tests/ui/repl_uninit.stderr +++ b/src/tools/clippy/tests/ui/repl_uninit.stderr @@ -1,5 +1,5 @@ error: replacing with `mem::uninitialized()` - --> $DIR/repl_uninit.rs:15:23 + --> tests/ui/repl_uninit.rs:15:23 | LL | let taken_v = mem::replace(&mut v, mem::uninitialized()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` @@ -8,13 +8,13 @@ LL | let taken_v = mem::replace(&mut v, mem::uninitialized()); = 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 + --> tests/ui/repl_uninit.rs:23:23 | LL | let taken_v = mem::replace(&mut v, mem::MaybeUninit::uninit().assume_init()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` error: replacing with `mem::zeroed()` - --> $DIR/repl_uninit.rs:30:23 + --> tests/ui/repl_uninit.rs:30:23 | LL | let taken_v = mem::replace(&mut v, mem::zeroed()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | let taken_v = mem::replace(&mut v, mem::zeroed()); = help: consider using a default value or the `take_mut` crate instead error: replacing with `mem::uninitialized()` - --> $DIR/repl_uninit.rs:43:28 + --> tests/ui/repl_uninit.rs:43:28 | LL | let taken_u = unsafe { mem::replace(uref, mem::uninitialized()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(uref)` diff --git a/src/tools/clippy/tests/ui/reserve_after_initialization.stderr b/src/tools/clippy/tests/ui/reserve_after_initialization.stderr index a910338907668..b6dbebb3f14c2 100644 --- a/src/tools/clippy/tests/ui/reserve_after_initialization.stderr +++ b/src/tools/clippy/tests/ui/reserve_after_initialization.stderr @@ -1,5 +1,5 @@ error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:10:5 + --> tests/ui/reserve_after_initialization.rs:10:5 | LL | / let mut v1: Vec = vec![]; LL | | v1.reserve(10); @@ -9,14 +9,14 @@ LL | | v1.reserve(10); = 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 + --> tests/ui/reserve_after_initialization.rs:17:5 | LL | / let mut v2: Vec = vec![]; LL | | v2.reserve(capacity); | |_________________________^ help: consider using `Vec::with_capacity(/* Space hint */)`: `let mut v2: Vec = Vec::with_capacity(capacity);` error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:35:5 + --> tests/ui/reserve_after_initialization.rs:35:5 | LL | / v5 = Vec::new(); LL | | v5.reserve(10); 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 a62f1d0b65f3b..d048933ddb7bc 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 @@ -1,5 +1,5 @@ error: unnecessary use of `..` pattern in struct binding. All fields were already bound - --> $DIR/rest_pat_in_fully_bound_structs.rs:23:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:23:9 | LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint = 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:25:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:25:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint = help: consider removing `..` from this binding error: unnecessary use of `..` pattern in struct binding. All fields were already bound - --> $DIR/rest_pat_in_fully_bound_structs.rs:32:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:32:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/result_filter_map.stderr b/src/tools/clippy/tests/ui/result_filter_map.stderr index 4687794949d34..12eb7083b5a82 100644 --- a/src/tools/clippy/tests/ui/result_filter_map.stderr +++ b/src/tools/clippy/tests/ui/result_filter_map.stderr @@ -1,5 +1,5 @@ error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:13:10 + --> tests/ui/result_filter_map.rs:13:10 | LL | .filter(Result::is_ok) | __________^ @@ -11,7 +11,7 @@ LL | | .map(Result::unwrap); = help: to override `-D warnings` add `#[allow(clippy::result_filter_map)]` error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:19:10 + --> tests/ui/result_filter_map.rs:19:10 | LL | .filter(|o| o.is_ok()) | __________^ @@ -20,7 +20,7 @@ LL | | .map(|o| o.unwrap()); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:26:10 + --> tests/ui/result_filter_map.rs:26:10 | LL | .filter(Result::is_ok) | __________^ @@ -29,7 +29,7 @@ LL | | .map(Result::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Ok` followed by `unwrap` - --> $DIR/result_filter_map.rs:32:10 + --> tests/ui/result_filter_map.rs:32:10 | LL | .filter(|o| o.is_ok()) | __________^ diff --git a/src/tools/clippy/tests/ui/result_large_err.stderr b/src/tools/clippy/tests/ui/result_large_err.stderr index 6602f396a9c0d..1dff3f9efe81c 100644 --- a/src/tools/clippy/tests/ui/result_large_err.stderr +++ b/src/tools/clippy/tests/ui/result_large_err.stderr @@ -1,5 +1,5 @@ error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:10:23 + --> tests/ui/result_large_err.rs:10:23 | LL | pub fn large_err() -> Result<(), [u8; 512]> { | ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -9,7 +9,7 @@ LL | pub fn large_err() -> Result<(), [u8; 512]> { = 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:22:21 + --> tests/ui/result_large_err.rs:22:21 | LL | pub fn ret() -> Result<(), Self> { | ^^^^^^^^^^^^^^^^ the `Err`-variant is at least 240 bytes @@ -17,7 +17,7 @@ LL | pub fn ret() -> Result<(), Self> { = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:28:26 + --> tests/ui/result_large_err.rs:28:26 | LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 240 bytes @@ -25,7 +25,7 @@ LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> { = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:34:45 + --> tests/ui/result_large_err.rs:34:45 | LL | pub fn large_err_via_type_alias(x: T) -> Fdlr { | ^^^^^^^ the `Err`-variant is at least 240 bytes @@ -33,7 +33,7 @@ LL | pub fn large_err_via_type_alias(x: T) -> Fdlr { = help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:43:34 + --> tests/ui/result_large_err.rs:43:34 | LL | pub fn param_large_error() -> Result<(), (u128, R, FullyDefinedLargeError)> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes @@ -41,7 +41,7 @@ LL | pub fn param_large_error() -> Result<(), (u128, R, FullyDefinedLargeErro = help: try reducing the size of `(u128, R, FullyDefinedLargeError)`, for example by boxing large elements or replacing it with `Box<(u128, R, FullyDefinedLargeError)>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:55:34 + --> tests/ui/result_large_err.rs:55:34 | LL | _Omg([u8; 512]), | --------------- the largest variant contains at least 512 bytes @@ -52,7 +52,7 @@ LL | pub fn large_enum_error() -> Result<(), Self> { = help: try reducing the size of `LargeErrorVariants<()>`, for example by boxing large elements or replacing it with `Box>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:68:30 + --> tests/ui/result_large_err.rs:68:30 | LL | _Biggest([u8; 1024]), | -------------------- the largest variant contains at least 1024 bytes @@ -65,7 +65,7 @@ LL | fn large_enum_error() -> Result<(), Self> { = help: try reducing the size of `MultipleLargeVariants`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:75:25 + --> tests/ui/result_large_err.rs:75:25 | LL | fn large_error() -> Result<(), [u8; 512]> { | ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -73,7 +73,7 @@ LL | fn large_error() -> Result<(), [u8; 512]> { = help: try reducing the size of `[u8; 512]`, for example by boxing large elements or replacing it with `Box<[u8; 512]>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:95:29 + --> tests/ui/result_large_err.rs:95:29 | LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -81,7 +81,7 @@ LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> { = help: try reducing the size of `FullyDefinedUnionError`, for example by boxing large elements or replacing it with `Box` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:105:40 + --> tests/ui/result_large_err.rs:105:40 | LL | pub fn param_large_union() -> Result<(), UnionError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes @@ -89,7 +89,7 @@ LL | pub fn param_large_union() -> Result<(), UnionError> { = help: try reducing the size of `UnionError`, for example by boxing large elements or replacing it with `Box>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:115:34 + --> tests/ui/result_large_err.rs:115:34 | LL | pub fn array_error_subst() -> Result<(), ArrayError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 128 bytes @@ -97,7 +97,7 @@ LL | pub fn array_error_subst() -> Result<(), ArrayError> { = help: try reducing the size of `ArrayError`, for example by boxing large elements or replacing it with `Box>` error: the `Err`-variant returned from this function is very large - --> $DIR/result_large_err.rs:120:31 + --> tests/ui/result_large_err.rs:120:31 | LL | pub fn array_error() -> Result<(), ArrayError<(i32, T), U>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 128 bytes 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 201868f09efa6..4cb510d77a060 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 @@ -1,5 +1,5 @@ error: called `map_or(None, Some)` on a `Result` value - --> $DIR/result_map_or_into_option.rs:5:13 + --> tests/ui/result_map_or_into_option.rs:5:13 | LL | let _ = opt.map_or(None, Some); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `opt.ok()` @@ -8,13 +8,13 @@ LL | let _ = opt.map_or(None, Some); = help: to override `-D warnings` add `#[allow(clippy::result_map_or_into_option)]` error: called `map_or_else(|_| None, Some)` on a `Result` value - --> $DIR/result_map_or_into_option.rs:7:13 + --> tests/ui/result_map_or_into_option.rs:7:13 | LL | let _ = opt.map_or_else(|_| None, Some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `opt.ok()` error: called `map_or_else(|_| None, Some)` on a `Result` value - --> $DIR/result_map_or_into_option.rs:10:13 + --> tests/ui/result_map_or_into_option.rs:10:13 | LL | let _ = opt.map_or_else(|_| { None }, Some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok`: `opt.ok()` 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 42ee273c2bd23..4f3bc2e954495 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 @@ -1,5 +1,5 @@ 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:34:5 + --> tests/ui/result_map_unit_fn_fixable.rs:34:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -10,7 +10,7 @@ LL | x.field.map(do_nothing); = 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 + --> tests/ui/result_map_unit_fn_fixable.rs:36:5 | LL | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- @@ -18,7 +18,7 @@ LL | x.field.map(do_nothing); | help: try: `if let Ok(x_field) = x.field { do_nothing(x_field) }` 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:38:5 + --> tests/ui/result_map_unit_fn_fixable.rs:38:5 | LL | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- @@ -26,7 +26,7 @@ LL | x.field.map(diverge); | help: try: `if let Ok(x_field) = x.field { diverge(x_field) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:44:5 + --> tests/ui/result_map_unit_fn_fixable.rs:44:5 | LL | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -34,7 +34,7 @@ LL | x.field.map(|value| x.do_result_nothing(value + captured)); | help: try: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:46:5 + --> tests/ui/result_map_unit_fn_fixable.rs:46:5 | LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -42,7 +42,7 @@ LL | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | help: try: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:49:5 + --> tests/ui/result_map_unit_fn_fixable.rs:49:5 | LL | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -50,7 +50,7 @@ LL | x.field.map(|value| do_nothing(value + captured)); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:51:5 + --> tests/ui/result_map_unit_fn_fixable.rs:51:5 | LL | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -58,7 +58,7 @@ LL | x.field.map(|value| { do_nothing(value + captured) }); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:53:5 + --> tests/ui/result_map_unit_fn_fixable.rs:53:5 | LL | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -66,7 +66,7 @@ LL | x.field.map(|value| { do_nothing(value + captured); }); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:55:5 + --> tests/ui/result_map_unit_fn_fixable.rs:55:5 | LL | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -74,7 +74,7 @@ LL | x.field.map(|value| { { do_nothing(value + captured); } }); | help: try: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:58:5 + --> tests/ui/result_map_unit_fn_fixable.rs:58:5 | LL | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -82,7 +82,7 @@ LL | x.field.map(|value| diverge(value + captured)); | help: try: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:60:5 + --> tests/ui/result_map_unit_fn_fixable.rs:60:5 | LL | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -90,7 +90,7 @@ LL | x.field.map(|value| { diverge(value + captured) }); | help: try: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:62:5 + --> tests/ui/result_map_unit_fn_fixable.rs:62:5 | LL | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -98,7 +98,7 @@ LL | x.field.map(|value| { diverge(value + captured); }); | help: try: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:64:5 + --> tests/ui/result_map_unit_fn_fixable.rs:64:5 | LL | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -106,7 +106,7 @@ LL | x.field.map(|value| { { diverge(value + captured); } }); | help: try: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:69:5 + --> tests/ui/result_map_unit_fn_fixable.rs:69:5 | LL | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -114,7 +114,7 @@ LL | x.field.map(|value| { let y = plus_one(value + captured); }); | help: try: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:71:5 + --> tests/ui/result_map_unit_fn_fixable.rs:71:5 | LL | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -122,7 +122,7 @@ LL | x.field.map(|value| { plus_one(value + captured); }); | help: try: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:73:5 + --> tests/ui/result_map_unit_fn_fixable.rs:73:5 | LL | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -130,7 +130,7 @@ LL | x.field.map(|value| { { plus_one(value + captured); } }); | help: try: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:76:5 + --> tests/ui/result_map_unit_fn_fixable.rs:76:5 | LL | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -138,7 +138,7 @@ LL | x.field.map(|ref value| { do_nothing(value + captured) }); | help: try: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` - --> $DIR/result_map_unit_fn_fixable.rs:78:5 + --> tests/ui/result_map_unit_fn_fixable.rs:78:5 | LL | x.field.map(|value| println!("{:?}", value)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- 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 ccf9bfb947c70..fa2ac7a1b37e8 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 @@ -1,5 +1,5 @@ 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:23:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:23:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -10,7 +10,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); = 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 + --> tests/ui/result_map_unit_fn_unfixable.rs:27:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -18,7 +18,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) | help: try: `if let Ok(value) = x.field { ... }` 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:32:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:32:5 | LL | // x.field.map(|value| { LL | || @@ -30,7 +30,7 @@ LL | || }); | 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:37:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:37:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -38,7 +38,7 @@ LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | help: try: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:42:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:42:5 | LL | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- @@ -46,7 +46,7 @@ LL | "12".parse::().map(diverge); | help: try: `if let Ok(a) = "12".parse::() { diverge(a) }` error: called `map(f)` on an `Result` value where `f` is a function that returns the unit type `()` - --> $DIR/result_map_unit_fn_unfixable.rs:49:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:49:5 | LL | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- diff --git a/src/tools/clippy/tests/ui/result_unit_error.stderr b/src/tools/clippy/tests/ui/result_unit_error.stderr index 72208f5391647..e869a31597752 100644 --- a/src/tools/clippy/tests/ui/result_unit_error.stderr +++ b/src/tools/clippy/tests/ui/result_unit_error.stderr @@ -1,5 +1,5 @@ error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:3:1 + --> tests/ui/result_unit_error.rs:3:1 | LL | pub fn returns_unit_error() -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | pub fn returns_unit_error() -> Result { = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]` error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:13:5 + --> tests/ui/result_unit_error.rs:13:5 | LL | fn get_that_error(&self) -> Result; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn get_that_error(&self) -> Result; = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:16:5 + --> tests/ui/result_unit_error.rs:16:5 | LL | fn get_this_one_too(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn get_this_one_too(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:35:5 + --> tests/ui/result_unit_error.rs:35:5 | LL | pub fn unit_error(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | pub fn unit_error(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/result_unit_error.rs:45:5 + --> tests/ui/result_unit_error.rs:45:5 | LL | pub fn should_lint() -> ResInv<(), usize> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 b3e41470d7b12..01f826b94a803 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 @@ -1,5 +1,5 @@ error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:8:5 + --> tests/ui/return_self_not_must_use.rs:8:5 | LL | fn what(&self) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | fn what(&self) -> Self; = 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 + --> tests/ui/return_self_not_must_use.rs:19:5 | LL | / pub fn foo(&self) -> Self { LL | | @@ -20,7 +20,7 @@ LL | | } = help: consider adding the `#[must_use]` attribute to the method or directly to the `Self` type error: missing `#[must_use]` attribute on a method returning `Self` - --> $DIR/return_self_not_must_use.rs:23:5 + --> tests/ui/return_self_not_must_use.rs:23:5 | LL | / pub fn bar(self) -> Self { LL | | 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 92fbac8e30c9e..3747eb9deebc4 100644 --- a/src/tools/clippy/tests/ui/reversed_empty_ranges_fixable.stderr +++ b/src/tools/clippy/tests/ui/reversed_empty_ranges_fixable.stderr @@ -1,5 +1,5 @@ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_fixable.rs:9:5 + --> tests/ui/reversed_empty_ranges_fixable.rs:9:5 | LL | (42..=21).for_each(|x| println!("{}", x)); | ^^^^^^^^^ @@ -12,7 +12,7 @@ LL | (21..=42).rev().for_each(|x| println!("{}", x)); | ~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_fixable.rs:10:13 + --> tests/ui/reversed_empty_ranges_fixable.rs:10:13 | LL | let _ = (ANSWER..21).filter(|x| x % 2 == 0).take(10).collect::>(); | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = (21..ANSWER).rev().filter(|x| x % 2 == 0).take(10).collect:: $DIR/reversed_empty_ranges_fixable.rs:12:14 + --> tests/ui/reversed_empty_ranges_fixable.rs:12:14 | LL | for _ in -21..=-42 {} | ^^^^^^^^^ @@ -34,7 +34,7 @@ LL | for _ in (-42..=-21).rev() {} | ~~~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_fixable.rs:13:14 + --> tests/ui/reversed_empty_ranges_fixable.rs:13:14 | LL | for _ in 42u32..21u32 {} | ^^^^^^^^^^^^ 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 843d6a36d9be5..d5df34c42f4f0 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 @@ -1,5 +1,5 @@ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:7:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:7:14 | LL | for i in 10..0 { | ^^^^^ @@ -12,7 +12,7 @@ LL | for i in (0..10).rev() { | ~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:11:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:11:14 | LL | for i in 10..=0 { | ^^^^^^ @@ -23,7 +23,7 @@ LL | for i in (0..=10).rev() { | ~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:15:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:15:14 | LL | for i in MAX_LEN..0 { | ^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | for i in (0..MAX_LEN).rev() { | ~~~~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:34:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:34:14 | LL | for i in (10..0).map(|x| x * 2) { | ^^^^^^^ @@ -45,7 +45,7 @@ LL | for i in (0..10).rev().map(|x| x * 2) { | ~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:39:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:39:14 | LL | for i in 10..5 + 4 { | ^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for i in (5 + 4..10).rev() { | ~~~~~~~~~~~~~~~~~ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_fixable.rs:43:14 + --> tests/ui/reversed_empty_ranges_loops_fixable.rs:43:14 | LL | for i in (5 + 2)..(3 - 1) { | ^^^^^^^^^^^^^^^^ 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 73165e091cb16..b9e6fa04a34c6 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 @@ -1,5 +1,5 @@ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_loops_unfixable.rs:5:14 + --> tests/ui/reversed_empty_ranges_loops_unfixable.rs:5:14 | LL | for i in 5..5 { | ^^^^ @@ -8,7 +8,7 @@ LL | for i in 5..5 { = 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 + --> tests/ui/reversed_empty_ranges_loops_unfixable.rs:11:14 | LL | for i in (5 + 2)..(8 - 1) { | ^^^^^^^^^^^^^^^^ 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 e3dc96dfb9c4e..bc2b9576c41d3 100644 --- a/src/tools/clippy/tests/ui/reversed_empty_ranges_unfixable.stderr +++ b/src/tools/clippy/tests/ui/reversed_empty_ranges_unfixable.stderr @@ -1,5 +1,5 @@ error: this range is reversed and using it to index a slice will panic at run-time - --> $DIR/reversed_empty_ranges_unfixable.rs:8:18 + --> tests/ui/reversed_empty_ranges_unfixable.rs:8:18 | LL | let _ = &arr[3usize..=1usize]; | ^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | let _ = &arr[3usize..=1usize]; = 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 + --> tests/ui/reversed_empty_ranges_unfixable.rs:11:18 | LL | let _ = &arr[SOME_NUM..1]; | ^^^^^^^^^^^ error: this range is empty so it will yield no values - --> $DIR/reversed_empty_ranges_unfixable.rs:14:14 + --> tests/ui/reversed_empty_ranges_unfixable.rs:14:14 | LL | for _ in ANSWER..ANSWER {} | ^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/same_functions_in_if_condition.stderr b/src/tools/clippy/tests/ui/same_functions_in_if_condition.stderr index 199e6769ff767..6cd4f96c13e32 100644 --- a/src/tools/clippy/tests/ui/same_functions_in_if_condition.stderr +++ b/src/tools/clippy/tests/ui/same_functions_in_if_condition.stderr @@ -1,76 +1,76 @@ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:39:15 + --> tests/ui/same_functions_in_if_condition.rs:39:15 | LL | } else if function() { | ^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:38:8 + --> tests/ui/same_functions_in_if_condition.rs:38:8 | LL | if function() { | ^^^^^^^^^^ note: the lint level is defined here - --> $DIR/same_functions_in_if_condition.rs:2:9 + --> tests/ui/same_functions_in_if_condition.rs:2:9 | LL | #![deny(clippy::same_functions_in_if_condition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:44:15 + --> tests/ui/same_functions_in_if_condition.rs:44:15 | LL | } else if fn_arg(a) { | ^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:43:8 + --> tests/ui/same_functions_in_if_condition.rs:43:8 | LL | if fn_arg(a) { | ^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:49:15 + --> tests/ui/same_functions_in_if_condition.rs:49:15 | LL | } else if obj.method() { | ^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:48:8 + --> tests/ui/same_functions_in_if_condition.rs:48:8 | LL | if obj.method() { | ^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:54:15 + --> tests/ui/same_functions_in_if_condition.rs:54:15 | LL | } else if obj.method_arg(a) { | ^^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:53:8 + --> tests/ui/same_functions_in_if_condition.rs:53:8 | LL | if obj.method_arg(a) { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:60:15 + --> tests/ui/same_functions_in_if_condition.rs:60:15 | LL | } else if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:59:8 + --> tests/ui/same_functions_in_if_condition.rs:59:8 | LL | if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> $DIR/same_functions_in_if_condition.rs:65:15 + --> tests/ui/same_functions_in_if_condition.rs:65:15 | LL | } else if v.len() == 42 { | ^^^^^^^^^^^^^ | note: same as this - --> $DIR/same_functions_in_if_condition.rs:64:8 + --> tests/ui/same_functions_in_if_condition.rs:64:8 | LL | if v.len() == 42 { | ^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/same_item_push.stderr b/src/tools/clippy/tests/ui/same_item_push.stderr index f569aab64900a..eb296ed4ce4ae 100644 --- a/src/tools/clippy/tests/ui/same_item_push.stderr +++ b/src/tools/clippy/tests/ui/same_item_push.stderr @@ -1,5 +1,5 @@ error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:23:9 + --> tests/ui/same_item_push.rs:23:9 | LL | vec.push(item); | ^^^ @@ -9,7 +9,7 @@ LL | vec.push(item); = 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 + --> tests/ui/same_item_push.rs:30:9 | LL | vec.push(item); | ^^^ @@ -17,7 +17,7 @@ LL | vec.push(item); = help: consider using vec![item;SIZE] or vec.resize(NEW_SIZE, item) error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:36:9 + --> tests/ui/same_item_push.rs:36:9 | LL | vec.push(13); | ^^^ @@ -25,7 +25,7 @@ LL | vec.push(13); = help: consider using vec![13;SIZE] or vec.resize(NEW_SIZE, 13) error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:42:9 + --> tests/ui/same_item_push.rs:42:9 | LL | vec.push(VALUE); | ^^^ @@ -33,7 +33,7 @@ LL | vec.push(VALUE); = help: consider using vec![VALUE;SIZE] or vec.resize(NEW_SIZE, VALUE) error: it looks like the same item is being pushed into this Vec - --> $DIR/same_item_push.rs:49:9 + --> tests/ui/same_item_push.rs:49:9 | LL | vec.push(item); | ^^^ diff --git a/src/tools/clippy/tests/ui/same_name_method.stderr b/src/tools/clippy/tests/ui/same_name_method.stderr index 82f5ef6a9e827..6c87a64b50514 100644 --- a/src/tools/clippy/tests/ui/same_name_method.stderr +++ b/src/tools/clippy/tests/ui/same_name_method.stderr @@ -1,11 +1,11 @@ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:21:13 + --> tests/ui/same_name_method.rs:21:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:26:13 + --> tests/ui/same_name_method.rs:26:13 | LL | fn foo() {} | ^^^^^^^^^^^ @@ -13,62 +13,62 @@ LL | fn foo() {} = 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 + --> tests/ui/same_name_method.rs:36:13 | LL | fn clone() {} | ^^^^^^^^^^^^^ | note: existing `clone` defined here - --> $DIR/same_name_method.rs:32:18 + --> tests/ui/same_name_method.rs:32:18 | LL | #[derive(Clone)] | ^^^^^ = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:47:13 + --> tests/ui/same_name_method.rs:47:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:52:13 + --> tests/ui/same_name_method.rs:52:13 | LL | fn foo() {} | ^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:62:13 + --> tests/ui/same_name_method.rs:62:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:66:9 + --> tests/ui/same_name_method.rs:66:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:75:13 + --> tests/ui/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:80:9 + --> tests/ui/same_name_method.rs:80:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> $DIR/same_name_method.rs:75:13 + --> tests/ui/same_name_method.rs:75:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> $DIR/same_name_method.rs:82:9 + --> tests/ui/same_name_method.rs:82:9 | LL | impl T2 for S {} | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/search_is_some.stderr b/src/tools/clippy/tests/ui/search_is_some.stderr index 9dec8c9caf274..b5f84d23284ac 100644 --- a/src/tools/clippy/tests/ui/search_is_some.stderr +++ b/src/tools/clippy/tests/ui/search_is_some.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:15:13 + --> tests/ui/search_is_some.rs:15:13 | LL | let _ = v.iter().find(|&x| { | _____________^ @@ -13,7 +13,7 @@ LL | | ).is_some(); = 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 + --> tests/ui/search_is_some.rs:21:13 | LL | let _ = v.iter().position(|&x| { | _____________^ @@ -25,7 +25,7 @@ LL | | ).is_some(); = help: this is more succinctly expressed by calling `any()` error: called `is_some()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some.rs:27:13 + --> tests/ui/search_is_some.rs:27:13 | LL | let _ = v.iter().rposition(|&x| { | _____________^ @@ -37,13 +37,13 @@ LL | | ).is_some(); = help: this is more succinctly expressed by calling `any()` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:42:20 + --> tests/ui/search_is_some.rs:42:20 | LL | let _ = (0..1).find(some_closure).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(some_closure)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:52:13 + --> tests/ui/search_is_some.rs:52:13 | LL | let _ = v.iter().find(|&x| { | _____________^ @@ -55,7 +55,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `position` - --> $DIR/search_is_some.rs:58:13 + --> tests/ui/search_is_some.rs:58:13 | LL | let _ = v.iter().position(|&x| { | _____________^ @@ -67,7 +67,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some.rs:64:13 + --> tests/ui/search_is_some.rs:64:13 | LL | let _ = v.iter().rposition(|&x| { | _____________^ @@ -79,7 +79,7 @@ LL | | ).is_none(); = help: this is more succinctly expressed by calling `any()` with negation error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some.rs:79:13 + --> tests/ui/search_is_some.rs:79:13 | LL | let _ = (0..1).find(some_closure).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(0..1).any(some_closure)` 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 107f59a97d2f3..4ad1e2508c480 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 @@ -1,5 +1,5 @@ error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:9:13 + --> tests/ui/search_is_some_fixable_none.rs:9:13 | LL | let _ = v.iter().find(|&x| *x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| *x < 0)` @@ -8,49 +8,49 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_none(); = 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 + --> tests/ui/search_is_some_fixable_none.rs:10:13 | LL | let _ = (0..1).find(|x| **y == *x).is_none(); // one dereference less | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(0..1).any(|x| **y == x)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:11:13 + --> tests/ui/search_is_some_fixable_none.rs:11:13 | LL | let _ = (0..1).find(|x| *x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(0..1).any(|x| x == 0)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:12:13 + --> tests/ui/search_is_some_fixable_none.rs:12:13 | LL | let _ = v.iter().find(|x| **x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| *x == 0)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:13:13 + --> tests/ui/search_is_some_fixable_none.rs:13:13 | LL | let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(4..5).any(|x| x == 1 || x == 3 || x == 5)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:14:13 + --> tests/ui/search_is_some_fixable_none.rs:14:13 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(1..3).any(|x| [1, 2, 3].contains(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:15:13 + --> tests/ui/search_is_some_fixable_none.rs:15:13 | LL | let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(1..3).any(|x| x == 0 || [1, 2, 3].contains(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:16:13 + --> tests/ui/search_is_some_fixable_none.rs:16:13 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:17:13 + --> tests/ui/search_is_some_fixable_none.rs:17:13 | LL | let _ = (1..3) | _____________^ @@ -59,91 +59,91 @@ LL | | .is_none(); | |__________________^ help: consider using: `!(1..3).any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)` error: called `is_none()` after searching an `Iterator` with `position` - --> $DIR/search_is_some_fixable_none.rs:22:13 + --> tests/ui/search_is_some_fixable_none.rs:22:13 | LL | let _ = v.iter().position(|&x| x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|&x| x < 0)` error: called `is_none()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some_fixable_none.rs:25:13 + --> tests/ui/search_is_some_fixable_none.rs:25:13 | LL | let _ = v.iter().rposition(|&x| x < 0).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|&x| x < 0)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:31:13 + --> tests/ui/search_is_some_fixable_none.rs:31:13 | LL | let _ = "hello world".find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!"hello world".contains("world")` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:32:13 + --> tests/ui/search_is_some_fixable_none.rs:32:13 | LL | let _ = "hello world".find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!"hello world".contains(&s2)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:33:13 + --> tests/ui/search_is_some_fixable_none.rs:33:13 | LL | let _ = "hello world".find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!"hello world".contains(&s2[2..])` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:35:13 + --> tests/ui/search_is_some_fixable_none.rs:35:13 | LL | let _ = s1.find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1.contains("world")` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:36:13 + --> tests/ui/search_is_some_fixable_none.rs:36:13 | LL | let _ = s1.find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1.contains(&s2)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:37:13 + --> tests/ui/search_is_some_fixable_none.rs:37:13 | LL | let _ = s1.find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1.contains(&s2[2..])` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:39:13 + --> tests/ui/search_is_some_fixable_none.rs:39:13 | LL | let _ = s1[2..].find("world").is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1[2..].contains("world")` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:40:13 + --> tests/ui/search_is_some_fixable_none.rs:40:13 | LL | let _ = s1[2..].find(&s2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1[2..].contains(&s2)` error: called `is_none()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_none.rs:41:13 + --> tests/ui/search_is_some_fixable_none.rs:41:13 | LL | let _ = s1[2..].find(&s2[2..]).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!s1[2..].contains(&s2[2..])` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:57:25 + --> tests/ui/search_is_some_fixable_none.rs:57:25 | LL | .filter(|c| filter_hand.iter().find(|cc| c == cc).is_none()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!filter_hand.iter().any(|cc| c == &cc)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:73:30 + --> tests/ui/search_is_some_fixable_none.rs:73:30 | LL | .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_none()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!filter_hand.iter().any(|cc| c == cc)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:84:17 + --> tests/ui/search_is_some_fixable_none.rs:84:17 | LL | let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|v| v.foo == 1 && v.bar == 2)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:87:17 + --> tests/ui/search_is_some_fixable_none.rs:87:17 | LL | let _ = vfoo | _________________^ @@ -159,55 +159,55 @@ LL ~ .iter().any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2); | error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:95:17 + --> tests/ui/search_is_some_fixable_none.rs:95:17 | LL | let _ = vfoo.iter().find(|a| a[0] == 42).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|a| a[0] == 42)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:101:17 + --> tests/ui/search_is_some_fixable_none.rs:101:17 | LL | let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|sub| sub[1..4].len() == 3)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:119:17 + --> tests/ui/search_is_some_fixable_none.rs:119:17 | LL | let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![ppx].iter().any(|ppp_x: &&u32| please(ppp_x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:120:17 + --> tests/ui/search_is_some_fixable_none.rs:120:17 | LL | let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![String::from("Hey hey")].iter().any(|s| s.len() == 2)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:123:17 + --> tests/ui/search_is_some_fixable_none.rs:123:17 | LL | let _ = v.iter().find(|x| deref_enough(**x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| deref_enough(*x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:124:17 + --> tests/ui/search_is_some_fixable_none.rs:124:17 | LL | let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x: &u32| deref_enough(*x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:127:17 + --> tests/ui/search_is_some_fixable_none.rs:127:17 | LL | let _ = v.iter().find(|x| arg_no_deref(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x| arg_no_deref(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:129:17 + --> tests/ui/search_is_some_fixable_none.rs:129:17 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|x: &u32| arg_no_deref(&x))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:149:17 + --> tests/ui/search_is_some_fixable_none.rs:149:17 | LL | let _ = vfoo | _________________^ @@ -223,61 +223,61 @@ LL ~ .iter().any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] | error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:165:17 + --> tests/ui/search_is_some_fixable_none.rs:165:17 | LL | let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|v| v.inner[0].bar == 2)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:170:17 + --> tests/ui/search_is_some_fixable_none.rs:170:17 | LL | let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|x| (**x)[0] == 9)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:183:17 + --> tests/ui/search_is_some_fixable_none.rs:183:17 | LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!vfoo.iter().any(|v| v.by_ref(&v.bar))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:187:17 + --> tests/ui/search_is_some_fixable_none.rs:187:17 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:188:17 + --> tests/ui/search_is_some_fixable_none.rs:188:17 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `![&(&1, 2), &(&3, 4), &(&5, 4)].iter().any(|(&x, y)| x == *y)` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:207:17 + --> tests/ui/search_is_some_fixable_none.rs:207:17 | LL | let _ = v.iter().find(|s| s[0].is_empty()).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|s| s[0].is_empty())` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:208:17 + --> tests/ui/search_is_some_fixable_none.rs:208:17 | LL | let _ = v.iter().find(|s| test_string_1(&s[0])).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|s| test_string_1(&s[0]))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:217:17 + --> tests/ui/search_is_some_fixable_none.rs:217:17 | LL | let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| fp.field.is_power_of_two())` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:218:17 + --> tests/ui/search_is_some_fixable_none.rs:218:17 | LL | let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| test_u32_1(fp.field))` error: called `is_none()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_none.rs:219:17 + --> tests/ui/search_is_some_fixable_none.rs:219:17 | LL | let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_none(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `!v.iter().any(|fp| test_u32_2(*fp.field))` 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 e706ce646923d..af1de7f82f80c 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 @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:9:22 + --> tests/ui/search_is_some_fixable_some.rs:9:22 | LL | let _ = v.iter().find(|&x| *x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| *x < 0)` @@ -8,49 +8,49 @@ LL | let _ = v.iter().find(|&x| *x < 0).is_some(); = 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 + --> tests/ui/search_is_some_fixable_some.rs:10:20 | LL | let _ = (0..1).find(|x| **y == *x).is_some(); // one dereference less | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| **y == x)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:11:20 + --> tests/ui/search_is_some_fixable_some.rs:11:20 | LL | let _ = (0..1).find(|x| *x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| x == 0)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:12:22 + --> tests/ui/search_is_some_fixable_some.rs:12:22 | LL | let _ = v.iter().find(|x| **x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| *x == 0)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:13:20 + --> tests/ui/search_is_some_fixable_some.rs:13:20 | LL | let _ = (4..5).find(|x| *x == 1 || *x == 3 || *x == 5).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| x == 1 || x == 3 || x == 5)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:14:20 + --> tests/ui/search_is_some_fixable_some.rs:14:20 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| [1, 2, 3].contains(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:15:20 + --> tests/ui/search_is_some_fixable_some.rs:15:20 | LL | let _ = (1..3).find(|x| *x == 0 || [1, 2, 3].contains(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| x == 0 || [1, 2, 3].contains(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:16:20 + --> tests/ui/search_is_some_fixable_some.rs:16:20 | LL | let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| [1, 2, 3].contains(&x) || x == 0)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:18:10 + --> tests/ui/search_is_some_fixable_some.rs:18:10 | LL | .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1) | __________^ @@ -58,91 +58,91 @@ LL | | .is_some(); | |__________________^ help: consider using: `any(|x| [1, 2, 3].contains(&x) || x == 0 || [4, 5, 6].contains(&x) || x == -1)` error: called `is_some()` after searching an `Iterator` with `position` - --> $DIR/search_is_some_fixable_some.rs:22:22 + --> tests/ui/search_is_some_fixable_some.rs:22:22 | LL | let _ = v.iter().position(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|&x| x < 0)` error: called `is_some()` after searching an `Iterator` with `rposition` - --> $DIR/search_is_some_fixable_some.rs:25:22 + --> tests/ui/search_is_some_fixable_some.rs:25:22 | LL | let _ = v.iter().rposition(|&x| x < 0).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|&x| x < 0)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:30:27 + --> tests/ui/search_is_some_fixable_some.rs:30:27 | LL | let _ = "hello world".find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains("world")` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:31:27 + --> tests/ui/search_is_some_fixable_some.rs:31:27 | LL | let _ = "hello world".find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:32:27 + --> tests/ui/search_is_some_fixable_some.rs:32:27 | LL | let _ = "hello world".find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2[2..])` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:34:16 + --> tests/ui/search_is_some_fixable_some.rs:34:16 | LL | let _ = s1.find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains("world")` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:35:16 + --> tests/ui/search_is_some_fixable_some.rs:35:16 | LL | let _ = s1.find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:36:16 + --> tests/ui/search_is_some_fixable_some.rs:36:16 | LL | let _ = s1.find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2[2..])` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:38:21 + --> tests/ui/search_is_some_fixable_some.rs:38:21 | LL | let _ = s1[2..].find("world").is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains("world")` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:39:21 + --> tests/ui/search_is_some_fixable_some.rs:39:21 | LL | let _ = s1[2..].find(&s2).is_some(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2)` error: called `is_some()` after calling `find()` on a string - --> $DIR/search_is_some_fixable_some.rs:40:21 + --> tests/ui/search_is_some_fixable_some.rs:40:21 | LL | let _ = s1[2..].find(&s2[2..]).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `contains(&s2[2..])` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:56:44 + --> tests/ui/search_is_some_fixable_some.rs:56:44 | LL | .filter(|c| filter_hand.iter().find(|cc| c == cc).is_some()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|cc| c == &cc)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:72:49 + --> tests/ui/search_is_some_fixable_some.rs:72:49 | LL | .filter(|(c, _)| filter_hand.iter().find(|cc| c == *cc).is_some()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|cc| c == cc)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:83:29 + --> tests/ui/search_is_some_fixable_some.rs:83:29 | LL | let _ = vfoo.iter().find(|v| v.foo == 1 && v.bar == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| v.foo == 1 && v.bar == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:88:14 + --> tests/ui/search_is_some_fixable_some.rs:88:14 | LL | .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2) | ______________^ @@ -150,55 +150,55 @@ LL | | .is_some(); | |______________________^ help: consider using: `any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:94:29 + --> tests/ui/search_is_some_fixable_some.rs:94:29 | LL | let _ = vfoo.iter().find(|a| a[0] == 42).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|a| a[0] == 42)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:100:29 + --> tests/ui/search_is_some_fixable_some.rs:100:29 | LL | let _ = vfoo.iter().find(|sub| sub[1..4].len() == 3).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|sub| sub[1..4].len() == 3)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:118:30 + --> tests/ui/search_is_some_fixable_some.rs:118:30 | LL | let _ = [ppx].iter().find(|ppp_x: &&&u32| please(**ppp_x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|ppp_x: &&u32| please(ppp_x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:119:50 + --> tests/ui/search_is_some_fixable_some.rs:119:50 | LL | let _ = [String::from("Hey hey")].iter().find(|s| s.len() == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|s| s.len() == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:122:26 + --> tests/ui/search_is_some_fixable_some.rs:122:26 | LL | let _ = v.iter().find(|x| deref_enough(**x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| deref_enough(*x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:123:26 + --> tests/ui/search_is_some_fixable_some.rs:123:26 | LL | let _ = v.iter().find(|x: &&u32| deref_enough(**x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| deref_enough(*x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:126:26 + --> tests/ui/search_is_some_fixable_some.rs:126:26 | LL | let _ = v.iter().find(|x| arg_no_deref(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| arg_no_deref(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:128:26 + --> tests/ui/search_is_some_fixable_some.rs:128:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| arg_no_deref(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:150:14 + --> tests/ui/search_is_some_fixable_some.rs:150:14 | LL | .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2) | ______________^ @@ -206,85 +206,85 @@ LL | | .is_some(); | |______________________^ help: consider using: `any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:164:29 + --> tests/ui/search_is_some_fixable_some.rs:164:29 | LL | let _ = vfoo.iter().find(|v| v.inner[0].bar == 2).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| v.inner[0].bar == 2)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:169:29 + --> tests/ui/search_is_some_fixable_some.rs:169:29 | LL | let _ = vfoo.iter().find(|x| (**x)[0] == 9).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x| (**x)[0] == 9)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:182:29 + --> tests/ui/search_is_some_fixable_some.rs:182:29 | LL | let _ = vfoo.iter().find(|v| v.by_ref(&v.bar)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|v| v.by_ref(&v.bar))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:186:55 + --> tests/ui/search_is_some_fixable_some.rs:186:55 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|(&x, y)| x == *y).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|(&x, y)| x == *y)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:187:55 + --> tests/ui/search_is_some_fixable_some.rs:187:55 | LL | let _ = [&(&1, 2), &(&3, 4), &(&5, 4)].iter().find(|&(&x, y)| x == *y).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|(&x, y)| x == *y)` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:206:26 + --> tests/ui/search_is_some_fixable_some.rs:206:26 | LL | let _ = v.iter().find(|s| s[0].is_empty()).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|s| s[0].is_empty())` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:207:26 + --> tests/ui/search_is_some_fixable_some.rs:207:26 | LL | let _ = v.iter().find(|s| test_string_1(&s[0])).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|s| test_string_1(&s[0]))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:216:26 + --> tests/ui/search_is_some_fixable_some.rs:216:26 | LL | let _ = v.iter().find(|fp| fp.field.is_power_of_two()).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|fp| fp.field.is_power_of_two())` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:217:26 + --> tests/ui/search_is_some_fixable_some.rs:217:26 | LL | let _ = v.iter().find(|fp| test_u32_1(fp.field)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|fp| test_u32_1(fp.field))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:218:26 + --> tests/ui/search_is_some_fixable_some.rs:218:26 | LL | let _ = v.iter().find(|fp| test_u32_2(*fp.field)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|fp| test_u32_2(*fp.field))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:233:18 + --> tests/ui/search_is_some_fixable_some.rs:233:18 | LL | v.iter().find(|x: &&u32| func(x)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| func(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:242:26 + --> tests/ui/search_is_some_fixable_some.rs:242:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref_impl(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| arg_no_deref_impl(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:245:26 + --> tests/ui/search_is_some_fixable_some.rs:245:26 | LL | let _ = v.iter().find(|x: &&u32| arg_no_deref_dyn(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| arg_no_deref_dyn(&x))` error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/search_is_some_fixable_some.rs:248:26 + --> tests/ui/search_is_some_fixable_some.rs:248:26 | LL | let _ = v.iter().find(|x: &&u32| (*arg_no_deref_dyn)(x)).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|x: &u32| (*arg_no_deref_dyn)(&x))` diff --git a/src/tools/clippy/tests/ui/seek_from_current.stderr b/src/tools/clippy/tests/ui/seek_from_current.stderr index 4858cb82e7eb0..23ba9968bfffa 100644 --- a/src/tools/clippy/tests/ui/seek_from_current.stderr +++ b/src/tools/clippy/tests/ui/seek_from_current.stderr @@ -1,5 +1,5 @@ error: using `SeekFrom::Current` to start from current position - --> $DIR/seek_from_current.rs:19:5 + --> tests/ui/seek_from_current.rs:19:5 | LL | f.seek(SeekFrom::Current(0))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `f.stream_position()` 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 b6b0d2effa815..2c3c45820e107 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 @@ -1,5 +1,5 @@ error: used `seek` to go to the start of the stream - --> $DIR/seek_to_start_instead_of_rewind.rs:52:7 + --> tests/ui/seek_to_start_instead_of_rewind.rs:52:7 | LL | t.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` @@ -8,13 +8,13 @@ LL | t.seek(SeekFrom::Start(0)); = 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 + --> tests/ui/seek_to_start_instead_of_rewind.rs:57:7 | LL | t.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` error: used `seek` to go to the start of the stream - --> $DIR/seek_to_start_instead_of_rewind.rs:136:7 + --> tests/ui/seek_to_start_instead_of_rewind.rs:136:7 | LL | f.seek(SeekFrom::Start(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()` diff --git a/src/tools/clippy/tests/ui/self_assignment.stderr b/src/tools/clippy/tests/ui/self_assignment.stderr index 4612f8f824481..e92414163d4c4 100644 --- a/src/tools/clippy/tests/ui/self_assignment.stderr +++ b/src/tools/clippy/tests/ui/self_assignment.stderr @@ -1,5 +1,5 @@ error: self-assignment of `a` to `a` - --> $DIR/self_assignment.rs:13:5 + --> tests/ui/self_assignment.rs:13:5 | LL | a = a; | ^^^^^ @@ -8,61 +8,61 @@ LL | a = a; = help: to override `-D warnings` add `#[allow(clippy::self_assignment)]` error: self-assignment of `*b` to `*b` - --> $DIR/self_assignment.rs:16:5 + --> tests/ui/self_assignment.rs:16:5 | LL | *b = *b; | ^^^^^^^ error: self-assignment of `s` to `s` - --> $DIR/self_assignment.rs:18:5 + --> tests/ui/self_assignment.rs:18:5 | LL | s = s; | ^^^^^ error: self-assignment of `s.a` to `s.a` - --> $DIR/self_assignment.rs:20:5 + --> tests/ui/self_assignment.rs:20:5 | LL | s.a = s.a; | ^^^^^^^^^ error: self-assignment of `s.b[5 + 4]` to `s.b[9]` - --> $DIR/self_assignment.rs:22:5 + --> tests/ui/self_assignment.rs:22:5 | LL | s.b[9] = s.b[5 + 4]; | ^^^^^^^^^^^^^^^^^^^ error: self-assignment of `s.c[0][1]` to `s.c[0][1]` - --> $DIR/self_assignment.rs:24:5 + --> tests/ui/self_assignment.rs:24:5 | LL | s.c[0][1] = s.c[0][1]; | ^^^^^^^^^^^^^^^^^^^^^ error: self-assignment of `s.b[a]` to `s.b[a]` - --> $DIR/self_assignment.rs:26:5 + --> tests/ui/self_assignment.rs:26:5 | LL | s.b[a] = s.b[a]; | ^^^^^^^^^^^^^^^ error: self-assignment of `*s.e` to `*s.e` - --> $DIR/self_assignment.rs:28:5 + --> tests/ui/self_assignment.rs:28:5 | LL | *s.e = *s.e; | ^^^^^^^^^^^ error: self-assignment of `s.b[10 + a]` to `s.b[a + 10]` - --> $DIR/self_assignment.rs:30:5 + --> tests/ui/self_assignment.rs:30:5 | LL | s.b[a + 10] = s.b[10 + a]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: self-assignment of `t.1` to `t.1` - --> $DIR/self_assignment.rs:34:5 + --> tests/ui/self_assignment.rs:34:5 | LL | t.1 = t.1; | ^^^^^^^^^ error: self-assignment of `(t.0)` to `t.0` - --> $DIR/self_assignment.rs:36:5 + --> tests/ui/self_assignment.rs:36:5 | LL | t.0 = (t.0); | ^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/self_named_constructors.stderr b/src/tools/clippy/tests/ui/self_named_constructors.stderr index 8083ff9651579..1d8b44f6bc2bd 100644 --- a/src/tools/clippy/tests/ui/self_named_constructors.stderr +++ b/src/tools/clippy/tests/ui/self_named_constructors.stderr @@ -1,5 +1,5 @@ error: constructor `should_spawn` has the same name as the type - --> $DIR/self_named_constructors.rs:7:5 + --> tests/ui/self_named_constructors.rs:7:5 | LL | / pub fn should_spawn() -> ShouldSpawn { LL | | diff --git a/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.fixed b/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.fixed index cdfa5d9cc7804..6c8c835d0e0e3 100644 --- a/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.fixed +++ b/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.fixed @@ -1,7 +1,12 @@ //@aux-build:proc_macro_attr.rs #![warn(clippy::semicolon_if_nothing_returned)] -#![allow(clippy::redundant_closure, clippy::uninlined_format_args, clippy::needless_late_init)] +#![allow( + clippy::redundant_closure, + clippy::uninlined_format_args, + clippy::needless_late_init, + clippy::empty_docs +)] #[macro_use] extern crate proc_macro_attr; diff --git a/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.rs b/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.rs index 315b7e4f38399..2c2e4c0241904 100644 --- a/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.rs +++ b/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.rs @@ -1,7 +1,12 @@ //@aux-build:proc_macro_attr.rs #![warn(clippy::semicolon_if_nothing_returned)] -#![allow(clippy::redundant_closure, clippy::uninlined_format_args, clippy::needless_late_init)] +#![allow( + clippy::redundant_closure, + clippy::uninlined_format_args, + clippy::needless_late_init, + clippy::empty_docs +)] #[macro_use] extern crate proc_macro_attr; 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 09c4d12f216c5..69e434b142cf4 100644 --- a/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.stderr +++ b/src/tools/clippy/tests/ui/semicolon_if_nothing_returned.stderr @@ -1,5 +1,5 @@ error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:13:5 + --> tests/ui/semicolon_if_nothing_returned.rs:18:5 | LL | println!("Hello") | ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");` @@ -8,25 +8,25 @@ LL | println!("Hello") = 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:17:5 + --> tests/ui/semicolon_if_nothing_returned.rs:22:5 | LL | get_unit() | ^^^^^^^^^^ help: add a `;` here: `get_unit();` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:22:5 + --> tests/ui/semicolon_if_nothing_returned.rs:27:5 | LL | y = x + 1 | ^^^^^^^^^ help: add a `;` here: `y = x + 1;` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:28:9 + --> tests/ui/semicolon_if_nothing_returned.rs:33:9 | LL | hello() | ^^^^^^^ help: add a `;` here: `hello();` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:39:9 + --> tests/ui/semicolon_if_nothing_returned.rs:44:9 | LL | ptr::drop_in_place(s.as_mut_ptr()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());` diff --git a/src/tools/clippy/tests/ui/semicolon_inside_block.stderr b/src/tools/clippy/tests/ui/semicolon_inside_block.stderr index 1bfc1f24c436a..d32fb681d3b99 100644 --- a/src/tools/clippy/tests/ui/semicolon_inside_block.stderr +++ b/src/tools/clippy/tests/ui/semicolon_inside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:38:5 + --> tests/ui/semicolon_inside_block.rs:38:5 | LL | { unit_fn_block() }; | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block(); } | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:39:5 + --> tests/ui/semicolon_inside_block.rs:39:5 | LL | unsafe { unit_fn_block() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block(); } | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:47:5 + --> tests/ui/semicolon_inside_block.rs:47:5 | LL | / { LL | | unit_fn_block(); @@ -40,7 +40,7 @@ LL ~ } | error: consider moving the `;` inside the block for consistent formatting - --> $DIR/semicolon_inside_block.rs:60:5 + --> tests/ui/semicolon_inside_block.rs:60:5 | LL | { m!(()) }; | ^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/semicolon_outside_block.stderr b/src/tools/clippy/tests/ui/semicolon_outside_block.stderr index 427271fca64da..68b44c8f980f2 100644 --- a/src/tools/clippy/tests/ui/semicolon_outside_block.stderr +++ b/src/tools/clippy/tests/ui/semicolon_outside_block.stderr @@ -1,5 +1,5 @@ error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:41:5 + --> tests/ui/semicolon_outside_block.rs:41:5 | LL | { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:42:5 + --> tests/ui/semicolon_outside_block.rs:42:5 | LL | unsafe { unit_fn_block(); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + unsafe { unit_fn_block() }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:51:5 + --> tests/ui/semicolon_outside_block.rs:51:5 | LL | / { LL | | unit_fn_block(); @@ -40,7 +40,7 @@ LL ~ }; | error: consider moving the `;` outside the block for consistent formatting - --> $DIR/semicolon_outside_block.rs:61:5 + --> tests/ui/semicolon_outside_block.rs:61:5 | LL | { m!(()); } | ^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/serde.stderr b/src/tools/clippy/tests/ui/serde.stderr index 079ba42bd2bc5..f71d41d58aae1 100644 --- a/src/tools/clippy/tests/ui/serde.stderr +++ b/src/tools/clippy/tests/ui/serde.stderr @@ -1,5 +1,5 @@ error: you should not implement `visit_string` without also implementing `visit_str` - --> $DIR/serde.rs:39:5 + --> tests/ui/serde.rs:39:5 | LL | / fn visit_string(self, _v: String) -> Result LL | | diff --git a/src/tools/clippy/tests/ui/shadow.stderr b/src/tools/clippy/tests/ui/shadow.stderr index 26ace287b1f4a..fdd149a2216f2 100644 --- a/src/tools/clippy/tests/ui/shadow.stderr +++ b/src/tools/clippy/tests/ui/shadow.stderr @@ -1,11 +1,11 @@ error: `x` is shadowed by itself in `x` - --> $DIR/shadow.rs:24:9 + --> tests/ui/shadow.rs:24:9 | LL | let x = x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:23:9 + --> tests/ui/shadow.rs:23:9 | LL | let x = 1; | ^ @@ -13,49 +13,49 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::shadow_same)]` error: `mut x` is shadowed by itself in `&x` - --> $DIR/shadow.rs:25:13 + --> tests/ui/shadow.rs:25:13 | LL | let mut x = &x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:24:9 + --> tests/ui/shadow.rs:24:9 | LL | let x = x; | ^ error: `x` is shadowed by itself in `&mut x` - --> $DIR/shadow.rs:26:9 + --> tests/ui/shadow.rs:26:9 | LL | let x = &mut x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:25:9 + --> tests/ui/shadow.rs:25:9 | LL | let mut x = &x; | ^^^^^ error: `x` is shadowed by itself in `*x` - --> $DIR/shadow.rs:27:9 + --> tests/ui/shadow.rs:27:9 | LL | let x = *x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:26:9 + --> tests/ui/shadow.rs:26:9 | LL | let x = &mut x; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:32:9 + --> tests/ui/shadow.rs:32:9 | LL | let x = x.0; | ^ | note: previous binding is here - --> $DIR/shadow.rs:31:9 + --> tests/ui/shadow.rs:31:9 | LL | let x = ([[0]], ()); | ^ @@ -63,97 +63,97 @@ LL | let x = ([[0]], ()); = help: to override `-D warnings` add `#[allow(clippy::shadow_reuse)]` error: `x` is shadowed - --> $DIR/shadow.rs:33:9 + --> tests/ui/shadow.rs:33:9 | LL | let x = x[0]; | ^ | note: previous binding is here - --> $DIR/shadow.rs:32:9 + --> tests/ui/shadow.rs:32:9 | LL | let x = x.0; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:34:10 + --> tests/ui/shadow.rs:34:10 | LL | let [x] = x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:33:9 + --> tests/ui/shadow.rs:33:9 | LL | let x = x[0]; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:35:9 + --> tests/ui/shadow.rs:35:9 | LL | let x = Some(x); | ^ | note: previous binding is here - --> $DIR/shadow.rs:34:10 + --> tests/ui/shadow.rs:34:10 | LL | let [x] = x; | ^ error: `x` is shadowed - --> $DIR/shadow.rs:36:9 + --> tests/ui/shadow.rs:36:9 | LL | let x = foo(x); | ^ | note: previous binding is here - --> $DIR/shadow.rs:35:9 + --> tests/ui/shadow.rs:35:9 | LL | let x = Some(x); | ^ error: `x` is shadowed - --> $DIR/shadow.rs:37:9 + --> tests/ui/shadow.rs:37:9 | LL | let x = || x; | ^ | note: previous binding is here - --> $DIR/shadow.rs:36:9 + --> tests/ui/shadow.rs:36:9 | LL | let x = foo(x); | ^ error: `x` is shadowed - --> $DIR/shadow.rs:38:9 + --> tests/ui/shadow.rs:38:9 | LL | let x = Some(1).map(|_| x)?; | ^ | note: previous binding is here - --> $DIR/shadow.rs:37:9 + --> tests/ui/shadow.rs:37:9 | LL | let x = || x; | ^ error: `y` is shadowed - --> $DIR/shadow.rs:40:9 + --> tests/ui/shadow.rs:40:9 | LL | let y = match y { | ^ | note: previous binding is here - --> $DIR/shadow.rs:39:9 + --> tests/ui/shadow.rs:39:9 | LL | let y = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:55:9 + --> tests/ui/shadow.rs:55:9 | LL | let x = 2; | ^ | note: previous binding is here - --> $DIR/shadow.rs:54:9 + --> tests/ui/shadow.rs:54:9 | LL | let x = 1; | ^ @@ -161,121 +161,121 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::shadow_unrelated)]` error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:60:13 + --> tests/ui/shadow.rs:60:13 | LL | let x = 1; | ^ | note: previous binding is here - --> $DIR/shadow.rs:59:10 + --> tests/ui/shadow.rs:59:10 | LL | fn f(x: u32) { | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:65:14 + --> tests/ui/shadow.rs:65:14 | LL | Some(x) => { | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:66:17 + --> tests/ui/shadow.rs:66:17 | LL | let x = 1; | ^ | note: previous binding is here - --> $DIR/shadow.rs:65:14 + --> tests/ui/shadow.rs:65:14 | LL | Some(x) => { | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:70:17 + --> tests/ui/shadow.rs:70:17 | LL | if let Some(x) = Some(1) {} | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:71:20 + --> tests/ui/shadow.rs:71:20 | LL | while let Some(x) = Some(1) {} | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:72:15 + --> tests/ui/shadow.rs:72:15 | LL | let _ = |[x]: [u32; 1]| { | ^ | note: previous binding is here - --> $DIR/shadow.rs:62:9 + --> tests/ui/shadow.rs:62:9 | LL | let x = 1; | ^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:73:13 + --> tests/ui/shadow.rs:73:13 | LL | let x = 1; | ^ | note: previous binding is here - --> $DIR/shadow.rs:72:15 + --> tests/ui/shadow.rs:72:15 | LL | let _ = |[x]: [u32; 1]| { | ^ error: `y` is shadowed - --> $DIR/shadow.rs:76:17 + --> tests/ui/shadow.rs:76:17 | LL | if let Some(y) = y {} | ^ | note: previous binding is here - --> $DIR/shadow.rs:75:9 + --> tests/ui/shadow.rs:75:9 | LL | let y = Some(1); | ^ error: `_b` shadows a previous, unrelated binding - --> $DIR/shadow.rs:112:9 + --> tests/ui/shadow.rs:112:9 | LL | let _b = _a; | ^^ | note: previous binding is here - --> $DIR/shadow.rs:111:28 + --> tests/ui/shadow.rs:111:28 | LL | pub async fn foo2(_a: i32, _b: i64) { | ^^ error: `x` shadows a previous, unrelated binding - --> $DIR/shadow.rs:118:21 + --> tests/ui/shadow.rs:118:21 | LL | if let Some(x) = Some(1) { x } else { 1 } | ^ | note: previous binding is here - --> $DIR/shadow.rs:117:13 + --> tests/ui/shadow.rs:117:13 | LL | let x = 1; | ^ diff --git a/src/tools/clippy/tests/ui/short_circuit_statement.stderr b/src/tools/clippy/tests/ui/short_circuit_statement.stderr index dbdf44dfcbd98..e7a8f2ca60ca1 100644 --- a/src/tools/clippy/tests/ui/short_circuit_statement.stderr +++ b/src/tools/clippy/tests/ui/short_circuit_statement.stderr @@ -1,5 +1,5 @@ error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:5:5 + --> tests/ui/short_circuit_statement.rs:5:5 | LL | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` @@ -8,13 +8,13 @@ LL | f() && g(); = 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 + --> tests/ui/short_circuit_statement.rs:6:5 | LL | f() || g(); | ^^^^^^^^^^^ help: replace it with: `if !f() { g(); }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:7:5 + --> tests/ui/short_circuit_statement.rs:7:5 | LL | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if 1 != 2 { g(); }` 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 c9894eec53a20..dfa55ace40f0a 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 @@ -1,5 +1,5 @@ error: method `add` can be confused for the standard trait method `std::ops::Add::add` - --> $DIR/method_list_1.rs:25:5 + --> tests/ui/should_impl_trait/method_list_1.rs:25:5 | LL | / pub fn add(self, other: T) -> T { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/should_impl_trait/method_list_1.rs:30:5 | LL | / pub fn as_mut(&mut self) -> &mut T { LL | | @@ -23,7 +23,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsMut` or choosing a less ambiguous method name error: method `as_ref` can be confused for the standard trait method `std::convert::AsRef::as_ref` - --> $DIR/method_list_1.rs:35:5 + --> tests/ui/should_impl_trait/method_list_1.rs:35:5 | LL | / pub fn as_ref(&self) -> &T { LL | | @@ -34,7 +34,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsRef` or choosing a less ambiguous method name error: method `bitand` can be confused for the standard trait method `std::ops::BitAnd::bitand` - --> $DIR/method_list_1.rs:40:5 + --> tests/ui/should_impl_trait/method_list_1.rs:40:5 | LL | / pub fn bitand(self, rhs: T) -> T { LL | | @@ -45,7 +45,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitAnd` or choosing a less ambiguous method name error: method `bitor` can be confused for the standard trait method `std::ops::BitOr::bitor` - --> $DIR/method_list_1.rs:45:5 + --> tests/ui/should_impl_trait/method_list_1.rs:45:5 | LL | / pub fn bitor(self, rhs: Self) -> Self { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitOr` or choosing a less ambiguous method name error: method `bitxor` can be confused for the standard trait method `std::ops::BitXor::bitxor` - --> $DIR/method_list_1.rs:50:5 + --> tests/ui/should_impl_trait/method_list_1.rs:50:5 | LL | / pub fn bitxor(self, rhs: Self) -> Self { LL | | @@ -67,7 +67,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitXor` or choosing a less ambiguous method name error: method `borrow` can be confused for the standard trait method `std::borrow::Borrow::borrow` - --> $DIR/method_list_1.rs:55:5 + --> tests/ui/should_impl_trait/method_list_1.rs:55:5 | LL | / pub fn borrow(&self) -> &str { LL | | @@ -78,7 +78,7 @@ LL | | } = help: consider implementing the trait `std::borrow::Borrow` or choosing a less ambiguous method name error: method `borrow_mut` can be confused for the standard trait method `std::borrow::BorrowMut::borrow_mut` - --> $DIR/method_list_1.rs:60:5 + --> tests/ui/should_impl_trait/method_list_1.rs:60:5 | LL | / pub fn borrow_mut(&mut self) -> &mut str { LL | | @@ -89,7 +89,7 @@ LL | | } = help: consider implementing the trait `std::borrow::BorrowMut` or choosing a less ambiguous method name error: method `clone` can be confused for the standard trait method `std::clone::Clone::clone` - --> $DIR/method_list_1.rs:65:5 + --> tests/ui/should_impl_trait/method_list_1.rs:65:5 | LL | / pub fn clone(&self) -> Self { LL | | @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::clone::Clone` or choosing a less ambiguous method name error: method `cmp` can be confused for the standard trait method `std::cmp::Ord::cmp` - --> $DIR/method_list_1.rs:70:5 + --> tests/ui/should_impl_trait/method_list_1.rs:70:5 | LL | / pub fn cmp(&self, other: &Self) -> Self { LL | | @@ -111,7 +111,7 @@ LL | | } = help: consider implementing the trait `std::cmp::Ord` or choosing a less ambiguous method name error: method `default` can be confused for the standard trait method `std::default::Default::default` - --> $DIR/method_list_1.rs:75:5 + --> tests/ui/should_impl_trait/method_list_1.rs:75:5 | LL | / pub fn default() -> Self { LL | | @@ -122,7 +122,7 @@ LL | | } = help: consider implementing the trait `std::default::Default` or choosing a less ambiguous method name error: method `deref` can be confused for the standard trait method `std::ops::Deref::deref` - --> $DIR/method_list_1.rs:80:5 + --> tests/ui/should_impl_trait/method_list_1.rs:80:5 | LL | / pub fn deref(&self) -> &Self { LL | | @@ -133,7 +133,7 @@ LL | | } = help: consider implementing the trait `std::ops::Deref` or choosing a less ambiguous method name error: method `deref_mut` can be confused for the standard trait method `std::ops::DerefMut::deref_mut` - --> $DIR/method_list_1.rs:85:5 + --> tests/ui/should_impl_trait/method_list_1.rs:85:5 | LL | / pub fn deref_mut(&mut self) -> &mut Self { LL | | @@ -144,7 +144,7 @@ LL | | } = help: consider implementing the trait `std::ops::DerefMut` or choosing a less ambiguous method name error: method `div` can be confused for the standard trait method `std::ops::Div::div` - --> $DIR/method_list_1.rs:90:5 + --> tests/ui/should_impl_trait/method_list_1.rs:90:5 | LL | / pub fn div(self, rhs: Self) -> Self { LL | | @@ -155,7 +155,7 @@ LL | | } = help: consider implementing the trait `std::ops::Div` or choosing a less ambiguous method name error: method `drop` can be confused for the standard trait method `std::ops::Drop::drop` - --> $DIR/method_list_1.rs:95:5 + --> tests/ui/should_impl_trait/method_list_1.rs:95:5 | LL | / pub fn drop(&mut self) { LL | | 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 c257f41134266..b1e5bbbfa4c5f 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 @@ -1,5 +1,5 @@ error: method `eq` can be confused for the standard trait method `std::cmp::PartialEq::eq` - --> $DIR/method_list_2.rs:26:5 + --> tests/ui/should_impl_trait/method_list_2.rs:26:5 | LL | / pub fn eq(&self, other: &Self) -> bool { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/should_impl_trait/method_list_2.rs:31:5 | LL | / pub fn from_iter(iter: T) -> Self { LL | | @@ -23,7 +23,7 @@ LL | | } = help: consider implementing the trait `std::iter::FromIterator` or choosing a less ambiguous method name error: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str` - --> $DIR/method_list_2.rs:36:5 + --> tests/ui/should_impl_trait/method_list_2.rs:36:5 | LL | / pub fn from_str(s: &str) -> Result { LL | | @@ -34,7 +34,7 @@ LL | | } = help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name error: method `hash` can be confused for the standard trait method `std::hash::Hash::hash` - --> $DIR/method_list_2.rs:41:5 + --> tests/ui/should_impl_trait/method_list_2.rs:41:5 | LL | / pub fn hash(&self, state: &mut T) { LL | | @@ -45,7 +45,7 @@ LL | | } = help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name error: method `index` can be confused for the standard trait method `std::ops::Index::index` - --> $DIR/method_list_2.rs:46:5 + --> tests/ui/should_impl_trait/method_list_2.rs:46:5 | LL | / pub fn index(&self, index: usize) -> &Self { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` - --> $DIR/method_list_2.rs:51:5 + --> tests/ui/should_impl_trait/method_list_2.rs:51:5 | LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self { LL | | @@ -67,7 +67,7 @@ LL | | } = help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` - --> $DIR/method_list_2.rs:56:5 + --> tests/ui/should_impl_trait/method_list_2.rs:56:5 | LL | / pub fn into_iter(self) -> Self { LL | | @@ -78,7 +78,7 @@ LL | | } = help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` - --> $DIR/method_list_2.rs:61:5 + --> tests/ui/should_impl_trait/method_list_2.rs:61:5 | LL | / pub fn mul(self, rhs: Self) -> Self { LL | | @@ -89,7 +89,7 @@ LL | | } = help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` - --> $DIR/method_list_2.rs:66:5 + --> tests/ui/should_impl_trait/method_list_2.rs:66:5 | LL | / pub fn neg(self) -> Self { LL | | @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name error: method `next` can be confused for the standard trait method `std::iter::Iterator::next` - --> $DIR/method_list_2.rs:71:5 + --> tests/ui/should_impl_trait/method_list_2.rs:71:5 | LL | / pub fn next(&mut self) -> Option { LL | | @@ -111,7 +111,7 @@ LL | | } = help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name error: method `not` can be confused for the standard trait method `std::ops::Not::not` - --> $DIR/method_list_2.rs:76:5 + --> tests/ui/should_impl_trait/method_list_2.rs:76:5 | LL | / pub fn not(self) -> Self { LL | | @@ -122,7 +122,7 @@ LL | | } = help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` - --> $DIR/method_list_2.rs:81:5 + --> tests/ui/should_impl_trait/method_list_2.rs:81:5 | LL | / pub fn rem(self, rhs: Self) -> Self { LL | | @@ -133,7 +133,7 @@ LL | | } = help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` - --> $DIR/method_list_2.rs:86:5 + --> tests/ui/should_impl_trait/method_list_2.rs:86:5 | LL | / pub fn shl(self, rhs: Self) -> Self { LL | | @@ -144,7 +144,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` - --> $DIR/method_list_2.rs:91:5 + --> tests/ui/should_impl_trait/method_list_2.rs:91:5 | LL | / pub fn shr(self, rhs: Self) -> Self { LL | | @@ -155,7 +155,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` - --> $DIR/method_list_2.rs:96:5 + --> tests/ui/should_impl_trait/method_list_2.rs:96:5 | LL | / pub fn sub(self, rhs: Self) -> Self { LL | | diff --git a/src/tools/clippy/tests/ui/should_panic_without_expect.stderr b/src/tools/clippy/tests/ui/should_panic_without_expect.stderr index b13db83bd5c71..0b841b23848e7 100644 --- a/src/tools/clippy/tests/ui/should_panic_without_expect.stderr +++ b/src/tools/clippy/tests/ui/should_panic_without_expect.stderr @@ -1,11 +1,11 @@ error: #[should_panic] attribute without a reason - --> $DIR/should_panic_without_expect.rs:5:1 + --> tests/ui/should_panic_without_expect.rs:5:1 | LL | #[should_panic] | ^^^^^^^^^^^^^^^ help: consider specifying the expected panic: `#[should_panic(expected = /* panic message */)]` | note: the lint level is defined here - --> $DIR/should_panic_without_expect.rs:2:9 + --> tests/ui/should_panic_without_expect.rs:2:9 | LL | #![deny(clippy::should_panic_without_expect)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 05bfda5475d8b..7d5b1acc7f00a 100644 --- a/src/tools/clippy/tests/ui/significant_drop_in_scrutinee.stderr +++ b/src/tools/clippy/tests/ui/significant_drop_in_scrutinee.stderr @@ -1,5 +1,5 @@ error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:55:11 + --> tests/ui/significant_drop_in_scrutinee.rs:55:11 | LL | match mutex.lock().unwrap().foo() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:143:11 + --> tests/ui/significant_drop_in_scrutinee.rs:143:11 | LL | match s.lock_m().get_the_value() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:166:11 + --> tests/ui/significant_drop_in_scrutinee.rs:166:11 | LL | match s.lock_m_m().get_the_value() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +58,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:216:11 + --> tests/ui/significant_drop_in_scrutinee.rs:216:11 | LL | match counter.temp_increment().len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:241:16 + --> tests/ui/significant_drop_in_scrutinee.rs:241:16 | LL | match (mutex1.lock().unwrap().s.len(), true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ LL ~ match (value, true) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:252:22 + --> tests/ui/significant_drop_in_scrutinee.rs:252:22 | LL | match (true, mutex1.lock().unwrap().s.len(), true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL ~ match (true, value, true) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:264:16 + --> tests/ui/significant_drop_in_scrutinee.rs:264:16 | LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL ~ match (value, true, mutex2.lock().unwrap().s.len()) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:264:54 + --> tests/ui/significant_drop_in_scrutinee.rs:264:54 | LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL ~ match (mutex1.lock().unwrap().s.len(), true, value) { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:279:15 + --> tests/ui/significant_drop_in_scrutinee.rs:279:15 | LL | match mutex3.lock().unwrap().s.as_str() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -170,7 +170,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:291:22 + --> tests/ui/significant_drop_in_scrutinee.rs:291:22 | LL | match (true, mutex3.lock().unwrap().s.as_str()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -186,7 +186,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:312:11 + --> tests/ui/significant_drop_in_scrutinee.rs:312:11 | LL | match mutex.lock().unwrap().s.len() > 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:321:11 + --> tests/ui/significant_drop_in_scrutinee.rs:321:11 | LL | match 1 < mutex.lock().unwrap().s.len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -224,7 +224,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:341:11 + --> tests/ui/significant_drop_in_scrutinee.rs:341:11 | LL | match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -245,7 +245,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:354:11 + --> tests/ui/significant_drop_in_scrutinee.rs:354:11 | LL | match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -266,7 +266,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:391:11 + --> tests/ui/significant_drop_in_scrutinee.rs:391:11 | LL | match get_mutex_guard().s.len() > 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -285,7 +285,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:410:11 + --> tests/ui/significant_drop_in_scrutinee.rs:410:11 | LL | match match i { | ___________^ @@ -319,7 +319,7 @@ LL ~ match value | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:438:11 + --> tests/ui/significant_drop_in_scrutinee.rs:438:11 | LL | match if i > 1 { | ___________^ @@ -354,7 +354,7 @@ LL ~ match value | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:494:11 + --> tests/ui/significant_drop_in_scrutinee.rs:494:11 | LL | match s.lock().deref().deref() { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -372,7 +372,7 @@ LL ~ match value { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:524:11 + --> tests/ui/significant_drop_in_scrutinee.rs:524:11 | LL | match s.lock().deref().deref() { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -386,7 +386,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:545:11 + --> tests/ui/significant_drop_in_scrutinee.rs:545:11 | LL | match mutex.lock().unwrap().i = i { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -405,7 +405,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:553:11 + --> tests/ui/significant_drop_in_scrutinee.rs:553:11 | LL | match i = mutex.lock().unwrap().i { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -424,7 +424,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:561:11 + --> tests/ui/significant_drop_in_scrutinee.rs:561:11 | LL | match mutex.lock().unwrap().i += 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -443,7 +443,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:569:11 + --> tests/ui/significant_drop_in_scrutinee.rs:569:11 | LL | match i += mutex.lock().unwrap().i { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -462,7 +462,7 @@ LL ~ match () { | error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:634:11 + --> tests/ui/significant_drop_in_scrutinee.rs:634:11 | LL | match rwlock.read().unwrap().to_number() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -473,7 +473,7 @@ LL | }; = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `for` loop condition will live until the end of the `for` expression - --> $DIR/significant_drop_in_scrutinee.rs:646:14 + --> tests/ui/significant_drop_in_scrutinee.rs:646:14 | LL | for s in rwlock.read().unwrap().iter() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -484,7 +484,7 @@ LL | } = note: this might lead to deadlocks or other unexpected behavior error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression - --> $DIR/significant_drop_in_scrutinee.rs:663:11 + --> tests/ui/significant_drop_in_scrutinee.rs:663:11 | LL | match 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 6572d99693170..f818a14cbe68b 100644 --- a/src/tools/clippy/tests/ui/significant_drop_tightening.stderr +++ b/src/tools/clippy/tests/ui/significant_drop_tightening.stderr @@ -1,5 +1,5 @@ error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:10:9 + --> tests/ui/significant_drop_tightening.rs:10:9 | LL | pub fn complex_return_triggers_the_lint() -> i32 { | __________________________________________________- @@ -24,7 +24,7 @@ LL + drop(lock); | error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:104:13 + --> tests/ui/significant_drop_tightening.rs:104:13 | LL | / { LL | | let mutex = Mutex::new(1i32); @@ -44,7 +44,7 @@ LL + drop(lock); | error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:125:13 + --> tests/ui/significant_drop_tightening.rs:125:13 | LL | / { LL | | let mutex = Mutex::new(1i32); @@ -68,7 +68,7 @@ LL + | error: temporary with significant `Drop` can be early dropped - --> $DIR/significant_drop_tightening.rs:131:17 + --> tests/ui/significant_drop_tightening.rs:131:17 | LL | / { LL | | let mutex = Mutex::new(vec![1i32]); diff --git a/src/tools/clippy/tests/ui/similar_names.rs b/src/tools/clippy/tests/ui/similar_names.rs index f46af56c6e2b0..f09693344915b 100644 --- a/src/tools/clippy/tests/ui/similar_names.rs +++ b/src/tools/clippy/tests/ui/similar_names.rs @@ -17,13 +17,10 @@ fn main() { let specter: i32; let spectre: i32; + // ok; first letter is different enough let apple: i32; - let bpple: i32; - //~^ ERROR: binding's name is too similar to existing binding - let cpple: i32; - //~^ ERROR: binding's name is too similar to existing binding let a_bar: i32; let b_bar: i32; diff --git a/src/tools/clippy/tests/ui/similar_names.stderr b/src/tools/clippy/tests/ui/similar_names.stderr index 44ae3532a4862..8d722fb8b564e 100644 --- a/src/tools/clippy/tests/ui/similar_names.stderr +++ b/src/tools/clippy/tests/ui/similar_names.stderr @@ -1,88 +1,64 @@ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:22:9 - | -LL | let bpple: i32; - | ^^^^^ - | -note: existing binding defined here - --> $DIR/similar_names.rs:20:9 - | -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:25:9 - | -LL | let cpple: i32; - | ^^^^^ - | -note: existing binding defined here - --> $DIR/similar_names.rs:20:9 - | -LL | let apple: i32; - | ^^^^^ - -error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:50:9 + --> tests/ui/similar_names.rs:47:9 | LL | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:49:9 + --> tests/ui/similar_names.rs:46:9 | LL | let blubx: 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:55:9 + --> tests/ui/similar_names.rs:52:9 | LL | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:53:9 + --> tests/ui/similar_names.rs:50:9 | LL | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:74:9 + --> tests/ui/similar_names.rs:71:9 | LL | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:72:9 + --> tests/ui/similar_names.rs:69:9 | LL | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:79:9 + --> tests/ui/similar_names.rs:76:9 | LL | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:77:9 + --> tests/ui/similar_names.rs:74:9 | LL | let parser: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/similar_names.rs:101:16 + --> tests/ui/similar_names.rs:98:16 | LL | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> $DIR/similar_names.rs:100:16 + --> tests/ui/similar_names.rs:97:16 | LL | apple: spring, | ^^^^^^ -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors diff --git a/src/tools/clippy/tests/ui/single_call_fn.rs b/src/tools/clippy/tests/ui/single_call_fn.rs index c20214fecccea..55e7508a9573a 100644 --- a/src/tools/clippy/tests/ui/single_call_fn.rs +++ b/src/tools/clippy/tests/ui/single_call_fn.rs @@ -84,3 +84,25 @@ mod issue12182 { fn l() { k(); } + +trait Trait { + fn default() {} + fn foo(&self); +} +extern "C" { + // test some kind of foreign item + fn rand() -> std::ffi::c_int; +} +fn m(v: T) { + const NOT_A_FUNCTION: i32 = 1; + let _ = NOT_A_FUNCTION; + + struct S; + impl S { + fn foo() {} + } + T::default(); + S::foo(); + v.foo(); + unsafe { rand() }; +} diff --git a/src/tools/clippy/tests/ui/single_call_fn.stderr b/src/tools/clippy/tests/ui/single_call_fn.stderr index d5cd707754c2f..14529beac616a 100644 --- a/src/tools/clippy/tests/ui/single_call_fn.stderr +++ b/src/tools/clippy/tests/ui/single_call_fn.stderr @@ -1,5 +1,31 @@ error: this function is only used once - --> $DIR/single_call_fn.rs:34:1 + --> tests/ui/single_call_fn.rs:13:1 + | +LL | fn i() {} + | ^^^^^^^^^ + | +note: used here + --> tests/ui/single_call_fn.rs:18:13 + | +LL | let a = i; + | ^ + = 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 + --> tests/ui/single_call_fn.rs:14:1 + | +LL | fn j() {} + | ^^^^^^^^^ + | +note: used here + --> tests/ui/single_call_fn.rs:25:9 + | +LL | j(); + | ^ + +error: this function is only used once + --> tests/ui/single_call_fn.rs:34:1 | LL | / fn c() { LL | | println!("really"); @@ -8,49 +34,47 @@ LL | | println!("function..."); LL | | } | |_^ | -help: used here - --> $DIR/single_call_fn.rs:41:5 +note: used here + --> tests/ui/single_call_fn.rs:41:5 | 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:13:1 + --> tests/ui/single_call_fn.rs:44:1 | -LL | fn i() {} +LL | fn a() {} | ^^^^^^^^^ | -help: used here - --> $DIR/single_call_fn.rs:18:13 +note: used here + --> tests/ui/single_call_fn.rs:47:5 | -LL | let a = i; - | ^ +LL | a(); + | ^ error: this function is only used once - --> $DIR/single_call_fn.rs:44:1 + --> tests/ui/single_call_fn.rs:89:5 | -LL | fn a() {} - | ^^^^^^^^^ +LL | fn default() {} + | ^^^^^^^^^^^^^^^ | -help: used here - --> $DIR/single_call_fn.rs:47:5 +note: used here + --> tests/ui/single_call_fn.rs:104:5 | -LL | a(); - | ^ +LL | T::default(); + | ^^^^^^^^^^ error: this function is only used once - --> $DIR/single_call_fn.rs:14:1 + --> tests/ui/single_call_fn.rs:102:9 | -LL | fn j() {} - | ^^^^^^^^^ +LL | fn foo() {} + | ^^^^^^^^^^^ | -help: used here - --> $DIR/single_call_fn.rs:25:9 +note: used here + --> tests/ui/single_call_fn.rs:105:5 | -LL | j(); - | ^ +LL | S::foo(); + | ^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 6 previous errors 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 a6f2b3e037b4a..89d75f20f55a7 100644 --- a/src/tools/clippy/tests/ui/single_char_add_str.stderr +++ b/src/tools/clippy/tests/ui/single_char_add_str.stderr @@ -1,5 +1,5 @@ error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:14:5 + --> tests/ui/single_char_add_str.rs:14:5 | LL | string.push_str("R"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('R')` @@ -8,85 +8,85 @@ LL | string.push_str("R"); = 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 + --> tests/ui/single_char_add_str.rs:15:5 | LL | string.push_str("'"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\'')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:20:5 + --> tests/ui/single_char_add_str.rs:20:5 | LL | string.push_str("\x52"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\x52')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:21:5 + --> tests/ui/single_char_add_str.rs:21:5 | LL | string.push_str("\u{0052}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('\u{0052}')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:22:5 + --> tests/ui/single_char_add_str.rs:22:5 | LL | string.push_str(r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `string.push('a')` error: calling `push_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:24:5 + --> tests/ui/single_char_add_str.rs:24:5 | LL | get_string!().push_str("ö"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `get_string!().push('ö')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:29:5 + --> tests/ui/single_char_add_str.rs:29:5 | LL | string.insert_str(0, "R"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, 'R')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:30:5 + --> tests/ui/single_char_add_str.rs:30:5 | LL | string.insert_str(1, "'"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(1, '\'')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:35:5 + --> tests/ui/single_char_add_str.rs:35:5 | LL | string.insert_str(0, "\x52"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '\x52')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:36:5 + --> tests/ui/single_char_add_str.rs:36:5 | LL | string.insert_str(0, "\u{0052}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(0, '\u{0052}')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:38:5 + --> tests/ui/single_char_add_str.rs:38:5 | LL | string.insert_str(x, r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(x, 'a')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:40:5 + --> tests/ui/single_char_add_str.rs:40:5 | LL | string.insert_str(Y, r##"a"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, 'a')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:41:5 + --> tests/ui/single_char_add_str.rs:41:5 | LL | string.insert_str(Y, r##"""##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '"')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:42:5 + --> tests/ui/single_char_add_str.rs:42:5 | LL | string.insert_str(Y, r##"'"##); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '\'')` error: calling `insert_str()` using a single-character string literal - --> $DIR/single_char_add_str.rs:44:5 + --> tests/ui/single_char_add_str.rs:44:5 | LL | get_string!().insert_str(1, "?"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `get_string!().insert(1, '?')` 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 2cdfd61358e75..005c897b19bac 100644 --- a/src/tools/clippy/tests/ui/single_char_lifetime_names.stderr +++ b/src/tools/clippy/tests/ui/single_char_lifetime_names.stderr @@ -1,5 +1,5 @@ error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:5:22 + --> tests/ui/single_char_lifetime_names.rs:5:22 | LL | struct DiagnosticCtx<'a, 'b> | ^^ @@ -9,7 +9,7 @@ LL | struct DiagnosticCtx<'a, 'b> = 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 + --> tests/ui/single_char_lifetime_names.rs:5:26 | LL | struct DiagnosticCtx<'a, 'b> | ^^ @@ -17,7 +17,7 @@ LL | struct DiagnosticCtx<'a, 'b> = help: use a more informative name error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:16:6 + --> tests/ui/single_char_lifetime_names.rs:16:6 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | ^^ @@ -25,7 +25,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { = help: use a more informative name error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:16:10 + --> tests/ui/single_char_lifetime_names.rs:16:10 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | ^^ @@ -33,7 +33,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { = help: use a more informative name error: single-character lifetime names are likely uninformative - --> $DIR/single_char_lifetime_names.rs:38:15 + --> tests/ui/single_char_lifetime_names.rs:38:15 | LL | fn split_once<'a>(base: &'a str, other: &'_ str) -> (&'a str, Option<&'a str>) { | ^^ diff --git a/src/tools/clippy/tests/ui/single_char_pattern.stderr b/src/tools/clippy/tests/ui/single_char_pattern.stderr index 664d6b5a1e9b0..5a2ec6c764b18 100644 --- a/src/tools/clippy/tests/ui/single_char_pattern.stderr +++ b/src/tools/clippy/tests/ui/single_char_pattern.stderr @@ -1,5 +1,5 @@ error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:7:13 + --> tests/ui/single_char_pattern.rs:7:13 | LL | x.split("x"); | ^^^ help: consider using a `char`: `'x'` @@ -8,235 +8,235 @@ LL | x.split("x"); = 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 + --> tests/ui/single_char_pattern.rs:13:13 | LL | x.split("ß"); | ^^^ help: consider using a `char`: `'ß'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:14:13 + --> tests/ui/single_char_pattern.rs:14:13 | LL | x.split("ℝ"); | ^^^ help: consider using a `char`: `'ℝ'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:15:13 + --> tests/ui/single_char_pattern.rs:15:13 | LL | x.split("💣"); | ^^^^ help: consider using a `char`: `'💣'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:18:23 + --> tests/ui/single_char_pattern.rs:18:23 | LL | x.split_inclusive("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:19:16 + --> tests/ui/single_char_pattern.rs:19:16 | LL | x.contains("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:20:19 + --> tests/ui/single_char_pattern.rs:20:19 | LL | x.starts_with("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:21:17 + --> tests/ui/single_char_pattern.rs:21:17 | LL | x.ends_with("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:22:12 + --> tests/ui/single_char_pattern.rs:22:12 | LL | x.find("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:23:13 + --> tests/ui/single_char_pattern.rs:23:13 | LL | x.rfind("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:24:14 + --> tests/ui/single_char_pattern.rs:24:14 | LL | x.rsplit("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:25:24 + --> tests/ui/single_char_pattern.rs:25:24 | LL | x.split_terminator("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:26:25 + --> tests/ui/single_char_pattern.rs:26:25 | LL | x.rsplit_terminator("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:27:17 + --> tests/ui/single_char_pattern.rs:27:17 | LL | x.splitn(2, "x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:28:18 + --> tests/ui/single_char_pattern.rs:28:18 | LL | x.rsplitn(2, "x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:29:18 + --> tests/ui/single_char_pattern.rs:29:18 | LL | x.split_once("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:30:19 + --> tests/ui/single_char_pattern.rs:30:19 | LL | x.rsplit_once("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:31:15 + --> tests/ui/single_char_pattern.rs:31:15 | LL | x.matches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:32:16 + --> tests/ui/single_char_pattern.rs:32:16 | LL | x.rmatches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:33:21 + --> tests/ui/single_char_pattern.rs:33:21 | LL | x.match_indices("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:34:22 + --> tests/ui/single_char_pattern.rs:34:22 | LL | x.rmatch_indices("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:35:26 + --> tests/ui/single_char_pattern.rs:35:26 | LL | x.trim_start_matches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:36:24 + --> tests/ui/single_char_pattern.rs:36:24 | LL | x.trim_end_matches("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:37:20 + --> tests/ui/single_char_pattern.rs:37:20 | LL | x.strip_prefix("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:38:20 + --> tests/ui/single_char_pattern.rs:38:20 | LL | x.strip_suffix("x"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:39:15 + --> tests/ui/single_char_pattern.rs:39:15 | LL | x.replace("x", "y"); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:40:16 + --> tests/ui/single_char_pattern.rs:40:16 | LL | x.replacen("x", "y", 3); | ^^^ help: consider using a `char`: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:42:13 + --> tests/ui/single_char_pattern.rs:42:13 | LL | x.split("\n"); | ^^^^ help: consider using a `char`: `'\n'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:43:13 + --> tests/ui/single_char_pattern.rs:43:13 | LL | x.split("'"); | ^^^ help: consider using a `char`: `'\''` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:44:13 + --> tests/ui/single_char_pattern.rs:44:13 | LL | x.split("\'"); | ^^^^ help: consider using a `char`: `'\''` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:46:13 + --> tests/ui/single_char_pattern.rs:46:13 | LL | x.split("\""); | ^^^^ help: consider using a `char`: `'"'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:51:31 + --> tests/ui/single_char_pattern.rs:51:31 | LL | x.replace(';', ",").split(","); // issue #2978 | ^^^ help: consider using a `char`: `','` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:52:19 + --> tests/ui/single_char_pattern.rs:52:19 | LL | x.starts_with("\x03"); // issue #2996 | ^^^^^^ help: consider using a `char`: `'\x03'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:59:13 + --> tests/ui/single_char_pattern.rs:59:13 | LL | x.split(r"a"); | ^^^^ help: consider using a `char`: `'a'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:60:13 + --> tests/ui/single_char_pattern.rs:60:13 | LL | x.split(r#"a"#); | ^^^^^^ help: consider using a `char`: `'a'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:61:13 + --> tests/ui/single_char_pattern.rs:61:13 | LL | x.split(r###"a"###); | ^^^^^^^^^^ help: consider using a `char`: `'a'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:62:13 + --> tests/ui/single_char_pattern.rs:62:13 | LL | x.split(r###"'"###); | ^^^^^^^^^^ help: consider using a `char`: `'\''` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:63:13 + --> tests/ui/single_char_pattern.rs:63:13 | LL | x.split(r###"#"###); | ^^^^^^^^^^ help: consider using a `char`: `'#'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:65:13 + --> tests/ui/single_char_pattern.rs:65:13 | LL | x.split(r#"\"#); | ^^^^^^ help: consider using a `char`: `'\\'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:66:13 + --> tests/ui/single_char_pattern.rs:66:13 | LL | x.split(r"\"); | ^^^^ help: consider using a `char`: `'\\'` 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 440d34002d7ff..95d7e4d85b7c3 100644 --- a/src/tools/clippy/tests/ui/single_component_path_imports.stderr +++ b/src/tools/clippy/tests/ui/single_component_path_imports.stderr @@ -1,5 +1,5 @@ error: this import is redundant - --> $DIR/single_component_path_imports.rs:6:1 + --> tests/ui/single_component_path_imports.rs:6:1 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely @@ -8,7 +8,7 @@ LL | use regex; = 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 + --> tests/ui/single_component_path_imports.rs:32:5 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely 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 d65ab5620db77..8eec877860e7e 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 @@ -1,5 +1,5 @@ error: this import is redundant - --> $DIR/single_component_path_imports_nested_first.rs:4:1 + --> tests/ui/single_component_path_imports_nested_first.rs:4:1 | LL | use regex; | ^^^^^^^^^^ help: remove it entirely @@ -8,7 +8,7 @@ LL | use regex; = 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 + --> tests/ui/single_component_path_imports_nested_first.rs:17:10 | LL | use {regex, serde}; | ^^^^^ @@ -16,7 +16,7 @@ LL | use {regex, serde}; = help: remove this import error: this import is redundant - --> $DIR/single_component_path_imports_nested_first.rs:17:17 + --> tests/ui/single_component_path_imports_nested_first.rs:17:17 | LL | use {regex, serde}; | ^^^^^ diff --git a/src/tools/clippy/tests/ui/single_element_loop.stderr b/src/tools/clippy/tests/ui/single_element_loop.stderr index 952d704143a5b..dfae5605b5715 100644 --- a/src/tools/clippy/tests/ui/single_element_loop.stderr +++ b/src/tools/clippy/tests/ui/single_element_loop.stderr @@ -1,5 +1,5 @@ error: for loop over a single element - --> $DIR/single_element_loop.rs:8:5 + --> tests/ui/single_element_loop.rs:8:5 | LL | / for item in &[item1] { LL | | dbg!(item); @@ -17,7 +17,7 @@ LL + } | error: for loop over a single element - --> $DIR/single_element_loop.rs:12:5 + --> tests/ui/single_element_loop.rs:12:5 | LL | / for item in [item1].iter() { LL | | dbg!(item); @@ -33,31 +33,31 @@ LL + } | error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:16:17 + --> tests/ui/single_element_loop.rs:16:17 | LL | for item in &[0..5] { | ^^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:20:17 + --> tests/ui/single_element_loop.rs:20:17 | LL | for item in [0..5].iter_mut() { | ^^^^^^^^^^^^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:24:17 + --> tests/ui/single_element_loop.rs:24:17 | LL | for item in [0..5] { | ^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: this loops only once with `item` being `0..5` - --> $DIR/single_element_loop.rs:28:17 + --> tests/ui/single_element_loop.rs:28:17 | LL | for item in [0..5].into_iter() { | ^^^^^^^^^^^^^^^^^^ help: did you mean to iterate over the range instead?: `0..5` error: for loop over a single element - --> $DIR/single_element_loop.rs:47:5 + --> tests/ui/single_element_loop.rs:47:5 | LL | / for _ in [42] { LL | | let _f = |n: u32| { diff --git a/src/tools/clippy/tests/ui/single_match.stderr b/src/tools/clippy/tests/ui/single_match.stderr index d4b8659952139..40af38879aeb2 100644 --- a/src/tools/clippy/tests/ui/single_match.stderr +++ b/src/tools/clippy/tests/ui/single_match.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:14:5 + --> tests/ui/single_match.rs:14:5 | LL | / match x { LL | | Some(y) => { @@ -19,7 +19,7 @@ LL ~ }; | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:22:5 + --> tests/ui/single_match.rs:22:5 | LL | / match x { LL | | // Note the missing block braces. @@ -31,7 +31,7 @@ LL | | } | |_____^ help: try: `if let Some(y) = x { println!("{:?}", y) }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:31:5 + --> tests/ui/single_match.rs:31:5 | LL | / match z { LL | | (2..=3, 7..=9) => dummy(), @@ -40,7 +40,7 @@ LL | | }; | |_____^ help: try: `if let (2..=3, 7..=9) = z { dummy() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:60:5 + --> tests/ui/single_match.rs:60:5 | LL | / match x { LL | | Some(y) => dummy(), @@ -49,7 +49,7 @@ LL | | }; | |_____^ help: try: `if let Some(y) = x { dummy() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:65:5 + --> tests/ui/single_match.rs:65:5 | LL | / match y { LL | | Ok(y) => dummy(), @@ -58,7 +58,7 @@ LL | | }; | |_____^ help: try: `if let Ok(y) = y { dummy() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:72:5 + --> tests/ui/single_match.rs:72:5 | LL | / match c { LL | | Cow::Borrowed(..) => dummy(), @@ -67,7 +67,7 @@ LL | | }; | |_____^ help: try: `if let Cow::Borrowed(..) = c { dummy() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:93:5 + --> tests/ui/single_match.rs:93:5 | LL | / match x { LL | | "test" => println!(), @@ -76,7 +76,7 @@ LL | | } | |_____^ help: try: `if x == "test" { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:106:5 + --> tests/ui/single_match.rs:106:5 | LL | / match x { LL | | Foo::A => println!(), @@ -85,7 +85,7 @@ LL | | } | |_____^ help: try: `if x == Foo::A { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:112:5 + --> tests/ui/single_match.rs:112:5 | LL | / match x { LL | | FOO_C => println!(), @@ -94,7 +94,7 @@ LL | | } | |_____^ help: try: `if x == FOO_C { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:117:5 + --> tests/ui/single_match.rs:117:5 | LL | / match &&x { LL | | Foo::A => println!(), @@ -103,7 +103,7 @@ LL | | } | |_____^ help: try: `if x == Foo::A { println!() }` error: you seem to be trying to use `match` for an equality check. Consider using `if` - --> $DIR/single_match.rs:123:5 + --> tests/ui/single_match.rs:123:5 | LL | / match &x { LL | | Foo::A => println!(), @@ -112,7 +112,7 @@ LL | | } | |_____^ help: try: `if x == &Foo::A { println!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:140:5 + --> tests/ui/single_match.rs:140:5 | LL | / match x { LL | | Bar::A => println!(), @@ -121,7 +121,7 @@ LL | | } | |_____^ help: try: `if let Bar::A = x { println!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:148:5 + --> tests/ui/single_match.rs:148:5 | LL | / match x { LL | | None => println!(), @@ -130,7 +130,7 @@ LL | | }; | |_____^ help: try: `if let None = x { println!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:170:5 + --> tests/ui/single_match.rs:170:5 | LL | / match x { LL | | (Some(_), _) => {}, @@ -139,7 +139,7 @@ LL | | } | |_____^ help: try: `if let (Some(_), _) = x {}` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:176:5 + --> tests/ui/single_match.rs:176:5 | LL | / match x { LL | | (Some(E::V), _) => todo!(), @@ -148,7 +148,7 @@ LL | | } | |_____^ help: try: `if let (Some(E::V), _) = x { todo!() }` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:182:5 + --> tests/ui/single_match.rs:182:5 | LL | / match (Some(42), Some(E::V), Some(42)) { LL | | (.., Some(E::V), _) => {}, @@ -157,7 +157,7 @@ LL | | } | |_____^ help: try: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:254:5 + --> tests/ui/single_match.rs:254:5 | LL | / match bar { LL | | Some(v) => unsafe { @@ -177,7 +177,7 @@ LL + } } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:262:5 + --> tests/ui/single_match.rs:262:5 | LL | / match bar { LL | | #[rustfmt::skip] diff --git a/src/tools/clippy/tests/ui/single_match_else.stderr b/src/tools/clippy/tests/ui/single_match_else.stderr index 3b4b1332c403a..63c733e9a7a03 100644 --- a/src/tools/clippy/tests/ui/single_match_else.stderr +++ b/src/tools/clippy/tests/ui/single_match_else.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:16:13 + --> tests/ui/single_match_else.rs:16:13 | LL | let _ = match ExprNode::Butterflies { | _____________^ @@ -22,7 +22,7 @@ LL ~ }; | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:81:5 + --> tests/ui/single_match_else.rs:81:5 | LL | / match Some(1) { LL | | Some(a) => println!("${:?}", a), @@ -42,7 +42,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:90:5 + --> tests/ui/single_match_else.rs:90:5 | LL | / match Some(1) { LL | | Some(a) => println!("${:?}", a), @@ -62,7 +62,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:100:5 + --> tests/ui/single_match_else.rs:100:5 | LL | / match Result::::Ok(1) { LL | | Ok(a) => println!("${:?}", a), @@ -82,7 +82,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:109:5 + --> tests/ui/single_match_else.rs:109:5 | LL | / match Cow::from("moo") { LL | | Cow::Owned(a) => println!("${:?}", a), @@ -102,7 +102,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:119:5 + --> tests/ui/single_match_else.rs:119:5 | LL | / match bar { LL | | Some(v) => unsafe { @@ -125,7 +125,7 @@ LL + } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:130:5 + --> tests/ui/single_match_else.rs:130:5 | LL | / match bar { LL | | Some(v) => { @@ -149,7 +149,7 @@ LL + } } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:142:5 + --> tests/ui/single_match_else.rs:142:5 | LL | / match bar { LL | | Some(v) => unsafe { @@ -173,7 +173,7 @@ LL + } } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match_else.rs:154:5 + --> tests/ui/single_match_else.rs:154:5 | LL | / match bar { LL | | #[rustfmt::skip] 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 e83e49af676cc..9c125adb51a73 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 @@ -1,5 +1,5 @@ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:26:5 + --> tests/ui/single_range_in_vec_init.rs:26:5 | LL | [0..200]; | ^^^^^^^^ @@ -16,7 +16,7 @@ LL | [0; 200]; | ~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:27:5 + --> tests/ui/single_range_in_vec_init.rs:27:5 | LL | vec![0..200]; | ^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | vec![0; 200]; | ~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:28:5 + --> tests/ui/single_range_in_vec_init.rs:28:5 | LL | [0u8..200]; | ^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | [0u8; 200]; | ~~~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:29:5 + --> tests/ui/single_range_in_vec_init.rs:29:5 | LL | [0usize..200]; | ^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | [0usize; 200]; | ~~~~~~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:30:5 + --> tests/ui/single_range_in_vec_init.rs:30:5 | LL | [0..200usize]; | ^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | [0; 200usize]; | ~~~~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:31:5 + --> tests/ui/single_range_in_vec_init.rs:31:5 | LL | vec![0u8..200]; | ^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | vec![0u8; 200]; | ~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:32:5 + --> tests/ui/single_range_in_vec_init.rs:32:5 | LL | vec![0usize..200]; | ^^^^^^^^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | vec![0usize; 200]; | ~~~~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:33:5 + --> tests/ui/single_range_in_vec_init.rs:33:5 | LL | vec![0..200usize]; | ^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | vec![0; 200usize]; | ~~~~~~~~~~~ error: an array of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:35:5 + --> tests/ui/single_range_in_vec_init.rs:35:5 | LL | [0..200isize]; | ^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ LL | (0..200isize).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: a `Vec` of `Range` that is only one element - --> $DIR/single_range_in_vec_init.rs:36:5 + --> tests/ui/single_range_in_vec_init.rs:36:5 | LL | vec![0..200isize]; | ^^^^^^^^^^^^^^^^^ 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 47f9632b8d123..6396afd7f3955 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 @@ -1,5 +1,5 @@ error: found a count of bytes instead of a count of elements of `T` - --> $DIR/expressions.rs:15:62 + --> tests/ui/size_of_in_element_count/expressions.rs:15:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::( = 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 + --> tests/ui/size_of_in_element_count/expressions.rs:19:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * si = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/expressions.rs:23:47 + --> tests/ui/size_of_in_element_count/expressions.rs:23:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() / 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/expressions.rs:33:47 + --> tests/ui/size_of_in_element_count/expressions.rs:33:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::())) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 aba4c800e44df..abde7dc7cd2d3 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 @@ -1,5 +1,5 @@ error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:18:68 + --> tests/ui/size_of_in_element_count/functions.rs:18:68 | LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | unsafe { copy_nonoverlapping::(x.as_ptr(), y.as_mut_ptr(), size_of: = 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 + --> tests/ui/size_of_in_element_count/functions.rs:20:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | ^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:23:49 + --> tests/ui/size_of_in_element_count/functions.rs:23:49 | LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { x.as_ptr().copy_to(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 error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:25:64 + --> tests/ui/size_of_in_element_count/functions.rs:25:64 | LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of:: $DIR/functions.rs:27:51 + --> tests/ui/size_of_in_element_count/functions.rs:27:51 | LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | unsafe { y.as_mut_ptr().copy_from(x.as_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 error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:29:66 + --> tests/ui/size_of_in_element_count/functions.rs:29:66 | LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_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 error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:32:47 + --> tests/ui/size_of_in_element_count/functions.rs:32:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | unsafe { copy(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 error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:34:47 + --> tests/ui/size_of_in_element_count/functions.rs:34:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | ^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:37:46 + --> tests/ui/size_of_in_element_count/functions.rs:37:46 | LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:39:47 + --> tests/ui/size_of_in_element_count/functions.rs:39:47 | LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:42:66 + --> tests/ui/size_of_in_element_count/functions.rs:42:66 | LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.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 error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:45:46 + --> tests/ui/size_of_in_element_count/functions.rs:45:46 | LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:47:38 + --> tests/ui/size_of_in_element_count/functions.rs:47:38 | LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:50:49 + --> tests/ui/size_of_in_element_count/functions.rs:50:49 | LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:52:41 + --> tests/ui/size_of_in_element_count/functions.rs:52:41 | LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:55:33 + --> tests/ui/size_of_in_element_count/functions.rs:55:33 | LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:57:29 + --> tests/ui/size_of_in_element_count/functions.rs:57:29 | LL | y.as_ptr().wrapping_sub(size_of::()); | ^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | y.as_ptr().wrapping_sub(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:59:29 + --> tests/ui/size_of_in_element_count/functions.rs:59:29 | LL | unsafe { y.as_ptr().add(size_of::()) }; | ^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | unsafe { y.as_ptr().add(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:61:33 + --> tests/ui/size_of_in_element_count/functions.rs:61:33 | LL | y.as_mut_ptr().wrapping_add(size_of::()); | ^^^^^^^^^^^^^^^ @@ -153,7 +153,7 @@ LL | y.as_mut_ptr().wrapping_add(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:63:32 + --> tests/ui/size_of_in_element_count/functions.rs:63:32 | LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -161,7 +161,7 @@ LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> $DIR/functions.rs:65:36 + --> tests/ui/size_of_in_element_count/functions.rs:65:36 | LL | y.as_mut_ptr().wrapping_offset(size_of::() as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/size_of_ref.stderr b/src/tools/clippy/tests/ui/size_of_ref.stderr index e239c5810c92e..bb8f08de531cf 100644 --- a/src/tools/clippy/tests/ui/size_of_ref.stderr +++ b/src/tools/clippy/tests/ui/size_of_ref.stderr @@ -1,5 +1,5 @@ error: argument to `std::mem::size_of_val()` is a reference to a reference - --> $DIR/size_of_ref.rs:13:5 + --> tests/ui/size_of_ref.rs:13:5 | LL | size_of_val(&&x); | ^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | size_of_val(&&x); = 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 + --> tests/ui/size_of_ref.rs:15:5 | LL | size_of_val(&y); | ^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | size_of_val(&y); = 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 error: argument to `std::mem::size_of_val()` is a reference to a reference - --> $DIR/size_of_ref.rs:27:9 + --> tests/ui/size_of_ref.rs:27:9 | LL | std::mem::size_of_val(&self) + (std::mem::size_of::() * self.data.capacity()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/skip_while_next.stderr b/src/tools/clippy/tests/ui/skip_while_next.stderr index 3c33af3a16080..2c1b9eeba3b6e 100644 --- a/src/tools/clippy/tests/ui/skip_while_next.stderr +++ b/src/tools/clippy/tests/ui/skip_while_next.stderr @@ -1,5 +1,5 @@ error: called `skip_while(

).next()` on an `Iterator` - --> $DIR/skip_while_next.rs:14:13 + --> tests/ui/skip_while_next.rs:14:13 | LL | let _ = v.iter().skip_while(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = v.iter().skip_while(|&x| *x < 0).next(); = 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 + --> tests/ui/skip_while_next.rs:17:13 | LL | let _ = v.iter().skip_while(|&x| { | _____________^ diff --git a/src/tools/clippy/tests/ui/slow_vector_initialization.stderr b/src/tools/clippy/tests/ui/slow_vector_initialization.stderr index 16a7057653c10..353c677097be7 100644 --- a/src/tools/clippy/tests/ui/slow_vector_initialization.stderr +++ b/src/tools/clippy/tests/ui/slow_vector_initialization.stderr @@ -1,5 +1,5 @@ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:14:5 + --> tests/ui/slow_vector_initialization.rs:14:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -10,7 +10,7 @@ LL | vec1.extend(repeat(0).take(len)); = help: to override `-D warnings` add `#[allow(clippy::slow_vector_initialization)]` error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:20:5 + --> tests/ui/slow_vector_initialization.rs:20:5 | LL | let mut vec2 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replacing this with: `vec![0; len - 10]` @@ -18,7 +18,7 @@ LL | vec2.extend(repeat(0).take(len - 10)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:28:5 + --> tests/ui/slow_vector_initialization.rs:28:5 | LL | let mut vec4 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -26,7 +26,7 @@ LL | vec4.extend(repeat(0).take(vec4.capacity())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:39:5 + --> tests/ui/slow_vector_initialization.rs:39:5 | LL | let mut resized_vec = Vec::with_capacity(30); | ---------------------- help: consider replacing this with: `vec![0; 30]` @@ -34,7 +34,7 @@ LL | resized_vec.resize(30, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:43:5 + --> tests/ui/slow_vector_initialization.rs:43:5 | LL | let mut extend_vec = Vec::with_capacity(30); | ---------------------- help: consider replacing this with: `vec![0; 30]` @@ -42,7 +42,7 @@ LL | extend_vec.extend(repeat(0).take(30)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:51:5 + --> tests/ui/slow_vector_initialization.rs:51:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -50,7 +50,7 @@ LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:60:5 + --> tests/ui/slow_vector_initialization.rs:60:5 | LL | let mut vec3 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replacing this with: `vec![0; len - 10]` @@ -58,7 +58,7 @@ LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:64:5 + --> tests/ui/slow_vector_initialization.rs:64:5 | LL | let mut vec4 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -66,7 +66,7 @@ LL | vec4.resize(vec4.capacity(), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:69:5 + --> tests/ui/slow_vector_initialization.rs:69:5 | LL | vec1 = Vec::with_capacity(10); | ---------------------- help: consider replacing this with: `vec![0; 10]` @@ -74,7 +74,7 @@ LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:77:5 + --> tests/ui/slow_vector_initialization.rs:77:5 | LL | let mut vec1 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; len]` @@ -82,7 +82,7 @@ LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:82:5 + --> tests/ui/slow_vector_initialization.rs:82:5 | LL | let mut vec3 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; len - 10]` @@ -90,7 +90,7 @@ LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:87:5 + --> tests/ui/slow_vector_initialization.rs:87:5 | LL | vec1 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; 10]` @@ -98,7 +98,7 @@ LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:91:5 + --> tests/ui/slow_vector_initialization.rs:91:5 | LL | vec1 = vec![]; | ------ help: consider replacing this with: `vec![0; 10]` diff --git a/src/tools/clippy/tests/ui/stable_sort_primitive.stderr b/src/tools/clippy/tests/ui/stable_sort_primitive.stderr index b665033283348..66bd4c79bb286 100644 --- a/src/tools/clippy/tests/ui/stable_sort_primitive.stderr +++ b/src/tools/clippy/tests/ui/stable_sort_primitive.stderr @@ -1,5 +1,5 @@ error: used `sort` on primitive type `i32` - --> $DIR/stable_sort_primitive.rs:7:5 + --> tests/ui/stable_sort_primitive.rs:7:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -9,7 +9,7 @@ LL | vec.sort(); = 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 + --> tests/ui/stable_sort_primitive.rs:9:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -17,7 +17,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `char` - --> $DIR/stable_sort_primitive.rs:11:5 + --> tests/ui/stable_sort_primitive.rs:11:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -25,7 +25,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `str` - --> $DIR/stable_sort_primitive.rs:13:5 + --> tests/ui/stable_sort_primitive.rs:13:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -33,7 +33,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `tuple` - --> $DIR/stable_sort_primitive.rs:15:5 + --> tests/ui/stable_sort_primitive.rs:15:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -41,7 +41,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `array` - --> $DIR/stable_sort_primitive.rs:17:5 + --> tests/ui/stable_sort_primitive.rs:17:5 | LL | vec.sort(); | ^^^^^^^^^^ help: try: `vec.sort_unstable()` @@ -49,7 +49,7 @@ LL | vec.sort(); = note: an unstable sort typically performs faster without any observable difference for this data type error: used `sort` on primitive type `i32` - --> $DIR/stable_sort_primitive.rs:19:5 + --> tests/ui/stable_sort_primitive.rs:19:5 | LL | arr.sort(); | ^^^^^^^^^^ help: try: `arr.sort_unstable()` diff --git a/src/tools/clippy/tests/ui/starts_ends_with.stderr b/src/tools/clippy/tests/ui/starts_ends_with.stderr index c4c547949a364..cee31f1e4cdd3 100644 --- a/src/tools/clippy/tests/ui/starts_ends_with.stderr +++ b/src/tools/clippy/tests/ui/starts_ends_with.stderr @@ -1,5 +1,5 @@ error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:7:5 + --> tests/ui/starts_ends_with.rs:7:5 | LL | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` @@ -8,31 +8,31 @@ LL | "".chars().next() == Some(' '); = 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 + --> tests/ui/starts_ends_with.rs:8:5 | LL | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:11:5 + --> tests/ui/starts_ends_with.rs:11:5 | LL | "".chars().next() == Some('\n'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with('\n')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:12:5 + --> tests/ui/starts_ends_with.rs:12:5 | LL | Some('\n') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with('\n')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:17:8 + --> tests/ui/starts_ends_with.rs:17:8 | LL | if s.chars().next().unwrap() == 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:21:8 + --> tests/ui/starts_ends_with.rs:21:8 | LL | if s.chars().next_back().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` @@ -41,61 +41,61 @@ LL | if s.chars().next_back().unwrap() == 'o' { = 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 + --> tests/ui/starts_ends_with.rs:25:8 | LL | if s.chars().last().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:29:8 + --> tests/ui/starts_ends_with.rs:29:8 | LL | if s.chars().next().unwrap() != 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:33:8 + --> tests/ui/starts_ends_with.rs:33:8 | LL | if s.chars().next_back().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:37:8 + --> tests/ui/starts_ends_with.rs:37:8 | LL | if s.chars().last().unwrap() != '\n' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('\n')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:45:5 + --> tests/ui/starts_ends_with.rs:45:5 | LL | "".chars().last() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:46:5 + --> tests/ui/starts_ends_with.rs:46:5 | LL | Some(' ') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:47:5 + --> tests/ui/starts_ends_with.rs:47:5 | LL | "".chars().next_back() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:48:5 + --> tests/ui/starts_ends_with.rs:48:5 | LL | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:51:5 + --> tests/ui/starts_ends_with.rs:51:5 | LL | "".chars().last() == Some('\n'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with('\n')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:52:5 + --> tests/ui/starts_ends_with.rs:52:5 | LL | Some('\n') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with('\n')` 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 4f7bdc4045e77..30dd49dc2688d 100644 --- a/src/tools/clippy/tests/ui/std_instead_of_core.stderr +++ b/src/tools/clippy/tests/ui/std_instead_of_core.stderr @@ -1,5 +1,5 @@ error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:13:9 + --> tests/ui/std_instead_of_core.rs:13:9 | LL | use std::hash::Hasher; | ^^^ help: consider importing the item from `core`: `core` @@ -8,49 +8,49 @@ LL | use std::hash::Hasher; = 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:16:11 + --> tests/ui/std_instead_of_core.rs:16:11 | LL | use ::std::hash::Hash; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:22:9 + --> tests/ui/std_instead_of_core.rs:22:9 | LL | use std::fmt::{Debug, Result}; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:26:15 + --> tests/ui/std_instead_of_core.rs:26:15 | LL | let ptr = std::ptr::null::(); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:28:21 + --> tests/ui/std_instead_of_core.rs:28:21 | LL | let ptr_mut = ::std::ptr::null_mut::(); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:32:16 + --> tests/ui/std_instead_of_core.rs:32:16 | LL | let cell = std::cell::Cell::new(8u32); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:34:27 + --> tests/ui/std_instead_of_core.rs:34:27 | LL | let cell_absolute = ::std::cell::Cell::new(8u32); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> $DIR/std_instead_of_core.rs:43:9 + --> tests/ui/std_instead_of_core.rs:43:9 | LL | use std::iter::Iterator; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `alloc` - --> $DIR/std_instead_of_core.rs:50:9 + --> tests/ui/std_instead_of_core.rs:50:9 | LL | use std::vec; | ^^^ help: consider importing the item from `alloc`: `alloc` @@ -59,13 +59,13 @@ LL | use std::vec; = 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:52:9 + --> tests/ui/std_instead_of_core.rs:52:9 | LL | use std::vec::Vec; | ^^^ help: consider importing the item from `alloc`: `alloc` error: used import from `alloc` instead of `core` - --> $DIR/std_instead_of_core.rs:58:9 + --> tests/ui/std_instead_of_core.rs:58:9 | LL | use alloc::slice::from_ref; | ^^^^^ help: consider importing the item from `core`: `core` diff --git a/src/tools/clippy/tests/ui/str_split.stderr b/src/tools/clippy/tests/ui/str_split.stderr index ee0a9653711a1..ebe0d4ef4d301 100644 --- a/src/tools/clippy/tests/ui/str_split.stderr +++ b/src/tools/clippy/tests/ui/str_split.stderr @@ -1,5 +1,5 @@ error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:59:13 + --> tests/ui/str_split.rs:59:13 | LL | let _ = s1.trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()` @@ -8,55 +8,55 @@ LL | let _ = s1.trim().split('\n'); = help: to override `-D warnings` add `#[allow(clippy::str_split_at_newline)]` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:61:13 + --> tests/ui/str_split.rs:61:13 | LL | let _ = s1.trim().split("\n"); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:62:13 + --> tests/ui/str_split.rs:62:13 | LL | let _ = s1.trim().split("\r\n"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s1.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:65:13 + --> tests/ui/str_split.rs:65:13 | LL | let _ = s2.trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:67:13 + --> tests/ui/str_split.rs:67:13 | LL | let _ = s2.trim().split("\n"); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:68:13 + --> tests/ui/str_split.rs:68:13 | LL | let _ = s2.trim().split("\r\n"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s2.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:72:13 + --> tests/ui/str_split.rs:72:13 | LL | let _ = s3.trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:74:13 + --> tests/ui/str_split.rs:74:13 | LL | let _ = s3.trim().split("\n"); | ^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:75:13 + --> tests/ui/str_split.rs:75:13 | LL | let _ = s3.trim().split("\r\n"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `s3.lines()` error: using `str.trim().split()` with hard-coded newlines - --> $DIR/str_split.rs:78:13 + --> tests/ui/str_split.rs:78:13 | LL | let _ = make_str!(s1).trim().split('\n'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `str.lines()` instead: `make_str!(s1).lines()` diff --git a/src/tools/clippy/tests/ui/str_to_string.stderr b/src/tools/clippy/tests/ui/str_to_string.stderr index 203805eca5a64..13b73622d6982 100644 --- a/src/tools/clippy/tests/ui/str_to_string.stderr +++ b/src/tools/clippy/tests/ui/str_to_string.stderr @@ -1,5 +1,5 @@ error: `to_string()` called on a `&str` - --> $DIR/str_to_string.rs:4:17 + --> tests/ui/str_to_string.rs:4:17 | LL | let hello = "hello world".to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let hello = "hello world".to_string(); = 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 + --> tests/ui/str_to_string.rs:7:5 | LL | msg.to_string(); | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/string_add.stderr b/src/tools/clippy/tests/ui/string_add.stderr index 892753b9034e9..fe6849b894b53 100644 --- a/src/tools/clippy/tests/ui/string_add.stderr +++ b/src/tools/clippy/tests/ui/string_add.stderr @@ -1,5 +1,5 @@ error: manual implementation of an assign operation - --> $DIR/string_add.rs:13:9 + --> tests/ui/string_add.rs:13:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` @@ -8,7 +8,7 @@ LL | x = x + "."; = 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 + --> tests/ui/string_add.rs:13:13 | LL | x = x + "."; | ^^^^^^^ @@ -17,13 +17,13 @@ LL | x = x + "."; = 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 + --> tests/ui/string_add.rs:17:13 | LL | let z = y + "..."; | ^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/string_add.rs:22:5 + --> tests/ui/string_add.rs:22:5 | LL | x = x + 1; | ^^^^^^^^^ help: replace it with: `x += 1` diff --git a/src/tools/clippy/tests/ui/string_add_assign.stderr b/src/tools/clippy/tests/ui/string_add_assign.stderr index 7d37c98a8f930..50f970084e6b2 100644 --- a/src/tools/clippy/tests/ui/string_add_assign.stderr +++ b/src/tools/clippy/tests/ui/string_add_assign.stderr @@ -1,5 +1,5 @@ error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/string_add_assign.rs:8:9 + --> tests/ui/string_add_assign.rs:8:9 | LL | x = x + "."; | ^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | x = x + "."; = 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 + --> tests/ui/string_add_assign.rs:8:9 | LL | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` @@ -17,7 +17,7 @@ LL | x = x + "."; = 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 + --> tests/ui/string_add_assign.rs:17:5 | LL | x = x + 1; | ^^^^^^^^^ help: replace it with: `x += 1` diff --git a/src/tools/clippy/tests/ui/string_extend.stderr b/src/tools/clippy/tests/ui/string_extend.stderr index e063d87e37d3e..fadda786aacb6 100644 --- a/src/tools/clippy/tests/ui/string_extend.stderr +++ b/src/tools/clippy/tests/ui/string_extend.stderr @@ -1,5 +1,5 @@ error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:16:5 + --> tests/ui/string_extend.rs:16:5 | LL | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str(abc)` @@ -8,19 +8,19 @@ LL | s.extend(abc.chars()); = help: to override `-D warnings` add `#[allow(clippy::string_extend_chars)]` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:19:5 + --> tests/ui/string_extend.rs:19:5 | LL | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str("abc")` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:22:5 + --> tests/ui/string_extend.rs:22:5 | LL | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str(&def)` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:32:5 + --> tests/ui/string_extend.rs:32:5 | LL | s.extend(abc[0..2].chars()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.push_str(&abc[0..2])` 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 4738bef3ae9ea..99c8d8ae4eabc 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 @@ -1,5 +1,5 @@ error: calling a slice of `as_bytes()` with `from_utf8` should be not necessary - --> $DIR/string_from_utf8_as_bytes.rs:4:13 + --> tests/ui/string_from_utf8_as_bytes.rs:4:13 | LL | let _ = std::str::from_utf8(&"Hello World!".as_bytes()[6..11]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(&"Hello World!"[6..11])` 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 1c12cb8e56d28..66b3e6f9462db 100644 --- a/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr +++ b/src/tools/clippy/tests/ui/string_lit_as_bytes.stderr @@ -1,5 +1,5 @@ error: calling `as_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:16:14 + --> tests/ui/string_lit_as_bytes.rs:16:14 | LL | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` @@ -8,25 +8,25 @@ LL | let bs = "hello there".as_bytes(); = 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 + --> tests/ui/string_lit_as_bytes.rs:18:14 | LL | let bs = r###"raw string with 3# plus " ""###.as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `br###"raw string with 3# plus " ""###` error: calling `into_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:20:14 + --> tests/ui/string_lit_as_bytes.rs:20:14 | LL | let bs = "lit to string".to_string().into_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"lit to string".to_vec()` error: calling `into_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:21:14 + --> tests/ui/string_lit_as_bytes.rs:21:14 | LL | let bs = "lit to owned".to_owned().into_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"lit to owned".to_vec()` error: calling `as_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:11:26 + --> tests/ui/string_lit_as_bytes.rs:11:26 | LL | const B: &[u8] = $b.as_bytes(); | ^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"warning"` @@ -37,13 +37,13 @@ LL | b!("warning"); = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info) error: calling `as_bytes()` on `include_str!(..)` - --> $DIR/string_lit_as_bytes.rs:38:22 + --> tests/ui/string_lit_as_bytes.rs:38:22 | LL | let includestr = include_str!("string_lit_as_bytes.rs").as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `include_bytes!(..)` instead: `include_bytes!("string_lit_as_bytes.rs")` error: calling `as_bytes()` on a string literal - --> $DIR/string_lit_as_bytes.rs:40:13 + --> tests/ui/string_lit_as_bytes.rs:40:13 | LL | let _ = "string with newline\t\n".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"string with newline\t\n"` 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 09c4f02eb062c..4d3ca98e62371 100644 --- a/src/tools/clippy/tests/ui/string_lit_chars_any.stderr +++ b/src/tools/clippy/tests/ui/string_lit_chars_any.stderr @@ -1,5 +1,5 @@ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:18:5 + --> tests/ui/string_lit_chars_any.rs:18:5 | LL | "\\.+*?()|[]{}^$#&-~".chars().any(|x| x == c); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:19:5 + --> tests/ui/string_lit_chars_any.rs:19:5 | LL | r#"\.+*?()|[]{}^$#&-~"#.chars().any(|x| x == c); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:20:5 + --> tests/ui/string_lit_chars_any.rs:20:5 | LL | "\\.+*?()|[]{}^$#&-~".chars().any(|x| c == x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:21:5 + --> tests/ui/string_lit_chars_any.rs:21:5 | LL | r#"\.+*?()|[]{}^$#&-~"#.chars().any(|x| c == x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | matches!(c, '\\' | '.' | '+' | '*' | '?' | '(' | ')' | '|' | '[' | ']' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: usage of `.chars().any(...)` to check if a char matches any from a string literal - --> $DIR/string_lit_chars_any.rs:23:5 + --> tests/ui/string_lit_chars_any.rs:23:5 | LL | "\\.+*?()|[]{}^$#&-~".chars().any(|x| { x == c }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/string_slice.stderr b/src/tools/clippy/tests/ui/string_slice.stderr index e9e773aaf3ae3..7a4596b5f2d25 100644 --- a/src/tools/clippy/tests/ui/string_slice.stderr +++ b/src/tools/clippy/tests/ui/string_slice.stderr @@ -1,5 +1,5 @@ error: indexing into a string may panic if the index is within a UTF-8 character - --> $DIR/string_slice.rs:5:6 + --> tests/ui/string_slice.rs:5:6 | LL | &"Ölkanne"[1..]; | ^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | &"Ölkanne"[1..]; = 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 + --> tests/ui/string_slice.rs:9:6 | LL | &m[2..5]; | ^^^^^^^ error: indexing into a string may panic if the index is within a UTF-8 character - --> $DIR/string_slice.rs:12:6 + --> tests/ui/string_slice.rs:12:6 | LL | &s[0..2]; | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/string_to_string.stderr b/src/tools/clippy/tests/ui/string_to_string.stderr index f1f8e176bc57d..ae80597d1f841 100644 --- a/src/tools/clippy/tests/ui/string_to_string.stderr +++ b/src/tools/clippy/tests/ui/string_to_string.stderr @@ -1,5 +1,5 @@ error: `to_string()` called on a `String` - --> $DIR/string_to_string.rs:6:17 + --> tests/ui/string_to_string.rs:6:17 | LL | let mut v = message.to_string(); | ^^^^^^^^^^^^^^^^^^^ 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 6d8ad3981c04b..8c2a7692659c4 100644 --- a/src/tools/clippy/tests/ui/strlen_on_c_strings.stderr +++ b/src/tools/clippy/tests/ui/strlen_on_c_strings.stderr @@ -1,5 +1,5 @@ error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:13:13 + --> tests/ui/strlen_on_c_strings.rs:13:13 | LL | let _ = unsafe { libc::strlen(cstring.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cstring.as_bytes().len()` @@ -8,37 +8,37 @@ LL | let _ = unsafe { libc::strlen(cstring.as_ptr()) }; = 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 + --> tests/ui/strlen_on_c_strings.rs:17:13 | LL | let _ = unsafe { libc::strlen(cstr.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cstr.to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:19:13 + --> tests/ui/strlen_on_c_strings.rs:19:13 | LL | let _ = unsafe { strlen(cstr.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cstr.to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:22:22 + --> tests/ui/strlen_on_c_strings.rs:22:22 | LL | let _ = unsafe { strlen((*pcstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*pcstr).to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:27:22 + --> tests/ui/strlen_on_c_strings.rs:27:22 | LL | let _ = unsafe { strlen(unsafe_identity(cstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unsafe_identity(cstr).to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:28:13 + --> tests/ui/strlen_on_c_strings.rs:28:13 | LL | let _ = unsafe { strlen(unsafe { unsafe_identity(cstr) }.as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unsafe { unsafe_identity(cstr) }.to_bytes().len()` error: using `libc::strlen` on a `CString` or `CStr` value - --> $DIR/strlen_on_c_strings.rs:31:22 + --> tests/ui/strlen_on_c_strings.rs:31:22 | LL | let _ = unsafe { strlen(f(cstr).as_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `f(cstr).to_bytes().len()` diff --git a/src/tools/clippy/tests/ui/struct_excessive_bools.stderr b/src/tools/clippy/tests/ui/struct_excessive_bools.stderr index 5284949c2d2aa..bdf6f0b7a1dae 100644 --- a/src/tools/clippy/tests/ui/struct_excessive_bools.stderr +++ b/src/tools/clippy/tests/ui/struct_excessive_bools.stderr @@ -1,5 +1,5 @@ error: more than 3 bools in a struct - --> $DIR/struct_excessive_bools.rs:22:1 + --> tests/ui/struct_excessive_bools.rs:22:1 | LL | / struct BadFoo { LL | | @@ -15,7 +15,7 @@ LL | | } = 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 + --> tests/ui/struct_excessive_bools.rs:39:5 | LL | / struct FooFoo { LL | | diff --git a/src/tools/clippy/tests/ui/struct_fields.rs b/src/tools/clippy/tests/ui/struct_fields.rs index 7c9e9d8ed2692..7c8867bd0fa3b 100644 --- a/src/tools/clippy/tests/ui/struct_fields.rs +++ b/src/tools/clippy/tests/ui/struct_fields.rs @@ -224,6 +224,7 @@ mod macro_tests { macro_rules! mk_struct { () => { struct MacroStruct { + //~^ ERROR: all fields have the same prefix: `some` some_a: i32, some_b: i32, some_c: i32, @@ -231,24 +232,24 @@ mod macro_tests { }; } mk_struct!(); - //~^ ERROR: all fields have the same prefix: `some` macro_rules! mk_struct2 { () => { struct Macrobaz { macrobaz_a: i32, + //~^ ERROR: field name starts with the struct's name some_b: i32, some_c: i32, } }; } mk_struct2!(); - //~^ ERROR: field name starts with the struct's name macro_rules! mk_struct_with_names { ($struct_name:ident, $field:ident) => { struct $struct_name { $field: i32, + //~^ ERROR: field name starts with the struct's name other_something: i32, other_field: i32, } @@ -256,7 +257,6 @@ mod macro_tests { } // expands to `struct Foo { foo: i32, ... }` mk_struct_with_names!(Foo, foo); - //~^ ERROR: field name starts with the struct's name // expands to a struct with all fields starting with `other` but should not // be linted because some fields come from the macro definition and the other from the input @@ -289,6 +289,7 @@ mod macro_tests { macro_rules! mk_struct_full_def { ($struct_name:ident, $field1:ident, $field2:ident, $field3:ident) => { struct $struct_name { + //~^ ERROR: all fields have the same prefix: `some` $field1: i32, $field2: i32, $field3: i32, @@ -296,7 +297,6 @@ mod macro_tests { }; } mk_struct_full_def!(PrefixData, some_data, some_meta, some_other); - //~^ ERROR: all fields have the same prefix: `some` } // should not lint on external code diff --git a/src/tools/clippy/tests/ui/struct_fields.stderr b/src/tools/clippy/tests/ui/struct_fields.stderr index d2bdbd17d5cc5..cfda18c708c0f 100644 --- a/src/tools/clippy/tests/ui/struct_fields.stderr +++ b/src/tools/clippy/tests/ui/struct_fields.stderr @@ -1,5 +1,5 @@ error: field name ends with the struct's name - --> $DIR/struct_fields.rs:10:5 + --> tests/ui/struct_fields.rs:10:5 | LL | field_data1: u8, | ^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | field_data1: u8, = help: to override `-D warnings` add `#[allow(clippy::struct_field_names)]` error: field name starts with the struct's name - --> $DIR/struct_fields.rs:20:5 + --> tests/ui/struct_fields.rs:20:5 | LL | data2_field: u8, | ^^^^^^^^^^^^^^^ error: all fields have the same postfix: `data` - --> $DIR/struct_fields.rs:25:1 + --> tests/ui/struct_fields.rs:25:1 | LL | / struct StructData { LL | | @@ -27,7 +27,7 @@ LL | | } = help: remove the postfixes error: all fields have the same prefix: `data` - --> $DIR/struct_fields.rs:32:1 + --> tests/ui/struct_fields.rs:32:1 | LL | / struct DataStruct { LL | | @@ -40,7 +40,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `some_data` - --> $DIR/struct_fields.rs:39:1 + --> tests/ui/struct_fields.rs:39:1 | LL | / struct DoublePrefix { LL | | @@ -53,7 +53,7 @@ LL | | } = help: remove the prefixes error: all fields have the same postfix: `some_data` - --> $DIR/struct_fields.rs:46:1 + --> tests/ui/struct_fields.rs:46:1 | LL | / struct DoublePostfix { LL | | @@ -66,7 +66,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `someData` - --> $DIR/struct_fields.rs:54:1 + --> tests/ui/struct_fields.rs:54:1 | LL | / struct NotSnakeCase { LL | | @@ -79,7 +79,7 @@ LL | | } = help: remove the postfixes error: all fields have the same prefix: `someData` - --> $DIR/struct_fields.rs:61:1 + --> tests/ui/struct_fields.rs:61:1 | LL | / struct NotSnakeCase2 { LL | | @@ -92,7 +92,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `prefix` - --> $DIR/struct_fields.rs:74:1 + --> tests/ui/struct_fields.rs:74:1 | LL | / struct NonCaps { LL | | @@ -105,7 +105,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `_type` - --> $DIR/struct_fields.rs:124:5 + --> tests/ui/struct_fields.rs:124:5 | LL | / struct DoLint { LL | | @@ -119,7 +119,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `__type` - --> $DIR/struct_fields.rs:132:5 + --> tests/ui/struct_fields.rs:132:5 | LL | / struct DoLint2 { LL | | @@ -133,7 +133,7 @@ LL | | } = help: remove the prefixes error: all fields have the same prefix: `___type` - --> $DIR/struct_fields.rs:140:5 + --> tests/ui/struct_fields.rs:140:5 | LL | / struct DoLint3 { LL | | @@ -147,7 +147,7 @@ LL | | } = help: remove the prefixes error: all fields have the same postfix: `_` - --> $DIR/struct_fields.rs:148:5 + --> tests/ui/struct_fields.rs:148:5 | LL | / struct DoLint4 { LL | | @@ -161,7 +161,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `__` - --> $DIR/struct_fields.rs:156:5 + --> tests/ui/struct_fields.rs:156:5 | LL | / struct DoLint5 { LL | | @@ -175,7 +175,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `___` - --> $DIR/struct_fields.rs:164:5 + --> tests/ui/struct_fields.rs:164:5 | LL | / struct DoLint6 { LL | | @@ -189,7 +189,7 @@ LL | | } = help: remove the postfixes error: all fields have the same postfix: `type` - --> $DIR/struct_fields.rs:172:5 + --> tests/ui/struct_fields.rs:172:5 | LL | / struct DoLintToo { LL | | @@ -202,15 +202,16 @@ LL | | } = help: remove the postfixes error: field name starts with the struct's name - --> $DIR/struct_fields.rs:210:5 + --> tests/ui/struct_fields.rs:210:5 | LL | proxy: i32, | ^^^^^^^^^^ error: all fields have the same prefix: `some` - --> $DIR/struct_fields.rs:226:13 + --> tests/ui/struct_fields.rs:226:13 | LL | / struct MacroStruct { +LL | | LL | | some_a: i32, LL | | some_b: i32, LL | | some_c: i32, @@ -224,7 +225,7 @@ LL | mk_struct!(); = note: this error originates in the macro `mk_struct` (in Nightly builds, run with -Z macro-backtrace for more info) error: field name starts with the struct's name - --> $DIR/struct_fields.rs:239:17 + --> tests/ui/struct_fields.rs:239:17 | LL | macrobaz_a: i32, | ^^^^^^^^^^^^^^^ @@ -235,7 +236,7 @@ LL | mk_struct2!(); = note: this error originates in the macro `mk_struct2` (in Nightly builds, run with -Z macro-backtrace for more info) error: field name starts with the struct's name - --> $DIR/struct_fields.rs:251:17 + --> tests/ui/struct_fields.rs:251:17 | LL | $field: i32, | ^^^^^^^^^^^ @@ -246,9 +247,10 @@ LL | mk_struct_with_names!(Foo, foo); = note: this error originates in the macro `mk_struct_with_names` (in Nightly builds, run with -Z macro-backtrace for more info) error: all fields have the same prefix: `some` - --> $DIR/struct_fields.rs:291:13 + --> tests/ui/struct_fields.rs:291:13 | LL | / struct $struct_name { +LL | | LL | | $field1: i32, LL | | $field2: i32, LL | | $field3: i32, @@ -262,19 +264,19 @@ LL | mk_struct_full_def!(PrefixData, some_data, some_meta, some_other); = note: this error originates in the macro `mk_struct_full_def` (in Nightly builds, run with -Z macro-backtrace for more info) error: field name starts with the struct's name - --> $DIR/struct_fields.rs:339:5 + --> tests/ui/struct_fields.rs:339:5 | LL | use_foo: bool, | ^^^^^^^^^^^^^ error: field name starts with the struct's name - --> $DIR/struct_fields.rs:341:5 + --> tests/ui/struct_fields.rs:341:5 | LL | use_bar: bool, | ^^^^^^^^^^^^^ error: field name starts with the struct's name - --> $DIR/struct_fields.rs:342:5 + --> tests/ui/struct_fields.rs:342:5 | LL | use_baz: bool, | ^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr b/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr index 3995c6eb5c4ee..193cd64149b1f 100644 --- a/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr +++ b/src/tools/clippy/tests/ui/suspicious_arithmetic_impl.stderr @@ -1,5 +1,5 @@ error: suspicious use of `-` in `Add` impl - --> $DIR/suspicious_arithmetic_impl.rs:13:20 + --> tests/ui/suspicious_arithmetic_impl.rs:13:20 | LL | Foo(self.0 - other.0) | ^ @@ -8,7 +8,7 @@ LL | Foo(self.0 - other.0) = 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 + --> tests/ui/suspicious_arithmetic_impl.rs:21:23 | LL | *self = *self - other; | ^ @@ -17,43 +17,43 @@ LL | *self = *self - other; = 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 + --> tests/ui/suspicious_arithmetic_impl.rs:36:16 | LL | self.0 /= other.0; | ^^ error: suspicious use of `/` in `Rem` impl - --> $DIR/suspicious_arithmetic_impl.rs:75:20 + --> tests/ui/suspicious_arithmetic_impl.rs:75:20 | LL | Foo(self.0 / other.0) | ^ error: suspicious use of `|` in `BitAnd` impl - --> $DIR/suspicious_arithmetic_impl.rs:84:20 + --> tests/ui/suspicious_arithmetic_impl.rs:84:20 | LL | Foo(self.0 | other.0) | ^ error: suspicious use of `^` in `BitOr` impl - --> $DIR/suspicious_arithmetic_impl.rs:93:20 + --> tests/ui/suspicious_arithmetic_impl.rs:93:20 | LL | Foo(self.0 ^ other.0) | ^ error: suspicious use of `&` in `BitXor` impl - --> $DIR/suspicious_arithmetic_impl.rs:102:20 + --> tests/ui/suspicious_arithmetic_impl.rs:102:20 | LL | Foo(self.0 & other.0) | ^ error: suspicious use of `>>` in `Shl` impl - --> $DIR/suspicious_arithmetic_impl.rs:111:20 + --> tests/ui/suspicious_arithmetic_impl.rs:111:20 | LL | Foo(self.0 >> other.0) | ^^ error: suspicious use of `<<` in `Shr` impl - --> $DIR/suspicious_arithmetic_impl.rs:120:20 + --> tests/ui/suspicious_arithmetic_impl.rs:120:20 | LL | Foo(self.0 << other.0) | ^^ 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 9bf3128cb8e26..d2517b66b5661 100644 --- a/src/tools/clippy/tests/ui/suspicious_command_arg_space.stderr +++ b/src/tools/clippy/tests/ui/suspicious_command_arg_space.stderr @@ -1,5 +1,5 @@ error: single argument that looks like it should be multiple arguments - --> $DIR/suspicious_command_arg_space.rs:3:44 + --> tests/ui/suspicious_command_arg_space.rs:3:44 | LL | std::process::Command::new("echo").arg("-n hello").spawn().unwrap(); | ^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | std::process::Command::new("echo").args(["-n", "hello"]).spawn().unwrap | ~~~~ ~~~~~~~~~~~~~~~ error: single argument that looks like it should be multiple arguments - --> $DIR/suspicious_command_arg_space.rs:6:43 + --> tests/ui/suspicious_command_arg_space.rs:6:43 | LL | std::process::Command::new("cat").arg("--number file").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 1b238f501e13a..b54309b44d5d8 100644 --- a/src/tools/clippy/tests/ui/suspicious_doc_comments.stderr +++ b/src/tools/clippy/tests/ui/suspicious_doc_comments.stderr @@ -1,5 +1,5 @@ error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:5:1 + --> tests/ui/suspicious_doc_comments.rs:5:1 | LL | ///! Fake module documentation. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | //! Fake module documentation. | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:9:5 + --> tests/ui/suspicious_doc_comments.rs:9:5 | LL | ///! This module contains useful functions. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | //! This module contains useful functions. | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:21:5 + --> tests/ui/suspicious_doc_comments.rs:21:5 | LL | / /**! This module contains useful functions. LL | | */ @@ -36,7 +36,7 @@ LL + */ | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:35:5 + --> tests/ui/suspicious_doc_comments.rs:35:5 | LL | / ///! This module LL | | ///! contains @@ -51,7 +51,7 @@ LL ~ //! useful functions. | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:43:5 + --> tests/ui/suspicious_doc_comments.rs:43:5 | LL | / ///! a LL | | ///! b @@ -64,7 +64,7 @@ LL ~ //! b | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:51:5 + --> tests/ui/suspicious_doc_comments.rs:51:5 | LL | ///! a | ^^^^^^ @@ -75,7 +75,7 @@ LL | //! a | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:57:5 + --> tests/ui/suspicious_doc_comments.rs:57:5 | LL | / ///! a LL | | @@ -90,7 +90,7 @@ LL ~ //! b | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:69:5 + --> tests/ui/suspicious_doc_comments.rs:69:5 | LL | ///! Very cool macro | ^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ LL | //! Very cool macro | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments.rs:76:5 + --> tests/ui/suspicious_doc_comments.rs:76:5 | LL | ///! Huh. | ^^^^^^^^^ 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 ae92c334f6092..d15f16f7c5032 100644 --- a/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr +++ b/src/tools/clippy/tests/ui/suspicious_doc_comments_unfixable.stderr @@ -1,5 +1,5 @@ error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments_unfixable.rs:4:1 + --> tests/ui/suspicious_doc_comments_unfixable.rs:4:1 | LL | / ///! a LL | | @@ -22,7 +22,7 @@ LL + //! d | error: this is an outer doc comment and does not apply to the parent module or crate - --> $DIR/suspicious_doc_comments_unfixable.rs:12:1 + --> tests/ui/suspicious_doc_comments_unfixable.rs:12:1 | LL | / ///! a LL | | diff --git a/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr b/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr index 95047cb95ee13..28c5a2d904ce2 100644 --- a/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr +++ b/src/tools/clippy/tests/ui/suspicious_else_formatting.stderr @@ -1,5 +1,5 @@ error: this looks like an `else {..}` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:22:6 + --> tests/ui/suspicious_else_formatting.rs:22:6 | LL | } { | ^ @@ -9,7 +9,7 @@ LL | } { = 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 + --> tests/ui/suspicious_else_formatting.rs:26:6 | LL | } if foo() { | ^ @@ -17,7 +17,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:33:10 + --> tests/ui/suspicious_else_formatting.rs:33:10 | LL | } if foo() { | ^ @@ -25,7 +25,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/suspicious_else_formatting.rs:41:10 + --> tests/ui/suspicious_else_formatting.rs:41:10 | LL | } if foo() { | ^ @@ -33,7 +33,7 @@ LL | } if foo() { = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this is an `else {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:50:6 + --> tests/ui/suspicious_else_formatting.rs:50:6 | LL | } else | ______^ @@ -43,7 +43,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else if` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:62:6 + --> tests/ui/suspicious_else_formatting.rs:62:6 | LL | } else | ______^ @@ -53,7 +53,7 @@ LL | | if foo() { // the span of the above error should continue here = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else if` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:67:6 + --> tests/ui/suspicious_else_formatting.rs:67:6 | LL | } | ______^ @@ -64,7 +64,7 @@ LL | | if foo() { // the span of the above error should continue here = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:94:6 + --> tests/ui/suspicious_else_formatting.rs:94:6 | LL | } | ______^ @@ -76,7 +76,7 @@ LL | | { = note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` error: this is an `else {..}` but the formatting might hide it - --> $DIR/suspicious_else_formatting.rs:102:6 + --> tests/ui/suspicious_else_formatting.rs:102:6 | LL | } | ______^ diff --git a/src/tools/clippy/tests/ui/suspicious_map.stderr b/src/tools/clippy/tests/ui/suspicious_map.stderr index 9c065e05ca6f6..2a5e2bf2a3467 100644 --- a/src/tools/clippy/tests/ui/suspicious_map.stderr +++ b/src/tools/clippy/tests/ui/suspicious_map.stderr @@ -1,5 +1,5 @@ error: this call to `map()` won't have an effect on the call to `count()` - --> $DIR/suspicious_map.rs:4:13 + --> tests/ui/suspicious_map.rs:4:13 | LL | let _ = (0..3).map(|x| x + 2).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = (0..3).map(|x| x + 2).count(); = 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 + --> tests/ui/suspicious_map.rs:8:13 | LL | let _ = (0..3).map(f).count(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr b/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr index 0784da06e5f58..9d1d8a1f34f55 100644 --- a/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr +++ b/src/tools/clippy/tests/ui/suspicious_operation_groupings.stderr @@ -1,5 +1,5 @@ error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:15:9 + --> tests/ui/suspicious_operation_groupings.rs:15:9 | LL | self.x == other.y && self.y == other.y && self.z == other.z | ^^^^^^^^^^^^^^^^^ help: did you mean: `self.x == other.x` @@ -8,151 +8,151 @@ LL | self.x == other.y && self.y == other.y && self.z == other.z = 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 + --> tests/ui/suspicious_operation_groupings.rs:28:20 | LL | s1.a < s2.a && s1.a < s2.b | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:76:33 + --> tests/ui/suspicious_operation_groupings.rs:76:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:81:19 + --> tests/ui/suspicious_operation_groupings.rs:81:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:81:19 + --> tests/ui/suspicious_operation_groupings.rs:81:19 | LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:86:19 + --> tests/ui/suspicious_operation_groupings.rs:86:19 | LL | s1.a * s2.a + s2.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:91:19 + --> tests/ui/suspicious_operation_groupings.rs:91:19 | LL | s1.a * s2.a + s1.b * s1.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:96:5 + --> tests/ui/suspicious_operation_groupings.rs:96:5 | LL | s1.a * s1.a + s1.b * s2.b + s1.c * s2.c | ^^^^^^^^^^^ help: did you mean: `s1.a * s2.a` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:101:33 + --> tests/ui/suspicious_operation_groupings.rs:101:33 | LL | s1.a * s2.a + s1.b * s2.b + s1.c * s1.c | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:114:20 + --> tests/ui/suspicious_operation_groupings.rs:114:20 | LL | (s1.a * s2.a + s1.b * s1.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:119:34 + --> tests/ui/suspicious_operation_groupings.rs:119:34 | LL | (s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:124:38 + --> tests/ui/suspicious_operation_groupings.rs:124:38 | LL | (s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:129:39 + --> tests/ui/suspicious_operation_groupings.rs:129:39 | LL | ((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:134:42 + --> tests/ui/suspicious_operation_groupings.rs:134:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:134:42 + --> tests/ui/suspicious_operation_groupings.rs:134:42 | LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:139:40 + --> tests/ui/suspicious_operation_groupings.rs:139:40 | LL | (((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b)) + (s1.d * s2.d)) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:144:40 + --> tests/ui/suspicious_operation_groupings.rs:144:40 | LL | ((s1.a * s2.a) + ((s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d))) | ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:149:20 + --> tests/ui/suspicious_operation_groupings.rs:149:20 | LL | (s1.a * s2.a + s2.b * s2.b) / 2 | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:154:35 + --> tests/ui/suspicious_operation_groupings.rs:154:35 | LL | i32::swap_bytes(s1.a * s2.a + s2.b * s2.b) | ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:159:29 + --> tests/ui/suspicious_operation_groupings.rs:159:29 | LL | s1.a > 0 && s1.b > 0 && s1.d == s2.c && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:164:17 + --> tests/ui/suspicious_operation_groupings.rs:164:17 | LL | s1.a > 0 && s1.d == s2.c && s1.b > 0 && s1.d == s2.d | ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:173:77 + --> tests/ui/suspicious_operation_groupings.rs:173:77 | LL | (n1.inner.0).0 == (n2.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.1).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `(n1.inner.2).0 == (n2.inner.2).0` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:187:25 + --> tests/ui/suspicious_operation_groupings.rs:187:25 | LL | s1.a <= s2.a && s1.a <= s2.b | ^^^^^^^^^^^^ help: did you mean: `s1.b <= s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:193:23 + --> tests/ui/suspicious_operation_groupings.rs:193:23 | LL | if s1.a < s2.a && s1.a < s2.b { | ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:200:48 + --> tests/ui/suspicious_operation_groupings.rs:200:48 | LL | -(-(-s1.a * -s2.a) + (-(-s1.b * -s2.b) + -(-s1.c * -s2.b) + -(-s1.d * -s2.d))) | ^^^^^^^^^^^^^ help: did you mean: `-s1.c * -s2.c` error: this sequence of operators looks suspiciously like a bug - --> $DIR/suspicious_operation_groupings.rs:205:27 + --> tests/ui/suspicious_operation_groupings.rs:205:27 | LL | -(if -s1.a < -s2.a && -s1.a < -s2.b { s1.c } else { s2.a }) | ^^^^^^^^^^^^^ help: did you mean: `-s1.b < -s2.b` diff --git a/src/tools/clippy/tests/ui/suspicious_splitn.stderr b/src/tools/clippy/tests/ui/suspicious_splitn.stderr index 4513beac8b2de..6e05bc28d130e 100644 --- a/src/tools/clippy/tests/ui/suspicious_splitn.stderr +++ b/src/tools/clippy/tests/ui/suspicious_splitn.stderr @@ -1,5 +1,5 @@ error: `splitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:10:13 + --> tests/ui/suspicious_splitn.rs:10:13 | LL | let _ = "a,b".splitn(0, ','); | ^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = "a,b".splitn(0, ','); = help: to override `-D warnings` add `#[allow(clippy::suspicious_splitn)]` error: `rsplitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:13:13 + --> tests/ui/suspicious_splitn.rs:13:13 | LL | let _ = "a,b".rsplitn(0, ','); | ^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = "a,b".rsplitn(0, ','); = note: the resulting iterator will always return `None` error: `splitn` called with `1` split - --> $DIR/suspicious_splitn.rs:16:13 + --> tests/ui/suspicious_splitn.rs:16:13 | LL | let _ = "a,b".splitn(1, ','); | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = "a,b".splitn(1, ','); = note: the resulting iterator will always return the entire string followed by `None` error: `splitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:19:13 + --> tests/ui/suspicious_splitn.rs:19:13 | LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); = note: the resulting iterator will always return `None` error: `splitn_mut` called with `0` splits - --> $DIR/suspicious_splitn.rs:22:13 + --> tests/ui/suspicious_splitn.rs:22:13 | LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); = note: the resulting iterator will always return `None` error: `splitn` called with `1` split - --> $DIR/suspicious_splitn.rs:25:13 + --> tests/ui/suspicious_splitn.rs:25:13 | LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); = note: the resulting iterator will always return the entire slice followed by `None` error: `rsplitn_mut` called with `1` split - --> $DIR/suspicious_splitn.rs:28:13 + --> tests/ui/suspicious_splitn.rs:28:13 | LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); = note: the resulting iterator will always return the entire slice followed by `None` error: `splitn` called with `1` split - --> $DIR/suspicious_splitn.rs:33:13 + --> tests/ui/suspicious_splitn.rs:33:13 | LL | let _ = "a,b".splitn(X + 1, ','); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = "a,b".splitn(X + 1, ','); = note: the resulting iterator will always return the entire string followed by `None` error: `splitn` called with `0` splits - --> $DIR/suspicious_splitn.rs:36:13 + --> tests/ui/suspicious_splitn.rs:36:13 | LL | let _ = "a,b".splitn(X, ','); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/suspicious_to_owned.stderr b/src/tools/clippy/tests/ui/suspicious_to_owned.stderr index eb967a714d949..255f211e65509 100644 --- a/src/tools/clippy/tests/ui/suspicious_to_owned.stderr +++ b/src/tools/clippy/tests/ui/suspicious_to_owned.stderr @@ -1,5 +1,5 @@ error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned - --> $DIR/suspicious_to_owned.rs:17:13 + --> tests/ui/suspicious_to_owned.rs:17:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, [char; 3]> itself and does not cause the Cow<'_, [char; 3]> contents to become owned - --> $DIR/suspicious_to_owned.rs:29:13 + --> tests/ui/suspicious_to_owned.rs:29:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, Vec> itself and does not cause the Cow<'_, Vec> contents to become owned - --> $DIR/suspicious_to_owned.rs:40:13 + --> tests/ui/suspicious_to_owned.rs:40:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned - --> $DIR/suspicious_to_owned.rs:51:13 + --> tests/ui/suspicious_to_owned.rs:51:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type - --> $DIR/suspicious_to_owned.rs:66:13 + --> tests/ui/suspicious_to_owned.rs:66:13 | LL | let _ = String::from(moo).to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::from(moo).clone()` @@ -70,7 +70,7 @@ LL | let _ = String::from(moo).to_owned(); = 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 + --> tests/ui/suspicious_to_owned.rs:69:13 | LL | let _ = moos_vec.to_owned(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `moos_vec.clone()` 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 3cddde4eca7b9..379fb17266a96 100644 --- a/src/tools/clippy/tests/ui/suspicious_unary_op_formatting.stderr +++ b/src/tools/clippy/tests/ui/suspicious_unary_op_formatting.stderr @@ -1,5 +1,5 @@ error: by not having a space between `>` and `-` it looks like `>-` is a single operator - --> $DIR/suspicious_unary_op_formatting.rs:9:9 + --> tests/ui/suspicious_unary_op_formatting.rs:9:9 | LL | if a >- 30 {} | ^^^^ @@ -9,7 +9,7 @@ LL | if a >- 30 {} = 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 + --> tests/ui/suspicious_unary_op_formatting.rs:11:9 | LL | if a >=- 30 {} | ^^^^^ @@ -17,7 +17,7 @@ LL | if a >=- 30 {} = help: put a space between `>=` and `-` and remove the space after `-` error: by not having a space between `&&` and `!` it looks like `&&!` is a single operator - --> $DIR/suspicious_unary_op_formatting.rs:17:9 + --> tests/ui/suspicious_unary_op_formatting.rs:17:9 | LL | if b &&! c {} | ^^^^^ @@ -25,7 +25,7 @@ LL | if b &&! c {} = help: put a space between `&&` and `!` and remove the space after `!` error: by not having a space between `>` and `-` it looks like `>-` is a single operator - --> $DIR/suspicious_unary_op_formatting.rs:20:9 + --> tests/ui/suspicious_unary_op_formatting.rs:20:9 | LL | if a >- 30 {} | ^^^^^^ 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 29e9fa771019e..4faf0237c17ad 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 @@ -1,5 +1,5 @@ error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:19:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:19:13 | LL | let _ = 2 ^ 5; | ^^^^^ help: did you mean to write: `2.pow(5)` @@ -8,37 +8,37 @@ LL | let _ = 2 ^ 5; = 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 + --> tests/ui/suspicious_xor_used_as_pow.rs:22:13 | LL | let _ = 2i32 ^ 9i32; | ^^^^^^^^^^^ help: did you mean to write: `2i32.pow(9i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:24:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:24:13 | LL | let _ = 2i32 ^ 2i32; | ^^^^^^^^^^^ help: did you mean to write: `2i32.pow(2i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:26:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:26:13 | LL | let _ = 50i32 ^ 3i32; | ^^^^^^^^^^^^ help: did you mean to write: `50i32.pow(3i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:28:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:28:13 | LL | let _ = 5i32 ^ 8i32; | ^^^^^^^^^^^ help: did you mean to write: `5i32.pow(8i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:30:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:30:13 | LL | let _ = 2i32 ^ 32i32; | ^^^^^^^^^^^^ help: did you mean to write: `2i32.pow(32i32)` error: `^` is not the exponentiation operator - --> $DIR/suspicious_xor_used_as_pow.rs:13:9 + --> tests/ui/suspicious_xor_used_as_pow.rs:13:9 | LL | 1 ^ 2 // should warn even if inside macro | ^^^^^ help: did you mean to write: `1.pow(2)` diff --git a/src/tools/clippy/tests/ui/swap.stderr b/src/tools/clippy/tests/ui/swap.stderr index e69ad02b08fe1..fad356782479b 100644 --- a/src/tools/clippy/tests/ui/swap.stderr +++ b/src/tools/clippy/tests/ui/swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are swapping `bar.a` and `bar.b` manually - --> $DIR/swap.rs:28:5 + --> tests/ui/swap.rs:28:5 | LL | / let temp = bar.a; LL | | bar.a = bar.b; @@ -11,7 +11,7 @@ LL | | bar.b = temp; = 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 + --> tests/ui/swap.rs:40:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -19,7 +19,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:49:5 + --> tests/ui/swap.rs:49:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -27,7 +27,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:68:5 + --> tests/ui/swap.rs:68:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -35,7 +35,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:79:5 + --> tests/ui/swap.rs:79:5 | LL | / a ^= b; LL | | b ^= a; @@ -43,7 +43,7 @@ LL | | a ^= b; | |___________^ help: try: `std::mem::swap(&mut a, &mut b);` error: this looks like you are swapping `bar.a` and `bar.b` manually - --> $DIR/swap.rs:87:5 + --> tests/ui/swap.rs:87:5 | LL | / bar.a ^= bar.b; LL | | bar.b ^= bar.a; @@ -51,7 +51,7 @@ LL | | bar.a ^= bar.b; | |___________________^ help: try: `std::mem::swap(&mut bar.a, &mut bar.b);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:95:5 + --> tests/ui/swap.rs:95:5 | LL | / foo[0] ^= foo[1]; LL | | foo[1] ^= foo[0]; @@ -59,7 +59,7 @@ LL | | foo[0] ^= foo[1]; | |_____________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping `foo[0][1]` and `bar[1][0]` manually - --> $DIR/swap.rs:124:5 + --> tests/ui/swap.rs:124:5 | LL | / let temp = foo[0][1]; LL | | foo[0][1] = bar[1][0]; @@ -69,7 +69,7 @@ LL | | bar[1][0] = temp; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:138:7 + --> tests/ui/swap.rs:138:7 | LL | ; let t = a; | _______^ @@ -80,7 +80,7 @@ LL | | b = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:147:7 + --> tests/ui/swap.rs:147:7 | LL | ; let t = c.0; | _______^ @@ -91,7 +91,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `b` and `a` manually - --> $DIR/swap.rs:173:5 + --> tests/ui/swap.rs:173:5 | LL | / let t = b; LL | | b = a; @@ -101,7 +101,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:135:5 + --> tests/ui/swap.rs:135:5 | LL | / a = b; LL | | b = a; @@ -112,7 +112,7 @@ LL | | b = a; = 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 + --> tests/ui/swap.rs:144:5 | LL | / c.0 = a; LL | | a = c.0; @@ -121,7 +121,7 @@ LL | | a = c.0; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:151:5 + --> tests/ui/swap.rs:151:5 | LL | / let a = b; LL | | let b = a; @@ -130,7 +130,7 @@ LL | | let b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `d` and `c` - --> $DIR/swap.rs:156:5 + --> tests/ui/swap.rs:156:5 | LL | / d = c; LL | | c = d; @@ -139,7 +139,7 @@ LL | | c = d; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:160:5 + --> tests/ui/swap.rs:160:5 | LL | / let a = b; LL | | b = a; @@ -148,7 +148,7 @@ LL | | b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `s.0.x` and `s.0.y` manually - --> $DIR/swap.rs:208:5 + --> tests/ui/swap.rs:208:5 | LL | / let t = s.0.x; LL | | s.0.x = s.0.y; 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 42455f4926e89..019c2f91f0e9e 100644 --- a/src/tools/clippy/tests/ui/swap_ptr_to_ref.stderr +++ b/src/tools/clippy/tests/ui/swap_ptr_to_ref.stderr @@ -1,5 +1,5 @@ error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref.rs:11:9 + --> tests/ui/swap_ptr_to_ref.rs:11:9 | LL | core::mem::swap(&mut *y, &mut *z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(y, z)` @@ -8,19 +8,19 @@ LL | core::mem::swap(&mut *y, &mut *z); = 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 + --> tests/ui/swap_ptr_to_ref.rs:12:9 | LL | core::mem::swap(&mut *y, &mut x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(y, &mut x)` error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref.rs:13:9 + --> tests/ui/swap_ptr_to_ref.rs:13:9 | LL | core::mem::swap(&mut x, &mut *y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(&mut x, y)` error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref.rs:14:9 + --> tests/ui/swap_ptr_to_ref.rs:14:9 | LL | core::mem::swap(&mut *addr_of_mut!(x), &mut *addr_of_mut!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use ptr::swap: `core::ptr::swap(addr_of_mut!(x), addr_of_mut!(x))` 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 ce1d7814250a7..8a0352049483e 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 @@ -1,5 +1,5 @@ error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref_unfixable.rs:14:9 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:14:9 | LL | core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); = 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 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:17:9 | LL | core::mem::swap(&mut *y, addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> $DIR/swap_ptr_to_ref_unfixable.rs:19:9 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:19:9 | LL | core::mem::swap(addr_of_mut_to_ref!(x), addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 69ce214ae565b..23d5dcd3a8dab 100644 --- a/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr +++ b/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr @@ -1,5 +1,5 @@ error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:10:9 + --> tests/ui/tabs_in_doc_comments.rs:10:9 | LL | /// - First String: | ^^^^ help: consider using four spaces per tab @@ -8,43 +8,43 @@ LL | /// - First String: = 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 + --> tests/ui/tabs_in_doc_comments.rs:11:9 | LL | /// - needs to be inside here | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:14:9 + --> tests/ui/tabs_in_doc_comments.rs:14:9 | LL | /// - Second String: | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:15:9 + --> tests/ui/tabs_in_doc_comments.rs:15:9 | LL | /// - needs to be inside here | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:6:5 + --> tests/ui/tabs_in_doc_comments.rs:6:5 | LL | /// - first one | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:6:13 + --> tests/ui/tabs_in_doc_comments.rs:6:13 | LL | /// - first one | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:7:5 + --> tests/ui/tabs_in_doc_comments.rs:7:5 | LL | /// - second one | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> $DIR/tabs_in_doc_comments.rs:7:14 + --> tests/ui/tabs_in_doc_comments.rs:7:14 | LL | /// - second one | ^^^^ help: consider using four spaces per tab diff --git a/src/tools/clippy/tests/ui/temporary_assignment.stderr b/src/tools/clippy/tests/ui/temporary_assignment.stderr index cbb8924187c44..8c28459407572 100644 --- a/src/tools/clippy/tests/ui/temporary_assignment.stderr +++ b/src/tools/clippy/tests/ui/temporary_assignment.stderr @@ -1,5 +1,5 @@ error: assignment to temporary - --> $DIR/temporary_assignment.rs:48:5 + --> tests/ui/temporary_assignment.rs:48:5 | LL | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | Struct { field: 0 }.field = 1; = help: to override `-D warnings` add `#[allow(clippy::temporary_assignment)]` error: assignment to temporary - --> $DIR/temporary_assignment.rs:51:5 + --> tests/ui/temporary_assignment.rs:51:5 | LL | / MultiStruct { LL | | @@ -19,13 +19,13 @@ LL | | .field = 1; | |______________^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:57:5 + --> tests/ui/temporary_assignment.rs:57:5 | LL | ArrayStruct { array: [0] }.array[0] = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: assignment to temporary - --> $DIR/temporary_assignment.rs:59:5 + --> tests/ui/temporary_assignment.rs:59:5 | LL | (0, 0).0 = 1; | ^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/test_attr_in_doctest.stderr b/src/tools/clippy/tests/ui/test_attr_in_doctest.stderr index 605259f3bfb4c..f950455f2908d 100644 --- a/src/tools/clippy/tests/ui/test_attr_in_doctest.stderr +++ b/src/tools/clippy/tests/ui/test_attr_in_doctest.stderr @@ -1,5 +1,5 @@ error: unit tests in doctest are not executed - --> $DIR/test_attr_in_doctest.rs:6:5 + --> tests/ui/test_attr_in_doctest.rs:6:5 | LL | /// #[test] | _____^ @@ -10,7 +10,7 @@ LL | | /// fn should_be_linted() { = help: to override `-D warnings` add `#[allow(clippy::test_attr_in_doctest)]` error: unit tests in doctest are not executed - --> $DIR/test_attr_in_doctest.rs:16:5 + --> tests/ui/test_attr_in_doctest.rs:16:5 | LL | /// #[test] | _____^ @@ -18,7 +18,7 @@ LL | | /// fn should_also_be_linted() { | |____________________________^ error: unit tests in doctest are not executed - --> $DIR/test_attr_in_doctest.rs:22:5 + --> tests/ui/test_attr_in_doctest.rs:22:5 | LL | /// #[test] | _____^ 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 ec0cdea83d657..09feae6bf2aa7 100644 --- a/src/tools/clippy/tests/ui/tests_outside_test_module.stderr +++ b/src/tools/clippy/tests/ui/tests_outside_test_module.stderr @@ -1,5 +1,5 @@ error: this function marked with #[test] is outside a #[cfg(test)] module - --> $DIR/tests_outside_test_module.rs:10:1 + --> tests/ui/tests_outside_test_module.rs:10:1 | LL | fn my_test() {} | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/thread_local_initializer_can_be_made_const.stderr b/src/tools/clippy/tests/ui/thread_local_initializer_can_be_made_const.stderr index b35bd306b5230..9ee52fbbb319e 100644 --- a/src/tools/clippy/tests/ui/thread_local_initializer_can_be_made_const.stderr +++ b/src/tools/clippy/tests/ui/thread_local_initializer_can_be_made_const.stderr @@ -1,5 +1,5 @@ error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:8:41 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:8:41 | LL | static BUF_1: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` @@ -8,19 +8,19 @@ LL | static BUF_1: RefCell = RefCell::new(String::new()); = help: to override `-D warnings` add `#[allow(clippy::thread_local_initializer_can_be_made_const)]` error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:18:29 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:18:29 | LL | static SIMPLE:i32 = 1; | ^ help: replace with: `const { 1 }` error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:24:59 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:24:59 | LL | static BUF_3_CAN_BE_MADE_CONST: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` error: initializer for `thread_local` value can be made `const` - --> $DIR/thread_local_initializer_can_be_made_const.rs:26:59 + --> tests/ui/thread_local_initializer_can_be_made_const.rs:26:59 | LL | static BUF_4_CAN_BE_MADE_CONST: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` 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 5067ad7fb6dff..e44106b2e188b 100644 --- a/src/tools/clippy/tests/ui/to_digit_is_some.stderr +++ b/src/tools/clippy/tests/ui/to_digit_is_some.stderr @@ -1,5 +1,5 @@ error: use of `.to_digit(..).is_some()` - --> $DIR/to_digit_is_some.rs:7:13 + --> tests/ui/to_digit_is_some.rs:7:13 | LL | let _ = d.to_digit(8).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d.is_digit(8)` @@ -8,7 +8,7 @@ LL | let _ = d.to_digit(8).is_some(); = 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 + --> tests/ui/to_digit_is_some.rs:8:13 | LL | let _ = char::to_digit(c, 8).is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `char::is_digit(c, 8)` diff --git a/src/tools/clippy/tests/ui/to_string_in_format_args_incremental.fixed b/src/tools/clippy/tests/ui/to_string_in_format_args_incremental.fixed deleted file mode 100644 index 1f78957963663..0000000000000 --- a/src/tools/clippy/tests/ui/to_string_in_format_args_incremental.fixed +++ /dev/null @@ -1,8 +0,0 @@ -//@compile-flags: -C incremental=target/debug/test/incr - -// see https://github.com/rust-lang/rust-clippy/issues/10969 - -fn main() { - let s = "Hello, world!"; - println!("{}", s); -} diff --git a/src/tools/clippy/tests/ui/to_string_trait_impl.rs b/src/tools/clippy/tests/ui/to_string_trait_impl.rs index b0731632d4504..4c1202d420341 100644 --- a/src/tools/clippy/tests/ui/to_string_trait_impl.rs +++ b/src/tools/clippy/tests/ui/to_string_trait_impl.rs @@ -1,4 +1,5 @@ #![warn(clippy::to_string_trait_impl)] +#![feature(min_specialization)] use std::fmt::{self, Display}; @@ -29,3 +30,46 @@ impl Bar { String::from("Bar") } } + +mod issue12263 { + pub struct MyStringWrapper<'a>(&'a str); + + impl std::fmt::Display for MyStringWrapper<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } + } + + impl ToString for MyStringWrapper<'_> { + fn to_string(&self) -> String { + self.0.to_string() + } + } + + pub struct S(T); + impl std::fmt::Display for S { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + // no specialization if the generics differ, so lint + impl ToString for S { + fn to_string(&self) -> String { + todo!() + } + } + + pub struct S2(T); + impl std::fmt::Display for S2 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + todo!() + } + } + + // also specialization if the generics don't differ + impl ToString for S2 { + fn to_string(&self) -> String { + todo!() + } + } +} diff --git a/src/tools/clippy/tests/ui/to_string_trait_impl.stderr b/src/tools/clippy/tests/ui/to_string_trait_impl.stderr index 55fa9f12c0e65..304c9a5e1fb71 100644 --- a/src/tools/clippy/tests/ui/to_string_trait_impl.stderr +++ b/src/tools/clippy/tests/ui/to_string_trait_impl.stderr @@ -1,5 +1,5 @@ error: direct implementation of `ToString` - --> $DIR/to_string_trait_impl.rs:10:1 + --> tests/ui/to_string_trait_impl.rs:11:1 | LL | / impl ToString for Point { LL | | fn to_string(&self) -> String { @@ -12,5 +12,17 @@ LL | | } = note: `-D clippy::to-string-trait-impl` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::to_string_trait_impl)]` -error: aborting due to 1 previous error +error: direct implementation of `ToString` + --> tests/ui/to_string_trait_impl.rs:56:5 + | +LL | / impl ToString for S { +LL | | fn to_string(&self) -> String { +LL | | todo!() +LL | | } +LL | | } + | |_____^ + | + = help: prefer implementing `Display` instead + +error: aborting due to 2 previous errors diff --git a/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr b/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr index 2c27a3c8e9189..61f0fd4a6cd20 100644 --- a/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr +++ b/src/tools/clippy/tests/ui/toplevel_ref_arg.stderr @@ -1,5 +1,5 @@ error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:14:9 + --> tests/ui/toplevel_ref_arg.rs:14:9 | LL | let ref _x = 1; | ----^^^^^^----- help: try: `let _x = &1;` @@ -8,31 +8,31 @@ LL | let ref _x = 1; = 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 + --> tests/ui/toplevel_ref_arg.rs:16:9 | LL | let ref _y: (&_, u8) = (&1, 2); | ----^^^^^^--------------------- help: try: `let _y: &(&_, u8) = &(&1, 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:18:9 + --> tests/ui/toplevel_ref_arg.rs:18:9 | LL | let ref _z = 1 + 2; | ----^^^^^^--------- help: try: `let _z = &(1 + 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:20:9 + --> tests/ui/toplevel_ref_arg.rs:20:9 | LL | let ref mut _z = 1 + 2; | ----^^^^^^^^^^--------- help: try: `let _z = &mut (1 + 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:25:9 + --> tests/ui/toplevel_ref_arg.rs:25:9 | LL | let ref _x = vec![1, 2, 3]; | ----^^^^^^----------------- help: try: `let _x = &vec![1, 2, 3];` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:35:17 + --> tests/ui/toplevel_ref_arg.rs:35:17 | LL | inline!(let ref _y = 42;); | ----^^^^^^------ help: try: `let _y = &42;` 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 45123dd5ec0bd..fb8fb1a009012 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 @@ -1,5 +1,5 @@ error: `ref` directly on a function argument is ignored. Consider using a reference type instead - --> $DIR/toplevel_ref_arg_non_rustfix.rs:9:15 + --> tests/ui/toplevel_ref_arg_non_rustfix.rs:9:15 | LL | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn the_answer(ref mut x: u8) { = 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 + --> tests/ui/toplevel_ref_arg_non_rustfix.rs:20:24 | LL | fn fun_example(ref _x: usize) {} | ^^^^^^ diff --git a/src/tools/clippy/tests/ui/track-diagnostics.stderr b/src/tools/clippy/tests/ui/track-diagnostics.stderr index 131adfd588c25..410e80f25280a 100644 --- a/src/tools/clippy/tests/ui/track-diagnostics.stderr +++ b/src/tools/clippy/tests/ui/track-diagnostics.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:LL:CC + --> tests/ui/track-diagnostics.rs:LL:CC | LL | const S: A = B; | ^ expected `A`, found `B` diff --git a/src/tools/clippy/tests/ui/trailing_empty_array.stderr b/src/tools/clippy/tests/ui/trailing_empty_array.stderr index ef7fc24c374fa..756381478f2b7 100644 --- a/src/tools/clippy/tests/ui/trailing_empty_array.stderr +++ b/src/tools/clippy/tests/ui/trailing_empty_array.stderr @@ -1,5 +1,5 @@ error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:5:1 + --> tests/ui/trailing_empty_array.rs:5:1 | LL | / struct RarelyUseful { LL | | @@ -13,7 +13,7 @@ LL | | } = 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 + --> tests/ui/trailing_empty_array.rs:11:1 | LL | / struct OnlyField { LL | | @@ -24,7 +24,7 @@ LL | | } = help: consider annotating `OnlyField` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:16:1 + --> tests/ui/trailing_empty_array.rs:16:1 | LL | / struct GenericArrayType { LL | | @@ -36,7 +36,7 @@ LL | | } = help: consider annotating `GenericArrayType` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:23:1 + --> tests/ui/trailing_empty_array.rs:23:1 | LL | / struct OnlyAnotherAttribute { LL | | @@ -48,7 +48,7 @@ LL | | } = help: consider annotating `OnlyAnotherAttribute` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:30:1 + --> tests/ui/trailing_empty_array.rs:30:1 | LL | / struct OnlyADeriveAttribute { LL | | @@ -60,7 +60,7 @@ LL | | } = help: consider annotating `OnlyADeriveAttribute` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:37:1 + --> tests/ui/trailing_empty_array.rs:37:1 | LL | / struct ZeroSizedWithConst { LL | | @@ -72,7 +72,7 @@ LL | | } = help: consider annotating `ZeroSizedWithConst` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:47:1 + --> tests/ui/trailing_empty_array.rs:47:1 | LL | / struct ZeroSizedWithConstFunction { LL | | @@ -84,7 +84,7 @@ LL | | } = help: consider annotating `ZeroSizedWithConstFunction` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:56:1 + --> tests/ui/trailing_empty_array.rs:56:1 | LL | / struct ZeroSizedWithConstFunction2 { LL | | @@ -96,7 +96,7 @@ LL | | } = help: consider annotating `ZeroSizedWithConstFunction2` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:62:1 + --> tests/ui/trailing_empty_array.rs:62:1 | LL | struct ZeroSizedArrayWrapper([usize; 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | struct ZeroSizedArrayWrapper([usize; 0]); = help: consider annotating `ZeroSizedArrayWrapper` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:65:1 + --> tests/ui/trailing_empty_array.rs:65:1 | LL | struct TupleStruct(i32, [usize; 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | struct TupleStruct(i32, [usize; 0]); = help: consider annotating `TupleStruct` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> $DIR/trailing_empty_array.rs:68:1 + --> tests/ui/trailing_empty_array.rs:68:1 | LL | / struct LotsOfFields { LL | | diff --git a/src/tools/clippy/tests/ui/trailing_zeros.stderr b/src/tools/clippy/tests/ui/trailing_zeros.stderr index 10924ad124712..6f3e7aa1d762e 100644 --- a/src/tools/clippy/tests/ui/trailing_zeros.stderr +++ b/src/tools/clippy/tests/ui/trailing_zeros.stderr @@ -1,5 +1,5 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:6:13 + --> tests/ui/trailing_zeros.rs:6:13 | LL | let _ = (x & 0b1111 == 0); | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` @@ -8,7 +8,7 @@ LL | let _ = (x & 0b1111 == 0); = 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 + --> tests/ui/trailing_zeros.rs:9:13 | LL | let _ = x & 0b1_1111 == 0; | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` diff --git a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr index 61a45538b65c1..78861fc16e817 100644 --- a/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr +++ b/src/tools/clippy/tests/ui/trait_duplication_in_bounds.stderr @@ -1,59 +1,59 @@ error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:6:15 + --> tests/ui/trait_duplication_in_bounds.rs:6:15 | LL | fn bad_foo(arg0: T, argo1: U) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` | note: the lint level is defined here - --> $DIR/trait_duplication_in_bounds.rs:1:9 + --> tests/ui/trait_duplication_in_bounds.rs:1:9 | LL | #![deny(clippy::trait_duplication_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: these where clauses contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:12:8 + --> tests/ui/trait_duplication_in_bounds.rs:12:8 | LL | T: Clone + Clone + Clone + Copy, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:40:26 + --> tests/ui/trait_duplication_in_bounds.rs:40:26 | LL | trait BadSelfTraitBound: Clone + Clone + Clone { | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone` error: these where clauses contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:47:15 + --> tests/ui/trait_duplication_in_bounds.rs:47:15 | LL | Self: Clone + Clone + Clone; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:61:24 + --> tests/ui/trait_duplication_in_bounds.rs:61:24 | LL | trait BadTraitBound { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` error: these where clauses contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:68:12 + --> tests/ui/trait_duplication_in_bounds.rs:68:12 | LL | T: Clone + Clone + Clone + Copy, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:101:19 + --> tests/ui/trait_duplication_in_bounds.rs:101:19 | LL | fn bad_generic + GenericTrait + GenericTrait>(arg0: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `GenericTrait + GenericTrait` error: these bounds contain repeated elements - --> $DIR/trait_duplication_in_bounds.rs:109:22 + --> tests/ui/trait_duplication_in_bounds.rs:109:22 | LL | fn qualified_path(arg0: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::clone::Clone + foo::Clone` error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds.rs:117:33 + --> tests/ui/trait_duplication_in_bounds.rs:117:33 | LL | fn bad_trait_object(arg0: &(dyn Any + Send + Send)) { | ^^^^^^^^^^^^^^^^^ help: try: `Any + Send` diff --git a/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.rs b/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.rs index effed3a26938b..b0095bb77b5a0 100644 --- a/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.rs +++ b/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.rs @@ -1,4 +1,5 @@ #![deny(clippy::trait_duplication_in_bounds)] +#![allow(clippy::multiple_bound_locations)] use std::collections::BTreeMap; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; diff --git a/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.stderr b/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.stderr index 80dc7d8b6c32d..41029007a98ee 100644 --- a/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.stderr +++ b/src/tools/clippy/tests/ui/trait_duplication_in_bounds_unfixable.stderr @@ -1,18 +1,18 @@ error: this trait bound is already specified in the where clause - --> $DIR/trait_duplication_in_bounds_unfixable.rs:6:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:7:15 | LL | fn bad_foo(arg0: T, arg1: Z) | ^^^^^ | = help: consider removing this trait bound note: the lint level is defined here - --> $DIR/trait_duplication_in_bounds_unfixable.rs:1:9 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:1:9 | LL | #![deny(clippy::trait_duplication_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this trait bound is already specified in the where clause - --> $DIR/trait_duplication_in_bounds_unfixable.rs:6:23 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:7:23 | LL | fn bad_foo(arg0: T, arg1: Z) | ^^^^^^^ @@ -20,7 +20,7 @@ LL | fn bad_foo(arg0: T, arg1: Z) = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:37:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:38:15 | LL | Self: Default; | ^^^^^^^ @@ -28,7 +28,7 @@ LL | Self: Default; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:52:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:53:15 | LL | Self: Default + Clone; | ^^^^^^^ @@ -36,7 +36,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:59:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:60:15 | LL | Self: Default + Clone; | ^^^^^^^ @@ -44,7 +44,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:59:25 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:60:25 | LL | Self: Default + Clone; | ^^^^^ @@ -52,7 +52,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:64:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:65:15 | LL | Self: Default; | ^^^^^^^ @@ -60,7 +60,7 @@ LL | Self: Default; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> $DIR/trait_duplication_in_bounds_unfixable.rs:100:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:101:15 | LL | Self: Iterator, | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/transmute.stderr b/src/tools/clippy/tests/ui/transmute.stderr index df32d478cbf40..3ed6cb2b3f974 100644 --- a/src/tools/clippy/tests/ui/transmute.stderr +++ b/src/tools/clippy/tests/ui/transmute.stderr @@ -1,5 +1,5 @@ error: transmute from a reference to a pointer - --> $DIR/transmute.rs:24:23 + --> tests/ui/transmute.rs:24:23 | LL | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T` @@ -8,61 +8,61 @@ LL | let _: *const T = core::intrinsics::transmute(t); = help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:28:21 + --> tests/ui/transmute.rs:28:21 | LL | let _: *mut T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:31:23 + --> tests/ui/transmute.rs:31:23 | LL | let _: *const U = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U` error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:38:27 + --> tests/ui/transmute.rs:38:27 | LL | let _: Vec = core::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:41:27 + --> tests/ui/transmute.rs:41:27 | LL | let _: Vec = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:44:27 + --> tests/ui/transmute.rs:44:27 | LL | let _: Vec = std::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:47:27 + --> tests/ui/transmute.rs:47:27 | LL | let _: Vec = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:50:27 + --> tests/ui/transmute.rs:50:27 | LL | let _: Vec = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from an integer to a pointer - --> $DIR/transmute.rs:53:31 + --> tests/ui/transmute.rs:53:31 | LL | let _: *const usize = std::mem::transmute(5_isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` error: transmute from an integer to a pointer - --> $DIR/transmute.rs:58:31 + --> tests/ui/transmute.rs:58:31 | LL | let _: *const usize = std::mem::transmute(1 + 1usize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize` error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:90:24 + --> tests/ui/transmute.rs:90:24 | LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,25 +71,25 @@ LL | let _: Usize = core::intrinsics::transmute(int_const_ptr); = 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 + --> tests/ui/transmute.rs:94:24 | LL | let _: Usize = core::intrinsics::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) - --> $DIR/transmute.rs:97:31 + --> tests/ui/transmute.rs:97:31 | LL | let _: *const Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) - --> $DIR/transmute.rs:100:29 + --> tests/ui/transmute.rs:100:29 | LL | let _: *mut Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `u8` to a `bool` - --> $DIR/transmute.rs:107:28 + --> tests/ui/transmute.rs:107:28 | LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` @@ -98,7 +98,7 @@ LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_bool)]` error: transmute from a `u32` to a `f32` - --> $DIR/transmute.rs:115:31 + --> tests/ui/transmute.rs:115:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` @@ -107,25 +107,25 @@ LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_float)]` error: transmute from a `i32` to a `f32` - --> $DIR/transmute.rs:118:31 + --> tests/ui/transmute.rs:118:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` error: transmute from a `u64` to a `f64` - --> $DIR/transmute.rs:120:31 + --> tests/ui/transmute.rs:120:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_u64)` error: transmute from a `i64` to a `f64` - --> $DIR/transmute.rs:122:31 + --> tests/ui/transmute.rs:122:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)` error: transmute from a `u8` to a `[u8; 1]` - --> $DIR/transmute.rs:143:30 + --> tests/ui/transmute.rs:143:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` @@ -134,85 +134,85 @@ LL | let _: [u8; 1] = std::mem::transmute(0u8); = help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]` error: transmute from a `u32` to a `[u8; 4]` - --> $DIR/transmute.rs:146:30 + --> tests/ui/transmute.rs:146:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` error: transmute from a `u128` to a `[u8; 16]` - --> $DIR/transmute.rs:148:31 + --> tests/ui/transmute.rs:148:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` error: transmute from a `i8` to a `[u8; 1]` - --> $DIR/transmute.rs:150:30 + --> tests/ui/transmute.rs:150:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` error: transmute from a `i32` to a `[u8; 4]` - --> $DIR/transmute.rs:152:30 + --> tests/ui/transmute.rs:152:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` error: transmute from a `i128` to a `[u8; 16]` - --> $DIR/transmute.rs:154:31 + --> tests/ui/transmute.rs:154:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` error: transmute from a `f32` to a `[u8; 4]` - --> $DIR/transmute.rs:156:30 + --> tests/ui/transmute.rs:156:30 | LL | let _: [u8; 4] = std::mem::transmute(0.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()` error: transmute from a `f64` to a `[u8; 8]` - --> $DIR/transmute.rs:158:30 + --> tests/ui/transmute.rs:158:30 | LL | let _: [u8; 8] = std::mem::transmute(0.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()` error: transmute from a `u8` to a `[u8; 1]` - --> $DIR/transmute.rs:164:30 + --> tests/ui/transmute.rs:164:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` error: transmute from a `u32` to a `[u8; 4]` - --> $DIR/transmute.rs:166:30 + --> tests/ui/transmute.rs:166:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` error: transmute from a `u128` to a `[u8; 16]` - --> $DIR/transmute.rs:168:31 + --> tests/ui/transmute.rs:168:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` error: transmute from a `i8` to a `[u8; 1]` - --> $DIR/transmute.rs:170:30 + --> tests/ui/transmute.rs:170:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` error: transmute from a `i32` to a `[u8; 4]` - --> $DIR/transmute.rs:172:30 + --> tests/ui/transmute.rs:172:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` error: transmute from a `i128` to a `[u8; 16]` - --> $DIR/transmute.rs:174:31 + --> tests/ui/transmute.rs:174:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` error: transmute from a `&[u8]` to a `&str` - --> $DIR/transmute.rs:185:28 + --> tests/ui/transmute.rs:185:28 | LL | let _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()` @@ -221,13 +221,13 @@ LL | let _: &str = unsafe { std::mem::transmute(B) }; = 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:188:32 + --> tests/ui/transmute.rs:188:32 | LL | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` error: transmute from a `&[u8]` to a `&str` - --> $DIR/transmute.rs:190:30 + --> tests/ui/transmute.rs:190:30 | LL | const _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)` diff --git a/src/tools/clippy/tests/ui/transmute_32bit.stderr b/src/tools/clippy/tests/ui/transmute_32bit.stderr index baa819e30fded..2f16d124670e7 100644 --- a/src/tools/clippy/tests/ui/transmute_32bit.stderr +++ b/src/tools/clippy/tests/ui/transmute_32bit.stderr @@ -1,5 +1,5 @@ error: transmute from a `f32` to a pointer - --> $DIR/transmute_32bit.rs:6:31 + --> tests/ui/transmute_32bit.rs:6:31 | LL | let _: *const usize = std::mem::transmute(6.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | let _: *const usize = std::mem::transmute(6.0f32); = help: to override `-D warnings` add `#[allow(clippy::wrong_transmute)]` error: transmute from a `f32` to a pointer - --> $DIR/transmute_32bit.rs:8:29 + --> tests/ui/transmute_32bit.rs:8:29 | LL | let _: *mut usize = std::mem::transmute(6.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `char` to a pointer - --> $DIR/transmute_32bit.rs:10:31 + --> tests/ui/transmute_32bit.rs:10:31 | LL | let _: *const usize = std::mem::transmute('x'); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `char` to a pointer - --> $DIR/transmute_32bit.rs:12:29 + --> tests/ui/transmute_32bit.rs:12:29 | LL | let _: *mut usize = std::mem::transmute('x'); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/transmute_64bit.stderr b/src/tools/clippy/tests/ui/transmute_64bit.stderr index a30480eb7df0a..65fff17f59fa9 100644 --- a/src/tools/clippy/tests/ui/transmute_64bit.stderr +++ b/src/tools/clippy/tests/ui/transmute_64bit.stderr @@ -1,5 +1,5 @@ error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:6:31 + --> tests/ui/transmute_64bit.rs:6:31 | LL | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _: *const usize = std::mem::transmute(6.0f64); = help: to override `-D warnings` add `#[allow(clippy::wrong_transmute)]` error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:10:29 + --> tests/ui/transmute_64bit.rs:10:29 | LL | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/transmute_collection.stderr b/src/tools/clippy/tests/ui/transmute_collection.stderr index 2163142eef2e8..f71fba6315ca7 100644 --- a/src/tools/clippy/tests/ui/transmute_collection.stderr +++ b/src/tools/clippy/tests/ui/transmute_collection.stderr @@ -1,5 +1,5 @@ error: transmute from `std::vec::Vec` to `std::vec::Vec` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:9:17 + --> tests/ui/transmute_collection.rs:9:17 | LL | let _ = transmute::<_, Vec>(vec![0u8]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,103 +8,103 @@ LL | let _ = transmute::<_, Vec>(vec![0u8]); = 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 + --> tests/ui/transmute_collection.rs:13:17 | LL | let _ = transmute::<_, Vec<[u8; 4]>>(vec![1234u32]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::VecDeque` to `std::collections::VecDeque` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:17:17 + --> tests/ui/transmute_collection.rs:17:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::VecDeque<[u8; 4]>` to `std::collections::VecDeque` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:20:17 + --> tests/ui/transmute_collection.rs:20:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BinaryHeap` to `std::collections::BinaryHeap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:24:17 + --> tests/ui/transmute_collection.rs:24:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BinaryHeap<[u8; 4]>` to `std::collections::BinaryHeap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:27:17 + --> tests/ui/transmute_collection.rs:27:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeSet` to `std::collections::BTreeSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:31:17 + --> tests/ui/transmute_collection.rs:31:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeSet<[u8; 4]>` to `std::collections::BTreeSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:34:17 + --> tests/ui/transmute_collection.rs:34:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashSet` to `std::collections::HashSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:38:17 + --> tests/ui/transmute_collection.rs:38:17 | LL | let _ = transmute::<_, HashSet>(HashSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashSet<[u8; 4]>` to `std::collections::HashSet` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:41:17 + --> tests/ui/transmute_collection.rs:41:17 | LL | let _ = transmute::<_, HashSet>(HashSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:45:17 + --> tests/ui/transmute_collection.rs:45:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:47:17 + --> tests/ui/transmute_collection.rs:47:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:50:17 + --> tests/ui/transmute_collection.rs:50:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap<[u8; 4], u32>` to `std::collections::BTreeMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:52:17 + --> tests/ui/transmute_collection.rs:52:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:56:17 + --> tests/ui/transmute_collection.rs:56:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:58:17 + --> tests/ui/transmute_collection.rs:58:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:61:17 + --> tests/ui/transmute_collection.rs:61:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap<[u8; 4], u32>` to `std::collections::HashMap` with mismatched layout is unsound - --> $DIR/transmute_collection.rs:63:17 + --> tests/ui/transmute_collection.rs:63:17 | LL | let _ = transmute::<_, HashMap>(HashMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 1895120c0c99c..e89258d9102ac 100644 --- a/src/tools/clippy/tests/ui/transmute_float_to_int.stderr +++ b/src/tools/clippy/tests/ui/transmute_float_to_int.stderr @@ -1,5 +1,5 @@ error: transmute from a `f32` to a `u32` - --> $DIR/transmute_float_to_int.rs:4:27 + --> tests/ui/transmute_float_to_int.rs:4:27 | LL | let _: u32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits()` @@ -8,31 +8,31 @@ LL | let _: u32 = unsafe { std::mem::transmute(1f32) }; = 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 + --> tests/ui/transmute_float_to_int.rs:7:27 | LL | let _: i32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits() as i32` error: transmute from a `f64` to a `u64` - --> $DIR/transmute_float_to_int.rs:9:27 + --> tests/ui/transmute_float_to_int.rs:9:27 | LL | let _: u64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits()` error: transmute from a `f64` to a `i64` - --> $DIR/transmute_float_to_int.rs:11:27 + --> tests/ui/transmute_float_to_int.rs:11:27 | LL | let _: i64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits() as i64` error: transmute from a `f64` to a `u64` - --> $DIR/transmute_float_to_int.rs:13:27 + --> tests/ui/transmute_float_to_int.rs:13:27 | LL | let _: u64 = unsafe { std::mem::transmute(1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.0f64.to_bits()` error: transmute from a `f64` to a `u64` - --> $DIR/transmute_float_to_int.rs:15:27 + --> tests/ui/transmute_float_to_int.rs:15:27 | LL | let _: u64 = unsafe { std::mem::transmute(-1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-1.0f64).to_bits()` diff --git a/src/tools/clippy/tests/ui/transmute_int_to_char.stderr b/src/tools/clippy/tests/ui/transmute_int_to_char.stderr index 2297f5b4f8bf2..8444afbd21ef2 100644 --- a/src/tools/clippy/tests/ui/transmute_int_to_char.stderr +++ b/src/tools/clippy/tests/ui/transmute_int_to_char.stderr @@ -1,5 +1,5 @@ error: transmute from a `u32` to a `char` - --> $DIR/transmute_int_to_char.rs:4:28 + --> tests/ui/transmute_int_to_char.rs:4:28 | LL | let _: char = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` @@ -8,7 +8,7 @@ LL | let _: char = unsafe { std::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_char)]` error: transmute from a `i32` to a `char` - --> $DIR/transmute_int_to_char.rs:7:28 + --> tests/ui/transmute_int_to_char.rs:7:28 | LL | let _: char = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` diff --git a/src/tools/clippy/tests/ui/transmute_int_to_char_no_std.stderr b/src/tools/clippy/tests/ui/transmute_int_to_char_no_std.stderr index aace6968696da..d2c3842b684e4 100644 --- a/src/tools/clippy/tests/ui/transmute_int_to_char_no_std.stderr +++ b/src/tools/clippy/tests/ui/transmute_int_to_char_no_std.stderr @@ -1,5 +1,5 @@ error: transmute from a `u32` to a `char` - --> $DIR/transmute_int_to_char_no_std.rs:16:28 + --> tests/ui/transmute_int_to_char_no_std.rs:16:28 | LL | let _: char = unsafe { core::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::char::from_u32(0_u32).unwrap()` @@ -8,7 +8,7 @@ LL | let _: char = unsafe { core::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_char)]` error: transmute from a `i32` to a `char` - --> $DIR/transmute_int_to_char_no_std.rs:19:28 + --> tests/ui/transmute_int_to_char_no_std.rs:19:28 | LL | let _: char = unsafe { core::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::char::from_u32(0_i32 as u32).unwrap()` 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 b79a80c326d8d..dd37bd2105585 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 @@ -1,5 +1,5 @@ error: transmute from a `u8` to a `NonZeroU8` - --> $DIR/transmute_int_to_non_zero.rs:18:33 + --> tests/ui/transmute_int_to_non_zero.rs:18:33 | LL | let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU8::new_unchecked(int_u8)` @@ -8,55 +8,55 @@ LL | let _: NonZeroU8 = unsafe { std::mem::transmute(int_u8) }; = 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 + --> tests/ui/transmute_int_to_non_zero.rs:21:34 | LL | let _: NonZeroU16 = unsafe { std::mem::transmute(int_u16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU16::new_unchecked(int_u16)` error: transmute from a `u32` to a `NonZeroU32` - --> $DIR/transmute_int_to_non_zero.rs:23:34 + --> tests/ui/transmute_int_to_non_zero.rs:23:34 | LL | let _: NonZeroU32 = unsafe { std::mem::transmute(int_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU32::new_unchecked(int_u32)` error: transmute from a `u64` to a `NonZeroU64` - --> $DIR/transmute_int_to_non_zero.rs:25:34 + --> tests/ui/transmute_int_to_non_zero.rs:25:34 | LL | let _: NonZeroU64 = unsafe { std::mem::transmute(int_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU64::new_unchecked(int_u64)` error: transmute from a `u128` to a `NonZeroU128` - --> $DIR/transmute_int_to_non_zero.rs:27:35 + --> tests/ui/transmute_int_to_non_zero.rs:27:35 | LL | let _: NonZeroU128 = unsafe { std::mem::transmute(int_u128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroU128::new_unchecked(int_u128)` error: transmute from a `i8` to a `NonZeroI8` - --> $DIR/transmute_int_to_non_zero.rs:30:33 + --> tests/ui/transmute_int_to_non_zero.rs:30:33 | LL | let _: NonZeroI8 = unsafe { std::mem::transmute(int_i8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI8::new_unchecked(int_i8)` error: transmute from a `i16` to a `NonZeroI16` - --> $DIR/transmute_int_to_non_zero.rs:32:34 + --> tests/ui/transmute_int_to_non_zero.rs:32:34 | LL | let _: NonZeroI16 = unsafe { std::mem::transmute(int_i16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI16::new_unchecked(int_i16)` error: transmute from a `i32` to a `NonZeroI32` - --> $DIR/transmute_int_to_non_zero.rs:34:34 + --> tests/ui/transmute_int_to_non_zero.rs:34:34 | LL | let _: NonZeroI32 = unsafe { std::mem::transmute(int_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI32::new_unchecked(int_i32)` error: transmute from a `i64` to a `NonZeroI64` - --> $DIR/transmute_int_to_non_zero.rs:36:34 + --> tests/ui/transmute_int_to_non_zero.rs:36:34 | LL | let _: NonZeroI64 = unsafe { std::mem::transmute(int_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI64::new_unchecked(int_i64)` error: transmute from a `i128` to a `NonZeroI128` - --> $DIR/transmute_int_to_non_zero.rs:38:35 + --> tests/ui/transmute_int_to_non_zero.rs:38:35 | LL | let _: NonZeroI128 = unsafe { std::mem::transmute(int_i128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZeroI128::new_unchecked(int_i128)` 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 9073080cbf3c6..cea7b42cb801c 100644 --- a/src/tools/clippy/tests/ui/transmute_null_to_fn.stderr +++ b/src/tools/clippy/tests/ui/transmute_null_to_fn.stderr @@ -1,5 +1,5 @@ error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:8:23 + --> tests/ui/transmute_null_to_fn.rs:8:23 | LL | let _: fn() = std::mem::transmute(0 as *const ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -9,7 +9,7 @@ LL | let _: fn() = std::mem::transmute(0 as *const ()); = 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 + --> tests/ui/transmute_null_to_fn.rs:10:23 | LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -17,7 +17,7 @@ LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>()); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:21:23 + --> tests/ui/transmute_null_to_fn.rs:21:23 | LL | let _: fn() = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -25,7 +25,7 @@ LL | let _: fn() = std::mem::transmute(ZPTR); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:30:23 + --> tests/ui/transmute_null_to_fn.rs:30:23 | LL | let _: fn() = std::mem::transmute(0 as *const u8 as *const ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -33,7 +33,7 @@ LL | let _: fn() = std::mem::transmute(0 as *const u8 as *const ()); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:32:23 + --> tests/ui/transmute_null_to_fn.rs:32:23 | LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -41,7 +41,7 @@ LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> $DIR/transmute_null_to_fn.rs:34:23 + --> tests/ui/transmute_null_to_fn.rs:34:23 | LL | let _: fn() = std::mem::transmute(ZPTR as *const u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior 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 6e3af1f733717..cd1f1f398dc2d 100644 --- a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr +++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.stderr @@ -1,5 +1,5 @@ error: transmute from a pointer to a pointer - --> $DIR/transmute_ptr_to_ptr.rs:30:29 + --> tests/ui/transmute_ptr_to_ptr.rs:30:29 | LL | let _: *const f32 = std::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` @@ -8,37 +8,37 @@ LL | let _: *const f32 = std::mem::transmute(ptr); = 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 + --> tests/ui/transmute_ptr_to_ptr.rs:33:27 | LL | let _: *mut f32 = std::mem::transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:36:23 + --> tests/ui/transmute_ptr_to_ptr.rs:36:23 | LL | let _: &f32 = std::mem::transmute(&1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:38:23 + --> tests/ui/transmute_ptr_to_ptr.rs:38:23 | LL | let _: &f32 = std::mem::transmute(&1f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f64 as *const f64 as *const f32)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:42:27 + --> tests/ui/transmute_ptr_to_ptr.rs:42:27 | LL | let _: &mut f32 = std::mem::transmute(&mut 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:44:37 + --> tests/ui/transmute_ptr_to_ptr.rs:44:37 | LL | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` error: transmute from a reference to a reference - --> $DIR/transmute_ptr_to_ptr.rs:47:36 + --> tests/ui/transmute_ptr_to_ptr.rs:47:36 | LL | let u8_ref: &u8 = unsafe { std::mem::transmute(u64_ref) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(u64_ref as *const u64 as *const u8)` 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 9d1b22a795b3d..d7d180398e1c6 100644 --- a/src/tools/clippy/tests/ui/transmute_ptr_to_ref.stderr +++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ref.stderr @@ -1,5 +1,5 @@ error: transmute from a pointer type (`*const T`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:5:17 + --> tests/ui/transmute_ptr_to_ref.rs:5:17 | LL | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` @@ -8,127 +8,127 @@ LL | let _: &T = std::mem::transmute(p); = 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 + --> tests/ui/transmute_ptr_to_ref.rs:8:21 | LL | let _: &mut T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m` error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:11:17 + --> tests/ui/transmute_ptr_to_ref.rs:11:17 | LL | let _: &T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute_ptr_to_ref.rs:14:21 + --> tests/ui/transmute_ptr_to_ref.rs:14:21 | LL | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)` error: transmute from a pointer type (`*const U`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:17:17 + --> tests/ui/transmute_ptr_to_ref.rs:17:17 | LL | let _: &T = std::mem::transmute(o); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) - --> $DIR/transmute_ptr_to_ref.rs:20:21 + --> tests/ui/transmute_ptr_to_ref.rs:20:21 | LL | let _: &mut T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) - --> $DIR/transmute_ptr_to_ref.rs:23:17 + --> tests/ui/transmute_ptr_to_ref.rs:23:17 | LL | let _: &T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)` error: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, u8>`) - --> $DIR/transmute_ptr_to_ref.rs:33:32 + --> tests/ui/transmute_ptr_to_ref.rs:33:32 | LL | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::>()` error: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, &u8>`) - --> $DIR/transmute_ptr_to_ref.rs:35:33 + --> tests/ui/transmute_ptr_to_ref.rs:35:33 | LL | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::>()` error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) - --> $DIR/transmute_ptr_to_ref.rs:39:14 + --> tests/ui/transmute_ptr_to_ref.rs:39:14 | LL | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:44:14 + --> tests/ui/transmute_ptr_to_ref.rs:44:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:45:14 + --> tests/ui/transmute_ptr_to_ref.rs:45:14 | LL | 1 => std::mem::transmute(y), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:46:14 + --> tests/ui/transmute_ptr_to_ref.rs:46:14 | LL | 2 => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:47:14 + --> tests/ui/transmute_ptr_to_ref.rs:47:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(y), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&'b u32>()` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:55:19 + --> tests/ui/transmute_ptr_to_ref.rs:55:19 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:56:19 + --> tests/ui/transmute_ptr_to_ref.rs:56:19 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a.cast::()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:58:14 + --> tests/ui/transmute_ptr_to_ref.rs:58:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:59:14 + --> tests/ui/transmute_ptr_to_ref.rs:59:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:67:19 + --> tests/ui/transmute_ptr_to_ref.rs:67:19 | LL | let _: &u32 = std::mem::transmute(a); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a` error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`) - --> $DIR/transmute_ptr_to_ref.rs:68:19 + --> tests/ui/transmute_ptr_to_ref.rs:68:19 | LL | let _: &u32 = std::mem::transmute::<_, &u32>(a); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const u32)` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:70:14 + --> tests/ui/transmute_ptr_to_ref.rs:70:14 | LL | 0 => std::mem::transmute(x), | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &u32)` error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`) - --> $DIR/transmute_ptr_to_ref.rs:71:14 + --> tests/ui/transmute_ptr_to_ref.rs:71:14 | LL | _ => std::mem::transmute::<_, &&'b u32>(x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &'b u32)` diff --git a/src/tools/clippy/tests/ui/transmute_ref_to_ref.stderr b/src/tools/clippy/tests/ui/transmute_ref_to_ref.stderr index 4238bc637ad04..e2d04cea8959f 100644 --- a/src/tools/clippy/tests/ui/transmute_ref_to_ref.stderr +++ b/src/tools/clippy/tests/ui/transmute_ref_to_ref.stderr @@ -1,23 +1,23 @@ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref.rs:9:39 + --> tests/ui/transmute_ref_to_ref.rs:9:39 | LL | let bools: &[bool] = unsafe { std::mem::transmute(single_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(single_u64 as *const [u64] as *const [bool])` | note: the lint level is defined here - --> $DIR/transmute_ref_to_ref.rs:3:9 + --> tests/ui/transmute_ref_to_ref.rs:3:9 | LL | #![deny(clippy::transmute_ptr_to_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref.rs:12:33 + --> tests/ui/transmute_ref_to_ref.rs:12:33 | LL | let b: &[u8] = unsafe { std::mem::transmute(a) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const [u32] as *const [u8])` error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref.rs:15:42 + --> tests/ui/transmute_ref_to_ref.rs:15:42 | LL | let alt_slice: &[u32] = unsafe { std::mem::transmute(bytes) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(bytes as *const [u8] as *const [u32])` diff --git a/src/tools/clippy/tests/ui/transmute_ref_to_ref_no_std.stderr b/src/tools/clippy/tests/ui/transmute_ref_to_ref_no_std.stderr index ca7966ffa9e88..6a76d6729d05b 100644 --- a/src/tools/clippy/tests/ui/transmute_ref_to_ref_no_std.stderr +++ b/src/tools/clippy/tests/ui/transmute_ref_to_ref_no_std.stderr @@ -1,23 +1,23 @@ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref_no_std.rs:21:39 + --> tests/ui/transmute_ref_to_ref_no_std.rs:21:39 | LL | let bools: &[bool] = unsafe { core::mem::transmute(single_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(single_u64 as *const [u64] as *const [bool])` | note: the lint level is defined here - --> $DIR/transmute_ref_to_ref_no_std.rs:3:9 + --> tests/ui/transmute_ref_to_ref_no_std.rs:3:9 | LL | #![deny(clippy::transmute_ptr_to_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref_no_std.rs:24:33 + --> tests/ui/transmute_ref_to_ref_no_std.rs:24:33 | LL | let b: &[u8] = unsafe { core::mem::transmute(a) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const [u32] as *const [u8])` error: transmute from a reference to a reference - --> $DIR/transmute_ref_to_ref_no_std.rs:27:42 + --> tests/ui/transmute_ref_to_ref_no_std.rs:27:42 | LL | let alt_slice: &[u32] = unsafe { core::mem::transmute(bytes) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(bytes as *const [u8] as *const [u32])` diff --git a/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr b/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr index f87b1ece96472..5504fbe16e416 100644 --- a/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr +++ b/src/tools/clippy/tests/ui/transmute_undefined_repr.stderr @@ -1,5 +1,5 @@ error: transmute from `Ty2` which has an undefined layout - --> $DIR/transmute_undefined_repr.rs:29:33 + --> tests/ui/transmute_undefined_repr.rs:29:33 | LL | let _: Ty2C = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | let _: Ty2C = transmute(value::>()); = 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 + --> tests/ui/transmute_undefined_repr.rs:33:32 | LL | let _: Ty2 = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `Ty>` to `Ty2`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:42:32 + --> tests/ui/transmute_undefined_repr.rs:42:32 | LL | let _: Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | let _: Ty2 = transmute(value::>>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `Ty2` to `Ty>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:46:36 + --> tests/ui/transmute_undefined_repr.rs:46:36 | LL | let _: Ty> = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | let _: Ty> = transmute(value::>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `Ty<&Ty2>` to `&Ty2`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:54:33 + --> tests/ui/transmute_undefined_repr.rs:54:33 | LL | let _: &Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | let _: &Ty2 = transmute(value::>>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `&Ty2` to `Ty<&Ty2>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:58:37 + --> tests/ui/transmute_undefined_repr.rs:58:37 | LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `std::boxed::Box>` to `&mut Ty2`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:88:45 + --> tests/ui/transmute_undefined_repr.rs:88:45 | LL | let _: &'static mut Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,7 +54,7 @@ LL | let _: &'static mut Ty2 = transmute(value::` to `std::boxed::Box>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:92:37 + --> tests/ui/transmute_undefined_repr.rs:92:37 | LL | let _: Box> = transmute(value::<&'static mut Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -62,7 +62,7 @@ LL | let _: Box> = transmute(value::<&'static mut Ty2` which has an undefined layout - --> $DIR/transmute_undefined_repr.rs:189:39 + --> tests/ui/transmute_undefined_repr.rs:189:39 | LL | let _: *const Ty2 = transmute(value::<*const Ty2C>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | let _: *const Ty2 = transmute(value::<*const Ty2C` has an undefined layout error: transmute from `*const Ty2` which has an undefined layout - --> $DIR/transmute_undefined_repr.rs:193:50 + --> tests/ui/transmute_undefined_repr.rs:193:50 | LL | let _: *const Ty2C> = transmute(value::<*const Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | let _: *const Ty2C> = transmute(value::<*const T = note: the contained type `Ty2` has an undefined layout error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:240:35 + --> tests/ui/transmute_undefined_repr.rs:240:35 | LL | let _: Vec> = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -86,7 +86,7 @@ LL | let _: Vec> = transmute(value::>>()); = note: two instances of the same generic type (`Vec`) may have different layouts error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout - --> $DIR/transmute_undefined_repr.rs:244:35 + --> tests/ui/transmute_undefined_repr.rs:244:35 | LL | let _: Vec> = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 a7988dc4b39b2..2ca44485826d7 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 @@ -1,5 +1,5 @@ error: transmute from an integer to a pointer - --> $DIR/transmutes_expressible_as_ptr_casts.rs:17:39 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:17:39 | LL | let _ptr_i32_transmute = unsafe { transmute::(usize::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::MAX as *const i32` @@ -8,7 +8,7 @@ LL | let _ptr_i32_transmute = unsafe { transmute::(usize: = 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 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:21:38 | LL | let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as *const i8` @@ -17,13 +17,13 @@ LL | let _ptr_i8_transmute = unsafe { transmute::<*const i32, *const i8>(ptr = 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 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:27:46 | LL | let _ptr_to_unsized_transmute = unsafe { transmute::<*const [i32], *const [u32]>(slice_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `slice_ptr as *const [u32]` error: transmute from `*const i32` to `usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:33:50 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:33:50 | LL | let _usize_from_int_ptr_transmute = unsafe { transmute::<*const i32, usize>(ptr_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr_i32 as usize` @@ -32,37 +32,37 @@ LL | let _usize_from_int_ptr_transmute = unsafe { transmute::<*const i32, us = 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 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:39:41 | LL | let _array_ptr_transmute = unsafe { transmute::<&[i32; 4], *const [i32; 4]>(array_ref) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array_ref as *const [i32; 4]` error: transmute from `fn(usize) -> u8` to `*const usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:47:41 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:47:41 | LL | let _usize_ptr_transmute = unsafe { transmute:: u8, *const usize>(foo) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as *const usize` error: transmute from `fn(usize) -> u8` to `usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:51:49 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:51:49 | LL | let _usize_from_fn_ptr_transmute = unsafe { transmute:: u8, usize>(foo) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `foo as usize` error: transmute from `*const u32` to `usize` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:54:36 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:54:36 | LL | let _usize_from_ref = unsafe { transmute::<*const u32, usize>(&1u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&1u32 as *const u32 as usize` error: transmute from a reference to a pointer - --> $DIR/transmutes_expressible_as_ptr_casts.rs:65:14 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:65:14 | LL | unsafe { transmute::<&[i32; 1], *const u8>(in_param) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `in_param as *const [i32; 1] as *const u8` error: transmute from `fn()` to `*const u8` which could be expressed as a pointer cast instead - --> $DIR/transmutes_expressible_as_ptr_casts.rs:83:28 + --> tests/ui/transmutes_expressible_as_ptr_casts.rs:83:28 | LL | let _x: u8 = unsafe { *std::mem::transmute::(f) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(f as *const u8)` diff --git a/src/tools/clippy/tests/ui/transmuting_null.stderr b/src/tools/clippy/tests/ui/transmuting_null.stderr index 402de38fe9e2f..84e6e374d5253 100644 --- a/src/tools/clippy/tests/ui/transmuting_null.stderr +++ b/src/tools/clippy/tests/ui/transmuting_null.stderr @@ -1,5 +1,5 @@ error: transmuting a known null pointer into a reference - --> $DIR/transmuting_null.rs:10:23 + --> tests/ui/transmuting_null.rs:10:23 | LL | let _: &u64 = std::mem::transmute(0 as *const u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | let _: &u64 = std::mem::transmute(0 as *const u64); = 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 + --> tests/ui/transmuting_null.rs:13:23 | LL | let _: &u64 = std::mem::transmute(std::ptr::null::()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmuting a known null pointer into a reference - --> $DIR/transmuting_null.rs:24:23 + --> tests/ui/transmuting_null.rs:24:23 | LL | let _: &u64 = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/trim_split_whitespace.stderr b/src/tools/clippy/tests/ui/trim_split_whitespace.stderr index a1c66eea0d14c..6119d21a8e9ae 100644 --- a/src/tools/clippy/tests/ui/trim_split_whitespace.stderr +++ b/src/tools/clippy/tests/ui/trim_split_whitespace.stderr @@ -1,5 +1,5 @@ error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:61:23 + --> tests/ui/trim_split_whitespace.rs:61:23 | LL | let _ = " A B C ".trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` @@ -8,43 +8,43 @@ LL | let _ = " A B C ".trim().split_whitespace(); // should trigger lint = 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 + --> tests/ui/trim_split_whitespace.rs:62:23 | LL | let _ = " A B C ".trim_start().split_whitespace(); // should trigger lint | ^^^^^^^^^^^^^ help: remove `trim_start()` error: found call to `str::trim_end` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:63:23 + --> tests/ui/trim_split_whitespace.rs:63:23 | LL | let _ = " A B C ".trim_end().split_whitespace(); // should trigger lint | ^^^^^^^^^^^ help: remove `trim_end()` error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:66:37 + --> tests/ui/trim_split_whitespace.rs:66:37 | LL | let _ = (" A B C ").to_string().trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` error: found call to `str::trim_start` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:67:37 + --> tests/ui/trim_split_whitespace.rs:67:37 | LL | let _ = (" A B C ").to_string().trim_start().split_whitespace(); // should trigger lint | ^^^^^^^^^^^^^ help: remove `trim_start()` error: found call to `str::trim_end` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:68:37 + --> tests/ui/trim_split_whitespace.rs:68:37 | LL | let _ = (" A B C ").to_string().trim_end().split_whitespace(); // should trigger lint | ^^^^^^^^^^^ help: remove `trim_end()` error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:75:15 + --> tests/ui/trim_split_whitespace.rs:75:15 | LL | let _ = s.trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` error: found call to `str::trim` before `str::split_whitespace` - --> $DIR/trim_split_whitespace.rs:83:15 + --> tests/ui/trim_split_whitespace.rs:83:15 | LL | let _ = s.trim().split_whitespace(); // should trigger lint | ^^^^^^^ help: remove `trim()` diff --git a/src/tools/clippy/tests/ui/trivially_copy_pass_by_ref.stderr b/src/tools/clippy/tests/ui/trivially_copy_pass_by_ref.stderr index c9585e519883c..4887fb00e7425 100644 --- a/src/tools/clippy/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/src/tools/clippy/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,113 +1,113 @@ error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:52:11 + --> tests/ui/trivially_copy_pass_by_ref.rs:52:11 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` | note: the lint level is defined here - --> $DIR/trivially_copy_pass_by_ref.rs:3:9 + --> tests/ui/trivially_copy_pass_by_ref.rs:3:9 | LL | #![deny(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: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:52:20 + --> tests/ui/trivially_copy_pass_by_ref.rs:52:20 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:52:29 + --> tests/ui/trivially_copy_pass_by_ref.rs:52:29 | LL | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:12 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:12 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^^ help: consider passing by value instead: `self` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:22 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:22 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:31 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:31 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:61:40 + --> tests/ui/trivially_copy_pass_by_ref.rs:61:40 | LL | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:67:16 + --> tests/ui/trivially_copy_pass_by_ref.rs:67:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:67:25 + --> tests/ui/trivially_copy_pass_by_ref.rs:67:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:67:34 + --> tests/ui/trivially_copy_pass_by_ref.rs:67:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:72:35 + --> tests/ui/trivially_copy_pass_by_ref.rs:72:35 | LL | fn bad_issue7518(self, other: &Self) {} | ^^^^^ help: consider passing by value instead: `Self` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:85:16 + --> tests/ui/trivially_copy_pass_by_ref.rs:85:16 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:85:25 + --> tests/ui/trivially_copy_pass_by_ref.rs:85:25 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:85:34 + --> tests/ui/trivially_copy_pass_by_ref.rs:85:34 | LL | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:92:34 + --> tests/ui/trivially_copy_pass_by_ref.rs:92:34 | LL | fn trait_method(&self, _foo: &Foo); | ^^^^ help: consider passing by value instead: `Foo` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:125:21 + --> tests/ui/trivially_copy_pass_by_ref.rs:125:21 | LL | fn foo_never(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:131:15 + --> tests/ui/trivially_copy_pass_by_ref.rs:131:15 | LL | fn foo(x: &i32) { | ^^^^ help: consider passing by value instead: `i32` error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) - --> $DIR/trivially_copy_pass_by_ref.rs:159:37 + --> tests/ui/trivially_copy_pass_by_ref.rs:159:37 | LL | fn _unrelated_lifetimes<'a, 'b>(_x: &'a u32, y: &'b u32) -> &'b u32 { | ^^^^^^^ help: consider passing by value instead: `u32` diff --git a/src/tools/clippy/tests/ui/try_err.stderr b/src/tools/clippy/tests/ui/try_err.stderr index 887889ffd111d..fb563d4078660 100644 --- a/src/tools/clippy/tests/ui/try_err.stderr +++ b/src/tools/clippy/tests/ui/try_err.stderr @@ -1,35 +1,35 @@ error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:22:9 + --> tests/ui/try_err.rs:22:9 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err)` | note: the lint level is defined here - --> $DIR/try_err.rs:3:9 + --> tests/ui/try_err.rs:3:9 | LL | #![deny(clippy::try_err)] | ^^^^^^^^^^^^^^^ error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:32:9 + --> tests/ui/try_err.rs:32:9 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err.into())` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:52:17 + --> tests/ui/try_err.rs:52:17 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err)` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:71:17 + --> tests/ui/try_err.rs:71:17 | LL | Err(err)?; | ^^^^^^^^^ help: try: `return Err(err.into())` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:91:23 + --> tests/ui/try_err.rs:91:23 | LL | Err(_) => Err(1)?, | ^^^^^^^ help: try: `return Err(1)` @@ -37,7 +37,7 @@ LL | Err(_) => Err(1)?, = note: this error originates in the macro `__inline_mac_fn_calling_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:98:23 + --> tests/ui/try_err.rs:98:23 | LL | Err(_) => Err(inline!(1))?, | ^^^^^^^^^^^^^^^^ help: try: `return Err(inline!(1))` @@ -45,31 +45,31 @@ LL | Err(_) => Err(inline!(1))?, = note: this error originates in the macro `__inline_mac_fn_calling_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:125:9 + --> tests/ui/try_err.rs:125:9 | LL | Err(inline!(inline!(String::from("aasdfasdfasdfa"))))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Err(inline!(inline!(String::from("aasdfasdfasdfa"))))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:132:9 + --> tests/ui/try_err.rs:132:9 | LL | Err(io::ErrorKind::WriteZero)? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Poll::Ready(Err(io::ErrorKind::WriteZero.into()))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:134:9 + --> tests/ui/try_err.rs:134:9 | LL | Err(io::Error::new(io::ErrorKind::InvalidInput, "error"))? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Poll::Ready(Err(io::Error::new(io::ErrorKind::InvalidInput, "error")))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:142:9 + --> tests/ui/try_err.rs:142:9 | LL | Err(io::ErrorKind::NotFound)? | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `return Poll::Ready(Some(Err(io::ErrorKind::NotFound.into())))` error: returning an `Err(_)` with the `?` operator - --> $DIR/try_err.rs:151:16 + --> tests/ui/try_err.rs:151:16 | LL | return Err(42)?; | ^^^^^^^^ help: try: `Err(42)` diff --git a/src/tools/clippy/tests/ui/tuple_array_conversions.stderr b/src/tools/clippy/tests/ui/tuple_array_conversions.stderr index f8f5b3e75871d..9e022b3cfb254 100644 --- a/src/tools/clippy/tests/ui/tuple_array_conversions.stderr +++ b/src/tools/clippy/tests/ui/tuple_array_conversions.stderr @@ -1,5 +1,5 @@ error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:10:13 + --> tests/ui/tuple_array_conversions.rs:10:13 | LL | let x = (x[0], x[1]); | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let x = (x[0], x[1]); = 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 + --> tests/ui/tuple_array_conversions.rs:11:13 | LL | let x = [x.0, x.1]; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let x = [x.0, x.1]; = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:16:53 + --> tests/ui/tuple_array_conversions.rs:16:53 | LL | let v1: Vec<[u32; 2]> = t1.iter().map(|&(a, b)| [a, b]).collect(); | ^^^^^^ @@ -25,7 +25,7 @@ LL | let v1: Vec<[u32; 2]> = t1.iter().map(|&(a, b)| [a, b]).collect(); = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:17:38 + --> tests/ui/tuple_array_conversions.rs:17:38 | LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); | ^^^^^^ @@ -33,7 +33,7 @@ LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:18:55 + --> tests/ui/tuple_array_conversions.rs:18:55 | LL | let t2: Vec<(u32, u32)> = v1.iter().map(|&[a, b]| (a, b)).collect(); | ^^^^^^ @@ -41,7 +41,7 @@ LL | let t2: Vec<(u32, u32)> = v1.iter().map(|&[a, b]| (a, b)).collect(); = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:19:38 + --> tests/ui/tuple_array_conversions.rs:19:38 | LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); | ^^^^^^ @@ -49,7 +49,7 @@ LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:57:22 + --> tests/ui/tuple_array_conversions.rs:57:22 | LL | let _: &[f64] = &[a, b]; | ^^^^^^ @@ -57,7 +57,7 @@ LL | let _: &[f64] = &[a, b]; = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:60:5 + --> tests/ui/tuple_array_conversions.rs:60:5 | LL | (src, dest); | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | (src, dest); = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed error: it looks like you're trying to convert an array to a tuple - --> $DIR/tuple_array_conversions.rs:104:13 + --> tests/ui/tuple_array_conversions.rs:104:13 | LL | let x = (x[0], x[1]); | ^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let x = (x[0], x[1]); = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed error: it looks like you're trying to convert a tuple to an array - --> $DIR/tuple_array_conversions.rs:105:13 + --> tests/ui/tuple_array_conversions.rs:105:13 | LL | let x = [x.0, x.1]; | ^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/type_complexity.stderr b/src/tools/clippy/tests/ui/type_complexity.stderr index a3cf6ffe97516..9e27899e4f904 100644 --- a/src/tools/clippy/tests/ui/type_complexity.stderr +++ b/src/tools/clippy/tests/ui/type_complexity.stderr @@ -1,5 +1,5 @@ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:7:12 + --> tests/ui/type_complexity.rs:7:12 | LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,85 +8,85 @@ LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); = 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 + --> tests/ui/type_complexity.rs:10:12 | LL | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:14:8 + --> tests/ui/type_complexity.rs:14:8 | LL | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:18:11 + --> tests/ui/type_complexity.rs:18:11 | LL | struct Ts(Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:22:11 + --> tests/ui/type_complexity.rs:22:11 | LL | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:24:17 + --> tests/ui/type_complexity.rs:24:17 | LL | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:29:14 + --> tests/ui/type_complexity.rs:29:14 | LL | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:31:30 + --> tests/ui/type_complexity.rs:31:30 | LL | fn impl_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:36:14 + --> tests/ui/type_complexity.rs:36:14 | LL | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:38:14 + --> tests/ui/type_complexity.rs:38:14 | LL | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:40:25 + --> tests/ui/type_complexity.rs:40:25 | LL | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:42:29 + --> tests/ui/type_complexity.rs:42:29 | LL | fn def_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:55:15 + --> tests/ui/type_complexity.rs:55:15 | LL | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:60:14 + --> tests/ui/type_complexity.rs:60:14 | LL | fn test2(_x: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/type_complexity.rs:64:13 + --> tests/ui/type_complexity.rs:64:13 | LL | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 844dae158b8d8..0fce6a37c0044 100644 --- a/src/tools/clippy/tests/ui/type_id_on_box.stderr +++ b/src/tools/clippy/tests/ui/type_id_on_box.stderr @@ -1,5 +1,5 @@ error: calling `.type_id()` on a `Box` - --> $DIR/type_id_on_box.rs:24:13 + --> tests/ui/type_id_on_box.rs:24:13 | LL | let _ = any_box.type_id(); | -------^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | let _ = any_box.type_id(); = 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 + --> tests/ui/type_id_on_box.rs:28:13 | LL | let _ = any_box.type_id(); // 2 derefs are needed here to get to the `dyn Any` | -------^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = any_box.type_id(); // 2 derefs are needed here to get to the `d = note: if this is intentional, use `TypeId::of::>()` instead, which makes it more clear error: calling `.type_id()` on a `Box` - --> $DIR/type_id_on_box.rs:34:13 + --> tests/ui/type_id_on_box.rs:34:13 | LL | let _ = b.type_id(); | -^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/type_repetition_in_bounds.rs b/src/tools/clippy/tests/ui/type_repetition_in_bounds.rs index 504a003940502..0039c805b7df8 100644 --- a/src/tools/clippy/tests/ui/type_repetition_in_bounds.rs +++ b/src/tools/clippy/tests/ui/type_repetition_in_bounds.rs @@ -1,5 +1,5 @@ #![deny(clippy::type_repetition_in_bounds)] -#![allow(clippy::extra_unused_type_parameters)] +#![allow(clippy::extra_unused_type_parameters, clippy::multiple_bound_locations)] use serde::Deserialize; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; diff --git a/src/tools/clippy/tests/ui/type_repetition_in_bounds.stderr b/src/tools/clippy/tests/ui/type_repetition_in_bounds.stderr index 607cd1fbf6a7b..e9c6b41aaa8ec 100644 --- a/src/tools/clippy/tests/ui/type_repetition_in_bounds.stderr +++ b/src/tools/clippy/tests/ui/type_repetition_in_bounds.stderr @@ -1,18 +1,18 @@ error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:10:5 + --> tests/ui/type_repetition_in_bounds.rs:10:5 | LL | T: Clone, | ^^^^^^^^ | = help: consider combining the bounds: `T: Copy + Clone` note: the lint level is defined here - --> $DIR/type_repetition_in_bounds.rs:1:9 + --> tests/ui/type_repetition_in_bounds.rs:1:9 | LL | #![deny(clippy::type_repetition_in_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:28:5 + --> tests/ui/type_repetition_in_bounds.rs:28:5 | LL | Self: Copy + Default + Ord, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | Self: Copy + Default + Ord, = help: consider combining the bounds: `Self: Clone + Copy + Default + Ord` error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:103:5 + --> tests/ui/type_repetition_in_bounds.rs:103:5 | LL | T: Clone, | ^^^^^^^^ @@ -28,7 +28,7 @@ LL | T: Clone, = help: consider combining the bounds: `T: ?Sized + Clone` error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:109:5 + --> tests/ui/type_repetition_in_bounds.rs:109:5 | LL | T: ?Sized, | ^^^^^^^^^ @@ -36,7 +36,7 @@ LL | T: ?Sized, = help: consider combining the bounds: `T: Clone + ?Sized` error: this type has already been used as a bound predicate - --> $DIR/type_repetition_in_bounds.rs:135:9 + --> tests/ui/type_repetition_in_bounds.rs:135:9 | LL | T: Trait, Box<[String]>, bool> + 'static, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/types.stderr b/src/tools/clippy/tests/ui/types.stderr index f7473e1c5c52d..02e75018129f4 100644 --- a/src/tools/clippy/tests/ui/types.stderr +++ b/src/tools/clippy/tests/ui/types.stderr @@ -1,5 +1,5 @@ error: casting `i32` to `i64` may become silently lossy if you later change the type - --> $DIR/types.rs:12:22 + --> tests/ui/types.rs:12:22 | LL | let c_i64: i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)` diff --git a/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr b/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr index 2b62bc9640392..b5e9bab86b478 100644 --- a/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr +++ b/src/tools/clippy/tests/ui/unchecked_duration_subtraction.stderr @@ -1,5 +1,5 @@ error: unchecked subtraction of a 'Duration' from an 'Instant' - --> $DIR/unchecked_duration_subtraction.rs:9:13 + --> tests/ui/unchecked_duration_subtraction.rs:9:13 | LL | let _ = _first - second; | ^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(second).unwrap()` @@ -8,19 +8,19 @@ LL | let _ = _first - second; = 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 + --> tests/ui/unchecked_duration_subtraction.rs:11:13 | LL | let _ = Instant::now() - Duration::from_secs(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(Duration::from_secs(5)).unwrap()` error: unchecked subtraction of a 'Duration' from an 'Instant' - --> $DIR/unchecked_duration_subtraction.rs:13:13 + --> tests/ui/unchecked_duration_subtraction.rs:13:13 | LL | let _ = _first - Duration::from_secs(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `_first.checked_sub(Duration::from_secs(5)).unwrap()` error: unchecked subtraction of a 'Duration' from an 'Instant' - --> $DIR/unchecked_duration_subtraction.rs:15:13 + --> tests/ui/unchecked_duration_subtraction.rs:15:13 | LL | let _ = Instant::now() - second; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Instant::now().checked_sub(second).unwrap()` diff --git a/src/tools/clippy/tests/ui/unconditional_recursion.rs b/src/tools/clippy/tests/ui/unconditional_recursion.rs index 6ad3bde51cde0..35275e81ded5c 100644 --- a/src/tools/clippy/tests/ui/unconditional_recursion.rs +++ b/src/tools/clippy/tests/ui/unconditional_recursion.rs @@ -147,6 +147,7 @@ macro_rules! impl_partial_eq { ($ty:ident) => { impl PartialEq for $ty { fn eq(&self, other: &Self) -> bool { + //~^ ERROR: function cannot return without recursing self == other } } @@ -156,7 +157,6 @@ macro_rules! impl_partial_eq { struct S5; impl_partial_eq!(S5); -//~^ ERROR: function cannot return without recursing struct S6 { field: String, diff --git a/src/tools/clippy/tests/ui/unconditional_recursion.stderr b/src/tools/clippy/tests/ui/unconditional_recursion.stderr index 93a5eac91d8e3..3fd6c91000eab 100644 --- a/src/tools/clippy/tests/ui/unconditional_recursion.stderr +++ b/src/tools/clippy/tests/ui/unconditional_recursion.stderr @@ -1,5 +1,5 @@ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:42:5 + --> tests/ui/unconditional_recursion.rs:42:5 | LL | fn ne(&self, other: &Self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -12,7 +12,7 @@ LL | self.ne(other) = help: to override `-D warnings` add `#[allow(unconditional_recursion)]` error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:46:5 + --> tests/ui/unconditional_recursion.rs:46:5 | LL | fn eq(&self, other: &Self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -23,7 +23,7 @@ LL | self.eq(other) = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:211:5 + --> tests/ui/unconditional_recursion.rs:211:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -34,7 +34,7 @@ LL | self.to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:221:5 + --> tests/ui/unconditional_recursion.rs:221:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -45,7 +45,7 @@ LL | x.to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:232:5 + --> tests/ui/unconditional_recursion.rs:232:5 | LL | fn to_string(&self) -> String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -56,7 +56,7 @@ LL | (self as &Self).to_string() = help: a `loop` may express intention better if this is on purpose error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:12:5 + --> tests/ui/unconditional_recursion.rs:12:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -65,7 +65,7 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:14:9 + --> tests/ui/unconditional_recursion.rs:14:9 | LL | self != other | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | self != other = help: to override `-D warnings` add `#[allow(clippy::unconditional_recursion)]` error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:16:5 + --> tests/ui/unconditional_recursion.rs:16:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -82,13 +82,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:18:9 + --> tests/ui/unconditional_recursion.rs:18:9 | LL | self == other | ^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:28:5 + --> tests/ui/unconditional_recursion.rs:28:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | self != &Foo2::B // no error here @@ -96,13 +96,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:29:9 + --> tests/ui/unconditional_recursion.rs:29:9 | LL | self != &Foo2::B // no error here | ^^^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:31:5 + --> tests/ui/unconditional_recursion.rs:31:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | self == &Foo2::B // no error here @@ -110,13 +110,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:32:9 + --> tests/ui/unconditional_recursion.rs:32:9 | LL | self == &Foo2::B // no error here | ^^^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:42:5 + --> tests/ui/unconditional_recursion.rs:42:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -125,19 +125,19 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:44:9 + --> tests/ui/unconditional_recursion.rs:44:9 | LL | self.ne(other) | ^^^^^^^^^^^^^^ error: parameter is only used in recursion - --> $DIR/unconditional_recursion.rs:42:18 + --> tests/ui/unconditional_recursion.rs:42:18 | LL | fn ne(&self, other: &Self) -> bool { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_other` | note: parameter used here - --> $DIR/unconditional_recursion.rs:44:17 + --> tests/ui/unconditional_recursion.rs:44:17 | LL | self.ne(other) | ^^^^^ @@ -145,7 +145,7 @@ LL | self.ne(other) = help: to override `-D warnings` add `#[allow(clippy::only_used_in_recursion)]` error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:46:5 + --> tests/ui/unconditional_recursion.rs:46:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -154,25 +154,25 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:48:9 + --> tests/ui/unconditional_recursion.rs:48:9 | LL | self.eq(other) | ^^^^^^^^^^^^^^ error: parameter is only used in recursion - --> $DIR/unconditional_recursion.rs:46:18 + --> tests/ui/unconditional_recursion.rs:46:18 | LL | fn eq(&self, other: &Self) -> bool { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_other` | note: parameter used here - --> $DIR/unconditional_recursion.rs:48:17 + --> tests/ui/unconditional_recursion.rs:48:17 | LL | self.eq(other) | ^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:90:5 + --> tests/ui/unconditional_recursion.rs:90:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -181,13 +181,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:92:9 + --> tests/ui/unconditional_recursion.rs:92:9 | LL | other != self | ^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:94:5 + --> tests/ui/unconditional_recursion.rs:94:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -196,13 +196,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:96:9 + --> tests/ui/unconditional_recursion.rs:96:9 | LL | other == self | ^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:104:5 + --> tests/ui/unconditional_recursion.rs:104:5 | LL | / fn ne(&self, other: &Self) -> bool { LL | | @@ -211,13 +211,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:106:9 + --> tests/ui/unconditional_recursion.rs:106:9 | LL | other != other | ^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/unconditional_recursion.rs:106:9 + --> tests/ui/unconditional_recursion.rs:106:9 | LL | other != other | ^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL | other != other = note: `#[deny(clippy::eq_op)]` on by default error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:108:5 + --> tests/ui/unconditional_recursion.rs:108:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -234,19 +234,19 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:110:9 + --> tests/ui/unconditional_recursion.rs:110:9 | LL | other == other | ^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/unconditional_recursion.rs:110:9 + --> tests/ui/unconditional_recursion.rs:110:9 | LL | other == other | ^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:117:5 + --> tests/ui/unconditional_recursion.rs:117:5 | LL | / fn ne(&self, _other: &Self) -> bool { LL | | @@ -255,19 +255,19 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:119:9 + --> tests/ui/unconditional_recursion.rs:119:9 | LL | self != self | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/unconditional_recursion.rs:119:9 + --> tests/ui/unconditional_recursion.rs:119:9 | LL | self != self | ^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:121:5 + --> tests/ui/unconditional_recursion.rs:121:5 | LL | / fn eq(&self, _other: &Self) -> bool { LL | | @@ -276,21 +276,22 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:123:9 + --> tests/ui/unconditional_recursion.rs:123:9 | LL | self == self | ^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/unconditional_recursion.rs:123:9 + --> tests/ui/unconditional_recursion.rs:123:9 | LL | self == self | ^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:149:13 + --> tests/ui/unconditional_recursion.rs:149:13 | LL | / fn eq(&self, other: &Self) -> bool { +LL | | LL | | self == other LL | | } | |_____________^ @@ -299,7 +300,7 @@ LL | impl_partial_eq!(S5); | -------------------- in this macro invocation | note: recursive call site - --> $DIR/unconditional_recursion.rs:150:17 + --> tests/ui/unconditional_recursion.rs:151:17 | LL | self == other | ^^^^^^^^^^^^^ @@ -309,7 +310,7 @@ LL | impl_partial_eq!(S5); = note: this error originates in the macro `impl_partial_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:178:5 + --> tests/ui/unconditional_recursion.rs:178:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -320,13 +321,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:182:9 + --> tests/ui/unconditional_recursion.rs:182:9 | LL | mine == theirs | ^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:247:5 + --> tests/ui/unconditional_recursion.rs:247:5 | LL | / fn new() -> Self { LL | | @@ -335,13 +336,13 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:249:9 + --> tests/ui/unconditional_recursion.rs:249:9 | LL | Self::default() | ^^^^^^^^^^^^^^^ error: function cannot return without recursing - --> $DIR/unconditional_recursion.rs:286:5 + --> tests/ui/unconditional_recursion.rs:286:5 | LL | / fn eq(&self, other: &Self) -> bool { LL | | @@ -352,7 +353,7 @@ LL | | } | |_____^ | note: recursive call site - --> $DIR/unconditional_recursion.rs:290:9 + --> tests/ui/unconditional_recursion.rs:290:9 | LL | mine.eq(theirs) | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unicode.stderr b/src/tools/clippy/tests/ui/unicode.stderr index 0b6e20664e34c..9c365e1097dbc 100644 --- a/src/tools/clippy/tests/ui/unicode.stderr +++ b/src/tools/clippy/tests/ui/unicode.stderr @@ -1,5 +1,5 @@ error: invisible character detected - --> $DIR/unicode.rs:5:12 + --> tests/ui/unicode.rs:5:12 | LL | print!("Here >​< is a ZWS, and ​another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{200B}< is a ZWS, and \u{200B}another"` @@ -8,19 +8,19 @@ LL | print!("Here >​< is a ZWS, and ​another"); = help: to override `-D warnings` add `#[allow(clippy::invisible_characters)]` error: invisible character detected - --> $DIR/unicode.rs:7:12 + --> tests/ui/unicode.rs:7:12 | LL | print!("Here >­< is a SHY, and ­another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{AD}< is a SHY, and \u{AD}another"` error: invisible character detected - --> $DIR/unicode.rs:9:12 + --> tests/ui/unicode.rs:9:12 | LL | print!("Here >⁠< is a WJ, and ⁠another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"Here >\u{2060}< is a WJ, and \u{2060}another"` error: non-NFC Unicode sequence detected - --> $DIR/unicode.rs:15:12 + --> tests/ui/unicode.rs:15:12 | LL | print!("̀àh?"); | ^^^^^ help: consider replacing the string with: `"̀àh?"` @@ -29,37 +29,37 @@ LL | print!("̀àh?"); = help: to override `-D warnings` add `#[allow(clippy::unicode_not_nfc)]` error: literal non-ASCII character detected - --> $DIR/unicode.rs:23:16 + --> tests/ui/unicode.rs:23:16 | LL | print!("Üben!"); | ^^^^^^^ help: consider replacing the string with: `"\u{dc}ben!"` | note: the lint level is defined here - --> $DIR/unicode.rs:20:13 + --> tests/ui/unicode.rs:20:13 | LL | #![deny(clippy::non_ascii_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: literal non-ASCII character detected - --> $DIR/unicode.rs:29:36 + --> tests/ui/unicode.rs:29:36 | LL | const _EMPTY_BLOCK: char = '▱'; | ^^^ help: consider replacing the string with: `'\u{25b1}'` error: literal non-ASCII character detected - --> $DIR/unicode.rs:30:35 + --> tests/ui/unicode.rs:30:35 | LL | const _FULL_BLOCK: char = '▰'; | ^^^ help: consider replacing the string with: `'\u{25b0}'` error: literal non-ASCII character detected - --> $DIR/unicode.rs:50:21 + --> tests/ui/unicode.rs:50:21 | LL | let _ = "悲しいかな、ここに日本語を書くことはできない。"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing the string with: `"\u{60b2}\u{3057}\u{3044}\u{304b}\u{306a}\u{3001}\u{3053}\u{3053}\u{306b}\u{65e5}\u{672c}\u{8a9e}\u{3092}\u{66f8}\u{304f}\u{3053}\u{3068}\u{306f}\u{3067}\u{304d}\u{306a}\u{3044}\u{3002}"` | note: the lint level is defined here - --> $DIR/unicode.rs:39:17 + --> tests/ui/unicode.rs:39:17 | LL | #![deny(clippy::non_ascii_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/uninhabited_references.stderr b/src/tools/clippy/tests/ui/uninhabited_references.stderr index 2cdf320b8092f..446d4e7555703 100644 --- a/src/tools/clippy/tests/ui/uninhabited_references.stderr +++ b/src/tools/clippy/tests/ui/uninhabited_references.stderr @@ -1,5 +1,5 @@ error: dereferencing a reference to an uninhabited type would be undefined behavior - --> $DIR/uninhabited_references.rs:4:23 + --> tests/ui/uninhabited_references.rs:4:23 | LL | fn ret_uninh_ref() -> &'static std::convert::Infallible { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn ret_uninh_ref() -> &'static std::convert::Infallible { = help: to override `-D warnings` add `#[allow(clippy::uninhabited_references)]` error: dereferencing a reference to an uninhabited type would be undefined behavior - --> $DIR/uninhabited_references.rs:10:30 + --> tests/ui/uninhabited_references.rs:10:30 | LL | fn $name(x: &$ty) -> &$ty { | ^^^^ @@ -19,7 +19,7 @@ LL | ret_something!(id_never, !); = note: this error originates in the macro `ret_something` (in Nightly builds, run with -Z macro-backtrace for more info) error: dereferencing a reference to an uninhabited type is undefined behavior - --> $DIR/uninhabited_references.rs:11:14 + --> tests/ui/uninhabited_references.rs:11:14 | LL | &*x | ^^ @@ -30,7 +30,7 @@ LL | ret_something!(id_never, !); = note: this error originates in the macro `ret_something` (in Nightly builds, run with -Z macro-backtrace for more info) error: dereferencing a reference to an uninhabited type is undefined behavior - --> $DIR/uninhabited_references.rs:21:13 + --> tests/ui/uninhabited_references.rs:21:13 | LL | let _ = *x; | ^^ diff --git a/src/tools/clippy/tests/ui/uninit.stderr b/src/tools/clippy/tests/ui/uninit.stderr index 1cc27ffe70d5d..81577fe3fd477 100644 --- a/src/tools/clippy/tests/ui/uninit.stderr +++ b/src/tools/clippy/tests/ui/uninit.stderr @@ -1,5 +1,5 @@ error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:12:29 + --> tests/ui/uninit.rs:12:29 | LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; = note: `#[deny(clippy::uninit_assumed_init)]` on by default error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:35:29 + --> tests/ui/uninit.rs:35:29 | LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call for this type may be undefined behavior - --> $DIR/uninit.rs:44:29 + --> tests/ui/uninit.rs:44:29 | LL | let _: T = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/uninit_vec.stderr b/src/tools/clippy/tests/ui/uninit_vec.stderr index d39f05839ed90..8e93466c2cc84 100644 --- a/src/tools/clippy/tests/ui/uninit_vec.stderr +++ b/src/tools/clippy/tests/ui/uninit_vec.stderr @@ -1,5 +1,5 @@ error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:17:5 + --> tests/ui/uninit_vec.rs:17:5 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | vec.set_len(200); = 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 + --> tests/ui/uninit_vec.rs:24:5 | LL | vec.reserve(1000); | ^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` on empty `Vec` creates out-of-bound values - --> $DIR/uninit_vec.rs:31:5 + --> tests/ui/uninit_vec.rs:31:5 | LL | let mut vec: Vec = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ error: calling `set_len()` on empty `Vec` creates out-of-bound values - --> $DIR/uninit_vec.rs:38:5 + --> tests/ui/uninit_vec.rs:38:5 | LL | let mut vec: Vec = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ error: calling `set_len()` on empty `Vec` creates out-of-bound values - --> $DIR/uninit_vec.rs:44:5 + --> tests/ui/uninit_vec.rs:44:5 | LL | let mut vec: Vec = Vec::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | vec.set_len(200); | ^^^^^^^^^^^^^^^^ error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:61:5 + --> tests/ui/uninit_vec.rs:61:5 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:71:5 + --> tests/ui/uninit_vec.rs:71:5 | LL | my_vec.vec.reserve(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | my_vec.vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:77:5 + --> tests/ui/uninit_vec.rs:77:5 | LL | my_vec.vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL | my_vec.vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:52:9 + --> tests/ui/uninit_vec.rs:52:9 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,7 +94,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:56:9 + --> tests/ui/uninit_vec.rs:56:9 | LL | vec.reserve(1000); | ^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | vec.set_len(200); = help: initialize the buffer or wrap the content in `MaybeUninit` error: calling `set_len()` immediately after reserving a buffer creates uninitialized values - --> $DIR/uninit_vec.rs:132:9 + --> tests/ui/uninit_vec.rs:132:9 | LL | let mut vec: Vec = Vec::with_capacity(1000); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/uninlined_format_args.stderr b/src/tools/clippy/tests/ui/uninlined_format_args.stderr index 829d646b86692..5a7ff3bc4f5aa 100644 --- a/src/tools/clippy/tests/ui/uninlined_format_args.stderr +++ b/src/tools/clippy/tests/ui/uninlined_format_args.stderr @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:45:5 + --> tests/ui/uninlined_format_args.rs:45:5 | LL | println!("val='{}'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:46:5 + --> tests/ui/uninlined_format_args.rs:46:5 | LL | println!("val='{ }'", local_i32); // 3 spaces | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("val='{local_i32}'"); // 3 spaces | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:47:5 + --> tests/ui/uninlined_format_args.rs:47:5 | LL | println!("val='{ }'", local_i32); // tab | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("val='{local_i32}'"); // tab | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:48:5 + --> tests/ui/uninlined_format_args.rs:48:5 | LL | println!("val='{ }'", local_i32); // space+tab | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("val='{local_i32}'"); // space+tab | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:49:5 + --> tests/ui/uninlined_format_args.rs:49:5 | LL | println!("val='{ }'", local_i32); // tab+space | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!("val='{local_i32}'"); // tab+space | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:50:5 + --> tests/ui/uninlined_format_args.rs:50:5 | LL | / println!( LL | | "val='{ @@ -71,7 +71,7 @@ LL | | ); | |_____^ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:55:5 + --> tests/ui/uninlined_format_args.rs:55:5 | LL | println!("{}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL + println!("{local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:56:5 + --> tests/ui/uninlined_format_args.rs:56:5 | LL | println!("{}", fn_arg); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL + println!("{fn_arg}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:57:5 + --> tests/ui/uninlined_format_args.rs:57:5 | LL | println!("{:?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -107,7 +107,7 @@ LL + println!("{local_i32:?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:58:5 + --> tests/ui/uninlined_format_args.rs:58:5 | LL | println!("{:#?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL + println!("{local_i32:#?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:59:5 + --> tests/ui/uninlined_format_args.rs:59:5 | LL | println!("{:4}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL + println!("{local_i32:4}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:60:5 + --> tests/ui/uninlined_format_args.rs:60:5 | LL | println!("{:04}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -143,7 +143,7 @@ LL + println!("{local_i32:04}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:61:5 + --> tests/ui/uninlined_format_args.rs:61:5 | LL | println!("{:<3}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + println!("{local_i32:<3}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:62:5 + --> tests/ui/uninlined_format_args.rs:62:5 | LL | println!("{:#010x}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL + println!("{local_i32:#010x}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:63:5 + --> tests/ui/uninlined_format_args.rs:63:5 | LL | println!("{:.1}", local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -179,7 +179,7 @@ LL + println!("{local_f64:.1}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:67:5 + --> tests/ui/uninlined_format_args.rs:67:5 | LL | println!("{} {}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -191,7 +191,7 @@ LL + println!("{local_i32} {local_f64}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:69:5 + --> tests/ui/uninlined_format_args.rs:69:5 | LL | println!("{}", val); | ^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL + println!("{val}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:70:5 + --> tests/ui/uninlined_format_args.rs:70:5 | LL | println!("{}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -215,7 +215,7 @@ LL + println!("{val}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:72:5 + --> tests/ui/uninlined_format_args.rs:72:5 | LL | println!("val='{\t }'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -227,7 +227,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:73:5 + --> tests/ui/uninlined_format_args.rs:73:5 | LL | println!("val='{\n }'", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -239,7 +239,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:74:5 + --> tests/ui/uninlined_format_args.rs:74:5 | LL | println!("val='{local_i32}'", local_i32 = local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -251,7 +251,7 @@ LL + println!("val='{local_i32}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:75:5 + --> tests/ui/uninlined_format_args.rs:75:5 | LL | println!("val='{local_i32}'", local_i32 = fn_arg); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL + println!("val='{fn_arg}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:76:5 + --> tests/ui/uninlined_format_args.rs:76:5 | LL | println!("{0}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -275,7 +275,7 @@ LL + println!("{local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:77:5 + --> tests/ui/uninlined_format_args.rs:77:5 | LL | println!("{0:?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -287,7 +287,7 @@ LL + println!("{local_i32:?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:78:5 + --> tests/ui/uninlined_format_args.rs:78:5 | LL | println!("{0:#?}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -299,7 +299,7 @@ LL + println!("{local_i32:#?}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:79:5 + --> tests/ui/uninlined_format_args.rs:79:5 | LL | println!("{0:04}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -311,7 +311,7 @@ LL + println!("{local_i32:04}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:80:5 + --> tests/ui/uninlined_format_args.rs:80:5 | LL | println!("{0:<3}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -323,7 +323,7 @@ LL + println!("{local_i32:<3}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:81:5 + --> tests/ui/uninlined_format_args.rs:81:5 | LL | println!("{0:#010x}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -335,7 +335,7 @@ LL + println!("{local_i32:#010x}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:82:5 + --> tests/ui/uninlined_format_args.rs:82:5 | LL | println!("{0:.1}", local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -347,7 +347,7 @@ LL + println!("{local_f64:.1}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:83:5 + --> tests/ui/uninlined_format_args.rs:83:5 | LL | println!("{0} {0}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -359,7 +359,7 @@ LL + println!("{local_i32} {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:84:5 + --> tests/ui/uninlined_format_args.rs:84:5 | LL | println!("{1} {} {0} {}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL + println!("{local_f64} {local_i32} {local_i32} {local_f64}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:85:5 + --> tests/ui/uninlined_format_args.rs:85:5 | LL | println!("{0} {1}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -383,7 +383,7 @@ LL + println!("{local_i32} {local_f64}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:86:5 + --> tests/ui/uninlined_format_args.rs:86:5 | LL | println!("{1} {0}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -395,7 +395,7 @@ LL + println!("{local_f64} {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:87:5 + --> tests/ui/uninlined_format_args.rs:87:5 | LL | println!("{1} {0} {1} {0}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -407,7 +407,7 @@ LL + println!("{local_f64} {local_i32} {local_f64} {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:89:5 + --> tests/ui/uninlined_format_args.rs:89:5 | LL | println!("{v}", v = local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -419,7 +419,7 @@ LL + println!("{local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:90:5 + --> tests/ui/uninlined_format_args.rs:90:5 | LL | println!("{local_i32:0$}", width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -431,7 +431,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:91:5 + --> tests/ui/uninlined_format_args.rs:91:5 | LL | println!("{local_i32:w$}", w = width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -443,7 +443,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:92:5 + --> tests/ui/uninlined_format_args.rs:92:5 | LL | println!("{local_i32:.0$}", prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -455,7 +455,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:93:5 + --> tests/ui/uninlined_format_args.rs:93:5 | LL | println!("{local_i32:.p$}", p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -467,7 +467,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:94:5 + --> tests/ui/uninlined_format_args.rs:94:5 | LL | println!("{:0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -479,7 +479,7 @@ LL + println!("{val:val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:95:5 + --> tests/ui/uninlined_format_args.rs:95:5 | LL | println!("{0:0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -491,7 +491,7 @@ LL + println!("{val:val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:96:5 + --> tests/ui/uninlined_format_args.rs:96:5 | LL | println!("{:0$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -503,7 +503,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:97:5 + --> tests/ui/uninlined_format_args.rs:97:5 | LL | println!("{0:0$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -515,7 +515,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:98:5 + --> tests/ui/uninlined_format_args.rs:98:5 | LL | println!("{0:0$.v$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -527,7 +527,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:99:5 + --> tests/ui/uninlined_format_args.rs:99:5 | LL | println!("{0:v$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -539,7 +539,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:100:5 + --> tests/ui/uninlined_format_args.rs:100:5 | LL | println!("{v:0$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -551,7 +551,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:101:5 + --> tests/ui/uninlined_format_args.rs:101:5 | LL | println!("{v:v$.0$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -563,7 +563,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:102:5 + --> tests/ui/uninlined_format_args.rs:102:5 | LL | println!("{v:0$.v$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -575,7 +575,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:103:5 + --> tests/ui/uninlined_format_args.rs:103:5 | LL | println!("{v:v$.v$}", v = val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -587,7 +587,7 @@ LL + println!("{val:val$.val$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:104:5 + --> tests/ui/uninlined_format_args.rs:104:5 | LL | println!("{:0$}", width); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -599,7 +599,7 @@ LL + println!("{width:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:105:5 + --> tests/ui/uninlined_format_args.rs:105:5 | LL | println!("{:1$}", local_i32, width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -611,7 +611,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:106:5 + --> tests/ui/uninlined_format_args.rs:106:5 | LL | println!("{:w$}", w = width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -623,7 +623,7 @@ LL + println!("{width:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:107:5 + --> tests/ui/uninlined_format_args.rs:107:5 | LL | println!("{:w$}", local_i32, w = width); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -635,7 +635,7 @@ LL + println!("{local_i32:width$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:108:5 + --> tests/ui/uninlined_format_args.rs:108:5 | LL | println!("{:.0$}", prec); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -647,7 +647,7 @@ LL + println!("{prec:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:109:5 + --> tests/ui/uninlined_format_args.rs:109:5 | LL | println!("{:.1$}", local_i32, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -659,7 +659,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:110:5 + --> tests/ui/uninlined_format_args.rs:110:5 | LL | println!("{:.p$}", p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -671,7 +671,7 @@ LL + println!("{prec:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:111:5 + --> tests/ui/uninlined_format_args.rs:111:5 | LL | println!("{:.p$}", local_i32, p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -683,7 +683,7 @@ LL + println!("{local_i32:.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:112:5 + --> tests/ui/uninlined_format_args.rs:112:5 | LL | println!("{:0$.1$}", width, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -695,7 +695,7 @@ LL + println!("{width:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:113:5 + --> tests/ui/uninlined_format_args.rs:113:5 | LL | println!("{:0$.w$}", width, w = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -707,7 +707,7 @@ LL + println!("{width:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:114:5 + --> tests/ui/uninlined_format_args.rs:114:5 | LL | println!("{:1$.2$}", local_f64, width, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -719,7 +719,7 @@ LL + println!("{local_f64:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:115:5 + --> tests/ui/uninlined_format_args.rs:115:5 | LL | println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -731,7 +731,7 @@ LL + println!("{local_f64:width$.prec$} {local_f64} {width} {prec}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:116:5 + --> tests/ui/uninlined_format_args.rs:116:5 | LL | / println!( LL | | "{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$}", @@ -740,7 +740,7 @@ LL | | ); | |_____^ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:127:5 + --> tests/ui/uninlined_format_args.rs:127:5 | LL | println!("Width = {}, value with width = {:0$}", local_i32, local_f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -752,7 +752,7 @@ LL + println!("Width = {local_i32}, value with width = {local_f64:local_i32$ | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:128:5 + --> tests/ui/uninlined_format_args.rs:128:5 | LL | println!("{:w$.p$}", local_i32, w = width, p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -764,7 +764,7 @@ LL + println!("{local_i32:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:129:5 + --> tests/ui/uninlined_format_args.rs:129:5 | LL | println!("{:w$.p$}", w = width, p = prec); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -776,7 +776,7 @@ LL + println!("{width:width$.prec$}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:148:5 + --> tests/ui/uninlined_format_args.rs:148:5 | LL | / println!( LL | | "{}", @@ -786,7 +786,7 @@ LL | | ); | |_____^ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:153:5 + --> tests/ui/uninlined_format_args.rs:153:5 | LL | println!("{}", /* comment with a comma , in it */ val); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -798,7 +798,7 @@ LL + println!("{val}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:159:9 + --> tests/ui/uninlined_format_args.rs:159:9 | LL | panic!("p1 {}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -810,7 +810,7 @@ LL + panic!("p1 {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:162:9 + --> tests/ui/uninlined_format_args.rs:162:9 | LL | panic!("p2 {0}", local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -822,7 +822,7 @@ LL + panic!("p2 {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:165:9 + --> tests/ui/uninlined_format_args.rs:165:9 | LL | panic!("p3 {local_i32}", local_i32 = local_i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -834,7 +834,7 @@ LL + panic!("p3 {local_i32}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args.rs:185:5 + --> tests/ui/uninlined_format_args.rs:185:5 | LL | println!("expand='{}'", 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 736a68ab1c7e3..0541dd9a7d7bc 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 @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:10:5 + --> tests/ui/uninlined_format_args_panic.rs:10:5 | 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 ec1e3a1cf1178..3615eaa9dee37 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 @@ -1,5 +1,5 @@ error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:10:5 + --> tests/ui/uninlined_format_args_panic.rs:10:5 | LL | println!("val='{}'", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + println!("val='{var}'"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:13:9 + --> tests/ui/uninlined_format_args_panic.rs:13:9 | LL | panic!("p1 {}", var); | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + panic!("p1 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:16:9 + --> tests/ui/uninlined_format_args_panic.rs:16:9 | LL | panic!("p2 {0}", var); | ^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + panic!("p2 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:19:9 + --> tests/ui/uninlined_format_args_panic.rs:19:9 | LL | panic!("p3 {var}", var = var); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + panic!("p3 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:29:5 + --> tests/ui/uninlined_format_args_panic.rs:29:5 | LL | assert!(var == 1, "p5 {}", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + assert!(var == 1, "p5 {var}"); | error: variables can be used directly in the `format!` string - --> $DIR/uninlined_format_args_panic.rs:30:5 + --> tests/ui/uninlined_format_args_panic.rs:30:5 | LL | debug_assert!(var == 1, "p6 {}", var); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unit_arg.stderr b/src/tools/clippy/tests/ui/unit_arg.stderr index 8656c8fddabc3..41ad1a2d3834f 100644 --- a/src/tools/clippy/tests/ui/unit_arg.stderr +++ b/src/tools/clippy/tests/ui/unit_arg.stderr @@ -1,5 +1,5 @@ error: passing a unit value to a function - --> $DIR/unit_arg.rs:63:5 + --> tests/ui/unit_arg.rs:63:5 | LL | / foo({ LL | | 1; @@ -21,7 +21,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:66:5 + --> tests/ui/unit_arg.rs:66:5 | LL | foo(foo(1)); | ^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:67:5 + --> tests/ui/unit_arg.rs:67:5 | LL | / foo({ LL | | foo(1); @@ -55,7 +55,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:72:5 + --> tests/ui/unit_arg.rs:72:5 | LL | / b.bar({ LL | | 1; @@ -75,7 +75,7 @@ LL ~ b.bar(()); | error: passing unit values to a function - --> $DIR/unit_arg.rs:75:5 + --> tests/ui/unit_arg.rs:75:5 | LL | taking_multiple_units(foo(0), foo(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL ~ taking_multiple_units((), ()); | error: passing unit values to a function - --> $DIR/unit_arg.rs:76:5 + --> tests/ui/unit_arg.rs:76:5 | LL | / taking_multiple_units(foo(0), { LL | | foo(1); @@ -111,7 +111,7 @@ LL ~ taking_multiple_units((), ()); | error: passing unit values to a function - --> $DIR/unit_arg.rs:80:5 + --> tests/ui/unit_arg.rs:80:5 | LL | / taking_multiple_units( LL | | { @@ -147,7 +147,7 @@ LL ~ ); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:91:13 + --> tests/ui/unit_arg.rs:91:13 | LL | None.or(Some(foo(2))); | ^^^^^^^^^^^^ @@ -161,7 +161,7 @@ LL ~ }); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:94:5 + --> tests/ui/unit_arg.rs:94:5 | LL | foo(foo(())); | ^^^^^^^^^^^^ @@ -173,7 +173,7 @@ LL ~ foo(()); | error: passing a unit value to a function - --> $DIR/unit_arg.rs:131:5 + --> tests/ui/unit_arg.rs:131:5 | LL | Some(foo(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 b207acb5927d5..d971195dda265 100644 --- a/src/tools/clippy/tests/ui/unit_arg_empty_blocks.stderr +++ b/src/tools/clippy/tests/ui/unit_arg_empty_blocks.stderr @@ -1,5 +1,5 @@ error: passing a unit value to a function - --> $DIR/unit_arg_empty_blocks.rs:16:5 + --> tests/ui/unit_arg_empty_blocks.rs:16:5 | LL | foo({}); | ^^^^--^ @@ -10,7 +10,7 @@ LL | foo({}); = 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 + --> tests/ui/unit_arg_empty_blocks.rs:17:5 | LL | foo3({}, 2, 2); | ^^^^^--^^^^^^^ @@ -18,7 +18,7 @@ LL | foo3({}, 2, 2); | help: use a unit literal instead: `()` error: passing unit values to a function - --> $DIR/unit_arg_empty_blocks.rs:18:5 + --> tests/ui/unit_arg_empty_blocks.rs:18:5 | LL | taking_two_units({}, foo(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL ~ taking_two_units((), ()); | error: passing unit values to a function - --> $DIR/unit_arg_empty_blocks.rs:19:5 + --> tests/ui/unit_arg_empty_blocks.rs:19:5 | LL | taking_three_units({}, foo(0), foo(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unit_cmp.stderr b/src/tools/clippy/tests/ui/unit_cmp.stderr index 17355e2379785..f9473d3be2627 100644 --- a/src/tools/clippy/tests/ui/unit_cmp.stderr +++ b/src/tools/clippy/tests/ui/unit_cmp.stderr @@ -1,5 +1,5 @@ error: ==-comparison of unit values detected. This will always be true - --> $DIR/unit_cmp.rs:17:8 + --> tests/ui/unit_cmp.rs:17:8 | LL | if { | ________^ @@ -15,7 +15,7 @@ LL | | } {} = 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 + --> tests/ui/unit_cmp.rs:25:8 | LL | if { | ________^ @@ -27,7 +27,7 @@ LL | | } {} | |_____^ error: `assert_eq` of unit values detected. This will always succeed - --> $DIR/unit_cmp.rs:32:5 + --> tests/ui/unit_cmp.rs:32:5 | LL | / assert_eq!( LL | | @@ -39,7 +39,7 @@ LL | | ); | |_____^ error: `debug_assert_eq` of unit values detected. This will always succeed - --> $DIR/unit_cmp.rs:41:5 + --> tests/ui/unit_cmp.rs:41:5 | LL | / debug_assert_eq!( LL | | @@ -51,7 +51,7 @@ LL | | ); | |_____^ error: `assert_ne` of unit values detected. This will always fail - --> $DIR/unit_cmp.rs:51:5 + --> tests/ui/unit_cmp.rs:51:5 | LL | / assert_ne!( LL | | @@ -63,7 +63,7 @@ LL | | ); | |_____^ error: `debug_assert_ne` of unit values detected. This will always fail - --> $DIR/unit_cmp.rs:60:5 + --> tests/ui/unit_cmp.rs:60:5 | LL | / debug_assert_ne!( LL | | diff --git a/src/tools/clippy/tests/ui/unit_hash.stderr b/src/tools/clippy/tests/ui/unit_hash.stderr index a26fd734413c1..b48f3a543b763 100644 --- a/src/tools/clippy/tests/ui/unit_hash.stderr +++ b/src/tools/clippy/tests/ui/unit_hash.stderr @@ -1,5 +1,5 @@ error: this call to `hash` on the unit type will do nothing - --> $DIR/unit_hash.rs:19:23 + --> tests/ui/unit_hash.rs:19:23 | LL | Foo::Empty => ().hash(&mut state), | ^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` @@ -9,7 +9,7 @@ LL | Foo::Empty => ().hash(&mut state), = 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 + --> tests/ui/unit_hash.rs:26:5 | LL | res.hash(&mut state); | ^^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` @@ -17,7 +17,7 @@ LL | res.hash(&mut state); = note: the implementation of `Hash` for `()` is a no-op error: this call to `hash` on the unit type will do nothing - --> $DIR/unit_hash.rs:31:5 + --> tests/ui/unit_hash.rs:31:5 | LL | do_nothing().hash(&mut state); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` 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 9220fb89e901e..b2fc885701582 100644 --- a/src/tools/clippy/tests/ui/unit_return_expecting_ord.stderr +++ b/src/tools/clippy/tests/ui/unit_return_expecting_ord.stderr @@ -1,11 +1,11 @@ error: this closure returns the unit type which also implements Ord - --> $DIR/unit_return_expecting_ord.rs:19:25 + --> tests/ui/unit_return_expecting_ord.rs:19:25 | LL | structs.sort_by_key(|s| { | ^^^ | help: probably caused by this trailing semicolon - --> $DIR/unit_return_expecting_ord.rs:21:24 + --> tests/ui/unit_return_expecting_ord.rs:21:24 | LL | double(s.field); | ^ @@ -13,25 +13,25 @@ LL | double(s.field); = 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 + --> tests/ui/unit_return_expecting_ord.rs:24:30 | LL | structs.is_sorted_by_key(|s| { | ^^^ | help: probably caused by this trailing semicolon - --> $DIR/unit_return_expecting_ord.rs:26:24 + --> tests/ui/unit_return_expecting_ord.rs:26:24 | LL | double(s.field); | ^ error: this closure returns the unit type which also implements PartialOrd - --> $DIR/unit_return_expecting_ord.rs:28:30 + --> tests/ui/unit_return_expecting_ord.rs:28:30 | LL | structs.is_sorted_by_key(|s| { | ^^^ error: this closure returns the unit type which also implements Ord - --> $DIR/unit_return_expecting_ord.rs:39:25 + --> tests/ui/unit_return_expecting_ord.rs:39:25 | LL | structs.sort_by_key(|s| unit(s.field)); | ^^^ diff --git a/src/tools/clippy/tests/ui/unknown_attribute.stderr b/src/tools/clippy/tests/ui/unknown_attribute.stderr index edad35d1591be..d1f8eeb51aeac 100644 --- a/src/tools/clippy/tests/ui/unknown_attribute.stderr +++ b/src/tools/clippy/tests/ui/unknown_attribute.stderr @@ -1,5 +1,5 @@ error: usage of unknown attribute - --> $DIR/unknown_attribute.rs:1:11 + --> tests/ui/unknown_attribute.rs:1:11 | LL | #[clippy::unknown] | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr b/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr index 432c7f72e32ed..aa2c2f3c0e202 100644 --- a/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr +++ b/src/tools/clippy/tests/ui/unknown_clippy_lints.stderr @@ -1,5 +1,5 @@ error: unknown lint: `clippy::All` - --> $DIR/unknown_clippy_lints.rs:3:10 + --> tests/ui/unknown_clippy_lints.rs:3:10 | LL | #![allow(clippy::All)] | ^^^^^^^^^^^ help: did you mean: `clippy::all` @@ -8,31 +8,31 @@ LL | #![allow(clippy::All)] = help: to override `-D warnings` add `#[allow(unknown_lints)]` error: unknown lint: `clippy::CMP_OWNED` - --> $DIR/unknown_clippy_lints.rs:4:9 + --> tests/ui/unknown_clippy_lints.rs:4:9 | LL | #![warn(clippy::CMP_OWNED)] | ^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::cmp_owned` error: unknown lint: `clippy::if_not_els` - --> $DIR/unknown_clippy_lints.rs:7:8 + --> tests/ui/unknown_clippy_lints.rs:7:8 | LL | #[warn(clippy::if_not_els)] | ^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::if_not_else` error: unknown lint: `clippy::UNNecsaRy_cAst` - --> $DIR/unknown_clippy_lints.rs:8:8 + --> tests/ui/unknown_clippy_lints.rs:8:8 | LL | #[warn(clippy::UNNecsaRy_cAst)] | ^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unnecessary_cast` error: unknown lint: `clippy::useles_transute` - --> $DIR/unknown_clippy_lints.rs:9:8 + --> tests/ui/unknown_clippy_lints.rs:9:8 | LL | #[warn(clippy::useles_transute)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::useless_transmute` error: unknown lint: `clippy::dead_cod` - --> $DIR/unknown_clippy_lints.rs:11:8 + --> tests/ui/unknown_clippy_lints.rs:11:8 | LL | #[warn(clippy::dead_cod)] | ^^^^^^^^^^^^^^^^ @@ -43,19 +43,19 @@ LL | #[warn(dead_code)] | ~~~~~~~~~ error: unknown lint: `clippy::unused_colle` - --> $DIR/unknown_clippy_lints.rs:13:8 + --> tests/ui/unknown_clippy_lints.rs:13:8 | LL | #[warn(clippy::unused_colle)] | ^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unused_self` error: unknown lint: `clippy::const_static_lifetim` - --> $DIR/unknown_clippy_lints.rs:15:8 + --> tests/ui/unknown_clippy_lints.rs:15:8 | LL | #[warn(clippy::const_static_lifetim)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::redundant_static_lifetimes` error: unknown lint: `clippy::missing_docs` - --> $DIR/unknown_clippy_lints.rs:17:8 + --> tests/ui/unknown_clippy_lints.rs:17:8 | LL | #[warn(clippy::missing_docs)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr b/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr index 944e911fa944e..cb88ba1b0016d 100644 --- a/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_box_returns.stderr @@ -1,5 +1,5 @@ error: boxed return of the sized type `usize` - --> $DIR/unnecessary_box_returns.rs:5:22 + --> tests/ui/unnecessary_box_returns.rs:5:22 | LL | fn baz(&self) -> Box; | ^^^^^^^^^^ help: try: `usize` @@ -9,7 +9,7 @@ LL | fn baz(&self) -> Box; = 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 + --> tests/ui/unnecessary_box_returns.rs:19:22 | LL | fn baz(&self) -> Box { | ^^^^^^^^^^ help: try: `usize` @@ -17,7 +17,7 @@ LL | fn baz(&self) -> Box { = help: changing this also requires a change to the return expressions in this function error: boxed return of the sized type `usize` - --> $DIR/unnecessary_box_returns.rs:27:20 + --> tests/ui/unnecessary_box_returns.rs:27:20 | LL | fn bxed_usize() -> Box { | ^^^^^^^^^^ help: try: `usize` @@ -25,7 +25,7 @@ LL | fn bxed_usize() -> Box { = help: changing this also requires a change to the return expressions in this function error: boxed return of the sized type `Foo` - --> $DIR/unnecessary_box_returns.rs:33:19 + --> tests/ui/unnecessary_box_returns.rs:33:19 | LL | fn _bxed_foo() -> Box { | ^^^^^^^^ help: try: `Foo` diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.fixed b/src/tools/clippy/tests/ui/unnecessary_cast.fixed index 18dd53bf2b42c..f52d325033987 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast.fixed +++ b/src/tools/clippy/tests/ui/unnecessary_cast.fixed @@ -2,6 +2,7 @@ #![warn(clippy::unnecessary_cast)] #![allow( clippy::borrow_as_ptr, + clippy::multiple_bound_locations, clippy::no_effect, clippy::nonstandard_macro_braces, clippy::unnecessary_operation, diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.rs b/src/tools/clippy/tests/ui/unnecessary_cast.rs index fcdd4c60ccd01..dfd8b454e6cca 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast.rs +++ b/src/tools/clippy/tests/ui/unnecessary_cast.rs @@ -2,6 +2,7 @@ #![warn(clippy::unnecessary_cast)] #![allow( clippy::borrow_as_ptr, + clippy::multiple_bound_locations, clippy::no_effect, clippy::nonstandard_macro_braces, clippy::unnecessary_operation, diff --git a/src/tools/clippy/tests/ui/unnecessary_cast.stderr b/src/tools/clippy/tests/ui/unnecessary_cast.stderr index d4786f66e4476..935bb71da32bd 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_cast.stderr @@ -1,5 +1,5 @@ error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`) - --> $DIR/unnecessary_cast.rs:18:5 + --> tests/ui/unnecessary_cast.rs:19:5 | LL | ptr as *const T | ^^^^^^^^^^^^^^^ help: try: `ptr` @@ -8,235 +8,235 @@ LL | ptr as *const T = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:53:5 + --> tests/ui/unnecessary_cast.rs:54:5 | LL | 1i32 as i32; | ^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:54:5 + --> tests/ui/unnecessary_cast.rs:55:5 | LL | 1f32 as f32; | ^^^^^^^^^^^ help: try: `1_f32` error: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/unnecessary_cast.rs:55:5 + --> tests/ui/unnecessary_cast.rs:56:5 | LL | false as bool; | ^^^^^^^^^^^^^ help: try: `false` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:58:5 + --> tests/ui/unnecessary_cast.rs:59:5 | LL | -1_i32 as i32; | ^^^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:59:5 + --> tests/ui/unnecessary_cast.rs:60:5 | LL | - 1_i32 as i32; | ^^^^^^^^^^^^^^ help: try: `- 1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:60:5 + --> tests/ui/unnecessary_cast.rs:61:5 | LL | -1f32 as f32; | ^^^^^^^^^^^^ help: try: `-1_f32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:61:5 + --> tests/ui/unnecessary_cast.rs:62:5 | LL | 1_i32 as i32; | ^^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:62:5 + --> tests/ui/unnecessary_cast.rs:63:5 | LL | 1_f32 as f32; | ^^^^^^^^^^^^ help: try: `1_f32` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:64:22 + --> tests/ui/unnecessary_cast.rs:65:22 | LL | let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:66:5 + --> tests/ui/unnecessary_cast.rs:67:5 | LL | [1u8, 2].as_ptr() as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`) - --> $DIR/unnecessary_cast.rs:68:5 + --> tests/ui/unnecessary_cast.rs:69:5 | LL | [1u8, 2].as_mut_ptr() as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_mut_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) - --> $DIR/unnecessary_cast.rs:79:5 + --> tests/ui/unnecessary_cast.rs:80:5 | LL | owo::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `owo::([1u32].as_ptr())` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast.rs:80:5 + --> tests/ui/unnecessary_cast.rs:81:5 | LL | uwu::([1u32].as_ptr()) as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) - --> $DIR/unnecessary_cast.rs:82:5 + --> tests/ui/unnecessary_cast.rs:83:5 | LL | uwu::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` error: casting to the same type is unnecessary (`u32` -> `u32`) - --> $DIR/unnecessary_cast.rs:117:5 + --> tests/ui/unnecessary_cast.rs:118:5 | LL | aaa() as u32; | ^^^^^^^^^^^^ help: try: `aaa()` error: casting to the same type is unnecessary (`u32` -> `u32`) - --> $DIR/unnecessary_cast.rs:119:5 + --> tests/ui/unnecessary_cast.rs:120:5 | LL | aaa() as u32; | ^^^^^^^^^^^^ help: try: `aaa()` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:155:9 + --> tests/ui/unnecessary_cast.rs:156:9 | LL | 100 as f32; | ^^^^^^^^^^ help: try: `100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:156:9 + --> tests/ui/unnecessary_cast.rs:157:9 | LL | 100 as f64; | ^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:157:9 + --> tests/ui/unnecessary_cast.rs:158:9 | LL | 100_i32 as f64; | ^^^^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:158:17 + --> tests/ui/unnecessary_cast.rs:159:17 | LL | let _ = -100 as f32; | ^^^^^^^^^^^ help: try: `-100_f32` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:159:17 + --> tests/ui/unnecessary_cast.rs:160:17 | LL | let _ = -100 as f64; | ^^^^^^^^^^^ help: try: `-100_f64` error: casting integer literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:160:17 + --> tests/ui/unnecessary_cast.rs:161:17 | LL | let _ = -100_i32 as f64; | ^^^^^^^^^^^^^^^ help: try: `-100_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:161:9 + --> tests/ui/unnecessary_cast.rs:162:9 | LL | 100. as f32; | ^^^^^^^^^^^ help: try: `100_f32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:162:9 + --> tests/ui/unnecessary_cast.rs:163:9 | LL | 100. as f64; | ^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:174:9 + --> tests/ui/unnecessary_cast.rs:175:9 | LL | 1 as u32; | ^^^^^^^^ help: try: `1_u32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:175:9 + --> tests/ui/unnecessary_cast.rs:176:9 | LL | 0x10 as i32; | ^^^^^^^^^^^ help: try: `0x10_i32` error: casting integer literal to `usize` is unnecessary - --> $DIR/unnecessary_cast.rs:176:9 + --> tests/ui/unnecessary_cast.rs:177:9 | LL | 0b10 as usize; | ^^^^^^^^^^^^^ help: try: `0b10_usize` error: casting integer literal to `u16` is unnecessary - --> $DIR/unnecessary_cast.rs:177:9 + --> tests/ui/unnecessary_cast.rs:178:9 | LL | 0o73 as u16; | ^^^^^^^^^^^ help: try: `0o73_u16` error: casting integer literal to `u32` is unnecessary - --> $DIR/unnecessary_cast.rs:178:9 + --> tests/ui/unnecessary_cast.rs:179:9 | LL | 1_000_000_000 as u32; | ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:180:9 + --> tests/ui/unnecessary_cast.rs:181:9 | LL | 1.0 as f64; | ^^^^^^^^^^ help: try: `1.0_f64` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:181:9 + --> tests/ui/unnecessary_cast.rs:182:9 | LL | 0.5 as f32; | ^^^^^^^^^^ help: try: `0.5_f32` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:185:17 + --> tests/ui/unnecessary_cast.rs:186:17 | LL | let _ = -1 as i32; | ^^^^^^^^^ help: try: `-1_i32` error: casting float literal to `f32` is unnecessary - --> $DIR/unnecessary_cast.rs:186:17 + --> tests/ui/unnecessary_cast.rs:187:17 | LL | let _ = -1.0 as f32; | ^^^^^^^^^^^ help: try: `-1.0_f32` error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/unnecessary_cast.rs:192:18 + --> tests/ui/unnecessary_cast.rs:193:18 | LL | let _ = &(x as i32); | ^^^^^^^^^^ help: try: `{ x }` error: casting integer literal to `i32` is unnecessary - --> $DIR/unnecessary_cast.rs:198:22 + --> tests/ui/unnecessary_cast.rs:199:22 | LL | let _: i32 = -(1) as i32; | ^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i64` is unnecessary - --> $DIR/unnecessary_cast.rs:200:22 + --> tests/ui/unnecessary_cast.rs:201:22 | LL | let _: i64 = -(1) as i64; | ^^^^^^^^^^^ help: try: `-1_i64` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:207:22 + --> tests/ui/unnecessary_cast.rs:208:22 | LL | let _: f64 = (-8.0 as f64).exp(); | ^^^^^^^^^^^^^ help: try: `(-8.0_f64)` error: casting float literal to `f64` is unnecessary - --> $DIR/unnecessary_cast.rs:209:23 + --> tests/ui/unnecessary_cast.rs:210:23 | LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior | ^^^^^^^^^^^^ help: try: `8.0_f64` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/unnecessary_cast.rs:217:20 + --> tests/ui/unnecessary_cast.rs:218:20 | LL | let _num = foo() as f32; | ^^^^^^^^^^^^ help: try: `foo()` diff --git a/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr b/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr index 2d38a2a7709ca..cafaffeae6c36 100644 --- a/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_cast_unfixable.stderr @@ -1,5 +1,5 @@ error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) - --> $DIR/unnecessary_cast_unfixable.rs:4:13 + --> tests/ui/unnecessary_cast_unfixable.rs:4:13 | LL | let _ = std::ptr::null() as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::null()` @@ -8,7 +8,7 @@ LL | let _ = std::ptr::null() as *const u8; = 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 + --> tests/ui/unnecessary_cast_unfixable.rs:21:16 | LL | ((*(*(self.object as *mut *mut _) as *mut Vtbl)).query)() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `*(self.object as *mut *mut _)` diff --git a/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.rs b/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.rs new file mode 100644 index 0000000000000..ff960520f5e72 --- /dev/null +++ b/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.rs @@ -0,0 +1,23 @@ +//@no-rustfix + +#![warn(clippy::unnecessary_clippy_cfg)] +#![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg + +#[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +#[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] +//~^ ERROR: no need to put clippy lints behind a `clippy` cfg +pub struct Bar; + +fn main() {} diff --git a/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.stderr b/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.stderr new file mode 100644 index 0000000000000..fbc05743ca74d --- /dev/null +++ b/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.stderr @@ -0,0 +1,61 @@ +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:13:1 + | +LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` + | + = note: `-D clippy::unnecessary-clippy-cfg` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_clippy_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:15:36 + | +LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#[deny(clippy::non_minimal_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:17:36 + | +LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#[deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:19:1 + | +LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:4:1 + | +LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:6:37 + | +LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#![deny(clippy::non_minimal_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:8:37 + | +LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: write instead: `#![deny(clippy::non_minimal_cfg,clippy::maybe_misused_cfg)]` + +error: no need to put clippy lints behind a `clippy` cfg + --> tests/ui/unnecessary_clippy_cfg.rs:10:1 + | +LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg, clippy::maybe_misused_cfg)]` + +error: aborting due to 8 previous errors + diff --git a/src/tools/clippy/tests/ui/unnecessary_clone.stderr b/src/tools/clippy/tests/ui/unnecessary_clone.stderr index eab5f04231656..e34a387c77e2e 100644 --- a/src/tools/clippy/tests/ui/unnecessary_clone.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_clone.stderr @@ -1,5 +1,5 @@ error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:23:5 + --> tests/ui/unnecessary_clone.rs:23:5 | LL | rc.clone(); | ^^^^^^^^^^ help: try: `Rc::::clone(&rc)` @@ -8,31 +8,31 @@ LL | rc.clone(); = 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 + --> tests/ui/unnecessary_clone.rs:28:5 | LL | arc.clone(); | ^^^^^^^^^^^ help: try: `Arc::::clone(&arc)` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:32:5 + --> tests/ui/unnecessary_clone.rs:32:5 | LL | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try: `Weak::::clone(&rcweak)` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:36:5 + --> tests/ui/unnecessary_clone.rs:36:5 | LL | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try: `Weak::::clone(&arc_weak)` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:41:33 + --> tests/ui/unnecessary_clone.rs:41:33 | LL | let _: Arc = x.clone(); | ^^^^^^^^^ help: try: `Arc::::clone(&x)` error: using `clone` on type `T` which implements the `Copy` trait - --> $DIR/unnecessary_clone.rs:46:5 + --> tests/ui/unnecessary_clone.rs:46:5 | LL | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` @@ -41,19 +41,19 @@ LL | t.clone(); = 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 + --> tests/ui/unnecessary_clone.rs:50:5 | LL | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` error: using `clone` on type `E` which implements the `Copy` trait - --> $DIR/unnecessary_clone.rs:85:20 + --> tests/ui/unnecessary_clone.rs:85:20 | LL | let _: E = a.clone(); | ^^^^^^^^^ help: try dereferencing it: `*****a` error: using `.clone()` on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:105:14 + --> tests/ui/unnecessary_clone.rs:105:14 | LL | Some(try_opt!(Some(rc)).clone()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc::::clone(&try_opt!(Some(rc)))` diff --git a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.fixed b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.fixed index 9668a6b99bf08..b6dd1f2677435 100644 --- a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.fixed +++ b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.fixed @@ -1,6 +1,43 @@ #![warn(clippy::unnecessary_fallible_conversions)] fn main() { + // --- TryFromMethod `T::try_from(u)` --- + let _: i64 = 0i32.into(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = 0i32.into(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `T::try_from(U)` --- + + let _ = i64::from(0i32); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _ = i64::from(0i32); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `U::try_into(t)` --- + + let _: i64 = i32::into(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _: i64 = i32::into(0i32); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `>::try_from(U)` --- + + let _ = >::from(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _ = >::from(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `>::try_into(U)` --- + + let _: i64 = >::into(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _: i64 = >::into(0); + //~^ ERROR: use of a fallible conversion when an infallible one could be used } diff --git a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.rs b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.rs index 9fa6c08b1b07e..6f8df7365e897 100644 --- a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.rs +++ b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.rs @@ -1,6 +1,43 @@ #![warn(clippy::unnecessary_fallible_conversions)] fn main() { + // --- TryFromMethod `T::try_from(u)` --- + let _: i64 = 0i32.try_into().unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + let _: i64 = 0i32.try_into().expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `T::try_from(U)` --- + + let _ = i64::try_from(0i32).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _ = i64::try_from(0i32).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `U::try_into(t)` --- + + let _: i64 = i32::try_into(0).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _: i64 = i32::try_into(0i32).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryFromFunction `>::try_from(U)` --- + + let _ = >::try_from(0).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _ = >::try_from(0).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + // --- TryIntoFunction `>::try_into(U)` --- + + let _: i64 = >::try_into(0).unwrap(); + //~^ ERROR: use of a fallible conversion when an infallible one could be used + + let _: i64 = >::try_into(0).expect("can't happen"); + //~^ ERROR: use of a fallible conversion when an infallible one could be used } diff --git a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.stderr b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.stderr index 26b152515ac7c..ade3aada92897 100644 --- a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions.stderr @@ -1,20 +1,134 @@ error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:4:23 + --> tests/ui/unnecessary_fallible_conversions.rs:6:23 | LL | let _: i64 = 0i32.try_into().unwrap(); - | ^^^^^^^^^^^^^^^^^^^ help: use: `into()` + | ^^^^^^^^^^^^^^^^^^^ | = note: converting `i32` to `i64` cannot fail = note: `-D clippy::unnecessary-fallible-conversions` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fallible_conversions)]` +help: use + | +LL - let _: i64 = 0i32.try_into().unwrap(); +LL + let _: i64 = 0i32.into(); + | error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions.rs:5:23 + --> tests/ui/unnecessary_fallible_conversions.rs:9:23 | LL | let _: i64 = 0i32.try_into().expect("can't happen"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `into()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = 0i32.try_into().expect("can't happen"); +LL + let _: i64 = 0i32.into(); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:14:13 + | +LL | let _ = i64::try_from(0i32).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = i64::try_from(0i32).unwrap(); +LL + let _ = i64::from(0i32); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:17:13 + | +LL | let _ = i64::try_from(0i32).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = i64::try_from(0i32).expect("can't happen"); +LL + let _ = i64::from(0i32); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:22:18 + | +LL | let _: i64 = i32::try_into(0).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = i32::try_into(0).unwrap(); +LL + let _: i64 = i32::into(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:25:18 + | +LL | let _: i64 = i32::try_into(0i32).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = i32::try_into(0i32).expect("can't happen"); +LL + let _: i64 = i32::into(0i32); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:30:13 + | +LL | let _ = >::try_from(0).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = >::try_from(0).unwrap(); +LL + let _ = >::from(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:33:13 + | +LL | let _ = >::try_from(0).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _ = >::try_from(0).expect("can't happen"); +LL + let _ = >::from(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:38:18 + | +LL | let _: i64 = >::try_into(0).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = >::try_into(0).unwrap(); +LL + let _: i64 = >::into(0); + | + +error: use of a fallible conversion when an infallible one could be used + --> tests/ui/unnecessary_fallible_conversions.rs:41:18 + | +LL | let _: i64 = >::try_into(0).expect("can't happen"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: converting `i32` to `i64` cannot fail +help: use + | +LL - let _: i64 = >::try_into(0).expect("can't happen"); +LL + let _: i64 = >::into(0); + | -error: aborting due to 2 previous errors +error: aborting due to 10 previous errors diff --git a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions_unfixable.stderr b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions_unfixable.stderr index 033de0e925082..43d0cde9399f0 100644 --- a/src/tools/clippy/tests/ui/unnecessary_fallible_conversions_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_fallible_conversions_unfixable.stderr @@ -1,5 +1,5 @@ error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:27:34 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:27:34 | LL | let _: Result = 0i64.try_into(); | ^^^^^^^^ help: use: `into` @@ -9,7 +9,7 @@ LL | let _: Result = 0i64.try_into(); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fallible_conversions)]` error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:29:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:29:29 | LL | let _: Result = i64::try_into(0i64); | ^^^^^^^^^^^^^ help: use: `Into::into` @@ -17,7 +17,7 @@ LL | let _: Result = i64::try_into(0i64); = note: converting `i64` to `Foo` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:31:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:31:29 | LL | let _: Result = Foo::try_from(0i64); | ^^^^^^^^^^^^^ help: use: `From::from` @@ -25,7 +25,7 @@ LL | let _: Result = Foo::try_from(0i64); = note: converting `i64` to `Foo` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:34:34 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:34:34 | LL | let _: Result = 0i32.try_into(); | ^^^^^^^^ help: use: `into` @@ -33,7 +33,7 @@ LL | let _: Result = 0i32.try_into(); = note: converting `i32` to `i64` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:36:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:36:29 | LL | let _: Result = i32::try_into(0i32); | ^^^^^^^^^^^^^ help: use: `Into::into` @@ -41,7 +41,7 @@ LL | let _: Result = i32::try_into(0i32); = note: converting `i32` to `i64` cannot fail error: use of a fallible conversion when an infallible one could be used - --> $DIR/unnecessary_fallible_conversions_unfixable.rs:38:29 + --> tests/ui/unnecessary_fallible_conversions_unfixable.rs:38:29 | LL | let _: Result = <_>::try_from(0i32); | ^^^^^^^^^^^^^ help: use: `From::from` diff --git a/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr b/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr index 0dd65f6527248..f32d444ba9e09 100644 --- a/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_filter_map.stderr @@ -1,5 +1,5 @@ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:4:13 + --> tests/ui/unnecessary_filter_map.rs:4:13 | LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); = 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 + --> tests/ui/unnecessary_filter_map.rs:7:13 | LL | let _ = (0..4).filter_map(|x| { | _____________^ @@ -21,7 +21,7 @@ LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:14:13 + --> tests/ui/unnecessary_filter_map.rs:14:13 | LL | let _ = (0..4).filter_map(|x| match x { | _____________^ @@ -32,13 +32,13 @@ LL | | }); | |______^ error: this `.filter_map` can be written more simply using `.map` - --> $DIR/unnecessary_filter_map.rs:20:13 + --> tests/ui/unnecessary_filter_map.rs:20:13 | LL | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:160:14 + --> tests/ui/unnecessary_filter_map.rs:160:14 | LL | let _x = std::iter::once(1).filter_map(|n| (n > 1).then_some(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnecessary_find_map.stderr b/src/tools/clippy/tests/ui/unnecessary_find_map.stderr index 662623fb61790..bb939a9921467 100644 --- a/src/tools/clippy/tests/ui/unnecessary_find_map.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_find_map.stderr @@ -1,5 +1,5 @@ error: this `.find_map` can be written more simply using `.find` - --> $DIR/unnecessary_find_map.rs:4:13 + --> tests/ui/unnecessary_find_map.rs:4:13 | LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); = 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 + --> tests/ui/unnecessary_find_map.rs:7:13 | LL | let _ = (0..4).find_map(|x| { | _____________^ @@ -21,7 +21,7 @@ LL | | }); | |______^ error: this `.find_map` can be written more simply using `.find` - --> $DIR/unnecessary_find_map.rs:14:13 + --> tests/ui/unnecessary_find_map.rs:14:13 | LL | let _ = (0..4).find_map(|x| match x { | _____________^ @@ -32,13 +32,13 @@ LL | | }); | |______^ error: this `.find_map` can be written more simply using `.map(..).next()` - --> $DIR/unnecessary_find_map.rs:20:13 + --> tests/ui/unnecessary_find_map.rs:20:13 | LL | let _ = (0..4).find_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `.find_map` can be written more simply using `.find` - --> $DIR/unnecessary_find_map.rs:32:14 + --> tests/ui/unnecessary_find_map.rs:32:14 | LL | let _x = std::iter::once(1).find_map(|n| (n > 1).then_some(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnecessary_fold.stderr b/src/tools/clippy/tests/ui/unnecessary_fold.stderr index 123d4a3be7557..31abab62f4c60 100644 --- a/src/tools/clippy/tests/ui/unnecessary_fold.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_fold.stderr @@ -1,5 +1,5 @@ error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:10:20 + --> tests/ui/unnecessary_fold.rs:10:20 | LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` @@ -8,7 +8,7 @@ LL | let _ = (0..3).fold(false, |acc, x| acc || x > 2); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_fold)]` error: redundant closure - --> $DIR/unnecessary_fold.rs:12:32 + --> tests/ui/unnecessary_fold.rs:12:32 | LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `is_any` @@ -17,85 +17,85 @@ LL | let _ = (0..3).fold(false, |acc, x| is_any(acc, x)); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:14:20 + --> tests/ui/unnecessary_fold.rs:14:20 | LL | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `all(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:16:25 + --> tests/ui/unnecessary_fold.rs:16:25 | LL | let _: i32 = (0..3).fold(0, |acc, x| acc + x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:18:25 + --> tests/ui/unnecessary_fold.rs:18:25 | LL | let _: i32 = (0..3).fold(1, |acc, x| acc * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:23:41 + --> tests/ui/unnecessary_fold.rs:23:41 | LL | let _: bool = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:53:10 + --> tests/ui/unnecessary_fold.rs:53:10 | LL | .fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `any(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:64:33 + --> tests/ui/unnecessary_fold.rs:64:33 | LL | assert_eq!(map.values().fold(0, |x, y| x + y), 0); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:67:30 + --> tests/ui/unnecessary_fold.rs:67:30 | LL | let _ = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:68:30 + --> tests/ui/unnecessary_fold.rs:68:30 | LL | let _ = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:69:35 + --> tests/ui/unnecessary_fold.rs:69:35 | LL | let _: i32 = map.values().fold(0, |x, y| x + y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:70:35 + --> tests/ui/unnecessary_fold.rs:70:35 | LL | let _: i32 = map.values().fold(1, |x, y| x * y); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:71:31 + --> tests/ui/unnecessary_fold.rs:71:31 | LL | anything(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:72:31 + --> tests/ui/unnecessary_fold.rs:72:31 | LL | anything(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product::()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:73:26 + --> tests/ui/unnecessary_fold.rs:73:26 | LL | num(map.values().fold(0, |x, y| x + y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:74:26 + --> tests/ui/unnecessary_fold.rs:74:26 | LL | num(map.values().fold(1, |x, y| x * y)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `product()` diff --git a/src/tools/clippy/tests/ui/unnecessary_get_then_check.fixed b/src/tools/clippy/tests/ui/unnecessary_get_then_check.fixed new file mode 100644 index 0000000000000..178a3300c3460 --- /dev/null +++ b/src/tools/clippy/tests/ui/unnecessary_get_then_check.fixed @@ -0,0 +1,26 @@ +#![warn(clippy::unnecessary_get_then_check)] + +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; + +fn main() { + let s: HashSet = HashSet::new(); + let _ = s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: HashMap = HashMap::new(); + let _ = s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeSet = BTreeSet::new(); + let _ = s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeMap = BTreeMap::new(); + let _ = s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = !s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_none()` + + // Import to check that the generic annotations are kept! + let s: HashSet = HashSet::new(); + let _ = s.contains::("a"); //~ ERROR: unnecessary use of `get::("a").is_some()` + let _ = !s.contains::("a"); //~ ERROR: unnecessary use of `get::("a").is_none()` +} diff --git a/src/tools/clippy/tests/ui/unnecessary_get_then_check.rs b/src/tools/clippy/tests/ui/unnecessary_get_then_check.rs new file mode 100644 index 0000000000000..c197bdef47eaf --- /dev/null +++ b/src/tools/clippy/tests/ui/unnecessary_get_then_check.rs @@ -0,0 +1,26 @@ +#![warn(clippy::unnecessary_get_then_check)] + +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; + +fn main() { + let s: HashSet = HashSet::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: HashMap = HashMap::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeSet = BTreeSet::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + let s: BTreeMap = BTreeMap::new(); + let _ = s.get("a").is_some(); //~ ERROR: unnecessary use of `get("a").is_some()` + let _ = s.get("a").is_none(); //~ ERROR: unnecessary use of `get("a").is_none()` + + // Import to check that the generic annotations are kept! + let s: HashSet = HashSet::new(); + let _ = s.get::("a").is_some(); //~ ERROR: unnecessary use of `get::("a").is_some()` + let _ = s.get::("a").is_none(); //~ ERROR: unnecessary use of `get::("a").is_none()` +} diff --git a/src/tools/clippy/tests/ui/unnecessary_get_then_check.stderr b/src/tools/clippy/tests/ui/unnecessary_get_then_check.stderr new file mode 100644 index 0000000000000..0477c03d16dd9 --- /dev/null +++ b/src/tools/clippy/tests/ui/unnecessary_get_then_check.stderr @@ -0,0 +1,75 @@ +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:7:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` + | + = note: `-D clippy::unnecessary-get-then-check` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_get_then_check)]` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:8:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains("a")` + +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:11:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:12:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains_key("a")` + +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:15:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:16:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains("a")` + +error: unnecessary use of `get("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:19:15 + | +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` + +error: unnecessary use of `get("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:20:15 + | +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains_key("a")` + +error: unnecessary use of `get::("a").is_some()` + --> tests/ui/unnecessary_get_then_check.rs:24:15 + | +LL | let _ = s.get::("a").is_some(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains::("a")` + +error: unnecessary use of `get::("a").is_none()` + --> tests/ui/unnecessary_get_then_check.rs:25:15 + | +LL | let _ = s.get::("a").is_none(); + | --^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains::("a")` + +error: aborting due to 10 previous errors + diff --git a/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr b/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr index ba40c6c14db21..9d3591e0dbfc8 100644 --- a/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_iter_cloned.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `copied` - --> $DIR/unnecessary_iter_cloned.rs:29:22 + --> tests/ui/unnecessary_iter_cloned.rs:29:22 | LL | for (t, path) in files.iter().copied() { | ^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + let other = match get_file_path(t) { | error: unnecessary use of `copied` - --> $DIR/unnecessary_iter_cloned.rs:44:22 + --> tests/ui/unnecessary_iter_cloned.rs:44:22 | LL | for (t, path) in files.iter().copied() { | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnecessary_join.stderr b/src/tools/clippy/tests/ui/unnecessary_join.stderr index 205a714b694ae..a06a1059033b7 100644 --- a/src/tools/clippy/tests/ui/unnecessary_join.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_join.stderr @@ -1,5 +1,5 @@ error: called `.collect::>().join("")` on an iterator - --> $DIR/unnecessary_join.rs:10:10 + --> tests/ui/unnecessary_join.rs:10:10 | LL | .collect::>() | __________^ @@ -10,7 +10,7 @@ LL | | .join(""); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_join)]` error: called `.collect::>().join("")` on an iterator - --> $DIR/unnecessary_join.rs:19:10 + --> tests/ui/unnecessary_join.rs:19:10 | LL | .collect::>() | __________^ diff --git a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr index 6ff2691a46167..fcd60f48bccdd 100644 --- a/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_lazy_eval.stderr @@ -1,5 +1,5 @@ error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:83:13 + --> tests/ui/unnecessary_lazy_eval.rs:83:13 | LL | let _ = opt.unwrap_or_else(|| 2); | ^^^^-------------------- @@ -10,7 +10,7 @@ LL | let _ = opt.unwrap_or_else(|| 2); = 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:84:13 + --> tests/ui/unnecessary_lazy_eval.rs:84:13 | LL | let _ = opt.unwrap_or_else(|| astronomers_pi); | ^^^^--------------------------------- @@ -18,7 +18,7 @@ LL | let _ = opt.unwrap_or_else(|| astronomers_pi); | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:85:13 + --> tests/ui/unnecessary_lazy_eval.rs:85:13 | LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); | ^^^^------------------------------------- @@ -26,7 +26,7 @@ LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:87:13 + --> tests/ui/unnecessary_lazy_eval.rs:87:13 | LL | let _ = opt.and_then(|_| ext_opt); | ^^^^--------------------- @@ -34,7 +34,7 @@ LL | let _ = opt.and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:88:13 + --> tests/ui/unnecessary_lazy_eval.rs:88:13 | LL | let _ = opt.or_else(|| ext_opt); | ^^^^------------------- @@ -42,7 +42,7 @@ LL | let _ = opt.or_else(|| ext_opt); | help: use `or(..)` instead: `or(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:89:13 + --> tests/ui/unnecessary_lazy_eval.rs:89:13 | LL | let _ = opt.or_else(|| None); | ^^^^---------------- @@ -50,7 +50,7 @@ LL | let _ = opt.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:90:13 + --> tests/ui/unnecessary_lazy_eval.rs:90:13 | LL | let _ = opt.get_or_insert_with(|| 2); | ^^^^------------------------ @@ -58,7 +58,7 @@ LL | let _ = opt.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:91:13 + --> tests/ui/unnecessary_lazy_eval.rs:91:13 | LL | let _ = opt.ok_or_else(|| 2); | ^^^^---------------- @@ -66,7 +66,7 @@ LL | let _ = opt.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:92:13 + --> tests/ui/unnecessary_lazy_eval.rs:92:13 | LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); | ^^^^^^^^^^^^^^^^^------------------------------- @@ -74,7 +74,7 @@ LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); | help: use `unwrap_or(..)` instead: `unwrap_or(Some((1, 2)))` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:93:13 + --> tests/ui/unnecessary_lazy_eval.rs:93:13 | LL | let _ = cond.then(|| astronomers_pi); | ^^^^^----------------------- @@ -82,7 +82,7 @@ LL | let _ = cond.then(|| astronomers_pi); | help: use `then_some(..)` instead: `then_some(astronomers_pi)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:94:13 + --> tests/ui/unnecessary_lazy_eval.rs:94:13 | LL | let _ = true.then(|| -> _ {}); | ^^^^^---------------- @@ -90,7 +90,7 @@ LL | let _ = true.then(|| -> _ {}); | help: use `then_some(..)` instead: `then_some({})` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:95:13 + --> tests/ui/unnecessary_lazy_eval.rs:95:13 | LL | let _ = true.then(|| {}); | ^^^^^----------- @@ -98,7 +98,7 @@ LL | let _ = true.then(|| {}); | help: use `then_some(..)` instead: `then_some({})` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:99:13 + --> tests/ui/unnecessary_lazy_eval.rs:99:13 | LL | let _ = Some(1).unwrap_or_else(|| *r); | ^^^^^^^^--------------------- @@ -106,7 +106,7 @@ LL | let _ = Some(1).unwrap_or_else(|| *r); | help: use `unwrap_or(..)` instead: `unwrap_or(*r)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:101:13 + --> tests/ui/unnecessary_lazy_eval.rs:101:13 | LL | let _ = Some(1).unwrap_or_else(|| *b); | ^^^^^^^^--------------------- @@ -114,7 +114,7 @@ LL | let _ = Some(1).unwrap_or_else(|| *b); | help: use `unwrap_or(..)` instead: `unwrap_or(*b)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:103:13 + --> tests/ui/unnecessary_lazy_eval.rs:103:13 | LL | let _ = Some(1).as_ref().unwrap_or_else(|| &r); | ^^^^^^^^^^^^^^^^^--------------------- @@ -122,7 +122,7 @@ LL | let _ = Some(1).as_ref().unwrap_or_else(|| &r); | help: use `unwrap_or(..)` instead: `unwrap_or(&r)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:104:13 + --> tests/ui/unnecessary_lazy_eval.rs:104:13 | LL | let _ = Some(1).as_ref().unwrap_or_else(|| &b); | ^^^^^^^^^^^^^^^^^--------------------- @@ -130,7 +130,7 @@ LL | let _ = Some(1).as_ref().unwrap_or_else(|| &b); | help: use `unwrap_or(..)` instead: `unwrap_or(&b)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:107:13 + --> tests/ui/unnecessary_lazy_eval.rs:107:13 | LL | let _ = Some(10).unwrap_or_else(|| 2); | ^^^^^^^^^-------------------- @@ -138,7 +138,7 @@ LL | let _ = Some(10).unwrap_or_else(|| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:108:13 + --> tests/ui/unnecessary_lazy_eval.rs:108:13 | LL | let _ = Some(10).and_then(|_| ext_opt); | ^^^^^^^^^--------------------- @@ -146,7 +146,7 @@ LL | let _ = Some(10).and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:109:28 + --> tests/ui/unnecessary_lazy_eval.rs:109:28 | LL | let _: Option = None.or_else(|| ext_opt); | ^^^^^------------------- @@ -154,7 +154,7 @@ LL | let _: Option = None.or_else(|| ext_opt); | help: use `or(..)` instead: `or(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:110:13 + --> tests/ui/unnecessary_lazy_eval.rs:110:13 | LL | let _ = None.get_or_insert_with(|| 2); | ^^^^^------------------------ @@ -162,7 +162,7 @@ LL | let _ = None.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:111:35 + --> tests/ui/unnecessary_lazy_eval.rs:111:35 | LL | let _: Result = None.ok_or_else(|| 2); | ^^^^^---------------- @@ -170,7 +170,7 @@ LL | let _: Result = None.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:112:28 + --> tests/ui/unnecessary_lazy_eval.rs:112:28 | LL | let _: Option = None.or_else(|| None); | ^^^^^---------------- @@ -178,7 +178,7 @@ LL | let _: Option = None.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:115:13 + --> tests/ui/unnecessary_lazy_eval.rs:115:13 | LL | let _ = deep.0.unwrap_or_else(|| 2); | ^^^^^^^-------------------- @@ -186,7 +186,7 @@ LL | let _ = deep.0.unwrap_or_else(|| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:116:13 + --> tests/ui/unnecessary_lazy_eval.rs:116:13 | LL | let _ = deep.0.and_then(|_| ext_opt); | ^^^^^^^--------------------- @@ -194,7 +194,7 @@ LL | let _ = deep.0.and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:117:13 + --> tests/ui/unnecessary_lazy_eval.rs:117:13 | LL | let _ = deep.0.or_else(|| None); | ^^^^^^^---------------- @@ -202,7 +202,7 @@ LL | let _ = deep.0.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:118:13 + --> tests/ui/unnecessary_lazy_eval.rs:118:13 | LL | let _ = deep.0.get_or_insert_with(|| 2); | ^^^^^^^------------------------ @@ -210,7 +210,7 @@ LL | let _ = deep.0.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:119:13 + --> tests/ui/unnecessary_lazy_eval.rs:119:13 | LL | let _ = deep.0.ok_or_else(|| 2); | ^^^^^^^---------------- @@ -218,7 +218,7 @@ LL | let _ = deep.0.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:150:28 + --> tests/ui/unnecessary_lazy_eval.rs:150:28 | LL | let _: Option = None.or_else(|| Some(3)); | ^^^^^------------------- @@ -226,7 +226,7 @@ LL | let _: Option = None.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:151:13 + --> tests/ui/unnecessary_lazy_eval.rs:151:13 | LL | let _ = deep.0.or_else(|| Some(3)); | ^^^^^^^------------------- @@ -234,7 +234,7 @@ LL | let _ = deep.0.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Option::None` - --> $DIR/unnecessary_lazy_eval.rs:152:13 + --> tests/ui/unnecessary_lazy_eval.rs:152:13 | LL | let _ = opt.or_else(|| Some(3)); | ^^^^------------------- @@ -242,7 +242,7 @@ LL | let _ = opt.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:158:13 + --> tests/ui/unnecessary_lazy_eval.rs:158:13 | LL | let _ = res2.unwrap_or_else(|_| 2); | ^^^^^--------------------- @@ -250,7 +250,7 @@ LL | let _ = res2.unwrap_or_else(|_| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:159:13 + --> tests/ui/unnecessary_lazy_eval.rs:159:13 | LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); | ^^^^^---------------------------------- @@ -258,7 +258,7 @@ LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:160:13 + --> tests/ui/unnecessary_lazy_eval.rs:160:13 | LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); | ^^^^^-------------------------------------- @@ -266,7 +266,7 @@ LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:182:35 + --> tests/ui/unnecessary_lazy_eval.rs:182:35 | LL | let _: Result = res.and_then(|_| Err(2)); | ^^^^-------------------- @@ -274,7 +274,7 @@ LL | let _: Result = res.and_then(|_| Err(2)); | help: use `and(..)` instead: `and(Err(2))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:183:35 + --> tests/ui/unnecessary_lazy_eval.rs:183:35 | LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); | ^^^^--------------------------------- @@ -282,7 +282,7 @@ LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); | help: use `and(..)` instead: `and(Err(astronomers_pi))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:184:35 + --> tests/ui/unnecessary_lazy_eval.rs:184:35 | LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)); | ^^^^------------------------------------- @@ -290,7 +290,7 @@ LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)) | help: use `and(..)` instead: `and(Err(ext_str.some_field))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:186:35 + --> tests/ui/unnecessary_lazy_eval.rs:186:35 | LL | let _: Result = res.or_else(|_| Ok(2)); | ^^^^------------------ @@ -298,7 +298,7 @@ LL | let _: Result = res.or_else(|_| Ok(2)); | help: use `or(..)` instead: `or(Ok(2))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:187:35 + --> tests/ui/unnecessary_lazy_eval.rs:187:35 | LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); | ^^^^------------------------------- @@ -306,7 +306,7 @@ LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); | help: use `or(..)` instead: `or(Ok(astronomers_pi))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:188:35 + --> tests/ui/unnecessary_lazy_eval.rs:188:35 | LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); | ^^^^----------------------------------- @@ -314,7 +314,7 @@ LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval.rs:189:35 + --> tests/ui/unnecessary_lazy_eval.rs:189:35 | LL | let _: Result = res. | ___________________________________^ @@ -329,7 +329,7 @@ LL | | or_else(|_| Ok(ext_str.some_field)); | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:219:14 + --> tests/ui/unnecessary_lazy_eval.rs:219:14 | LL | let _x = false.then(|| i32::MAX + 1); | ^^^^^^--------------------- @@ -337,7 +337,7 @@ LL | let _x = false.then(|| i32::MAX + 1); | help: use `then_some(..)` instead: `then_some(i32::MAX + 1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:221:14 + --> tests/ui/unnecessary_lazy_eval.rs:221:14 | LL | let _x = false.then(|| i32::MAX * 2); | ^^^^^^--------------------- @@ -345,7 +345,7 @@ LL | let _x = false.then(|| i32::MAX * 2); | help: use `then_some(..)` instead: `then_some(i32::MAX * 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:223:14 + --> tests/ui/unnecessary_lazy_eval.rs:223:14 | LL | let _x = false.then(|| i32::MAX - 1); | ^^^^^^--------------------- @@ -353,7 +353,7 @@ LL | let _x = false.then(|| i32::MAX - 1); | help: use `then_some(..)` instead: `then_some(i32::MAX - 1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:225:14 + --> tests/ui/unnecessary_lazy_eval.rs:225:14 | LL | let _x = false.then(|| i32::MIN - 1); | ^^^^^^--------------------- @@ -361,7 +361,7 @@ LL | let _x = false.then(|| i32::MIN - 1); | help: use `then_some(..)` instead: `then_some(i32::MIN - 1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:227:14 + --> tests/ui/unnecessary_lazy_eval.rs:227:14 | LL | let _x = false.then(|| (1 + 2 * 3 - 2 / 3 + 9) << 2); | ^^^^^^------------------------------------- @@ -369,7 +369,7 @@ LL | let _x = false.then(|| (1 + 2 * 3 - 2 / 3 + 9) << 2); | help: use `then_some(..)` instead: `then_some((1 + 2 * 3 - 2 / 3 + 9) << 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:229:14 + --> tests/ui/unnecessary_lazy_eval.rs:229:14 | LL | let _x = false.then(|| 255u8 << 7); | ^^^^^^------------------- @@ -377,7 +377,7 @@ LL | let _x = false.then(|| 255u8 << 7); | help: use `then_some(..)` instead: `then_some(255u8 << 7)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:231:14 + --> tests/ui/unnecessary_lazy_eval.rs:231:14 | LL | let _x = false.then(|| 255u8 << 8); | ^^^^^^------------------- @@ -385,7 +385,7 @@ LL | let _x = false.then(|| 255u8 << 8); | help: use `then_some(..)` instead: `then_some(255u8 << 8)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:233:14 + --> tests/ui/unnecessary_lazy_eval.rs:233:14 | LL | let _x = false.then(|| 255u8 >> 8); | ^^^^^^------------------- @@ -393,7 +393,7 @@ LL | let _x = false.then(|| 255u8 >> 8); | help: use `then_some(..)` instead: `then_some(255u8 >> 8)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:236:14 + --> tests/ui/unnecessary_lazy_eval.rs:236:14 | LL | let _x = false.then(|| i32::MAX + -1); | ^^^^^^---------------------- @@ -401,7 +401,7 @@ LL | let _x = false.then(|| i32::MAX + -1); | help: use `then_some(..)` instead: `then_some(i32::MAX + -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:238:14 + --> tests/ui/unnecessary_lazy_eval.rs:238:14 | LL | let _x = false.then(|| -i32::MAX); | ^^^^^^------------------ @@ -409,7 +409,7 @@ LL | let _x = false.then(|| -i32::MAX); | help: use `then_some(..)` instead: `then_some(-i32::MAX)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:240:14 + --> tests/ui/unnecessary_lazy_eval.rs:240:14 | LL | let _x = false.then(|| -i32::MIN); | ^^^^^^------------------ @@ -417,7 +417,7 @@ LL | let _x = false.then(|| -i32::MIN); | help: use `then_some(..)` instead: `then_some(-i32::MIN)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:243:14 + --> tests/ui/unnecessary_lazy_eval.rs:243:14 | LL | let _x = false.then(|| 255 >> -7); | ^^^^^^------------------ @@ -425,7 +425,7 @@ LL | let _x = false.then(|| 255 >> -7); | help: use `then_some(..)` instead: `then_some(255 >> -7)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:245:14 + --> tests/ui/unnecessary_lazy_eval.rs:245:14 | LL | let _x = false.then(|| 255 << -1); | ^^^^^^------------------ @@ -433,7 +433,7 @@ LL | let _x = false.then(|| 255 << -1); | help: use `then_some(..)` instead: `then_some(255 << -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:247:14 + --> tests/ui/unnecessary_lazy_eval.rs:247:14 | LL | let _x = false.then(|| 1 / 0); | ^^^^^^-------------- @@ -441,7 +441,7 @@ LL | let _x = false.then(|| 1 / 0); | help: use `then_some(..)` instead: `then_some(1 / 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:249:14 + --> tests/ui/unnecessary_lazy_eval.rs:249:14 | LL | let _x = false.then(|| x << -1); | ^^^^^^---------------- @@ -449,7 +449,7 @@ LL | let _x = false.then(|| x << -1); | help: use `then_some(..)` instead: `then_some(x << -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:251:14 + --> tests/ui/unnecessary_lazy_eval.rs:251:14 | LL | let _x = false.then(|| x << 2); | ^^^^^^--------------- @@ -457,7 +457,7 @@ LL | let _x = false.then(|| x << 2); | help: use `then_some(..)` instead: `then_some(x << 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:261:14 + --> tests/ui/unnecessary_lazy_eval.rs:261:14 | LL | let _x = false.then(|| x / 0); | ^^^^^^-------------- @@ -465,7 +465,7 @@ LL | let _x = false.then(|| x / 0); | help: use `then_some(..)` instead: `then_some(x / 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:263:14 + --> tests/ui/unnecessary_lazy_eval.rs:263:14 | LL | let _x = false.then(|| x % 0); | ^^^^^^-------------- @@ -473,7 +473,7 @@ LL | let _x = false.then(|| x % 0); | help: use `then_some(..)` instead: `then_some(x % 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:266:14 + --> tests/ui/unnecessary_lazy_eval.rs:266:14 | LL | let _x = false.then(|| 1 / -1); | ^^^^^^--------------- @@ -481,7 +481,7 @@ LL | let _x = false.then(|| 1 / -1); | help: use `then_some(..)` instead: `then_some(1 / -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:268:14 + --> tests/ui/unnecessary_lazy_eval.rs:268:14 | LL | let _x = false.then(|| i32::MIN / -1); | ^^^^^^---------------------- @@ -489,7 +489,7 @@ LL | let _x = false.then(|| i32::MIN / -1); | help: use `then_some(..)` instead: `then_some(i32::MIN / -1)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:271:14 + --> tests/ui/unnecessary_lazy_eval.rs:271:14 | LL | let _x = false.then(|| i32::MIN / 0); | ^^^^^^--------------------- @@ -497,7 +497,7 @@ LL | let _x = false.then(|| i32::MIN / 0); | help: use `then_some(..)` instead: `then_some(i32::MIN / 0)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:273:14 + --> tests/ui/unnecessary_lazy_eval.rs:273:14 | LL | let _x = false.then(|| 4 / 2); | ^^^^^^-------------- @@ -505,7 +505,7 @@ LL | let _x = false.then(|| 4 / 2); | help: use `then_some(..)` instead: `then_some(4 / 2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval.rs:281:14 + --> tests/ui/unnecessary_lazy_eval.rs:281:14 | LL | let _x = false.then(|| f1 + f2); | ^^^^^^---------------- 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 95b02be91ca8a..b566b119571cb 100644 --- a/src/tools/clippy/tests/ui/unnecessary_lazy_eval_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_lazy_eval_unfixable.stderr @@ -1,5 +1,5 @@ error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval_unfixable.rs:13:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:13:13 | LL | let _ = Ok(1).unwrap_or_else(|()| 2); | ^^^^^^---------------------- @@ -10,7 +10,7 @@ LL | let _ = Ok(1).unwrap_or_else(|()| 2); = 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 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:19:13 | LL | let _ = Ok(1).unwrap_or_else(|e::E| 2); | ^^^^^^------------------------ @@ -18,7 +18,7 @@ LL | let _ = Ok(1).unwrap_or_else(|e::E| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Result::Err` - --> $DIR/unnecessary_lazy_eval_unfixable.rs:21:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:21:13 | LL | let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); | ^^^^^^------------------------------------- @@ -26,7 +26,7 @@ LL | let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used with `bool::then` - --> $DIR/unnecessary_lazy_eval_unfixable.rs:31:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:31:13 | LL | let _ = true.then(|| -> &[u8] { &[] }); | ^^^^^------------------------- diff --git a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr index 4940091be60ae..15708090361ed 100644 --- a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr @@ -1,5 +1,5 @@ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:11:16 + --> tests/ui/unnecessary_literal_unwrap.rs:11:16 | LL | let _val = Some(1).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + let _val = 1; | error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:12:16 + --> tests/ui/unnecessary_literal_unwrap.rs:12:16 | LL | let _val = Some(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + let _val = 1; | error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:14:5 + --> tests/ui/unnecessary_literal_unwrap.rs:14:5 | LL | Some(1).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + 1; | error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:15:5 + --> tests/ui/unnecessary_literal_unwrap.rs:15:5 | LL | Some(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,13 +49,13 @@ LL + 1; | error: used `unwrap()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:20:16 + --> tests/ui/unnecessary_literal_unwrap.rs:20:16 | LL | let _val = None::<()>.unwrap(); | ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()` error: used `expect()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:21:16 + --> tests/ui/unnecessary_literal_unwrap.rs:21:16 | LL | let _val = None::<()>.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,13 +66,13 @@ LL | let _val = panic!("this always happens"); | ~~~~~~~ ~ error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:22:24 + --> tests/ui/unnecessary_literal_unwrap.rs:22:24 | LL | let _val: String = None.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `String::default()` error: used `unwrap_or()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:23:21 + --> tests/ui/unnecessary_literal_unwrap.rs:23:21 | LL | let _val: u16 = None.unwrap_or(234); | ^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL + let _val: u16 = 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:24:21 + --> tests/ui/unnecessary_literal_unwrap.rs:24:21 | LL | let _val: u16 = None.unwrap_or_else(|| 234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL + let _val: u16 = 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:25:21 + --> tests/ui/unnecessary_literal_unwrap.rs:25:21 | LL | let _val: u16 = None.unwrap_or_else(|| { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + let _val: u16 = { 234 }; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:26:21 + --> tests/ui/unnecessary_literal_unwrap.rs:26:21 | LL | let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,13 +120,13 @@ LL + let _val: u16 = { 234 }; | error: used `unwrap()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:28:5 + --> tests/ui/unnecessary_literal_unwrap.rs:28:5 | LL | None::<()>.unwrap(); | ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()` error: used `expect()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:29:5 + --> tests/ui/unnecessary_literal_unwrap.rs:29:5 | LL | None::<()>.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -137,13 +137,13 @@ LL | panic!("this always happens"); | ~~~~~~~ ~ error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:30:5 + --> tests/ui/unnecessary_literal_unwrap.rs:30:5 | LL | None::.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `String::default()` error: used `unwrap_or()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:31:5 + --> tests/ui/unnecessary_literal_unwrap.rs:31:5 | LL | None::.unwrap_or(234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:32:5 + --> tests/ui/unnecessary_literal_unwrap.rs:32:5 | LL | None::.unwrap_or_else(|| 234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL + 234; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:33:5 + --> tests/ui/unnecessary_literal_unwrap.rs:33:5 | LL | None::.unwrap_or_else(|| { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -179,7 +179,7 @@ LL + { 234 }; | error: used `unwrap_or_else()` on `None` value - --> $DIR/unnecessary_literal_unwrap.rs:34:5 + --> tests/ui/unnecessary_literal_unwrap.rs:34:5 | LL | None::.unwrap_or_else(|| -> u16 { 234 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -191,7 +191,7 @@ LL + { 234 }; | error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:38:16 + --> tests/ui/unnecessary_literal_unwrap.rs:38:16 | LL | let _val = Ok::<_, ()>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL + let _val = 1; | error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:39:16 + --> tests/ui/unnecessary_literal_unwrap.rs:39:16 | LL | let _val = Ok::<_, ()>(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -215,7 +215,7 @@ LL + let _val = 1; | error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:40:16 + --> tests/ui/unnecessary_literal_unwrap.rs:40:16 | LL | let _val = Ok::<_, ()>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -226,7 +226,7 @@ LL | let _val = panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:41:16 + --> tests/ui/unnecessary_literal_unwrap.rs:41:16 | LL | let _val = Ok::<_, ()>(1).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -237,7 +237,7 @@ LL | let _val = panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:43:5 + --> tests/ui/unnecessary_literal_unwrap.rs:43:5 | LL | Ok::<_, ()>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -249,7 +249,7 @@ LL + 1; | error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:44:5 + --> tests/ui/unnecessary_literal_unwrap.rs:44:5 | LL | Ok::<_, ()>(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -261,7 +261,7 @@ LL + 1; | error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:45:5 + --> tests/ui/unnecessary_literal_unwrap.rs:45:5 | LL | Ok::<_, ()>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -272,7 +272,7 @@ LL | panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:46:5 + --> tests/ui/unnecessary_literal_unwrap.rs:46:5 | LL | Ok::<_, ()>(1).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -283,7 +283,7 @@ LL | panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:50:16 + --> tests/ui/unnecessary_literal_unwrap.rs:50:16 | LL | let _val = Err::<(), _>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +295,7 @@ LL + let _val = 1; | error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:51:16 + --> tests/ui/unnecessary_literal_unwrap.rs:51:16 | LL | let _val = Err::<(), _>(1).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -307,7 +307,7 @@ LL + let _val = 1; | error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:52:16 + --> tests/ui/unnecessary_literal_unwrap.rs:52:16 | LL | let _val = Err::<(), _>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -318,7 +318,7 @@ LL | let _val = panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:53:16 + --> tests/ui/unnecessary_literal_unwrap.rs:53:16 | LL | let _val = Err::<(), _>(1).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -329,7 +329,7 @@ LL | let _val = panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:55:5 + --> tests/ui/unnecessary_literal_unwrap.rs:55:5 | LL | Err::<(), _>(1).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -341,7 +341,7 @@ LL + 1; | error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:56:5 + --> tests/ui/unnecessary_literal_unwrap.rs:56:5 | LL | Err::<(), _>(1).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -353,7 +353,7 @@ LL + 1; | error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:57:5 + --> tests/ui/unnecessary_literal_unwrap.rs:57:5 | LL | Err::<(), _>(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -364,7 +364,7 @@ LL | panic!("{:?}", 1); | ~~~~~~~~~~~~~~ ~ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:58:5 + --> tests/ui/unnecessary_literal_unwrap.rs:58:5 | LL | Err::<(), _>(1).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -375,7 +375,7 @@ LL | panic!("{1}: {:?}", 1, "this always happens"); | ~~~~~~~~~~~~~~~~~~~ ~ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:62:16 + --> tests/ui/unnecessary_literal_unwrap.rs:62:16 | LL | let _val = Some(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^ @@ -387,7 +387,7 @@ LL + let _val = 1; | error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:63:16 + --> tests/ui/unnecessary_literal_unwrap.rs:63:16 | LL | let _val = Some(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -399,7 +399,7 @@ LL + let _val = 1; | error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:64:16 + --> tests/ui/unnecessary_literal_unwrap.rs:64:16 | LL | let _val = Some(1).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -411,7 +411,7 @@ LL + let _val = 1; | error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:66:5 + --> tests/ui/unnecessary_literal_unwrap.rs:66:5 | LL | Some(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^ @@ -423,7 +423,7 @@ LL + 1; | error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:67:5 + --> tests/ui/unnecessary_literal_unwrap.rs:67:5 | LL | Some(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ LL + 1; | error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:68:5 + --> tests/ui/unnecessary_literal_unwrap.rs:68:5 | LL | Some(1).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -447,7 +447,7 @@ LL + 1; | error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:72:16 + --> tests/ui/unnecessary_literal_unwrap.rs:72:16 | LL | let _val = Ok::<_, ()>(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ LL + let _val = 1; | error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:73:16 + --> tests/ui/unnecessary_literal_unwrap.rs:73:16 | LL | let _val = Ok::<_, ()>(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -471,7 +471,7 @@ LL + let _val = 1; | error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:74:16 + --> tests/ui/unnecessary_literal_unwrap.rs:74:16 | LL | let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -483,7 +483,7 @@ LL + let _val = 1; | error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:76:5 + --> tests/ui/unnecessary_literal_unwrap.rs:76:5 | LL | Ok::<_, ()>(1).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -495,7 +495,7 @@ LL + 1; | error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:77:5 + --> tests/ui/unnecessary_literal_unwrap.rs:77:5 | LL | Ok::<_, ()>(1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +507,7 @@ LL + 1; | error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:78:5 + --> tests/ui/unnecessary_literal_unwrap.rs:78:5 | LL | Ok::<_, ()>(1).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -519,7 +519,7 @@ LL + 1; | error: used `unwrap_unchecked()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:92:22 + --> tests/ui/unnecessary_literal_unwrap.rs:92:22 | LL | let _ = unsafe { Some(1).unwrap_unchecked() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -531,7 +531,7 @@ LL + let _ = 1; | error: used `unwrap_unchecked()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:93:22 + --> tests/ui/unnecessary_literal_unwrap.rs:93:22 | LL | let _ = unsafe { Some(1).unwrap_unchecked() + *(&1 as *const i32) }; // needs to keep the unsafe block | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -543,7 +543,7 @@ LL + let _ = unsafe { 1 + *(&1 as *const i32) }; // needs to keep the unsafe | error: used `unwrap_unchecked()` on `Some` value - --> $DIR/unnecessary_literal_unwrap.rs:94:22 + --> tests/ui/unnecessary_literal_unwrap.rs:94:22 | LL | let _ = unsafe { Some(1).unwrap_unchecked() } + 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -555,7 +555,7 @@ LL + let _ = 1 + 1; | error: used `unwrap_unchecked()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:95:22 + --> tests/ui/unnecessary_literal_unwrap.rs:95:22 | LL | let _ = unsafe { Ok::<_, ()>(1).unwrap_unchecked() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -567,7 +567,7 @@ LL + let _ = 1; | error: used `unwrap_unchecked()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:96:22 + --> tests/ui/unnecessary_literal_unwrap.rs:96:22 | LL | let _ = unsafe { Ok::<_, ()>(1).unwrap_unchecked() + *(&1 as *const i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -579,7 +579,7 @@ LL + let _ = unsafe { 1 + *(&1 as *const i32) }; | error: used `unwrap_unchecked()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap.rs:97:22 + --> tests/ui/unnecessary_literal_unwrap.rs:97:22 | LL | let _ = unsafe { Ok::<_, ()>(1).unwrap_unchecked() } + 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -591,7 +591,7 @@ LL + let _ = 1 + 1; | error: used `unwrap_err_unchecked()` on `Err` value - --> $DIR/unnecessary_literal_unwrap.rs:98:22 + --> tests/ui/unnecessary_literal_unwrap.rs:98:22 | LL | let _ = unsafe { Err::<(), i32>(123).unwrap_err_unchecked() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 c6ecd6de61ea1..b7dd7ae729fd9 100644 --- a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap_unfixable.stderr @@ -1,11 +1,11 @@ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:7:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:7:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:6:15 | LL | let val = Some(1); | ^^^^^^^ @@ -13,601 +13,601 @@ LL | let val = Some(1); = 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 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:9:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:6:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:14:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:14:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:14:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:14:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:16:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:16:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:16:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:16:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:20:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:20:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:19:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:19:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:22:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:22:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:19:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:19:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:28:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:28:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `None` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:27:15 | LL | let val = None::<()>; | ^^^^^^^^^^ error: used `expect()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:30:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:30:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `None` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:27:15 | LL | let val = None::<()>; | ^^^^^^^^^^ error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:32:21 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:32:21 | LL | let _val3: u8 = None.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `Default::default()` error: used `unwrap_or_default()` on `None` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:34:5 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:34:5 | LL | None::<()>.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `Default::default()` error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:40:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:42:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:42:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:44:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:44:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:46:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:46:17 | LL | let _val2 = val.expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:39:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:39:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:51:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:51:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:51:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:51:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:53:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:53:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:53:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:53:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:55:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:55:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:55:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:55:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:57:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:57:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:61:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:63:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:63:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:65:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:65:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:67:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:67:17 | LL | let _val2 = val.expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:60:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:73:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:73:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:75:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:75:17 | LL | let _val2 = val.expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:77:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:77:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:79:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:79:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:84:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:84:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:84:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:84:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:86:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:86:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:86:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:86:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:88:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:88:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:88:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:88:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:90:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:90:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:90:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:90:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:94:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:94:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:96:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:96:17 | LL | let _val2 = val.expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:98:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:100:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:100:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:93:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:93:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:106:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:106:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:105:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:108:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:108:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:105:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:110:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:110:17 | LL | let _val2 = val.unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:105:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:115:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:115:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:115:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:115:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:117:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:117:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:117:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:117:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:119:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:119:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:119:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:119:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:123:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:123:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:122:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:122:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:125:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:125:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:122:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:122:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:127:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:127:17 | LL | let _val2 = val.unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:122:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:122:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:133:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:133:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:132:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:132:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:135:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:135:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:132:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:132:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:137:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:137:17 | LL | let _val2 = val.unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:132:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:132:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:142:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:142:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:142:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:142:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:144:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:144:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:144:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:144:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:146:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:146:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:146:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:146:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:150:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:150:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:149:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:149:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:152:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:152:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:149:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:149:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:154:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:154:17 | LL | let _val2 = val.unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> $DIR/unnecessary_literal_unwrap_unfixable.rs:149:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:149:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnecessary_map_on_constructor.stderr b/src/tools/clippy/tests/ui/unnecessary_map_on_constructor.stderr index d522b68d8726a..ecbf652441549 100644 --- a/src/tools/clippy/tests/ui/unnecessary_map_on_constructor.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_map_on_constructor.stderr @@ -1,5 +1,5 @@ error: unnecessary map on constructor Some(_) - --> $DIR/unnecessary_map_on_constructor.rs:32:13 + --> tests/ui/unnecessary_map_on_constructor.rs:32:13 | LL | let a = Some(x).map(fun); | ^^^^^^^^^^^^^^^^ help: try: `Some(fun(x))` @@ -8,43 +8,43 @@ LL | let a = Some(x).map(fun); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_map_on_constructor)]` error: unnecessary map on constructor Ok(_) - --> $DIR/unnecessary_map_on_constructor.rs:33:27 + --> tests/ui/unnecessary_map_on_constructor.rs:33:27 | LL | let b: SimpleResult = Ok(x).map(fun); | ^^^^^^^^^^^^^^ help: try: `Ok(fun(x))` error: unnecessary map_err on constructor Err(_) - --> $DIR/unnecessary_map_on_constructor.rs:34:27 + --> tests/ui/unnecessary_map_on_constructor.rs:34:27 | LL | let c: SimpleResult = Err(err).map_err(notfun); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Err(notfun(err))` error: unnecessary map on constructor Option::Some(_) - --> $DIR/unnecessary_map_on_constructor.rs:36:13 + --> tests/ui/unnecessary_map_on_constructor.rs:36:13 | LL | let a = Option::Some(x).map(fun); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Option::Some(fun(x))` error: unnecessary map on constructor SimpleResult::Ok(_) - --> $DIR/unnecessary_map_on_constructor.rs:37:27 + --> tests/ui/unnecessary_map_on_constructor.rs:37:27 | LL | let b: SimpleResult = SimpleResult::Ok(x).map(fun); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `SimpleResult::Ok(fun(x))` error: unnecessary map_err on constructor SimpleResult::Err(_) - --> $DIR/unnecessary_map_on_constructor.rs:38:27 + --> tests/ui/unnecessary_map_on_constructor.rs:38:27 | LL | let c: SimpleResult = SimpleResult::Err(err).map_err(notfun); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `SimpleResult::Err(notfun(err))` error: unnecessary map on constructor Ok(_) - --> $DIR/unnecessary_map_on_constructor.rs:39:52 + --> tests/ui/unnecessary_map_on_constructor.rs:39:52 | LL | let b: std::result::Result = Ok(x).map(fun); | ^^^^^^^^^^^^^^ help: try: `Ok(fun(x))` error: unnecessary map_err on constructor Err(_) - --> $DIR/unnecessary_map_on_constructor.rs:40:52 + --> tests/ui/unnecessary_map_on_constructor.rs:40:52 | LL | let c: std::result::Result = Err(err).map_err(notfun); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Err(notfun(err))` diff --git a/src/tools/clippy/tests/ui/unnecessary_operation.stderr b/src/tools/clippy/tests/ui/unnecessary_operation.stderr index eeee9ad60068b..27be5e6f4b922 100644 --- a/src/tools/clippy/tests/ui/unnecessary_operation.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_operation.stderr @@ -1,5 +1,5 @@ error: unnecessary operation - --> $DIR/unnecessary_operation.rs:70:5 + --> tests/ui/unnecessary_operation.rs:70:5 | LL | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` @@ -8,103 +8,103 @@ LL | Tuple(get_number()); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_operation)]` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:71:5 + --> tests/ui/unnecessary_operation.rs:71:5 | LL | Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:72:5 + --> tests/ui/unnecessary_operation.rs:72:5 | LL | Struct { ..get_struct() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_struct();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:73:5 + --> tests/ui/unnecessary_operation.rs:73:5 | LL | Enum::Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:74:5 + --> tests/ui/unnecessary_operation.rs:74:5 | LL | Enum::Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:75:5 + --> tests/ui/unnecessary_operation.rs:75:5 | LL | 5 + get_number(); | ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:76:5 + --> tests/ui/unnecessary_operation.rs:76:5 | LL | *&get_number(); | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:77:5 + --> tests/ui/unnecessary_operation.rs:77:5 | LL | &get_number(); | ^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:78:5 + --> tests/ui/unnecessary_operation.rs:78:5 | LL | (5, 6, get_number()); | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;6;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:79:5 + --> tests/ui/unnecessary_operation.rs:79:5 | LL | get_number()..; | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:80:5 + --> tests/ui/unnecessary_operation.rs:80:5 | LL | ..get_number(); | ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:81:5 + --> tests/ui/unnecessary_operation.rs:81:5 | LL | 5..get_number(); | ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:82:5 + --> tests/ui/unnecessary_operation.rs:82:5 | LL | [42, get_number()]; | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:83:5 + --> tests/ui/unnecessary_operation.rs:83:5 | LL | [42, 55][get_usize()]; | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:84:5 + --> tests/ui/unnecessary_operation.rs:84:5 | LL | (42, get_number()).1; | ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:85:5 + --> tests/ui/unnecessary_operation.rs:85:5 | LL | [get_number(); 55]; | ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:86:5 + --> tests/ui/unnecessary_operation.rs:86:5 | LL | [42; 55][get_usize()]; | ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42; 55].len() > get_usize());` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:87:5 + --> tests/ui/unnecessary_operation.rs:87:5 | LL | / { LL | | get_number() @@ -112,7 +112,7 @@ LL | | }; | |______^ help: statement can be reduced to: `get_number();` error: unnecessary operation - --> $DIR/unnecessary_operation.rs:90:5 + --> tests/ui/unnecessary_operation.rs:90:5 | LL | / FooString { LL | | s: String::from("blah"), 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 58d925b1096d9..1820ea4ef5d85 100644 --- a/src/tools/clippy/tests/ui/unnecessary_owned_empty_strings.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_owned_empty_strings.stderr @@ -1,5 +1,5 @@ error: usage of `&String::new()` for a function expecting a `&str` argument - --> $DIR/unnecessary_owned_empty_strings.rs:10:22 + --> tests/ui/unnecessary_owned_empty_strings.rs:10:22 | LL | ref_str_argument(&String::new()); | ^^^^^^^^^^^^^^ help: try: `""` @@ -8,7 +8,7 @@ LL | ref_str_argument(&String::new()); = 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 + --> tests/ui/unnecessary_owned_empty_strings.rs:14:22 | LL | ref_str_argument(&String::from("")); | ^^^^^^^^^^^^^^^^^ help: try: `""` diff --git a/src/tools/clippy/tests/ui/unnecessary_result_map_or_else.stderr b/src/tools/clippy/tests/ui/unnecessary_result_map_or_else.stderr index 0f83be5d55661..e3a6dbf8ecd8b 100644 --- a/src/tools/clippy/tests/ui/unnecessary_result_map_or_else.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_result_map_or_else.stderr @@ -1,5 +1,5 @@ error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:6:5 + --> tests/ui/unnecessary_result_map_or_else.rs:6:5 | LL | x.map_or_else(|err| err, |n| n); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` @@ -8,19 +8,19 @@ LL | x.map_or_else(|err| err, |n| n); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_result_map_or_else)]` error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:10:5 + --> tests/ui/unnecessary_result_map_or_else.rs:10:5 | LL | x.map_or_else(|err: ()| err, |n: ()| n); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err: ()| err)` error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:15:19 + --> tests/ui/unnecessary_result_map_or_else.rs:15:19 | LL | let y: &str = x.map_or_else(|err| err, |n| n); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` error: unused "map closure" when calling `Result::map_or_else` value - --> $DIR/unnecessary_result_map_or_else.rs:19:5 + --> tests/ui/unnecessary_result_map_or_else.rs:19:5 | LL | / x.map_or_else( LL | | diff --git a/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr b/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr index 6d4ef6c308db8..139ed769975b3 100644 --- a/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr @@ -1,11 +1,11 @@ error: constant item has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:6:5 + --> tests/ui/unnecessary_safety_comment.rs:6:5 | LL | const CONST: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:5:5 + --> tests/ui/unnecessary_safety_comment.rs:5:5 | LL | // SAFETY: | ^^^^^^^^^^ @@ -13,55 +13,55 @@ LL | // SAFETY: = 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 + --> tests/ui/unnecessary_safety_comment.rs:9:5 | LL | static STATIC: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:8:5 + --> tests/ui/unnecessary_safety_comment.rs:8:5 | LL | // SAFETY: | ^^^^^^^^^^ error: struct has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:12:5 + --> tests/ui/unnecessary_safety_comment.rs:12:5 | LL | struct Struct; | ^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:11:5 + --> tests/ui/unnecessary_safety_comment.rs:11:5 | LL | // SAFETY: | ^^^^^^^^^^ error: enum has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:15:5 + --> tests/ui/unnecessary_safety_comment.rs:15:5 | LL | enum Enum {} | ^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:14:5 + --> tests/ui/unnecessary_safety_comment.rs:14:5 | LL | // SAFETY: | ^^^^^^^^^^ error: module has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:18:5 + --> tests/ui/unnecessary_safety_comment.rs:18:5 | LL | mod module {} | ^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:17:5 + --> tests/ui/unnecessary_safety_comment.rs:17:5 | LL | // SAFETY: | ^^^^^^^^^^ error: impl has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:38:13 + --> tests/ui/unnecessary_safety_comment.rs:38:13 | LL | impl T for $t {} | ^^^^^^^^^^^^^^^^ @@ -70,44 +70,44 @@ LL | with_safety_comment!(i32); | ------------------------- in this macro invocation | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:37:13 + --> tests/ui/unnecessary_safety_comment.rs:37:13 | LL | // Safety: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `with_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: expression has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:55:5 + --> tests/ui/unnecessary_safety_comment.rs:55:5 | LL | 24 | ^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:54:5 + --> tests/ui/unnecessary_safety_comment.rs:54:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ error: statement has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:47:5 + --> tests/ui/unnecessary_safety_comment.rs:47:5 | LL | let num = 42; | ^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:46:5 + --> tests/ui/unnecessary_safety_comment.rs:46:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ error: statement has unnecessary safety comment - --> $DIR/unnecessary_safety_comment.rs:51:5 + --> tests/ui/unnecessary_safety_comment.rs:51:5 | LL | if num > 24 {} | ^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> $DIR/unnecessary_safety_comment.rs:50:5 + --> tests/ui/unnecessary_safety_comment.rs:50:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr b/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr index 4e50aaececf95..9b143b48c9a6e 100644 --- a/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_self_imports.stderr @@ -1,5 +1,5 @@ error: import ending with `::{self}` - --> $DIR/unnecessary_self_imports.rs:5:1 + --> tests/ui/unnecessary_self_imports.rs:5:1 | LL | use std::fs::{self as alias}; | ^^^^^^^^^-------------------- @@ -11,7 +11,7 @@ LL | use std::fs::{self as alias}; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_self_imports)]` error: import ending with `::{self}` - --> $DIR/unnecessary_self_imports.rs:7:1 + --> tests/ui/unnecessary_self_imports.rs:7:1 | LL | use std::rc::{self}; | ^^^^^^^^^----------- diff --git a/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr b/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr index f4409113a45fa..e2013a4e6f9d2 100644 --- a/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_sort_by.stderr @@ -1,5 +1,5 @@ error: consider using `sort` - --> $DIR/unnecessary_sort_by.rs:12:5 + --> tests/ui/unnecessary_sort_by.rs:12:5 | LL | vec.sort_by(|a, b| a.cmp(b)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort()` @@ -8,67 +8,67 @@ LL | vec.sort_by(|a, b| a.cmp(b)); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_sort_by)]` error: consider using `sort` - --> $DIR/unnecessary_sort_by.rs:13:5 + --> tests/ui/unnecessary_sort_by.rs:13:5 | LL | vec.sort_unstable_by(|a, b| a.cmp(b)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable()` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:14:5 + --> tests/ui/unnecessary_sort_by.rs:14:5 | LL | vec.sort_by(|a, b| (a + 5).abs().cmp(&(b + 5).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|a| (a + 5).abs())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:15:5 + --> tests/ui/unnecessary_sort_by.rs:15:5 | LL | vec.sort_unstable_by(|a, b| id(-a).cmp(&id(-b))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|a| id(-a))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:18:5 + --> tests/ui/unnecessary_sort_by.rs:18:5 | LL | vec.sort_by(|a, b| (b + 5).abs().cmp(&(a + 5).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|b| std::cmp::Reverse((b + 5).abs()))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:19:5 + --> tests/ui/unnecessary_sort_by.rs:19:5 | LL | vec.sort_unstable_by(|a, b| id(-b).cmp(&id(-a))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|b| std::cmp::Reverse(id(-b)))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:29:5 + --> tests/ui/unnecessary_sort_by.rs:29:5 | LL | vec.sort_by(|a, b| (***a).abs().cmp(&(***b).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_by_key(|a| (***a).abs())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:30:5 + --> tests/ui/unnecessary_sort_by.rs:30:5 | LL | vec.sort_unstable_by(|a, b| (***a).abs().cmp(&(***b).abs())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.sort_unstable_by_key(|a| (***a).abs())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:89:9 + --> tests/ui/unnecessary_sort_by.rs:89:9 | LL | args.sort_by(|a, b| a.name().cmp(&b.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|a| a.name())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:90:9 + --> tests/ui/unnecessary_sort_by.rs:90:9 | LL | args.sort_unstable_by(|a, b| a.name().cmp(&b.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_unstable_by_key(|a| a.name())` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:92:9 + --> tests/ui/unnecessary_sort_by.rs:92:9 | LL | args.sort_by(|a, b| b.name().cmp(&a.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_by_key(|b| std::cmp::Reverse(b.name()))` error: consider using `sort_by_key` - --> $DIR/unnecessary_sort_by.rs:93:9 + --> tests/ui/unnecessary_sort_by.rs:93:9 | LL | args.sort_unstable_by(|a, b| b.name().cmp(&a.name())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `args.sort_unstable_by_key(|b| std::cmp::Reverse(b.name()))` diff --git a/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr b/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr index d8e0ce6ccaf27..8bc308c7567b5 100644 --- a/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_struct_initialization.stderr @@ -1,5 +1,5 @@ error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:32:9 + --> tests/ui/unnecessary_struct_initialization.rs:32:9 | LL | Self { ..*self } | ^^^^^^^^^^^^^^^^ help: replace with: `*self` @@ -8,25 +8,25 @@ LL | Self { ..*self } = help: to override `-D warnings` add `#[allow(clippy::unnecessary_struct_initialization)]` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:39:17 + --> tests/ui/unnecessary_struct_initialization.rs:39:17 | LL | let mut b = S { ..a }; | ^^^^^^^^^ help: replace with: `a` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:42:18 + --> tests/ui/unnecessary_struct_initialization.rs:42:18 | LL | let c = &mut S { ..b }; | ^^^^^^^^^ help: replace with: `b` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:50:14 + --> tests/ui/unnecessary_struct_initialization.rs:50:14 | LL | let g = &S { ..f }; | ^^^^^^^^^ help: replace with: `f` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:53:18 + --> tests/ui/unnecessary_struct_initialization.rs:53:18 | LL | let h = &mut S { | __________________^ @@ -35,7 +35,7 @@ LL | | }; | |_____^ help: replace with: `*Box::new(S { f: String::from("foo") })` error: unnecessary struct building - --> $DIR/unnecessary_struct_initialization.rs:72:18 + --> tests/ui/unnecessary_struct_initialization.rs:72:18 | LL | let p = &mut T { | __________________^ diff --git a/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed b/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed index 7f01c981a9380..1afa5ab54c461 100644 --- a/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed +++ b/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed @@ -530,3 +530,39 @@ mod issue_11952 { IntoFuture::into_future(foo([], &0)); } } + +fn borrow_checks() { + use std::borrow::Borrow; + use std::collections::HashSet; + + fn inner(a: &[&str]) { + let mut s = HashSet::from([vec!["a"]]); + s.remove(a); //~ ERROR: unnecessary use of `to_vec` + } + + let mut s = HashSet::from(["a".to_string()]); + s.remove("b"); //~ ERROR: unnecessary use of `to_owned` + s.remove("b"); //~ ERROR: unnecessary use of `to_string` + // Should not warn. + s.remove("b"); + + let mut s = HashSet::from([vec!["a"]]); + s.remove(["b"].as_slice()); //~ ERROR: unnecessary use of `to_vec` + s.remove((&["b"]).as_slice()); //~ ERROR: unnecessary use of `to_vec` + + // Should not warn. + s.remove(&["b"].to_vec().clone()); + s.remove(["a"].as_slice()); + + trait SetExt { + fn foo>(&self, _: &String); + } + + impl SetExt for HashSet { + fn foo>(&self, _: &String) {} + } + + // Should not lint! + HashSet::::new().foo::<&str>(&"".to_owned()); + HashSet::::new().get(&1.to_string()); +} diff --git a/src/tools/clippy/tests/ui/unnecessary_to_owned.rs b/src/tools/clippy/tests/ui/unnecessary_to_owned.rs index a270ed1e1c21e..aa88dde43bf66 100644 --- a/src/tools/clippy/tests/ui/unnecessary_to_owned.rs +++ b/src/tools/clippy/tests/ui/unnecessary_to_owned.rs @@ -530,3 +530,39 @@ mod issue_11952 { IntoFuture::into_future(foo([].to_vec(), &0)); } } + +fn borrow_checks() { + use std::borrow::Borrow; + use std::collections::HashSet; + + fn inner(a: &[&str]) { + let mut s = HashSet::from([vec!["a"]]); + s.remove(&a.to_vec()); //~ ERROR: unnecessary use of `to_vec` + } + + let mut s = HashSet::from(["a".to_string()]); + s.remove(&"b".to_owned()); //~ ERROR: unnecessary use of `to_owned` + s.remove(&"b".to_string()); //~ ERROR: unnecessary use of `to_string` + // Should not warn. + s.remove("b"); + + let mut s = HashSet::from([vec!["a"]]); + s.remove(&["b"].to_vec()); //~ ERROR: unnecessary use of `to_vec` + s.remove(&(&["b"]).to_vec()); //~ ERROR: unnecessary use of `to_vec` + + // Should not warn. + s.remove(&["b"].to_vec().clone()); + s.remove(["a"].as_slice()); + + trait SetExt { + fn foo>(&self, _: &String); + } + + impl SetExt for HashSet { + fn foo>(&self, _: &String) {} + } + + // Should not lint! + HashSet::::new().foo::<&str>(&"".to_owned()); + HashSet::::new().get(&1.to_string()); +} diff --git a/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr b/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr index 95ff5f2ec2cff..5475df9c7b936 100644 --- a/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_to_owned.stderr @@ -1,11 +1,11 @@ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:155:64 + --> tests/ui/unnecessary_to_owned.rs:155:64 | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:155:20 + --> tests/ui/unnecessary_to_owned.rs:155:20 | LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,55 +13,55 @@ LL | require_c_str(&CString::from_vec_with_nul(vec![0]).unwrap().to_owned()) = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: redundant clone - --> $DIR/unnecessary_to_owned.rs:156:40 + --> tests/ui/unnecessary_to_owned.rs:156:40 | LL | require_os_str(&OsString::from("x").to_os_string()); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:156:21 + --> tests/ui/unnecessary_to_owned.rs:156:21 | LL | require_os_str(&OsString::from("x").to_os_string()); | ^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:157:48 + --> tests/ui/unnecessary_to_owned.rs:157:48 | LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); | ^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:157:19 + --> tests/ui/unnecessary_to_owned.rs:157:19 | LL | require_path(&std::path::PathBuf::from("x").to_path_buf()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:158:35 + --> tests/ui/unnecessary_to_owned.rs:158:35 | LL | require_str(&String::from("x").to_string()); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:158:18 + --> tests/ui/unnecessary_to_owned.rs:158:18 | LL | require_str(&String::from("x").to_string()); | ^^^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/unnecessary_to_owned.rs:159:39 + --> tests/ui/unnecessary_to_owned.rs:159:39 | LL | require_slice(&[String::from("x")].to_owned()); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/unnecessary_to_owned.rs:159:20 + --> tests/ui/unnecessary_to_owned.rs:159:20 | LL | require_slice(&[String::from("x")].to_owned()); | ^^^^^^^^^^^^^^^^^^^ error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:64:36 + --> tests/ui/unnecessary_to_owned.rs:64:36 | LL | require_c_str(&Cow::from(c_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this @@ -70,415 +70,415 @@ LL | require_c_str(&Cow::from(c_str).into_owned()); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:65:19 + --> tests/ui/unnecessary_to_owned.rs:65:19 | LL | require_c_str(&c_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_os_string` - --> $DIR/unnecessary_to_owned.rs:67:20 + --> tests/ui/unnecessary_to_owned.rs:67:20 | LL | require_os_str(&os_str.to_os_string()); | ^^^^^^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:68:38 + --> tests/ui/unnecessary_to_owned.rs:68:38 | LL | require_os_str(&Cow::from(os_str).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:69:20 + --> tests/ui/unnecessary_to_owned.rs:69:20 | LL | require_os_str(&os_str.to_owned()); | ^^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_path_buf` - --> $DIR/unnecessary_to_owned.rs:71:18 + --> tests/ui/unnecessary_to_owned.rs:71:18 | LL | require_path(&path.to_path_buf()); | ^^^^^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:72:34 + --> tests/ui/unnecessary_to_owned.rs:72:34 | LL | require_path(&Cow::from(path).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:73:18 + --> tests/ui/unnecessary_to_owned.rs:73:18 | LL | require_path(&path.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:75:17 + --> tests/ui/unnecessary_to_owned.rs:75:17 | LL | require_str(&s.to_string()); | ^^^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:76:30 + --> tests/ui/unnecessary_to_owned.rs:76:30 | LL | require_str(&Cow::from(s).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:77:17 + --> tests/ui/unnecessary_to_owned.rs:77:17 | LL | require_str(&s.to_owned()); | ^^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:78:17 + --> tests/ui/unnecessary_to_owned.rs:78:17 | LL | require_str(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref.as_ref()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:80:19 + --> tests/ui/unnecessary_to_owned.rs:80:19 | LL | require_slice(&slice.to_vec()); | ^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:81:36 + --> tests/ui/unnecessary_to_owned.rs:81:36 | LL | require_slice(&Cow::from(slice).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:82:19 + --> tests/ui/unnecessary_to_owned.rs:82:19 | LL | require_slice(&array.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `array.as_ref()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:83:19 + --> tests/ui/unnecessary_to_owned.rs:83:19 | LL | require_slice(&array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref.as_ref()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:84:19 + --> tests/ui/unnecessary_to_owned.rs:84:19 | LL | require_slice(&slice.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `into_owned` - --> $DIR/unnecessary_to_owned.rs:87:42 + --> tests/ui/unnecessary_to_owned.rs:87:42 | LL | require_x(&Cow::::Owned(x.clone()).into_owned()); | ^^^^^^^^^^^^^ help: remove this error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:90:25 + --> tests/ui/unnecessary_to_owned.rs:90:25 | LL | require_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:91:26 + --> tests/ui/unnecessary_to_owned.rs:91:26 | LL | require_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:92:24 + --> tests/ui/unnecessary_to_owned.rs:92:24 | LL | require_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:93:23 + --> tests/ui/unnecessary_to_owned.rs:93:23 | LL | require_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:94:25 + --> tests/ui/unnecessary_to_owned.rs:94:25 | LL | require_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:96:30 + --> tests/ui/unnecessary_to_owned.rs:96:30 | LL | require_impl_deref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:97:31 + --> tests/ui/unnecessary_to_owned.rs:97:31 | LL | require_impl_deref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:98:29 + --> tests/ui/unnecessary_to_owned.rs:98:29 | LL | require_impl_deref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:99:28 + --> tests/ui/unnecessary_to_owned.rs:99:28 | LL | require_impl_deref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:100:30 + --> tests/ui/unnecessary_to_owned.rs:100:30 | LL | require_impl_deref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:102:29 + --> tests/ui/unnecessary_to_owned.rs:102:29 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:102:43 + --> tests/ui/unnecessary_to_owned.rs:102:43 | LL | require_deref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:103:29 + --> tests/ui/unnecessary_to_owned.rs:103:29 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:103:47 + --> tests/ui/unnecessary_to_owned.rs:103:47 | LL | require_deref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:105:26 + --> tests/ui/unnecessary_to_owned.rs:105:26 | LL | require_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:106:27 + --> tests/ui/unnecessary_to_owned.rs:106:27 | LL | require_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:107:25 + --> tests/ui/unnecessary_to_owned.rs:107:25 | LL | require_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:108:24 + --> tests/ui/unnecessary_to_owned.rs:108:24 | LL | require_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:109:24 + --> tests/ui/unnecessary_to_owned.rs:109:24 | LL | require_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:110:26 + --> tests/ui/unnecessary_to_owned.rs:110:26 | LL | require_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:111:26 + --> tests/ui/unnecessary_to_owned.rs:111:26 | LL | require_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:112:26 + --> tests/ui/unnecessary_to_owned.rs:112:26 | LL | require_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:114:31 + --> tests/ui/unnecessary_to_owned.rs:114:31 | LL | require_impl_as_ref_c_str(c_str.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `c_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:115:32 + --> tests/ui/unnecessary_to_owned.rs:115:32 | LL | require_impl_as_ref_os_str(os_str.to_owned()); | ^^^^^^^^^^^^^^^^^ help: use: `os_str` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:116:30 + --> tests/ui/unnecessary_to_owned.rs:116:30 | LL | require_impl_as_ref_path(path.to_owned()); | ^^^^^^^^^^^^^^^ help: use: `path` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:117:29 + --> tests/ui/unnecessary_to_owned.rs:117:29 | LL | require_impl_as_ref_str(s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:118:29 + --> tests/ui/unnecessary_to_owned.rs:118:29 | LL | require_impl_as_ref_str(x.to_owned()); | ^^^^^^^^^^^^ help: use: `&x` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:119:31 + --> tests/ui/unnecessary_to_owned.rs:119:31 | LL | require_impl_as_ref_slice(array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:120:31 + --> tests/ui/unnecessary_to_owned.rs:120:31 | LL | require_impl_as_ref_slice(array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:121:31 + --> tests/ui/unnecessary_to_owned.rs:121:31 | LL | require_impl_as_ref_slice(slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:123:30 + --> tests/ui/unnecessary_to_owned.rs:123:30 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:123:44 + --> tests/ui/unnecessary_to_owned.rs:123:44 | LL | require_as_ref_str_slice(s.to_owned(), array.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:124:30 + --> tests/ui/unnecessary_to_owned.rs:124:30 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:124:44 + --> tests/ui/unnecessary_to_owned.rs:124:44 | LL | require_as_ref_str_slice(s.to_owned(), array_ref.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:125:30 + --> tests/ui/unnecessary_to_owned.rs:125:30 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:125:44 + --> tests/ui/unnecessary_to_owned.rs:125:44 | LL | require_as_ref_str_slice(s.to_owned(), slice.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:126:30 + --> tests/ui/unnecessary_to_owned.rs:126:30 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `array` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:126:48 + --> tests/ui/unnecessary_to_owned.rs:126:48 | LL | require_as_ref_slice_str(array.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:127:30 + --> tests/ui/unnecessary_to_owned.rs:127:30 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^^^^^ help: use: `array_ref` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:127:52 + --> tests/ui/unnecessary_to_owned.rs:127:52 | LL | require_as_ref_slice_str(array_ref.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:128:30 + --> tests/ui/unnecessary_to_owned.rs:128:30 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^^^^^ help: use: `slice` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:128:48 + --> tests/ui/unnecessary_to_owned.rs:128:48 | LL | require_as_ref_slice_str(slice.to_owned(), s.to_owned()); | ^^^^^^^^^^^^ help: use: `s` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:130:20 + --> tests/ui/unnecessary_to_owned.rs:130:20 | LL | let _ = x.join(&x_ref.to_string()); | ^^^^^^^^^^^^^^^^^^ help: use: `x_ref` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:132:13 + --> tests/ui/unnecessary_to_owned.rs:132:13 | LL | let _ = slice.to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:133:13 + --> tests/ui/unnecessary_to_owned.rs:133:13 | LL | let _ = slice.to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:134:13 + --> tests/ui/unnecessary_to_owned.rs:134:13 | LL | let _ = [std::path::PathBuf::new()][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:135:13 + --> tests/ui/unnecessary_to_owned.rs:135:13 | LL | let _ = [std::path::PathBuf::new()][..].to_owned().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:137:13 + --> tests/ui/unnecessary_to_owned.rs:137:13 | LL | let _ = IntoIterator::into_iter(slice.to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:138:13 + --> tests/ui/unnecessary_to_owned.rs:138:13 | LL | let _ = IntoIterator::into_iter(slice.to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:139:13 + --> tests/ui/unnecessary_to_owned.rs:139:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned.rs:140:13 + --> tests/ui/unnecessary_to_owned.rs:140:13 | LL | let _ = IntoIterator::into_iter([std::path::PathBuf::new()][..].to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[std::path::PathBuf::new()][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:202:14 + --> tests/ui/unnecessary_to_owned.rs:202:14 | LL | for t in file_types.to_vec() { | ^^^^^^^^^^^^^^^^^^^ @@ -494,34 +494,64 @@ LL + let path = match get_file_path(t) { | error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:225:14 + --> tests/ui/unnecessary_to_owned.rs:225:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().cloned()` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:230:14 + --> tests/ui/unnecessary_to_owned.rs:230:14 | LL | let _ = &["x"][..].to_vec().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `["x"][..].iter().copied()` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:278:24 + --> tests/ui/unnecessary_to_owned.rs:278:24 | LL | Box::new(build(y.to_string())) | ^^^^^^^^^^^^^ help: use: `y` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned.rs:387:12 + --> tests/ui/unnecessary_to_owned.rs:387:12 | LL | id("abc".to_string()) | ^^^^^^^^^^^^^^^^^ help: use: `"abc"` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned.rs:530:37 + --> tests/ui/unnecessary_to_owned.rs:530:37 | LL | IntoFuture::into_future(foo([].to_vec(), &0)); | ^^^^^^^^^^^ help: use: `[]` -error: aborting due to 80 previous errors +error: unnecessary use of `to_vec` + --> tests/ui/unnecessary_to_owned.rs:540:18 + | +LL | s.remove(&a.to_vec()); + | ^^^^^^^^^^^ help: replace it with: `a` + +error: unnecessary use of `to_owned` + --> tests/ui/unnecessary_to_owned.rs:544:14 + | +LL | s.remove(&"b".to_owned()); + | ^^^^^^^^^^^^^^^ help: replace it with: `"b"` + +error: unnecessary use of `to_string` + --> tests/ui/unnecessary_to_owned.rs:545:14 + | +LL | s.remove(&"b".to_string()); + | ^^^^^^^^^^^^^^^^ help: replace it with: `"b"` + +error: unnecessary use of `to_vec` + --> tests/ui/unnecessary_to_owned.rs:550:14 + | +LL | s.remove(&["b"].to_vec()); + | ^^^^^^^^^^^^^^^ help: replace it with: `["b"].as_slice()` + +error: unnecessary use of `to_vec` + --> tests/ui/unnecessary_to_owned.rs:551:14 + | +LL | s.remove(&(&["b"]).to_vec()); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `(&["b"]).as_slice()` + +error: aborting due to 85 previous errors diff --git a/src/tools/clippy/tests/ui/unnecessary_to_owned_on_split.stderr b/src/tools/clippy/tests/ui/unnecessary_to_owned_on_split.stderr index 9aea15b48bfbd..cf5c964bcf3cd 100644 --- a/src/tools/clippy/tests/ui/unnecessary_to_owned_on_split.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_to_owned_on_split.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:19:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:19:13 | LL | let _ = "a".to_string().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` @@ -8,49 +8,49 @@ LL | let _ = "a".to_string().split('a').next().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_to_owned)]` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:21:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:21:13 | LL | let _ = "a".to_string().split("a").next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split("a")` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:23:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:23:13 | LL | let _ = "a".to_owned().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split('a')` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:25:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:25:13 | LL | let _ = "a".to_owned().split("a").next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `"a".split("a")` error: unnecessary use of `to_string` - --> $DIR/unnecessary_to_owned_on_split.rs:27:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:27:13 | LL | let _ = Issue12068.to_string().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Issue12068.as_ref().split('a')` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned_on_split.rs:30:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:30:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_vec` - --> $DIR/unnecessary_to_owned_on_split.rs:32:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:32:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:34:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:34:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> $DIR/unnecessary_to_owned_on_split.rs:36:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:36:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` diff --git a/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr b/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr index 817eb3e26eed5..d8a9f0aa38c33 100644 --- a/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_unsafety_doc.stderr @@ -1,5 +1,5 @@ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:19:1 + --> tests/ui/unnecessary_unsafety_doc.rs:19:1 | LL | pub fn apocalypse(universe: &mut ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | pub fn apocalypse(universe: &mut ()) { = 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 + --> tests/ui/unnecessary_unsafety_doc.rs:45:5 | LL | pub fn republished() { | ^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:58:5 + --> tests/ui/unnecessary_unsafety_doc.rs:58:5 | LL | fn documented(self); | ^^^^^^^^^^^^^^^^^^^^ error: docs for safe trait have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:68:1 + --> tests/ui/unnecessary_unsafety_doc.rs:68:1 | LL | pub trait DocumentedSafeTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:96:5 + --> tests/ui/unnecessary_unsafety_doc.rs:96:5 | LL | pub fn documented() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: safe function's docs have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:123:9 + --> tests/ui/unnecessary_unsafety_doc.rs:123:9 | LL | pub fn drive() { | ^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | very_safe!(); = note: this error originates in the macro `very_safe` (in Nightly builds, run with -Z macro-backtrace for more info) error: docs for safe trait have unnecessary `# Safety` section - --> $DIR/unnecessary_unsafety_doc.rs:151:1 + --> tests/ui/unnecessary_unsafety_doc.rs:151:1 | LL | pub trait DocumentedSafeTraitWithImplementationHeader { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnecessary_wraps.stderr b/src/tools/clippy/tests/ui/unnecessary_wraps.stderr index 20d3e070e71c9..a55a23d449f57 100644 --- a/src/tools/clippy/tests/ui/unnecessary_wraps.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_wraps.stderr @@ -1,5 +1,5 @@ error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:9:1 + --> tests/ui/unnecessary_wraps.rs:9:1 | LL | / fn func1(a: bool, b: bool) -> Option { LL | | @@ -28,7 +28,7 @@ LL ~ return 1337; | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:24:1 + --> tests/ui/unnecessary_wraps.rs:24:1 | LL | / fn func2(a: bool, b: bool) -> Option { LL | | @@ -51,7 +51,7 @@ LL ~ if a { 20 } else { 30 } | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:43:1 + --> tests/ui/unnecessary_wraps.rs:43:1 | LL | / fn func5() -> Option { LL | | @@ -69,7 +69,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Result` - --> $DIR/unnecessary_wraps.rs:54:1 + --> tests/ui/unnecessary_wraps.rs:54:1 | LL | / fn func7() -> Result { LL | | @@ -87,7 +87,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Option` - --> $DIR/unnecessary_wraps.rs:83:5 + --> tests/ui/unnecessary_wraps.rs:83:5 | LL | / fn func12() -> Option { LL | | @@ -105,7 +105,7 @@ LL | 1 | error: this function's return value is unnecessary - --> $DIR/unnecessary_wraps.rs:111:1 + --> tests/ui/unnecessary_wraps.rs:111:1 | LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> { LL | | @@ -132,7 +132,7 @@ LL ~ return ; | error: this function's return value is unnecessary - --> $DIR/unnecessary_wraps.rs:125:1 + --> tests/ui/unnecessary_wraps.rs:125:1 | LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { LL | | diff --git a/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr b/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr index 68b433df8aaac..4ea33a5db9e2f 100644 --- a/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr +++ b/src/tools/clippy/tests/ui/unneeded_field_pattern.stderr @@ -1,5 +1,5 @@ error: you matched a field with a wildcard pattern, consider using `..` instead - --> $DIR/unneeded_field_pattern.rs:18:15 + --> tests/ui/unneeded_field_pattern.rs:18:15 | LL | Foo { a: _, b: 0, .. } => {}, | ^^^^ @@ -9,7 +9,7 @@ LL | Foo { a: _, b: 0, .. } => {}, = 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 + --> tests/ui/unneeded_field_pattern.rs:20:9 | LL | Foo { a: _, b: _, c: _ } => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unneeded_wildcard_pattern.stderr b/src/tools/clippy/tests/ui/unneeded_wildcard_pattern.stderr index f2880a8e68d38..ceb7d7fe9e09f 100644 --- a/src/tools/clippy/tests/ui/unneeded_wildcard_pattern.stderr +++ b/src/tools/clippy/tests/ui/unneeded_wildcard_pattern.stderr @@ -1,89 +1,89 @@ error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:12:18 + --> tests/ui/unneeded_wildcard_pattern.rs:12:18 | LL | if let (0, .., _) = t {}; | ^^^ help: remove it | note: the lint level is defined here - --> $DIR/unneeded_wildcard_pattern.rs:3:9 + --> tests/ui/unneeded_wildcard_pattern.rs:3:9 | LL | #![deny(clippy::unneeded_wildcard_pattern)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:13:16 + --> tests/ui/unneeded_wildcard_pattern.rs:13:16 | LL | if let (0, _, ..) = t {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:14:13 + --> tests/ui/unneeded_wildcard_pattern.rs:14:13 | LL | if let (_, .., 0) = t {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:15:15 + --> tests/ui/unneeded_wildcard_pattern.rs:15:15 | LL | if let (.., _, 0) = t {}; | ^^^ help: remove it error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:16:16 + --> tests/ui/unneeded_wildcard_pattern.rs:16:16 | LL | if let (0, _, _, ..) = t {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:17:18 + --> tests/ui/unneeded_wildcard_pattern.rs:17:18 | LL | if let (0, .., _, _) = t {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:26:22 + --> tests/ui/unneeded_wildcard_pattern.rs:26:22 | LL | if let (0, .., _, _,) = t {}; | ^^^^^^ help: remove them error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:33:19 + --> tests/ui/unneeded_wildcard_pattern.rs:33:19 | LL | if let S(0, .., _) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:34:17 + --> tests/ui/unneeded_wildcard_pattern.rs:34:17 | LL | if let S(0, _, ..) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:35:14 + --> tests/ui/unneeded_wildcard_pattern.rs:35:14 | LL | if let S(_, .., 0) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element - --> $DIR/unneeded_wildcard_pattern.rs:36:16 + --> tests/ui/unneeded_wildcard_pattern.rs:36:16 | LL | if let S(.., _, 0) = s {}; | ^^^ help: remove it error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:37:17 + --> tests/ui/unneeded_wildcard_pattern.rs:37:17 | LL | if let S(0, _, _, ..) = s {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:38:19 + --> tests/ui/unneeded_wildcard_pattern.rs:38:19 | LL | if let S(0, .., _, _) = s {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements - --> $DIR/unneeded_wildcard_pattern.rs:47:23 + --> tests/ui/unneeded_wildcard_pattern.rs:47:23 | LL | if let S(0, .., _, _,) = s {}; | ^^^^^^ help: remove them diff --git a/src/tools/clippy/tests/ui/unnested_or_patterns.stderr b/src/tools/clippy/tests/ui/unnested_or_patterns.stderr index 98ca7e3735678..bd15ef62368ea 100644 --- a/src/tools/clippy/tests/ui/unnested_or_patterns.stderr +++ b/src/tools/clippy/tests/ui/unnested_or_patterns.stderr @@ -1,5 +1,5 @@ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:16:12 + --> tests/ui/unnested_or_patterns.rs:16:12 | LL | if let box 0 | box 2 = Box::new(0) {} | ^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let box (0 | 2) = Box::new(0) {} | ~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:17:12 + --> tests/ui/unnested_or_patterns.rs:17:12 | LL | if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} | ~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:19:12 + --> tests/ui/unnested_or_patterns.rs:19:12 | LL | if let Some(1) | C0 | Some(2) = None {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | if let Some(1 | 2) | C0 = None {} | ~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:20:12 + --> tests/ui/unnested_or_patterns.rs:20:12 | LL | if let &mut 0 | &mut 2 = &mut 0 {} | ^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | if let &mut (0 | 2) = &mut 0 {} | ~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:21:12 + --> tests/ui/unnested_or_patterns.rs:21:12 | LL | if let x @ 0 | x @ 2 = 0 {} | ^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | if let x @ (0 | 2) = 0 {} | ~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:22:12 + --> tests/ui/unnested_or_patterns.rs:22:12 | LL | if let (0, 1) | (0, 2) | (0, 3) = (0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | if let (0, 1 | 2 | 3) = (0, 0) {} | ~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:23:12 + --> tests/ui/unnested_or_patterns.rs:23:12 | LL | if let (1, 0) | (2, 0) | (3, 0) = (0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | if let (1 | 2 | 3, 0) = (0, 0) {} | ~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:24:12 + --> tests/ui/unnested_or_patterns.rs:24:12 | LL | if let (x, ..) | (x, 1) | (x, 2) = (0, 1) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | if let (x, ..) | (x, 1 | 2) = (0, 1) {} | ~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:25:12 + --> tests/ui/unnested_or_patterns.rs:25:12 | LL | if let [0] | [1] = [0] {} | ^^^^^^^^^ @@ -100,7 +100,7 @@ LL | if let [0 | 1] = [0] {} | ~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:26:12 + --> tests/ui/unnested_or_patterns.rs:26:12 | LL | if let [x, 0] | [x, 1] = [0, 1] {} | ^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | if let [x, 0 | 1] = [0, 1] {} | ~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:27:12 + --> tests/ui/unnested_or_patterns.rs:27:12 | LL | if let [x, 0] | [x, 1] | [x, 2] = [0, 1] {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | if let [x, 0 | 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:28:12 + --> tests/ui/unnested_or_patterns.rs:28:12 | LL | if let [x, ..] | [x, 1] | [x, 2] = [0, 1] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | if let [x, ..] | [x, 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:30:12 + --> tests/ui/unnested_or_patterns.rs:30:12 | LL | if let TS(0, x) | TS(1, x) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | if let TS(0 | 1, x) = TS(0, 0) {} | ~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:31:12 + --> tests/ui/unnested_or_patterns.rs:31:12 | LL | if let TS(1, 0) | TS(2, 0) | TS(3, 0) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | if let TS(1 | 2 | 3, 0) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:32:12 + --> tests/ui/unnested_or_patterns.rs:32:12 | LL | if let TS(x, ..) | TS(x, 1) | TS(x, 2) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | if let TS(x, ..) | TS(x, 1 | 2) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:37:12 + --> tests/ui/unnested_or_patterns.rs:37:12 | LL | if let S { x: 0, y } | S { y, x: 1 } = (S { x: 0, y: 1 }) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {} | ~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns.rs:48:12 + --> tests/ui/unnested_or_patterns.rs:48:12 | LL | if let [1] | [53] = [0] {} | ^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr b/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr index 182ae00de2208..54f03937508a9 100644 --- a/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr +++ b/src/tools/clippy/tests/ui/unnested_or_patterns2.stderr @@ -1,5 +1,5 @@ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:12:12 + --> tests/ui/unnested_or_patterns2.rs:12:12 | LL | if let Some(Some(0)) | Some(Some(1)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let Some(Some(0 | 1)) = None {} | ~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:13:12 + --> tests/ui/unnested_or_patterns2.rs:13:12 | LL | if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if let Some(Some(0 | 1 | 2)) = None {} | ~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:14:12 + --> tests/ui/unnested_or_patterns2.rs:14:12 | LL | if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:15:12 + --> tests/ui/unnested_or_patterns2.rs:15:12 | LL | if let Some(Some(0) | Some(1 | 2)) = None {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | if let Some(Some(0 | 1 | 2)) = None {} | ~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:16:12 + --> tests/ui/unnested_or_patterns2.rs:16:12 | LL | if let ((0,),) | ((1,) | (2,),) = ((0,),) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | if let ((0 | 1 | 2,),) = ((0,),) {} | ~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:17:12 + --> tests/ui/unnested_or_patterns2.rs:17:12 | LL | if let 0 | (1 | 2) = 0 {} | ^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | if let 0 | 1 | 2 = 0 {} | ~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:18:12 + --> tests/ui/unnested_or_patterns2.rs:18:12 | LL | if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} | ~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns - --> $DIR/unnested_or_patterns2.rs:19:12 + --> tests/ui/unnested_or_patterns2.rs:19:12 | LL | if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unreadable_literal.stderr b/src/tools/clippy/tests/ui/unreadable_literal.stderr index 37f91acf82b94..5e350d760643a 100644 --- a/src/tools/clippy/tests/ui/unreadable_literal.stderr +++ b/src/tools/clippy/tests/ui/unreadable_literal.stderr @@ -1,5 +1,5 @@ error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:17 + --> tests/ui/unreadable_literal.rs:31:17 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` @@ -8,55 +8,55 @@ LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); = help: to override `-D warnings` add `#[allow(clippy::unreadable_literal)]` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:31 + --> tests/ui/unreadable_literal.rs:31:31 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^^^^^ help: consider: `0x1234_5678_usize` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:49 + --> tests/ui/unreadable_literal.rs:31:49 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^ help: consider: `123_456_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:31:61 + --> tests/ui/unreadable_literal.rs:31:61 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `1.234_567_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:33:20 + --> tests/ui/unreadable_literal.rs:33:20 | LL | let _bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:35:18 + --> tests/ui/unreadable_literal.rs:35:18 | LL | let _fail1 = 0xabcdef; | ^^^^^^^^ help: consider: `0x00ab_cdef` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:36:23 + --> tests/ui/unreadable_literal.rs:36:23 | LL | let _fail2: u32 = 0xBAFEBAFE; | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:37:18 + --> tests/ui/unreadable_literal.rs:37:18 | LL | let _fail3 = 0xabcdeff; | ^^^^^^^^^ help: consider: `0x0abc_deff` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:38:24 + --> tests/ui/unreadable_literal.rs:38:24 | LL | let _fail4: i128 = 0xabcabcabcabcabcabc; | ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:39:18 + --> tests/ui/unreadable_literal.rs:39:18 | LL | let _fail5 = 1.100300400; | ^^^^^^^^^^^ help: consider: `1.100_300_400` diff --git a/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr b/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr index d6fb82398d87a..f2d4429f707a5 100644 --- a/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr +++ b/src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr @@ -1,5 +1,5 @@ error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe` - --> $DIR/unsafe_derive_deserialize.rs:8:10 + --> tests/ui/unsafe_derive_deserialize.rs:8:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[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` - --> $DIR/unsafe_derive_deserialize.rs:17:10 + --> tests/ui/unsafe_derive_deserialize.rs:17:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | #[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` - --> $DIR/unsafe_derive_deserialize.rs:24:10 + --> tests/ui/unsafe_derive_deserialize.rs:24:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | #[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` - --> $DIR/unsafe_derive_deserialize.rs:33:10 + --> tests/ui/unsafe_derive_deserialize.rs:33:10 | LL | #[derive(Deserialize)] | ^^^^^^^^^^^ 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 261c7837a4c1f..998cdbb579f65 100644 --- a/src/tools/clippy/tests/ui/unsafe_removed_from_name.stderr +++ b/src/tools/clippy/tests/ui/unsafe_removed_from_name.stderr @@ -1,5 +1,5 @@ error: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCell` - --> $DIR/unsafe_removed_from_name.rs:5:1 + --> tests/ui/unsafe_removed_from_name.rs:5:1 | LL | use std::cell::UnsafeCell as TotallySafeCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,25 +8,25 @@ LL | use std::cell::UnsafeCell as TotallySafeCell; = 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 + --> tests/ui/unsafe_removed_from_name.rs:9:1 | LL | use std::cell::UnsafeCell as TotallySafeCellAgain; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `LieAboutModSafety` - --> $DIR/unsafe_removed_from_name.rs:28:1 + --> tests/ui/unsafe_removed_from_name.rs:28:1 | LL | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `A` - --> $DIR/unsafe_removed_from_name.rs:32:1 + --> tests/ui/unsafe_removed_from_name.rs:32:1 | LL | use mod_with_some_unsafe_things::{Unsafe as A, Unsafe as B}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `B` - --> $DIR/unsafe_removed_from_name.rs:32:1 + --> tests/ui/unsafe_removed_from_name.rs:32:1 | LL | use mod_with_some_unsafe_things::{Unsafe as A, Unsafe as B}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr b/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr index d74e728750577..1c51f7ada91f1 100644 --- a/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr +++ b/src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr @@ -1,5 +1,5 @@ error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:23:18 + --> tests/ui/unseparated_prefix_literals.rs:23:18 | LL | let _fail1 = 1234i32; | ^^^^^^^ help: add an underscore: `1234_i32` @@ -8,43 +8,43 @@ LL | let _fail1 = 1234i32; = 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 + --> tests/ui/unseparated_prefix_literals.rs:24:18 | LL | let _fail2 = 1234u32; | ^^^^^^^ help: add an underscore: `1234_u32` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:25:18 + --> tests/ui/unseparated_prefix_literals.rs:25:18 | LL | let _fail3 = 1234isize; | ^^^^^^^^^ help: add an underscore: `1234_isize` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:26:18 + --> tests/ui/unseparated_prefix_literals.rs:26:18 | LL | let _fail4 = 1234usize; | ^^^^^^^^^ help: add an underscore: `1234_usize` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:27:18 + --> tests/ui/unseparated_prefix_literals.rs:27:18 | LL | let _fail5 = 0x123isize; | ^^^^^^^^^^ help: add an underscore: `0x123_isize` error: float type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:31:19 + --> tests/ui/unseparated_prefix_literals.rs:31:19 | LL | let _failf1 = 1.5f32; | ^^^^^^ help: add an underscore: `1.5_f32` error: float type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:32:19 + --> tests/ui/unseparated_prefix_literals.rs:32:19 | LL | let _failf2 = 1f32; | ^^^^ help: add an underscore: `1_f32` error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:15:9 + --> tests/ui/unseparated_prefix_literals.rs:15:9 | LL | 42usize | ^^^^^^^ help: add an underscore: `42_usize` @@ -55,7 +55,7 @@ LL | let _ = lit_from_macro!(); = note: this error originates in the macro `lit_from_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: integer type suffix should be separated by an underscore - --> $DIR/unseparated_prefix_literals.rs:40:16 + --> tests/ui/unseparated_prefix_literals.rs:40:16 | LL | assert_eq!(4897u32, 32223); | ^^^^^^^ help: add an underscore: `4897_u32` diff --git a/src/tools/clippy/tests/ui/unused_async.stderr b/src/tools/clippy/tests/ui/unused_async.stderr index c97a76a55cbe1..337c650e029f8 100644 --- a/src/tools/clippy/tests/ui/unused_async.stderr +++ b/src/tools/clippy/tests/ui/unused_async.stderr @@ -1,5 +1,5 @@ error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:12:5 + --> tests/ui/unused_async.rs:12:5 | LL | / async fn async_block_await() { LL | | @@ -11,7 +11,7 @@ LL | | } | = help: consider removing the `async` from this function note: `await` used in an async block, which does not require the enclosing function to be `async` - --> $DIR/unused_async.rs:15:23 + --> tests/ui/unused_async.rs:15:23 | LL | ready(()).await; | ^^^^^ @@ -19,7 +19,7 @@ LL | ready(()).await; = help: to override `-D warnings` add `#[allow(clippy::unused_async)]` error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:45:5 + --> tests/ui/unused_async.rs:45:5 | LL | async fn f3() {} | ^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | async fn f3() {} = help: consider removing the `async` from this function error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:58:1 + --> tests/ui/unused_async.rs:58:1 | LL | / async fn foo() -> i32 { LL | | @@ -38,7 +38,7 @@ LL | | } = help: consider removing the `async` from this function error: unused `async` for function with no await statements - --> $DIR/unused_async.rs:70:5 + --> tests/ui/unused_async.rs:70:5 | LL | / async fn unused(&self) -> i32 { LL | | diff --git a/src/tools/clippy/tests/ui/unused_enumerate_index.stderr b/src/tools/clippy/tests/ui/unused_enumerate_index.stderr index b575fbbc4e616..7bd7d29117e24 100644 --- a/src/tools/clippy/tests/ui/unused_enumerate_index.stderr +++ b/src/tools/clippy/tests/ui/unused_enumerate_index.stderr @@ -1,5 +1,5 @@ error: you seem to use `.enumerate()` and immediately discard the index - --> $DIR/unused_enumerate_index.rs:8:19 + --> tests/ui/unused_enumerate_index.rs:8:19 | LL | for (_, x) in v.iter().enumerate() { | ^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | for x in v.iter() { | ~ ~~~~~~~~ error: you seem to use `.enumerate()` and immediately discard the index - --> $DIR/unused_enumerate_index.rs:55:19 + --> tests/ui/unused_enumerate_index.rs:55:19 | LL | for (_, x) in dummy.enumerate() { | ^^^^^^^^^^^^^^^^^ 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 183e80c853c66..d3b334c6092ed 100644 --- a/src/tools/clippy/tests/ui/unused_format_specs_unfixable.stderr +++ b/src/tools/clippy/tests/ui/unused_format_specs_unfixable.stderr @@ -1,5 +1,5 @@ error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:12:15 + --> tests/ui/unused_format_specs_unfixable.rs:12:15 | LL | println!("{:5}.", format_args!("")); | ^^^^ @@ -17,7 +17,7 @@ LL + println!("{}.", format_args!("")); | error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:16:15 + --> tests/ui/unused_format_specs_unfixable.rs:16:15 | LL | println!("{:.3}", format_args!("abcde")); | ^^^^^ @@ -33,7 +33,7 @@ LL + println!("{}", format_args!("abcde")); | error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:19:15 + --> tests/ui/unused_format_specs_unfixable.rs:19:15 | LL | println!("{:5}.", format_args_from_macro!()); | ^^^^ @@ -46,7 +46,7 @@ LL + println!("{}.", format_args_from_macro!()); | error: format specifiers have no effect on `format_args!()` - --> $DIR/unused_format_specs_unfixable.rs:23:15 + --> tests/ui/unused_format_specs_unfixable.rs:23:15 | LL | println!("{args:5}"); | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unused_io_amount.stderr b/src/tools/clippy/tests/ui/unused_io_amount.stderr index 1aab56966a88c..771e463ca010a 100644 --- a/src/tools/clippy/tests/ui/unused_io_amount.stderr +++ b/src/tools/clippy/tests/ui/unused_io_amount.stderr @@ -1,5 +1,5 @@ error: written amount is not handled - --> $DIR/unused_io_amount.rs:10:5 + --> tests/ui/unused_io_amount.rs:10:5 | LL | s.write(b"test")?; | ^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | s.write(b"test")?; = help: to override `-D warnings` add `#[allow(clippy::unused_io_amount)]` error: read amount is not handled - --> $DIR/unused_io_amount.rs:13:5 + --> tests/ui/unused_io_amount.rs:13:5 | LL | s.read(&mut buf)?; | ^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | s.read(&mut buf)?; = help: use `Read::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:19:5 + --> tests/ui/unused_io_amount.rs:19:5 | LL | s.write(b"test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | s.write(b"test").unwrap(); = help: use `Write::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:22:5 + --> tests/ui/unused_io_amount.rs:22:5 | LL | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,19 +33,19 @@ LL | s.read(&mut buf).unwrap(); = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:27:5 + --> tests/ui/unused_io_amount.rs:27:5 | LL | s.read_vectored(&mut [io::IoSliceMut::new(&mut [])])?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:29:5 + --> tests/ui/unused_io_amount.rs:29:5 | LL | s.write_vectored(&[io::IoSlice::new(&[])])?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:37:5 + --> tests/ui/unused_io_amount.rs:37:5 | LL | reader.read(&mut result).ok()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | reader.read(&mut result).ok()?; = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:47:5 + --> tests/ui/unused_io_amount.rs:47:5 | LL | reader.read(&mut result).or_else(|err| Err(err))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | reader.read(&mut result).or_else(|err| Err(err))?; = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:60:5 + --> tests/ui/unused_io_amount.rs:60:5 | LL | reader.read(&mut result).or(Err(Error::Kind))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | reader.read(&mut result).or(Err(Error::Kind))?; = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:68:5 + --> tests/ui/unused_io_amount.rs:68:5 | LL | / reader LL | | @@ -82,7 +82,7 @@ LL | | .expect("error"); = help: use `Read::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:78:5 + --> tests/ui/unused_io_amount.rs:78:5 | LL | s.write(b"ok").is_ok(); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | s.write(b"ok").is_ok(); = help: use `Write::write_all` instead, or handle partial writes error: written amount is not handled - --> $DIR/unused_io_amount.rs:80:5 + --> tests/ui/unused_io_amount.rs:80:5 | LL | s.write(b"err").is_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -98,7 +98,7 @@ LL | s.write(b"err").is_err(); = help: use `Write::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:83:5 + --> tests/ui/unused_io_amount.rs:83:5 | LL | s.read(&mut buf).is_ok(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | s.read(&mut buf).is_ok(); = help: use `Read::read_exact` instead, or handle partial reads error: read amount is not handled - --> $DIR/unused_io_amount.rs:85:5 + --> tests/ui/unused_io_amount.rs:85:5 | LL | s.read(&mut buf).is_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | s.read(&mut buf).is_err(); = help: use `Read::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:90:5 + --> tests/ui/unused_io_amount.rs:90:5 | LL | w.write(b"hello world").await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | w.write(b"hello world").await.unwrap(); = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:96:5 + --> tests/ui/unused_io_amount.rs:96:5 | LL | r.read(&mut buf[..]).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | r.read(&mut buf[..]).await.unwrap(); = help: use `AsyncReadExt::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:104:5 + --> tests/ui/unused_io_amount.rs:104:5 | LL | w.write(b"hello world"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,7 +138,7 @@ LL | w.write(b"hello world"); = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: written amount is not handled - --> $DIR/unused_io_amount.rs:110:9 + --> tests/ui/unused_io_amount.rs:110:9 | LL | w.write(b"hello world").await?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -146,7 +146,7 @@ LL | w.write(b"hello world").await?; = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:119:9 + --> tests/ui/unused_io_amount.rs:119:9 | LL | r.read(&mut buf[..]).await.or(Err(Error::Kind))?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL | r.read(&mut buf[..]).await.or(Err(Error::Kind))?; = help: use `AsyncReadExt::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:128:5 + --> tests/ui/unused_io_amount.rs:128:5 | LL | w.write(b"hello world").await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -162,7 +162,7 @@ LL | w.write(b"hello world").await.unwrap(); = help: use `AsyncWriteExt::write_all` instead, or handle partial writes error: read amount is not handled - --> $DIR/unused_io_amount.rs:134:5 + --> tests/ui/unused_io_amount.rs:134:5 | LL | r.read(&mut buf[..]).await.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -170,92 +170,92 @@ LL | r.read(&mut buf[..]).await.unwrap(); = help: use `AsyncReadExt::read_exact` instead, or handle partial reads error: written amount is not handled - --> $DIR/unused_io_amount.rs:147:11 + --> tests/ui/unused_io_amount.rs:147:11 | LL | match s.write(b"test") { | ^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:149:9 + --> tests/ui/unused_io_amount.rs:149:9 | LL | Ok(_) => todo!(), | ^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:155:11 + --> tests/ui/unused_io_amount.rs:155:11 | LL | match s.read(&mut buf) { | ^^^^^^^^^^^^^^^^ | = help: use `Read::read_exact` instead, or handle partial reads note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:157:9 + --> tests/ui/unused_io_amount.rs:157:9 | LL | Ok(_) => todo!(), | ^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:164:11 + --> tests/ui/unused_io_amount.rs:164:11 | LL | match s.read(&mut [0u8; 4]) { | ^^^^^^^^^^^^^^^^^^^^^ | = help: use `Read::read_exact` instead, or handle partial reads note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:166:9 + --> tests/ui/unused_io_amount.rs:166:9 | LL | Ok(_) => todo!(), | ^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:173:11 + --> tests/ui/unused_io_amount.rs:173:11 | LL | match s.write(b"test") { | ^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:175:9 + --> tests/ui/unused_io_amount.rs:175:9 | LL | Ok(_) => todo!(), | ^^^^^ error: read amount is not handled - --> $DIR/unused_io_amount.rs:186:8 + --> tests/ui/unused_io_amount.rs:186:8 | LL | if let Ok(_) = s.read(&mut [0u8; 4]) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `Read::read_exact` instead, or handle partial reads note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:186:12 + --> tests/ui/unused_io_amount.rs:186:12 | LL | if let Ok(_) = s.read(&mut [0u8; 4]) { | ^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:193:8 + --> tests/ui/unused_io_amount.rs:193:8 | LL | if let Ok(_) = s.write(b"test") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:193:12 + --> tests/ui/unused_io_amount.rs:193:12 | LL | if let Ok(_) = s.write(b"test") { | ^^^^^ error: written amount is not handled - --> $DIR/unused_io_amount.rs:200:8 + --> tests/ui/unused_io_amount.rs:200:8 | LL | if let Ok(..) = s.write(b"test") { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: use `Write::write_all` instead, or handle partial writes note: the result is consumed here, but the amount of I/O bytes remains unhandled - --> $DIR/unused_io_amount.rs:200:12 + --> tests/ui/unused_io_amount.rs:200:12 | LL | if let Ok(..) = s.write(b"test") { | ^^^^^^ diff --git a/src/tools/clippy/tests/ui/unused_peekable.stderr b/src/tools/clippy/tests/ui/unused_peekable.stderr index 157d6fc15f2f7..00c6a52bab336 100644 --- a/src/tools/clippy/tests/ui/unused_peekable.stderr +++ b/src/tools/clippy/tests/ui/unused_peekable.stderr @@ -1,5 +1,5 @@ error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:13:9 + --> tests/ui/unused_peekable.rs:13:9 | LL | let peekable = std::iter::empty::().peekable(); | ^^^^^^^^ @@ -9,7 +9,7 @@ LL | let peekable = std::iter::empty::().peekable(); = help: to override `-D warnings` add `#[allow(clippy::unused_peekable)]` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:18:9 + --> tests/ui/unused_peekable.rs:18:9 | LL | let new_local = old_local; | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let new_local = old_local; = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:23:9 + --> tests/ui/unused_peekable.rs:23:9 | LL | let by_mut_ref = &mut by_mut_ref_test; | ^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let by_mut_ref = &mut by_mut_ref_test; = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:31:9 + --> tests/ui/unused_peekable.rs:31:9 | LL | let peekable_from_fn = returns_peekable(); | ^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let peekable_from_fn = returns_peekable(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:35:13 + --> tests/ui/unused_peekable.rs:35:13 | LL | let mut peekable_using_iterator_method = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let mut peekable_using_iterator_method = std::iter::empty::().peek = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:41:9 + --> tests/ui/unused_peekable.rs:41:9 | LL | let passed_along_ref = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let passed_along_ref = std::iter::empty::().peekable(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:47:9 + --> tests/ui/unused_peekable.rs:47:9 | LL | let _by_ref = by_ref_test.by_ref(); | ^^^^^^^ @@ -57,7 +57,7 @@ LL | let _by_ref = by_ref_test.by_ref(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> $DIR/unused_peekable.rs:50:13 + --> tests/ui/unused_peekable.rs:50:13 | LL | let mut peekable_in_for_loop = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unused_rounding.stderr b/src/tools/clippy/tests/ui/unused_rounding.stderr index d6ce27351353c..75ad895012b37 100644 --- a/src/tools/clippy/tests/ui/unused_rounding.stderr +++ b/src/tools/clippy/tests/ui/unused_rounding.stderr @@ -1,5 +1,5 @@ error: used the `ceil` method with a whole number float - --> $DIR/unused_rounding.rs:4:13 + --> tests/ui/unused_rounding.rs:4:13 | LL | let _ = 1f32.ceil(); | ^^^^^^^^^^^ help: remove the `ceil` method call: `1f32` @@ -8,25 +8,25 @@ LL | let _ = 1f32.ceil(); = 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 + --> tests/ui/unused_rounding.rs:5:13 | LL | let _ = 1.0f64.floor(); | ^^^^^^^^^^^^^^ help: remove the `floor` method call: `1.0f64` error: used the `round` method with a whole number float - --> $DIR/unused_rounding.rs:6:13 + --> tests/ui/unused_rounding.rs:6:13 | LL | let _ = 1.00f32.round(); | ^^^^^^^^^^^^^^^ help: remove the `round` method call: `1.00f32` error: used the `round` method with a whole number float - --> $DIR/unused_rounding.rs:12:13 + --> tests/ui/unused_rounding.rs:12:13 | LL | let _ = 3.0_f32.round(); | ^^^^^^^^^^^^^^^ help: remove the `round` method call: `3.0_f32` error: used the `round` method with a whole number float - --> $DIR/unused_rounding.rs:14:13 + --> tests/ui/unused_rounding.rs:14:13 | LL | let _ = 3_3.0_0_f32.round(); | ^^^^^^^^^^^^^^^^^^^ help: remove the `round` method call: `3_3.0_0_f32` diff --git a/src/tools/clippy/tests/ui/unused_self.stderr b/src/tools/clippy/tests/ui/unused_self.stderr index 3865095bbfeb6..5d5f1b643a4a1 100644 --- a/src/tools/clippy/tests/ui/unused_self.stderr +++ b/src/tools/clippy/tests/ui/unused_self.stderr @@ -1,5 +1,5 @@ error: unused `self` argument - --> $DIR/unused_self.rs:11:29 + --> tests/ui/unused_self.rs:11:29 | LL | fn unused_self_move(self) {} | ^^^^ @@ -9,7 +9,7 @@ LL | fn unused_self_move(self) {} = help: to override `-D warnings` add `#[allow(clippy::unused_self)]` error: unused `self` argument - --> $DIR/unused_self.rs:13:28 + --> tests/ui/unused_self.rs:13:28 | LL | fn unused_self_ref(&self) {} | ^^^^^ @@ -17,7 +17,7 @@ LL | fn unused_self_ref(&self) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:15:32 + --> tests/ui/unused_self.rs:15:32 | LL | fn unused_self_mut_ref(&mut self) {} | ^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn unused_self_mut_ref(&mut self) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:17:32 + --> tests/ui/unused_self.rs:17:32 | LL | fn unused_self_pin_ref(self: Pin<&Self>) {} | ^^^^ @@ -33,7 +33,7 @@ LL | fn unused_self_pin_ref(self: Pin<&Self>) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:19:36 + --> tests/ui/unused_self.rs:19:36 | LL | fn unused_self_pin_mut_ref(self: Pin<&mut Self>) {} | ^^^^ @@ -41,7 +41,7 @@ LL | fn unused_self_pin_mut_ref(self: Pin<&mut Self>) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:21:35 + --> tests/ui/unused_self.rs:21:35 | LL | fn unused_self_pin_nested(self: Pin>) {} | ^^^^ @@ -49,7 +49,7 @@ LL | fn unused_self_pin_nested(self: Pin>) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:23:28 + --> tests/ui/unused_self.rs:23:28 | LL | fn unused_self_box(self: Box) {} | ^^^^ @@ -57,7 +57,7 @@ LL | fn unused_self_box(self: Box) {} = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:25:40 + --> tests/ui/unused_self.rs:25:40 | LL | fn unused_with_other_used_args(&self, x: u8, y: u8) -> u8 { | ^^^^^ @@ -65,7 +65,7 @@ LL | fn unused_with_other_used_args(&self, x: u8, y: u8) -> u8 { = help: consider refactoring to an associated function error: unused `self` argument - --> $DIR/unused_self.rs:29:37 + --> tests/ui/unused_self.rs:29:37 | LL | fn unused_self_class_method(&self) { | ^^^^^ diff --git a/src/tools/clippy/tests/ui/unused_unit.fixed b/src/tools/clippy/tests/ui/unused_unit.fixed index 16da9a25b2aa8..04fe2d3b7af18 100644 --- a/src/tools/clippy/tests/ui/unused_unit.fixed +++ b/src/tools/clippy/tests/ui/unused_unit.fixed @@ -94,3 +94,10 @@ mod issue9748 { let _ = for<'a> |_: &'a u32| -> () {}; } } + +mod issue9949 { + fn main() { + #[doc = "documentation"] + () + } +} diff --git a/src/tools/clippy/tests/ui/unused_unit.rs b/src/tools/clippy/tests/ui/unused_unit.rs index e374031436d5f..25c2ed59873ac 100644 --- a/src/tools/clippy/tests/ui/unused_unit.rs +++ b/src/tools/clippy/tests/ui/unused_unit.rs @@ -94,3 +94,10 @@ mod issue9748 { let _ = for<'a> |_: &'a u32| -> () {}; } } + +mod issue9949 { + fn main() { + #[doc = "documentation"] + () + } +} diff --git a/src/tools/clippy/tests/ui/unused_unit.stderr b/src/tools/clippy/tests/ui/unused_unit.stderr index ce06738cfe473..104159ad5fc63 100644 --- a/src/tools/clippy/tests/ui/unused_unit.stderr +++ b/src/tools/clippy/tests/ui/unused_unit.stderr @@ -1,119 +1,119 @@ error: unneeded unit return type - --> $DIR/unused_unit.rs:20:58 + --> tests/ui/unused_unit.rs:20:58 | LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> () | ^^^^^^ help: remove the `-> ()` | note: the lint level is defined here - --> $DIR/unused_unit.rs:13:9 + --> tests/ui/unused_unit.rs:13:9 | LL | #![deny(clippy::unused_unit)] | ^^^^^^^^^^^^^^^^^^^ error: unneeded unit return type - --> $DIR/unused_unit.rs:20:28 + --> tests/ui/unused_unit.rs:20:28 | LL | pub fn get_unit (), G>(&self, f: F, _g: G) -> () | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:21:18 + --> tests/ui/unused_unit.rs:21:18 | LL | where G: Fn() -> () { | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:22:26 + --> tests/ui/unused_unit.rs:22:26 | LL | let _y: &dyn Fn() -> () = &f; | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:29:18 + --> tests/ui/unused_unit.rs:29:18 | LL | fn into(self) -> () { | ^^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:30:9 + --> tests/ui/unused_unit.rs:30:9 | LL | () | ^^ help: remove the final `()` error: unneeded unit return type - --> $DIR/unused_unit.rs:35:29 + --> tests/ui/unused_unit.rs:35:29 | LL | fn redundant (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:37:19 + --> tests/ui/unused_unit.rs:37:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:38:16 + --> tests/ui/unused_unit.rs:38:16 | LL | H: Fn() -> (); | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:42:29 + --> tests/ui/unused_unit.rs:42:29 | LL | fn redundant (), G, H>(&self, _f: F, _g: G, _h: H) | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:44:19 + --> tests/ui/unused_unit.rs:44:19 | LL | G: FnMut() -> (), | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:45:16 + --> tests/ui/unused_unit.rs:45:16 | LL | H: Fn() -> () {} | ^^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:48:17 + --> tests/ui/unused_unit.rs:48:17 | LL | fn return_unit() -> () { () } | ^^^^^^ help: remove the `-> ()` error: unneeded unit expression - --> $DIR/unused_unit.rs:48:26 + --> tests/ui/unused_unit.rs:48:26 | LL | fn return_unit() -> () { () } | ^^ help: remove the final `()` error: unneeded `()` - --> $DIR/unused_unit.rs:58:14 + --> tests/ui/unused_unit.rs:58:14 | LL | break(); | ^^ help: remove the `()` error: unneeded `()` - --> $DIR/unused_unit.rs:60:11 + --> tests/ui/unused_unit.rs:60:11 | LL | return(); | ^^ help: remove the `()` error: unneeded unit return type - --> $DIR/unused_unit.rs:77:10 + --> tests/ui/unused_unit.rs:77:10 | LL | fn test()->(){} | ^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:80:11 + --> tests/ui/unused_unit.rs:80:11 | LL | fn test2() ->(){} | ^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> $DIR/unused_unit.rs:83:11 + --> tests/ui/unused_unit.rs:83:11 | LL | fn test3()-> (){} | ^^^^^ help: remove the `-> ()` diff --git a/src/tools/clippy/tests/ui/unwrap.stderr b/src/tools/clippy/tests/ui/unwrap.stderr index 25911ded2fb3c..3c1b37bc3d9bf 100644 --- a/src/tools/clippy/tests/ui/unwrap.stderr +++ b/src/tools/clippy/tests/ui/unwrap.stderr @@ -1,5 +1,5 @@ error: used `unwrap()` on an `Option` value - --> $DIR/unwrap.rs:6:13 + --> tests/ui/unwrap.rs:6:13 | LL | let _ = opt.unwrap(); | ^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | let _ = opt.unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `unwrap()` on a `Result` value - --> $DIR/unwrap.rs:12:13 + --> tests/ui/unwrap.rs:12:13 | LL | let _ = res.unwrap(); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | let _ = res.unwrap(); = help: consider using `expect()` to provide a better panic message error: used `unwrap_err()` on a `Result` value - --> $DIR/unwrap.rs:14:13 + --> tests/ui/unwrap.rs:14:13 | LL | let _ = res.unwrap_err(); | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unwrap_expect_used.stderr b/src/tools/clippy/tests/ui/unwrap_expect_used.stderr index cbe6ea22e8997..9069522a4df1a 100644 --- a/src/tools/clippy/tests/ui/unwrap_expect_used.stderr +++ b/src/tools/clippy/tests/ui/unwrap_expect_used.stderr @@ -1,5 +1,5 @@ error: used `unwrap()` on an `Option` value - --> $DIR/unwrap_expect_used.rs:27:5 + --> tests/ui/unwrap_expect_used.rs:27:5 | LL | Some(3).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(3).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `expect()` on an `Option` value - --> $DIR/unwrap_expect_used.rs:29:5 + --> tests/ui/unwrap_expect_used.rs:29:5 | LL | Some(3).expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | Some(3).expect("Hello world!"); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `unwrap()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:45:5 + --> tests/ui/unwrap_expect_used.rs:45:5 | LL | a.unwrap(); | ^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | a.unwrap(); = note: if this value is an `Err`, it will panic error: used `expect()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:47:5 + --> tests/ui/unwrap_expect_used.rs:47:5 | LL | a.expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | a.expect("Hello world!"); = note: if this value is an `Err`, it will panic error: used `unwrap_err()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:49:5 + --> tests/ui/unwrap_expect_used.rs:49:5 | LL | a.unwrap_err(); | ^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | a.unwrap_err(); = note: if this value is an `Ok`, it will panic error: used `expect_err()` on a `Result` value - --> $DIR/unwrap_expect_used.rs:51:5 + --> tests/ui/unwrap_expect_used.rs:51:5 | LL | a.expect_err("Hello error!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unwrap_in_result.stderr b/src/tools/clippy/tests/ui/unwrap_in_result.stderr index 9a0a32d471e33..29c7a9373aa7b 100644 --- a/src/tools/clippy/tests/ui/unwrap_in_result.stderr +++ b/src/tools/clippy/tests/ui/unwrap_in_result.stderr @@ -1,5 +1,5 @@ error: used unwrap or expect in a function that returns result or option - --> $DIR/unwrap_in_result.rs:22:5 + --> tests/ui/unwrap_in_result.rs:22:5 | LL | / fn bad_divisible_by_3(i_str: String) -> Result { LL | | @@ -12,7 +12,7 @@ LL | | } | = help: unwrap and expect should not be used in a function that returns result or option note: potential non-recoverable error(s) - --> $DIR/unwrap_in_result.rs:25:17 + --> tests/ui/unwrap_in_result.rs:25:17 | LL | let i = i_str.parse::().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | let i = i_str.parse::().unwrap(); = 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 + --> tests/ui/unwrap_in_result.rs:33:5 | LL | / fn example_option_expect(i_str: String) -> Option { LL | | @@ -33,7 +33,7 @@ LL | | } | = help: unwrap and expect should not be used in a function that returns result or option note: potential non-recoverable error(s) - --> $DIR/unwrap_in_result.rs:35:17 + --> tests/ui/unwrap_in_result.rs:35:17 | LL | let i = i_str.parse::().expect("not a number"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/unwrap_or.stderr b/src/tools/clippy/tests/ui/unwrap_or.stderr index 3a32092f7be17..6aa0b9df29b94 100644 --- a/src/tools/clippy/tests/ui/unwrap_or.stderr +++ b/src/tools/clippy/tests/ui/unwrap_or.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:5:47 + --> tests/ui/unwrap_or.rs:5:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| "Fail".to_string())` @@ -8,7 +8,7 @@ LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()) = 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 + --> tests/ui/unwrap_or.rs:11:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| "Fail".to_string())` 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 3119aba19e8fd..e4b4a0a1f6aa7 100644 --- a/src/tools/clippy/tests/ui/unwrap_or_else_default.stderr +++ b/src/tools/clippy/tests/ui/unwrap_or_else_default.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:46:14 + --> tests/ui/unwrap_or_else_default.rs:46:14 | LL | with_new.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` @@ -8,91 +8,91 @@ LL | with_new.unwrap_or_else(Vec::new); = 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 + --> tests/ui/unwrap_or_else_default.rs:60:23 | LL | with_real_default.unwrap_or_else(::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:63:24 + --> tests/ui/unwrap_or_else_default.rs:63:24 | LL | with_default_trait.unwrap_or_else(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:66:23 + --> tests/ui/unwrap_or_else_default.rs:66:23 | LL | with_default_type.unwrap_or_else(u64::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:69:23 + --> tests/ui/unwrap_or_else_default.rs:69:23 | LL | with_default_type.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:72:18 + --> tests/ui/unwrap_or_else_default.rs:72:18 | LL | empty_string.unwrap_or_else(|| "".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:76:12 + --> tests/ui/unwrap_or_else_default.rs:76:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:79:12 + --> tests/ui/unwrap_or_else_default.rs:79:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:82:12 + --> tests/ui/unwrap_or_else_default.rs:82:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:85:12 + --> tests/ui/unwrap_or_else_default.rs:85:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:88:12 + --> tests/ui/unwrap_or_else_default.rs:88:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:91:12 + --> tests/ui/unwrap_or_else_default.rs:91:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:94:12 + --> tests/ui/unwrap_or_else_default.rs:94:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:97:12 + --> tests/ui/unwrap_or_else_default.rs:97:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:113:12 + --> tests/ui/unwrap_or_else_default.rs:113:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `or_insert_with` to construct default value - --> $DIR/unwrap_or_else_default.rs:130:32 + --> tests/ui/unwrap_or_else_default.rs:130:32 | LL | let _ = inner_map.entry(0).or_insert_with(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` diff --git a/src/tools/clippy/tests/ui/upper_case_acronyms.stderr b/src/tools/clippy/tests/ui/upper_case_acronyms.stderr index 009c53c725b6f..1f8046c8e841f 100644 --- a/src/tools/clippy/tests/ui/upper_case_acronyms.stderr +++ b/src/tools/clippy/tests/ui/upper_case_acronyms.stderr @@ -1,5 +1,5 @@ error: name `CWR` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:9:5 + --> tests/ui/upper_case_acronyms.rs:9:5 | LL | CWR, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` @@ -8,67 +8,67 @@ LL | CWR, = 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 + --> tests/ui/upper_case_acronyms.rs:12:5 | LL | ECE, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` error: name `URG` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:14:5 + --> tests/ui/upper_case_acronyms.rs:14:5 | LL | URG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` error: name `ACK` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:16:5 + --> tests/ui/upper_case_acronyms.rs:16:5 | LL | ACK, | ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` error: name `PSH` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:18:5 + --> tests/ui/upper_case_acronyms.rs:18:5 | LL | PSH, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` error: name `RST` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:20:5 + --> tests/ui/upper_case_acronyms.rs:20:5 | LL | RST, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` error: name `SYN` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:22:5 + --> tests/ui/upper_case_acronyms.rs:22:5 | LL | SYN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` error: name `FIN` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:24:5 + --> tests/ui/upper_case_acronyms.rs:24:5 | LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` error: name `WASD` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:45:5 + --> tests/ui/upper_case_acronyms.rs:45:5 | LL | WASD(u8), | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd` error: name `JSON` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:52:8 + --> tests/ui/upper_case_acronyms.rs:52:8 | LL | struct JSON; | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Json` error: name `YAML` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:56:6 + --> tests/ui/upper_case_acronyms.rs:56:6 | LL | enum YAML { | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Yaml` error: name `DISALLOW` contains a capitalized acronym - --> $DIR/upper_case_acronyms.rs:64:5 + --> tests/ui/upper_case_acronyms.rs:64:5 | LL | DISALLOW, | ^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `Disallow` diff --git a/src/tools/clippy/tests/ui/use_self.stderr b/src/tools/clippy/tests/ui/use_self.stderr index a1d4eac5dc09a..8d045f05ed286 100644 --- a/src/tools/clippy/tests/ui/use_self.stderr +++ b/src/tools/clippy/tests/ui/use_self.stderr @@ -1,5 +1,5 @@ error: unnecessary structure name repetition - --> $DIR/use_self.rs:21:21 + --> tests/ui/use_self.rs:21:21 | LL | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` @@ -8,247 +8,247 @@ LL | fn new() -> Foo { = help: to override `-D warnings` add `#[allow(clippy::use_self)]` error: unnecessary structure name repetition - --> $DIR/use_self.rs:22:13 + --> tests/ui/use_self.rs:22:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:24:22 + --> tests/ui/use_self.rs:24:22 | LL | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:25:13 + --> tests/ui/use_self.rs:25:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:30:25 + --> tests/ui/use_self.rs:30:25 | LL | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:31:13 + --> tests/ui/use_self.rs:31:13 | LL | Foo::new() | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:96:24 + --> tests/ui/use_self.rs:96:24 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:96:55 + --> tests/ui/use_self.rs:96:55 | LL | fn bad(foos: &[Foo]) -> impl Iterator { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:111:13 + --> tests/ui/use_self.rs:111:13 | LL | TS(0) | ^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:146:29 + --> tests/ui/use_self.rs:146:29 | LL | fn bar() -> Bar { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:147:21 + --> tests/ui/use_self.rs:147:21 | LL | Bar { foo: Foo {} } | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:158:21 + --> tests/ui/use_self.rs:158:21 | LL | fn baz() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:159:13 + --> tests/ui/use_self.rs:159:13 | LL | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:176:21 + --> tests/ui/use_self.rs:176:21 | LL | let _ = Enum::B(42); | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:177:21 + --> tests/ui/use_self.rs:177:21 | LL | let _ = Enum::C { field: true }; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:178:21 + --> tests/ui/use_self.rs:178:21 | LL | let _ = Enum::A; | ^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:220:13 + --> tests/ui/use_self.rs:220:13 | LL | nested::A::fun_1(); | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:221:13 + --> tests/ui/use_self.rs:221:13 | LL | nested::A::A; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:223:13 + --> tests/ui/use_self.rs:223:13 | LL | nested::A {}; | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:242:13 + --> tests/ui/use_self.rs:242:13 | LL | TestStruct::from_something() | ^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:256:25 + --> tests/ui/use_self.rs:256:25 | LL | async fn g() -> S { | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:257:13 + --> tests/ui/use_self.rs:257:13 | LL | S {} | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:261:16 + --> tests/ui/use_self.rs:261:16 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:261:22 + --> tests/ui/use_self.rs:261:22 | LL | &p[S::A..S::B] | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:284:29 + --> tests/ui/use_self.rs:284:29 | LL | fn foo(value: T) -> Foo { | ^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:285:13 + --> tests/ui/use_self.rs:285:13 | LL | Foo:: { value } | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:457:13 + --> tests/ui/use_self.rs:457:13 | LL | A::new::(submod::B {}) | ^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:494:13 + --> tests/ui/use_self.rs:494:13 | LL | S2::new() | ^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:531:17 + --> tests/ui/use_self.rs:531:17 | LL | Foo::Bar => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:532:17 + --> tests/ui/use_self.rs:532:17 | LL | Foo::Baz => unimplemented!(), | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:538:20 + --> tests/ui/use_self.rs:538:20 | LL | if let Foo::Bar = self { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:562:17 + --> tests/ui/use_self.rs:562:17 | LL | Something::Num(n) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:563:17 + --> tests/ui/use_self.rs:563:17 | LL | Something::TupleNums(n, _m) => *n, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:564:17 + --> tests/ui/use_self.rs:564:17 | LL | Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:570:17 + --> tests/ui/use_self.rs:570:17 | LL | crate::issue8845::Something::Num(n) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:571:17 + --> tests/ui/use_self.rs:571:17 | LL | crate::issue8845::Something::TupleNums(n, _m) => *n, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:572:17 + --> tests/ui/use_self.rs:572:17 | LL | crate::issue8845::Something::StructNums { one, two: _ } => *one, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:588:17 + --> tests/ui/use_self.rs:588:17 | LL | let Foo(x) = self; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:593:17 + --> tests/ui/use_self.rs:593:17 | LL | let crate::issue8845::Foo(x) = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:600:17 + --> tests/ui/use_self.rs:600:17 | LL | let Bar { x, .. } = self; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:605:17 + --> tests/ui/use_self.rs:605:17 | LL | let crate::issue8845::Bar { x, .. } = self; | ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:644:17 + --> tests/ui/use_self.rs:644:17 | LL | E::A => {}, | ^ help: use the applicable keyword: `Self` diff --git a/src/tools/clippy/tests/ui/use_self_trait.stderr b/src/tools/clippy/tests/ui/use_self_trait.stderr index 71a227174eafc..9cbb728ebe667 100644 --- a/src/tools/clippy/tests/ui/use_self_trait.stderr +++ b/src/tools/clippy/tests/ui/use_self_trait.stderr @@ -1,5 +1,5 @@ error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:19:18 + --> tests/ui/use_self_trait.rs:19:18 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` @@ -8,91 +8,91 @@ LL | fn refs(p1: &Bad) -> &Bad { = help: to override `-D warnings` add `#[allow(clippy::use_self)]` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:19:27 + --> tests/ui/use_self_trait.rs:19:27 | LL | fn refs(p1: &Bad) -> &Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:23:33 + --> tests/ui/use_self_trait.rs:23:33 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:23:49 + --> tests/ui/use_self_trait.rs:23:49 | LL | fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:27:26 + --> tests/ui/use_self_trait.rs:27:26 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:27:39 + --> tests/ui/use_self_trait.rs:27:39 | LL | fn mut_refs(p1: &mut Bad) -> &mut Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:31:24 + --> tests/ui/use_self_trait.rs:31:24 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:31:42 + --> tests/ui/use_self_trait.rs:31:42 | LL | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:33:16 + --> tests/ui/use_self_trait.rs:33:16 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:33:24 + --> tests/ui/use_self_trait.rs:33:24 | LL | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:34:9 + --> tests/ui/use_self_trait.rs:34:9 | LL | Bad | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:39:19 + --> tests/ui/use_self_trait.rs:39:19 | LL | type Output = Bad; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:41:23 + --> tests/ui/use_self_trait.rs:41:23 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:41:31 + --> tests/ui/use_self_trait.rs:41:31 | LL | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:48:9 + --> tests/ui/use_self_trait.rs:48:9 | LL | Bad | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self_trait.rs:145:13 + --> tests/ui/use_self_trait.rs:145:13 | LL | std::fmt::Error // Should lint | ^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self` diff --git a/src/tools/clippy/tests/ui/used_underscore_binding.stderr b/src/tools/clippy/tests/ui/used_underscore_binding.stderr index 78d8279810c1f..556e1792b3e68 100644 --- a/src/tools/clippy/tests/ui/used_underscore_binding.stderr +++ b/src/tools/clippy/tests/ui/used_underscore_binding.stderr @@ -1,11 +1,11 @@ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:23:5 + --> tests/ui/used_underscore_binding.rs:23:5 | LL | _foo + 1 | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:22:22 + --> tests/ui/used_underscore_binding.rs:22:22 | LL | fn prefix_underscore(_foo: u32) -> u32 { | ^^^^ @@ -13,61 +13,61 @@ LL | fn prefix_underscore(_foo: u32) -> u32 { = 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:28:20 + --> tests/ui/used_underscore_binding.rs:28:20 | LL | println!("{}", _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> tests/ui/used_underscore_binding.rs:27:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:29:16 + --> tests/ui/used_underscore_binding.rs:29:16 | LL | assert_eq!(_foo, _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> tests/ui/used_underscore_binding.rs:27:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:29:22 + --> tests/ui/used_underscore_binding.rs:29:22 | LL | assert_eq!(_foo, _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> tests/ui/used_underscore_binding.rs:27:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:42:5 + --> tests/ui/used_underscore_binding.rs:42:5 | LL | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ | note: `_underscore_field` is defined here - --> $DIR/used_underscore_binding.rs:36:5 + --> tests/ui/used_underscore_binding.rs:36:5 | LL | _underscore_field: u32, | ^^^^^^^^^^^^^^^^^^^^^^ error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:103:16 + --> tests/ui/used_underscore_binding.rs:103:16 | LL | uses_i(_i); | ^^ | note: `_i` is defined here - --> $DIR/used_underscore_binding.rs:102:13 + --> tests/ui/used_underscore_binding.rs:102:13 | LL | let _i = 5; | ^^ diff --git a/src/tools/clippy/tests/ui/useless_asref.stderr b/src/tools/clippy/tests/ui/useless_asref.stderr index e158df2664d77..c7d622ec2dcaf 100644 --- a/src/tools/clippy/tests/ui/useless_asref.stderr +++ b/src/tools/clippy/tests/ui/useless_asref.stderr @@ -1,113 +1,113 @@ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:48:18 + --> tests/ui/useless_asref.rs:48:18 | LL | foo_rstr(rstr.as_ref()); | ^^^^^^^^^^^^^ help: try: `rstr` | note: the lint level is defined here - --> $DIR/useless_asref.rs:1:9 + --> tests/ui/useless_asref.rs:1:9 | LL | #![deny(clippy::useless_asref)] | ^^^^^^^^^^^^^^^^^^^^^ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:50:20 + --> tests/ui/useless_asref.rs:50:20 | LL | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try: `rslice` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:54:21 + --> tests/ui/useless_asref.rs:54:21 | LL | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:56:20 + --> tests/ui/useless_asref.rs:56:20 | LL | foo_rslice(mrslice.as_ref()); | ^^^^^^^^^^^^^^^^ help: try: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:63:20 + --> tests/ui/useless_asref.rs:63:20 | LL | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try: `rrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:65:18 + --> tests/ui/useless_asref.rs:65:18 | LL | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try: `rrrrrstr` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:70:21 + --> tests/ui/useless_asref.rs:70:21 | LL | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:72:20 + --> tests/ui/useless_asref.rs:72:20 | LL | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:76:16 + --> tests/ui/useless_asref.rs:76:16 | LL | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&&&&MoreRef)` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:126:13 + --> tests/ui/useless_asref.rs:126:13 | LL | foo_mrt(mrt.as_mut()); | ^^^^^^^^^^^^ help: try: `mrt` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:128:12 + --> tests/ui/useless_asref.rs:128:12 | LL | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try: `mrt` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:139:13 + --> tests/ui/useless_asref.rs:139:13 | LL | let z = x.as_ref().map(String::clone); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:141:13 + --> tests/ui/useless_asref.rs:141:13 | LL | let z = x.as_ref().map(|z| z.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:143:13 + --> tests/ui/useless_asref.rs:143:13 | LL | let z = x.as_ref().map(|z| String::clone(z)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:167:9 + --> tests/ui/useless_asref.rs:167:9 | LL | x.field.as_ref().map(|v| v.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:169:9 + --> tests/ui/useless_asref.rs:169:9 | LL | x.field.as_ref().map(Clone::clone); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:171:9 + --> tests/ui/useless_asref.rs:171:9 | LL | x.field.as_ref().map(|v| Clone::clone(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> $DIR/useless_asref.rs:176:9 + --> tests/ui/useless_asref.rs:176:9 | LL | Some(1).as_ref().map(|&x| x.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(1).clone()` diff --git a/src/tools/clippy/tests/ui/useless_attribute.fixed b/src/tools/clippy/tests/ui/useless_attribute.fixed index 98a2bed0e81b5..d1cdf73d559fc 100644 --- a/src/tools/clippy/tests/ui/useless_attribute.fixed +++ b/src/tools/clippy/tests/ui/useless_attribute.fixed @@ -6,7 +6,7 @@ #![feature(rustc_private)] #![allow(dead_code)] -#![cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#![cfg_attr(clippy, allow(dead_code))] #[rustfmt::skip] #[allow(unused_imports)] #[allow(unused_extern_crates)] @@ -80,6 +80,14 @@ pub mod split { #[allow(clippy::single_component_path_imports)] use regex; +mod module { + pub(crate) struct Struct; +} + +#[rustfmt::skip] +#[allow(unused_import_braces)] +use module::{Struct}; + fn main() { test_indented_attr(); } diff --git a/src/tools/clippy/tests/ui/useless_attribute.rs b/src/tools/clippy/tests/ui/useless_attribute.rs index c5e324717b112..d6aa7fa242cf0 100644 --- a/src/tools/clippy/tests/ui/useless_attribute.rs +++ b/src/tools/clippy/tests/ui/useless_attribute.rs @@ -6,7 +6,7 @@ #![feature(rustc_private)] #[allow(dead_code)] -#[cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#[cfg_attr(clippy, allow(dead_code))] #[rustfmt::skip] #[allow(unused_imports)] #[allow(unused_extern_crates)] @@ -80,6 +80,14 @@ pub mod split { #[allow(clippy::single_component_path_imports)] use regex; +mod module { + pub(crate) struct Struct; +} + +#[rustfmt::skip] +#[allow(unused_import_braces)] +use module::{Struct}; + fn main() { test_indented_attr(); } diff --git a/src/tools/clippy/tests/ui/useless_attribute.stderr b/src/tools/clippy/tests/ui/useless_attribute.stderr index e65c59abaf88f..19f0e02de6808 100644 --- a/src/tools/clippy/tests/ui/useless_attribute.stderr +++ b/src/tools/clippy/tests/ui/useless_attribute.stderr @@ -1,5 +1,5 @@ error: useless lint attribute - --> $DIR/useless_attribute.rs:8:1 + --> tests/ui/useless_attribute.rs:8:1 | LL | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` @@ -8,13 +8,13 @@ LL | #[allow(dead_code)] = help: to override `-D warnings` add `#[allow(clippy::useless_attribute)]` error: useless lint attribute - --> $DIR/useless_attribute.rs:9:1 + --> tests/ui/useless_attribute.rs:9:1 | -LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` +LL | #[cfg_attr(clippy, allow(dead_code))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(clippy, allow(dead_code)` error: useless lint attribute - --> $DIR/useless_attribute.rs:20:5 + --> tests/ui/useless_attribute.rs:20:5 | LL | #[allow(clippy::almost_swapped)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]` diff --git a/src/tools/clippy/tests/ui/useless_conversion.stderr b/src/tools/clippy/tests/ui/useless_conversion.stderr index c1f8b6b4aa966..82f945c5e89f6 100644 --- a/src/tools/clippy/tests/ui/useless_conversion.stderr +++ b/src/tools/clippy/tests/ui/useless_conversion.stderr @@ -1,227 +1,227 @@ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion.rs:5:13 + --> tests/ui/useless_conversion.rs:5:13 | LL | let _ = T::from(val); | ^^^^^^^^^^^^ help: consider removing `T::from()`: `val` | note: the lint level is defined here - --> $DIR/useless_conversion.rs:1:9 + --> tests/ui/useless_conversion.rs:1:9 | LL | #![deny(clippy::useless_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion.rs:6:5 + --> tests/ui/useless_conversion.rs:6:5 | LL | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` error: useless conversion to the same type: `i32` - --> $DIR/useless_conversion.rs:18:22 + --> tests/ui/useless_conversion.rs:18:22 | LL | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:48:22 + --> tests/ui/useless_conversion.rs:48:22 | LL | if Some("ok") == lines.into_iter().next() {} | ^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `lines` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:53:21 + --> tests/ui/useless_conversion.rs:53:21 | LL | let mut lines = text.lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `text.lines()` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:59:22 + --> tests/ui/useless_conversion.rs:59:22 | LL | if Some("ok") == text.lines().into_iter().next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `text.lines()` error: useless conversion to the same type: `std::ops::Range` - --> $DIR/useless_conversion.rs:65:13 + --> tests/ui/useless_conversion.rs:65:13 | LL | let _ = NUMBERS.into_iter().next(); | ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `NUMBERS` error: useless conversion to the same type: `std::ops::Range` - --> $DIR/useless_conversion.rs:70:17 + --> tests/ui/useless_conversion.rs:70:17 | LL | let mut n = NUMBERS.into_iter(); | ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `NUMBERS` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:132:21 + --> tests/ui/useless_conversion.rs:132:21 | LL | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:133:21 + --> tests/ui/useless_conversion.rs:133:21 | LL | let _: String = From::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:134:13 + --> tests/ui/useless_conversion.rs:134:13 | LL | let _ = String::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:135:13 + --> tests/ui/useless_conversion.rs:135:13 | LL | let _ = String::from(format!("A: {:04}", 123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` error: useless conversion to the same type: `std::str::Lines<'_>` - --> $DIR/useless_conversion.rs:136:13 + --> tests/ui/useless_conversion.rs:136:13 | LL | let _ = "".lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` error: useless conversion to the same type: `std::vec::IntoIter` - --> $DIR/useless_conversion.rs:137:13 + --> tests/ui/useless_conversion.rs:137:13 | LL | let _ = vec![1, 2, 3].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion.rs:138:21 + --> tests/ui/useless_conversion.rs:138:21 | LL | let _: String = format!("Hello {}", "world").into(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")` error: useless conversion to the same type: `i32` - --> $DIR/useless_conversion.rs:143:13 + --> tests/ui/useless_conversion.rs:143:13 | LL | let _ = i32::from(a + b) * 3; | ^^^^^^^^^^^^^^^^ help: consider removing `i32::from()`: `(a + b)` error: useless conversion to the same type: `Foo<'a'>` - --> $DIR/useless_conversion.rs:149:23 + --> tests/ui/useless_conversion.rs:149:23 | LL | let _: Foo<'a'> = s2.into(); | ^^^^^^^^^ help: consider removing `.into()`: `s2` error: useless conversion to the same type: `Foo<'a'>` - --> $DIR/useless_conversion.rs:151:13 + --> tests/ui/useless_conversion.rs:151:13 | LL | let _ = Foo::<'a'>::from(s3); | ^^^^^^^^^^^^^^^^^^^^ help: consider removing `Foo::<'a'>::from()`: `s3` error: useless conversion to the same type: `std::vec::IntoIter>` - --> $DIR/useless_conversion.rs:153:13 + --> tests/ui/useless_conversion.rs:153:13 | LL | let _ = vec![s4, s4, s4].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![s4, s4, s4].into_iter()` error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:185:7 + --> tests/ui/useless_conversion.rs:185:7 | LL | b(vec![1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:175:13 + --> tests/ui/useless_conversion.rs:175:13 | LL | fn b>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:186:7 + --> tests/ui/useless_conversion.rs:186:7 | LL | c(vec![1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:176:18 + --> tests/ui/useless_conversion.rs:176:18 | LL | fn c(_: impl IntoIterator) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:187:7 + --> tests/ui/useless_conversion.rs:187:7 | LL | d(vec![1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:179:12 + --> tests/ui/useless_conversion.rs:179:12 | LL | T: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:190:7 + --> tests/ui/useless_conversion.rs:190:7 | LL | b(vec![1, 2].into_iter().into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:175:13 + --> tests/ui/useless_conversion.rs:175:13 | LL | fn b>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:191:7 + --> tests/ui/useless_conversion.rs:191:7 | LL | b(vec![1, 2].into_iter().into_iter().into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:175:13 + --> tests/ui/useless_conversion.rs:175:13 | LL | fn b>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:237:24 + --> tests/ui/useless_conversion.rs:237:24 | LL | foo2::([1, 2, 3].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2, 3]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:216:12 + --> tests/ui/useless_conversion.rs:216:12 | LL | I: IntoIterator + Helper, | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:245:14 + --> tests/ui/useless_conversion.rs:245:14 | LL | foo3([1, 2, 3].into_iter()); | ^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2, 3]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:225:12 + --> tests/ui/useless_conversion.rs:225:12 | LL | I: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:254:16 + --> tests/ui/useless_conversion.rs:254:16 | LL | S1.foo([1, 2].into_iter()); | ^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `[1, 2]` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:251:27 + --> tests/ui/useless_conversion.rs:251:27 | LL | pub fn foo(&self, _: I) {} | ^^^^^^^^^^^^ error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> $DIR/useless_conversion.rs:273:44 + --> tests/ui/useless_conversion.rs:273:44 | LL | v0.into_iter().interleave_shortest(v1.into_iter()); | ^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `v1` | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> $DIR/useless_conversion.rs:260:20 + --> tests/ui/useless_conversion.rs:260:20 | LL | J: IntoIterator, | ^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/useless_conversion_try.stderr b/src/tools/clippy/tests/ui/useless_conversion_try.stderr index 938bfb5237bba..11fb8f38ea5c2 100644 --- a/src/tools/clippy/tests/ui/useless_conversion_try.stderr +++ b/src/tools/clippy/tests/ui/useless_conversion_try.stderr @@ -1,18 +1,18 @@ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion_try.rs:5:13 + --> tests/ui/useless_conversion_try.rs:5:13 | LL | let _ = T::try_from(val).unwrap(); | ^^^^^^^^^^^^^^^^ | = help: consider removing `T::try_from()` note: the lint level is defined here - --> $DIR/useless_conversion_try.rs:1:9 + --> tests/ui/useless_conversion_try.rs:1:9 | LL | #![deny(clippy::useless_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: useless conversion to the same type: `T` - --> $DIR/useless_conversion_try.rs:7:5 + --> tests/ui/useless_conversion_try.rs:7:5 | LL | val.try_into().unwrap() | ^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | val.try_into().unwrap() = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:30:21 + --> tests/ui/useless_conversion_try.rs:30:21 | LL | let _: String = "foo".to_string().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _: String = "foo".to_string().try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:32:21 + --> tests/ui/useless_conversion_try.rs:32:21 | LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); = help: consider removing `TryFrom::try_from()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:34:13 + --> tests/ui/useless_conversion_try.rs:34:13 | LL | let _ = String::try_from("foo".to_string()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _ = String::try_from("foo".to_string()).unwrap(); = help: consider removing `String::try_from()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:36:13 + --> tests/ui/useless_conversion_try.rs:36:13 | LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); = help: consider removing `String::try_from()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:38:21 + --> tests/ui/useless_conversion_try.rs:38:21 | LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:40:21 + --> tests/ui/useless_conversion_try.rs:40:21 | LL | let _: String = String::new().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _: String = String::new().try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> $DIR/useless_conversion_try.rs:42:27 + --> tests/ui/useless_conversion_try.rs:42:27 | LL | let _: String = match String::from("_").try_into() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/vec.fixed b/src/tools/clippy/tests/ui/vec.fixed index b318fd42f7ca2..9e755a82af45f 100644 --- a/src/tools/clippy/tests/ui/vec.fixed +++ b/src/tools/clippy/tests/ui/vec.fixed @@ -217,3 +217,7 @@ fn issue_11958() { // should not lint, `String` is not `Copy` f(&vec!["test".to_owned(); 2]); } + +fn issue_12101() { + for a in &[1, 2] {} +} diff --git a/src/tools/clippy/tests/ui/vec.rs b/src/tools/clippy/tests/ui/vec.rs index 08ad6efa37f2d..c483271438b1f 100644 --- a/src/tools/clippy/tests/ui/vec.rs +++ b/src/tools/clippy/tests/ui/vec.rs @@ -217,3 +217,7 @@ fn issue_11958() { // should not lint, `String` is not `Copy` f(&vec!["test".to_owned(); 2]); } + +fn issue_12101() { + for a in &(vec![1, 2]) {} +} diff --git a/src/tools/clippy/tests/ui/vec.stderr b/src/tools/clippy/tests/ui/vec.stderr index c9018f94f9d1f..3faea8033fe2c 100644 --- a/src/tools/clippy/tests/ui/vec.stderr +++ b/src/tools/clippy/tests/ui/vec.stderr @@ -1,5 +1,5 @@ error: useless use of `vec!` - --> $DIR/vec.rs:30:14 + --> tests/ui/vec.rs:30:14 | LL | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` @@ -8,118 +8,124 @@ LL | on_slice(&vec![]); = help: to override `-D warnings` add `#[allow(clippy::useless_vec)]` error: useless use of `vec!` - --> $DIR/vec.rs:32:18 + --> tests/ui/vec.rs:32:18 | LL | on_mut_slice(&mut vec![]); | ^^^^^^^^^^^ help: you can use a slice directly: `&mut []` error: useless use of `vec!` - --> $DIR/vec.rs:34:14 + --> tests/ui/vec.rs:34:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:36:18 + --> tests/ui/vec.rs:36:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:38:14 + --> tests/ui/vec.rs:38:14 | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:40:18 + --> tests/ui/vec.rs:40:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:42:14 + --> tests/ui/vec.rs:42:14 | LL | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:44:18 + --> tests/ui/vec.rs:44:18 | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:46:14 + --> tests/ui/vec.rs:46:14 | LL | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:48:18 + --> tests/ui/vec.rs:48:18 | LL | on_mut_slice(&mut vec![1; 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:74:19 + --> tests/ui/vec.rs:74:19 | LL | let _x: i32 = vec![1, 2, 3].iter().sum(); | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:77:17 + --> tests/ui/vec.rs:77:17 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:83:22 + --> tests/ui/vec.rs:83:22 | LL | let _x: &[i32] = &vec![1, 2, 3]; | ^^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:85:14 + --> tests/ui/vec.rs:85:14 | LL | for _ in vec![1, 2, 3] {} | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:124:20 + --> tests/ui/vec.rs:124:20 | LL | for _string in vec![repro!(true), repro!(null)] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[repro!(true), repro!(null)]` error: useless use of `vec!` - --> $DIR/vec.rs:141:18 + --> tests/ui/vec.rs:141:18 | LL | in_macro!(1, vec![1, 2], vec![1; 2]); | ^^^^^^^^^^ help: you can use an array directly: `[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:141:30 + --> tests/ui/vec.rs:141:30 | LL | in_macro!(1, vec![1, 2], vec![1; 2]); | ^^^^^^^^^^ help: you can use an array directly: `[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:160:14 + --> tests/ui/vec.rs:160:14 | LL | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` - --> $DIR/vec.rs:164:14 + --> tests/ui/vec.rs:164:14 | LL | for a in vec![String::new(), String::new()] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]` error: useless use of `vec!` - --> $DIR/vec.rs:196:33 + --> tests/ui/vec.rs:196:33 | LL | this_macro_doesnt_need_vec!(vec![1]); | ^^^^^^^ help: you can use an array directly: `[1]` -error: aborting due to 20 previous errors +error: useless use of `vec!` + --> tests/ui/vec.rs:222:14 + | +LL | for a in &(vec![1, 2]) {} + | ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` + +error: aborting due to 21 previous errors diff --git a/src/tools/clippy/tests/ui/vec_box_sized.stderr b/src/tools/clippy/tests/ui/vec_box_sized.stderr index d6479271fa632..0ffcc83143402 100644 --- a/src/tools/clippy/tests/ui/vec_box_sized.stderr +++ b/src/tools/clippy/tests/ui/vec_box_sized.stderr @@ -1,5 +1,5 @@ error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:26:14 + --> tests/ui/vec_box_sized.rs:26:14 | LL | const C: Vec> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec` @@ -8,49 +8,49 @@ LL | const C: Vec> = Vec::new(); = 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:27:15 + --> tests/ui/vec_box_sized.rs:27:15 | LL | static S: Vec> = Vec::new(); | ^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:30:21 + --> tests/ui/vec_box_sized.rs:30:21 | LL | sized_type: Vec>, | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:33:14 + --> tests/ui/vec_box_sized.rs:33:14 | LL | struct A(Vec>); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:34:18 + --> tests/ui/vec_box_sized.rs:34:18 | LL | struct B(Vec>>); | ^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:36:42 + --> tests/ui/vec_box_sized.rs:36:42 | LL | fn allocator_global_defined_vec() -> Vec, std::alloc::Global> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:39:42 + --> tests/ui/vec_box_sized.rs:39:42 | LL | fn allocator_global_defined_box() -> Vec> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:42:29 + --> tests/ui/vec_box_sized.rs:42:29 | LL | fn allocator_match() -> Vec, DummyAllocator> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Vec` error: `Vec` is already on the heap, the boxing is unnecessary - --> $DIR/vec_box_sized.rs:79:23 + --> tests/ui/vec_box_sized.rs:79:23 | LL | pub fn f() -> Vec> { | ^^^^^^^^^^^ help: try: `Vec` 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 978201bd17aa2..58720c9a18135 100644 --- a/src/tools/clippy/tests/ui/vec_init_then_push.stderr +++ b/src/tools/clippy/tests/ui/vec_init_then_push.stderr @@ -1,5 +1,5 @@ error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:5:5 + --> tests/ui/vec_init_then_push.rs:5:5 | LL | / let mut def_err: Vec = Default::default(); LL | | @@ -11,7 +11,7 @@ LL | | def_err.push(0); = 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 + --> tests/ui/vec_init_then_push.rs:10:5 | LL | / let mut new_err = Vec::::new(); LL | | @@ -19,7 +19,7 @@ LL | | new_err.push(1); | |____________________^ help: consider using the `vec![]` macro: `let mut new_err = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:14:5 + --> tests/ui/vec_init_then_push.rs:14:5 | LL | / let mut cap_err = Vec::with_capacity(2); LL | | @@ -29,7 +29,7 @@ LL | | cap_err.push(2); | |____________________^ help: consider using the `vec![]` macro: `let mut cap_err = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:27:5 + --> tests/ui/vec_init_then_push.rs:27:5 | LL | / new_err = Vec::new(); LL | | @@ -37,7 +37,7 @@ LL | | new_err.push(0); | |____________________^ help: consider using the `vec![]` macro: `new_err = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:78:5 + --> tests/ui/vec_init_then_push.rs:78:5 | LL | / let mut v = Vec::new(); LL | | @@ -46,7 +46,7 @@ LL | | v.push(1); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:87:5 + --> tests/ui/vec_init_then_push.rs:87:5 | LL | / let mut v = Vec::new(); LL | | @@ -58,7 +58,7 @@ LL | | v.push(0); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:101:5 + --> tests/ui/vec_init_then_push.rs:101:5 | LL | / let mut v2 = Vec::new(); LL | | @@ -70,7 +70,7 @@ LL | | v2.push(0); | |_______________^ help: consider using the `vec![]` macro: `let mut v2 = vec![..];` error: calls to `push` immediately after creation - --> $DIR/vec_init_then_push.rs:117:5 + --> tests/ui/vec_init_then_push.rs:117:5 | LL | / let mut v = Vec::new(); LL | | 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 c16ba4e526278..ee4efeb2009be 100644 --- a/src/tools/clippy/tests/ui/vec_resize_to_zero.stderr +++ b/src/tools/clippy/tests/ui/vec_resize_to_zero.stderr @@ -1,5 +1,5 @@ error: emptying a vector with `resize` - --> $DIR/vec_resize_to_zero.rs:7:5 + --> tests/ui/vec_resize_to_zero.rs:7:5 | LL | v.resize(0, 5); | ^^------------ diff --git a/src/tools/clippy/tests/ui/verbose_file_reads.stderr b/src/tools/clippy/tests/ui/verbose_file_reads.stderr index 04e1aedf7c5a5..e85068fc7a9c7 100644 --- a/src/tools/clippy/tests/ui/verbose_file_reads.stderr +++ b/src/tools/clippy/tests/ui/verbose_file_reads.stderr @@ -1,5 +1,5 @@ error: use of `File::read_to_end` - --> $DIR/verbose_file_reads.rs:23:5 + --> tests/ui/verbose_file_reads.rs:23:5 | LL | f.read_to_end(&mut buffer)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | f.read_to_end(&mut buffer)?; = 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 + --> tests/ui/verbose_file_reads.rs:27:5 | LL | f.read_to_string(&mut string_buffer)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/waker_clone_wake.stderr b/src/tools/clippy/tests/ui/waker_clone_wake.stderr index f1abf4d9cb050..bf2c02a76c9bb 100644 --- a/src/tools/clippy/tests/ui/waker_clone_wake.stderr +++ b/src/tools/clippy/tests/ui/waker_clone_wake.stderr @@ -1,5 +1,5 @@ error: cloning a `Waker` only to wake it - --> $DIR/waker_clone_wake.rs:15:5 + --> tests/ui/waker_clone_wake.rs:15:5 | LL | cx.waker().clone().wake(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `cx.waker().wake_by_ref()` @@ -8,7 +8,7 @@ LL | cx.waker().clone().wake(); = help: to override `-D warnings` add `#[allow(clippy::waker_clone_wake)]` error: cloning a `Waker` only to wake it - --> $DIR/waker_clone_wake.rs:17:5 + --> tests/ui/waker_clone_wake.rs:17:5 | LL | mac!(cx).clone().wake(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `mac!(cx).wake_by_ref()` diff --git a/src/tools/clippy/tests/ui/while_let_loop.stderr b/src/tools/clippy/tests/ui/while_let_loop.stderr index db887dc65c6a2..5212d4fdcc7b8 100644 --- a/src/tools/clippy/tests/ui/while_let_loop.stderr +++ b/src/tools/clippy/tests/ui/while_let_loop.stderr @@ -1,5 +1,5 @@ error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:6:5 + --> tests/ui/while_let_loop.rs:6:5 | LL | / loop { LL | | @@ -14,7 +14,7 @@ LL | | } = 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 + --> tests/ui/while_let_loop.rs:25:5 | LL | / loop { LL | | @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:33:5 + --> tests/ui/while_let_loop.rs:33:5 | LL | / loop { LL | | @@ -38,7 +38,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:43:5 + --> tests/ui/while_let_loop.rs:43:5 | LL | / loop { LL | | @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_let_loop.rs:74:5 + --> tests/ui/while_let_loop.rs:74:5 | LL | / loop { LL | | 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 7b9a9dc049a28..8ff1f23644b16 100644 --- a/src/tools/clippy/tests/ui/while_let_on_iterator.stderr +++ b/src/tools/clippy/tests/ui/while_let_on_iterator.stderr @@ -1,5 +1,5 @@ error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:15:5 + --> tests/ui/while_let_on_iterator.rs:15:5 | LL | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` @@ -8,157 +8,157 @@ LL | while let Option::Some(x) = iter.next() { = 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 + --> tests/ui/while_let_on_iterator.rs:20:5 | LL | while let Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:25:5 + --> tests/ui/while_let_on_iterator.rs:25:5 | LL | while let Some(_) = iter.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in iter` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:101:9 + --> tests/ui/while_let_on_iterator.rs:101:9 | LL | while let Some([..]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [..] in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:108:9 + --> tests/ui/while_let_on_iterator.rs:108:9 | LL | while let Some([_x]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [_x] in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:121:9 + --> tests/ui/while_let_on_iterator.rs:121:9 | LL | while let Some(x @ [_]) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x @ [_] in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:141:9 + --> tests/ui/while_let_on_iterator.rs:141:9 | LL | while let Some(_) = y.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in y` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:198:9 + --> tests/ui/while_let_on_iterator.rs:198:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:209:5 + --> tests/ui/while_let_on_iterator.rs:209:5 | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:211:9 + --> tests/ui/while_let_on_iterator.rs:211:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:220:9 + --> tests/ui/while_let_on_iterator.rs:220:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:229:9 + --> tests/ui/while_let_on_iterator.rs:229:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:246:9 + --> tests/ui/while_let_on_iterator.rs:246:9 | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:261:13 + --> tests/ui/while_let_on_iterator.rs:261:13 | LL | while let Some(i) = self.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:293:13 + --> tests/ui/while_let_on_iterator.rs:293:13 | LL | while let Some(i) = self.0.0.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.0.0.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:322:5 + --> tests/ui/while_let_on_iterator.rs:322:5 | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:334:9 + --> tests/ui/while_let_on_iterator.rs:334:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:348:5 + --> tests/ui/while_let_on_iterator.rs:348:5 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:359:5 + --> tests/ui/while_let_on_iterator.rs:359:5 | LL | while let Some(x) = it.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.0.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:394:5 + --> tests/ui/while_let_on_iterator.rs:394:5 | LL | while let Some(x) = s.x.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in s.x.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:401:5 + --> tests/ui/while_let_on_iterator.rs:401:5 | LL | while let Some(x) = x[0].next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in x[0].by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:409:9 + --> tests/ui/while_let_on_iterator.rs:409:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:419:9 + --> tests/ui/while_let_on_iterator.rs:419:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:429:9 + --> tests/ui/while_let_on_iterator.rs:429:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:439:9 + --> tests/ui/while_let_on_iterator.rs:439:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:451:9 + --> tests/ui/while_let_on_iterator.rs:451:9 | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop - --> $DIR/while_let_on_iterator.rs:461:5 + --> tests/ui/while_let_on_iterator.rs:461:5 | LL | while let Some(..) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in it` 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 4cfa0d99350d0..06b2415d221e9 100644 --- a/src/tools/clippy/tests/ui/wild_in_or_pats.stderr +++ b/src/tools/clippy/tests/ui/wild_in_or_pats.stderr @@ -1,5 +1,5 @@ error: wildcard pattern covers any other pattern as it will match anyway - --> $DIR/wild_in_or_pats.rs:8:9 + --> tests/ui/wild_in_or_pats.rs:8:9 | LL | "bar" | _ => { | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | "bar" | _ => { = 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 + --> tests/ui/wild_in_or_pats.rs:17:9 | LL | "bar" | "bar2" | _ => { | ^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | "bar" | "bar2" | _ => { = help: consider handling `_` separately error: wildcard pattern covers any other pattern as it will match anyway - --> $DIR/wild_in_or_pats.rs:26:9 + --> tests/ui/wild_in_or_pats.rs:26:9 | LL | _ | "bar" | _ => { | ^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | _ | "bar" | _ => { = help: consider handling `_` separately error: wildcard pattern covers any other pattern as it will match anyway - --> $DIR/wild_in_or_pats.rs:35:9 + --> tests/ui/wild_in_or_pats.rs:35:9 | LL | _ | "bar" => { | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/wildcard_enum_match_arm.stderr b/src/tools/clippy/tests/ui/wildcard_enum_match_arm.stderr index 7fbb16e69e4c5..70ac768aaacdc 100644 --- a/src/tools/clippy/tests/ui/wildcard_enum_match_arm.stderr +++ b/src/tools/clippy/tests/ui/wildcard_enum_match_arm.stderr @@ -1,41 +1,41 @@ error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:39:9 + --> tests/ui/wildcard_enum_match_arm.rs:39:9 | LL | _ => eprintln!("Not red"), | ^ help: try: `Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan` | note: the lint level is defined here - --> $DIR/wildcard_enum_match_arm.rs:2:9 + --> tests/ui/wildcard_enum_match_arm.rs:2:9 | LL | #![deny(clippy::wildcard_enum_match_arm)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:43:9 + --> tests/ui/wildcard_enum_match_arm.rs:43:9 | LL | _not_red => eprintln!("Not red"), | ^^^^^^^^ help: try: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan` error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:47:9 + --> tests/ui/wildcard_enum_match_arm.rs:47:9 | LL | not_red => format!("{:?}", not_red), | ^^^^^^^ help: try: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan` error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:63:9 + --> tests/ui/wildcard_enum_match_arm.rs:63:9 | LL | _ => "No red", | ^ help: try: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan` error: wildcard matches known variants and will also match future added variants - --> $DIR/wildcard_enum_match_arm.rs:80:9 + --> tests/ui/wildcard_enum_match_arm.rs:80:9 | LL | _ => {}, | ^ help: try: `ErrorKind::PermissionDenied | _` error: wildcard match will also match any future added variants - --> $DIR/wildcard_enum_match_arm.rs:98:13 + --> tests/ui/wildcard_enum_match_arm.rs:98:13 | LL | _ => (), | ^ help: try: `Enum::B | Enum::__Private` diff --git a/src/tools/clippy/tests/ui/wildcard_imports.stderr b/src/tools/clippy/tests/ui/wildcard_imports.stderr index 01a5414778c10..0c69d5262c26f 100644 --- a/src/tools/clippy/tests/ui/wildcard_imports.stderr +++ b/src/tools/clippy/tests/ui/wildcard_imports.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports.rs:15:5 + --> tests/ui/wildcard_imports.rs:15:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` @@ -8,91 +8,91 @@ LL | use crate::fn_mod::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:16:5 + --> tests/ui/wildcard_imports.rs:16:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:17:5 + --> tests/ui/wildcard_imports.rs:17:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:19:5 + --> tests/ui/wildcard_imports.rs:19:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:23:5 + --> tests/ui/wildcard_imports.rs:23:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:24:5 + --> tests/ui/wildcard_imports.rs:24:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:94:13 + --> tests/ui/wildcard_imports.rs:94:13 | LL | use self::exports_underscore_ish::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self::exports_underscore_ish::{_Deref, dummy}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:125:13 + --> tests/ui/wildcard_imports.rs:125:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:131:75 + --> tests/ui/wildcard_imports.rs:131:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:132:13 + --> tests/ui/wildcard_imports.rs:132:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:144:20 + --> tests/ui/wildcard_imports.rs:144:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:144:30 + --> tests/ui/wildcard_imports.rs:144:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:151:13 + --> tests/ui/wildcard_imports.rs:151:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:180:9 + --> tests/ui/wildcard_imports.rs:180:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:189:9 + --> tests/ui/wildcard_imports.rs:189:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:190:9 + --> tests/ui/wildcard_imports.rs:190:9 | LL | use crate:: fn_mod:: | _________^ @@ -100,37 +100,37 @@ LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:201:13 + --> tests/ui/wildcard_imports.rs:201:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:236:17 + --> tests/ui/wildcard_imports.rs:236:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:244:13 + --> tests/ui/wildcard_imports.rs:244:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:253:17 + --> tests/ui/wildcard_imports.rs:253:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:262:13 + --> tests/ui/wildcard_imports.rs:262:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports.rs:270:13 + --> tests/ui/wildcard_imports.rs:270:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` 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 e39f240a4aa2a..11e0bd377692d 100644 --- a/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.stderr +++ b/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2018.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:13:5 + --> tests/ui/wildcard_imports_2021.rs:13:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` @@ -8,91 +8,91 @@ LL | use crate::fn_mod::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:14:5 + --> tests/ui/wildcard_imports_2021.rs:14:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:15:5 + --> tests/ui/wildcard_imports_2021.rs:15:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:16:5 + --> tests/ui/wildcard_imports_2021.rs:16:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:19:5 + --> tests/ui/wildcard_imports_2021.rs:19:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:21:5 + --> tests/ui/wildcard_imports_2021.rs:21:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:89:13 + --> tests/ui/wildcard_imports_2021.rs:89:13 | LL | use exports_underscore_ish::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `exports_underscore_ish::{_Deref, dummy}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:119:13 + --> tests/ui/wildcard_imports_2021.rs:119:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:125:75 + --> tests/ui/wildcard_imports_2021.rs:125:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:126:13 + --> tests/ui/wildcard_imports_2021.rs:126:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:20 + --> tests/ui/wildcard_imports_2021.rs:138:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:30 + --> tests/ui/wildcard_imports_2021.rs:138:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:145:13 + --> tests/ui/wildcard_imports_2021.rs:145:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:174:9 + --> tests/ui/wildcard_imports_2021.rs:174:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:183:9 + --> tests/ui/wildcard_imports_2021.rs:183:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:184:9 + --> tests/ui/wildcard_imports_2021.rs:184:9 | LL | use crate:: fn_mod:: | _________^ @@ -100,37 +100,37 @@ LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:195:13 + --> tests/ui/wildcard_imports_2021.rs:195:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:230:17 + --> tests/ui/wildcard_imports_2021.rs:230:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:238:13 + --> tests/ui/wildcard_imports_2021.rs:238:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:247:17 + --> tests/ui/wildcard_imports_2021.rs:247:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:256:13 + --> tests/ui/wildcard_imports_2021.rs:256:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:264:13 + --> tests/ui/wildcard_imports_2021.rs:264:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` 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 e39f240a4aa2a..11e0bd377692d 100644 --- a/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.stderr +++ b/src/tools/clippy/tests/ui/wildcard_imports_2021.edition2021.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:13:5 + --> tests/ui/wildcard_imports_2021.rs:13:5 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` @@ -8,91 +8,91 @@ LL | use crate::fn_mod::*; = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:14:5 + --> tests/ui/wildcard_imports_2021.rs:14:5 | LL | use crate::mod_mod::*; | ^^^^^^^^^^^^^^^^^ help: try: `crate::mod_mod::inner_mod` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:15:5 + --> tests/ui/wildcard_imports_2021.rs:15:5 | LL | use crate::multi_fn_mod::*; | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::multi_fn_mod::{multi_bar, multi_foo, multi_inner_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:16:5 + --> tests/ui/wildcard_imports_2021.rs:16:5 | LL | use crate::struct_mod::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::struct_mod::{A, inner_struct_mod}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:19:5 + --> tests/ui/wildcard_imports_2021.rs:19:5 | LL | use wildcard_imports_helper::inner::inner_for_self_import::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::inner::inner_for_self_import::inner_extern_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:21:5 + --> tests/ui/wildcard_imports_2021.rs:21:5 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:89:13 + --> tests/ui/wildcard_imports_2021.rs:89:13 | LL | use exports_underscore_ish::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `exports_underscore_ish::{_Deref, dummy}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:119:13 + --> tests/ui/wildcard_imports_2021.rs:119:13 | LL | use crate::fn_mod::*; | ^^^^^^^^^^^^^^^^ help: try: `crate::fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:125:75 + --> tests/ui/wildcard_imports_2021.rs:125:75 | LL | use wildcard_imports_helper::inner::inner_for_self_import::{self, *}; | ^ help: try: `inner_extern_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:126:13 + --> tests/ui/wildcard_imports_2021.rs:126:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternA, extern_foo}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:20 + --> tests/ui/wildcard_imports_2021.rs:138:20 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^ help: try: `inner::inner_foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:138:30 + --> tests/ui/wildcard_imports_2021.rs:138:30 | LL | use self::{inner::*, inner2::*}; | ^^^^^^^^^ help: try: `inner2::inner_bar` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:145:13 + --> tests/ui/wildcard_imports_2021.rs:145:13 | LL | use wildcard_imports_helper::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `wildcard_imports_helper::{ExternExportedEnum, ExternExportedStruct, extern_exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:174:9 + --> tests/ui/wildcard_imports_2021.rs:174:9 | LL | use crate::in_fn_test::*; | ^^^^^^^^^^^^^^^^^^^^ help: try: `crate::in_fn_test::{ExportedEnum, ExportedStruct, exported}` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:183:9 + --> tests/ui/wildcard_imports_2021.rs:183:9 | LL | use crate:: in_fn_test:: * ; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate:: in_fn_test::exported` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:184:9 + --> tests/ui/wildcard_imports_2021.rs:184:9 | LL | use crate:: fn_mod:: | _________^ @@ -100,37 +100,37 @@ LL | | *; | |_________^ help: try: `crate:: fn_mod::foo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:195:13 + --> tests/ui/wildcard_imports_2021.rs:195:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:230:17 + --> tests/ui/wildcard_imports_2021.rs:230:17 | LL | use super::*; | ^^^^^^^^ help: try: `super::insidefoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:238:13 + --> tests/ui/wildcard_imports_2021.rs:238:13 | LL | use crate::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `crate::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:247:17 + --> tests/ui/wildcard_imports_2021.rs:247:17 | LL | use super::super::*; | ^^^^^^^^^^^^^^^ help: try: `super::super::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:256:13 + --> tests/ui/wildcard_imports_2021.rs:256:13 | LL | use super::super::super_imports::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `super::super::super_imports::foofoo` error: usage of wildcard import - --> $DIR/wildcard_imports_2021.rs:264:13 + --> tests/ui/wildcard_imports_2021.rs:264:13 | LL | use super::*; | ^^^^^^^^ help: try: `super::foofoo` diff --git a/src/tools/clippy/tests/ui/write_literal.stderr b/src/tools/clippy/tests/ui/write_literal.stderr index ee0d536e954f3..9f4cdfd91e8ab 100644 --- a/src/tools/clippy/tests/ui/write_literal.stderr +++ b/src/tools/clippy/tests/ui/write_literal.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:31:27 + --> tests/ui/write_literal.rs:31:27 | LL | write!(v, "Hello {}", "world"); | ^^^^^^^ @@ -13,7 +13,7 @@ LL + write!(v, "Hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:34:39 + --> tests/ui/write_literal.rs:34:39 | LL | writeln!(v, "Hello {} {}", world, "world"); | ^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, "Hello {} world", world); | error: literal with an empty format string - --> $DIR/write_literal.rs:36:29 + --> tests/ui/write_literal.rs:36:29 | LL | writeln!(v, "Hello {}", "world"); | ^^^^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "Hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:38:29 + --> tests/ui/write_literal.rs:38:29 | LL | writeln!(v, "{} {:.4}", "a literal", 5); | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + writeln!(v, "a literal {:.4}", 5); | error: literal with an empty format string - --> $DIR/write_literal.rs:44:28 + --> tests/ui/write_literal.rs:44:28 | LL | writeln!(v, "{0} {1}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + writeln!(v, "hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:46:28 + --> tests/ui/write_literal.rs:46:28 | LL | writeln!(v, "{1} {0}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + writeln!(v, "world hello"); | error: literal with an empty format string - --> $DIR/write_literal.rs:50:38 + --> tests/ui/write_literal.rs:50:38 | LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + writeln!(v, "hello world"); | error: literal with an empty format string - --> $DIR/write_literal.rs:52:38 + --> tests/ui/write_literal.rs:52:38 | LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + writeln!(v, "world hello"); | error: literal with an empty format string - --> $DIR/write_literal.rs:56:32 + --> tests/ui/write_literal.rs:56:32 | LL | writeln!(v, "{0} {1} {2}", "hello", 2, "world"); | ^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + writeln!(v, "hello {0} world", 2); | error: literal with an empty format string - --> $DIR/write_literal.rs:58:32 + --> tests/ui/write_literal.rs:58:32 | LL | writeln!(v, "{2} {1} {0}", "hello", 2, "world"); | ^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + writeln!(v, "world {0} hello", 2); | error: literal with an empty format string - --> $DIR/write_literal.rs:60:39 + --> tests/ui/write_literal.rs:60:39 | LL | writeln!(v, "{0} {1} {2}, {bar}", "hello", 2, 3, bar = 4); | ^^^^^^^ @@ -133,7 +133,7 @@ LL + writeln!(v, "hello {0} {1}, {bar}", 2, 3, bar = 4); | error: literal with an empty format string - --> $DIR/write_literal.rs:62:41 + --> tests/ui/write_literal.rs:62:41 | LL | writeln!(v, "{0} {1} {2}, {3} {4}", "hello", 2, 3, "world", 4); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/write_literal_2.stderr b/src/tools/clippy/tests/ui/write_literal_2.stderr index 81ef49de082e7..9fba3ce548a06 100644 --- a/src/tools/clippy/tests/ui/write_literal_2.stderr +++ b/src/tools/clippy/tests/ui/write_literal_2.stderr @@ -1,5 +1,5 @@ error: literal with an empty format string - --> $DIR/write_literal_2.rs:10:23 + --> tests/ui/write_literal_2.rs:10:23 | LL | writeln!(v, "{}", "{hello}"); | ^^^^^^^^^ @@ -13,7 +13,7 @@ LL + writeln!(v, "{{hello}}"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:13:24 + --> tests/ui/write_literal_2.rs:13:24 | LL | writeln!(v, r"{}", r"{hello}"); | ^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, r"{{hello}}"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:15:23 + --> tests/ui/write_literal_2.rs:15:23 | LL | writeln!(v, "{}", '\''); | ^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "'"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:17:23 + --> tests/ui/write_literal_2.rs:17:23 | LL | writeln!(v, "{}", '"'); | ^^^ @@ -49,13 +49,13 @@ LL + writeln!(v, "\""); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:19:24 + --> tests/ui/write_literal_2.rs:19:24 | LL | writeln!(v, r"{}", '"'); | ^^^ error: literal with an empty format string - --> $DIR/write_literal_2.rs:21:24 + --> tests/ui/write_literal_2.rs:21:24 | LL | writeln!(v, r"{}", '\''); | ^^^^ @@ -67,7 +67,7 @@ LL + writeln!(v, r"'"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:26:9 + --> tests/ui/write_literal_2.rs:26:9 | LL | / "hello \ LL | | world!", @@ -80,7 +80,7 @@ LL ~ world!", | error: literal with an empty format string - --> $DIR/write_literal_2.rs:34:9 + --> tests/ui/write_literal_2.rs:34:9 | LL | "1", "2", "3", | ^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL ~ 2 \\ 3", | error: literal with an empty format string - --> $DIR/write_literal_2.rs:36:23 + --> tests/ui/write_literal_2.rs:36:23 | LL | writeln!(v, "{}", "\\"); | ^^^^ @@ -104,7 +104,7 @@ LL + writeln!(v, "\\"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:38:24 + --> tests/ui/write_literal_2.rs:38:24 | LL | writeln!(v, r"{}", "\\"); | ^^^^ @@ -116,7 +116,7 @@ LL + writeln!(v, r"\"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:40:26 + --> tests/ui/write_literal_2.rs:40:26 | LL | writeln!(v, r#"{}"#, "\\"); | ^^^^ @@ -128,7 +128,7 @@ LL + writeln!(v, r#"\"#); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:42:23 + --> tests/ui/write_literal_2.rs:42:23 | LL | writeln!(v, "{}", r"\"); | ^^^^ @@ -140,7 +140,7 @@ LL + writeln!(v, "\\"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:44:23 + --> tests/ui/write_literal_2.rs:44:23 | LL | writeln!(v, "{}", "\r"); | ^^^^ @@ -152,7 +152,7 @@ LL + writeln!(v, "\r"); | error: literal with an empty format string - --> $DIR/write_literal_2.rs:47:28 + --> tests/ui/write_literal_2.rs:47:28 | LL | writeln!(v, r#"{}{}"#, '#', '"'); | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/write_with_newline.stderr b/src/tools/clippy/tests/ui/write_with_newline.stderr index 78874ffadc0be..7eb741107a7b8 100644 --- a/src/tools/clippy/tests/ui/write_with_newline.stderr +++ b/src/tools/clippy/tests/ui/write_with_newline.stderr @@ -1,5 +1,5 @@ error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:12:5 + --> tests/ui/write_with_newline.rs:12:5 | LL | write!(v, "Hello\n"); | ^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + writeln!(v, "Hello"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:15:5 + --> tests/ui/write_with_newline.rs:15:5 | LL | write!(v, "Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, "Hello {}", "world"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:17:5 + --> tests/ui/write_with_newline.rs:17:5 | LL | write!(v, "Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "Hello {} {}", "world", "#2"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:19:5 + --> tests/ui/write_with_newline.rs:19:5 | LL | write!(v, "{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + writeln!(v, "{}", 1265); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:21:5 + --> tests/ui/write_with_newline.rs:21:5 | LL | write!(v, "\n"); | ^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + writeln!(v); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:44:5 + --> tests/ui/write_with_newline.rs:44:5 | LL | write!(v, "\\\n"); | ^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + writeln!(v, "\\"); | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:53:5 + --> tests/ui/write_with_newline.rs:53:5 | LL | / write!( LL | | @@ -91,7 +91,7 @@ LL ~ v | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:59:5 + --> tests/ui/write_with_newline.rs:59:5 | LL | / write!( LL | | @@ -109,7 +109,7 @@ LL ~ v | error: using `write!()` with a format string that ends in a single newline - --> $DIR/write_with_newline.rs:69:5 + --> tests/ui/write_with_newline.rs:69:5 | LL | write!(v, "\\r\n"); | ^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/writeln_empty_string.stderr b/src/tools/clippy/tests/ui/writeln_empty_string.stderr index 0374755436176..20ece6a419264 100644 --- a/src/tools/clippy/tests/ui/writeln_empty_string.stderr +++ b/src/tools/clippy/tests/ui/writeln_empty_string.stderr @@ -1,5 +1,5 @@ error: empty string literal in `writeln!` - --> $DIR/writeln_empty_string.rs:9:5 + --> tests/ui/writeln_empty_string.rs:9:5 | LL | writeln!(v, ""); | ^^^^^^^^^^----^ @@ -10,7 +10,7 @@ LL | writeln!(v, ""); = help: to override `-D warnings` add `#[allow(clippy::writeln_empty_string)]` error: empty string literal in `writeln!` - --> $DIR/writeln_empty_string.rs:12:5 + --> tests/ui/writeln_empty_string.rs:12:5 | LL | writeln!(suggestion, ""); | ^^^^^^^^^^^^^^^^^^^----^ diff --git a/src/tools/clippy/tests/ui/wrong_self_convention.stderr b/src/tools/clippy/tests/ui/wrong_self_convention.stderr index 9f457b50ce775..5c286721c4782 100644 --- a/src/tools/clippy/tests/ui/wrong_self_convention.stderr +++ b/src/tools/clippy/tests/ui/wrong_self_convention.stderr @@ -1,5 +1,5 @@ error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:16:17 + --> tests/ui/wrong_self_convention.rs:16:17 | LL | fn from_i32(self) {} | ^^^^ @@ -9,7 +9,7 @@ LL | fn from_i32(self) {} = 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 + --> tests/ui/wrong_self_convention.rs:23:21 | LL | pub fn from_i64(self) {} | ^^^^ @@ -17,7 +17,7 @@ LL | pub fn from_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:36:15 + --> tests/ui/wrong_self_convention.rs:36:15 | LL | fn as_i32(self) {} | ^^^^ @@ -25,7 +25,7 @@ LL | fn as_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:39:17 + --> tests/ui/wrong_self_convention.rs:39:17 | LL | fn into_i32(&self) {} | ^^^^^ @@ -33,7 +33,7 @@ LL | fn into_i32(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:42:15 + --> tests/ui/wrong_self_convention.rs:42:15 | LL | fn is_i32(self) {} | ^^^^ @@ -41,7 +41,7 @@ LL | fn is_i32(self) {} = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_convention.rs:45:15 + --> tests/ui/wrong_self_convention.rs:45:15 | LL | fn to_i32(self) {} | ^^^^ @@ -49,7 +49,7 @@ LL | fn to_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:48:17 + --> tests/ui/wrong_self_convention.rs:48:17 | LL | fn from_i32(self) {} | ^^^^ @@ -57,7 +57,7 @@ LL | fn from_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:51:19 + --> tests/ui/wrong_self_convention.rs:51:19 | LL | pub fn as_i64(self) {} | ^^^^ @@ -65,7 +65,7 @@ LL | pub fn as_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:53:21 + --> tests/ui/wrong_self_convention.rs:53:21 | LL | pub fn into_i64(&self) {} | ^^^^^ @@ -73,7 +73,7 @@ LL | pub fn into_i64(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:55:19 + --> tests/ui/wrong_self_convention.rs:55:19 | LL | pub fn is_i64(self) {} | ^^^^ @@ -81,7 +81,7 @@ LL | pub fn is_i64(self) {} = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_convention.rs:57:19 + --> tests/ui/wrong_self_convention.rs:57:19 | LL | pub fn to_i64(self) {} | ^^^^ @@ -89,7 +89,7 @@ LL | pub fn to_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:59:21 + --> tests/ui/wrong_self_convention.rs:59:21 | LL | pub fn from_i64(self) {} | ^^^^ @@ -97,7 +97,7 @@ LL | pub fn from_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:105:19 + --> tests/ui/wrong_self_convention.rs:105:19 | LL | fn as_i32(self) {} | ^^^^ @@ -105,7 +105,7 @@ LL | fn as_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:109:25 + --> tests/ui/wrong_self_convention.rs:109:25 | LL | fn into_i32_ref(&self) {} | ^^^^^ @@ -113,7 +113,7 @@ LL | fn into_i32_ref(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:112:19 + --> tests/ui/wrong_self_convention.rs:112:19 | LL | fn is_i32(self) {} | ^^^^ @@ -121,7 +121,7 @@ LL | fn is_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:117:21 + --> tests/ui/wrong_self_convention.rs:117:21 | LL | fn from_i32(self) {} | ^^^^ @@ -129,7 +129,7 @@ LL | fn from_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/wrong_self_convention.rs:133:19 + --> tests/ui/wrong_self_convention.rs:133:19 | LL | fn as_i32(self); | ^^^^ @@ -137,7 +137,7 @@ LL | fn as_i32(self); = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:137:25 + --> tests/ui/wrong_self_convention.rs:137:25 | LL | fn into_i32_ref(&self); | ^^^^^ @@ -145,7 +145,7 @@ LL | fn into_i32_ref(&self); = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> $DIR/wrong_self_convention.rs:140:19 + --> tests/ui/wrong_self_convention.rs:140:19 | LL | fn is_i32(self); | ^^^^ @@ -153,7 +153,7 @@ LL | fn is_i32(self); = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:145:21 + --> tests/ui/wrong_self_convention.rs:145:21 | LL | fn from_i32(self); | ^^^^ @@ -161,7 +161,7 @@ LL | fn from_i32(self); = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> $DIR/wrong_self_convention.rs:164:25 + --> tests/ui/wrong_self_convention.rs:164:25 | LL | fn into_i32_ref(&self); | ^^^^^ @@ -169,7 +169,7 @@ LL | fn into_i32_ref(&self); = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention.rs:171:21 + --> tests/ui/wrong_self_convention.rs:171:21 | LL | fn from_i32(self); | ^^^^ @@ -177,7 +177,7 @@ LL | fn from_i32(self); = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value - --> $DIR/wrong_self_convention.rs:196:22 + --> tests/ui/wrong_self_convention.rs:196:22 | LL | fn to_u64_v2(&self) -> u64 { | ^^^^^ @@ -185,7 +185,7 @@ LL | fn to_u64_v2(&self) -> u64 { = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_convention.rs:206:19 + --> tests/ui/wrong_self_convention.rs:206:19 | LL | fn to_u64(self) -> u64 { | ^^^^ diff --git a/src/tools/clippy/tests/ui/wrong_self_convention2.stderr b/src/tools/clippy/tests/ui/wrong_self_convention2.stderr index dc12a844332eb..7aabdcd408c66 100644 --- a/src/tools/clippy/tests/ui/wrong_self_convention2.stderr +++ b/src/tools/clippy/tests/ui/wrong_self_convention2.stderr @@ -1,5 +1,5 @@ error: methods called `from_*` usually take no `self` - --> $DIR/wrong_self_convention2.rs:54:29 + --> tests/ui/wrong_self_convention2.rs:54:29 | LL | pub fn from_be_self(self) -> Self { | ^^^^ @@ -9,7 +9,7 @@ LL | pub fn from_be_self(self) -> Self { = 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 + --> tests/ui/wrong_self_convention2.rs:64:25 | LL | fn from_be_self(self) -> Self; | ^^^^ 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 21255287d722e..f52a36632101c 100644 --- a/src/tools/clippy/tests/ui/wrong_self_conventions_mut.stderr +++ b/src/tools/clippy/tests/ui/wrong_self_conventions_mut.stderr @@ -1,5 +1,5 @@ error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> $DIR/wrong_self_conventions_mut.rs:14:24 + --> tests/ui/wrong_self_conventions_mut.rs:14:24 | LL | pub fn to_many(&mut self) -> Option<&mut [T]> { | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | pub fn to_many(&mut self) -> Option<&mut [T]> { = 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 + --> tests/ui/wrong_self_conventions_mut.rs:23:28 | LL | pub fn to_many_mut(&self) -> Option<&[T]> { | ^^^^^ diff --git a/src/tools/clippy/tests/ui/zero_div_zero.stderr b/src/tools/clippy/tests/ui/zero_div_zero.stderr index 797ae2537bb37..5294ebdfa5da1 100644 --- a/src/tools/clippy/tests/ui/zero_div_zero.stderr +++ b/src/tools/clippy/tests/ui/zero_div_zero.stderr @@ -1,5 +1,5 @@ error: constant division of `0.0` with `0.0` will always result in NaN - --> $DIR/zero_div_zero.rs:4:15 + --> tests/ui/zero_div_zero.rs:4:15 | LL | let nan = 0.0 / 0.0; | ^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let nan = 0.0 / 0.0; = 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 + --> tests/ui/zero_div_zero.rs:6:19 | LL | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let f64_nan = 0.0 / 0.0f64; = help: consider using `f64::NAN` if you would like a constant representing NaN error: constant division of `0.0` with `0.0` will always result in NaN - --> $DIR/zero_div_zero.rs:8:25 + --> tests/ui/zero_div_zero.rs:8:25 | LL | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let other_f64_nan = 0.0f64 / 0.0; = help: consider using `f64::NAN` if you would like a constant representing NaN error: constant division of `0.0` with `0.0` will always result in NaN - --> $DIR/zero_div_zero.rs:10:28 + --> tests/ui/zero_div_zero.rs:10:28 | LL | let one_more_f64_nan = 0.0f64 / 0.0f64; | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/zero_offset.stderr b/src/tools/clippy/tests/ui/zero_offset.stderr index bb616f456ae14..a1efe3904c18b 100644 --- a/src/tools/clippy/tests/ui/zero_offset.stderr +++ b/src/tools/clippy/tests/ui/zero_offset.stderr @@ -1,5 +1,5 @@ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:5:9 + --> tests/ui/zero_offset.rs:5:9 | LL | m.offset(0); | ^^^^^^^^^^^ @@ -7,43 +7,43 @@ LL | m.offset(0); = note: `#[deny(clippy::zst_offset)]` on by default error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:8:9 + --> tests/ui/zero_offset.rs:8:9 | LL | m.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:10:9 + --> tests/ui/zero_offset.rs:10:9 | LL | m.sub(0); | ^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:12:9 + --> tests/ui/zero_offset.rs:12:9 | LL | m.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:16:9 + --> tests/ui/zero_offset.rs:16:9 | LL | c.offset(0); | ^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:18:9 + --> tests/ui/zero_offset.rs:18:9 | LL | c.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:20:9 + --> tests/ui/zero_offset.rs:20:9 | LL | c.sub(0); | ^^^^^^^^ error: offset calculation on zero-sized value - --> $DIR/zero_offset.rs:22:9 + --> tests/ui/zero_offset.rs:22:9 | LL | c.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/zero_ptr.stderr b/src/tools/clippy/tests/ui/zero_ptr.stderr index 57679a8ac564f..a580bebd5d3aa 100644 --- a/src/tools/clippy/tests/ui/zero_ptr.stderr +++ b/src/tools/clippy/tests/ui/zero_ptr.stderr @@ -1,5 +1,5 @@ error: `0 as *const _` detected - --> $DIR/zero_ptr.rs:4:13 + --> tests/ui/zero_ptr.rs:4:13 | LL | let _ = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ help: try: `std::ptr::null::()` @@ -8,25 +8,25 @@ LL | let _ = 0 as *const usize; = help: to override `-D warnings` add `#[allow(clippy::zero_ptr)]` error: `0 as *mut _` detected - --> $DIR/zero_ptr.rs:5:13 + --> tests/ui/zero_ptr.rs:5:13 | LL | let _ = 0 as *mut f64; | ^^^^^^^^^^^^^ help: try: `std::ptr::null_mut::()` error: `0 as *const _` detected - --> $DIR/zero_ptr.rs:6:24 + --> tests/ui/zero_ptr.rs:6:24 | LL | let _: *const u8 = 0 as *const _; | ^^^^^^^^^^^^^ help: try: `std::ptr::null()` error: `0 as *const _` detected - --> $DIR/zero_ptr.rs:9:9 + --> tests/ui/zero_ptr.rs:9:9 | LL | foo(0 as *const _, 0 as *mut _); | ^^^^^^^^^^^^^ help: try: `std::ptr::null()` error: `0 as *mut _` detected - --> $DIR/zero_ptr.rs:9:24 + --> tests/ui/zero_ptr.rs:9:24 | LL | foo(0 as *const _, 0 as *mut _); | ^^^^^^^^^^^ help: try: `std::ptr::null_mut()` diff --git a/src/tools/clippy/tests/ui/zero_ptr_no_std.stderr b/src/tools/clippy/tests/ui/zero_ptr_no_std.stderr index 915b9c477ff4c..42a1a41ca94f4 100644 --- a/src/tools/clippy/tests/ui/zero_ptr_no_std.stderr +++ b/src/tools/clippy/tests/ui/zero_ptr_no_std.stderr @@ -1,23 +1,23 @@ error: `0 as *const _` detected - --> $DIR/zero_ptr_no_std.rs:7:13 + --> tests/ui/zero_ptr_no_std.rs:7:13 | LL | let _ = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ help: try: `core::ptr::null::()` | note: the lint level is defined here - --> $DIR/zero_ptr_no_std.rs:3:9 + --> tests/ui/zero_ptr_no_std.rs:3:9 | LL | #![deny(clippy::zero_ptr)] | ^^^^^^^^^^^^^^^^ error: `0 as *mut _` detected - --> $DIR/zero_ptr_no_std.rs:8:13 + --> tests/ui/zero_ptr_no_std.rs:8:13 | LL | let _ = 0 as *mut f64; | ^^^^^^^^^^^^^ help: try: `core::ptr::null_mut::()` error: `0 as *const _` detected - --> $DIR/zero_ptr_no_std.rs:9:24 + --> tests/ui/zero_ptr_no_std.rs:9:24 | LL | let _: *const u8 = 0 as *const _; | ^^^^^^^^^^^^^ help: try: `core::ptr::null()` 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 c48e19a760af2..65fc81e10e6c3 100644 --- a/src/tools/clippy/tests/ui/zero_sized_btreemap_values.stderr +++ b/src/tools/clippy/tests/ui/zero_sized_btreemap_values.stderr @@ -1,5 +1,5 @@ error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:5:28 + --> tests/ui/zero_sized_btreemap_values.rs:5:28 | LL | const CONST_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const CONST_NOT_OK: Option> = None; = 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 + --> tests/ui/zero_sized_btreemap_values.rs:9:30 | LL | static STATIC_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static STATIC_NOT_OK: Option> = None; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:13:17 + --> tests/ui/zero_sized_btreemap_values.rs:13:17 | LL | type NotOkMap = BTreeMap; | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type NotOkMap = BTreeMap; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:18:11 + --> tests/ui/zero_sized_btreemap_values.rs:18:11 | LL | NotOk(BTreeMap), | ^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | NotOk(BTreeMap), = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:24:13 + --> tests/ui/zero_sized_btreemap_values.rs:24:13 | LL | not_ok: BTreeMap, | ^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | not_ok: BTreeMap, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:26:22 + --> tests/ui/zero_sized_btreemap_values.rs:26:22 | LL | also_not_ok: Vec>, | ^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | also_not_ok: Vec>, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:35:30 + --> tests/ui/zero_sized_btreemap_values.rs:35:30 | LL | fn weird_map(&self, map: BTreeMap); | ^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn weird_map(&self, map: BTreeMap); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:44:25 + --> tests/ui/zero_sized_btreemap_values.rs:44:25 | LL | fn not_ok(&self) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn not_ok(&self) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:62:14 + --> tests/ui/zero_sized_btreemap_values.rs:62:14 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:62:50 + --> tests/ui/zero_sized_btreemap_values.rs:62:50 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:73:35 + --> tests/ui/zero_sized_btreemap_values.rs:73:35 | LL | let _: BTreeMap = BTreeMap::new(); | ^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: BTreeMap = BTreeMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:73:12 + --> tests/ui/zero_sized_btreemap_values.rs:73:12 | LL | let _: BTreeMap = BTreeMap::new(); | ^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _: BTreeMap = BTreeMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_btreemap_values.rs:78:12 + --> tests/ui/zero_sized_btreemap_values.rs:78:12 | LL | let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect(); | ^^^^^^^^^^^^^^ 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 08b1b58f3df3a..08afef58a2aaa 100644 --- a/src/tools/clippy/tests/ui/zero_sized_hashmap_values.stderr +++ b/src/tools/clippy/tests/ui/zero_sized_hashmap_values.stderr @@ -1,5 +1,5 @@ error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:5:28 + --> tests/ui/zero_sized_hashmap_values.rs:5:28 | LL | const CONST_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const CONST_NOT_OK: Option> = None; = 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 + --> tests/ui/zero_sized_hashmap_values.rs:9:30 | LL | static STATIC_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static STATIC_NOT_OK: Option> = None; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:13:17 + --> tests/ui/zero_sized_hashmap_values.rs:13:17 | LL | type NotOkMap = HashMap; | ^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type NotOkMap = HashMap; = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:18:11 + --> tests/ui/zero_sized_hashmap_values.rs:18:11 | LL | NotOk(HashMap), | ^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | NotOk(HashMap), = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:24:13 + --> tests/ui/zero_sized_hashmap_values.rs:24:13 | LL | not_ok: HashMap, | ^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | not_ok: HashMap, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:26:22 + --> tests/ui/zero_sized_hashmap_values.rs:26:22 | LL | also_not_ok: Vec>, | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | also_not_ok: Vec>, = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:35:30 + --> tests/ui/zero_sized_hashmap_values.rs:35:30 | LL | fn weird_map(&self, map: HashMap); | ^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn weird_map(&self, map: HashMap); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:44:25 + --> tests/ui/zero_sized_hashmap_values.rs:44:25 | LL | fn not_ok(&self) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn not_ok(&self) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:62:14 + --> tests/ui/zero_sized_hashmap_values.rs:62:14 | LL | fn test(map: HashMap, key: &str) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:62:49 + --> tests/ui/zero_sized_hashmap_values.rs:62:49 | LL | fn test(map: HashMap, key: &str) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:73:34 + --> tests/ui/zero_sized_hashmap_values.rs:73:34 | LL | let _: HashMap = HashMap::new(); | ^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: HashMap = HashMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:73:12 + --> tests/ui/zero_sized_hashmap_values.rs:73:12 | LL | let _: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _: HashMap = HashMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> $DIR/zero_sized_hashmap_values.rs:78:12 + --> tests/ui/zero_sized_hashmap_values.rs:78:12 | LL | let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect(); | ^^^^^^^^^^^^^ diff --git a/src/tools/clippy/triagebot.toml b/src/tools/clippy/triagebot.toml index 3eadc66f544f3..1a81394af10d5 100644 --- a/src/tools/clippy/triagebot.toml +++ b/src/tools/clippy/triagebot.toml @@ -6,7 +6,7 @@ allow-unauthenticated = [ # Allows shortcuts like `@rustbot ready` # -# See https://github.com/rust-lang/triagebot/wiki/Shortcuts +# See https://forge.rust-lang.org/triagebot/shortcuts.html [shortcut] # Have rustbot inform users about the *No Merge Policy* @@ -19,6 +19,7 @@ new_pr = true [assign] contributing_url = "https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md" +users_on_vacation = ["xFrednet"] [assign.owners] "/.github" = ["@flip1995"] @@ -32,4 +33,5 @@ contributing_url = "https://github.com/rust-lang/rust-clippy/blob/master/CONTRIB "@dswij", "@Jarcho", "@blyxyas", + "@y21", ] diff --git a/src/tools/clippy/util/gh-pages/index.html b/src/tools/clippy/util/gh-pages/index.html index a5274eeb349d1..c88c298d5d787 100644 --- a/src/tools/clippy/util/gh-pages/index.html +++ b/src/tools/clippy/util/gh-pages/index.html @@ -594,19 +594,9 @@

>

{ } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct TheBook { compiler: Compiler, target: TargetSelection, @@ -286,7 +286,7 @@ fn invoke_rustdoc( builder.run(&mut cmd); } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Standalone { compiler: Compiler, target: TargetSelection, @@ -389,7 +389,7 @@ impl Step for Standalone { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Releases { compiler: Compiler, target: TargetSelection, @@ -492,7 +492,7 @@ pub struct SharedAssetsPaths { pub version_info: PathBuf, } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct SharedAssets { target: TargetSelection, } @@ -872,7 +872,7 @@ macro_rules! tool_doc { $(is_library = $is_library:expr,)? $(crates = $crates:expr)? ) => { - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $tool { target: TargetSelection, } @@ -1021,7 +1021,7 @@ tool_doc!( crates = ["bootstrap"] ); -#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { pub target: TargetSelection, } @@ -1056,7 +1056,7 @@ impl Step for ErrorIndex { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct UnstableBookGen { target: TargetSelection, } @@ -1112,7 +1112,7 @@ fn symlink_dir_force(config: &Config, original: &Path, link: &Path) { ); } -#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)] pub struct RustcBook { pub compiler: Compiler, pub target: TargetSelection, diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index 29238b90225af..6726671ddd9b3 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -159,7 +159,7 @@ macro_rules! install { only_hosts: $only_hosts:expr, $run_item:block $(, $c:ident)*;)+) => { $( - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -303,7 +303,7 @@ install!((self, builder, _config), }; ); -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Src { pub stage: u32, } diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 9622321a74e7c..4a92acfa3d90d 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -242,7 +242,7 @@ pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Llvm { pub target: TargetSelection, } @@ -815,7 +815,7 @@ fn get_var(var_base: &str, host: &str, target: &str) -> Option { .or_else(|| env::var_os(var_base)) } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Lld { pub target: TargetSelection, } @@ -937,7 +937,7 @@ impl Step for Lld { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Sanitizers { pub target: TargetSelection, } @@ -1147,7 +1147,7 @@ impl HashStamp { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrtBeginEnd { pub target: TargetSelection, } @@ -1215,7 +1215,7 @@ impl Step for CrtBeginEnd { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Libunwind { pub target: TargetSelection, } diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 27b0c7760f078..61ee2fc1f6f3d 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -10,7 +10,7 @@ use crate::core::config::TargetSelection; use crate::utils::helpers::output; use crate::Mode; -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExpandYamlAnchors; impl Step for ExpandYamlAnchors { @@ -36,7 +36,7 @@ impl Step for ExpandYamlAnchors { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct BuildManifest; impl Step for BuildManifest { @@ -75,7 +75,7 @@ impl Step for BuildManifest { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct BumpStage0; impl Step for BumpStage0 { @@ -97,7 +97,7 @@ impl Step for BumpStage0 { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct ReplaceVersionPlaceholder; impl Step for ReplaceVersionPlaceholder { @@ -119,7 +119,7 @@ impl Step for ReplaceVersionPlaceholder { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Miri { stage: u32, host: TargetSelection, @@ -178,7 +178,7 @@ impl Step for Miri { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct CollectLicenseMetadata; impl Step for CollectLicenseMetadata { @@ -210,7 +210,7 @@ impl Step for CollectLicenseMetadata { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct GenerateCopyright; impl Step for GenerateCopyright { @@ -240,7 +240,7 @@ impl Step for GenerateCopyright { } } -#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] pub struct GenerateWindowsSys; impl Step for GenerateWindowsSys { @@ -262,7 +262,7 @@ impl Step for GenerateWindowsSys { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct GenerateCompletions; macro_rules! generate_completions { diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 74a5578b43ec1..7bc68b5aec11f 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -233,7 +233,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) { } /// Creates a toolchain link for stage1 using `rustup` -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Link; impl Step for Link { type Output = (); @@ -444,7 +444,7 @@ fn prompt_user(prompt: &str) -> io::Result> { } /// Installs `src/etc/pre-push.sh` as a Git hook -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Hook; impl Step for Hook { @@ -516,7 +516,7 @@ undesirable, simply delete the `pre-push` file from .git/hooks." } /// Sets up or displays `src/etc/rust_analyzer_settings.json` -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Vscode; impl Step for Vscode { diff --git a/src/bootstrap/src/core/build_steps/synthetic_targets.rs b/src/bootstrap/src/core/build_steps/synthetic_targets.rs index a00835402ec8b..89d50b5ffffa4 100644 --- a/src/bootstrap/src/core/build_steps/synthetic_targets.rs +++ b/src/bootstrap/src/core/build_steps/synthetic_targets.rs @@ -12,7 +12,7 @@ use crate::core::config::TargetSelection; use crate::Compiler; use std::process::{Command, Stdio}; -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub(crate) struct MirOptPanicAbortSyntheticTarget { pub(crate) compiler: Compiler, pub(crate) base: TargetSelection, diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 791f847a8661a..a2c6e79d5e25c 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -86,7 +86,7 @@ impl Step for CrateBootstrap { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Linkcheck { host: TargetSelection, } @@ -179,7 +179,7 @@ fn check_if_tidy_is_installed() -> bool { .map_or(false, |status| status.success()) } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct HtmlCheck { target: TargetSelection, } @@ -220,7 +220,7 @@ impl Step for HtmlCheck { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Cargotest { stage: u32, host: TargetSelection, @@ -266,7 +266,7 @@ impl Step for Cargotest { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Cargo { stage: u32, host: TargetSelection, @@ -327,7 +327,7 @@ impl Step for Cargo { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustAnalyzer { stage: u32, host: TargetSelection, @@ -386,7 +386,7 @@ impl Step for RustAnalyzer { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Rustfmt { stage: u32, host: TargetSelection, @@ -433,7 +433,7 @@ impl Step for Rustfmt { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustDemangler { stage: u32, host: TargetSelection, @@ -492,7 +492,7 @@ impl Step for RustDemangler { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Miri { stage: u32, host: TargetSelection, @@ -699,7 +699,7 @@ impl Step for Miri { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CompiletestTest { host: TargetSelection, } @@ -747,7 +747,7 @@ impl Step for CompiletestTest { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Clippy { stage: u32, host: TargetSelection, @@ -815,7 +815,7 @@ fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString { env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("") } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocTheme { pub compiler: Compiler, } @@ -852,7 +852,7 @@ impl Step for RustdocTheme { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocJSStd { pub target: TargetSelection, } @@ -912,7 +912,7 @@ impl Step for RustdocJSStd { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocJSNotStd { pub target: TargetSelection, pub compiler: Compiler, @@ -966,7 +966,7 @@ fn get_browser_ui_test_version(npm: &Path) -> Option { .or_else(|| get_browser_ui_test_version_inner(npm, true)) } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustdocGUI { pub target: TargetSelection, pub compiler: Compiler, @@ -1060,7 +1060,7 @@ impl Step for RustdocGUI { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Tidy; impl Step for Tidy { @@ -1151,7 +1151,7 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExpandYamlAnchors; impl Step for ExpandYamlAnchors { @@ -1251,7 +1251,7 @@ macro_rules! test_definitions { host: $host:expr, compare_mode: $compare_mode:expr }) => { - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -1294,7 +1294,7 @@ macro_rules! coverage_test_alias { default: $default:expr, only_hosts: $only_hosts:expr $(,)? }) => { - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -1376,7 +1376,7 @@ default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assem /// /// Each individual mode also has its own alias that will run the tests in /// just that mode. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Coverage { pub compiler: Compiler, pub target: TargetSelection, @@ -1438,7 +1438,7 @@ host_test!(CoverageRunRustdoc { }); // For the mir-opt suite we do not use macros, as we need custom behavior when blessing. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct MirOpt { pub compiler: Compiler, pub target: TargetSelection, @@ -1494,7 +1494,7 @@ impl Step for MirOpt { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] struct Compiletest { compiler: Compiler, target: TargetSelection, @@ -2142,7 +2142,7 @@ impl BookTest { macro_rules! test_book { ($($name:ident, $path:expr, $book_name:expr, default=$default:expr;)+) => { $( - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { compiler: Compiler, } @@ -2187,7 +2187,7 @@ test_book!( EditionGuide, "src/doc/edition-guide", "edition-guide", default=false; ); -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ErrorIndex { compiler: Compiler, } @@ -2264,7 +2264,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustcGuide; impl Step for RustcGuide { @@ -2537,7 +2537,7 @@ impl Step for Crate { } /// Rustdoc is special in various ways, which is why this step is different from `Crate`. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdoc { host: TargetSelection, } @@ -2638,7 +2638,7 @@ impl Step for CrateRustdoc { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateRustdocJsonTypes { host: TargetSelection, } @@ -2708,7 +2708,7 @@ impl Step for CrateRustdocJsonTypes { /// QEMU we have to build our own tools so we've got conditional dependencies /// on those programs as well. Note that the remote test client is built for /// the build target (us) and the server is built for the target. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RemoteCopyLibs { compiler: Compiler, target: TargetSelection, @@ -2754,7 +2754,7 @@ impl Step for RemoteCopyLibs { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Distcheck; impl Step for Distcheck { @@ -2824,7 +2824,7 @@ impl Step for Distcheck { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Bootstrap; impl Step for Bootstrap { @@ -2876,7 +2876,7 @@ impl Step for Bootstrap { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TierCheck { pub compiler: Compiler, } @@ -2926,7 +2926,7 @@ impl Step for TierCheck { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct LintDocs { pub compiler: Compiler, pub target: TargetSelection, @@ -2959,7 +2959,7 @@ impl Step for LintDocs { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RustInstaller; impl Step for RustInstaller { @@ -3020,7 +3020,7 @@ impl Step for RustInstaller { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TestHelpers { pub target: TargetSelection, } diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index ba867a04ec55f..889876f461df2 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -15,7 +15,7 @@ use crate::Compiler; use crate::Mode; use crate::{gha, Kind}; -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum SourceType { InTree, Submodule, @@ -220,7 +220,7 @@ macro_rules! bootstrap_tool { $(,allow_features = $allow_features:expr)? ; )+) => { - #[derive(Copy, PartialEq, Eq, Clone)] + #[derive(PartialEq, Eq, Clone)] pub enum Tool { $( $name, @@ -241,7 +241,7 @@ macro_rules! bootstrap_tool { } $( - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct $name { pub compiler: Compiler, pub target: TargetSelection, @@ -315,7 +315,7 @@ bootstrap_tool!( CoverageDump, "src/tools/coverage-dump", "coverage-dump"; ); -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] pub struct ErrorIndex { pub compiler: Compiler, } @@ -369,7 +369,7 @@ impl Step for ErrorIndex { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RemoteTestServer { pub compiler: Compiler, pub target: TargetSelection, @@ -403,7 +403,7 @@ impl Step for RemoteTestServer { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] +#[derive(Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] pub struct Rustdoc { /// This should only ever be 0 or 2. /// We sometimes want to reference the "bootstrap" rustdoc, which is why this option is here. @@ -515,7 +515,7 @@ impl Step for Rustdoc { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub compiler: Compiler, pub target: TargetSelection, @@ -560,7 +560,7 @@ impl Step for Cargo { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct LldWrapper { pub compiler: Compiler, pub target: TargetSelection, @@ -589,7 +589,7 @@ impl Step for LldWrapper { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzer { pub compiler: Compiler, pub target: TargetSelection, @@ -637,7 +637,7 @@ impl Step for RustAnalyzer { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzerProcMacroSrv { pub compiler: Compiler, pub target: TargetSelection, diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 0ec5e16de1da5..e169cba3c13ae 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1069,7 +1069,7 @@ impl<'a> Builder<'a> { /// Returns the libdir where the standard library and other artifacts are /// found for a compiler's sysroot. pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> Interned { - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] + #[derive(Debug, Clone, Hash, PartialEq, Eq)] struct Libdir { compiler: Compiler, target: TargetSelection, diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 66592fe7e1010..875a4efae02fc 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1235,12 +1235,16 @@ impl Config { // Infer the rest of the configuration. // Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary, - // running on a completely machine from where it was compiled. + // running on a completely different machine from where it was compiled. let mut cmd = Command::new("git"); - // NOTE: we cannot support running from outside the repository because the only path we have available - // is set at compile time, which can be wrong if bootstrap was downloaded from source. + // NOTE: we cannot support running from outside the repository because the only other path we have available + // is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally. // We still support running outside the repository if we find we aren't in a git directory. - cmd.arg("rev-parse").arg("--show-toplevel"); + + // NOTE: We get a relative path from git to work around an issue on MSYS/mingw. If we used an absolute path, + // and end up using MSYS's git rather than git-for-windows, we would get a unix-y MSYS path. But as bootstrap + // has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path. + cmd.arg("rev-parse").arg("--show-cdup"); // Discard stderr because we expect this to fail when building from a tarball. let output = cmd .stderr(std::process::Stdio::null()) @@ -1248,13 +1252,18 @@ impl Config { .ok() .and_then(|output| if output.status.success() { Some(output) } else { None }); if let Some(output) = output { - let git_root = String::from_utf8(output.stdout).unwrap(); - // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes. - let git_root = PathBuf::from(git_root.trim()).canonicalize().unwrap(); + let git_root_relative = String::from_utf8(output.stdout).unwrap(); + // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes, + // and to resolve any relative components. + let git_root = env::current_dir() + .unwrap() + .join(PathBuf::from(git_root_relative.trim())) + .canonicalize() + .unwrap(); let s = git_root.to_str().unwrap(); // Bootstrap is quite bad at handling /? in front of paths - let src = match s.strip_prefix("\\\\?\\") { + let git_root = match s.strip_prefix("\\\\?\\") { Some(p) => PathBuf::from(p), None => git_root, }; @@ -1264,8 +1273,8 @@ impl Config { // // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1. - if src.join("src").join("stage0.json").exists() { - config.src = src; + if git_root.join("src").join("stage0.json").exists() { + config.src = git_root; } } else { // We're building from a tarball, not git sources. @@ -2399,7 +2408,7 @@ impl Config { .last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true) .is_none() { - // there are some untracked changes in the the given paths. + // there are some untracked changes in the given paths. false } else { llvm::is_ci_llvm_available(self, asserts) diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 965d788bb8371..f7748621d93ba 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -89,7 +89,7 @@ const EXTRA_CHECK_CFGS: &[(Option, &str, Option<&[&'static str]>)] = &[ (Some(Mode::Std), "netbsd10", None), (Some(Mode::Std), "backtrace_in_libstd", None), /* Extra values not defined in the built-in targets yet, but used in std */ - (Some(Mode::Std), "target_env", Some(&["libnx"])), + (Some(Mode::Std), "target_env", Some(&["libnx", "p2"])), // (Some(Mode::Std), "target_os", Some(&[])), (Some(Mode::Std), "target_arch", Some(&["spirv", "nvptx", "xtensa"])), /* Extra names used by dependencies */ diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index b813d82ca6f53..9a50ad4437e73 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -131,4 +131,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Warning, summary: "The \"codegen\"/\"llvm\" profile has been removed and replaced with \"compiler\", use it instead for the same behavior.", }, + ChangeInfo { + change_id: 118724, + severity: ChangeSeverity::Info, + summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.", + }, ]; diff --git a/src/bootstrap/src/utils/tarball.rs b/src/bootstrap/src/utils/tarball.rs index 573d923ed8fdd..a14dfd1ca1234 100644 --- a/src/bootstrap/src/utils/tarball.rs +++ b/src/bootstrap/src/utils/tarball.rs @@ -3,8 +3,8 @@ use std::{ process::Command, }; -use crate::core::build_steps::dist::distdir; use crate::core::builder::Builder; +use crate::core::{build_steps::dist::distdir, builder::Kind}; use crate::utils::channel; use crate::utils::helpers::t; @@ -325,7 +325,22 @@ impl<'a> Tarball<'a> { assert!(!formats.is_empty(), "dist.compression-formats can't be empty"); cmd.arg("--compression-formats").arg(formats.join(",")); } - cmd.args(["--compression-profile", &self.builder.config.dist_compression_profile]); + + // For `x install` tarball files aren't needed, so we can speed up the process by not producing them. + let compression_profile = if self.builder.kind == Kind::Install { + self.builder.verbose("Forcing dist.compression-profile = 'no-op' for `x install`."); + // "no-op" indicates that the rust-installer won't produce compressed tarball sources. + "no-op" + } else { + assert!( + self.builder.config.dist_compression_profile != "no-op", + "dist.compression-profile = 'no-op' can only be used for `x install`" + ); + + &self.builder.config.dist_compression_profile + }; + + cmd.args(&["--compression-profile", compression_profile]); self.builder.run(&mut cmd); // Ensure there are no symbolic links in the tarball. In particular, diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 9b0f477409a93..58d5dec9ba520 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -111,10 +111,31 @@ x--expand-yaml-anchors--remove: if: success() && !env.SKIP_JOB - &base-ci-job + defaults: + run: + shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }} timeout-minutes: 600 runs-on: "${{ matrix.os }}" env: *shared-ci-variables steps: + - if: contains(matrix.os, 'windows') + uses: msys2/setup-msys2@v2.22.0 + with: + # i686 jobs use mingw32. x86_64 and cross-compile jobs use mingw64. + msystem: ${{ contains(matrix.name, 'i686') && 'mingw32' || 'mingw64' }} + # don't try to download updates for already installed packages + update: false + # don't try to use the msys that comes built-in to the github runner, + # so we can control what is installed (i.e. not python) + release: true + # Inherit the full path from the Windows environment, with MSYS2's */bin/ + # dirs placed in front. This lets us run Windows-native Python etc. + path-type: inherit + install: > + make + dos2unix + diffutils + - name: disable git crlf conversion run: git config --global core.autocrlf false diff --git a/src/ci/run.sh b/src/ci/run.sh index 1cdcffc1a7544..3ad04c73d3da4 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -76,7 +76,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set dist.compression-profile=balance # the LLVM build, as not to run out of memory. # This is an attempt to fix the spurious build error tracked by # https://github.com/rust-lang/rust/issues/108227. -if isWindows && [[ ${CUSTOM_MINGW-0} -eq 1 ]]; then +if isKnownToBeMingwBuild; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.link-jobs=1" fi diff --git a/src/ci/scripts/install-clang.sh b/src/ci/scripts/install-clang.sh index 77164ed4117a9..aa7ff813f5161 100755 --- a/src/ci/scripts/install-clang.sh +++ b/src/ci/scripts/install-clang.sh @@ -37,8 +37,7 @@ if isMacOS; then # Configure `AR` specifically so rustbuild doesn't try to infer it as # `clang-ar` by accident. ciCommandSetEnv AR "ar" -elif isWindows && [[ ${CUSTOM_MINGW-0} -ne 1 ]]; then - +elif isWindows && ! isKnownToBeMingwBuild; then # If we're compiling for MSVC then we, like most other distribution builders, # switch to clang as the compiler. This'll allow us eventually to enable LTO # amongst LLVM and rustc. Note that we only do this on MSVC as I don't think diff --git a/src/ci/scripts/install-mingw.sh b/src/ci/scripts/install-mingw.sh index 7eccb9b86502c..87b835b63db5b 100755 --- a/src/ci/scripts/install-mingw.sh +++ b/src/ci/scripts/install-mingw.sh @@ -38,11 +38,11 @@ if isWindows; then ;; esac - if [[ "${CUSTOM_MINGW-0}" -ne 1 ]]; then - pacman -S --noconfirm --needed mingw-w64-$arch-toolchain mingw-w64-$arch-cmake \ - mingw-w64-$arch-gcc \ - mingw-w64-$arch-python # the python package is actually for python3 - ciCommandAddPath "$(ciCheckoutPath)/msys2/mingw${bits}/bin" + if [[ "${CUSTOM_MINGW:-0}" == 0 ]]; then + pacboy -S --noconfirm toolchain:p + # According to the comment in the Windows part of install-clang.sh, in the future we might + # want to do this instead: + # pacboy -S --noconfirm clang:p ... else mingw_dir="mingw${bits}" diff --git a/src/ci/scripts/install-msys2.sh b/src/ci/scripts/install-msys2.sh index 0aa4b42a6a8fb..905edf38a09db 100755 --- a/src/ci/scripts/install-msys2.sh +++ b/src/ci/scripts/install-msys2.sh @@ -1,17 +1,12 @@ #!/bin/bash -# Download and install MSYS2, needed primarily for the test suite (run-make) but -# also used by the MinGW toolchain for assembling things. +# Clean up and prepare the MSYS2 installation. MSYS2 is needed primarily for +# the test suite (run-make), but is also used by the MinGW toolchain for assembling things. set -euo pipefail IFS=$'\n\t' source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" - if isWindows; then - msys2Path="c:/msys64" - mkdir -p "${msys2Path}/home/${USERNAME}" - ciCommandAddPath "${msys2Path}/usr/bin" - # Detect the native Python version installed on the agent. On GitHub # Actions, the C:\hostedtoolcache\windows\Python directory contains a # subdirectory for each installed Python version. @@ -29,4 +24,33 @@ if isWindows; then fi ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64" ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts" + + # Install pacboy for easily installing packages + pacman -S --noconfirm pactoys + + # Delete these pre-installed tools so we can't accidentally use them, because we are using the + # MSYS2 setup action versions instead. + # Delete pre-installed version of MSYS2 + rm -r "/c/msys64/" + # Delete Strawberry Perl, which contains a version of mingw + rm -r "/c/Strawberry/" + # Delete these other copies of mingw, I don't even know where they come from. + rm -r "/c/mingw64/" + rm -r "/c/mingw32/" + + if isKnownToBeMingwBuild; then + # Use the mingw version of CMake for mingw builds. + # However, the MSVC build needs native CMake, as it fails with the mingw one. + # Delete native CMake + rm -r "/c/Program Files/CMake/" + # Install mingw-w64-$arch-cmake + pacboy -S --noconfirm cmake:p + + # We use Git-for-Windows for MSVC builds, and MSYS2 Git for mingw builds, + # so that both are tested. + # Delete Windows-Git + rm -r "/c/Program Files/Git/" + # Install MSYS2 git + pacman -S --noconfirm git + fi fi diff --git a/src/ci/shared.sh b/src/ci/shared.sh index 720394af249b2..2b0a10e4d08d9 100644 --- a/src/ci/shared.sh +++ b/src/ci/shared.sh @@ -52,6 +52,10 @@ function isLinux { [[ "${OSTYPE}" = "linux-gnu" ]] } +function isKnownToBeMingwBuild { + isGitHubActions && [[ "${CI_JOB_NAME}" == *mingw ]] +} + function isCiBranch { if [[ $# -ne 1 ]]; then echo "usage: $0 " diff --git a/src/doc/book b/src/doc/book index 71352deb20727..19c40bfd2d576 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 71352deb20727b4dda9ebfe8182709d5bf17dfea +Subproject commit 19c40bfd2d57641d962f3119a1c343355f1b3c5e diff --git a/src/doc/edition-guide b/src/doc/edition-guide index 76bd48a273a0e..e1eead1181a69 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit 76bd48a273a0e0413a3bf22c699112d41497b99e +Subproject commit e1eead1181a691e56299294d5f1d62fe7a26d317 diff --git a/src/doc/reference b/src/doc/reference index 8227666de13f6..3417f866932cb 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 8227666de13f6e7bb32dea9dc42e841adb5ce4b7 +Subproject commit 3417f866932cb1c09c6be0f31d2a02ee01b4b95d diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index e188d5d466f7f..57f1e708f5d58 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit e188d5d466f7f3ff9f1d518393235f4fe951be46 +Subproject commit 57f1e708f5d5850562bc385aaf610e6af14d6ec8 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 1f30cc7cca9a3..7b0ef5b0bea5e 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 1f30cc7cca9a3433bc1872abdc98960b36c21ca0 +Subproject commit 7b0ef5b0bea5e3ce3b9764aa5754a60e2cc05c52 diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 1f9307203bc3c..d4ca91977a636 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -60,6 +60,7 @@ - [*-unknown-openbsd](platform-support/openbsd.md) - [\*-unknown-uefi](platform-support/unknown-uefi.md) - [wasm32-wasi-preview1-threads](platform-support/wasm32-wasi-preview1-threads.md) + - [wasm32-wasip2](platform-support/wasm32-wasip2.md) - [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md) - [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md) - [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 80d9dc85f162a..984cb13f790ca 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -361,6 +361,7 @@ target | std | host | notes `thumbv7a-pc-windows-msvc` | ? | | `thumbv7a-uwp-windows-msvc` | ✓ | | `thumbv7neon-unknown-linux-musleabihf` | ? | | Thumb2-mode ARMv7-A Linux with NEON, MUSL +[`wasm32-wasip2`](platform-support/wasm32-wasip2.md) | ✓ | | WebAssembly [`wasm64-unknown-unknown`](platform-support/wasm64-unknown-unknown.md) | ? | | WebAssembly `x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst on x86_64 [`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ? | | x86 64-bit tvOS diff --git a/src/doc/rustc/src/platform-support/wasm32-wasip2.md b/src/doc/rustc/src/platform-support/wasm32-wasip2.md new file mode 100644 index 0000000000000..4466d2c084053 --- /dev/null +++ b/src/doc/rustc/src/platform-support/wasm32-wasip2.md @@ -0,0 +1,30 @@ +# `wasm32-wasip2` + +**Tier: 3** + +The `wasm32-wasip2` target is a new and still (as of January 2024) an +experimental target. This target is an extension to `wasm32-wasip1` target, +originally known as `wasm32-wasi`. It is the next evolution in the development of +wasi (the [WebAssembly System Interface](https://wasi.dev)) that uses the WebAssembly +[component model] to allow for a standardized set of syscalls that are intended to empower +WebAssembly binaries with native host capabilities. + +[component model]: https://github.com/WebAssembly/component-model + +## Target maintainers + +- Alex Crichton, https://github.com/alexcrichton +- Ryan Levick, https://github.com/rylev + +## Requirements + +This target is cross-compiled. The target supports `std` fully. + +## Platform requirements + +The WebAssembly runtime should support the wasi preview 2 API set. + +This target is not a stable target. This means that there are only a few engines +which implement wasi preview 2, for example: + +* Wasmtime - `-W component-model` diff --git a/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md b/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md index f7a749744e0fe..56c14b1638a6f 100644 --- a/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md +++ b/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md @@ -167,5 +167,5 @@ render differently in this case: [f]: g ``` -`1.` and `2.` will will be displayed as is in the rendered documentation (ie, `[a]` and `[b][c]`) +`1.` and `2.` will be displayed as is in the rendered documentation (ie, `[a]` and `[b][c]`) whereas `3.` and `4.` will be replaced by a link targetting `e` for `[d](e)` and `g` for `[f]`. diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index b736f4a795614..b6880cfc60fbf 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -1,4 +1,4 @@ -use rustc_ast::token::{self, BinOpToken, Delimiter}; +use rustc_ast::token::{self, BinOpToken, Delimiter, IdentIsRaw}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast_pretty::pprust::state::State as Printer; use rustc_ast_pretty::pprust::PrintState; @@ -148,7 +148,7 @@ fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) { (false, Other) } (Pound, token::Not) => (false, PoundBang), - (_, token::Ident(symbol, /* is_raw */ false)) + (_, token::Ident(symbol, IdentIsRaw::No)) if !usually_needs_space_between_keyword_and_open_delim(*symbol, tt.span) => { (true, Ident) diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 09a90b62d97be..e2b4ec5908b9d 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -643,8 +643,8 @@ pub(crate) fn make_test( // Reset errors so that they won't be reported as compiler bugs when dropping the // dcx. Any errors in the tests will be reported when the test file is compiled, - // Note that we still need to cancel the errors above otherwise `DiagnosticBuilder` - // will panic on drop. + // Note that we still need to cancel the errors above otherwise `Diag` will panic on + // drop. sess.dcx.reset_err_count(); (found_main, found_extern_crate, found_macro) @@ -1207,6 +1207,13 @@ impl Tester for Collector { } } +#[cfg(test)] // used in tests +impl Tester for Vec { + fn add_test(&mut self, _test: String, _config: LangString, line: usize) { + self.push(line); + } +} + struct HirCollector<'a, 'hir, 'tcx> { sess: &'a Session, collector: &'a mut Collector, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index bb68c84f529a7..afd5eb42d019d 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -575,7 +575,7 @@ fn generate_macro_def_id_path( ExternalLocation::Local => { // `root_path` always end with a `/`. format!( - "{root_path}{crate_name}/{path}", + "{root_path}{path}", root_path = root_path.unwrap_or(""), path = path.iter().map(|p| p.as_str()).join("/") ) @@ -879,11 +879,16 @@ fn primitive_link_fragment( match m.primitive_locations.get(&prim) { Some(&def_id) if def_id.is_local() => { let len = cx.current.len(); - let len = if len == 0 { 0 } else { len - 1 }; + let path = if len == 0 { + let cname_sym = ExternalCrate { crate_num: def_id.krate }.name(cx.tcx()); + format!("{cname_sym}/") + } else { + "../".repeat(len - 1) + }; write!( f, "", - "../".repeat(len), + path, prim.as_sym() )?; needs_termination = true; diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 1cdc792a819a8..aa5998876d9ab 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -136,6 +136,7 @@ fn can_merge(class1: Option, class2: Option, text: &str) -> bool { match (class1, class2) { (Some(c1), Some(c2)) => c1.is_equal_to(c2), (Some(Class::Ident(_)), None) | (None, Some(Class::Ident(_))) => true, + (Some(Class::Macro(_)), _) => false, (Some(_), None) | (None, Some(_)) => text.trim().is_empty(), (None, None) => true, } diff --git a/src/librustdoc/html/highlight/fixtures/sample.html b/src/librustdoc/html/highlight/fixtures/sample.html index aa735e81597c7..773afd5c2cc30 100644 --- a/src/librustdoc/html/highlight/fixtures/sample.html +++ b/src/librustdoc/html/highlight/fixtures/sample.html @@ -32,7 +32,7 @@ } } -macro_rules! bar { +macro_rules! bar { ($foo:tt) => {}; } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 21f682d15b97d..e8b250648bcad 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -27,7 +27,7 @@ //! ``` use rustc_data_structures::fx::FxHashMap; -use rustc_errors::{DiagnosticBuilder, DiagnosticMessage}; +use rustc_errors::{Diag, DiagnosticMessage}; use rustc_hir::def_id::DefId; use rustc_middle::ty::TyCtxt; pub(crate) use rustc_resolve::rustdoc::main_body_opts; @@ -843,7 +843,7 @@ impl<'tcx> ExtraInfo<'tcx> { fn error_invalid_codeblock_attr_with_help( &self, msg: impl Into, - f: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), + f: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), ) { if let Some(def_id) = self.def_id.as_local() { self.tcx.node_span_lint( diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 4dd176b3a692a..1de97e49b8307 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -480,11 +480,6 @@ fn test_markdown_html_escape() { #[test] fn test_find_testable_code_line() { fn t(input: &str, expect: &[usize]) { - impl crate::doctest::Tester for Vec { - fn add_test(&mut self, _test: String, _config: LangString, line: usize) { - self.push(line); - } - } let mut lines = Vec::::new(); find_testable_code(input, &mut lines, ErrorCodes::No, false, None, true); assert_eq!(lines, expect); diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index b26efb75ff657..b9a769a7c6da4 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -185,9 +185,12 @@ function preLoadCss(cssUrl) { (function() { const isHelpPage = window.location.pathname.endsWith("/help.html"); - function loadScript(url) { + function loadScript(url, errorCallback) { const script = document.createElement("script"); script.src = url; + if (errorCallback !== undefined) { + script.onerror = errorCallback; + } document.head.append(script); } @@ -292,11 +295,16 @@ function preLoadCss(cssUrl) { return; } let searchLoaded = false; + // If you're browsing the nightly docs, the page might need to be refreshed for the + // search to work because the hash of the JS scripts might have changed. + function sendSearchForm() { + document.getElementsByClassName("search-form")[0].submit(); + } function loadSearch() { if (!searchLoaded) { searchLoaded = true; - loadScript(getVar("static-root-path") + getVar("search-js")); - loadScript(resourcePath("search-index", ".js")); + loadScript(getVar("static-root-path") + getVar("search-js"), sendSearchForm); + loadScript(resourcePath("search-index", ".js"), sendSearchForm); } } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index a172580ac3f04..33bdbbe1b94fb 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -8,7 +8,7 @@ use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, intern::Interned, }; -use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticMessage}; +use rustc_errors::{Applicability, Diag, DiagnosticMessage}; use rustc_hir::def::Namespace::*; use rustc_hir::def::{DefKind, Namespace, PerNS}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; @@ -1173,22 +1173,21 @@ impl LinkCollector<'_, '_> { ) { // The resolved item did not match the disambiguator; give a better error than 'not found' let msg = format!("incompatible link kind for `{path_str}`"); - let callback = - |diag: &mut DiagnosticBuilder<'_, ()>, sp: Option, link_range| { - let note = format!( - "this link resolved to {} {}, which is not {} {}", - resolved.article(), - resolved.descr(), - specified.article(), - specified.descr(), - ); - if let Some(sp) = sp { - diag.span_label(sp, note); - } else { - diag.note(note); - } - suggest_disambiguator(resolved, diag, path_str, link_range, sp, diag_info); - }; + let callback = |diag: &mut Diag<'_, ()>, sp: Option, link_range| { + let note = format!( + "this link resolved to {} {}, which is not {} {}", + resolved.article(), + resolved.descr(), + specified.article(), + specified.descr(), + ); + if let Some(sp) = sp { + diag.span_label(sp, note); + } else { + diag.note(note); + } + suggest_disambiguator(resolved, diag, path_str, link_range, sp, diag_info); + }; report_diagnostic(self.cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, diag_info, callback); } @@ -1677,7 +1676,7 @@ fn report_diagnostic( lint: &'static Lint, msg: impl Into + Display, DiagnosticInfo { item, ori_link: _, dox, link_range }: &DiagnosticInfo<'_>, - decorate: impl FnOnce(&mut DiagnosticBuilder<'_, ()>, Option, MarkdownLinkRange), + decorate: impl FnOnce(&mut Diag<'_, ()>, Option, MarkdownLinkRange), ) { let Some(hir_id) = DocContext::as_local_hir_id(tcx, item.item_id) else { // If non-local, no need to check anything. @@ -2125,7 +2124,7 @@ fn ambiguity_error( /// disambiguator. fn suggest_disambiguator( res: Res, - diag: &mut DiagnosticBuilder<'_, ()>, + diag: &mut Diag<'_, ()>, path_str: &str, link_range: MarkdownLinkRange, sp: Option, diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index f3537873dc2ef..c6571e72fc558 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -3,7 +3,7 @@ use rustc_data_structures::sync::{Lock, Lrc}; use rustc_errors::{ emitter::Emitter, translation::{to_fluent_args, Translate}, - Applicability, DiagCtxt, Diagnostic, LazyFallbackBundle, + Applicability, DiagCtxt, DiagInner, LazyFallbackBundle, }; use rustc_parse::parse_stream_from_source_str; use rustc_resolve::rustdoc::source_span_for_markdown_range; @@ -156,7 +156,7 @@ impl Translate for BufferEmitter { } impl Emitter for BufferEmitter { - fn emit_diagnostic(&mut self, diag: Diagnostic) { + fn emit_diagnostic(&mut self, diag: DiagInner) { let mut buffer = self.buffer.borrow_mut(); let fluent_args = to_fluent_args(diag.args.iter()); diff --git a/src/librustdoc/passes/lint/unescaped_backticks.rs b/src/librustdoc/passes/lint/unescaped_backticks.rs index dbbf39362e316..4ea926cb79aab 100644 --- a/src/librustdoc/passes/lint/unescaped_backticks.rs +++ b/src/librustdoc/passes/lint/unescaped_backticks.rs @@ -4,7 +4,7 @@ use crate::clean::Item; use crate::core::DocContext; use crate::html::markdown::main_body_opts; use pulldown_cmark::{BrokenLink, Event, Parser}; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_lint_defs::Applicability; use rustc_resolve::rustdoc::source_span_for_markdown_range; use std::ops::Range; @@ -368,7 +368,7 @@ fn suggest_insertion( cx: &DocContext<'_>, item: &Item, dox: &str, - lint: &mut DiagnosticBuilder<'_, ()>, + lint: &mut Diag<'_, ()>, insert_index: usize, suggestion: char, message: &'static str, diff --git a/src/tools/cargo b/src/tools/cargo index 194a60b2952bd..8964c8ccff6e4 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 194a60b2952bd5d12ba15dd2577a97eed7d3c587 +Subproject commit 8964c8ccff6e420e2a38b8696d178d69fab84d9d diff --git a/src/tools/clippy/.github/driver.sh b/src/tools/clippy/.github/driver.sh index 40a2aad0f5379..11fd6b5c79ed8 100755 --- a/src/tools/clippy/.github/driver.sh +++ b/src/tools/clippy/.github/driver.sh @@ -32,7 +32,7 @@ test "$sysroot" = $desired_sysroot ) # Check that the --sysroot argument is only passed once via arg_file.txt (SYSROOT is ignored) -( +( echo "fn main() {}" > target/driver_test.rs echo "--sysroot="$(./target/debug/clippy-driver --print sysroot)"" > arg_file.txt echo "--verbose" >> arg_file.txt @@ -45,7 +45,7 @@ unset CARGO_MANIFEST_DIR # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 # FIXME: How to match the clippy invocation in compile-test.rs? ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2>double_neg.stderr && exit 1 -sed -e "s,tests/ui,\$DIR," -e "/= help: for/d" double_neg.stderr > normalized.stderr +sed -e "/= help: for/d" double_neg.stderr > normalized.stderr diff -u normalized.stderr tests/ui/double_neg.stderr # make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same diff --git a/src/tools/clippy/CHANGELOG.md b/src/tools/clippy/CHANGELOG.md index 9b853567219c9..f0b01742deb05 100644 --- a/src/tools/clippy/CHANGELOG.md +++ b/src/tools/clippy/CHANGELOG.md @@ -5125,6 +5125,7 @@ Released 2018-09-13 [`default_trait_access`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_trait_access [`default_union_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_union_representation [`deprecated_cfg_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr +[`deprecated_clippy_cfg_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_clippy_cfg_attr [`deprecated_semver`]: https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_semver [`deref_addrof`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_addrof [`deref_by_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#deref_by_slicing @@ -5157,6 +5158,7 @@ Released 2018-09-13 [`duration_subsec`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_subsec [`eager_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#eager_transmute [`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else +[`empty_docs`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_docs [`empty_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drop [`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum [`empty_enum_variants_with_brackets`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum_variants_with_brackets @@ -5429,6 +5431,7 @@ Released 2018-09-13 [`modulo_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_arithmetic [`modulo_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#modulo_one [`multi_assignments`]: https://rust-lang.github.io/rust-clippy/master/index.html#multi_assignments +[`multiple_bound_locations`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_bound_locations [`multiple_crate_versions`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions [`multiple_inherent_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_inherent_impl [`multiple_unsafe_ops_per_block`]: https://rust-lang.github.io/rust-clippy/master/index.html#multiple_unsafe_ops_per_block @@ -5725,10 +5728,12 @@ Released 2018-09-13 [`unknown_clippy_lints`]: https://rust-lang.github.io/rust-clippy/master/index.html#unknown_clippy_lints [`unnecessary_box_returns`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_box_returns [`unnecessary_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast +[`unnecessary_clippy_cfg`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_clippy_cfg [`unnecessary_fallible_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fallible_conversions [`unnecessary_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map [`unnecessary_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_find_map [`unnecessary_fold`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fold +[`unnecessary_get_then_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check [`unnecessary_join`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_join [`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations [`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap diff --git a/src/tools/clippy/Cargo.toml b/src/tools/clippy/Cargo.toml index 321424880d1e2..5d1d0ce2c42fb 100644 --- a/src/tools/clippy/Cargo.toml +++ b/src/tools/clippy/Cargo.toml @@ -27,17 +27,17 @@ rustc_tools_util = "0.3.0" tempfile = { version = "3.2", optional = true } termize = "0.1" color-print = "0.3.4" -anstream = "0.5.0" +anstream = "0.6.0" [dev-dependencies] -ui_test = "0.21.2" +ui_test = "0.22.2" tester = "0.9" regex = "1.5" toml = "0.7.3" walkdir = "2.3" # This is used by the `collect-metadata` alias. filetime = "0.2" -itertools = "0.11" +itertools = "0.12" # UI test dependencies clippy_utils = { path = "clippy_utils" } diff --git a/src/tools/clippy/book/src/configuration.md b/src/tools/clippy/book/src/configuration.md index e8274bc4575d0..9eb067abd91ec 100644 --- a/src/tools/clippy/book/src/configuration.md +++ b/src/tools/clippy/book/src/configuration.md @@ -33,26 +33,29 @@ disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"] To deactivate the "for further information visit *lint-link*" message you can define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable. -### Allowing/denying lints +### Allowing/Denying Lints -You can add options to your code to `allow`/`warn`/`deny` Clippy lints: +#### Attributes in Code -* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`) +You can add attributes to your code to `allow`/`warn`/`deny` Clippy lints: -* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`, - `#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive lints prone to false - positives. +* the whole set of `warn`-by-default lints using the `clippy` lint group (`#![allow(clippy::all)]`) + +* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![warn(clippy::all, clippy::pedantic)]`. Note + that `clippy::pedantic` contains some very aggressive lints prone to false positives. * only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.) * `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc. Note: `allow` means to suppress the lint for your code. With `warn` the lint will only emit a warning, while with `deny` -the lint will emit an error, when triggering for your code. An error causes clippy to exit with an error code, so is -useful in scripts like CI/CD. +the lint will emit an error, when triggering for your code. An error causes Clippy to exit with an error code, so is +most useful in scripts used in CI/CD. + +#### Command Line Flags -If you do not want to include your lint levels in your code, you can globally enable/disable lints by passing extra -flags to Clippy during the run: +If you do not want to include your lint levels in the code, you can globally enable/disable lints by passing extra flags +to Clippy during the run: To allow `lint_name`, run @@ -66,19 +69,33 @@ And to warn on `lint_name`, run cargo clippy -- -W clippy::lint_name ``` -This also works with lint groups. For example, you can run Clippy with warnings for all lints enabled: +This also works with lint groups. For example, you can run Clippy with warnings for all pedantic lints enabled: ```terminal cargo clippy -- -W clippy::pedantic ``` -If you care only about a single lint, you can allow all others and then explicitly warn on the lint(s) you are +If you care only about a certain lints, you can allow all others and then explicitly warn on the lints you are interested in: ```terminal cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::... ``` +#### Lints Section in `Cargo.toml` + +Finally, lints can be allowed/denied using [the lints +section](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-lints-section)) in the `Cargo.toml` file: + +To deny `clippy::enum_glob_use`, put the following in the `Cargo.toml`: + +```toml +[lints.clippy] +enum_glob_use = "deny" +``` + +For more details and options, refer to the Cargo documentation. + ### Specifying the minimum supported Rust version Projects that intend to support old versions of Rust can disable lints pertaining to newer features by specifying the @@ -113,17 +130,14 @@ found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv) Very rarely, you may wish to prevent Clippy from evaluating certain sections of code entirely. You can do this with [conditional compilation](https://doc.rust-lang.org/reference/conditional-compilation.html) by checking that the -`cargo-clippy` feature is not set. You may need to provide a stub so that the code compiles: +`clippy` cfg is not set. You may need to provide a stub so that the code compiles: ```rust -#[cfg(not(feature = "cargo-clippy"))] +#[cfg(not(clippy)] include!(concat!(env!("OUT_DIR"), "/my_big_function-generated.rs")); -#[cfg(feature = "cargo-clippy")] +#[cfg(clippy)] fn my_big_function(_input: &str) -> Option { None } ``` - -This feature is not actually part of your crate, so specifying `--all-features` to other tools, e.g. `cargo test ---all-features`, will not disable it. diff --git a/src/tools/clippy/book/src/development/emitting_lints.md b/src/tools/clippy/book/src/development/emitting_lints.md index a12f6aa91b307..d70f4fc17ebf0 100644 --- a/src/tools/clippy/book/src/development/emitting_lints.md +++ b/src/tools/clippy/book/src/development/emitting_lints.md @@ -82,7 +82,7 @@ The output looks something like this (from the example earlier): ```text error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:37:14 + --> tests/ui/range_plus_minus_one.rs:37:14 | LL | for _ in 1..1 + 1 {} | ^^^^^^^^ help: use: `1..=1` @@ -135,14 +135,14 @@ Examples: ```text error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:10:5 + --> tests/ui/drop_forget_ref.rs:10:5 | 10 | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::forget-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:10:12 + --> tests/ui/drop_forget_ref.rs:10:12 | 10 | forget(&SomeStruct); | ^^^^^^^^^^^ @@ -158,7 +158,7 @@ Example: ```text error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:6:25 + --> tests/ui/zero_div_zero.rs:6:25 | 6 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ @@ -176,7 +176,7 @@ Example: ```text error: This `.fold` can be more succinctly expressed as `.any` ---> $DIR/methods.rs:390:13 +--> tests/ui/methods.rs:390:13 | 390 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` diff --git a/src/tools/clippy/book/src/development/writing_tests.md b/src/tools/clippy/book/src/development/writing_tests.md index 8937e0d8e9469..39a5ad9668851 100644 --- a/src/tools/clippy/book/src/development/writing_tests.md +++ b/src/tools/clippy/book/src/development/writing_tests.md @@ -97,19 +97,19 @@ failures: ---- compile_test stdout ---- normalized stderr: error: function called "foo" - --> $DIR/foo_functions.rs:6:12 + --> tests/ui/foo_functions.rs:6:12 | LL | pub fn foo(&self) {} | ^^^ | = note: `-D clippy::foo-functions` implied by `-D warnings` error: function called "foo" - --> $DIR/foo_functions.rs:13:8 + --> tests/ui/foo_functions.rs:13:8 | LL | fn foo(&self) {} | ^^^ error: function called "foo" - --> $DIR/foo_functions.rs:19:4 + --> tests/ui/foo_functions.rs:19:4 | LL | fn foo() {} | ^^^ diff --git a/src/tools/clippy/book/src/lint_configuration.md b/src/tools/clippy/book/src/lint_configuration.md index f2357e2b5de92..214a60d3bfdf7 100644 --- a/src/tools/clippy/book/src/lint_configuration.md +++ b/src/tools/clippy/book/src/lint_configuration.md @@ -278,7 +278,7 @@ The minimum number of struct fields for the lints about field names to trigger --- **Affected lints:** -* [`struct_variant_names`](https://rust-lang.github.io/rust-clippy/master/index.html#struct_variant_names) +* [`struct_field_names`](https://rust-lang.github.io/rust-clippy/master/index.html#struct_field_names) ## `enum-variant-size-threshold` diff --git a/src/tools/clippy/clippy_config/src/conf.rs b/src/tools/clippy/clippy_config/src/conf.rs index 9741b94d50413..b781259ad9695 100644 --- a/src/tools/clippy/clippy_config/src/conf.rs +++ b/src/tools/clippy/clippy_config/src/conf.rs @@ -325,7 +325,7 @@ define_Conf! { /// /// The minimum number of enum variants for the lints about variant names to trigger (enum_variant_name_threshold: u64 = 3), - /// Lint: STRUCT_VARIANT_NAMES. + /// Lint: STRUCT_FIELD_NAMES. /// /// The minimum number of struct fields for the lints about field names to trigger (struct_field_name_threshold: u64 = 3), @@ -648,7 +648,7 @@ fn deserialize(file: &SourceFile) -> TryConf { extend_vec_if_indicator_present(&mut conf.conf.doc_valid_idents, DEFAULT_DOC_VALID_IDENTS); extend_vec_if_indicator_present(&mut conf.conf.disallowed_names, DEFAULT_DISALLOWED_NAMES); // TODO: THIS SHOULD BE TESTED, this comment will be gone soon - if conf.conf.allowed_idents_below_min_chars.contains(&"..".to_owned()) { + if conf.conf.allowed_idents_below_min_chars.contains("..") { conf.conf .allowed_idents_below_min_chars .extend(DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS.iter().map(ToString::to_string)); diff --git a/src/tools/clippy/clippy_config/src/lib.rs b/src/tools/clippy/clippy_config/src/lib.rs index 5449feed090a9..3d5002f1780ae 100644 --- a/src/tools/clippy/clippy_config/src/lib.rs +++ b/src/tools/clippy/clippy_config/src/lib.rs @@ -6,7 +6,6 @@ clippy::missing_panics_doc, rustc::diagnostic_outside_of_impl, rustc::untranslatable_diagnostic, - rustc::untranslatable_diagnostic_trivial, )] extern crate rustc_ast; diff --git a/src/tools/clippy/clippy_dev/Cargo.toml b/src/tools/clippy/clippy_dev/Cargo.toml index 5ec67554e7d89..42a953039b1c0 100644 --- a/src/tools/clippy/clippy_dev/Cargo.toml +++ b/src/tools/clippy/clippy_dev/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" aho-corasick = "1.0" clap = "4.1.4" indoc = "1.0" -itertools = "0.11" +itertools = "0.12" opener = "0.6" shell-escape = "0.1" walkdir = "2.3" diff --git a/src/tools/clippy/clippy_lints/Cargo.toml b/src/tools/clippy/clippy_lints/Cargo.toml index 6e6e315bb6561..6ae089b3e0321 100644 --- a/src/tools/clippy/clippy_lints/Cargo.toml +++ b/src/tools/clippy/clippy_lints/Cargo.toml @@ -14,7 +14,7 @@ cargo_metadata = "0.18" clippy_config = { path = "../clippy_config" } clippy_utils = { path = "../clippy_utils" } declare_clippy_lint = { path = "../declare_clippy_lint" } -itertools = "0.11" +itertools = "0.12" quine-mc_cluskey = "0.2" regex-syntax = "0.8" serde = { version = "1.0", features = ["derive"] } diff --git a/src/tools/clippy/clippy_lints/src/asm_syntax.rs b/src/tools/clippy/clippy_lints/src/asm_syntax.rs index feb6437ee26ac..c2fa56e136031 100644 --- a/src/tools/clippy/clippy_lints/src/asm_syntax.rs +++ b/src/tools/clippy/clippy_lints/src/asm_syntax.rs @@ -2,8 +2,11 @@ use std::fmt; use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions}; -use rustc_lint::{EarlyContext, EarlyLintPass, Lint}; +use rustc_ast::{InlineAsm, Item, ItemKind}; +use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext}; use rustc_session::declare_lint_pass; +use rustc_span::Span; +use rustc_target::asm::InlineAsmArch; #[derive(Clone, Copy, PartialEq, Eq)] enum AsmStyle { @@ -31,8 +34,14 @@ impl std::ops::Not for AsmStyle { } } -fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr, check_for: AsmStyle) { - if let ExprKind::InlineAsm(ref inline_asm) = expr.kind { +fn check_asm_syntax( + lint: &'static Lint, + cx: &EarlyContext<'_>, + inline_asm: &InlineAsm, + span: Span, + check_for: AsmStyle, +) { + if matches!(cx.sess().asm_arch, Some(InlineAsmArch::X86 | InlineAsmArch::X86_64)) { let style = if inline_asm.options.contains(InlineAsmOptions::ATT_SYNTAX) { AsmStyle::Att } else { @@ -43,7 +52,7 @@ fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr span_lint_and_help( cx, lint, - expr.span, + span, &format!("{style} x86 assembly syntax used"), None, &format!("use {} x86 assembly syntax", !style), @@ -89,7 +98,15 @@ declare_lint_pass!(InlineAsmX86IntelSyntax => [INLINE_ASM_X86_INTEL_SYNTAX]); impl EarlyLintPass for InlineAsmX86IntelSyntax { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { - check_expr_asm_syntax(Self::get_lints()[0], cx, expr, AsmStyle::Intel); + if let ExprKind::InlineAsm(inline_asm) = &expr.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Intel); + } + } + + fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { + if let ItemKind::GlobalAsm(inline_asm) = &item.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Intel); + } } } @@ -130,6 +147,14 @@ declare_lint_pass!(InlineAsmX86AttSyntax => [INLINE_ASM_X86_ATT_SYNTAX]); impl EarlyLintPass for InlineAsmX86AttSyntax { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { - check_expr_asm_syntax(Self::get_lints()[0], cx, expr, AsmStyle::Att); + if let ExprKind::InlineAsm(inline_asm) = &expr.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Att); + } + } + + fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { + if let ItemKind::GlobalAsm(inline_asm) = &item.kind { + check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Att); + } } } diff --git a/src/tools/clippy/clippy_lints/src/attrs.rs b/src/tools/clippy/clippy_lints/src/attrs.rs index da38422874b44..f2937d51340b8 100644 --- a/src/tools/clippy/clippy_lints/src/attrs.rs +++ b/src/tools/clippy/clippy_lints/src/attrs.rs @@ -1,7 +1,9 @@ //! checks for attributes use clippy_config::msrvs::{self, Msrv}; -use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; +use clippy_utils::diagnostics::{ + span_lint, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then, +}; use clippy_utils::is_from_proc_macro; use clippy_utils::macros::{is_panic, macro_backtrace}; use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments}; @@ -433,6 +435,56 @@ declare_clippy_lint! { "prevent from misusing the wrong attr name" } +declare_clippy_lint! { + /// ### What it does + /// Checks for `#[cfg_attr(feature = "cargo-clippy", ...)]` and for + /// `#[cfg(feature = "cargo-clippy")]` and suggests to replace it with + /// `#[cfg_attr(clippy, ...)]` or `#[cfg(clippy)]`. + /// + /// ### Why is this bad? + /// This feature has been deprecated for years and shouldn't be used anymore. + /// + /// ### Example + /// ```no_run + /// #[cfg(feature = "cargo-clippy")] + /// struct Bar; + /// ``` + /// + /// Use instead: + /// ```no_run + /// #[cfg(clippy)] + /// struct Bar; + /// ``` + #[clippy::version = "1.78.0"] + pub DEPRECATED_CLIPPY_CFG_ATTR, + suspicious, + "usage of `cfg(feature = \"cargo-clippy\")` instead of `cfg(clippy)`" +} + +declare_clippy_lint! { + /// ### What it does + /// Checks for `#[cfg_attr(clippy, allow(clippy::lint))]` + /// and suggests to replace it with `#[allow(clippy::lint)]`. + /// + /// ### Why is this bad? + /// There is no reason to put clippy attributes behind a clippy `cfg` as they are not + /// run by anything else than clippy. + /// + /// ### Example + /// ```no_run + /// #![cfg_attr(clippy, allow(clippy::deprecated_cfg_attr))] + /// ``` + /// + /// Use instead: + /// ```no_run + /// #![allow(clippy::deprecated_cfg_attr)] + /// ``` + #[clippy::version = "1.78.0"] + pub UNNECESSARY_CLIPPY_CFG, + suspicious, + "usage of `cfg_attr(clippy, allow(clippy::lint))` instead of `allow(clippy::lint)`" +} + declare_lint_pass!(Attributes => [ ALLOW_ATTRIBUTES_WITHOUT_REASON, INLINE_ALWAYS, @@ -512,6 +564,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes { || is_word(lint, sym::deprecated) || is_word(lint, sym!(unreachable_pub)) || is_word(lint, sym!(unused)) + || is_word(lint, sym!(unused_import_braces)) || extract_clippy_lint(lint).map_or(false, |s| { matches!( s.as_str(), @@ -794,6 +847,8 @@ impl_lint_pass!(EarlyAttributes => [ EMPTY_LINE_AFTER_DOC_COMMENTS, NON_MINIMAL_CFG, MAYBE_MISUSED_CFG, + DEPRECATED_CLIPPY_CFG_ATTR, + UNNECESSARY_CLIPPY_CFG, ]); impl EarlyLintPass for EarlyAttributes { @@ -803,6 +858,7 @@ impl EarlyLintPass for EarlyAttributes { fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) { check_deprecated_cfg_attr(cx, attr, &self.msrv); + check_deprecated_cfg(cx, attr); check_mismatched_target_os(cx, attr); check_minimal_cfg_condition(cx, attr); check_misused_cfg(cx, attr); @@ -857,39 +913,146 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It } } +fn check_cargo_clippy_attr(cx: &EarlyContext<'_>, item: &rustc_ast::MetaItem) { + if item.has_name(sym::feature) && item.value_str().is_some_and(|v| v.as_str() == "cargo-clippy") { + span_lint_and_sugg( + cx, + DEPRECATED_CLIPPY_CFG_ATTR, + item.span, + "`feature = \"cargo-clippy\"` was replaced by `clippy`", + "replace with", + "clippy".to_string(), + Applicability::MachineApplicable, + ); + } +} + +fn check_deprecated_cfg_recursively(cx: &EarlyContext<'_>, attr: &rustc_ast::MetaItem) { + if let Some(ident) = attr.ident() { + if ["any", "all", "not"].contains(&ident.name.as_str()) { + let Some(list) = attr.meta_item_list() else { return }; + for item in list.iter().filter_map(|item| item.meta_item()) { + check_deprecated_cfg_recursively(cx, item); + } + } else { + check_cargo_clippy_attr(cx, attr); + } + } +} + +fn check_deprecated_cfg(cx: &EarlyContext<'_>, attr: &Attribute) { + if attr.has_name(sym::cfg) + && let Some(list) = attr.meta_item_list() + { + for item in list.iter().filter_map(|item| item.meta_item()) { + check_deprecated_cfg_recursively(cx, item); + } + } +} + fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute, msrv: &Msrv) { - if msrv.meets(msrvs::TOOL_ATTRIBUTES) - // check cfg_attr - && attr.has_name(sym::cfg_attr) + // check cfg_attr + if attr.has_name(sym::cfg_attr) && let Some(items) = attr.meta_item_list() && items.len() == 2 - // check for `rustfmt` && let Some(feature_item) = items[0].meta_item() - && feature_item.has_name(sym::rustfmt) - // check for `rustfmt_skip` and `rustfmt::skip` - && let Some(skip_item) = &items[1].meta_item() - && (skip_item.has_name(sym!(rustfmt_skip)) - || skip_item - .path - .segments - .last() - .expect("empty path in attribute") - .ident - .name - == sym::skip) - // Only lint outer attributes, because custom inner attributes are unstable - // Tracking issue: https://github.com/rust-lang/rust/issues/54726 - && attr.style == AttrStyle::Outer { - span_lint_and_sugg( - cx, - DEPRECATED_CFG_ATTR, - attr.span, - "`cfg_attr` is deprecated for rustfmt and got replaced by tool attributes", - "use", - "#[rustfmt::skip]".to_string(), - Applicability::MachineApplicable, - ); + // check for `rustfmt` + if feature_item.has_name(sym::rustfmt) + && msrv.meets(msrvs::TOOL_ATTRIBUTES) + // check for `rustfmt_skip` and `rustfmt::skip` + && let Some(skip_item) = &items[1].meta_item() + && (skip_item.has_name(sym!(rustfmt_skip)) + || skip_item + .path + .segments + .last() + .expect("empty path in attribute") + .ident + .name + == sym::skip) + // Only lint outer attributes, because custom inner attributes are unstable + // Tracking issue: https://github.com/rust-lang/rust/issues/54726 + && attr.style == AttrStyle::Outer + { + span_lint_and_sugg( + cx, + DEPRECATED_CFG_ATTR, + attr.span, + "`cfg_attr` is deprecated for rustfmt and got replaced by tool attributes", + "use", + "#[rustfmt::skip]".to_string(), + Applicability::MachineApplicable, + ); + } else { + check_deprecated_cfg_recursively(cx, feature_item); + if let Some(behind_cfg_attr) = items[1].meta_item() { + check_clippy_cfg_attr(cx, feature_item, behind_cfg_attr, attr); + } + } + } +} + +fn check_clippy_cfg_attr( + cx: &EarlyContext<'_>, + cfg_attr: &rustc_ast::MetaItem, + behind_cfg_attr: &rustc_ast::MetaItem, + attr: &Attribute, +) { + if cfg_attr.has_name(sym::clippy) + && let Some(ident) = behind_cfg_attr.ident() + && Level::from_symbol(ident.name, Some(attr.id)).is_some() + && let Some(items) = behind_cfg_attr.meta_item_list() + { + let nb_items = items.len(); + let mut clippy_lints = Vec::with_capacity(items.len()); + for item in items { + if let Some(meta_item) = item.meta_item() + && let [part1, _] = meta_item.path.segments.as_slice() + && part1.ident.name == sym::clippy + { + clippy_lints.push(item.span()); + } + } + if clippy_lints.is_empty() { + return; + } + if nb_items == clippy_lints.len() { + if let Some(snippet) = snippet_opt(cx, behind_cfg_attr.span) { + span_lint_and_sugg( + cx, + UNNECESSARY_CLIPPY_CFG, + attr.span, + "no need to put clippy lints behind a `clippy` cfg", + "replace with", + format!( + "#{}[{}]", + if attr.style == AttrStyle::Inner { "!" } else { "" }, + snippet + ), + Applicability::MachineApplicable, + ); + } + } else { + let snippet = clippy_lints + .iter() + .filter_map(|sp| snippet_opt(cx, *sp)) + .collect::>() + .join(","); + span_lint_and_note( + cx, + UNNECESSARY_CLIPPY_CFG, + clippy_lints, + "no need to put clippy lints behind a `clippy` cfg", + None, + &format!( + "write instead: `#{}[{}({})]`", + if attr.style == AttrStyle::Inner { "!" } else { "" }, + ident.name, + snippet + ), + ); + } } } diff --git a/src/tools/clippy/clippy_lints/src/blocks_in_conditions.rs b/src/tools/clippy/clippy_lints/src/blocks_in_conditions.rs index ff4dffd06079f..2eb0dac974258 100644 --- a/src/tools/clippy/clippy_lints/src/blocks_in_conditions.rs +++ b/src/tools/clippy/clippy_lints/src/blocks_in_conditions.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg}; use clippy_utils::source::snippet_block_with_applicability; use clippy_utils::ty::implements_trait; use clippy_utils::visitors::{for_each_expr, Descend}; -use clippy_utils::{get_parent_expr, higher}; +use clippy_utils::{get_parent_expr, higher, is_from_proc_macro}; use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::{BlockCheckMode, Expr, ExprKind, MatchSource}; @@ -13,7 +13,7 @@ use rustc_span::sym; declare_clippy_lint! { /// ### What it does - /// Checks for `if` conditions that use blocks containing an + /// Checks for `if` and `match` conditions that use blocks containing an /// expression, statements or conditions that use closures with blocks. /// /// ### Why is this bad? @@ -25,6 +25,11 @@ declare_clippy_lint! { /// if { true } { /* ... */ } /// /// if { let x = somefunc(); x } { /* ... */ } + /// + /// match { let e = somefunc(); e } { + /// // ... + /// # _ => {} + /// } /// ``` /// /// Use instead: @@ -34,6 +39,12 @@ declare_clippy_lint! { /// /// let res = { let x = somefunc(); x }; /// if res { /* ... */ } + /// + /// let res = { let e = somefunc(); e }; + /// match res { + /// // ... + /// # _ => {} + /// } /// ``` #[clippy::version = "1.45.0"] pub BLOCKS_IN_CONDITIONS, @@ -94,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions { } } else { let span = block.expr.as_ref().map_or_else(|| block.stmts[0].span, |e| e.span); - if span.from_expansion() || expr.span.from_expansion() { + if span.from_expansion() || expr.span.from_expansion() || is_from_proc_macro(cx, cond) { return; } // move block higher diff --git a/src/tools/clippy/clippy_lints/src/booleans.rs b/src/tools/clippy/clippy_lints/src/booleans.rs index 2d1c250ace905..0d66f2d644d98 100644 --- a/src/tools/clippy/clippy_lints/src/booleans.rs +++ b/src/tools/clippy/clippy_lints/src/booleans.rs @@ -85,7 +85,117 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool { ) { NonminimalBoolVisitor { cx }.visit_body(body); } + + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { + match expr.kind { + ExprKind::Unary(UnOp::Not, sub) => check_inverted_condition(cx, expr.span, sub), + // This check the case where an element in a boolean comparison is inverted, like: + // + // ``` + // let a = true; + // !a == false; + // ``` + ExprKind::Binary(op, left, right) if matches!(op.node, BinOpKind::Eq | BinOpKind::Ne) => { + check_inverted_bool_in_condition(cx, expr.span, op.node, left, right); + }, + _ => {}, + } + } +} + +fn inverted_bin_op_eq_str(op: BinOpKind) -> Option<&'static str> { + match op { + BinOpKind::Eq => Some("!="), + BinOpKind::Ne => Some("=="), + _ => None, + } +} + +fn bin_op_eq_str(op: BinOpKind) -> Option<&'static str> { + match op { + BinOpKind::Eq => Some("=="), + BinOpKind::Ne => Some("!="), + _ => None, + } +} + +fn check_inverted_condition(cx: &LateContext<'_>, expr_span: Span, sub_expr: &Expr<'_>) { + if !expr_span.from_expansion() + && let ExprKind::Binary(op, left, right) = sub_expr.kind + && let Some(left) = snippet_opt(cx, left.span) + && let Some(right) = snippet_opt(cx, right.span) + { + let Some(op) = inverted_bin_op_eq_str(op.node) else { + return; + }; + span_lint_and_sugg( + cx, + NONMINIMAL_BOOL, + expr_span, + "this boolean expression can be simplified", + "try", + format!("{left} {op} {right}",), + Applicability::MachineApplicable, + ); + } +} + +fn check_inverted_bool_in_condition( + cx: &LateContext<'_>, + expr_span: Span, + op: BinOpKind, + left: &Expr<'_>, + right: &Expr<'_>, +) { + if expr_span.from_expansion() + && (!cx.typeck_results().node_types()[left.hir_id].is_bool() + || !cx.typeck_results().node_types()[right.hir_id].is_bool()) + { + return; + } + + let suggestion = match (left.kind, right.kind) { + (ExprKind::Unary(UnOp::Not, left_sub), ExprKind::Unary(UnOp::Not, right_sub)) => { + let Some(left) = snippet_opt(cx, left_sub.span) else { + return; + }; + let Some(right) = snippet_opt(cx, right_sub.span) else { + return; + }; + let Some(op) = bin_op_eq_str(op) else { return }; + format!("{left} {op} {right}") + }, + (ExprKind::Unary(UnOp::Not, left_sub), _) => { + let Some(left) = snippet_opt(cx, left_sub.span) else { + return; + }; + let Some(right) = snippet_opt(cx, right.span) else { + return; + }; + let Some(op) = inverted_bin_op_eq_str(op) else { return }; + format!("{left} {op} {right}") + }, + (_, ExprKind::Unary(UnOp::Not, right_sub)) => { + let Some(left) = snippet_opt(cx, left.span) else { return }; + let Some(right) = snippet_opt(cx, right_sub.span) else { + return; + }; + let Some(op) = inverted_bin_op_eq_str(op) else { return }; + format!("{left} {op} {right}") + }, + _ => return, + }; + span_lint_and_sugg( + cx, + NONMINIMAL_BOOL, + expr_span, + "this boolean expression can be simplified", + "try", + suggestion, + Applicability::MachineApplicable, + ); } + struct NonminimalBoolVisitor<'a, 'tcx> { cx: &'a LateContext<'tcx>, } diff --git a/src/tools/clippy/clippy_lints/src/box_default.rs b/src/tools/clippy/clippy_lints/src/box_default.rs index ef12fe344e409..779ae03c4640b 100644 --- a/src/tools/clippy/clippy_lints/src/box_default.rs +++ b/src/tools/clippy/clippy_lints/src/box_default.rs @@ -1,11 +1,12 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::macros::macro_backtrace; +use clippy_utils::source::snippet_opt; use clippy_utils::ty::expr_sig; -use clippy_utils::{get_parent_node, is_default_equivalent, path_def_id}; +use clippy_utils::{is_default_equivalent, path_def_id}; use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::intravisit::{walk_ty, Visitor}; -use rustc_hir::{Block, Expr, ExprKind, Local, Node, QPath, TyKind}; +use rustc_hir::{Block, Expr, ExprKind, Local, Node, QPath, Ty, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty::print::with_forced_trimmed_paths; @@ -41,13 +42,24 @@ declare_lint_pass!(BoxDefault => [BOX_DEFAULT]); impl LateLintPass<'_> for BoxDefault { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { + // If the expression is a call (`Box::new(...)`) if let ExprKind::Call(box_new, [arg]) = expr.kind + // And call is of the form `::something` + // Here, it would be `::new` && let ExprKind::Path(QPath::TypeRelative(ty, seg)) = box_new.kind - && let ExprKind::Call(arg_path, ..) = arg.kind - && !in_external_macro(cx.sess(), expr.span) - && (expr.span.eq_ctxt(arg.span) || is_local_vec_expn(cx, arg, expr)) + // And that method is `new` && seg.ident.name == sym::new + // And the call is that of a `Box` method && path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box()) + // And the single argument to the call is another function call + // This is the `T::default()` of `Box::new(T::default())` + && let ExprKind::Call(arg_path, inner_call_args) = arg.kind + // And we are not in a foreign crate's macro + && !in_external_macro(cx.sess(), expr.span) + // And the argument expression has the same context as the outer call expression + // or that we are inside a `vec!` macro expansion + && (expr.span.eq_ctxt(arg.span) || is_local_vec_expn(cx, arg, expr)) + // And the argument is equivalent to `Default::default()` && is_default_equivalent(cx, arg) { span_lint_and_sugg( @@ -59,7 +71,17 @@ impl LateLintPass<'_> for BoxDefault { if is_plain_default(cx, arg_path) || given_type(cx, expr) { "Box::default()".into() } else if let Some(arg_ty) = cx.typeck_results().expr_ty(arg).make_suggestable(cx.tcx, true) { - with_forced_trimmed_paths!(format!("Box::<{arg_ty}>::default()")) + // Check if we can copy from the source expression in the replacement. + // We need the call to have no argument (see `explicit_default_type`). + if inner_call_args.is_empty() + && let Some(ty) = explicit_default_type(arg_path) + && let Some(s) = snippet_opt(cx, ty.span) + { + format!("Box::<{s}>::default()") + } else { + // Otherwise, use the inferred type's formatting. + with_forced_trimmed_paths!(format!("Box::<{arg_ty}>::default()")) + } } else { return; }, @@ -81,6 +103,20 @@ fn is_plain_default(cx: &LateContext<'_>, arg_path: &Expr<'_>) -> bool { } } +// Checks whether the call is of the form `A::B::f()`. Returns `A::B` if it is. +// +// In the event we have this kind of construct, it's easy to use `A::B` as a replacement in the +// quickfix. `f` must however have no parameter. Should `f` have some, then some of the type of +// `A::B` may be inferred from the arguments. This would be the case for `Vec::from([0; false])`, +// where the argument to `from` allows inferring this is a `Vec` +fn explicit_default_type<'a>(arg_path: &'a Expr<'_>) -> Option<&'a Ty<'a>> { + if let ExprKind::Path(QPath::TypeRelative(ty, _)) = &arg_path.kind { + Some(ty) + } else { + None + } +} + fn is_local_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>, ref_expr: &Expr<'_>) -> bool { macro_backtrace(expr.span).next().map_or(false, |call| { cx.tcx.is_diagnostic_item(sym::vec_macro, call.def_id) && call.span.eq_ctxt(ref_expr.span) @@ -100,26 +136,23 @@ impl<'tcx> Visitor<'tcx> for InferVisitor { } fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { - match get_parent_node(cx.tcx, expr.hir_id) { - Some(Node::Local(Local { ty: Some(ty), .. })) => { + match cx.tcx.parent_hir_node(expr.hir_id) { + Node::Local(Local { ty: Some(ty), .. }) => { let mut v = InferVisitor::default(); v.visit_ty(ty); !v.0 }, - Some( - Node::Expr(Expr { + Node::Expr(Expr { + kind: ExprKind::Call(path, args), + .. + }) + | Node::Block(Block { + expr: Some(Expr { kind: ExprKind::Call(path, args), .. - }) - | Node::Block(Block { - expr: - Some(Expr { - kind: ExprKind::Call(path, args), - .. - }), - .. }), - ) => { + .. + }) => { if let Some(index) = args.iter().position(|arg| arg.hir_id == expr.hir_id) && let Some(sig) = expr_sig(cx, path) && let Some(input) = sig.input(index) diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs b/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs index 1543ae8039968..2c0a3d4829608 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs @@ -4,7 +4,7 @@ use clippy_utils::expr_or_init; use clippy_utils::source::snippet; use clippy_utils::sugg::Sugg; use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize}; -use rustc_errors::{Applicability, DiagnosticBuilder, SuggestionStyle}; +use rustc_errors::{Applicability, Diag, SuggestionStyle}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; @@ -131,8 +131,7 @@ pub(super) fn check( let cast_from_ptr_size = def.repr().int.map_or(true, |ty| matches!(ty, IntegerType::Pointer(_),)); let suffix = match (cast_from_ptr_size, is_isize_or_usize(cast_to)) { - (false, false) if from_nbits > to_nbits => "", - (true, false) if from_nbits > to_nbits => "", + (_, false) if from_nbits > to_nbits => "", (false, true) if from_nbits > 64 => "", (false, true) if from_nbits > 32 => " on targets with 32-bit wide pointers", _ => return, @@ -177,7 +176,7 @@ fn offer_suggestion( expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to_span: Span, - diag: &mut DiagnosticBuilder<'_, ()>, + diag: &mut Diag<'_, ()>, ) { let cast_to_snip = snippet(cx, cast_to_span, ".."); let suggestion = if cast_to_snip == "_" { diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs b/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs index 1df5a25f674d7..8fd95d9654cf0 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_sign_loss.rs @@ -1,15 +1,47 @@ +use std::convert::Infallible; +use std::ops::ControlFlow; + use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint; -use clippy_utils::{clip, method_chain_args, sext}; +use clippy_utils::visitors::{for_each_expr, Descend}; +use clippy_utils::{method_chain_args, sext}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::LateContext; -use rustc_middle::ty::{self, Ty, UintTy}; +use rustc_middle::ty::{self, Ty}; use super::CAST_SIGN_LOSS; -const METHODS_RET_POSITIVE: &[&str] = &["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"]; +/// A list of methods that can never return a negative value. +/// Includes methods that panic rather than returning a negative value. +/// +/// Methods that can overflow and return a negative value must not be included in this list, +/// because casting their return values can still result in sign loss. +const METHODS_RET_POSITIVE: &[&str] = &[ + "checked_abs", + "saturating_abs", + "isqrt", + "checked_isqrt", + "rem_euclid", + "checked_rem_euclid", + "wrapping_rem_euclid", +]; + +/// A list of methods that act like `pow()`. See `pow_call_result_sign()` for details. +/// +/// Methods that can overflow and return a negative value must not be included in this list, +/// because casting their return values can still result in sign loss. +const METHODS_POW: &[&str] = &["pow", "saturating_pow", "checked_pow"]; -pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { +/// A list of methods that act like `unwrap()`, and don't change the sign of the inner value. +const METHODS_UNWRAP: &[&str] = &["unwrap", "unwrap_unchecked", "expect", "into_ok"]; + +pub(super) fn check<'cx>( + cx: &LateContext<'cx>, + expr: &Expr<'_>, + cast_op: &Expr<'_>, + cast_from: Ty<'cx>, + cast_to: Ty<'_>, +) { if should_lint(cx, cast_op, cast_from, cast_to) { span_lint( cx, @@ -20,35 +52,27 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_op: &Expr<'_>, c } } -fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) -> bool { +fn should_lint<'cx>(cx: &LateContext<'cx>, cast_op: &Expr<'_>, cast_from: Ty<'cx>, cast_to: Ty<'_>) -> bool { match (cast_from.is_integral(), cast_to.is_integral()) { (true, true) => { if !cast_from.is_signed() || cast_to.is_signed() { return false; } - // Don't lint if `cast_op` is known to be positive. + // Don't lint if `cast_op` is known to be positive, ignoring overflow. if let Sign::ZeroOrPositive = expr_sign(cx, cast_op, cast_from) { return false; } - let (mut uncertain_count, mut negative_count) = (0, 0); - // Peel off possible binary expressions, e.g. x * x * y => [x, x, y] - let Some(exprs) = exprs_with_selected_binop_peeled(cast_op) else { - // Assume cast sign lose if we cannot determine the sign of `cast_op` - return true; - }; - for expr in exprs { - let ty = cx.typeck_results().expr_ty(expr); - match expr_sign(cx, expr, ty) { - Sign::Negative => negative_count += 1, - Sign::Uncertain => uncertain_count += 1, - Sign::ZeroOrPositive => (), - }; + if let Sign::ZeroOrPositive = expr_muldiv_sign(cx, cast_op) { + return false; + } + + if let Sign::ZeroOrPositive = expr_add_sign(cx, cast_op) { + return false; } - // Lint if there are odd number of uncertain or negative results - uncertain_count % 2 == 1 || negative_count % 2 == 1 + true }, (false, true) => !cast_to.is_signed(), @@ -57,7 +81,13 @@ fn should_lint(cx: &LateContext<'_>, cast_op: &Expr<'_>, cast_from: Ty<'_>, cast } } -fn get_const_int_eval(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Option { +fn get_const_signed_int_eval<'cx>( + cx: &LateContext<'cx>, + expr: &Expr<'_>, + ty: impl Into>>, +) -> Option { + let ty = ty.into().unwrap_or_else(|| cx.typeck_results().expr_ty(expr)); + if let Constant::Int(n) = constant(cx, cx.typeck_results(), expr)? && let ty::Int(ity) = *ty.kind() { @@ -66,29 +96,52 @@ fn get_const_int_eval(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Opti None } +fn get_const_unsigned_int_eval<'cx>( + cx: &LateContext<'cx>, + expr: &Expr<'_>, + ty: impl Into>>, +) -> Option { + let ty = ty.into().unwrap_or_else(|| cx.typeck_results().expr_ty(expr)); + + if let Constant::Int(n) = constant(cx, cx.typeck_results(), expr)? + && let ty::Uint(_ity) = *ty.kind() + { + return Some(n); + } + None +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] enum Sign { ZeroOrPositive, Negative, Uncertain, } -fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { +fn expr_sign<'cx>(cx: &LateContext<'cx>, expr: &Expr<'_>, ty: impl Into>>) -> Sign { // Try evaluate this expr first to see if it's positive - if let Some(val) = get_const_int_eval(cx, expr, ty) { + if let Some(val) = get_const_signed_int_eval(cx, expr, ty) { return if val >= 0 { Sign::ZeroOrPositive } else { Sign::Negative }; } + if let Some(_val) = get_const_unsigned_int_eval(cx, expr, None) { + return Sign::ZeroOrPositive; + } + // Calling on methods that always return non-negative values. if let ExprKind::MethodCall(path, caller, args, ..) = expr.kind { let mut method_name = path.ident.name.as_str(); - if method_name == "unwrap" - && let Some(arglist) = method_chain_args(expr, &["unwrap"]) + // Peel unwrap(), expect(), etc. + while let Some(&found_name) = METHODS_UNWRAP.iter().find(|&name| &method_name == name) + && let Some(arglist) = method_chain_args(expr, &[found_name]) && let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind { + // The original type has changed, but we can't use `ty` here anyway, because it has been + // moved. method_name = inner_path.ident.name.as_str(); } - if method_name == "pow" + if METHODS_POW.iter().any(|&name| method_name == name) && let [arg] = args { return pow_call_result_sign(cx, caller, arg); @@ -100,53 +153,182 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign { Sign::Uncertain } -/// Return the sign of the `pow` call's result. +/// Return the sign of the `pow` call's result, ignoring overflow. /// -/// If the caller is a positive number, the result is always positive, -/// If the `power_of` is a even number, the result is always positive as well, -/// Otherwise a [`Sign::Uncertain`] will be returned. -fn pow_call_result_sign(cx: &LateContext<'_>, caller: &Expr<'_>, power_of: &Expr<'_>) -> Sign { - let caller_ty = cx.typeck_results().expr_ty(caller); - if let Some(caller_val) = get_const_int_eval(cx, caller, caller_ty) - && caller_val >= 0 - { - return Sign::ZeroOrPositive; +/// If the base is positive, the result is always positive. +/// If the exponent is a even number, the result is always positive, +/// Otherwise, if the base is negative, and the exponent is an odd number, the result is always +/// negative. +/// +/// Otherwise, returns [`Sign::Uncertain`]. +fn pow_call_result_sign(cx: &LateContext<'_>, base: &Expr<'_>, exponent: &Expr<'_>) -> Sign { + let base_sign = expr_sign(cx, base, None); + + // Rust's integer pow() functions take an unsigned exponent. + let exponent_val = get_const_unsigned_int_eval(cx, exponent, None); + let exponent_is_even = exponent_val.map(|val| val % 2 == 0); + + match (base_sign, exponent_is_even) { + // Non-negative bases always return non-negative results, ignoring overflow. + (Sign::ZeroOrPositive, _) | + // Any base raised to an even exponent is non-negative. + // These both hold even if we don't know the value of the base. + (_, Some(true)) + => Sign::ZeroOrPositive, + + // A negative base raised to an odd exponent is non-negative. + (Sign::Negative, Some(false)) => Sign::Negative, + + // Negative/unknown base to an unknown exponent, or unknown base to an odd exponent. + // Could be negative or positive depending on the actual values. + (Sign::Negative | Sign::Uncertain, None) | + (Sign::Uncertain, Some(false)) => Sign::Uncertain, } +} - if let Some(Constant::Int(n)) = constant(cx, cx.typeck_results(), power_of) - && clip(cx.tcx, n, UintTy::U32) % 2 == 0 - { - return Sign::ZeroOrPositive; +/// Peels binary operators such as [`BinOpKind::Mul`] or [`BinOpKind::Rem`], +/// where the result could always be positive. See [`exprs_with_muldiv_binop_peeled()`] for details. +/// +/// Returns the sign of the list of peeled expressions. +fn expr_muldiv_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign { + let mut negative_count = 0; + + // Peel off possible binary expressions, for example: + // x * x / y => [x, x, y] + // a % b => [a] + let exprs = exprs_with_muldiv_binop_peeled(expr); + for expr in exprs { + match expr_sign(cx, expr, None) { + Sign::Negative => negative_count += 1, + // A mul/div is: + // - uncertain if there are any uncertain values (because they could be negative or positive), + Sign::Uncertain => return Sign::Uncertain, + Sign::ZeroOrPositive => (), + }; } - Sign::Uncertain + // A mul/div is: + // - negative if there are an odd number of negative values, + // - positive or zero otherwise. + if negative_count % 2 == 1 { + Sign::Negative + } else { + Sign::ZeroOrPositive + } +} + +/// Peels binary operators such as [`BinOpKind::Add`], where the result could always be positive. +/// See [`exprs_with_add_binop_peeled()`] for details. +/// +/// Returns the sign of the list of peeled expressions. +fn expr_add_sign(cx: &LateContext<'_>, expr: &Expr<'_>) -> Sign { + let mut negative_count = 0; + let mut positive_count = 0; + + // Peel off possible binary expressions, for example: + // a + b + c => [a, b, c] + let exprs = exprs_with_add_binop_peeled(expr); + for expr in exprs { + match expr_sign(cx, expr, None) { + Sign::Negative => negative_count += 1, + // A sum is: + // - uncertain if there are any uncertain values (because they could be negative or positive), + Sign::Uncertain => return Sign::Uncertain, + Sign::ZeroOrPositive => positive_count += 1, + }; + } + + // A sum is: + // - positive or zero if there are only positive (or zero) values, + // - negative if there are only negative (or zero) values, or + // - uncertain if there are both. + // We could split Zero out into its own variant, but we don't yet. + if negative_count == 0 { + Sign::ZeroOrPositive + } else if positive_count == 0 { + Sign::Negative + } else { + Sign::Uncertain + } } /// Peels binary operators such as [`BinOpKind::Mul`], [`BinOpKind::Div`] or [`BinOpKind::Rem`], -/// which the result could always be positive under certain condition. +/// where the result depends on: +/// - the number of negative values in the entire expression, or +/// - the number of negative values on the left hand side of the expression. +/// Ignores overflow. /// -/// Other operators such as `+`/`-` causing the result's sign hard to determine, which we will -/// return `None` -fn exprs_with_selected_binop_peeled<'a>(expr: &'a Expr<'_>) -> Option>> { - #[inline] - fn collect_operands<'a>(expr: &'a Expr<'a>, operands: &mut Vec<&'a Expr<'a>>) -> Option<()> { - match expr.kind { - ExprKind::Binary(op, lhs, rhs) => { - if matches!(op.node, BinOpKind::Mul | BinOpKind::Div | BinOpKind::Rem) { - collect_operands(lhs, operands); - operands.push(rhs); - } else { - // Things are complicated when there are other binary ops exist, - // abort checking by returning `None` for now. - return None; - } - }, - _ => operands.push(expr), +/// +/// Expressions using other operators are preserved, so we can try to evaluate them later. +fn exprs_with_muldiv_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { + let mut res = vec![]; + + for_each_expr(expr, |sub_expr| -> ControlFlow { + // We don't check for mul/div/rem methods here, but we could. + if let ExprKind::Binary(op, lhs, _rhs) = sub_expr.kind { + if matches!(op.node, BinOpKind::Mul | BinOpKind::Div) { + // For binary operators where both sides contribute to the sign of the result, + // collect all their operands, recursively. This ignores overflow. + ControlFlow::Continue(Descend::Yes) + } else if matches!(op.node, BinOpKind::Rem | BinOpKind::Shr) { + // For binary operators where the left hand side determines the sign of the result, + // only collect that side, recursively. Overflow panics, so this always holds. + // + // Large left shifts turn negatives into zeroes, so we can't use it here. + // + // > Given remainder = dividend % divisor, the remainder will have the same sign as the dividend + // > ... + // > Arithmetic right shift on signed integer types + // https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators + + // We want to descend into the lhs, but skip the rhs. + // That's tricky to do using for_each_expr(), so we just keep the lhs intact. + res.push(lhs); + ControlFlow::Continue(Descend::No) + } else { + // The sign of the result of other binary operators depends on the values of the operands, + // so try to evaluate the expression. + res.push(sub_expr); + ControlFlow::Continue(Descend::No) + } + } else { + // For other expressions, including unary operators and constants, try to evaluate the expression. + res.push(sub_expr); + ControlFlow::Continue(Descend::No) } - Some(()) - } + }); + res +} + +/// Peels binary operators such as [`BinOpKind::Add`], where the result depends on: +/// - all the expressions being positive, or +/// - all the expressions being negative. +/// Ignores overflow. +/// +/// Expressions using other operators are preserved, so we can try to evaluate them later. +fn exprs_with_add_binop_peeled<'e>(expr: &'e Expr<'_>) -> Vec<&'e Expr<'e>> { let mut res = vec![]; - collect_operands(expr, &mut res)?; - Some(res) + + for_each_expr(expr, |sub_expr| -> ControlFlow { + // We don't check for add methods here, but we could. + if let ExprKind::Binary(op, _lhs, _rhs) = sub_expr.kind { + if matches!(op.node, BinOpKind::Add) { + // For binary operators where both sides contribute to the sign of the result, + // collect all their operands, recursively. This ignores overflow. + ControlFlow::Continue(Descend::Yes) + } else { + // The sign of the result of other binary operators depends on the values of the operands, + // so try to evaluate the expression. + res.push(sub_expr); + ControlFlow::Continue(Descend::No) + } + } else { + // For other expressions, including unary operators and constants, try to evaluate the expression. + res.push(sub_expr); + ControlFlow::Continue(Descend::No) + } + }); + + res } diff --git a/src/tools/clippy/clippy_lints/src/casts/ref_as_ptr.rs b/src/tools/clippy/clippy_lints/src/casts/ref_as_ptr.rs index d600d2aec1b5e..9d5a486336d5f 100644 --- a/src/tools/clippy/clippy_lints/src/casts/ref_as_ptr.rs +++ b/src/tools/clippy/clippy_lints/src/casts/ref_as_ptr.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::is_no_std_crate; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sugg::Sugg; +use clippy_utils::{expr_use_ctxt, is_no_std_crate, ExprUseNode}; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability, Ty, TyKind}; use rustc_lint::LateContext; @@ -9,7 +9,12 @@ use rustc_middle::ty::{self, TypeAndMut}; use super::REF_AS_PTR; -pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to_hir_ty: &Ty<'_>) { +pub(super) fn check<'tcx>( + cx: &LateContext<'tcx>, + expr: &'tcx Expr<'_>, + cast_expr: &'tcx Expr<'_>, + cast_to_hir_ty: &Ty<'_>, +) { let (cast_from, cast_to) = ( cx.typeck_results().expr_ty(cast_expr), cx.typeck_results().expr_ty(expr), @@ -17,6 +22,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, if matches!(cast_from.kind(), ty::Ref(..)) && let ty::RawPtr(TypeAndMut { mutbl: to_mutbl, .. }) = cast_to.kind() + && let Some(use_cx) = expr_use_ctxt(cx, expr) + // TODO: only block the lint if `cast_expr` is a temporary + && !matches!(use_cx.node, ExprUseNode::Local(_) | ExprUseNode::ConstStatic(_)) { let core_or_std = if is_no_std_crate(cx) { "core" } else { "std" }; let fn_name = match to_mutbl { diff --git a/src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs b/src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs index b4a23d0d4db41..cc513d46bf4ec 100644 --- a/src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs +++ b/src/tools/clippy/clippy_lints/src/casts/unnecessary_cast.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::numeric_literal::NumericLiteral; use clippy_utils::source::snippet_opt; use clippy_utils::visitors::{for_each_expr, Visitable}; -use clippy_utils::{get_parent_expr, get_parent_node, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; +use clippy_utils::{get_parent_expr, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; use rustc_ast::{LitFloatType, LitIntType, LitKind}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; @@ -264,8 +264,7 @@ fn is_cast_from_ty_alias<'tcx>(cx: &LateContext<'tcx>, expr: impl Visitable<'tcx } // Local usage } else if let Res::Local(hir_id) = res - && let Some(parent) = get_parent_node(cx.tcx, hir_id) - && let Node::Local(l) = parent + && let Node::Local(l) = cx.tcx.parent_hir_node(hir_id) { if let Some(e) = l.init && is_cast_from_ty_alias(cx, e, cast_from) diff --git a/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs b/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs index d0c989cfff304..d820413e11129 100644 --- a/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs +++ b/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item}; use clippy_utils::visitors::for_each_expr_with_closures; -use clippy_utils::{get_enclosing_block, get_parent_node, path_to_local_id}; +use clippy_utils::{get_enclosing_block, path_to_local_id}; use core::ops::ControlFlow; use rustc_hir::{Block, ExprKind, HirId, LangItem, Local, Node, PatKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -94,7 +94,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc // `id` appearing in the left-hand side of an assignment is not a read access: // // id = ...; // Not reading `id`. - if let Some(Node::Expr(parent)) = get_parent_node(cx.tcx, expr.hir_id) + if let Node::Expr(parent) = cx.tcx.parent_hir_node(expr.hir_id) && let ExprKind::Assign(lhs, ..) = parent.kind && path_to_local_id(lhs, id) { @@ -108,7 +108,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc // Only assuming this for "official" methods defined on the type. For methods defined in extension // traits (identified as local, based on the orphan rule), pessimistically assume that they might // have side effects, so consider them a read. - if let Some(Node::Expr(parent)) = get_parent_node(cx.tcx, expr.hir_id) + if let Node::Expr(parent) = cx.tcx.parent_hir_node(expr.hir_id) && let ExprKind::MethodCall(_, receiver, _, _) = parent.kind && path_to_local_id(receiver, id) && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(parent.hir_id) @@ -117,7 +117,7 @@ fn has_no_read_access<'tcx>(cx: &LateContext<'tcx>, id: HirId, block: &'tcx Bloc // The method call is a statement, so the return value is not used. That's not a read access: // // id.foo(args); - if let Some(Node::Stmt(..)) = get_parent_node(cx.tcx, parent.hir_id) { + if let Node::Stmt(..) = cx.tcx.parent_hir_node(parent.hir_id) { return ControlFlow::Continue(()); } diff --git a/src/tools/clippy/clippy_lints/src/declared_lints.rs b/src/tools/clippy/clippy_lints/src/declared_lints.rs index 0a5baabd973ea..fb3ae2457e3c4 100644 --- a/src/tools/clippy/clippy_lints/src/declared_lints.rs +++ b/src/tools/clippy/clippy_lints/src/declared_lints.rs @@ -51,6 +51,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::attrs::ALLOW_ATTRIBUTES_WITHOUT_REASON_INFO, crate::attrs::BLANKET_CLIPPY_RESTRICTION_LINTS_INFO, crate::attrs::DEPRECATED_CFG_ATTR_INFO, + crate::attrs::DEPRECATED_CLIPPY_CFG_ATTR_INFO, crate::attrs::DEPRECATED_SEMVER_INFO, crate::attrs::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO, crate::attrs::EMPTY_LINE_AFTER_OUTER_ATTR_INFO, @@ -59,6 +60,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::attrs::MISMATCHED_TARGET_OS_INFO, crate::attrs::NON_MINIMAL_CFG_INFO, crate::attrs::SHOULD_PANIC_WITHOUT_EXPECT_INFO, + crate::attrs::UNNECESSARY_CLIPPY_CFG_INFO, crate::attrs::USELESS_ATTRIBUTE_INFO, crate::await_holding_invalid::AWAIT_HOLDING_INVALID_TYPE_INFO, crate::await_holding_invalid::AWAIT_HOLDING_LOCK_INFO, @@ -137,6 +139,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::disallowed_types::DISALLOWED_TYPES_INFO, crate::doc::DOC_LINK_WITH_QUOTES_INFO, crate::doc::DOC_MARKDOWN_INFO, + crate::doc::EMPTY_DOCS_INFO, crate::doc::MISSING_ERRORS_DOC_INFO, crate::doc::MISSING_PANICS_DOC_INFO, crate::doc::MISSING_SAFETY_DOC_INFO, @@ -453,6 +456,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::methods::UNNECESSARY_FILTER_MAP_INFO, crate::methods::UNNECESSARY_FIND_MAP_INFO, crate::methods::UNNECESSARY_FOLD_INFO, + crate::methods::UNNECESSARY_GET_THEN_CHECK_INFO, crate::methods::UNNECESSARY_JOIN_INFO, crate::methods::UNNECESSARY_LAZY_EVALUATIONS_INFO, crate::methods::UNNECESSARY_LITERAL_UNWRAP_INFO, @@ -497,6 +501,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::module_style::MOD_MODULE_FILES_INFO, crate::module_style::SELF_NAMED_MODULE_FILES_INFO, crate::multi_assignments::MULTI_ASSIGNMENTS_INFO, + crate::multiple_bound_locations::MULTIPLE_BOUND_LOCATIONS_INFO, crate::multiple_unsafe_ops_per_block::MULTIPLE_UNSAFE_OPS_PER_BLOCK_INFO, crate::mut_key::MUTABLE_KEY_TYPE_INFO, crate::mut_mut::MUT_MUT_INFO, diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index 0ddfeaa0ae059..560b2acc1c702 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -2,9 +2,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then}; use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::sugg::has_enclosing_paren; use clippy_utils::ty::{implements_trait, is_manually_drop, peel_mid_ty_refs}; -use clippy_utils::{ - expr_use_ctxt, get_parent_expr, get_parent_node, is_lint_allowed, path_to_local, DefinedTy, ExprUseNode, -}; +use clippy_utils::{expr_use_ctxt, get_parent_expr, is_lint_allowed, path_to_local, DefinedTy, ExprUseNode}; use core::mem; use rustc_ast::util::parser::{PREC_POSTFIX, PREC_PREFIX}; use rustc_data_structures::fx::FxIndexMap; @@ -1008,8 +1006,8 @@ fn report<'tcx>( data.first_expr.span, state.msg, |diag| { - let (precedence, calls_field) = match get_parent_node(cx.tcx, data.first_expr.hir_id) { - Some(Node::Expr(e)) => match e.kind { + let (precedence, calls_field) = match cx.tcx.parent_hir_node(data.first_expr.hir_id) { + Node::Expr(e) => match e.kind { ExprKind::Call(callee, _) if callee.hir_id != data.first_expr.hir_id => (0, false), ExprKind::Call(..) => (PREC_POSTFIX, matches!(expr.kind, ExprKind::Field(..))), _ => (e.precedence().order(), false), diff --git a/src/tools/clippy/clippy_lints/src/disallowed_macros.rs b/src/tools/clippy/clippy_lints/src/disallowed_macros.rs index 656b3d9bfaf1b..4a617ba34d57b 100644 --- a/src/tools/clippy/clippy_lints/src/disallowed_macros.rs +++ b/src/tools/clippy/clippy_lints/src/disallowed_macros.rs @@ -1,13 +1,16 @@ use clippy_config::types::DisallowedPath; -use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then}; use clippy_utils::macros::macro_backtrace; use rustc_ast::Attribute; use rustc_data_structures::fx::FxHashSet; +use rustc_errors::Diag; use rustc_hir::def_id::DefIdMap; -use rustc_hir::{Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, Pat, Path, Stmt, TraitItem, Ty}; +use rustc_hir::{ + Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, ItemKind, OwnerId, Pat, Path, Stmt, TraitItem, Ty, +}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; -use rustc_span::{ExpnId, Span}; +use rustc_span::{ExpnId, MacroKind, Span}; declare_clippy_lint! { /// ### What it does @@ -57,6 +60,10 @@ pub struct DisallowedMacros { conf_disallowed: Vec, disallowed: DefIdMap, seen: FxHashSet, + + // Track the most recently seen node that can have a `derive` attribute. + // Needed to use the correct lint level. + derive_src: Option, } impl DisallowedMacros { @@ -65,10 +72,11 @@ impl DisallowedMacros { conf_disallowed, disallowed: DefIdMap::default(), seen: FxHashSet::default(), + derive_src: None, } } - fn check(&mut self, cx: &LateContext<'_>, span: Span) { + fn check(&mut self, cx: &LateContext<'_>, span: Span, derive_src: Option) { if self.conf_disallowed.is_empty() { return; } @@ -80,18 +88,26 @@ impl DisallowedMacros { if let Some(&index) = self.disallowed.get(&mac.def_id) { let conf = &self.conf_disallowed[index]; - - span_lint_and_then( - cx, - DISALLOWED_MACROS, - mac.span, - &format!("use of a disallowed macro `{}`", conf.path()), - |diag| { - if let Some(reason) = conf.reason() { - diag.note(reason); - } - }, - ); + let msg = format!("use of a disallowed macro `{}`", conf.path()); + let add_note = |diag: &mut Diag<'_, _>| { + if let Some(reason) = conf.reason() { + diag.note(reason); + } + }; + if matches!(mac.kind, MacroKind::Derive) + && let Some(derive_src) = derive_src + { + span_lint_hir_and_then( + cx, + DISALLOWED_MACROS, + cx.tcx.local_def_id_to_hir_id(derive_src.def_id), + mac.span, + &msg, + add_note, + ); + } else { + span_lint_and_then(cx, DISALLOWED_MACROS, mac.span, &msg, add_note); + } } } } @@ -110,49 +126,57 @@ impl LateLintPass<'_> for DisallowedMacros { } fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { - self.check(cx, expr.span); + self.check(cx, expr.span, None); // `$t + $t` can have the context of $t, check also the span of the binary operator if let ExprKind::Binary(op, ..) = expr.kind { - self.check(cx, op.span); + self.check(cx, op.span, None); } } fn check_stmt(&mut self, cx: &LateContext<'_>, stmt: &Stmt<'_>) { - self.check(cx, stmt.span); + self.check(cx, stmt.span, None); } fn check_ty(&mut self, cx: &LateContext<'_>, ty: &Ty<'_>) { - self.check(cx, ty.span); + self.check(cx, ty.span, None); } fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) { - self.check(cx, pat.span); + self.check(cx, pat.span, None); } fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { - self.check(cx, item.span); - self.check(cx, item.vis_span); + self.check(cx, item.span, self.derive_src); + self.check(cx, item.vis_span, None); + + if matches!( + item.kind, + ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..) + ) && macro_backtrace(item.span).all(|m| !matches!(m.kind, MacroKind::Derive)) + { + self.derive_src = Some(item.owner_id); + } } fn check_foreign_item(&mut self, cx: &LateContext<'_>, item: &ForeignItem<'_>) { - self.check(cx, item.span); - self.check(cx, item.vis_span); + self.check(cx, item.span, None); + self.check(cx, item.vis_span, None); } fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &ImplItem<'_>) { - self.check(cx, item.span); - self.check(cx, item.vis_span); + self.check(cx, item.span, None); + self.check(cx, item.vis_span, None); } fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) { - self.check(cx, item.span); + self.check(cx, item.span, None); } fn check_path(&mut self, cx: &LateContext<'_>, path: &Path<'_>, _: HirId) { - self.check(cx, path.span); + self.check(cx, path.span, None); } fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &Attribute) { - self.check(cx, attr.span); + self.check(cx, attr.span, self.derive_src); } } diff --git a/src/tools/clippy/clippy_lints/src/doc/mod.rs b/src/tools/clippy/clippy_lints/src/doc/mod.rs index 2b4ce6ddfaaa3..9af34c3a7bf0b 100644 --- a/src/tools/clippy/clippy_lints/src/doc/mod.rs +++ b/src/tools/clippy/clippy_lints/src/doc/mod.rs @@ -19,7 +19,8 @@ use rustc_middle::hir::nested_filter; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_resolve::rustdoc::{ - add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, DocFragment, + add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range, span_of_fragments, + DocFragment, }; use rustc_session::impl_lint_pass; use rustc_span::edition::Edition; @@ -338,6 +339,30 @@ declare_clippy_lint! { "suspicious usage of (outer) doc comments" } +declare_clippy_lint! { + /// ### What it does + /// Detects documentation that is empty. + /// ### Why is this bad? + /// Empty docs clutter code without adding value, reducing readability and maintainability. + /// ### Example + /// ```no_run + /// /// + /// fn returns_true() -> bool { + /// true + /// } + /// ``` + /// Use instead: + /// ```no_run + /// fn returns_true() -> bool { + /// true + /// } + /// ``` + #[clippy::version = "1.78.0"] + pub EMPTY_DOCS, + suspicious, + "docstrings exist but documentation is empty" +} + #[derive(Clone)] pub struct Documentation { valid_idents: FxHashSet, @@ -364,7 +389,8 @@ impl_lint_pass!(Documentation => [ NEEDLESS_DOCTEST_MAIN, TEST_ATTR_IN_DOCTEST, UNNECESSARY_SAFETY_DOC, - SUSPICIOUS_DOC_COMMENTS + SUSPICIOUS_DOC_COMMENTS, + EMPTY_DOCS, ]); impl<'tcx> LateLintPass<'tcx> for Documentation { @@ -373,11 +399,22 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { check_attrs(cx, &self.valid_idents, attrs); } + fn check_variant(&mut self, cx: &LateContext<'tcx>, variant: &'tcx hir::Variant<'tcx>) { + let attrs = cx.tcx.hir().attrs(variant.hir_id); + check_attrs(cx, &self.valid_idents, attrs); + } + + fn check_field_def(&mut self, cx: &LateContext<'tcx>, variant: &'tcx hir::FieldDef<'tcx>) { + let attrs = cx.tcx.hir().attrs(variant.hir_id); + check_attrs(cx, &self.valid_idents, attrs); + } + fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) { let attrs = cx.tcx.hir().attrs(item.hir_id()); let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return; }; + match item.kind { hir::ItemKind::Fn(ref sig, _, body_id) => { if !(is_entrypoint_fn(cx, item.owner_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) { @@ -502,13 +539,23 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ suspicious_doc_comments::check(cx, attrs); let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true); - let mut doc = String::new(); - for fragment in &fragments { - add_doc_fragment(&mut doc, fragment); - } + let mut doc = fragments.iter().fold(String::new(), |mut acc, fragment| { + add_doc_fragment(&mut acc, fragment); + acc + }); doc.pop(); - if doc.is_empty() { + if doc.trim().is_empty() { + if let Some(span) = span_of_fragments(&fragments) { + span_lint_and_help( + cx, + EMPTY_DOCS, + span, + "empty doc comment", + None, + "consider removing or filling it", + ); + } return Some(DocHeaders::default()); } diff --git a/src/tools/clippy/clippy_lints/src/doc/needless_doctest_main.rs b/src/tools/clippy/clippy_lints/src/doc/needless_doctest_main.rs index 8dde4f227ed15..58656140352f9 100644 --- a/src/tools/clippy/clippy_lints/src/doc/needless_doctest_main.rs +++ b/src/tools/clippy/clippy_lints/src/doc/needless_doctest_main.rs @@ -6,7 +6,7 @@ use clippy_utils::diagnostics::span_lint; use rustc_ast::{CoroutineKind, Fn, FnRetTy, Item, ItemKind}; use rustc_data_structures::sync::Lrc; use rustc_errors::emitter::HumanEmitter; -use rustc_errors::{DiagCtxt, DiagnosticBuilder}; +use rustc_errors::{Diag, DiagCtxt}; use rustc_lint::LateContext; use rustc_parse::maybe_new_parser_from_source_str; use rustc_parse::parser::ForceCollect; @@ -53,7 +53,7 @@ pub fn check( let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) { Ok(p) => p, Err(errs) => { - errs.into_iter().for_each(DiagnosticBuilder::cancel); + errs.into_iter().for_each(Diag::cancel); return (false, test_attr_spans); }, }; diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index 124d78fc4ffdc..bf6f54c1e72a3 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_note; +use clippy_utils::is_must_use_func_call; use clippy_utils::ty::{is_copy, is_must_use_ty, is_type_lang_item}; -use clippy_utils::{get_parent_node, is_must_use_func_call}; use rustc_hir::{Arm, Expr, ExprKind, LangItem, Node}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -144,8 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { // } fn is_single_call_in_arm<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'_>, drop_expr: &'tcx Expr<'_>) -> bool { if matches!(arg.kind, ExprKind::Call(..) | ExprKind::MethodCall(..)) { - let parent_node = get_parent_node(cx.tcx, drop_expr.hir_id); - if let Some(Node::Arm(Arm { body, .. })) = &parent_node { + if let Node::Arm(Arm { body, .. }) = cx.tcx.parent_hir_node(drop_expr.hir_id) { return body.hir_id == drop_expr.hir_id; } } diff --git a/src/tools/clippy/clippy_lints/src/format_args.rs b/src/tools/clippy/clippy_lints/src/format_args.rs index 8af321e4d553b..61f550ce0beb4 100644 --- a/src/tools/clippy/clippy_lints/src/format_args.rs +++ b/src/tools/clippy/clippy_lints/src/format_args.rs @@ -4,7 +4,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::is_diag_trait_item; use clippy_utils::macros::{ find_format_arg_expr, find_format_args, format_arg_removal_span, format_placeholder_format_span, is_assert_macro, - is_format_macro, is_panic, root_macro_call, root_macro_call_first_node, FormatParamUsage, + is_format_macro, is_panic, root_macro_call, root_macro_call_first_node, FormatParamUsage, MacroCall, }; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{implements_trait, is_type_lang_item}; @@ -20,7 +20,6 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; use rustc_middle::ty::Ty; use rustc_session::impl_lint_pass; -use rustc_span::def_id::DefId; use rustc_span::edition::Edition::Edition2021; use rustc_span::{sym, Span, Symbol}; @@ -189,32 +188,18 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { && is_format_macro(cx, macro_call.def_id) && let Some(format_args) = find_format_args(cx, expr, macro_call.expn) { - for piece in &format_args.template { - if let FormatArgsPiece::Placeholder(placeholder) = piece - && let Ok(index) = placeholder.argument.index - && let Some(arg) = format_args.arguments.all_args().get(index) - { - let arg_expr = find_format_arg_expr(expr, arg); - - check_unused_format_specifier(cx, placeholder, arg_expr); - - if placeholder.format_trait != FormatTrait::Display - || placeholder.format_options != FormatOptions::default() - || is_aliased(&format_args, index) - { - continue; - } + let linter = FormatArgsExpr { + cx, + expr, + macro_call: ¯o_call, + format_args: &format_args, + ignore_mixed: self.ignore_mixed, + }; - if let Ok(arg_hir_expr) = arg_expr { - let name = cx.tcx.item_name(macro_call.def_id); - check_format_in_format_args(cx, macro_call.span, name, arg_hir_expr); - check_to_string_in_format_args(cx, name, arg_hir_expr); - } - } - } + linter.check_templates(); if self.msrv.meets(msrvs::FORMAT_ARGS_CAPTURE) { - check_uninlined_args(cx, &format_args, macro_call.span, macro_call.def_id, self.ignore_mixed); + linter.check_uninlined_args(); } } } @@ -222,255 +207,279 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs { extract_msrv_attr!(LateContext); } -fn check_unused_format_specifier( - cx: &LateContext<'_>, - placeholder: &FormatPlaceholder, - arg_expr: Result<&Expr<'_>, &rustc_ast::Expr>, -) { - let ty_or_ast_expr = arg_expr.map(|expr| cx.typeck_results().expr_ty(expr).peel_refs()); - - let is_format_args = match ty_or_ast_expr { - Ok(ty) => is_type_lang_item(cx, ty, LangItem::FormatArguments), - Err(expr) => matches!(expr.peel_parens_and_refs().kind, rustc_ast::ExprKind::FormatArgs(_)), - }; - - let options = &placeholder.format_options; - - let arg_span = match arg_expr { - Ok(expr) => expr.span, - Err(expr) => expr.span, - }; - - if let Some(placeholder_span) = placeholder.span - && is_format_args - && *options != FormatOptions::default() - { - span_lint_and_then( - cx, - UNUSED_FORMAT_SPECS, - placeholder_span, - "format specifiers have no effect on `format_args!()`", - |diag| { - let mut suggest_format = |spec| { - let message = format!("for the {spec} to apply consider using `format!()`"); - - if let Some(mac_call) = root_macro_call(arg_span) - && cx.tcx.is_diagnostic_item(sym::format_args_macro, mac_call.def_id) - { - diag.span_suggestion( - cx.sess().source_map().span_until_char(mac_call.span, '!'), - message, - "format", - Applicability::MaybeIncorrect, - ); - } else { - diag.help(message); - } - }; +struct FormatArgsExpr<'a, 'tcx> { + cx: &'a LateContext<'tcx>, + expr: &'tcx Expr<'tcx>, + macro_call: &'a MacroCall, + format_args: &'a rustc_ast::FormatArgs, + ignore_mixed: bool, +} - if options.width.is_some() { - suggest_format("width"); +impl<'a, 'tcx> FormatArgsExpr<'a, 'tcx> { + fn check_templates(&self) { + for piece in &self.format_args.template { + if let FormatArgsPiece::Placeholder(placeholder) = piece + && let Ok(index) = placeholder.argument.index + && let Some(arg) = self.format_args.arguments.all_args().get(index) + { + let arg_expr = find_format_arg_expr(self.expr, arg); + + self.check_unused_format_specifier(placeholder, arg_expr); + + if let Ok(arg_expr) = arg_expr + && placeholder.format_trait == FormatTrait::Display + && placeholder.format_options == FormatOptions::default() + && !self.is_aliased(index) + { + let name = self.cx.tcx.item_name(self.macro_call.def_id); + self.check_format_in_format_args(name, arg_expr); + self.check_to_string_in_format_args(name, arg_expr); } + } + } + } - if options.precision.is_some() { - suggest_format("precision"); - } + fn check_unused_format_specifier( + &self, + placeholder: &FormatPlaceholder, + arg_expr: Result<&Expr<'_>, &rustc_ast::Expr>, + ) { + let ty_or_ast_expr = arg_expr.map(|expr| self.cx.typeck_results().expr_ty(expr).peel_refs()); - if let Some(format_span) = format_placeholder_format_span(placeholder) { - diag.span_suggestion_verbose( - format_span, - "if the current behavior is intentional, remove the format specifiers", - "", - Applicability::MaybeIncorrect, - ); - } - }, - ); - } -} + let is_format_args = match ty_or_ast_expr { + Ok(ty) => is_type_lang_item(self.cx, ty, LangItem::FormatArguments), + Err(expr) => matches!(expr.peel_parens_and_refs().kind, rustc_ast::ExprKind::FormatArgs(_)), + }; -fn check_uninlined_args( - cx: &LateContext<'_>, - args: &rustc_ast::FormatArgs, - call_site: Span, - def_id: DefId, - ignore_mixed: bool, -) { - if args.span.from_expansion() { - return; - } - if call_site.edition() < Edition2021 && (is_panic(cx, def_id) || is_assert_macro(cx, def_id)) { - // panic!, assert!, and debug_assert! before 2021 edition considers a single string argument as - // non-format - return; + let options = &placeholder.format_options; + + let arg_span = match arg_expr { + Ok(expr) => expr.span, + Err(expr) => expr.span, + }; + + if let Some(placeholder_span) = placeholder.span + && is_format_args + && *options != FormatOptions::default() + { + span_lint_and_then( + self.cx, + UNUSED_FORMAT_SPECS, + placeholder_span, + "format specifiers have no effect on `format_args!()`", + |diag| { + let mut suggest_format = |spec| { + let message = format!("for the {spec} to apply consider using `format!()`"); + + if let Some(mac_call) = root_macro_call(arg_span) + && self.cx.tcx.is_diagnostic_item(sym::format_args_macro, mac_call.def_id) + { + diag.span_suggestion( + self.cx.sess().source_map().span_until_char(mac_call.span, '!'), + message, + "format", + Applicability::MaybeIncorrect, + ); + } else { + diag.help(message); + } + }; + + if options.width.is_some() { + suggest_format("width"); + } + + if options.precision.is_some() { + suggest_format("precision"); + } + + if let Some(format_span) = format_placeholder_format_span(placeholder) { + diag.span_suggestion_verbose( + format_span, + "if the current behavior is intentional, remove the format specifiers", + "", + Applicability::MaybeIncorrect, + ); + } + }, + ); + } } - let mut fixes = Vec::new(); - // If any of the arguments are referenced by an index number, - // and that argument is not a simple variable and cannot be inlined, - // we cannot remove any other arguments in the format string, - // because the index numbers might be wrong after inlining. - // Example of an un-inlinable format: print!("{}{1}", foo, 2) - for (pos, usage) in format_arg_positions(args) { - if !check_one_arg(args, pos, usage, &mut fixes, ignore_mixed) { + fn check_uninlined_args(&self) { + if self.format_args.span.from_expansion() { + return; + } + if self.macro_call.span.edition() < Edition2021 + && (is_panic(self.cx, self.macro_call.def_id) || is_assert_macro(self.cx, self.macro_call.def_id)) + { + // panic!, assert!, and debug_assert! before 2021 edition considers a single string argument as + // non-format return; } - } - if fixes.is_empty() { - return; - } + let mut fixes = Vec::new(); + // If any of the arguments are referenced by an index number, + // and that argument is not a simple variable and cannot be inlined, + // we cannot remove any other arguments in the format string, + // because the index numbers might be wrong after inlining. + // Example of an un-inlinable format: print!("{}{1}", foo, 2) + for (pos, usage) in self.format_arg_positions() { + if !self.check_one_arg(pos, usage, &mut fixes) { + return; + } + } - // multiline span display suggestion is sometimes broken: https://github.com/rust-lang/rust/pull/102729#discussion_r988704308 - // in those cases, make the code suggestion hidden - let multiline_fix = fixes.iter().any(|(span, _)| cx.sess().source_map().is_multiline(*span)); - - // Suggest removing each argument only once, for example in `format!("{0} {0}", arg)`. - fixes.sort_unstable_by_key(|(span, _)| *span); - fixes.dedup_by_key(|(span, _)| *span); - - span_lint_and_then( - cx, - UNINLINED_FORMAT_ARGS, - call_site, - "variables can be used directly in the `format!` string", - |diag| { - diag.multipart_suggestion_with_style( - "change this to", - fixes, - Applicability::MachineApplicable, - if multiline_fix { CompletelyHidden } else { ShowCode }, - ); - }, - ); -} + if fixes.is_empty() { + return; + } -fn check_one_arg( - args: &rustc_ast::FormatArgs, - pos: &FormatArgPosition, - usage: FormatParamUsage, - fixes: &mut Vec<(Span, String)>, - ignore_mixed: bool, -) -> bool { - let index = pos.index.unwrap(); - let arg = &args.arguments.all_args()[index]; - - if !matches!(arg.kind, FormatArgumentKind::Captured(_)) - && let rustc_ast::ExprKind::Path(None, path) = &arg.expr.kind - && let [segment] = path.segments.as_slice() - && segment.args.is_none() - && let Some(arg_span) = format_arg_removal_span(args, index) - && let Some(pos_span) = pos.span - { - let replacement = match usage { - FormatParamUsage::Argument => segment.ident.name.to_string(), - FormatParamUsage::Width => format!("{}$", segment.ident.name), - FormatParamUsage::Precision => format!(".{}$", segment.ident.name), - }; - fixes.push((pos_span, replacement)); - fixes.push((arg_span, String::new())); - true // successful inlining, continue checking - } else { - // Do not continue inlining (return false) in case - // * if we can't inline a numbered argument, e.g. `print!("{0} ...", foo.bar, ...)` - // * if allow_mixed_uninlined_format_args is false and this arg hasn't been inlined already - pos.kind != FormatArgPositionKind::Number - && (!ignore_mixed || matches!(arg.kind, FormatArgumentKind::Captured(_))) - } -} + // multiline span display suggestion is sometimes broken: https://github.com/rust-lang/rust/pull/102729#discussion_r988704308 + // in those cases, make the code suggestion hidden + let multiline_fix = fixes + .iter() + .any(|(span, _)| self.cx.sess().source_map().is_multiline(*span)); -fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symbol, arg: &Expr<'_>) { - let expn_data = arg.span.ctxt().outer_expn_data(); - if expn_data.call_site.from_expansion() { - return; - } - let Some(mac_id) = expn_data.macro_def_id else { return }; - if !cx.tcx.is_diagnostic_item(sym::format_macro, mac_id) { - return; + // Suggest removing each argument only once, for example in `format!("{0} {0}", arg)`. + fixes.sort_unstable_by_key(|(span, _)| *span); + fixes.dedup_by_key(|(span, _)| *span); + + span_lint_and_then( + self.cx, + UNINLINED_FORMAT_ARGS, + self.macro_call.span, + "variables can be used directly in the `format!` string", + |diag| { + diag.multipart_suggestion_with_style( + "change this to", + fixes, + Applicability::MachineApplicable, + if multiline_fix { CompletelyHidden } else { ShowCode }, + ); + }, + ); } - span_lint_and_then( - cx, - FORMAT_IN_FORMAT_ARGS, - call_site, - &format!("`format!` in `{name}!` args"), - |diag| { - diag.help(format!( - "combine the `format!(..)` arguments with the outer `{name}!(..)` call" - )); - diag.help("or consider changing `format!` to `format_args!`"); - }, - ); -} -fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Expr<'_>) { - if !value.span.from_expansion() - && let ExprKind::MethodCall(_, receiver, [], to_string_span) = value.kind - && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(value.hir_id) - && is_diag_trait_item(cx, method_def_id, sym::ToString) - && let receiver_ty = cx.typeck_results().expr_ty(receiver) - && let Some(display_trait_id) = cx.tcx.get_diagnostic_item(sym::Display) - && let (n_needed_derefs, target) = - count_needed_derefs(receiver_ty, cx.typeck_results().expr_adjustments(receiver).iter()) - && implements_trait(cx, target, display_trait_id, &[]) - && let Some(sized_trait_id) = cx.tcx.lang_items().sized_trait() - && let Some(receiver_snippet) = snippet_opt(cx, receiver.span) - { - let needs_ref = !implements_trait(cx, receiver_ty, sized_trait_id, &[]); - if n_needed_derefs == 0 && !needs_ref { - span_lint_and_sugg( - cx, - TO_STRING_IN_FORMAT_ARGS, - to_string_span.with_lo(receiver.span.hi()), - &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), - "remove this", - String::new(), - Applicability::MachineApplicable, - ); + fn check_one_arg(&self, pos: &FormatArgPosition, usage: FormatParamUsage, fixes: &mut Vec<(Span, String)>) -> bool { + let index = pos.index.unwrap(); + let arg = &self.format_args.arguments.all_args()[index]; + + if !matches!(arg.kind, FormatArgumentKind::Captured(_)) + && let rustc_ast::ExprKind::Path(None, path) = &arg.expr.kind + && let [segment] = path.segments.as_slice() + && segment.args.is_none() + && let Some(arg_span) = format_arg_removal_span(self.format_args, index) + && let Some(pos_span) = pos.span + { + let replacement = match usage { + FormatParamUsage::Argument => segment.ident.name.to_string(), + FormatParamUsage::Width => format!("{}$", segment.ident.name), + FormatParamUsage::Precision => format!(".{}$", segment.ident.name), + }; + fixes.push((pos_span, replacement)); + fixes.push((arg_span, String::new())); + true // successful inlining, continue checking } else { - span_lint_and_sugg( - cx, - TO_STRING_IN_FORMAT_ARGS, - value.span, - &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), - "use this", - format!( - "{}{:*>n_needed_derefs$}{receiver_snippet}", - if needs_ref { "&" } else { "" }, - "" - ), - Applicability::MachineApplicable, - ); + // Do not continue inlining (return false) in case + // * if we can't inline a numbered argument, e.g. `print!("{0} ...", foo.bar, ...)` + // * if allow_mixed_uninlined_format_args is false and this arg hasn't been inlined already + pos.kind != FormatArgPositionKind::Number + && (!self.ignore_mixed || matches!(arg.kind, FormatArgumentKind::Captured(_))) } } -} -fn format_arg_positions( - format_args: &rustc_ast::FormatArgs, -) -> impl Iterator { - format_args.template.iter().flat_map(|piece| match piece { - FormatArgsPiece::Placeholder(placeholder) => { - let mut positions = ArrayVec::<_, 3>::new(); + fn check_format_in_format_args(&self, name: Symbol, arg: &Expr<'_>) { + let expn_data = arg.span.ctxt().outer_expn_data(); + if expn_data.call_site.from_expansion() { + return; + } + let Some(mac_id) = expn_data.macro_def_id else { return }; + if !self.cx.tcx.is_diagnostic_item(sym::format_macro, mac_id) { + return; + } + span_lint_and_then( + self.cx, + FORMAT_IN_FORMAT_ARGS, + self.macro_call.span, + &format!("`format!` in `{name}!` args"), + |diag| { + diag.help(format!( + "combine the `format!(..)` arguments with the outer `{name}!(..)` call" + )); + diag.help("or consider changing `format!` to `format_args!`"); + }, + ); + } - positions.push((&placeholder.argument, FormatParamUsage::Argument)); - if let Some(FormatCount::Argument(position)) = &placeholder.format_options.width { - positions.push((position, FormatParamUsage::Width)); - } - if let Some(FormatCount::Argument(position)) = &placeholder.format_options.precision { - positions.push((position, FormatParamUsage::Precision)); + fn check_to_string_in_format_args(&self, name: Symbol, value: &Expr<'_>) { + let cx = self.cx; + if !value.span.from_expansion() + && let ExprKind::MethodCall(_, receiver, [], to_string_span) = value.kind + && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(value.hir_id) + && is_diag_trait_item(cx, method_def_id, sym::ToString) + && let receiver_ty = cx.typeck_results().expr_ty(receiver) + && let Some(display_trait_id) = cx.tcx.get_diagnostic_item(sym::Display) + && let (n_needed_derefs, target) = + count_needed_derefs(receiver_ty, cx.typeck_results().expr_adjustments(receiver).iter()) + && implements_trait(cx, target, display_trait_id, &[]) + && let Some(sized_trait_id) = cx.tcx.lang_items().sized_trait() + && let Some(receiver_snippet) = snippet_opt(cx, receiver.span) + { + let needs_ref = !implements_trait(cx, receiver_ty, sized_trait_id, &[]); + if n_needed_derefs == 0 && !needs_ref { + span_lint_and_sugg( + cx, + TO_STRING_IN_FORMAT_ARGS, + to_string_span.with_lo(receiver.span.hi()), + &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), + "remove this", + String::new(), + Applicability::MachineApplicable, + ); + } else { + span_lint_and_sugg( + cx, + TO_STRING_IN_FORMAT_ARGS, + value.span, + &format!("`to_string` applied to a type that implements `Display` in `{name}!` args"), + "use this", + format!( + "{}{:*>n_needed_derefs$}{receiver_snippet}", + if needs_ref { "&" } else { "" }, + "" + ), + Applicability::MachineApplicable, + ); } + } + } - positions - }, - FormatArgsPiece::Literal(_) => ArrayVec::new(), - }) -} + fn format_arg_positions(&self) -> impl Iterator { + self.format_args.template.iter().flat_map(|piece| match piece { + FormatArgsPiece::Placeholder(placeholder) => { + let mut positions = ArrayVec::<_, 3>::new(); -/// Returns true if the format argument at `index` is referred to by multiple format params -fn is_aliased(format_args: &rustc_ast::FormatArgs, index: usize) -> bool { - format_arg_positions(format_args) - .filter(|(position, _)| position.index == Ok(index)) - .at_most_one() - .is_err() + positions.push((&placeholder.argument, FormatParamUsage::Argument)); + if let Some(FormatCount::Argument(position)) = &placeholder.format_options.width { + positions.push((position, FormatParamUsage::Width)); + } + if let Some(FormatCount::Argument(position)) = &placeholder.format_options.precision { + positions.push((position, FormatParamUsage::Precision)); + } + + positions + }, + FormatArgsPiece::Literal(_) => ArrayVec::new(), + }) + } + + /// Returns true if the format argument at `index` is referred to by multiple format params + fn is_aliased(&self, index: usize) -> bool { + self.format_arg_positions() + .filter(|(position, _)| position.index == Ok(index)) + .at_most_one() + .is_err() + } } fn count_needed_derefs<'tcx, I>(mut ty: Ty<'tcx>, mut iter: I) -> (usize, Ty<'tcx>) diff --git a/src/tools/clippy/clippy_lints/src/format_impl.rs b/src/tools/clippy/clippy_lints/src/format_impl.rs index 9360eb1fa91ad..93517076cda01 100644 --- a/src/tools/clippy/clippy_lints/src/format_impl.rs +++ b/src/tools/clippy/clippy_lints/src/format_impl.rs @@ -7,7 +7,7 @@ use rustc_hir::{Expr, ExprKind, Impl, ImplItem, ImplItemKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; -use rustc_span::{sym, Span, Symbol}; +use rustc_span::{sym, Symbol}; declare_clippy_lint! { /// ### What it does @@ -119,123 +119,132 @@ impl<'tcx> LateLintPass<'tcx> for FormatImpl { } fn check_impl_item_post(&mut self, cx: &LateContext<'_>, impl_item: &ImplItem<'_>) { - // Assume no nested Impl of Debug and Display within eachother + // Assume no nested Impl of Debug and Display within each other if is_format_trait_impl(cx, impl_item).is_some() { self.format_trait_impl = None; } } fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { - let Some(format_trait_impl) = self.format_trait_impl else { - return; - }; - - if format_trait_impl.name == sym::Display { - check_to_string_in_display(cx, expr); + if let Some(format_trait_impl) = self.format_trait_impl { + let linter = FormatImplExpr { + cx, + expr, + format_trait_impl, + }; + linter.check_to_string_in_display(); + linter.check_self_in_format_args(); + linter.check_print_in_format_impl(); } - - check_self_in_format_args(cx, expr, format_trait_impl); - check_print_in_format_impl(cx, expr, format_trait_impl); } } -fn check_to_string_in_display(cx: &LateContext<'_>, expr: &Expr<'_>) { - if let ExprKind::MethodCall(path, self_arg, ..) = expr.kind - // Get the hir_id of the object we are calling the method on - // Is the method to_string() ? - && path.ident.name == sym::to_string - // Is the method a part of the ToString trait? (i.e. not to_string() implemented - // separately) - && let Some(expr_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) - && is_diag_trait_item(cx, expr_def_id, sym::ToString) - // Is the method is called on self - && let ExprKind::Path(QPath::Resolved(_, path)) = self_arg.kind - && let [segment] = path.segments - && segment.ident.name == kw::SelfLower - { - span_lint( - cx, - RECURSIVE_FORMAT_IMPL, - expr.span, - "using `self.to_string` in `fmt::Display` implementation will cause infinite recursion", - ); - } +struct FormatImplExpr<'a, 'tcx> { + cx: &'a LateContext<'tcx>, + expr: &'tcx Expr<'tcx>, + format_trait_impl: FormatTraitNames, } -fn check_self_in_format_args<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, impl_trait: FormatTraitNames) { - // Check each arg in format calls - do we ever use Display on self (directly or via deref)? - if let Some(outer_macro) = root_macro_call_first_node(cx, expr) - && let macro_def_id = outer_macro.def_id - && is_format_macro(cx, macro_def_id) - && let Some(format_args) = find_format_args(cx, expr, outer_macro.expn) - { - for piece in &format_args.template { - if let FormatArgsPiece::Placeholder(placeholder) = piece - && let trait_name = match placeholder.format_trait { - FormatTrait::Display => sym::Display, - FormatTrait::Debug => sym::Debug, - FormatTrait::LowerExp => sym!(LowerExp), - FormatTrait::UpperExp => sym!(UpperExp), - FormatTrait::Octal => sym!(Octal), - FormatTrait::Pointer => sym::Pointer, - FormatTrait::Binary => sym!(Binary), - FormatTrait::LowerHex => sym!(LowerHex), - FormatTrait::UpperHex => sym!(UpperHex), +impl<'a, 'tcx> FormatImplExpr<'a, 'tcx> { + fn check_to_string_in_display(&self) { + if self.format_trait_impl.name == sym::Display + && let ExprKind::MethodCall(path, self_arg, ..) = self.expr.kind + // Get the hir_id of the object we are calling the method on + // Is the method to_string() ? + && path.ident.name == sym::to_string + // Is the method a part of the ToString trait? (i.e. not to_string() implemented + // separately) + && let Some(expr_def_id) = self.cx.typeck_results().type_dependent_def_id(self.expr.hir_id) + && is_diag_trait_item(self.cx, expr_def_id, sym::ToString) + // Is the method is called on self + && let ExprKind::Path(QPath::Resolved(_, path)) = self_arg.kind + && let [segment] = path.segments + && segment.ident.name == kw::SelfLower + { + span_lint( + self.cx, + RECURSIVE_FORMAT_IMPL, + self.expr.span, + "using `self.to_string` in `fmt::Display` implementation will cause infinite recursion", + ); + } + } + + fn check_self_in_format_args(&self) { + // Check each arg in format calls - do we ever use Display on self (directly or via deref)? + if let Some(outer_macro) = root_macro_call_first_node(self.cx, self.expr) + && let macro_def_id = outer_macro.def_id + && is_format_macro(self.cx, macro_def_id) + && let Some(format_args) = find_format_args(self.cx, self.expr, outer_macro.expn) + { + for piece in &format_args.template { + if let FormatArgsPiece::Placeholder(placeholder) = piece + && let trait_name = match placeholder.format_trait { + FormatTrait::Display => sym::Display, + FormatTrait::Debug => sym::Debug, + FormatTrait::LowerExp => sym!(LowerExp), + FormatTrait::UpperExp => sym!(UpperExp), + FormatTrait::Octal => sym!(Octal), + FormatTrait::Pointer => sym::Pointer, + FormatTrait::Binary => sym!(Binary), + FormatTrait::LowerHex => sym!(LowerHex), + FormatTrait::UpperHex => sym!(UpperHex), + } + && trait_name == self.format_trait_impl.name + && let Ok(index) = placeholder.argument.index + && let Some(arg) = format_args.arguments.all_args().get(index) + && let Ok(arg_expr) = find_format_arg_expr(self.expr, arg) + { + self.check_format_arg_self(arg_expr); } - && trait_name == impl_trait.name - && let Ok(index) = placeholder.argument.index - && let Some(arg) = format_args.arguments.all_args().get(index) - && let Ok(arg_expr) = find_format_arg_expr(expr, arg) - { - check_format_arg_self(cx, expr.span, arg_expr, impl_trait); } } } -} -fn check_format_arg_self(cx: &LateContext<'_>, span: Span, arg: &Expr<'_>, impl_trait: FormatTraitNames) { - // Handle multiple dereferencing of references e.g. &&self - // Handle dereference of &self -> self that is equivalent (i.e. via *self in fmt() impl) - // Since the argument to fmt is itself a reference: &self - let reference = peel_ref_operators(cx, arg); - let map = cx.tcx.hir(); - // Is the reference self? - if path_to_local(reference).map(|x| map.name(x)) == Some(kw::SelfLower) { - let FormatTraitNames { name, .. } = impl_trait; - span_lint( - cx, - RECURSIVE_FORMAT_IMPL, - span, - &format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"), - ); + fn check_format_arg_self(&self, arg: &Expr<'_>) { + // Handle multiple dereferencing of references e.g. &&self + // Handle dereference of &self -> self that is equivalent (i.e. via *self in fmt() impl) + // Since the argument to fmt is itself a reference: &self + let reference = peel_ref_operators(self.cx, arg); + let map = self.cx.tcx.hir(); + // Is the reference self? + if path_to_local(reference).map(|x| map.name(x)) == Some(kw::SelfLower) { + let FormatTraitNames { name, .. } = self.format_trait_impl; + span_lint( + self.cx, + RECURSIVE_FORMAT_IMPL, + self.expr.span, + &format!("using `self` as `{name}` in `impl {name}` will cause infinite recursion"), + ); + } } -} -fn check_print_in_format_impl(cx: &LateContext<'_>, expr: &Expr<'_>, impl_trait: FormatTraitNames) { - if let Some(macro_call) = root_macro_call_first_node(cx, expr) - && let Some(name) = cx.tcx.get_diagnostic_name(macro_call.def_id) - { - let replacement = match name { - sym::print_macro | sym::eprint_macro => "write", - sym::println_macro | sym::eprintln_macro => "writeln", - _ => return, - }; + fn check_print_in_format_impl(&self) { + if let Some(macro_call) = root_macro_call_first_node(self.cx, self.expr) + && let Some(name) = self.cx.tcx.get_diagnostic_name(macro_call.def_id) + { + let replacement = match name { + sym::print_macro | sym::eprint_macro => "write", + sym::println_macro | sym::eprintln_macro => "writeln", + _ => return, + }; - let name = name.as_str().strip_suffix("_macro").unwrap(); + let name = name.as_str().strip_suffix("_macro").unwrap(); - span_lint_and_sugg( - cx, - PRINT_IN_FORMAT_IMPL, - macro_call.span, - &format!("use of `{name}!` in `{}` impl", impl_trait.name), - "replace with", - if let Some(formatter_name) = impl_trait.formatter_name { - format!("{replacement}!({formatter_name}, ..)") - } else { - format!("{replacement}!(..)") - }, - Applicability::HasPlaceholders, - ); + span_lint_and_sugg( + self.cx, + PRINT_IN_FORMAT_IMPL, + macro_call.span, + &format!("use of `{name}!` in `{}` impl", self.format_trait_impl.name), + "replace with", + if let Some(formatter_name) = self.format_trait_impl.formatter_name { + format!("{replacement}!({formatter_name}, ..)") + } else { + format!("{replacement}!(..)") + }, + Applicability::HasPlaceholders, + ); + } } } diff --git a/src/tools/clippy/clippy_lints/src/functions/result.rs b/src/tools/clippy/clippy_lints/src/functions/result.rs index 9505741e68ff9..7f36f33fe708c 100644 --- a/src/tools/clippy/clippy_lints/src/functions/result.rs +++ b/src/tools/clippy/clippy_lints/src/functions/result.rs @@ -1,4 +1,4 @@ -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir as hir; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; @@ -135,7 +135,7 @@ fn check_result_large_err<'tcx>(cx: &LateContext<'tcx>, err_ty: Ty<'tcx>, hir_ty RESULT_LARGE_ERR, hir_ty_span, "the `Err`-variant returned from this function is very large", - |diag: &mut DiagnosticBuilder<'_, ()>| { + |diag: &mut Diag<'_, ()>| { diag.span_label(hir_ty_span, format!("the `Err`-variant is at least {ty_size} bytes")); diag.help(format!("try reducing the size of `{err_ty}`, for example by boxing large elements or replacing it with `Box<{err_ty}>`")); }, diff --git a/src/tools/clippy/clippy_lints/src/if_let_mutex.rs b/src/tools/clippy/clippy_lints/src/if_let_mutex.rs index 61a322ea8812f..a55836a972fb8 100644 --- a/src/tools/clippy/clippy_lints/src/if_let_mutex.rs +++ b/src/tools/clippy/clippy_lints/src/if_let_mutex.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{higher, SpanlessEq}; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir::intravisit::{self as visit, Visitor}; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for IfLetMutex { arm_visit.visit_expr(if_else); if let Some(arm_mutex) = arm_visit.found_mutex_if_same_as(op_mutex) { - let diag = |diag: &mut DiagnosticBuilder<'_, ()>| { + let diag = |diag: &mut Diag<'_, ()>| { diag.span_label( op_mutex.span, "this Mutex will remain locked for the entire `if let`-block...", diff --git a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs index 746de50c0fa79..a79bf66ae0133 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use std::collections::BTreeMap; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_hir as hir; use rustc_hir::intravisit::{walk_body, walk_expr, walk_inf, walk_ty, Visitor}; use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind}; @@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher { fn suggestion( cx: &LateContext<'_>, - diag: &mut DiagnosticBuilder<'_, ()>, + diag: &mut Diag<'_, ()>, generics_span: Span, generics_suggestion_span: Span, target: &ImplicitHasherType<'_>, diff --git a/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs b/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs index fab8ffedb9493..74582f7f1de23 100644 --- a/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs +++ b/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs @@ -1,11 +1,10 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet; use rustc_errors::{Applicability, SuggestionStyle}; -use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::intravisit::FnKind; +use rustc_hir::def_id::DefId; use rustc_hir::{ - Body, FnDecl, FnRetTy, GenericArg, GenericBound, ImplItem, ImplItemKind, ItemKind, TraitBoundModifier, TraitItem, - TraitItemKind, TyKind, + GenericArg, GenericBound, GenericBounds, ItemKind, PredicateOrigin, TraitBoundModifier, TyKind, TypeBinding, + WherePredicate, }; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; @@ -50,20 +49,17 @@ declare_clippy_lint! { } declare_lint_pass!(ImpliedBoundsInImpls => [IMPLIED_BOUNDS_IN_IMPLS]); -#[allow(clippy::too_many_arguments)] fn emit_lint( cx: &LateContext<'_>, poly_trait: &rustc_hir::PolyTraitRef<'_>, - opaque_ty: &rustc_hir::OpaqueTy<'_>, + bounds: GenericBounds<'_>, index: usize, - // The bindings that were implied + // The bindings that were implied, used for suggestion purposes since removing a bound with associated types + // means we might need to then move it to a different bound implied_bindings: &[rustc_hir::TypeBinding<'_>], - // The original bindings that `implied_bindings` are implied from - implied_by_bindings: &[rustc_hir::TypeBinding<'_>], - implied_by_args: &[GenericArg<'_>], - implied_by_span: Span, + bound: &ImplTraitBound<'_>, ) { - let implied_by = snippet(cx, implied_by_span, ".."); + let implied_by = snippet(cx, bound.span, ".."); span_lint_and_then( cx, @@ -75,10 +71,10 @@ fn emit_lint( // to include the `+` token that is ahead or behind, // so we don't end up with something like `impl + B` or `impl A + ` - let implied_span_extended = if let Some(next_bound) = opaque_ty.bounds.get(index + 1) { + let implied_span_extended = if let Some(next_bound) = bounds.get(index + 1) { poly_trait.span.to(next_bound.span().shrink_to_lo()) } else if index > 0 - && let Some(prev_bound) = opaque_ty.bounds.get(index - 1) + && let Some(prev_bound) = bounds.get(index - 1) { prev_bound.span().shrink_to_hi().to(poly_trait.span.shrink_to_hi()) } else { @@ -93,17 +89,17 @@ fn emit_lint( // If we're going to suggest removing `Deref<..>`, we'll need to put `` on `DerefMut` let omitted_assoc_tys: Vec<_> = implied_bindings .iter() - .filter(|binding| !implied_by_bindings.iter().any(|b| b.ident == binding.ident)) + .filter(|binding| !bound.bindings.iter().any(|b| b.ident == binding.ident)) .collect(); if !omitted_assoc_tys.is_empty() { // `<>` needs to be added if there aren't yet any generic arguments or bindings - let needs_angle_brackets = implied_by_args.is_empty() && implied_by_bindings.is_empty(); - let insert_span = match (implied_by_args, implied_by_bindings) { + let needs_angle_brackets = bound.args.is_empty() && bound.bindings.is_empty(); + let insert_span = match (bound.args, bound.bindings) { ([.., arg], [.., binding]) => arg.span().max(binding.span).shrink_to_hi(), ([.., arg], []) => arg.span().shrink_to_hi(), ([], [.., binding]) => binding.span.shrink_to_hi(), - ([], []) => implied_by_span.shrink_to_hi(), + ([], []) => bound.span.shrink_to_hi(), }; let mut associated_tys_sugg = if needs_angle_brackets { @@ -223,111 +219,135 @@ fn is_same_generics<'tcx>( }) } -fn check(cx: &LateContext<'_>, decl: &FnDecl<'_>) { - if let FnRetTy::Return(ty) = decl.output - &&let TyKind::OpaqueDef(item_id, ..) = ty.kind - && let item = cx.tcx.hir().item(item_id) - && let ItemKind::OpaqueTy(opaque_ty) = item.kind - // Very often there is only a single bound, e.g. `impl Deref<..>`, in which case - // we can avoid doing a bunch of stuff unnecessarily. - && opaque_ty.bounds.len() > 1 - { - // Get all the (implied) trait predicates in the bounds. - // For `impl Deref + DerefMut` this will contain [`Deref`]. - // The implied `Deref` comes from `DerefMut` because `trait DerefMut: Deref {}`. - // N.B. (G)ATs are fine to disregard, because they must be the same for all of its supertraits. - // Example: - // `impl Deref + DerefMut` is not allowed. - // `DerefMut::Target` needs to match `Deref::Target`. - let implied_bounds: Vec<_> = opaque_ty - .bounds - .iter() - .filter_map(|bound| { - if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound - && let [.., path] = poly_trait.trait_ref.path.segments - && poly_trait.bound_generic_params.is_empty() - && let Some(trait_def_id) = path.res.opt_def_id() - && let predicates = cx.tcx.super_predicates_of(trait_def_id).predicates - && !predicates.is_empty() - // If the trait has no supertrait, there is nothing to add. - { - Some((bound.span(), path, predicates, trait_def_id)) - } else { - None - } - }) - .collect(); +struct ImplTraitBound<'tcx> { + /// The span of the bound in the `impl Trait` type + span: Span, + /// The predicates defined in the trait referenced by this bound. This also contains the actual + /// supertrait bounds + predicates: &'tcx [(ty::Clause<'tcx>, Span)], + /// The `DefId` of the trait being referenced by this bound + trait_def_id: DefId, + /// The generic arguments on the `impl Trait` bound + args: &'tcx [GenericArg<'tcx>], + /// The associated types on this bound + bindings: &'tcx [TypeBinding<'tcx>], +} - // Lint all bounds in the `impl Trait` type that are also in the `implied_bounds` vec. - // This involves some extra logic when generic arguments are present, since - // simply comparing trait `DefId`s won't be enough. We also need to compare the generics. - for (index, bound) in opaque_ty.bounds.iter().enumerate() { +/// Given an `impl Trait` type, gets all the supertraits from each bound ("implied bounds"). +/// +/// For `impl Deref + DerefMut + Eq` this returns `[Deref, PartialEq]`. +/// The `Deref` comes from `DerefMut` because `trait DerefMut: Deref {}`, and `PartialEq` comes from +/// `Eq`. +fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) -> Vec> { + bounds + .iter() + .filter_map(|bound| { if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound && let [.., path] = poly_trait.trait_ref.path.segments - && let implied_args = path.args.map_or([].as_slice(), |a| a.args) - && let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings) - && let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id() - && let Some((implied_by_span, implied_by_args, implied_by_bindings)) = - implied_bounds - .iter() - .find_map(|&(span, implied_by_path, preds, implied_by_def_id)| { - let implied_by_args = implied_by_path.args.map_or([].as_slice(), |a| a.args); - let implied_by_bindings = implied_by_path.args.map_or([].as_slice(), |a| a.bindings); + && poly_trait.bound_generic_params.is_empty() + && let Some(trait_def_id) = path.res.opt_def_id() + && let predicates = cx.tcx.super_predicates_of(trait_def_id).predicates + // If the trait has no supertrait, there is no need to collect anything from that bound + && !predicates.is_empty() + { + Some(ImplTraitBound { + predicates, + args: path.args.map_or([].as_slice(), |p| p.args), + bindings: path.args.map_or([].as_slice(), |p| p.bindings), + trait_def_id, + span: bound.span(), + }) + } else { + None + } + }) + .collect() +} - preds.iter().find_map(|(clause, _)| { - if let ClauseKind::Trait(tr) = clause.kind().skip_binder() - && tr.def_id() == def_id - && is_same_generics( - cx.tcx, - tr.trait_ref.args, - implied_by_args, - implied_args, - implied_by_def_id, - def_id, - ) - { - Some((span, implied_by_args, implied_by_bindings)) - } else { - None - } - }) - }) +/// Given a bound in an `impl Trait` type, looks for a trait in the set of supertraits (previously +/// collected in [`collect_supertrait_bounds`]) that matches (same trait and generic arguments). +fn find_bound_in_supertraits<'a, 'tcx>( + cx: &LateContext<'tcx>, + trait_def_id: DefId, + args: &'tcx [GenericArg<'tcx>], + bounds: &'a [ImplTraitBound<'tcx>], +) -> Option<&'a ImplTraitBound<'tcx>> { + bounds.iter().find(|bound| { + bound.predicates.iter().any(|(clause, _)| { + if let ClauseKind::Trait(tr) = clause.kind().skip_binder() + && tr.def_id() == trait_def_id { - emit_lint( - cx, - poly_trait, - opaque_ty, - index, - implied_bindings, - implied_by_bindings, - implied_by_args, - implied_by_span, - ); + is_same_generics( + cx.tcx, + tr.trait_ref.args, + bound.args, + args, + bound.trait_def_id, + trait_def_id, + ) + } else { + false } + }) + }) +} + +fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) { + if bounds.len() == 1 { + // Very often there is only a single bound, e.g. `impl Deref<..>`, in which case + // we can avoid doing a bunch of stuff unnecessarily; there will trivially be + // no duplicate bounds + return; + } + + let supertraits = collect_supertrait_bounds(cx, bounds); + + // Lint all bounds in the `impl Trait` type that we've previously also seen in the set of + // supertraits of each of the bounds. + // This involves some extra logic when generic arguments are present, since + // simply comparing trait `DefId`s won't be enough. We also need to compare the generics. + for (index, bound) in bounds.iter().enumerate() { + if let GenericBound::Trait(poly_trait, TraitBoundModifier::None) = bound + && let [.., path] = poly_trait.trait_ref.path.segments + && let implied_args = path.args.map_or([].as_slice(), |a| a.args) + && let implied_bindings = path.args.map_or([].as_slice(), |a| a.bindings) + && let Some(def_id) = poly_trait.trait_ref.path.res.opt_def_id() + && let Some(bound) = find_bound_in_supertraits(cx, def_id, implied_args, &supertraits) + // If the implied bound has a type binding that also exists in the implied-by trait, + // then we shouldn't lint. See #11880 for an example. + && let assocs = cx.tcx.associated_items(bound.trait_def_id) + && !implied_bindings.iter().any(|binding| { + assocs + .filter_by_name_unhygienic(binding.ident.name) + .next() + .is_some_and(|assoc| assoc.kind == ty::AssocKind::Type) + }) + { + emit_lint(cx, poly_trait, bounds, index, implied_bindings, bound); } } } -impl LateLintPass<'_> for ImpliedBoundsInImpls { - fn check_fn( - &mut self, - cx: &LateContext<'_>, - _: FnKind<'_>, - decl: &FnDecl<'_>, - _: &Body<'_>, - _: Span, - _: LocalDefId, - ) { - check(cx, decl); - } - fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) { - if let TraitItemKind::Fn(sig, ..) = &item.kind { - check(cx, sig.decl); +impl<'tcx> LateLintPass<'tcx> for ImpliedBoundsInImpls { + fn check_generics(&mut self, cx: &LateContext<'tcx>, generics: &rustc_hir::Generics<'tcx>) { + for predicate in generics.predicates { + if let WherePredicate::BoundPredicate(predicate) = predicate + // In theory, the origin doesn't really matter, + // we *could* also lint on explicit where clauses written out by the user, + // not just impl trait desugared ones, but that contradicts with the lint name... + && let PredicateOrigin::ImplTrait = predicate.origin + { + check(cx, predicate.bounds); + } } } - fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &ImplItem<'_>) { - if let ImplItemKind::Fn(sig, ..) = &item.kind { - check(cx, sig.decl); + + fn check_ty(&mut self, cx: &LateContext<'_>, ty: &rustc_hir::Ty<'_>) { + if let TyKind::OpaqueDef(item_id, ..) = ty.kind + && let item = cx.tcx.hir().item(item_id) + && let ItemKind::OpaqueTy(opaque_ty) = item.kind + { + check(cx, opaque_ty.bounds); } } } diff --git a/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs b/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs index f2f0e7d426628..cd000fcd18449 100644 --- a/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs +++ b/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs @@ -1,14 +1,15 @@ use clippy_config::msrvs::Msrv; use clippy_utils::diagnostics::span_lint; +use clippy_utils::is_in_test_function; use rustc_attr::{StabilityLevel, StableSince}; use rustc_data_structures::fx::FxHashMap; -use rustc_hir::{Expr, ExprKind}; +use rustc_hir::{Expr, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TyCtxt; use rustc_semver::RustcVersion; use rustc_session::impl_lint_pass; use rustc_span::def_id::DefId; -use rustc_span::Span; +use rustc_span::{ExpnKind, Span}; declare_clippy_lint! { /// ### What it does @@ -81,13 +82,18 @@ impl IncompatibleMsrv { version } - fn emit_lint_if_under_msrv(&mut self, cx: &LateContext<'_>, def_id: DefId, span: Span) { + fn emit_lint_if_under_msrv(&mut self, cx: &LateContext<'_>, def_id: DefId, node: HirId, span: Span) { if def_id.is_local() { // We don't check local items since their MSRV is supposed to always be valid. return; } let version = self.get_def_id_version(cx.tcx, def_id); - if self.msrv.meets(version) { + if self.msrv.meets(version) || is_in_test_function(cx.tcx, node) { + return; + } + if let ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) = span.ctxt().outer_expn_data().kind { + // Desugared expressions get to cheat and stability is ignored. + // Intentionally not using `.from_expansion()`, since we do still care about macro expansions return; } self.emit_lint_for(cx, span, version); @@ -117,14 +123,14 @@ impl<'tcx> LateLintPass<'tcx> for IncompatibleMsrv { match expr.kind { ExprKind::MethodCall(_, _, _, span) => { if let Some(method_did) = cx.typeck_results().type_dependent_def_id(expr.hir_id) { - self.emit_lint_if_under_msrv(cx, method_did, span); + self.emit_lint_if_under_msrv(cx, method_did, expr.hir_id, span); } }, ExprKind::Call(call, [_]) => { if let ExprKind::Path(qpath) = call.kind && let Some(path_def_id) = cx.qpath_res(&qpath, call.hir_id).opt_def_id() { - self.emit_lint_if_under_msrv(cx, path_def_id, call.span); + self.emit_lint_if_under_msrv(cx, path_def_id, expr.hir_id, call.span); } }, _ => {}, diff --git a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs index 41e9d5b1c2e9d..5b5eb355f86cd 100644 --- a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs +++ b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs @@ -255,7 +255,9 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { && let hir::Node::Expr(maybe_addrof_expr) = cx.tcx.parent_hir_node(parent_id) && let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind { - use_info.index_use.push((index_value, cx.tcx.hir().span(parent_expr.hir_id))); + use_info + .index_use + .push((index_value, cx.tcx.hir().span(parent_expr.hir_id))); return; } diff --git a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs index 391db0b0df726..35fcd8cdd3547 100644 --- a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs +++ b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs @@ -174,6 +174,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { // only `usize` index is legal in rust array index // leave other type to rustc if let Constant::Int(off) = constant + && off <= usize::MAX as u128 && let ty::Uint(utype) = cx.typeck_results().expr_ty(index).kind() && *utype == ty::UintTy::Usize && let ty::Array(_, s) = ty.kind() diff --git a/src/tools/clippy/clippy_lints/src/item_name_repetitions.rs b/src/tools/clippy/clippy_lints/src/item_name_repetitions.rs index 276c1abb60cd5..0b4c416d94db0 100644 --- a/src/tools/clippy/clippy_lints/src/item_name_repetitions.rs +++ b/src/tools/clippy/clippy_lints/src/item_name_repetitions.rs @@ -385,7 +385,6 @@ impl LateLintPass<'_> for ItemNameRepetitions { assert!(last.is_some()); } - #[expect(clippy::similar_names)] fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { let item_name = item.ident.name.as_str(); let item_camel = to_camel_case(item_name); diff --git a/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs b/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs index b9fad726511c5..32ae6be568735 100644 --- a/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs +++ b/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs @@ -1,5 +1,4 @@ use clippy_utils::diagnostics::span_lint; -use clippy_utils::get_parent_node; use clippy_utils::ty::implements_trait; use rustc_hir::def_id::LocalDefId; use rustc_hir::{FnSig, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind}; @@ -56,8 +55,8 @@ impl<'tcx> LateLintPass<'tcx> for IterNotReturningIterator { let name = item.ident.name.as_str(); if matches!(name, "iter" | "iter_mut") && !matches!( - get_parent_node(cx.tcx, item.hir_id()), - Some(Node::Item(Item { kind: ItemKind::Impl(i), .. })) if i.of_trait.is_some() + cx.tcx.parent_hir_node(item.hir_id()), + Node::Item(Item { kind: ItemKind::Impl(i), .. }) if i.of_trait.is_some() ) { if let ImplItemKind::Fn(fn_sig, _) = &item.kind { diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index 14bd82f9c97ea..76e759683145e 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -14,7 +14,7 @@ clippy::missing_docs_in_private_items, clippy::must_use_candidate, rustc::diagnostic_outside_of_impl, - rustc::untranslatable_diagnostic, + rustc::untranslatable_diagnostic )] #![warn(trivial_casts, trivial_numeric_casts)] // warn on lints, that are included in `rust-lang/rust`s bootstrap @@ -231,6 +231,7 @@ mod missing_trait_methods; mod mixed_read_write_in_expression; mod module_style; mod multi_assignments; +mod multiple_bound_locations; mod multiple_unsafe_ops_per_block; mod mut_key; mod mut_mut; @@ -1067,7 +1068,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { store.register_late_pass(move |_| { Box::new(single_call_fn::SingleCallFn { avoid_breaking_exported_api, - def_id_to_usage: rustc_data_structures::fx::FxHashMap::default(), + def_id_to_usage: rustc_data_structures::fx::FxIndexMap::default(), }) }); store.register_early_pass(move || { @@ -1116,6 +1117,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) { }); store.register_late_pass(move |_| Box::new(incompatible_msrv::IncompatibleMsrv::new(msrv()))); store.register_late_pass(|_| Box::new(to_string_trait_impl::ToStringTraitImpl)); + store.register_early_pass(|| Box::new(multiple_bound_locations::MultipleBoundLocations)); // add lints here, do not remove this comment, it's used in `new_lint` } diff --git a/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs b/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs index 5e099f1e76f86..5b5bb88c17908 100644 --- a/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs @@ -1,17 +1,18 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::{fn_def_id, is_lint_allowed}; +use clippy_utils::{fn_def_id, is_from_proc_macro, is_lint_allowed}; use hir::intravisit::{walk_expr, Visitor}; use hir::{Expr, ExprKind, FnRetTy, FnSig, Node}; use rustc_ast::Label; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_lint::LateContext; +use rustc_lint::{LateContext, LintContext}; +use rustc_middle::lint::in_external_macro; use super::INFINITE_LOOP; pub(super) fn check<'tcx>( cx: &LateContext<'tcx>, - expr: &Expr<'_>, + expr: &Expr<'tcx>, loop_block: &'tcx hir::Block<'_>, label: Option) { | ^ @@ -8,19 +8,19 @@ LL | fn warn_arg(x: Box) { = 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 + --> tests/ui/boxed_local.rs:123:12 | LL | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ error: local variable doesn't need to be boxed here - --> $DIR/boxed_local.rs:188:44 + --> tests/ui/boxed_local.rs:188:44 | LL | fn default_impl_x(self: Box, x: Box) -> u32 { | ^ error: local variable doesn't need to be boxed here - --> $DIR/boxed_local.rs:196:16 + --> tests/ui/boxed_local.rs:196:16 | LL | fn foo(x: Box) {} | ^ diff --git a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr index 8223df0fe7bab..68ebb6ad7811a 100644 --- a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr +++ b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_bottom.stderr @@ -1,5 +1,5 @@ error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:35:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:35:5 | LL | / let result = false; LL | | @@ -11,7 +11,7 @@ LL | | }; | = note: the end suggestion probably needs some adjustments to use the expression result correctly note: the lint level is defined here - --> $DIR/shared_at_bottom.rs:1:36 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:1:36 | LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL ~ result; | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:55:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:55:5 | LL | / println!("Same end of block"); LL | | @@ -40,7 +40,7 @@ LL + println!("Same end of block"); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:73:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:73:5 | LL | / println!( LL | | @@ -61,7 +61,7 @@ LL + ); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:86:9 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:86:9 | LL | / println!("Hello World"); LL | | @@ -75,7 +75,7 @@ LL + println!("Hello World"); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:103:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:103:5 | LL | / let later_used_value = "A string value"; LL | | @@ -94,7 +94,7 @@ LL + println!("{}", later_used_value); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:117:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:117:5 | LL | / let simple_examples = "I now identify as a &str :)"; LL | | @@ -112,7 +112,7 @@ LL + println!("This is the new simple_example: {}", simple_examples); | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:183:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:183:5 | LL | / x << 2 LL | | @@ -128,7 +128,7 @@ LL ~ x << 2; | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:192:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:192:5 | LL | / x * 4 LL | | @@ -144,7 +144,7 @@ LL + x * 4 | error: all if blocks contain the same code at the end - --> $DIR/shared_at_bottom.rs:206:44 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:206:44 | LL | if x == 17 { b = 1; a = 0x99; } else { a = 0x99; } | ^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top.stderr b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top.stderr index 317d1577226ca..0d4e19be1f523 100644 --- a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top.stderr +++ b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top.stderr @@ -1,12 +1,12 @@ error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:11:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:11:5 | LL | / if true { LL | | println!("Hello World!"); | |_________________________________^ | note: the lint level is defined here - --> $DIR/shared_at_top.rs:1:9 + --> tests/ui/branches_sharing_code/shared_at_top.rs:1:9 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL + if true { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:21:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:21:5 | LL | / if x == 0 { LL | | let y = 9; @@ -35,7 +35,7 @@ LL + if x == 0 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:43:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:43:5 | LL | / let _ = if x == 7 { LL | | @@ -49,7 +49,7 @@ LL + let _ = if x == 7 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:62:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:62:5 | LL | / if x == 10 { LL | | let used_value_name = "Different type"; @@ -65,7 +65,7 @@ LL + if x == 10 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:77:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:77:5 | LL | / if x == 11 { LL | | @@ -82,7 +82,7 @@ LL + if x == 11 { | error: all if blocks contain the same code at the start - --> $DIR/shared_at_top.rs:94:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:94:5 | LL | / if x == 2020 { LL | | @@ -98,7 +98,7 @@ LL + if x == 2020 { | error: this `if` has identical blocks - --> $DIR/shared_at_top.rs:103:18 + --> tests/ui/branches_sharing_code/shared_at_top.rs:103:18 | LL | if x == 2019 { | __________________^ @@ -107,7 +107,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/shared_at_top.rs:105:12 + --> tests/ui/branches_sharing_code/shared_at_top.rs:105:12 | LL | } else { | ____________^ @@ -115,7 +115,7 @@ LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual"); LL | | } | |_____^ note: the lint level is defined here - --> $DIR/shared_at_top.rs:1:40 + --> tests/ui/branches_sharing_code/shared_at_top.rs:1:40 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr index 74495fca8ab75..b79307f96778a 100644 --- a/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr +++ b/src/tools/clippy/tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr @@ -1,5 +1,5 @@ error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:17:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:17:5 | LL | / if x == 7 { LL | | @@ -9,13 +9,13 @@ LL | | let _overlap_end = 2 * t; | |_________________________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:30:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:30:5 | LL | / let _u = 9; LL | | } | |_____^ note: the lint level is defined here - --> $DIR/shared_at_top_and_bottom.rs:1:9 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:1:9 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL + let _u = 9; | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:34:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:34:5 | LL | / if x == 99 { LL | | @@ -43,7 +43,7 @@ LL | | let _overlap_middle = r * r; | |____________________________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:46:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:46:5 | LL | / let _overlap_end = r * r * r; LL | | let z = "end"; @@ -65,7 +65,7 @@ LL + let z = "end"; | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:64:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:64:5 | LL | / if (x > 7 && y < 13) || (x + y) % 2 == 1 { LL | | @@ -75,7 +75,7 @@ LL | | let e_id = gen_id(a, b); | |________________________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:85:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:85:5 | LL | / let pack = DataPack { LL | | id: e_id, @@ -105,7 +105,7 @@ LL + process_data(pack); | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:98:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:98:5 | LL | / let _ = if x == 7 { LL | | @@ -113,7 +113,7 @@ LL | | let _ = 19; | |___________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:108:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:108:5 | LL | / x << 2 LL | | }; @@ -131,7 +131,7 @@ LL ~ x << 2; | error: all if blocks contain the same code at both the start and the end - --> $DIR/shared_at_top_and_bottom.rs:111:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:111:5 | LL | / if x == 9 { LL | | @@ -139,7 +139,7 @@ LL | | let _ = 17; | |___________________^ | note: this code is shared at the end - --> $DIR/shared_at_top_and_bottom.rs:121:5 + --> tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs:121:5 | LL | / x * 4 LL | | } diff --git a/src/tools/clippy/tests/ui/branches_sharing_code/valid_if_blocks.stderr b/src/tools/clippy/tests/ui/branches_sharing_code/valid_if_blocks.stderr index 0daf2ff6967cd..4c7e4141b629c 100644 --- a/src/tools/clippy/tests/ui/branches_sharing_code/valid_if_blocks.stderr +++ b/src/tools/clippy/tests/ui/branches_sharing_code/valid_if_blocks.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:109:14 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:109:14 | LL | if false { | ______________^ @@ -7,20 +7,20 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:110:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:110:12 | LL | } else { | ____________^ LL | | } | |_____^ note: the lint level is defined here - --> $DIR/valid_if_blocks.rs:1:40 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:1:40 | LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:121:15 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:121:15 | LL | if x == 0 { | _______________^ @@ -31,7 +31,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:125:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:125:12 | LL | } else { | ____________^ @@ -42,19 +42,19 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:133:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:133:23 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ | note: same as this - --> $DIR/valid_if_blocks.rs:133:34 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:133:34 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:140:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:140:23 | LL | } else if x == 68 { | _______________________^ @@ -65,7 +65,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:144:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:144:12 | LL | } else { | ____________^ @@ -76,7 +76,7 @@ LL | | }; | |_____^ error: this `if` has identical blocks - --> $DIR/valid_if_blocks.rs:153:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:153:23 | LL | } else if x == 68 { | _______________________^ @@ -85,7 +85,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/valid_if_blocks.rs:155:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:155:12 | LL | } else { | ____________^ diff --git a/src/tools/clippy/tests/ui/builtin_type_shadow.stderr b/src/tools/clippy/tests/ui/builtin_type_shadow.stderr index e051c00eb8d2c..1e15cdee772a2 100644 --- a/src/tools/clippy/tests/ui/builtin_type_shadow.stderr +++ b/src/tools/clippy/tests/ui/builtin_type_shadow.stderr @@ -1,5 +1,5 @@ error: this generic shadows the built-in type `u32` - --> $DIR/builtin_type_shadow.rs:4:8 + --> tests/ui/builtin_type_shadow.rs:4:8 | LL | fn foo(a: u32) -> u32 { | ^^^ @@ -8,7 +8,7 @@ LL | fn foo(a: u32) -> u32 { = help: to override `-D warnings` add `#[allow(clippy::builtin_type_shadow)]` error[E0308]: mismatched types - --> $DIR/builtin_type_shadow.rs:5:5 + --> tests/ui/builtin_type_shadow.rs:5:5 | LL | fn foo(a: u32) -> u32 { | --- --- expected `u32` because of return type diff --git a/src/tools/clippy/tests/ui/bytecount.stderr b/src/tools/clippy/tests/ui/bytecount.stderr index 39007f9d10aa2..d1a73fe983584 100644 --- a/src/tools/clippy/tests/ui/bytecount.stderr +++ b/src/tools/clippy/tests/ui/bytecount.stderr @@ -1,23 +1,23 @@ error: you appear to be counting bytes the naive way - --> $DIR/bytecount.rs:10:13 + --> tests/ui/bytecount.rs:10:13 | LL | let _ = x.iter().filter(|&&a| a == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, 0)` | note: the lint level is defined here - --> $DIR/bytecount.rs:5:8 + --> tests/ui/bytecount.rs:5:8 | LL | #[deny(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: you appear to be counting bytes the naive way - --> $DIR/bytecount.rs:14:13 + --> tests/ui/bytecount.rs:14:13 | LL | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count((&x[..]), 0)` error: you appear to be counting bytes the naive way - --> $DIR/bytecount.rs:32:13 + --> tests/ui/bytecount.rs:32:13 | LL | let _ = x.iter().filter(|a| b + 1 == **a).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, b + 1)` 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 db0bb4099de9f..b80f3af18f780 100644 --- a/src/tools/clippy/tests/ui/bytes_count_to_len.stderr +++ b/src/tools/clippy/tests/ui/bytes_count_to_len.stderr @@ -1,5 +1,5 @@ error: using long and hard to read `.bytes().count()` - --> $DIR/bytes_count_to_len.rs:7:13 + --> tests/ui/bytes_count_to_len.rs:7:13 | LL | let _ = String::from("foo").bytes().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `String::from("foo").len()` @@ -8,19 +8,19 @@ LL | let _ = String::from("foo").bytes().count(); = 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 + --> tests/ui/bytes_count_to_len.rs:10:13 | LL | let _ = s1.bytes().count(); | ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s1.len()` error: using long and hard to read `.bytes().count()` - --> $DIR/bytes_count_to_len.rs:13:13 + --> tests/ui/bytes_count_to_len.rs:13:13 | LL | let _ = "foo".bytes().count(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `"foo".len()` error: using long and hard to read `.bytes().count()` - --> $DIR/bytes_count_to_len.rs:16:13 + --> tests/ui/bytes_count_to_len.rs:16:13 | LL | let _ = s2.bytes().count(); | ^^^^^^^^^^^^^^^^^^ help: consider calling `.len()` instead: `s2.len()` diff --git a/src/tools/clippy/tests/ui/bytes_nth.stderr b/src/tools/clippy/tests/ui/bytes_nth.stderr index 574bfaac193db..c6f21576c3dbf 100644 --- a/src/tools/clippy/tests/ui/bytes_nth.stderr +++ b/src/tools/clippy/tests/ui/bytes_nth.stderr @@ -1,5 +1,5 @@ error: called `.bytes().nth()` on a `String` - --> $DIR/bytes_nth.rs:6:13 + --> tests/ui/bytes_nth.rs:6:13 | LL | let _ = s.bytes().nth(3); | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3).copied()` @@ -8,13 +8,13 @@ LL | let _ = s.bytes().nth(3); = help: to override `-D warnings` add `#[allow(clippy::bytes_nth)]` error: called `.bytes().nth().unwrap()` on a `String` - --> $DIR/bytes_nth.rs:7:14 + --> tests/ui/bytes_nth.rs:7:14 | LL | let _ = &s.bytes().nth(3).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.as_bytes()[3]` error: called `.bytes().nth()` on a `str` - --> $DIR/bytes_nth.rs:8:13 + --> tests/ui/bytes_nth.rs:8:13 | LL | let _ = s[..].bytes().nth(3); | ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..].as_bytes().get(3).copied()` diff --git a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.fixed b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.fixed index a816224c91c8d..8b4a165a97c68 100644 --- a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.fixed +++ b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.fixed @@ -63,4 +63,9 @@ fn main() { let _ = String::new().ends_with("a.ext"); let _ = "str".ends_with("a.extA"); TestStruct {}.ends_with("a.ext"); + + // Shouldn't fail if the extension has no ascii letter + let _ = String::new().ends_with(".123"); + let _ = "str".ends_with(".123"); + TestStruct {}.ends_with(".123"); } diff --git a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs index 994de2805f742..e4b8178110b6c 100644 --- a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs +++ b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs @@ -51,4 +51,9 @@ fn main() { let _ = String::new().ends_with("a.ext"); let _ = "str".ends_with("a.extA"); TestStruct {}.ends_with("a.ext"); + + // Shouldn't fail if the extension has no ascii letter + let _ = String::new().ends_with(".123"); + let _ = "str".ends_with(".123"); + TestStruct {}.ends_with(".123"); } 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 49c840bd76924..d203f91b8323f 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 @@ -1,5 +1,5 @@ error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:13:5 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:13:5 | LL | filename.ends_with(".rs") | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL + .map_or(false, |ext| ext.eq_ignore_ascii_case("rs")) | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:18:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:18:13 | LL | let _ = String::new().ends_with(".ext12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:19:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:19:13 | LL | let _ = "str".ends_with(".ext12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:23:17 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:23:17 | LL | let _ = "str".ends_with(".ext12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("ext12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:30:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:30:13 | LL | let _ = String::new().ends_with(".EXT12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("EXT12")); | error: case-sensitive file extension comparison - --> $DIR/case_sensitive_file_extension_comparisons.rs:31:13 + --> tests/ui/case_sensitive_file_extension_comparisons.rs:31:13 | LL | let _ = "str".ends_with(".EXT12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/cast.rs b/src/tools/clippy/tests/ui/cast.rs index e9476c80ccb81..a7331ddc7d0e7 100644 --- a/src/tools/clippy/tests/ui/cast.rs +++ b/src/tools/clippy/tests/ui/cast.rs @@ -1,6 +1,7 @@ //@no-rustfix #![feature(repr128)] +#![feature(isqrt)] #![allow(incomplete_features)] #![warn( clippy::cast_precision_loss, @@ -116,20 +117,40 @@ fn main() { i64::MAX as u64; i128::MAX as u128; - (-1i8).abs() as u8; - (-1i16).abs() as u16; - (-1i32).abs() as u32; + (-1i8).saturating_abs() as u8; + // abs() can return a negative value in release builds + (i8::MIN).abs() as u8; + //~^ ERROR: casting `i8` to `u8` may lose the sign of the value + (-1i16).saturating_abs() as u16; + (-1i32).saturating_abs() as u32; (-1i64).abs() as u64; (-1isize).abs() as usize; (-1i8).checked_abs().unwrap() as u8; + (i8::MIN).checked_abs().unwrap() as u8; (-1i16).checked_abs().unwrap() as u16; (-1i32).checked_abs().unwrap() as u32; - (-1i64).checked_abs().unwrap() as u64; - (-1isize).checked_abs().unwrap() as usize; + // SAFETY: -1 is a small number which will always return Some + (unsafe { (-1i64).checked_abs().unwrap_unchecked() }) as u64; + (-1isize).checked_abs().expect("-1 is a small number") as usize; + + (-1i8).isqrt() as u8; + (i8::MIN).isqrt() as u8; + (-1i16).isqrt() as u16; + (-1i32).isqrt() as u32; + (-1i64).isqrt() as u64; + (-1isize).isqrt() as usize; + + (-1i8).checked_isqrt().unwrap() as u8; + (i8::MIN).checked_isqrt().unwrap() as u8; + (-1i16).checked_isqrt().unwrap() as u16; + (-1i32).checked_isqrt().unwrap() as u32; + // SAFETY: -1 is a small number which will always return Some + (unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }) as u64; + (-1isize).checked_isqrt().expect("-1 is a small number") as usize; (-1i8).rem_euclid(1i8) as u8; - (-1i8).rem_euclid(1i8) as u16; + (-1i8).wrapping_rem_euclid(1i8) as u16; (-1i16).rem_euclid(1i16) as u16; (-1i16).rem_euclid(1i16) as u32; (-1i32).rem_euclid(1i32) as u32; @@ -138,7 +159,7 @@ fn main() { (-1i64).rem_euclid(1i64) as u128; (-1isize).rem_euclid(1isize) as usize; (1i8).rem_euclid(-1i8) as u8; - (1i8).rem_euclid(-1i8) as u16; + (1i8).wrapping_rem_euclid(-1i8) as u16; (1i16).rem_euclid(-1i16) as u16; (1i16).rem_euclid(-1i16) as u32; (1i32).rem_euclid(-1i32) as u32; @@ -371,14 +392,25 @@ fn issue11642() { let x = x as i32; (x * x) as u32; x.pow(2) as u32; - (-2_i32).pow(2) as u32 + (-2_i32).saturating_pow(2) as u32 } let _a = |x: i32| -> u32 { (x * x * x * x) as u32 }; + (2_i32).checked_pow(3).unwrap() as u32; (-2_i32).pow(3) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + (3_i32 % 2) as u32; + (3_i32 % -2) as u32; + (-5_i32 % 2) as u32; + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + (-5_i32 % -2) as u32; + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + (2_i32 >> 1) as u32; + (-2_i32 >> 1) as u32; + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value + let x: i32 = 10; (x * x) as u32; (x * x * x) as u32; @@ -387,12 +419,22 @@ fn issue11642() { let y: i16 = -2; (y * y * y * y * -2) as u16; //~^ ERROR: casting `i16` to `u16` may lose the sign of the value - (y * y * y * y * 2) as u16; - (y * y * y * 2) as u16; + (y * y * y / y * 2) as u16; + (y * y / y * 2) as u16; //~^ ERROR: casting `i16` to `u16` may lose the sign of the value - (y * y * y * -2) as u16; + (y / y * y * -2) as u16; //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + (y + y + y + -2) as u16; + //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + (y + y + y + 2) as u16; + //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + + let z: i16 = 2; + (z + -2) as u16; + //~^ ERROR: casting `i16` to `u16` may lose the sign of the value + (z + z + 2) as u16; + fn foo(a: i32, b: i32, c: i32) -> u32 { (a * a * b * b * c * c) as u32; (a * b * c) as u32; @@ -409,8 +451,9 @@ fn issue11642() { //~^ ERROR: casting `i32` to `u32` may lose the sign of the value (a / b + b * c) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value - a.pow(3) as u32; + a.saturating_pow(3) as u32; //~^ ERROR: casting `i32` to `u32` may lose the sign of the value (a.abs() * b.pow(2) / c.abs()) as u32 + //~^ ERROR: casting `i32` to `u32` may lose the sign of the value } } diff --git a/src/tools/clippy/tests/ui/cast.stderr b/src/tools/clippy/tests/ui/cast.stderr index 4e37af7f37891..dd5d339b81b2a 100644 --- a/src/tools/clippy/tests/ui/cast.stderr +++ b/src/tools/clippy/tests/ui/cast.stderr @@ -1,5 +1,5 @@ error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast.rs:16:5 + --> tests/ui/cast.rs:17:5 | LL | x0 as f32; | ^^^^^^^^^ @@ -8,37 +8,37 @@ LL | x0 as f32; = 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 + --> tests/ui/cast.rs:21:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast.rs:22:5 + --> tests/ui/cast.rs:23:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast.rs:25:5 + --> tests/ui/cast.rs:26:5 | LL | x2 as f32; | ^^^^^^^^^ error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast.rs:28:5 + --> tests/ui/cast.rs:29:5 | LL | x3 as f32; | ^^^^^^^^^ error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast.rs:30:5 + --> tests/ui/cast.rs:31:5 | LL | x3 as f64; | ^^^^^^^^^ error: casting `f32` to `i32` may truncate the value - --> $DIR/cast.rs:33:5 + --> tests/ui/cast.rs:34:5 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | 1f32 as i32; = 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 + --> tests/ui/cast.rs:36:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | 1f32 as u32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:35:5 + --> tests/ui/cast.rs:36:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | 1f32 as u32; = 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 + --> tests/ui/cast.rs:40:5 | LL | 1f64 as f32; | ^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | 1f64 as f32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `i32` to `i8` may truncate the value - --> $DIR/cast.rs:41:5 + --> tests/ui/cast.rs:42:5 | LL | 1i32 as i8; | ^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | i8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u8` may truncate the value - --> $DIR/cast.rs:43:5 + --> tests/ui/cast.rs:44:5 | LL | 1i32 as u8; | ^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | u8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `f64` to `isize` may truncate the value - --> $DIR/cast.rs:45:5 + --> tests/ui/cast.rs:46:5 | LL | 1f64 as isize; | ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | 1f64 as isize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may truncate the value - --> $DIR/cast.rs:47:5 + --> tests/ui/cast.rs:48:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ @@ -113,13 +113,13 @@ LL | 1f64 as usize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may lose the sign of the value - --> $DIR/cast.rs:47:5 + --> tests/ui/cast.rs:48:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting `u32` to `u16` may truncate the value - --> $DIR/cast.rs:50:5 + --> tests/ui/cast.rs:51:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL | u16::try_from(1f32 as u32); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `f32` to `u32` may truncate the value - --> $DIR/cast.rs:50:5 + --> tests/ui/cast.rs:51:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ @@ -139,13 +139,13 @@ LL | 1f32 as u32 as u16; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:50:5 + --> tests/ui/cast.rs:51:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ error: casting `i32` to `i8` may truncate the value - --> $DIR/cast.rs:55:22 + --> tests/ui/cast.rs:56:22 | LL | let _x: i8 = 1i32 as _; | ^^^^^^^^^ @@ -157,7 +157,7 @@ LL | let _x: i8 = 1i32.try_into(); | ~~~~~~~~~~~~~~~ error: casting `f32` to `i32` may truncate the value - --> $DIR/cast.rs:57:9 + --> tests/ui/cast.rs:58:9 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | 1f32 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `i32` may truncate the value - --> $DIR/cast.rs:59:9 + --> tests/ui/cast.rs:60:9 | LL | 1f64 as i32; | ^^^^^^^^^^^ @@ -173,7 +173,7 @@ LL | 1f64 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may truncate the value - --> $DIR/cast.rs:61:9 + --> tests/ui/cast.rs:62:9 | LL | 1f32 as u8; | ^^^^^^^^^^ @@ -181,13 +181,13 @@ LL | 1f32 as u8; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may lose the sign of the value - --> $DIR/cast.rs:61:9 + --> tests/ui/cast.rs:62:9 | LL | 1f32 as u8; | ^^^^^^^^^^ error: casting `u8` to `i8` may wrap around the value - --> $DIR/cast.rs:66:5 + --> tests/ui/cast.rs:67:5 | LL | 1u8 as i8; | ^^^^^^^^^ @@ -196,31 +196,31 @@ LL | 1u8 as i8; = 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 + --> tests/ui/cast.rs:70:5 | LL | 1u16 as i16; | ^^^^^^^^^^^ error: casting `u32` to `i32` may wrap around the value - --> $DIR/cast.rs:71:5 + --> tests/ui/cast.rs:72:5 | LL | 1u32 as i32; | ^^^^^^^^^^^ error: casting `u64` to `i64` may wrap around the value - --> $DIR/cast.rs:73:5 + --> tests/ui/cast.rs:74:5 | LL | 1u64 as i64; | ^^^^^^^^^^^ error: casting `usize` to `isize` may wrap around the value - --> $DIR/cast.rs:75:5 + --> tests/ui/cast.rs:76:5 | LL | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting `usize` to `i8` may truncate the value - --> $DIR/cast.rs:78:5 + --> tests/ui/cast.rs:79:5 | LL | 1usize as i8; | ^^^^^^^^^^^^ @@ -232,7 +232,7 @@ LL | i8::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may truncate the value - --> $DIR/cast.rs:81:5 + --> tests/ui/cast.rs:82:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -244,7 +244,7 @@ LL | i16::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may wrap around the value on targets with 16-bit wide pointers - --> $DIR/cast.rs:81:5 + --> tests/ui/cast.rs:82:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | 1usize as i16; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:86:5 + --> tests/ui/cast.rs:87:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -265,19 +265,19 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:86:5 + --> tests/ui/cast.rs:87:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ error: casting `usize` to `i64` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:90:5 + --> tests/ui/cast.rs:91:5 | LL | 1usize as i64; | ^^^^^^^^^^^^^ error: casting `u16` to `isize` may wrap around the value on targets with 16-bit wide pointers - --> $DIR/cast.rs:95:5 + --> tests/ui/cast.rs:96:5 | LL | 1u16 as isize; | ^^^^^^^^^^^^^ @@ -286,13 +286,13 @@ LL | 1u16 as isize; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:99:5 + --> tests/ui/cast.rs:100:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:102:5 + --> tests/ui/cast.rs:103:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -304,25 +304,55 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:102:5 + --> tests/ui/cast.rs:103:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:107:5 + --> tests/ui/cast.rs:108:5 | LL | -1i32 as u32; | ^^^^^^^^^^^^ error: casting `isize` to `usize` may lose the sign of the value - --> $DIR/cast.rs:110:5 + --> tests/ui/cast.rs:111:5 | LL | -1isize as usize; | ^^^^^^^^^^^^^^^^ +error: casting `i8` to `u8` may lose the sign of the value + --> tests/ui/cast.rs:122:5 + | +LL | (i8::MIN).abs() as u8; + | ^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i64` to `u64` may lose the sign of the value + --> tests/ui/cast.rs:126:5 + | +LL | (-1i64).abs() as u64; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `isize` to `usize` may lose the sign of the value + --> tests/ui/cast.rs:127:5 + | +LL | (-1isize).abs() as usize; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i64` to `u64` may lose the sign of the value + --> tests/ui/cast.rs:134:5 + | +LL | (unsafe { (-1i64).checked_abs().unwrap_unchecked() }) as u64; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i64` to `u64` may lose the sign of the value + --> tests/ui/cast.rs:149:5 + | +LL | (unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }) as u64; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: casting `i64` to `i8` may truncate the value - --> $DIR/cast.rs:179:5 + --> tests/ui/cast.rs:200:5 | LL | (-99999999999i64).min(1) as i8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -334,7 +364,7 @@ LL | i8::try_from((-99999999999i64).min(1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `u8` may truncate the value - --> $DIR/cast.rs:193:5 + --> tests/ui/cast.rs:214:5 | LL | 999999u64.clamp(0, 256) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -346,7 +376,7 @@ LL | u8::try_from(999999u64.clamp(0, 256)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E2` to `u8` may truncate the value - --> $DIR/cast.rs:216:21 + --> tests/ui/cast.rs:237:21 | LL | let _ = self as u8; | ^^^^^^^^^^ @@ -358,7 +388,7 @@ LL | let _ = u8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E2::B` to `u8` will truncate the value - --> $DIR/cast.rs:218:21 + --> tests/ui/cast.rs:239:21 | LL | let _ = Self::B as u8; | ^^^^^^^^^^^^^ @@ -367,7 +397,7 @@ LL | let _ = Self::B as u8; = 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 + --> tests/ui/cast.rs:281:21 | LL | let _ = self as i8; | ^^^^^^^^^^ @@ -379,13 +409,13 @@ LL | let _ = i8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E5::A` to `i8` will truncate the value - --> $DIR/cast.rs:262:21 + --> tests/ui/cast.rs:283:21 | LL | let _ = Self::A as i8; | ^^^^^^^^^^^^^ error: casting `main::E6` to `i16` may truncate the value - --> $DIR/cast.rs:279:21 + --> tests/ui/cast.rs:300:21 | LL | let _ = self as i16; | ^^^^^^^^^^^ @@ -397,7 +427,7 @@ LL | let _ = i16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:298:21 + --> tests/ui/cast.rs:319:21 | LL | let _ = self as usize; | ^^^^^^^^^^^^^ @@ -409,7 +439,7 @@ LL | let _ = usize::try_from(self); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E10` to `u16` may truncate the value - --> $DIR/cast.rs:345:21 + --> tests/ui/cast.rs:366:21 | LL | let _ = self as u16; | ^^^^^^^^^^^ @@ -421,7 +451,7 @@ LL | let _ = u16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> $DIR/cast.rs:356:13 + --> tests/ui/cast.rs:377:13 | LL | let c = (q >> 16) as u8; | ^^^^^^^^^^^^^^^ @@ -433,7 +463,7 @@ LL | let c = u8::try_from(q >> 16); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> $DIR/cast.rs:360:13 + --> tests/ui/cast.rs:381:13 | LL | let c = (q / 1000) as u8; | ^^^^^^^^^^^^^^^^ @@ -445,76 +475,180 @@ LL | let c = u8::try_from(q / 1000); | ~~~~~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:379:5 + --> tests/ui/cast.rs:393:9 + | +LL | (x * x) as u32; + | ^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:398:32 + | +LL | let _a = |x: i32| -> u32 { (x * x * x * x) as u32 }; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:400:5 + | +LL | (2_i32).checked_pow(3).unwrap() as u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:401:5 | LL | (-2_i32).pow(3) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:384:5 + --> tests/ui/cast.rs:406:5 + | +LL | (-5_i32 % 2) as u32; + | ^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:408:5 + | +LL | (-5_i32 % -2) as u32; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:411:5 + | +LL | (-2_i32 >> 1) as u32; + | ^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:415:5 + | +LL | (x * x) as u32; + | ^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:416:5 | LL | (x * x * x) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> $DIR/cast.rs:388:5 + --> tests/ui/cast.rs:420:5 | LL | (y * y * y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> $DIR/cast.rs:391:5 + --> tests/ui/cast.rs:422:5 + | +LL | (y * y * y / y * 2) as u16; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:423:5 | -LL | (y * y * y * 2) as u16; +LL | (y * y / y * 2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> $DIR/cast.rs:393:5 + --> tests/ui/cast.rs:425:5 | -LL | (y * y * y * -2) as u16; +LL | (y / y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^ +error: equal expressions as operands to `/` + --> tests/ui/cast.rs:425:6 + | +LL | (y / y * y * -2) as u16; + | ^^^^^ + | + = note: `#[deny(clippy::eq_op)]` on by default + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:428:5 + | +LL | (y + y + y + -2) as u16; + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:430:5 + | +LL | (y + y + y + 2) as u16; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:434:5 + | +LL | (z + -2) as u16; + | ^^^^^^^^^^^^^^^ + +error: casting `i16` to `u16` may lose the sign of the value + --> tests/ui/cast.rs:436:5 + | +LL | (z + z + 2) as u16; + | ^^^^^^^^^^^^^^^^^^ + error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:398:9 + --> tests/ui/cast.rs:439:9 + | +LL | (a * a * b * b * c * c) as u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:440:9 | LL | (a * b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:400:9 + --> tests/ui/cast.rs:442:9 | LL | (a * -b * c) as u32; | ^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:403:9 + --> tests/ui/cast.rs:444:9 + | +LL | (a * b * c * c) as u32; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:445:9 | LL | (a * -2) as u32; | ^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:405:9 + --> tests/ui/cast.rs:447:9 | LL | (a * b * c * -2) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:408:9 + --> tests/ui/cast.rs:449:9 + | +LL | (a / b) as u32; + | ^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:450:9 | LL | (a / b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:410:9 + --> tests/ui/cast.rs:452:9 | LL | (a / b + b * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> $DIR/cast.rs:412:9 + --> tests/ui/cast.rs:454:9 | -LL | a.pow(3) as u32; - | ^^^^^^^^^^^^^^^ +LL | a.saturating_pow(3) as u32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: casting `i32` to `u32` may lose the sign of the value + --> tests/ui/cast.rs:456:9 + | +LL | (a.abs() * b.pow(2) / c.abs()) as u32 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 63 previous errors +error: aborting due to 85 previous errors 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 fbdb559fc4219..96e5c1724a51b 100644 --- a/src/tools/clippy/tests/ui/cast_abs_to_unsigned.stderr +++ b/src/tools/clippy/tests/ui/cast_abs_to_unsigned.stderr @@ -1,5 +1,5 @@ error: casting the result of `i32::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:6:18 + --> tests/ui/cast_abs_to_unsigned.rs:6:18 | LL | let y: u32 = x.abs() as u32; | ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()` @@ -8,103 +8,103 @@ LL | let y: u32 = x.abs() as u32; = 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 + --> tests/ui/cast_abs_to_unsigned.rs:10:20 | LL | let _: usize = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i32::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:11:20 + --> tests/ui/cast_abs_to_unsigned.rs:11:20 | LL | let _: usize = a.abs() as _; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i32::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:12:13 + --> tests/ui/cast_abs_to_unsigned.rs:12:13 | LL | let _ = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:15:13 + --> tests/ui/cast_abs_to_unsigned.rs:15:13 | LL | let _ = a.abs() as usize; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u8 - --> $DIR/cast_abs_to_unsigned.rs:16:13 + --> tests/ui/cast_abs_to_unsigned.rs:16:13 | LL | let _ = a.abs() as u8; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u16 - --> $DIR/cast_abs_to_unsigned.rs:17:13 + --> tests/ui/cast_abs_to_unsigned.rs:17:13 | LL | let _ = a.abs() as u16; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:18:13 + --> tests/ui/cast_abs_to_unsigned.rs:18:13 | LL | let _ = a.abs() as u32; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u64 - --> $DIR/cast_abs_to_unsigned.rs:19:13 + --> tests/ui/cast_abs_to_unsigned.rs:19:13 | LL | let _ = a.abs() as u64; | ^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u128 - --> $DIR/cast_abs_to_unsigned.rs:20:13 + --> tests/ui/cast_abs_to_unsigned.rs:20:13 | LL | let _ = a.abs() as u128; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to usize - --> $DIR/cast_abs_to_unsigned.rs:23:13 + --> tests/ui/cast_abs_to_unsigned.rs:23:13 | LL | let _ = a.abs() as usize; | ^^^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u8 - --> $DIR/cast_abs_to_unsigned.rs:24:13 + --> tests/ui/cast_abs_to_unsigned.rs:24:13 | LL | let _ = a.abs() as u8; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u16 - --> $DIR/cast_abs_to_unsigned.rs:25:13 + --> tests/ui/cast_abs_to_unsigned.rs:25:13 | LL | let _ = a.abs() as u16; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:26:13 + --> tests/ui/cast_abs_to_unsigned.rs:26:13 | LL | let _ = a.abs() as u32; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u64 - --> $DIR/cast_abs_to_unsigned.rs:27:13 + --> tests/ui/cast_abs_to_unsigned.rs:27:13 | LL | let _ = a.abs() as u64; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `isize::abs()` to u128 - --> $DIR/cast_abs_to_unsigned.rs:28:13 + --> tests/ui/cast_abs_to_unsigned.rs:28:13 | LL | let _ = a.abs() as u128; | ^^^^^^^ help: replace with: `a.unsigned_abs()` error: casting the result of `i64::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:30:13 + --> tests/ui/cast_abs_to_unsigned.rs:30:13 | LL | let _ = (x as i64 - y as i64).abs() as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `(x as i64 - y as i64).unsigned_abs()` error: casting the result of `i32::abs()` to u32 - --> $DIR/cast_abs_to_unsigned.rs:42:23 + --> tests/ui/cast_abs_to_unsigned.rs:42:23 | LL | assert_eq!(10u32, x.abs() as u32); | ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()` diff --git a/src/tools/clippy/tests/ui/cast_alignment.stderr b/src/tools/clippy/tests/ui/cast_alignment.stderr index 49bd8dad9c241..b32624f958fc2 100644 --- a/src/tools/clippy/tests/ui/cast_alignment.stderr +++ b/src/tools/clippy/tests/ui/cast_alignment.stderr @@ -1,5 +1,5 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:19:5 + --> tests/ui/cast_alignment.rs:19:5 | LL | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | (&1u8 as *const u8) as *const u16; = 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 + --> tests/ui/cast_alignment.rs:22:5 | LL | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:26:5 + --> tests/ui/cast_alignment.rs:26:5 | LL | (&1u8 as *const u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) - --> $DIR/cast_alignment.rs:28:5 + --> tests/ui/cast_alignment.rs:28:5 | LL | (&mut 1u8 as *mut u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/cast_enum_constructor.stderr b/src/tools/clippy/tests/ui/cast_enum_constructor.stderr index b1bf61edeedbe..67cca68073152 100644 --- a/src/tools/clippy/tests/ui/cast_enum_constructor.stderr +++ b/src/tools/clippy/tests/ui/cast_enum_constructor.stderr @@ -1,5 +1,5 @@ error: cast of an enum tuple constructor to an integer - --> $DIR/cast_enum_constructor.rs:13:13 + --> tests/ui/cast_enum_constructor.rs:13:13 | LL | let _ = Foo::Y as usize; | ^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = Foo::Y as usize; = 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 + --> tests/ui/cast_enum_constructor.rs:16:13 | LL | let _ = Foo::Y as isize; | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/cast_lossless_bool.stderr b/src/tools/clippy/tests/ui/cast_lossless_bool.stderr index e4a5b2e805c35..792b30b7a38b3 100644 --- a/src/tools/clippy/tests/ui/cast_lossless_bool.stderr +++ b/src/tools/clippy/tests/ui/cast_lossless_bool.stderr @@ -1,5 +1,5 @@ error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` - --> $DIR/cast_lossless_bool.rs:6:13 + --> tests/ui/cast_lossless_bool.rs:6:13 | LL | let _ = true as u8; | ^^^^^^^^^^ help: try: `u8::from(true)` @@ -8,79 +8,79 @@ LL | let _ = true as u8; = 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 + --> tests/ui/cast_lossless_bool.rs:7:13 | LL | let _ = true as u16; | ^^^^^^^^^^^ help: try: `u16::from(true)` error: casting `bool` to `u32` is more cleanly stated with `u32::from(_)` - --> $DIR/cast_lossless_bool.rs:8:13 + --> tests/ui/cast_lossless_bool.rs:8:13 | LL | let _ = true as u32; | ^^^^^^^^^^^ help: try: `u32::from(true)` error: casting `bool` to `u64` is more cleanly stated with `u64::from(_)` - --> $DIR/cast_lossless_bool.rs:9:13 + --> tests/ui/cast_lossless_bool.rs:9:13 | LL | let _ = true as u64; | ^^^^^^^^^^^ help: try: `u64::from(true)` error: casting `bool` to `u128` is more cleanly stated with `u128::from(_)` - --> $DIR/cast_lossless_bool.rs:10:13 + --> tests/ui/cast_lossless_bool.rs:10:13 | LL | let _ = true as u128; | ^^^^^^^^^^^^ help: try: `u128::from(true)` error: casting `bool` to `usize` is more cleanly stated with `usize::from(_)` - --> $DIR/cast_lossless_bool.rs:11:13 + --> tests/ui/cast_lossless_bool.rs:11:13 | LL | let _ = true as usize; | ^^^^^^^^^^^^^ help: try: `usize::from(true)` error: casting `bool` to `i8` is more cleanly stated with `i8::from(_)` - --> $DIR/cast_lossless_bool.rs:13:13 + --> tests/ui/cast_lossless_bool.rs:13:13 | LL | let _ = true as i8; | ^^^^^^^^^^ help: try: `i8::from(true)` error: casting `bool` to `i16` is more cleanly stated with `i16::from(_)` - --> $DIR/cast_lossless_bool.rs:14:13 + --> tests/ui/cast_lossless_bool.rs:14:13 | LL | let _ = true as i16; | ^^^^^^^^^^^ help: try: `i16::from(true)` error: casting `bool` to `i32` is more cleanly stated with `i32::from(_)` - --> $DIR/cast_lossless_bool.rs:15:13 + --> tests/ui/cast_lossless_bool.rs:15:13 | LL | let _ = true as i32; | ^^^^^^^^^^^ help: try: `i32::from(true)` error: casting `bool` to `i64` is more cleanly stated with `i64::from(_)` - --> $DIR/cast_lossless_bool.rs:16:13 + --> tests/ui/cast_lossless_bool.rs:16:13 | LL | let _ = true as i64; | ^^^^^^^^^^^ help: try: `i64::from(true)` error: casting `bool` to `i128` is more cleanly stated with `i128::from(_)` - --> $DIR/cast_lossless_bool.rs:17:13 + --> tests/ui/cast_lossless_bool.rs:17:13 | LL | let _ = true as i128; | ^^^^^^^^^^^^ help: try: `i128::from(true)` error: casting `bool` to `isize` is more cleanly stated with `isize::from(_)` - --> $DIR/cast_lossless_bool.rs:18:13 + --> tests/ui/cast_lossless_bool.rs:18:13 | LL | let _ = true as isize; | ^^^^^^^^^^^^^ help: try: `isize::from(true)` error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)` - --> $DIR/cast_lossless_bool.rs:21:13 + --> tests/ui/cast_lossless_bool.rs:21:13 | LL | let _ = (true | false) as u16; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::from(true | false)` error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)` - --> $DIR/cast_lossless_bool.rs:49:13 + --> tests/ui/cast_lossless_bool.rs:49:13 | LL | let _ = true as u8; | ^^^^^^^^^^ help: try: `u8::from(true)` diff --git a/src/tools/clippy/tests/ui/cast_lossless_float.stderr b/src/tools/clippy/tests/ui/cast_lossless_float.stderr index 95e80b4e4a6e7..e70f81eb91fc7 100644 --- a/src/tools/clippy/tests/ui/cast_lossless_float.stderr +++ b/src/tools/clippy/tests/ui/cast_lossless_float.stderr @@ -1,5 +1,5 @@ error: casting `i8` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:7:13 + --> tests/ui/cast_lossless_float.rs:7:13 | LL | let _ = x0 as f32; | ^^^^^^^^^ help: try: `f32::from(x0)` @@ -8,61 +8,61 @@ LL | let _ = x0 as f32; = 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 + --> tests/ui/cast_lossless_float.rs:8:13 | LL | let _ = x0 as f64; | ^^^^^^^^^ help: try: `f64::from(x0)` error: casting `u8` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:10:13 + --> tests/ui/cast_lossless_float.rs:10:13 | LL | let _ = x1 as f32; | ^^^^^^^^^ help: try: `f32::from(x1)` error: casting `u8` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:11:13 + --> tests/ui/cast_lossless_float.rs:11:13 | LL | let _ = x1 as f64; | ^^^^^^^^^ help: try: `f64::from(x1)` error: casting `i16` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:13:13 + --> tests/ui/cast_lossless_float.rs:13:13 | LL | let _ = x2 as f32; | ^^^^^^^^^ help: try: `f32::from(x2)` error: casting `i16` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:14:13 + --> tests/ui/cast_lossless_float.rs:14:13 | LL | let _ = x2 as f64; | ^^^^^^^^^ help: try: `f64::from(x2)` error: casting `u16` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:16:13 + --> tests/ui/cast_lossless_float.rs:16:13 | LL | let _ = x3 as f32; | ^^^^^^^^^ help: try: `f32::from(x3)` error: casting `u16` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:17:13 + --> tests/ui/cast_lossless_float.rs:17:13 | LL | let _ = x3 as f64; | ^^^^^^^^^ help: try: `f64::from(x3)` error: casting `i32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:19:13 + --> tests/ui/cast_lossless_float.rs:19:13 | LL | let _ = x4 as f64; | ^^^^^^^^^ help: try: `f64::from(x4)` error: casting `u32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:21:13 + --> tests/ui/cast_lossless_float.rs:21:13 | LL | let _ = x5 as f64; | ^^^^^^^^^ help: try: `f64::from(x5)` error: casting `f32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:24:13 + --> tests/ui/cast_lossless_float.rs:24:13 | LL | let _ = 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` diff --git a/src/tools/clippy/tests/ui/cast_lossless_integer.stderr b/src/tools/clippy/tests/ui/cast_lossless_integer.stderr index f9f111a7c20f1..43d4ce3ce9161 100644 --- a/src/tools/clippy/tests/ui/cast_lossless_integer.stderr +++ b/src/tools/clippy/tests/ui/cast_lossless_integer.stderr @@ -1,5 +1,5 @@ error: casting `i8` to `i16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:6:13 + --> tests/ui/cast_lossless_integer.rs:6:13 | LL | let _ = 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` @@ -8,121 +8,121 @@ LL | let _ = 1i8 as i16; = 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 + --> tests/ui/cast_lossless_integer.rs:7:13 | LL | let _ = 1i8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1i8)` error: casting `i8` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:8:13 + --> tests/ui/cast_lossless_integer.rs:8:13 | LL | let _ = 1i8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1i8)` error: casting `u8` to `i16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:9:13 + --> tests/ui/cast_lossless_integer.rs:9:13 | LL | let _ = 1u8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1u8)` error: casting `u8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:10:13 + --> tests/ui/cast_lossless_integer.rs:10:13 | LL | let _ = 1u8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1u8)` error: casting `u8` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:11:13 + --> tests/ui/cast_lossless_integer.rs:11:13 | LL | let _ = 1u8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1u8)` error: casting `u8` to `u16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:12:13 + --> tests/ui/cast_lossless_integer.rs:12:13 | LL | let _ = 1u8 as u16; | ^^^^^^^^^^ help: try: `u16::from(1u8)` error: casting `u8` to `u32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:13:13 + --> tests/ui/cast_lossless_integer.rs:13:13 | LL | let _ = 1u8 as u32; | ^^^^^^^^^^ help: try: `u32::from(1u8)` error: casting `u8` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:14:13 + --> tests/ui/cast_lossless_integer.rs:14:13 | LL | let _ = 1u8 as u64; | ^^^^^^^^^^ help: try: `u64::from(1u8)` error: casting `i16` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:15:13 + --> tests/ui/cast_lossless_integer.rs:15:13 | LL | let _ = 1i16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1i16)` error: casting `i16` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:16:13 + --> tests/ui/cast_lossless_integer.rs:16:13 | LL | let _ = 1i16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i16)` error: casting `u16` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:17:13 + --> tests/ui/cast_lossless_integer.rs:17:13 | LL | let _ = 1u16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1u16)` error: casting `u16` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:18:13 + --> tests/ui/cast_lossless_integer.rs:18:13 | LL | let _ = 1u16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u16)` error: casting `u16` to `u32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:19:13 + --> tests/ui/cast_lossless_integer.rs:19:13 | LL | let _ = 1u16 as u32; | ^^^^^^^^^^^ help: try: `u32::from(1u16)` error: casting `u16` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:20:13 + --> tests/ui/cast_lossless_integer.rs:20:13 | LL | let _ = 1u16 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u16)` error: casting `i32` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:21:13 + --> tests/ui/cast_lossless_integer.rs:21:13 | LL | let _ = 1i32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i32)` error: casting `u32` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:22:13 + --> tests/ui/cast_lossless_integer.rs:22:13 | LL | let _ = 1u32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u32)` error: casting `u32` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:23:13 + --> tests/ui/cast_lossless_integer.rs:23:13 | LL | let _ = 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` error: casting `u8` to `u16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:26:13 + --> tests/ui/cast_lossless_integer.rs:26:13 | LL | let _ = (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` error: casting `i8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:60:13 + --> tests/ui/cast_lossless_integer.rs:60:13 | LL | let _ = sign_cast!(x, u8, i8) as i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::from(sign_cast!(x, u8, i8))` error: casting `i8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:61:13 + --> tests/ui/cast_lossless_integer.rs:61:13 | LL | let _ = (sign_cast!(x, u8, i8) + 1) as i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::from(sign_cast!(x, u8, i8) + 1)` 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 c0bb29448f2f8..3cb46d1e79bb7 100644 --- a/src/tools/clippy/tests/ui/cast_nan_to_int.stderr +++ b/src/tools/clippy/tests/ui/cast_nan_to_int.stderr @@ -1,5 +1,5 @@ error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:5:13 + --> tests/ui/cast_nan_to_int.rs:5:13 | LL | let _ = (0.0_f32 / -0.0) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = (0.0_f32 / -0.0) as usize; = 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 + --> tests/ui/cast_nan_to_int.rs:8:13 | LL | let _ = (f64::INFINITY * -0.0) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = (f64::INFINITY * -0.0) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:11:13 + --> tests/ui/cast_nan_to_int.rs:11:13 | LL | let _ = (0.0 * f32::INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = (0.0 * f32::INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:15:13 + --> tests/ui/cast_nan_to_int.rs:15:13 | LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:18:13 + --> tests/ui/cast_nan_to_int.rs:18:13 | LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> $DIR/cast_nan_to_int.rs:21:13 + --> tests/ui/cast_nan_to_int.rs:21:13 | LL | let _ = (f32::INFINITY / f32::NEG_INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 47dc39a30ef7d..2aedd320a4289 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 @@ -1,5 +1,5 @@ error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:8:35 + --> tests/ui/cast_raw_slice_pointer_cast.rs:8:35 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) as *const [u8] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` @@ -8,37 +8,37 @@ LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) as *co = 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 + --> tests/ui/cast_raw_slice_pointer_cast.rs:9:35 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts_mut(mptr, 1) as *mut [u8] }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts_mut(mptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:10:26 + --> tests/ui/cast_raw_slice_pointer_cast.rs:10:26 | LL | let _: *const [u8] = unsafe { std::slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:13:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:13:30 | LL | let _: *const [u8] = unsafe { slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:15:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:15:30 | LL | let _: *const [u8] = unsafe { one::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:19:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:19:30 | LL | let _: *const [u8] = unsafe { slice::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` error: casting the result of `from_raw_parts` to *const [u8] - --> $DIR/cast_raw_slice_pointer_cast.rs:21:30 + --> tests/ui/cast_raw_slice_pointer_cast.rs:21:30 | LL | let _: *const [u8] = unsafe { one::from_raw_parts(ptr, 1) } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr, 1)` diff --git a/src/tools/clippy/tests/ui/cast_size.32bit.stderr b/src/tools/clippy/tests/ui/cast_size.32bit.stderr index 379ca60862b9c..eb6c59deabba2 100644 --- a/src/tools/clippy/tests/ui/cast_size.32bit.stderr +++ b/src/tools/clippy/tests/ui/cast_size.32bit.stderr @@ -1,5 +1,5 @@ error: casting `isize` to `i8` may truncate the value - --> $DIR/cast_size.rs:15:5 + --> tests/ui/cast_size.rs:15:5 | LL | 1isize as i8; | ^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | i8::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:18:5 + --> tests/ui/cast_size.rs:18:5 | LL | x0 as f64; | ^^^^^^^^^ @@ -22,25 +22,25 @@ LL | x0 as f64; = 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 + --> tests/ui/cast_size.rs:19:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:20:5 + --> tests/ui/cast_size.rs:20:5 | LL | x0 as f32; | ^^^^^^^^^ error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:21:5 + --> tests/ui/cast_size.rs:21:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:22:5 + --> tests/ui/cast_size.rs:22:5 | LL | 1isize as i32; | ^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | i32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:23:5 + --> tests/ui/cast_size.rs:23:5 | LL | 1isize as u32; | ^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | u32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:24:5 + --> tests/ui/cast_size.rs:24:5 | LL | 1usize as u32; | ^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | u32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | 1usize as i32; = 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:26:5 + --> tests/ui/cast_size.rs:26:5 | LL | 1i64 as isize; | ^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | isize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:27:5 + --> tests/ui/cast_size.rs:27:5 | LL | 1i64 as usize; | ^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | usize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -133,13 +133,13 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> tests/ui/cast_size.rs:29:5 | LL | 1u64 as usize; | ^^^^^^^^^^^^^ @@ -151,25 +151,25 @@ LL | usize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:30:5 + --> tests/ui/cast_size.rs:30:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:35:5 + --> tests/ui/cast_size.rs:35:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ 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:36:5 + --> tests/ui/cast_size.rs:36:5 | LL | 9_999_999_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: literal out of range for `usize` - --> $DIR/cast_size.rs:36:5 + --> tests/ui/cast_size.rs:36:5 | LL | 9_999_999_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/cast_size.64bit.stderr b/src/tools/clippy/tests/ui/cast_size.64bit.stderr index 7fae92b12503d..0dc4ca91529c6 100644 --- a/src/tools/clippy/tests/ui/cast_size.64bit.stderr +++ b/src/tools/clippy/tests/ui/cast_size.64bit.stderr @@ -1,5 +1,5 @@ error: casting `isize` to `i8` may truncate the value - --> $DIR/cast_size.rs:15:5 + --> tests/ui/cast_size.rs:15:5 | LL | 1isize as i8; | ^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | i8::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:18:5 + --> tests/ui/cast_size.rs:18:5 | LL | x0 as f64; | ^^^^^^^^^ @@ -22,25 +22,25 @@ LL | x0 as f64; = 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 + --> tests/ui/cast_size.rs:19:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:20:5 + --> tests/ui/cast_size.rs:20:5 | LL | x0 as f32; | ^^^^^^^^^ error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:21:5 + --> tests/ui/cast_size.rs:21:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:22:5 + --> tests/ui/cast_size.rs:22:5 | LL | 1isize as i32; | ^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | i32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:23:5 + --> tests/ui/cast_size.rs:23:5 | LL | 1isize as u32; | ^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | u32::try_from(1isize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:24:5 + --> tests/ui/cast_size.rs:24:5 | LL | 1usize as u32; | ^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | u32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> tests/ui/cast_size.rs:25:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | 1usize as i32; = 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:26:5 + --> tests/ui/cast_size.rs:26:5 | LL | 1i64 as isize; | ^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | isize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:27:5 + --> tests/ui/cast_size.rs:27:5 | LL | 1i64 as usize; | ^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | usize::try_from(1i64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -133,13 +133,13 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> tests/ui/cast_size.rs:28:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> tests/ui/cast_size.rs:29:5 | LL | 1u64 as usize; | ^^^^^^^^^^^^^ @@ -151,19 +151,19 @@ LL | usize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:30:5 + --> tests/ui/cast_size.rs:30:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:35:5 + --> tests/ui/cast_size.rs:35:5 | LL | 999_999_999 as f32; | ^^^^^^^^^^^^^^^^^^ 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:36:5 + --> tests/ui/cast_size.rs:36:5 | LL | 9_999_999_999_999_999usize as f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/cast_slice_different_sizes.stderr b/src/tools/clippy/tests/ui/cast_slice_different_sizes.stderr index a5c38e310f67a..625de4a8359ba 100644 --- a/src/tools/clippy/tests/ui/cast_slice_different_sizes.stderr +++ b/src/tools/clippy/tests/ui/cast_slice_different_sizes.stderr @@ -1,5 +1,5 @@ error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:10:13 + --> tests/ui/cast_slice_different_sizes.rs:10:13 | LL | let b = a as *const [u8]; | ^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(a as *const u8, ..)` @@ -7,25 +7,25 @@ LL | let b = a as *const [u8]; = note: `#[deny(clippy::cast_slice_different_sizes)]` on by default error: casting between raw pointers to `[u8]` (element size 1) and `[u32]` (element size 4) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:13:13 + --> tests/ui/cast_slice_different_sizes.rs:13:13 | LL | let c = b as *const [u32]; | ^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(b as *const u32, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:17:16 + --> tests/ui/cast_slice_different_sizes.rs:17:16 | LL | let loss = r_x as *const [i32] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:25:24 + --> tests/ui/cast_slice_different_sizes.rs:25:24 | LL | let loss_block_1 = { r_x as *const [i32] } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts({ r_x as *const [i32] } as *const u8, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:27:24 + --> tests/ui/cast_slice_different_sizes.rs:27:24 | LL | let loss_block_2 = { | ________________________^ @@ -45,13 +45,13 @@ LL ~ } as *const u8, ..); | error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:45:27 + --> tests/ui/cast_slice_different_sizes.rs:45:27 | LL | let long_chain_loss = r_x as *const [i32] as *const [u32] as *const [u16] as *const [i8] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:61:36 + --> tests/ui/cast_slice_different_sizes.rs:61:36 | LL | fn bar(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -61,7 +61,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:66:36 + --> tests/ui/cast_slice_different_sizes.rs:66:36 | LL | fn uwu(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -71,7 +71,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:71:37 + --> tests/ui/cast_slice_different_sizes.rs:71:37 | LL | fn bar2(x: *mut [u16]) -> *mut [u8] { | _____________________________________^ @@ -81,7 +81,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:77:39 + --> tests/ui/cast_slice_different_sizes.rs:77:39 | LL | fn bar3(x: *mut [u16]) -> *const [u8] { | _______________________________________^ @@ -91,7 +91,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(x as *const u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:83:39 + --> tests/ui/cast_slice_different_sizes.rs:83:39 | LL | fn bar4(x: *const [u16]) -> *mut [u8] { | _______________________________________^ @@ -101,7 +101,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:89:39 + --> tests/ui/cast_slice_different_sizes.rs:89:39 | LL | fn blocks(x: *mut [u16]) -> *mut [u8] { | _______________________________________^ @@ -111,7 +111,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:94:44 + --> tests/ui/cast_slice_different_sizes.rs:94:44 | LL | fn more_blocks(x: *mut [u16]) -> *mut [u8] { | ____________________________________________^ @@ -122,7 +122,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> $DIR/cast_slice_different_sizes.rs:96:5 + --> tests/ui/cast_slice_different_sizes.rs:96:5 | LL | { ({ x }) as _ } | ^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` diff --git a/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.fixed b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.fixed new file mode 100644 index 0000000000000..89815ffe9cbc1 --- /dev/null +++ b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.fixed @@ -0,0 +1,13 @@ +#![warn(clippy::deprecated_clippy_cfg_attr)] +#![allow(clippy::non_minimal_cfg)] +#![cfg_attr(clippy, doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was + +#[cfg_attr(clippy, derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg_attr(not(clippy), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(clippy)] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(not(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(any(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(all(clippy))] //~ ERROR: `feature = "cargo-clippy"` was +pub struct Bar; + +fn main() {} diff --git a/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.rs b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.rs new file mode 100644 index 0000000000000..745f8957641ed --- /dev/null +++ b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.rs @@ -0,0 +1,13 @@ +#![warn(clippy::deprecated_clippy_cfg_attr)] +#![allow(clippy::non_minimal_cfg)] +#![cfg_attr(feature = "cargo-clippy", doc = "a")] //~ ERROR: `feature = "cargo-clippy"` was + +#[cfg_attr(feature = "cargo-clippy", derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(feature = "cargo-clippy")] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(not(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(any(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +#[cfg(all(feature = "cargo-clippy"))] //~ ERROR: `feature = "cargo-clippy"` was +pub struct Bar; + +fn main() {} diff --git a/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.stderr b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.stderr new file mode 100644 index 0000000000000..ddec0e648d10c --- /dev/null +++ b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.stderr @@ -0,0 +1,47 @@ +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:5:12 + | +LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + | + = note: `-D clippy::deprecated-clippy-cfg-attr` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::deprecated_clippy_cfg_attr)]` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:6:16 + | +LL | #[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:7:7 + | +LL | #[cfg(feature = "cargo-clippy")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:8:11 + | +LL | #[cfg(not(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:9:11 + | +LL | #[cfg(any(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:10:11 + | +LL | #[cfg(all(feature = "cargo-clippy"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:3:13 + | +LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: aborting due to 7 previous errors + diff --git a/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr b/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr index 8816ce2d83749..24b6ed1b0458d 100644 --- a/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr +++ b/src/tools/clippy/tests/ui/cfg_attr_rustfmt.stderr @@ -1,5 +1,5 @@ error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes - --> $DIR/cfg_attr_rustfmt.rs:18:5 + --> tests/ui/cfg_attr_rustfmt.rs:18:5 | LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` @@ -8,13 +8,13 @@ LL | #[cfg_attr(rustfmt, rustfmt::skip)] = 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 + --> tests/ui/cfg_attr_rustfmt.rs:22:1 | LL | #[cfg_attr(rustfmt, rustfmt_skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes - --> $DIR/cfg_attr_rustfmt.rs:41:5 + --> tests/ui/cfg_attr_rustfmt.rs:41:5 | LL | #[cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]` diff --git a/src/tools/clippy/tests/ui/cfg_features.stderr b/src/tools/clippy/tests/ui/cfg_features.stderr index e1593e2071b49..d576271f1a291 100644 --- a/src/tools/clippy/tests/ui/cfg_features.stderr +++ b/src/tools/clippy/tests/ui/cfg_features.stderr @@ -1,5 +1,5 @@ error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:4:11 + --> tests/ui/cfg_features.rs:4:11 | LL | #[cfg(features = "not-really-a-feature")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "not-really-a-feature"` @@ -8,43 +8,43 @@ LL | #[cfg(features = "not-really-a-feature")] = help: to override `-D warnings` add `#[allow(clippy::maybe_misused_cfg)]` error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:9:34 + --> tests/ui/cfg_features.rs:9:34 | LL | #[cfg(all(feature = "right", features = "wrong"))] | ^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong"` error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:13:15 + --> tests/ui/cfg_features.rs:13:15 | LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))] | ^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong1"` error: 'feature' may be misspelled as 'features' - --> $DIR/cfg_features.rs:13:59 + --> tests/ui/cfg_features.rs:13:59 | LL | #[cfg(all(features = "wrong1", any(feature = "right", features = "wrong2", feature, features)))] | ^^^^^^^^^^^^^^^^^^^ help: did you mean: `feature = "wrong2"` error: 'test' may be misspelled as 'tests' - --> $DIR/cfg_features.rs:18:11 + --> tests/ui/cfg_features.rs:18:11 | LL | #[cfg(tests)] | ^^^^^ help: did you mean: `test` error: 'test' may be misspelled as 'Test' - --> $DIR/cfg_features.rs:21:11 + --> tests/ui/cfg_features.rs:21:11 | LL | #[cfg(Test)] | ^^^^ help: did you mean: `test` error: 'test' may be misspelled as 'tests' - --> $DIR/cfg_features.rs:25:15 + --> tests/ui/cfg_features.rs:25:15 | LL | #[cfg(all(tests, Test))] | ^^^^^ help: did you mean: `test` error: 'test' may be misspelled as 'Test' - --> $DIR/cfg_features.rs:25:22 + --> tests/ui/cfg_features.rs:25:22 | LL | #[cfg(all(tests, Test))] | ^^^^ help: did you mean: `test` 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 22774d2f9f6d0..ec02f1341c0a3 100644 --- a/src/tools/clippy/tests/ui/char_lit_as_u8.stderr +++ b/src/tools/clippy/tests/ui/char_lit_as_u8.stderr @@ -1,5 +1,5 @@ error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8.rs:5:13 + --> tests/ui/char_lit_as_u8.rs:5:13 | LL | let _ = '❤' as u8; | ^^^^^^^^^ 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 359857119d09c..4826aca42e1c3 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 @@ -1,5 +1,5 @@ error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8_suggestions.rs:4:13 + --> tests/ui/char_lit_as_u8_suggestions.rs:4:13 | LL | let _ = 'a' as u8; | ^^^^^^^^^ help: use a byte literal instead: `b'a'` @@ -9,7 +9,7 @@ LL | let _ = 'a' as u8; = 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 + --> tests/ui/char_lit_as_u8_suggestions.rs:5:13 | LL | let _ = '\n' as u8; | ^^^^^^^^^^ help: use a byte literal instead: `b'\n'` @@ -17,7 +17,7 @@ LL | let _ = '\n' as u8; = note: `char` is four bytes wide, but `u8` is a single byte error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8_suggestions.rs:6:13 + --> tests/ui/char_lit_as_u8_suggestions.rs:6:13 | LL | let _ = '\0' as u8; | ^^^^^^^^^^ help: use a byte literal instead: `b'\0'` @@ -25,7 +25,7 @@ LL | let _ = '\0' as u8; = note: `char` is four bytes wide, but `u8` is a single byte error: casting a character literal to `u8` truncates - --> $DIR/char_lit_as_u8_suggestions.rs:7:13 + --> tests/ui/char_lit_as_u8_suggestions.rs:7:13 | LL | let _ = '\x01' as u8; | ^^^^^^^^^^^^ help: use a byte literal instead: `b'\x01'` diff --git a/src/tools/clippy/tests/ui/checked_conversions.stderr b/src/tools/clippy/tests/ui/checked_conversions.stderr index 3e0169b74dabc..223e379cce960 100644 --- a/src/tools/clippy/tests/ui/checked_conversions.stderr +++ b/src/tools/clippy/tests/ui/checked_conversions.stderr @@ -1,5 +1,5 @@ error: checked cast can be simplified - --> $DIR/checked_conversions.rs:14:13 + --> tests/ui/checked_conversions.rs:14:13 | LL | let _ = value <= (u32::max_value() as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` @@ -8,97 +8,97 @@ LL | let _ = value <= (u32::max_value() as i64) && value >= 0; = help: to override `-D warnings` add `#[allow(clippy::checked_conversions)]` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:15:13 + --> tests/ui/checked_conversions.rs:15:13 | LL | let _ = value <= (u32::MAX as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:19:13 + --> tests/ui/checked_conversions.rs:19:13 | LL | let _ = value <= i64::from(u16::max_value()) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:20:13 + --> tests/ui/checked_conversions.rs:20:13 | LL | let _ = value <= i64::from(u16::MAX) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:24:13 + --> tests/ui/checked_conversions.rs:24:13 | LL | let _ = value <= (u8::max_value() as isize) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:25:13 + --> tests/ui/checked_conversions.rs:25:13 | LL | let _ = value <= (u8::MAX as isize) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:31:13 + --> tests/ui/checked_conversions.rs:31:13 | LL | let _ = value <= (i32::max_value() as i64) && value >= (i32::min_value() as i64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:32:13 + --> tests/ui/checked_conversions.rs:32:13 | LL | let _ = value <= (i32::MAX as i64) && value >= (i32::MIN as i64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:36:13 + --> tests/ui/checked_conversions.rs:36:13 | LL | let _ = value <= i64::from(i16::max_value()) && value >= i64::from(i16::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:37:13 + --> tests/ui/checked_conversions.rs:37:13 | LL | let _ = value <= i64::from(i16::MAX) && value >= i64::from(i16::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:43:13 + --> tests/ui/checked_conversions.rs:43:13 | LL | let _ = value <= i32::max_value() as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:44:13 + --> tests/ui/checked_conversions.rs:44:13 | LL | let _ = value <= i32::MAX as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:48:13 + --> tests/ui/checked_conversions.rs:48:13 | LL | let _ = value <= isize::max_value() as usize && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:49:13 + --> tests/ui/checked_conversions.rs:49:13 | LL | let _ = value <= isize::MAX as usize && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:53:13 + --> tests/ui/checked_conversions.rs:53:13 | LL | let _ = value <= u16::max_value() as u32 && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:54:13 + --> tests/ui/checked_conversions.rs:54:13 | LL | let _ = value <= u16::MAX as u32 && value as i32 == 5; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()` error: checked cast can be simplified - --> $DIR/checked_conversions.rs:87:13 + --> tests/ui/checked_conversions.rs:87:13 | LL | let _ = value <= (u32::MAX as i64) && value >= 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()` diff --git a/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals.stderr b/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals.stderr index 73c074a93393f..aa72e8cce590f 100644 --- a/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals.stderr +++ b/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:13:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:13:9 | LL | if x.is_ok() && y.is_err() { | --------- the check is happening here @@ -9,13 +9,13 @@ LL | x.unwrap(); | = help: try using `if let` or `match` note: the lint level is defined here - --> $DIR/complex_conditionals.rs:1:35 + --> tests/ui/checked_unwrap/complex_conditionals.rs:1:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:16:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:16:9 | LL | if x.is_ok() && y.is_err() { | --------- because of this check @@ -24,13 +24,13 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/complex_conditionals.rs:1:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:1:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:19:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:19:9 | LL | if x.is_ok() && y.is_err() { | ---------- because of this check @@ -39,7 +39,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_err` - --> $DIR/complex_conditionals.rs:22:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:22:9 | LL | if x.is_ok() && y.is_err() { | ---------- the check is happening here @@ -50,7 +50,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:38:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:38:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -59,7 +59,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:41:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:41:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -70,7 +70,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:44:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:44:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -79,7 +79,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:47:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:47:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -90,7 +90,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:53:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:53:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -101,7 +101,7 @@ LL | x.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:56:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:56:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -110,7 +110,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:59:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:59:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -119,7 +119,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:62:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:62:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -130,7 +130,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `z` after checking its variant with `is_err` - --> $DIR/complex_conditionals.rs:65:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:65:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here @@ -141,7 +141,7 @@ LL | z.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:68:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:68:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check @@ -150,7 +150,7 @@ LL | z.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:78:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:78:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -159,7 +159,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:81:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:81:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -170,7 +170,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `y` after checking its variant with `is_ok` - --> $DIR/complex_conditionals.rs:84:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:84:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -181,7 +181,7 @@ LL | y.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> $DIR/complex_conditionals.rs:87:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:87:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -190,7 +190,7 @@ LL | y.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals.rs:90:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:90:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check @@ -199,7 +199,7 @@ LL | z.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `z` after checking its variant with `is_err` - --> $DIR/complex_conditionals.rs:93:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:93:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- the check is happening here diff --git a/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals_nested.stderr b/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals_nested.stderr index d9f701a5b2e00..f7e659b10de07 100644 --- a/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals_nested.stderr +++ b/src/tools/clippy/tests/ui/checked_unwrap/complex_conditionals_nested.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/complex_conditionals_nested.rs:13:13 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:13:13 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -8,13 +8,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/complex_conditionals_nested.rs:1:35 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:1:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/complex_conditionals_nested.rs:17:13 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:17:13 | LL | if x.is_some() { | ----------- because of this check @@ -23,7 +23,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/complex_conditionals_nested.rs:1:9 + --> tests/ui/checked_unwrap/complex_conditionals_nested.rs:1:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr index a5afbba7317e9..bae6213376012 100644 --- a/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr +++ b/src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr @@ -1,5 +1,5 @@ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:47:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:47:9 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -8,13 +8,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/simple_conditionals.rs:3:35 + --> tests/ui/checked_unwrap/simple_conditionals.rs:3:35 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `expect` on `x` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:50:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:50:9 | LL | if x.is_some() { | -------------- help: try: `if let Some(..) = x` @@ -23,7 +23,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:54:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:54:9 | LL | if x.is_some() { | ----------- because of this check @@ -32,13 +32,13 @@ LL | x.unwrap(); | ^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/simple_conditionals.rs:3:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:3:9 | LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `expect()` will always panic - --> $DIR/simple_conditionals.rs:57:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:57:9 | LL | if x.is_some() { | ----------- because of this check @@ -47,7 +47,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:62:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:62:9 | LL | if x.is_none() { | ----------- because of this check @@ -56,7 +56,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_none` - --> $DIR/simple_conditionals.rs:66:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:66:9 | LL | if x.is_none() { | -------------- help: try: `if let Some(..) = x` @@ -65,7 +65,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:14:13 + --> tests/ui/checked_unwrap/simple_conditionals.rs:14:13 | LL | if $a.is_some() { | --------------- help: try: `if let Some(..) = x` @@ -79,7 +79,7 @@ LL | m!(x); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error: called `unwrap` on `x` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:79:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:79:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok(..) = x` @@ -88,7 +88,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `expect` on `x` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:82:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:82:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok(..) = x` @@ -97,7 +97,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/simple_conditionals.rs:85:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9 | LL | if x.is_ok() { | --------- because of this check @@ -106,7 +106,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:89:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9 | LL | if x.is_ok() { | --------- because of this check @@ -115,7 +115,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `expect()` will always panic - --> $DIR/simple_conditionals.rs:92:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:92:9 | LL | if x.is_ok() { | --------- because of this check @@ -124,7 +124,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:95:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:95:9 | LL | if x.is_ok() { | ------------ help: try: `if let Err(..) = x` @@ -133,7 +133,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:100:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:100:9 | LL | if x.is_err() { | ---------- because of this check @@ -142,7 +142,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_err` - --> $DIR/simple_conditionals.rs:103:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:103:9 | LL | if x.is_err() { | ------------- help: try: `if let Err(..) = x` @@ -151,7 +151,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_err` - --> $DIR/simple_conditionals.rs:107:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:107:9 | LL | if x.is_err() { | ------------- help: try: `if let Ok(..) = x` @@ -160,7 +160,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> $DIR/simple_conditionals.rs:110:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:110:9 | LL | if x.is_err() { | ---------- because of this check @@ -169,7 +169,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:135:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:135:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some(..) = &option` @@ -177,7 +177,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:138:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:138:9 | LL | if option.is_some() { | ---------------- because of this check @@ -186,7 +186,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:145:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:145:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok(..) = &result` @@ -194,7 +194,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:148:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:148:9 | LL | if result.is_ok() { | -------------- because of this check @@ -203,7 +203,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> $DIR/simple_conditionals.rs:154:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:154:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some(..) = &mut option` @@ -211,7 +211,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:157:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:157:9 | LL | if option.is_some() { | ---------------- because of this check @@ -220,7 +220,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> $DIR/simple_conditionals.rs:163:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:163:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok(..) = &mut result` @@ -228,7 +228,7 @@ LL | result.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> $DIR/simple_conditionals.rs:166:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:166:9 | LL | if result.is_ok() { | -------------- because of this check diff --git a/src/tools/clippy/tests/ui/clear_with_drain.stderr b/src/tools/clippy/tests/ui/clear_with_drain.stderr index b1a3812563afa..3c7d22192dc77 100644 --- a/src/tools/clippy/tests/ui/clear_with_drain.stderr +++ b/src/tools/clippy/tests/ui/clear_with_drain.stderr @@ -1,5 +1,5 @@ error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:22:7 + --> tests/ui/clear_with_drain.rs:22:7 | LL | v.drain(0..v.len()); | ^^^^^^^^^^^^^^^^^ help: try: `clear()` @@ -8,121 +8,121 @@ LL | v.drain(0..v.len()); = 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 + --> tests/ui/clear_with_drain.rs:26:7 | LL | v.drain(usize::MIN..v.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:45:7 + --> tests/ui/clear_with_drain.rs:45:7 | LL | v.drain(0..); | ^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:49:7 + --> tests/ui/clear_with_drain.rs:49:7 | LL | v.drain(usize::MIN..); | ^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:65:7 + --> tests/ui/clear_with_drain.rs:65:7 | LL | v.drain(..); | ^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `Vec` - --> $DIR/clear_with_drain.rs:82:7 + --> tests/ui/clear_with_drain.rs:82:7 | LL | v.drain(..v.len()); | ^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:120:11 + --> tests/ui/clear_with_drain.rs:120:11 | LL | deque.drain(0..deque.len()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:124:11 + --> tests/ui/clear_with_drain.rs:124:11 | LL | deque.drain(usize::MIN..deque.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:143:11 + --> tests/ui/clear_with_drain.rs:143:11 | LL | deque.drain(0..); | ^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:147:11 + --> tests/ui/clear_with_drain.rs:147:11 | LL | deque.drain(usize::MIN..); | ^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:163:11 + --> tests/ui/clear_with_drain.rs:163:11 | LL | deque.drain(..); | ^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `VecDeque` - --> $DIR/clear_with_drain.rs:180:11 + --> tests/ui/clear_with_drain.rs:180:11 | LL | deque.drain(..deque.len()); | ^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:218:7 + --> tests/ui/clear_with_drain.rs:218:7 | LL | s.drain(0..s.len()); | ^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:222:7 + --> tests/ui/clear_with_drain.rs:222:7 | LL | s.drain(usize::MIN..s.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:241:7 + --> tests/ui/clear_with_drain.rs:241:7 | LL | s.drain(0..); | ^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:245:7 + --> tests/ui/clear_with_drain.rs:245:7 | LL | s.drain(usize::MIN..); | ^^^^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:261:7 + --> tests/ui/clear_with_drain.rs:261:7 | LL | s.drain(..); | ^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `String` - --> $DIR/clear_with_drain.rs:278:7 + --> tests/ui/clear_with_drain.rs:278:7 | LL | s.drain(..s.len()); | ^^^^^^^^^^^^^^^^ help: try: `clear()` error: `drain` used to clear a `HashSet` - --> $DIR/clear_with_drain.rs:316:9 + --> tests/ui/clear_with_drain.rs:316:9 | LL | set.drain(); | ^^^^^^^ help: try: `clear()` error: `drain` used to clear a `HashMap` - --> $DIR/clear_with_drain.rs:335:9 + --> tests/ui/clear_with_drain.rs:335:9 | LL | map.drain(); | ^^^^^^^ help: try: `clear()` error: `drain` used to clear a `BinaryHeap` - --> $DIR/clear_with_drain.rs:354:10 + --> tests/ui/clear_with_drain.rs:354:10 | LL | heap.drain(); | ^^^^^^^ help: try: `clear()` diff --git a/src/tools/clippy/tests/ui/clone_on_copy.stderr b/src/tools/clippy/tests/ui/clone_on_copy.stderr index 0526c2f5a28a4..314fd13afca43 100644 --- a/src/tools/clippy/tests/ui/clone_on_copy.stderr +++ b/src/tools/clippy/tests/ui/clone_on_copy.stderr @@ -1,5 +1,5 @@ error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:23:5 + --> tests/ui/clone_on_copy.rs:23:5 | LL | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` @@ -8,49 +8,49 @@ LL | 42.clone(); = 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 + --> tests/ui/clone_on_copy.rs:27:5 | LL | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:30:5 + --> tests/ui/clone_on_copy.rs:30:5 | LL | rc.borrow().clone(); | ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` error: using `clone` on type `u32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:33:5 + --> tests/ui/clone_on_copy.rs:33:5 | LL | x.clone().rotate_left(1); | ^^^^^^^^^ help: try removing the `clone` call: `x` error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:47:5 + --> tests/ui/clone_on_copy.rs:47:5 | LL | m!(42).clone(); | ^^^^^^^^^^^^^^ help: try removing the `clone` call: `m!(42)` error: using `clone` on type `[u32; 2]` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:57:5 + --> tests/ui/clone_on_copy.rs:57:5 | LL | x.clone()[0]; | ^^^^^^^^^ help: try dereferencing it: `(*x)` error: using `clone` on type `char` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:67:14 + --> tests/ui/clone_on_copy.rs:67:14 | LL | is_ascii('z'.clone()); | ^^^^^^^^^^^ help: try removing the `clone` call: `'z'` error: using `clone` on type `i32` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:71:14 + --> tests/ui/clone_on_copy.rs:71:14 | LL | vec.push(42.clone()); | ^^^^^^^^^^ help: try removing the `clone` call: `42` error: using `clone` on type `Option` which implements the `Copy` trait - --> $DIR/clone_on_copy.rs:75:17 + --> tests/ui/clone_on_copy.rs:75:17 | LL | let value = opt.clone()?; // operator precedence needed (*opt)? | ^^^^^^^^^^^ help: try dereferencing it: `(*opt)` 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 69a3738dd05b5..ad857c4ef7d0f 100644 --- a/src/tools/clippy/tests/ui/cloned_instead_of_copied.stderr +++ b/src/tools/clippy/tests/ui/cloned_instead_of_copied.stderr @@ -1,5 +1,5 @@ error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:7:24 + --> tests/ui/cloned_instead_of_copied.rs:7:24 | LL | let _ = [1].iter().cloned(); | ^^^^^^ help: try: `copied` @@ -8,43 +8,43 @@ LL | let _ = [1].iter().cloned(); = 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 + --> tests/ui/cloned_instead_of_copied.rs:8:31 | LL | let _ = vec!["hi"].iter().cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:9:22 + --> tests/ui/cloned_instead_of_copied.rs:9:22 | LL | let _ = Some(&1).cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:10:34 + --> tests/ui/cloned_instead_of_copied.rs:10:34 | LL | let _ = Box::new([1].iter()).cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:11:32 + --> tests/ui/cloned_instead_of_copied.rs:11:32 | LL | let _ = Box::new(Some(&1)).cloned(); | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:27:22 + --> tests/ui/cloned_instead_of_copied.rs:27:22 | LL | let _ = Some(&1).cloned(); // Option::copied needs 1.35 | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:32:24 + --> tests/ui/cloned_instead_of_copied.rs:32:24 | LL | let _ = [1].iter().cloned(); // Iterator::copied needs 1.36 | ^^^^^^ help: try: `copied` error: used `cloned` where `copied` could be used instead - --> $DIR/cloned_instead_of_copied.rs:33:22 + --> tests/ui/cloned_instead_of_copied.rs:33:22 | LL | let _ = Some(&1).cloned(); | ^^^^^^ help: try: `copied` diff --git a/src/tools/clippy/tests/ui/cmp_null.stderr b/src/tools/clippy/tests/ui/cmp_null.stderr index d3b7c85b22935..8362904a5ba9d 100644 --- a/src/tools/clippy/tests/ui/cmp_null.stderr +++ b/src/tools/clippy/tests/ui/cmp_null.stderr @@ -1,5 +1,5 @@ error: comparing with null is better expressed by the `.is_null()` method - --> $DIR/cmp_null.rs:9:8 + --> tests/ui/cmp_null.rs:9:8 | LL | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | if p == ptr::null() { = 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 + --> tests/ui/cmp_null.rs:16:8 | LL | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ 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 6431b3619be9a..e230d5f06bb05 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 @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:46:12 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:46:12 | LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` @@ -8,7 +8,7 @@ LL | if borrowed.to_owned() == owned {} = 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 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:47:21 | LL | if owned == borrowed.to_owned() {} | ---------^^^^^^^^^^^^^^^^^^^ @@ -16,13 +16,13 @@ LL | if owned == borrowed.to_owned() {} | help: try: `borrowed == owned` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:65:21 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:65:21 | LL | if owned == borrowed.to_owned() {} | ^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:66:12 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:66:12 | LL | if borrowed.to_owned() == owned {} | ^^^^^^^^^^^^^^^^^^^--------- @@ -30,7 +30,7 @@ LL | if borrowed.to_owned() == owned {} | help: try: `owned == borrowed` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:92:20 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:92:20 | LL | if "Hi" == borrowed.to_string() {} | --------^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | if "Hi" == borrowed.to_string() {} | help: try: `borrowed == "Hi"` error: this creates an owned instance just for comparison - --> $DIR/asymmetric_partial_eq.rs:93:12 + --> tests/ui/cmp_owned/asymmetric_partial_eq.rs:93:12 | LL | if borrowed.to_string() == "Hi" {} | ^^^^^^^^^^^^^^^^^^^^ help: try: `borrowed` 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 09a495996f2cc..cfb6978158b37 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.stderr +++ b/src/tools/clippy/tests/ui/cmp_owned/comparison_flip.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/comparison_flip.rs:6:8 + --> tests/ui/cmp_owned/comparison_flip.rs:6:8 | LL | if a.to_string() != "bar" { | ^^^^^^^^^^^^^ help: try: `a` @@ -8,7 +8,7 @@ LL | if a.to_string() != "bar" { = 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 + --> tests/ui/cmp_owned/comparison_flip.rs:10:17 | LL | if "bar" != a.to_string() { | ---------^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed index 8846092fef40f..ab72e096cc7c7 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed +++ b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.fixed @@ -29,7 +29,7 @@ struct Foo; impl PartialEq for Foo { // Allow this here, because it emits the lint // without a suggestion. This is tested in - // `$DIR/without_suggestion.rs` + // `tests/ui/cmp_owned/without_suggestion.rs` #[allow(clippy::cmp_owned)] fn eq(&self, other: &Self) -> bool { self.to_owned() == *other 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 0b1127c1a61bd..41448e0120039 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.stderr +++ b/src/tools/clippy/tests/ui/cmp_owned/with_suggestion.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:5:14 + --> tests/ui/cmp_owned/with_suggestion.rs:5:14 | LL | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` @@ -8,31 +8,31 @@ LL | x != "foo".to_string(); = 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 + --> tests/ui/cmp_owned/with_suggestion.rs:7:9 | LL | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:14:10 + --> tests/ui/cmp_owned/with_suggestion.rs:14:10 | LL | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:16:10 + --> tests/ui/cmp_owned/with_suggestion.rs:16:10 | LL | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:20:5 + --> tests/ui/cmp_owned/with_suggestion.rs:20:5 | LL | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` error: this creates an owned instance just for comparison - --> $DIR/with_suggestion.rs:22:30 + --> tests/ui/cmp_owned/with_suggestion.rs:22:30 | LL | "abc".chars().filter(|c| c.to_owned() != 'X'); | ^^^^^^^^^^^^ help: try: `*c` 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 c4f63bd09cb81..13ca699b9fd3b 100644 --- a/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr +++ b/src/tools/clippy/tests/ui/cmp_owned/without_suggestion.stderr @@ -1,5 +1,5 @@ error: this creates an owned instance just for comparison - --> $DIR/without_suggestion.rs:7:5 + --> tests/ui/cmp_owned/without_suggestion.rs:7:5 | LL | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating @@ -8,13 +8,13 @@ LL | y.to_owned() == *x; = 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 + --> tests/ui/cmp_owned/without_suggestion.rs:13:5 | LL | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/without_suggestion.rs:25:9 + --> tests/ui/cmp_owned/without_suggestion.rs:25:9 | LL | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating diff --git a/src/tools/clippy/tests/ui/cognitive_complexity.stderr b/src/tools/clippy/tests/ui/cognitive_complexity.stderr index 58c7455d11a69..1e60247e5f584 100644 --- a/src/tools/clippy/tests/ui/cognitive_complexity.stderr +++ b/src/tools/clippy/tests/ui/cognitive_complexity.stderr @@ -1,5 +1,5 @@ error: the function has a cognitive complexity of (28/25) - --> $DIR/cognitive_complexity.rs:6:4 + --> tests/ui/cognitive_complexity.rs:6:4 | LL | fn main() { | ^^^^ @@ -9,7 +9,7 @@ LL | fn main() { = 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 + --> tests/ui/cognitive_complexity.rs:92:4 | LL | fn kaboom() { | ^^^^^^ @@ -17,7 +17,7 @@ LL | fn kaboom() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:151:4 + --> tests/ui/cognitive_complexity.rs:151:4 | LL | fn baa() { | ^^^ @@ -25,7 +25,7 @@ LL | fn baa() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:153:13 + --> tests/ui/cognitive_complexity.rs:153:13 | LL | let x = || match 99 { | ^^ @@ -33,7 +33,7 @@ LL | let x = || match 99 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:171:4 + --> tests/ui/cognitive_complexity.rs:171:4 | LL | fn bar() { | ^^^ @@ -41,7 +41,7 @@ LL | fn bar() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:183:4 + --> tests/ui/cognitive_complexity.rs:183:4 | LL | fn dont_warn_on_tests() { | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn dont_warn_on_tests() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:192:4 + --> tests/ui/cognitive_complexity.rs:192:4 | LL | fn barr() { | ^^^^ @@ -57,7 +57,7 @@ LL | fn barr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> $DIR/cognitive_complexity.rs:203:4 + --> tests/ui/cognitive_complexity.rs:203:4 | LL | fn barr2() { | ^^^^^ @@ -65,7 +65,7 @@ LL | fn barr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:220:4 + --> tests/ui/cognitive_complexity.rs:220:4 | LL | fn barrr() { | ^^^^^ @@ -73,7 +73,7 @@ LL | fn barrr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> $DIR/cognitive_complexity.rs:231:4 + --> tests/ui/cognitive_complexity.rs:231:4 | LL | fn barrr2() { | ^^^^^^ @@ -81,7 +81,7 @@ LL | fn barrr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:248:4 + --> tests/ui/cognitive_complexity.rs:248:4 | LL | fn barrrr() { | ^^^^^^ @@ -89,7 +89,7 @@ LL | fn barrrr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> $DIR/cognitive_complexity.rs:259:4 + --> tests/ui/cognitive_complexity.rs:259:4 | LL | fn barrrr2() { | ^^^^^^^ @@ -97,7 +97,7 @@ LL | fn barrrr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:276:4 + --> tests/ui/cognitive_complexity.rs:276:4 | LL | fn cake() { | ^^^^ @@ -105,7 +105,7 @@ LL | fn cake() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (4/1) - --> $DIR/cognitive_complexity.rs:287:8 + --> tests/ui/cognitive_complexity.rs:287:8 | LL | pub fn read_file(input_path: &str) -> String { | ^^^^^^^^^ @@ -113,7 +113,7 @@ LL | pub fn read_file(input_path: &str) -> String { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:319:4 + --> tests/ui/cognitive_complexity.rs:319:4 | LL | fn void(void: Void) { | ^^^^ @@ -121,7 +121,7 @@ LL | fn void(void: Void) { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (8/1) - --> $DIR/cognitive_complexity.rs:371:4 + --> tests/ui/cognitive_complexity.rs:371:4 | LL | fn early_ret() -> i32 { | ^^^^^^^^^ @@ -129,7 +129,7 @@ LL | fn early_ret() -> i32 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:393:13 + --> tests/ui/cognitive_complexity.rs:393:13 | LL | let x = |a: i32, b: i32| -> i32 { | ^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | let x = |a: i32, b: i32| -> i32 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:407:8 + --> tests/ui/cognitive_complexity.rs:407:8 | LL | fn moo(&self) { | ^^^ @@ -145,7 +145,7 @@ LL | fn moo(&self) { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:417:14 + --> tests/ui/cognitive_complexity.rs:417:14 | LL | async fn a() { | ^ @@ -153,7 +153,7 @@ LL | async fn a() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> $DIR/cognitive_complexity.rs:425:22 + --> tests/ui/cognitive_complexity.rs:425:22 | LL | pub async fn async_method() { | ^^^^^^^^^^^^ 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 b9af72371e6a6..88de135409b5b 100644 --- a/src/tools/clippy/tests/ui/cognitive_complexity_attr_used.stderr +++ b/src/tools/clippy/tests/ui/cognitive_complexity_attr_used.stderr @@ -1,5 +1,5 @@ error: the function has a cognitive complexity of (3/0) - --> $DIR/cognitive_complexity_attr_used.rs:9:4 + --> tests/ui/cognitive_complexity_attr_used.rs:9:4 | LL | fn kaboom() { | ^^^^^^ diff --git a/src/tools/clippy/tests/ui/collapsible_else_if.stderr b/src/tools/clippy/tests/ui/collapsible_else_if.stderr index f0f840653f8ac..dc19d90b4d132 100644 --- a/src/tools/clippy/tests/ui/collapsible_else_if.stderr +++ b/src/tools/clippy/tests/ui/collapsible_else_if.stderr @@ -1,5 +1,5 @@ error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:13:12 + --> tests/ui/collapsible_else_if.rs:13:12 | LL | } else { | ____________^ @@ -19,7 +19,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:21:12 + --> tests/ui/collapsible_else_if.rs:21:12 | LL | } else { | ____________^ @@ -37,7 +37,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:29:12 + --> tests/ui/collapsible_else_if.rs:29:12 | LL | } else { | ____________^ @@ -60,7 +60,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:40:12 + --> tests/ui/collapsible_else_if.rs:40:12 | LL | } else { | ____________^ @@ -83,7 +83,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:51:12 + --> tests/ui/collapsible_else_if.rs:51:12 | LL | } else { | ____________^ @@ -106,7 +106,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:62:12 + --> tests/ui/collapsible_else_if.rs:62:12 | LL | } else { | ____________^ @@ -129,7 +129,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:73:12 + --> tests/ui/collapsible_else_if.rs:73:12 | LL | } else { | ____________^ @@ -152,7 +152,7 @@ LL + } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_else_if.rs:96:10 + --> tests/ui/collapsible_else_if.rs:96:10 | LL | }else{ | __________^ diff --git a/src/tools/clippy/tests/ui/collapsible_if.stderr b/src/tools/clippy/tests/ui/collapsible_if.stderr index 16df3e433db49..5bcbdf2fd08da 100644 --- a/src/tools/clippy/tests/ui/collapsible_if.stderr +++ b/src/tools/clippy/tests/ui/collapsible_if.stderr @@ -1,5 +1,5 @@ error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:15:5 + --> tests/ui/collapsible_if.rs:15:5 | LL | / if x == "hello" { LL | | if y == "world" { @@ -18,7 +18,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:21:5 + --> tests/ui/collapsible_if.rs:21:5 | LL | / if x == "hello" || x == "world" { LL | | if y == "world" || y == "hello" { @@ -35,7 +35,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:27:5 + --> tests/ui/collapsible_if.rs:27:5 | LL | / if x == "hello" && x == "world" { LL | | if y == "world" || y == "hello" { @@ -52,7 +52,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:33:5 + --> tests/ui/collapsible_if.rs:33:5 | LL | / if x == "hello" || x == "world" { LL | | if y == "world" && y == "hello" { @@ -69,7 +69,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:39:5 + --> tests/ui/collapsible_if.rs:39:5 | LL | / if x == "hello" && x == "world" { LL | | if y == "world" && y == "hello" { @@ -86,7 +86,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:45:5 + --> tests/ui/collapsible_if.rs:45:5 | LL | / if 42 == 1337 { LL | | if 'a' != 'A' { @@ -103,7 +103,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:101:5 + --> tests/ui/collapsible_if.rs:101:5 | LL | / if x == "hello" { LL | | if y == "world" { // Collapsible @@ -120,7 +120,7 @@ LL + } | error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:160:5 + --> tests/ui/collapsible_if.rs:160:5 | LL | / if matches!(true, true) { LL | | if matches!(true, true) {} @@ -128,7 +128,7 @@ LL | | } | |_____^ help: collapse nested if block: `if matches!(true, true) && matches!(true, true) {}` error: this `if` statement can be collapsed - --> $DIR/collapsible_if.rs:165:5 + --> tests/ui/collapsible_if.rs:165:5 | LL | / if matches!(true, true) && truth() { LL | | if matches!(true, true) {} diff --git a/src/tools/clippy/tests/ui/collapsible_match.stderr b/src/tools/clippy/tests/ui/collapsible_match.stderr index ce7da1c16d30c..46b484ab05c4e 100644 --- a/src/tools/clippy/tests/ui/collapsible_match.stderr +++ b/src/tools/clippy/tests/ui/collapsible_match.stderr @@ -1,5 +1,5 @@ error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:13:20 + --> tests/ui/collapsible_match.rs:13:20 | LL | Ok(val) => match val { | ____________________^ @@ -10,7 +10,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:13:12 + --> tests/ui/collapsible_match.rs:13:12 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -21,7 +21,7 @@ LL | Some(n) => foo(n), = 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 + --> tests/ui/collapsible_match.rs:23:20 | LL | Ok(val) => match val { | ____________________^ @@ -32,7 +32,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:23:12 + --> tests/ui/collapsible_match.rs:23:12 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -41,7 +41,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:33:9 + --> tests/ui/collapsible_match.rs:33:9 | LL | / if let Some(n) = val { LL | | @@ -50,7 +50,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:32:15 + --> tests/ui/collapsible_match.rs:32:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -58,7 +58,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:41:9 + --> tests/ui/collapsible_match.rs:41:9 | LL | / if let Some(n) = val { LL | | @@ -69,7 +69,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:40:15 + --> tests/ui/collapsible_match.rs:40:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -77,7 +77,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:53:9 + --> tests/ui/collapsible_match.rs:53:9 | LL | / match val { LL | | @@ -87,7 +87,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:52:15 + --> tests/ui/collapsible_match.rs:52:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -96,7 +96,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:63:13 + --> tests/ui/collapsible_match.rs:63:13 | LL | / if let Some(n) = val { LL | | @@ -105,7 +105,7 @@ LL | | } | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:62:12 + --> tests/ui/collapsible_match.rs:62:12 | LL | Ok(val) => { | ^^^ replace this binding @@ -113,7 +113,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:73:9 + --> tests/ui/collapsible_match.rs:73:9 | LL | / match val { LL | | @@ -123,7 +123,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:72:15 + --> tests/ui/collapsible_match.rs:72:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -132,7 +132,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:85:13 + --> tests/ui/collapsible_match.rs:85:13 | LL | / if let Some(n) = val { LL | | @@ -143,7 +143,7 @@ LL | | } | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:84:12 + --> tests/ui/collapsible_match.rs:84:12 | LL | Ok(val) => { | ^^^ replace this binding @@ -151,7 +151,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:97:20 + --> tests/ui/collapsible_match.rs:97:20 | LL | Ok(val) => match val { | ____________________^ @@ -162,7 +162,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:97:12 + --> tests/ui/collapsible_match.rs:97:12 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -171,7 +171,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match.rs:107:22 + --> tests/ui/collapsible_match.rs:107:22 | LL | Some(val) => match val { | ______________________^ @@ -182,7 +182,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:107:14 + --> tests/ui/collapsible_match.rs:107:14 | LL | Some(val) => match val { | ^^^ replace this binding @@ -191,7 +191,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:273:9 + --> tests/ui/collapsible_match.rs:273:9 | LL | / if let Some(u) = a { LL | | @@ -200,7 +200,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:272:27 + --> tests/ui/collapsible_match.rs:272:27 | LL | if let Issue9647::A { a, .. } = x { | ^ replace this binding @@ -208,7 +208,7 @@ LL | if let Some(u) = a { | ^^^^^^^ with this pattern, prefixed by a: error: this `if let` can be collapsed into the outer `if let` - --> $DIR/collapsible_match.rs:282:9 + --> tests/ui/collapsible_match.rs:282:9 | LL | / if let Some(u) = a { LL | | @@ -217,7 +217,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match.rs:281:35 + --> tests/ui/collapsible_match.rs:281:35 | LL | if let Issue9647::A { a: Some(a), .. } = x { | ^ replace this binding diff --git a/src/tools/clippy/tests/ui/collapsible_match2.stderr b/src/tools/clippy/tests/ui/collapsible_match2.stderr index e008355bec8aa..13caa78fbeb54 100644 --- a/src/tools/clippy/tests/ui/collapsible_match2.stderr +++ b/src/tools/clippy/tests/ui/collapsible_match2.stderr @@ -1,5 +1,5 @@ error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:13:34 + --> tests/ui/collapsible_match2.rs:13:34 | LL | Ok(val) if make() => match val { | __________________________________^ @@ -10,7 +10,7 @@ LL | | }, | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:13:16 + --> tests/ui/collapsible_match2.rs:13:16 | LL | Ok(val) if make() => match val { | ^^^ replace this binding @@ -21,7 +21,7 @@ LL | Some(n) => foo(n), = 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 + --> tests/ui/collapsible_match2.rs:21:24 | LL | Ok(val) => match val { | ________________________^ @@ -32,7 +32,7 @@ LL | | }, | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:21:16 + --> tests/ui/collapsible_match2.rs:21:16 | LL | Ok(val) => match val { | ^^^ replace this binding @@ -41,7 +41,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:36:29 + --> tests/ui/collapsible_match2.rs:36:29 | LL | $pat => match $e { | _____________________________^ @@ -54,7 +54,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); | ------------------------------------------------ in this macro invocation | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:48:28 + --> tests/ui/collapsible_match2.rs:48:28 | LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); | ^^^ ^^^^^^^ with this pattern @@ -63,7 +63,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:53:20 + --> tests/ui/collapsible_match2.rs:53:20 | LL | Some(s) => match *s { | ____________________^ @@ -74,7 +74,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:53:14 + --> tests/ui/collapsible_match2.rs:53:14 | LL | Some(s) => match *s { | ^ replace this binding @@ -83,7 +83,7 @@ LL | [n] => foo(n), | ^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> $DIR/collapsible_match2.rs:63:24 + --> tests/ui/collapsible_match2.rs:63:24 | LL | Some(ref s) => match s { | ________________________^ @@ -94,7 +94,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> $DIR/collapsible_match2.rs:63:14 + --> tests/ui/collapsible_match2.rs:63:14 | LL | Some(ref s) => match s { | ^^^^^ replace this binding diff --git a/src/tools/clippy/tests/ui/collapsible_str_replace.stderr b/src/tools/clippy/tests/ui/collapsible_str_replace.stderr index 4b0bd818d2f00..da681dffd8757 100644 --- a/src/tools/clippy/tests/ui/collapsible_str_replace.stderr +++ b/src/tools/clippy/tests/ui/collapsible_str_replace.stderr @@ -1,5 +1,5 @@ error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:18:27 + --> tests/ui/collapsible_str_replace.rs:18:27 | LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], "l")` @@ -8,19 +8,19 @@ LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l"); = help: to override `-D warnings` add `#[allow(clippy::collapsible_str_replace)]` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:20:27 + --> tests/ui/collapsible_str_replace.rs:20:27 | LL | let _ = "hesuo worpd".replace('s', l).replace('u', l); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], l)` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:22:27 + --> tests/ui/collapsible_str_replace.rs:22:27 | LL | let _ = "hesuo worpd".replace('s', "l").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:25:10 + --> tests/ui/collapsible_str_replace.rs:25:10 | LL | .replace('s', "l") | __________^ @@ -30,61 +30,61 @@ LL | | .replace('d', "l"); | |__________________________^ help: replace with: `replace(['s', 'u', 'p', 'd'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:30:27 + --> tests/ui/collapsible_str_replace.rs:30:27 | LL | let _ = "hesuo world".replace(s, "l").replace('u', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, 'u'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:32:27 + --> tests/ui/collapsible_str_replace.rs:32:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, 'u', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:34:27 + --> tests/ui/collapsible_str_replace.rs:34:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, u, 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:36:27 + --> tests/ui/collapsible_str_replace.rs:36:27 | LL | let _ = "hesuo worpd".replace(s, "l").replace(u, "l").replace(p, "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([s, u, p], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:38:27 + --> tests/ui/collapsible_str_replace.rs:38:27 | LL | let _ = "hesuo worlp".replace('s', "l").replace('u', "l").replace('p', "d"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['s', 'u'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:40:45 + --> tests/ui/collapsible_str_replace.rs:40:45 | LL | let _ = "hesuo worpd".replace('s', "x").replace('u', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['u', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:43:47 + --> tests/ui/collapsible_str_replace.rs:43:47 | LL | let _ = "hesudo worpd".replace("su", "l").replace('d', "l").replace('p', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['d', 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:45:28 + --> tests/ui/collapsible_str_replace.rs:45:28 | LL | let _ = "hesudo worpd".replace(d, "l").replace('p', "l").replace("su", "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([d, 'p'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:47:27 + --> tests/ui/collapsible_str_replace.rs:47:27 | LL | let _ = "hesuo world".replace(get_filter(), "l").replace('s', "l"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace([get_filter(), 's'], "l")` error: used consecutive `str::replace` call - --> $DIR/collapsible_str_replace.rs:84:16 + --> tests/ui/collapsible_str_replace.rs:84:16 | LL | let _ = "".replace('a', "1.58").replace('b', "1.58"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `replace(['a', 'b'], "1.58")` 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 acb9abff68e9b..f91ce07483c33 100644 --- a/src/tools/clippy/tests/ui/collection_is_never_read.stderr +++ b/src/tools/clippy/tests/ui/collection_is_never_read.stderr @@ -1,5 +1,5 @@ error: collection is never read - --> $DIR/collection_is_never_read.rs:21:5 + --> tests/ui/collection_is_never_read.rs:21:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,115 +8,115 @@ LL | let mut x = HashMap::new(); = 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 + --> tests/ui/collection_is_never_read.rs:62:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:78:5 + --> tests/ui/collection_is_never_read.rs:78:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:84:5 + --> tests/ui/collection_is_never_read.rs:84:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:93:5 + --> tests/ui/collection_is_never_read.rs:93:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:100:5 + --> tests/ui/collection_is_never_read.rs:100:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:107:5 + --> tests/ui/collection_is_never_read.rs:107:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:115:5 + --> tests/ui/collection_is_never_read.rs:115:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:133:5 + --> tests/ui/collection_is_never_read.rs:133:5 | LL | let mut x = HashSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:148:5 + --> tests/ui/collection_is_never_read.rs:148:5 | LL | let x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:184:5 + --> tests/ui/collection_is_never_read.rs:184:5 | LL | let mut x = std::collections::BTreeMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:188:5 + --> tests/ui/collection_is_never_read.rs:188:5 | LL | let mut x = std::collections::BTreeSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:192:5 + --> tests/ui/collection_is_never_read.rs:192:5 | LL | let mut x = std::collections::BinaryHeap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:196:5 + --> tests/ui/collection_is_never_read.rs:196:5 | LL | let mut x = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:200:5 + --> tests/ui/collection_is_never_read.rs:200:5 | LL | let mut x = std::collections::HashSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:204:5 + --> tests/ui/collection_is_never_read.rs:204:5 | LL | let mut x = std::collections::LinkedList::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:208:5 + --> tests/ui/collection_is_never_read.rs:208:5 | LL | let mut x = Some(true); | ^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:212:5 + --> tests/ui/collection_is_never_read.rs:212:5 | LL | let mut x = String::from("hello"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:216:5 + --> tests/ui/collection_is_never_read.rs:216:5 | LL | let mut x = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> $DIR/collection_is_never_read.rs:221:5 + --> tests/ui/collection_is_never_read.rs:221:5 | LL | let mut x = std::collections::VecDeque::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/comparison_chain.stderr b/src/tools/clippy/tests/ui/comparison_chain.stderr index 3b41dcf55c623..96d8d819e6a55 100644 --- a/src/tools/clippy/tests/ui/comparison_chain.stderr +++ b/src/tools/clippy/tests/ui/comparison_chain.stderr @@ -1,5 +1,5 @@ error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:14:5 + --> tests/ui/comparison_chain.rs:14:5 | LL | / if x > y { LL | | @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::comparison_chain)]` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:28:5 + --> tests/ui/comparison_chain.rs:28:5 | LL | / if x > y { LL | | @@ -28,7 +28,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:37:5 + --> tests/ui/comparison_chain.rs:37:5 | LL | / if x > y { LL | | @@ -42,7 +42,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:46:5 + --> tests/ui/comparison_chain.rs:46:5 | LL | / if x > 1 { LL | | @@ -56,7 +56,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:121:5 + --> tests/ui/comparison_chain.rs:121:5 | LL | / if x > y { LL | | @@ -69,7 +69,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:128:5 + --> tests/ui/comparison_chain.rs:128:5 | LL | / if x > y { LL | | @@ -83,7 +83,7 @@ LL | | } = help: consider rewriting the `if` chain to use `cmp` and `match` error: `if` chain can be rewritten with `match` - --> $DIR/comparison_chain.rs:137:5 + --> tests/ui/comparison_chain.rs:137:5 | LL | / if x > y { LL | | diff --git a/src/tools/clippy/tests/ui/comparison_to_empty.stderr b/src/tools/clippy/tests/ui/comparison_to_empty.stderr index 83d431fd52b49..6b027459ed347 100644 --- a/src/tools/clippy/tests/ui/comparison_to_empty.stderr +++ b/src/tools/clippy/tests/ui/comparison_to_empty.stderr @@ -1,5 +1,5 @@ error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:8:13 + --> tests/ui/comparison_to_empty.rs:8:13 | LL | let _ = s == ""; | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` @@ -8,49 +8,49 @@ LL | let _ = s == ""; = help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:9:13 + --> tests/ui/comparison_to_empty.rs:9:13 | LL | let _ = s != ""; | ^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!s.is_empty()` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:12:13 + --> tests/ui/comparison_to_empty.rs:12:13 | LL | let _ = v == []; | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `v.is_empty()` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:13:13 + --> tests/ui/comparison_to_empty.rs:13:13 | LL | let _ = v != []; | ^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!v.is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:14:8 + --> tests/ui/comparison_to_empty.rs:14:8 | LL | if let [] = &*v {} | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(*v).is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:16:8 + --> tests/ui/comparison_to_empty.rs:16:8 | LL | if let [] = s {} | ^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:17:8 + --> tests/ui/comparison_to_empty.rs:17:8 | LL | if let [] = &*s {} | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` error: comparison to empty slice using `if let` - --> $DIR/comparison_to_empty.rs:18:8 + --> tests/ui/comparison_to_empty.rs:18:8 | LL | if let [] = &*s | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` error: comparison to empty slice - --> $DIR/comparison_to_empty.rs:19:12 + --> tests/ui/comparison_to_empty.rs:19:12 | LL | && s == [] | ^^^^^^^ help: using `is_empty` is clearer and more explicit: `s.is_empty()` diff --git a/src/tools/clippy/tests/ui/const_comparisons.stderr b/src/tools/clippy/tests/ui/const_comparisons.stderr index f773ccbc711e9..1b8fd9733fae7 100644 --- a/src/tools/clippy/tests/ui/const_comparisons.stderr +++ b/src/tools/clippy/tests/ui/const_comparisons.stderr @@ -1,5 +1,5 @@ error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:45:5 + --> tests/ui/const_comparisons.rs:45:5 | LL | status_code <= 400 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | status_code <= 400 && status_code > 500; = help: to override `-D warnings` add `#[allow(clippy::impossible_comparisons)]` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:48:5 + --> tests/ui/const_comparisons.rs:48:5 | LL | status_code > 500 && status_code < 400; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | status_code > 500 && status_code < 400; = note: since `500` > `400`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:51:5 + --> tests/ui/const_comparisons.rs:51:5 | LL | status_code < 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | status_code < 500 && status_code > 500; = note: `status_code` cannot simultaneously be greater than and less than `500` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:56:5 + --> tests/ui/const_comparisons.rs:56:5 | LL | status_code < { 400 } && status_code > { 500 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | status_code < { 400 } && status_code > { 500 }; = note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:59:5 + --> tests/ui/const_comparisons.rs:59:5 | LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR; = note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:62:5 + --> tests/ui/const_comparisons.rs:62:5 | LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR; = note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:65:5 + --> tests/ui/const_comparisons.rs:65:5 | LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR; = note: `status_code` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:70:5 + --> tests/ui/const_comparisons.rs:70:5 | LL | status < { 400 } && status > { 500 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | status < { 400 } && status > { 500 }; = note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:73:5 + --> tests/ui/const_comparisons.rs:73:5 | LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR; = note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:76:5 + --> tests/ui/const_comparisons.rs:76:5 | LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR; = note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:79:5 + --> tests/ui/const_comparisons.rs:79:5 | LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR; = note: `status` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:89:5 + --> tests/ui/const_comparisons.rs:89:5 | LL | 500 >= status_code && 600 < status_code; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | 500 >= status_code && 600 < status_code; = note: since `500` < `600`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:93:5 + --> tests/ui/const_comparisons.rs:93:5 | LL | 500 >= status_code && status_code > 600; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | 500 >= status_code && status_code > 600; = note: since `500` < `600`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:103:5 + --> tests/ui/const_comparisons.rs:103:5 | LL | 500 >= status && 600 < status; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | 500 >= status && 600 < status; = note: since `500` < `600`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:107:5 + --> tests/ui/const_comparisons.rs:107:5 | LL | 500 >= status && status > 600; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,13 +121,13 @@ LL | 500 >= status && status > 600; = note: since `500` < `600`, the expression evaluates to false for any value of `status` error: right-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:112:5 + --> tests/ui/const_comparisons.rs:112:5 | LL | status_code < 200 && status_code <= 299; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 200` evaluates to true, status_code <= 299` will always evaluate to true as well - --> $DIR/const_comparisons.rs:112:23 + --> tests/ui/const_comparisons.rs:112:23 | LL | status_code < 200 && status_code <= 299; | ^^^^^^^^^^^^^^^^^^^^^ @@ -135,67 +135,67 @@ LL | status_code < 200 && status_code <= 299; = 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 + --> tests/ui/const_comparisons.rs:114:5 | LL | status_code > 200 && status_code >= 299; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code >= 299` evaluates to true, status_code > 200` will always evaluate to true as well - --> $DIR/const_comparisons.rs:114:5 + --> tests/ui/const_comparisons.rs:114:5 | LL | status_code > 200 && status_code >= 299; | ^^^^^^^^^^^^^^^^^^^^^ error: left-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:118:5 + --> tests/ui/const_comparisons.rs:118:5 | LL | status_code >= 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:118:5 + --> tests/ui/const_comparisons.rs:118:5 | LL | status_code >= 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^ error: right-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:121:5 + --> tests/ui/const_comparisons.rs:121:5 | LL | status_code > 500 && status_code >= 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:121:23 + --> tests/ui/const_comparisons.rs:121:23 | LL | status_code > 500 && status_code >= 500; | ^^^^^^^^^^^^^^^^^^^^^ error: left-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:124:5 + --> tests/ui/const_comparisons.rs:124:5 | LL | status_code <= 500 && status_code < 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:124:5 + --> tests/ui/const_comparisons.rs:124:5 | LL | status_code <= 500 && status_code < 500; | ^^^^^^^^^^^^^^^^^^^^^^ error: right-hand side of `&&` operator has no effect - --> $DIR/const_comparisons.rs:127:5 + --> tests/ui/const_comparisons.rs:127:5 | LL | status_code < 500 && status_code <= 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well - --> $DIR/const_comparisons.rs:127:23 + --> tests/ui/const_comparisons.rs:127:23 | LL | status_code < 500 && status_code <= 500; | ^^^^^^^^^^^^^^^^^^^^^ error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:132:5 + --> tests/ui/const_comparisons.rs:132:5 | LL | name < "Jennifer" && name > "Shannon"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | name < "Jennifer" && name > "Shannon"; = note: since `"Jennifer"` < `"Shannon"`, the expression evaluates to false for any value of `name` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:137:5 + --> tests/ui/const_comparisons.rs:137:5 | LL | numbers < [3, 4] && numbers > [5, 6]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +211,7 @@ LL | numbers < [3, 4] && numbers > [5, 6]; = note: since `[3, 4]` < `[5, 6]`, the expression evaluates to false for any value of `numbers` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:142:5 + --> tests/ui/const_comparisons.rs:142:5 | LL | letter < 'b' && letter > 'c'; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | letter < 'b' && letter > 'c'; = note: since `'b'` < `'c'`, the expression evaluates to false for any value of `letter` error: boolean expression will never evaluate to 'true' - --> $DIR/const_comparisons.rs:147:5 + --> tests/ui/const_comparisons.rs:147:5 | LL | area < std::f32::consts::E && area > std::f32::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/copy_iterator.stderr b/src/tools/clippy/tests/ui/copy_iterator.stderr index 30535db50cc9a..533bddaadb5ec 100644 --- a/src/tools/clippy/tests/ui/copy_iterator.stderr +++ b/src/tools/clippy/tests/ui/copy_iterator.stderr @@ -1,5 +1,5 @@ error: you are implementing `Iterator` on a `Copy` type - --> $DIR/copy_iterator.rs:6:1 + --> tests/ui/copy_iterator.rs:6:1 | LL | / impl Iterator for Countdown { LL | | diff --git a/src/tools/clippy/tests/ui/crashes/ice-10148.stderr b/src/tools/clippy/tests/ui/crashes/ice-10148.stderr index ece3e1c394037..639cf2dd442b8 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-10148.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-10148.stderr @@ -1,5 +1,5 @@ error: empty string literal in `println!` - --> $DIR/ice-10148.rs:8:5 + --> tests/ui/crashes/ice-10148.rs:8:5 | LL | println!(with_span!(""something "")); | ^^^^^^^^^^^^^^^^^^^^-----------^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-10645.stderr b/src/tools/clippy/tests/ui/crashes/ice-10645.stderr index 7fc62d4fcf855..0269072b88bc1 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-10645.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-10645.stderr @@ -1,11 +1,11 @@ warning: future cannot be sent between threads safely - --> $DIR/ice-10645.rs:5:1 + --> tests/ui/crashes/ice-10645.rs:5:1 | LL | pub async fn bar<'a, T: 'a>(_: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `bar` is not `Send` | note: captured value is not `Send` - --> $DIR/ice-10645.rs:5:29 + --> tests/ui/crashes/ice-10645.rs:5:29 | LL | pub async fn bar<'a, T: 'a>(_: T) {} | ^ has type `T` which is not `Send` diff --git a/src/tools/clippy/tests/ui/crashes/ice-10912.rs b/src/tools/clippy/tests/ui/crashes/ice-10912.rs index 8dfce19422171..1d689e1d0082d 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-10912.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-10912.rs @@ -2,7 +2,5 @@ //@no-rustfix fn f2() -> impl Sized { && 3.14159265358979323846E } //~^ ERROR: expected at least one digit in exponent -//~| ERROR: long literal lacking separators -//~| NOTE: `-D clippy::unreadable-literal` implied by `-D warnings` fn main() {} diff --git a/src/tools/clippy/tests/ui/crashes/ice-10912.stderr b/src/tools/clippy/tests/ui/crashes/ice-10912.stderr index 2be297b56250f..c697e54679f96 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-10912.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-10912.stderr @@ -1,17 +1,8 @@ error: expected at least one digit in exponent - --> $DIR/ice-10912.rs:3:28 + --> tests/ui/crashes/ice-10912.rs:3:28 | LL | fn f2() -> impl Sized { && 3.14159265358979323846E } | ^^^^^^^^^^^^^^^^^^^^^^^ -error: long literal lacking separators - --> $DIR/ice-10912.rs:3:28 - | -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 +error: aborting due to 1 previous error diff --git a/src/tools/clippy/tests/ui/crashes/ice-11065.rs b/src/tools/clippy/tests/ui/crashes/ice-11065.rs index f5cf6b1cd77a2..a17d7e38e0c35 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-11065.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-11065.rs @@ -1,6 +1,5 @@ #![warn(clippy::useless_conversion)] -use std::iter::FromIterator; use std::option::IntoIter as OptionIter; fn eq(a: T, b: T) -> bool { diff --git a/src/tools/clippy/tests/ui/crashes/ice-11422.stderr b/src/tools/clippy/tests/ui/crashes/ice-11422.stderr index b3dcc00f3d9ef..a340977f4699d 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-11422.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-11422.stderr @@ -1,5 +1,5 @@ error: this bound is already specified as the supertrait of `PartialOrd` - --> $DIR/ice-11422.rs:6:31 + --> tests/ui/crashes/ice-11422.rs:6:31 | LL | fn gen() -> impl PartialOrd + PartialEq + Debug {} | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-11803.stderr b/src/tools/clippy/tests/ui/crashes/ice-11803.stderr index b8289048a8b90..f62de8e2b9dbe 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-11803.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-11803.stderr @@ -1,5 +1,5 @@ error: `impl Trait` used as a function parameter - --> $DIR/ice-11803.rs:5:54 + --> tests/ui/crashes/ice-11803.rs:5:54 | LL | pub fn g>>() { | ^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | pub fn g>, { /* Gen | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/ice-11803.rs:5:33 + --> tests/ui/crashes/ice-11803.rs:5:33 | LL | pub fn g>>() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-12253.rs b/src/tools/clippy/tests/ui/crashes/ice-12253.rs new file mode 100644 index 0000000000000..41f50035144a7 --- /dev/null +++ b/src/tools/clippy/tests/ui/crashes/ice-12253.rs @@ -0,0 +1,5 @@ +#[allow(overflowing_literals, unconditional_panic, clippy::no_effect)] +fn main() { + let arr: [i32; 5] = [0; 5]; + arr[0xfffffe7ffffffffffffffffffffffff]; +} diff --git a/src/tools/clippy/tests/ui/crashes/ice-2774.stderr b/src/tools/clippy/tests/ui/crashes/ice-2774.stderr index 188a5985024e7..a8c92166358af 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-2774.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-2774.stderr @@ -1,5 +1,5 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/ice-2774.rs:15:28 + --> tests/ui/crashes/ice-2774.rs:15:28 | 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 a84697a9f291d..50b245c65cde5 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-360.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-360.stderr @@ -1,5 +1,5 @@ error: this loop never actually loops - --> $DIR/ice-360.rs:5:5 + --> tests/ui/crashes/ice-360.rs:5:5 | LL | / loop { LL | | @@ -13,7 +13,7 @@ LL | | } = note: `#[deny(clippy::never_loop)]` on by default error: this loop could be written as a `while let` loop - --> $DIR/ice-360.rs:5:5 + --> tests/ui/crashes/ice-360.rs:5:5 | LL | / loop { LL | | @@ -28,7 +28,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: empty `loop {}` wastes CPU cycles - --> $DIR/ice-360.rs:13:9 + --> tests/ui/crashes/ice-360.rs:13:9 | LL | loop {} | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-3717.stderr b/src/tools/clippy/tests/ui/crashes/ice-3717.stderr index 863608fca8bdf..54b18a9641afc 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-3717.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-3717.stderr @@ -1,11 +1,11 @@ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/ice-3717.rs:7:21 + --> tests/ui/crashes/ice-3717.rs:7:21 | LL | pub fn ice_3717(_: &HashSet) { | ^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/ice-3717.rs:1:9 + --> tests/ui/crashes/ice-3717.rs:1:9 | LL | #![deny(clippy::implicit_hasher)] | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-3891.stderr b/src/tools/clippy/tests/ui/crashes/ice-3891.stderr index 5358734fed04e..b6a2c9d3de839 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-3891.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-3891.stderr @@ -1,5 +1,5 @@ error: invalid suffix `x` for number literal - --> $DIR/ice-3891.rs:2:5 + --> tests/ui/crashes/ice-3891.rs:2:5 | LL | 1x; | ^^ invalid suffix `x` diff --git a/src/tools/clippy/tests/ui/crashes/ice-3969.stderr b/src/tools/clippy/tests/ui/crashes/ice-3969.stderr index c6bef3004d377..285efee36bd85 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-3969.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-3969.stderr @@ -1,5 +1,5 @@ error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:20:10 + --> tests/ui/crashes/ice-3969.rs:20:10 | LL | str: Sized; | ^^^^^ @@ -8,25 +8,25 @@ LL | str: Sized; = 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 + --> tests/ui/crashes/ice-3969.rs:26:30 | LL | for<'a> Dst: Sized, | ^^^^^ error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:34:10 + --> tests/ui/crashes/ice-3969.rs:34:10 | LL | str: Sized, | ^^^^^ error: trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:42:13 + --> tests/ui/crashes/ice-3969.rs:42:13 | LL | String: ::std::ops::Neg, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters - --> $DIR/ice-3969.rs:50:10 + --> tests/ui/crashes/ice-3969.rs:50:10 | LL | i32: Iterator, | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-4760.rs b/src/tools/clippy/tests/ui/crashes/ice-4760.rs index 08b06961760ff..e1265169762fc 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-4760.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-4760.rs @@ -1,3 +1,5 @@ +#![allow(non_local_definitions)] + const COUNT: usize = 2; struct Thing; trait Dummy {} diff --git a/src/tools/clippy/tests/ui/crashes/ice-5497.stderr b/src/tools/clippy/tests/ui/crashes/ice-5497.stderr index 3efaf05827e80..2f7dd3bd563a4 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-5497.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-5497.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/ice-5497.rs:11:22 + --> tests/ui/crashes/ice-5497.rs:11:22 | LL | const OOB: i32 = [1][1] + T::OOB; | ^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/src/tools/clippy/tests/ui/crashes/ice-5835.stderr b/src/tools/clippy/tests/ui/crashes/ice-5835.stderr index 1f930e1f6d2cc..45e5e9a4b83d5 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-5835.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-5835.stderr @@ -1,5 +1,5 @@ error: using tabs in doc comments is not recommended - --> $DIR/ice-5835.rs:3:10 + --> tests/ui/crashes/ice-5835.rs:3:10 | LL | /// 位 | ^^^^ help: consider using four spaces per tab diff --git a/src/tools/clippy/tests/ui/crashes/ice-5872.stderr b/src/tools/clippy/tests/ui/crashes/ice-5872.stderr index d0067a2239e97..3f6568d34542b 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-5872.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-5872.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/ice-5872.rs:4:39 + --> tests/ui/crashes/ice-5872.rs:4:39 | LL | let _ = vec![1, 2, 3].into_iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` diff --git a/src/tools/clippy/tests/ui/crashes/ice-6179.rs b/src/tools/clippy/tests/ui/crashes/ice-6179.rs index ce1895851e2d9..fffc0f7d0d4f2 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6179.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-6179.rs @@ -3,6 +3,7 @@ #![warn(clippy::use_self)] #![allow(dead_code, clippy::let_with_type_underscore)] +#![allow(non_local_definitions)] struct Foo; diff --git a/src/tools/clippy/tests/ui/crashes/ice-6250.stderr b/src/tools/clippy/tests/ui/crashes/ice-6250.stderr index 97390af3e89ed..c126547611f36 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6250.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6250.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ice-6250.rs:12:14 + --> tests/ui/crashes/ice-6250.rs:12:14 | LL | for reference in vec![1, 2, 3] { | --------- expected due to the type of this binding @@ -8,7 +8,7 @@ LL | Some(reference) = cache.data.get(key) { | ^^^^^^^^^ expected integer, found `&i32` error[E0308]: mismatched types - --> $DIR/ice-6250.rs:12:9 + --> tests/ui/crashes/ice-6250.rs:12:9 | LL | Some(reference) = cache.data.get(key) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` diff --git a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr index 0196c9923dbe6..82e7d72358697 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/ice-6251.rs:4:45 + --> tests/ui/crashes/ice-6251.rs:4:45 | LL | fn bug() -> impl Iterator { | ^ doesn't have a size known at compile-time @@ -12,7 +12,7 @@ LL | fn bug() -> impl Iterator { | + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/ice-6251.rs:4:54 + --> tests/ui/crashes/ice-6251.rs:4:54 | LL | fn bug() -> impl Iterator { | ^ doesn't have a size known at compile-time @@ -21,13 +21,13 @@ LL | fn bug() -> impl Iterator { = note: the return type of a function must have a statically known size error[E0308]: mismatched types - --> $DIR/ice-6251.rs:4:44 + --> tests/ui/crashes/ice-6251.rs:4:44 | LL | fn bug() -> impl Iterator { | ^^^^^^^^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `{closure@$DIR/ice-6251.rs:4:44: 4:53}` + found closure `{closure@tests/ui/crashes/ice-6251.rs:4:44: 4:53}` error: aborting due to 3 previous errors diff --git a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr index f6d0976091c53..ce3b9495eb1ea 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `PhantomData` in this scope - --> $DIR/ice-6252.rs:9:9 + --> tests/ui/crashes/ice-6252.rs:9:9 | LL | _n: PhantomData, | ^^^^^^^^^^^ not found in this scope @@ -12,7 +12,7 @@ LL + use std::marker::PhantomData; | error[E0412]: cannot find type `VAL` in this scope - --> $DIR/ice-6252.rs:11:63 + --> tests/ui/crashes/ice-6252.rs:11:63 | LL | impl TypeVal for Multiply where N: TypeVal {} | ^^^ not found in this scope @@ -23,7 +23,7 @@ LL | impl TypeVal for Multiply where N: TypeVal {} | +++++ error[E0046]: not all trait items implemented, missing: `VAL` - --> $DIR/ice-6252.rs:11:1 + --> tests/ui/crashes/ice-6252.rs:11:1 | LL | const VAL: T; | ------------ `VAL` from trait diff --git a/src/tools/clippy/tests/ui/crashes/ice-6255.rs b/src/tools/clippy/tests/ui/crashes/ice-6255.rs index b6555ac5c4072..ef1e01f80ef0b 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6255.rs +++ b/src/tools/clippy/tests/ui/crashes/ice-6255.rs @@ -4,6 +4,7 @@ macro_rules! define_other_core { ( ) => { extern crate std as core; + //~^ ERROR: macro-expanded `extern crate` items cannot shadow names passed with `--extern` }; } @@ -12,4 +13,3 @@ fn main() { } define_other_core!(); -//~^ ERROR: macro-expanded `extern crate` items cannot shadow names passed with `--extern` diff --git a/src/tools/clippy/tests/ui/crashes/ice-6255.stderr b/src/tools/clippy/tests/ui/crashes/ice-6255.stderr index bc13319bef023..738e9d1bd5cad 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6255.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6255.stderr @@ -1,5 +1,5 @@ error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` - --> $DIR/ice-6255.rs:6:9 + --> tests/ui/crashes/ice-6255.rs:6:9 | LL | extern crate std as core; | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-6256.stderr b/src/tools/clippy/tests/ui/crashes/ice-6256.stderr index cba6df194eccb..922772a6147bc 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6256.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6256.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/ice-6256.rs:13:26 + --> tests/ui/crashes/ice-6256.rs:13:26 | LL | let f = |x: &dyn TT| x.func(); | - - ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-7169.stderr b/src/tools/clippy/tests/ui/crashes/ice-7169.stderr index 3126de93d2241..ac7d2862d3ade 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-7169.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-7169.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/ice-7169.rs:10:12 + --> tests/ui/crashes/ice-7169.rs:10:12 | LL | if let Ok(_) = Ok::<_, ()>(A::::default()) {} | -------^^^^^-------------------------------------- help: try: `if Ok::<_, ()>(A::::default()).is_ok()` diff --git a/src/tools/clippy/tests/ui/crashes/ice-7868.stderr b/src/tools/clippy/tests/ui/crashes/ice-7868.stderr index 3315a8d907ae6..1aba43604ff18 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-7868.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-7868.stderr @@ -1,5 +1,5 @@ error: unsafe block missing a safety comment - --> $DIR/auxiliary/ice-7868-aux.rs:2:5 + --> tests/ui/crashes/auxiliary/ice-7868-aux.rs:2:5 | LL | unsafe { 0 }; | ^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-7869.stderr b/src/tools/clippy/tests/ui/crashes/ice-7869.stderr index 22f2c7e46fdc5..2377b4fd5b6bb 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-7869.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-7869.stderr @@ -1,5 +1,5 @@ error: all variants have the same prefix: `Työ` - --> $DIR/ice-7869.rs:1:1 + --> tests/ui/crashes/ice-7869.rs:1:1 | LL | / enum Tila { LL | | diff --git a/src/tools/clippy/tests/ui/crashes/ice-8250.stderr b/src/tools/clippy/tests/ui/crashes/ice-8250.stderr index 397e978af0bd6..61576f13d1e1a 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-8250.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-8250.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `splitn` - --> $DIR/ice-8250.rs:2:13 + --> tests/ui/crashes/ice-8250.rs:2:13 | LL | let _ = s[1..].splitn(2, '.').next()?; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `s[1..].split('.')` diff --git a/src/tools/clippy/tests/ui/crashes/ice-8850.stderr b/src/tools/clippy/tests/ui/crashes/ice-8850.stderr index aa140f305e39d..5a8f24ee8c0be 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-8850.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-8850.stderr @@ -1,5 +1,5 @@ error: returning the result of a `let` binding from a block - --> $DIR/ice-8850.rs:4:5 + --> tests/ui/crashes/ice-8850.rs:4:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding @@ -15,7 +15,7 @@ LL ~ FN() + 1 | error: returning the result of a `let` binding from a block - --> $DIR/ice-8850.rs:12:5 + --> tests/ui/crashes/ice-8850.rs:12:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding @@ -29,7 +29,7 @@ LL ~ FN() + 1 | error: returning the result of a `let` binding from a block - --> $DIR/ice-8850.rs:27:5 + --> tests/ui/crashes/ice-8850.rs:27:5 | LL | let res = FN() + 1; | ------------------- unnecessary `let` binding diff --git a/src/tools/clippy/tests/ui/crashes/ice-9041.stderr b/src/tools/clippy/tests/ui/crashes/ice-9041.stderr index 67589d1a8ab32..dd9db71c5de83 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9041.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-9041.stderr @@ -1,5 +1,5 @@ error: called `is_some()` after searching an `Iterator` with `find` - --> $DIR/ice-9041.rs:5:19 + --> tests/ui/crashes/ice-9041.rs:5:19 | LL | things.iter().find(|p| is_thing_ready(p)).is_some() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `any(|p| is_thing_ready(&p))` diff --git a/src/tools/clippy/tests/ui/crashes/ice-9405.stderr b/src/tools/clippy/tests/ui/crashes/ice-9405.stderr index 56649a2bdfcb5..e8a73b9e782ef 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9405.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-9405.stderr @@ -1,5 +1,5 @@ warning: multiple lines skipped by escaped newline - --> $DIR/ice-9405.rs:6:10 + --> tests/ui/crashes/ice-9405.rs:6:10 | LL | "\ | __________^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-9445.stderr b/src/tools/clippy/tests/ui/crashes/ice-9445.stderr index f97b4536e129a..d6957e9549d69 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9445.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-9445.stderr @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/ice-9445.rs:1:1 + --> tests/ui/crashes/ice-9445.rs:1:1 | LL | const UNINIT: core::mem::MaybeUninit> = core::mem::MaybeUninit::uninit(); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-9463.stderr b/src/tools/clippy/tests/ui/crashes/ice-9463.stderr index 911795694c38e..9a3a5e444ade8 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-9463.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-9463.stderr @@ -1,23 +1,23 @@ error: this arithmetic operation will overflow - --> $DIR/ice-9463.rs:3:14 + --> tests/ui/crashes/ice-9463.rs:3:14 | LL | let _x = -1_i32 >> -1; | ^^^^^^^^^^^^ attempt to shift right by `-1_i32`, which would overflow | note: the lint level is defined here - --> $DIR/ice-9463.rs:1:9 + --> tests/ui/crashes/ice-9463.rs:1:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ error: this arithmetic operation will overflow - --> $DIR/ice-9463.rs:5:14 + --> tests/ui/crashes/ice-9463.rs:5:14 | LL | let _y = 1u32 >> 10000000000000u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift right by `1316134912_u32`, which would overflow error: literal out of range for `u32` - --> $DIR/ice-9463.rs:5:22 + --> tests/ui/crashes/ice-9463.rs:5:22 | LL | let _y = 1u32 >> 10000000000000u32; | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/crashes/ice-96721.stderr b/src/tools/clippy/tests/ui/crashes/ice-96721.stderr index 1741c7c6a0a22..f0778a4b32b3e 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-96721.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-96721.stderr @@ -1,5 +1,5 @@ error: malformed `path` attribute input - --> $DIR/ice-96721.rs:7:1 + --> tests/ui/crashes/ice-96721.rs:7:1 | LL | #[path = foo!()] | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]` diff --git a/src/tools/clippy/tests/ui/crashes/needless_lifetimes_impl_trait.stderr b/src/tools/clippy/tests/ui/crashes/needless_lifetimes_impl_trait.stderr index 2ebb9d5cd1a12..3a2d1f4410ef1 100644 --- a/src/tools/clippy/tests/ui/crashes/needless_lifetimes_impl_trait.stderr +++ b/src/tools/clippy/tests/ui/crashes/needless_lifetimes_impl_trait.stderr @@ -1,11 +1,11 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes_impl_trait.rs:15:12 + --> tests/ui/crashes/needless_lifetimes_impl_trait.rs:15:12 | LL | fn baz<'a>(&'a self) -> impl Foo + 'a { | ^^ ^^ ^^ | note: the lint level is defined here - --> $DIR/needless_lifetimes_impl_trait.rs:1:9 + --> tests/ui/crashes/needless_lifetimes_impl_trait.rs:1:9 | LL | #![deny(clippy::needless_lifetimes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 b318f8d3f7af1..90076d4338a47 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 @@ -1,11 +1,11 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value-w-late-bound.rs:7:12 + --> tests/ui/crashes/needless_pass_by_value-w-late-bound.rs:7:12 | LL | fn test(x: Foo<'_>) {} | ^^^^^^^ help: consider taking a reference instead: `&Foo<'_>` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value-w-late-bound.rs:5:1 + --> tests/ui/crashes/needless_pass_by_value-w-late-bound.rs:5:1 | LL | struct Foo<'a>(&'a [(); 100]); | ^^^^^^^^^^^^^^ 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 1a21d4e92f24a..4202e9bc10357 100644 --- a/src/tools/clippy/tests/ui/crate_in_macro_def.stderr +++ b/src/tools/clippy/tests/ui/crate_in_macro_def.stderr @@ -1,5 +1,5 @@ error: `crate` references the macro call's crate - --> $DIR/crate_in_macro_def.rs:18:28 + --> tests/ui/crate_in_macro_def.rs:18:28 | LL | println!("{}", crate::unhygienic::MESSAGE); | ^^^^^ help: to reference the macro definition's crate, use: `$crate` 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 7ef8d08d5d69e..7d7922ae8cac7 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 @@ -1,5 +1,5 @@ error: this looks like you are trying to swap `a` and `b` - --> $DIR/no_std_swap.rs:12:5 + --> tests/ui/crate_level_checks/no_std_swap.rs:12:5 | LL | / a = b; LL | | 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 3bc406206e4b5..319ab783d5591 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 @@ -1,5 +1,5 @@ error: recursing into entrypoint `main` - --> $DIR/std_main_recursion.rs:5:5 + --> tests/ui/crate_level_checks/std_main_recursion.rs:5:5 | LL | main(); | ^^^^ diff --git a/src/tools/clippy/tests/ui/create_dir.stderr b/src/tools/clippy/tests/ui/create_dir.stderr index 037e6ff173ac0..9c6e640ca784c 100644 --- a/src/tools/clippy/tests/ui/create_dir.stderr +++ b/src/tools/clippy/tests/ui/create_dir.stderr @@ -1,5 +1,5 @@ error: calling `std::fs::create_dir` where there may be a better way - --> $DIR/create_dir.rs:10:5 + --> tests/ui/create_dir.rs:10:5 | LL | std::fs::create_dir("foo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("foo")` @@ -8,7 +8,7 @@ LL | std::fs::create_dir("foo"); = 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 + --> tests/ui/create_dir.rs:11:5 | LL | std::fs::create_dir("bar").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `std::fs::create_dir_all` instead: `create_dir_all("bar")` diff --git a/src/tools/clippy/tests/ui/dbg_macro/dbg_macro.stderr b/src/tools/clippy/tests/ui/dbg_macro/dbg_macro.stderr index 4d00421c71186..5ad0bbfed9422 100644 --- a/src/tools/clippy/tests/ui/dbg_macro/dbg_macro.stderr +++ b/src/tools/clippy/tests/ui/dbg_macro/dbg_macro.stderr @@ -1,5 +1,5 @@ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/auxiliary/submodule.rs:2:5 + --> tests/ui/dbg_macro/auxiliary/submodule.rs:2:5 | LL | dbg!(); | ^^^^^^^ @@ -13,7 +13,7 @@ LL + | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:9:22 + --> tests/ui/dbg_macro/dbg_macro.rs:9:22 | LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:15:8 + --> tests/ui/dbg_macro/dbg_macro.rs:15:8 | LL | if dbg!(n <= 1) { | ^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | if n <= 1 { | ~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:17:9 + --> tests/ui/dbg_macro/dbg_macro.rs:17:9 | LL | dbg!(1) | ^^^^^^^ @@ -46,7 +46,7 @@ LL | 1 | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:20:9 + --> tests/ui/dbg_macro/dbg_macro.rs:20:9 | LL | dbg!(n * factorial(n - 1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | n * factorial(n - 1) | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:26:5 + --> tests/ui/dbg_macro/dbg_macro.rs:26:5 | LL | dbg!(42); | ^^^^^^^^ @@ -68,7 +68,7 @@ LL | 42; | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:28:5 + --> tests/ui/dbg_macro/dbg_macro.rs:28:5 | LL | dbg!(dbg!(dbg!(42))); | ^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | dbg!(dbg!(42)); | ~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:30:14 + --> tests/ui/dbg_macro/dbg_macro.rs:30:14 | LL | foo(3) + dbg!(factorial(4)); | ^^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:32:5 + --> tests/ui/dbg_macro/dbg_macro.rs:32:5 | LL | dbg!(1, 2, dbg!(3, 4)); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ LL | (1, 2, dbg!(3, 4)); | ~~~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:34:5 + --> tests/ui/dbg_macro/dbg_macro.rs:34:5 | LL | dbg!(1, 2, 3, 4, 5); | ^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | (1, 2, 3, 4, 5); | ~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:55:5 + --> tests/ui/dbg_macro/dbg_macro.rs:55:5 | LL | dbg!(); | ^^^^^^^ @@ -124,7 +124,7 @@ LL + | error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:58:13 + --> tests/ui/dbg_macro/dbg_macro.rs:58:13 | LL | let _ = dbg!(); | ^^^^^^ @@ -135,7 +135,7 @@ LL | let _ = (); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:60:9 + --> tests/ui/dbg_macro/dbg_macro.rs:60:9 | LL | bar(dbg!()); | ^^^^^^ @@ -146,7 +146,7 @@ LL | bar(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:62:10 + --> tests/ui/dbg_macro/dbg_macro.rs:62:10 | LL | foo!(dbg!()); | ^^^^^^ @@ -157,7 +157,7 @@ LL | foo!(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:64:16 + --> tests/ui/dbg_macro/dbg_macro.rs:64:16 | LL | foo2!(foo!(dbg!())); | ^^^^^^ @@ -168,7 +168,7 @@ LL | foo2!(foo!(())); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:86:9 + --> tests/ui/dbg_macro/dbg_macro.rs:86:9 | LL | dbg!(2); | ^^^^^^^ @@ -179,7 +179,7 @@ LL | 2; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:93:5 + --> tests/ui/dbg_macro/dbg_macro.rs:93:5 | LL | dbg!(1); | ^^^^^^^ @@ -190,7 +190,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:99:5 + --> tests/ui/dbg_macro/dbg_macro.rs:99:5 | LL | dbg!(1); | ^^^^^^^ @@ -201,7 +201,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> $DIR/dbg_macro.rs:106:9 + --> tests/ui/dbg_macro/dbg_macro.rs:106:9 | LL | dbg!(1); | ^^^^^^^ 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 b993bbf5526dd..83e1105a07dff 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 @@ -1,5 +1,5 @@ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:42:19 + --> tests/ui/debug_assert_with_mut_call.rs:42:19 | LL | debug_assert!(bool_mut(&mut 3)); | ^^^^^^^^^^^^^^^^ @@ -8,163 +8,163 @@ LL | debug_assert!(bool_mut(&mut 3)); = 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 + --> tests/ui/debug_assert_with_mut_call.rs:45:20 | LL | debug_assert!(!bool_mut(&mut 3)); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:48:25 + --> tests/ui/debug_assert_with_mut_call.rs:48:25 | LL | debug_assert_eq!(0, u32_mut(&mut 3)); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:50:22 + --> tests/ui/debug_assert_with_mut_call.rs:50:22 | LL | debug_assert_eq!(u32_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:53:25 + --> tests/ui/debug_assert_with_mut_call.rs:53:25 | LL | debug_assert_ne!(1, u32_mut(&mut 3)); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:55:22 + --> tests/ui/debug_assert_with_mut_call.rs:55:22 | LL | debug_assert_ne!(u32_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:71:19 + --> tests/ui/debug_assert_with_mut_call.rs:71:19 | LL | debug_assert!(S.bool_self_mut()); | ^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:73:20 + --> tests/ui/debug_assert_with_mut_call.rs:73:20 | LL | debug_assert!(!S.bool_self_mut()); | ^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:75:19 + --> tests/ui/debug_assert_with_mut_call.rs:75:19 | LL | debug_assert!(S.bool_self_ref_arg_mut(&mut 3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:77:19 + --> tests/ui/debug_assert_with_mut_call.rs:77:19 | LL | debug_assert!(S.bool_self_mut_arg_ref(&3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:79:19 + --> tests/ui/debug_assert_with_mut_call.rs:79:19 | LL | debug_assert!(S.bool_self_mut_arg_mut(&mut 3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:82:22 + --> tests/ui/debug_assert_with_mut_call.rs:82:22 | LL | debug_assert_eq!(S.u32_self_mut(), 0); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:84:22 + --> tests/ui/debug_assert_with_mut_call.rs:84:22 | LL | debug_assert_eq!(S.u32_self_mut_arg_ref(&3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:86:22 + --> tests/ui/debug_assert_with_mut_call.rs:86:22 | LL | debug_assert_eq!(S.u32_self_ref_arg_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:88:22 + --> tests/ui/debug_assert_with_mut_call.rs:88:22 | LL | debug_assert_eq!(S.u32_self_mut_arg_mut(&mut 3), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:91:22 + --> tests/ui/debug_assert_with_mut_call.rs:91:22 | LL | debug_assert_ne!(S.u32_self_mut(), 1); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:93:22 + --> tests/ui/debug_assert_with_mut_call.rs:93:22 | LL | debug_assert_ne!(S.u32_self_mut_arg_ref(&3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:95:22 + --> tests/ui/debug_assert_with_mut_call.rs:95:22 | LL | debug_assert_ne!(S.u32_self_ref_arg_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:97:22 + --> tests/ui/debug_assert_with_mut_call.rs:97:22 | LL | debug_assert_ne!(S.u32_self_mut_arg_mut(&mut 3), 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:106:22 + --> tests/ui/debug_assert_with_mut_call.rs:106:22 | LL | debug_assert_eq!(v.pop(), Some(1)); | ^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_ne!` - --> $DIR/debug_assert_with_mut_call.rs:108:31 + --> tests/ui/debug_assert_with_mut_call.rs:108:31 | LL | debug_assert_ne!(Some(3), v.pop()); | ^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:112:19 + --> tests/ui/debug_assert_with_mut_call.rs:112:19 | LL | debug_assert!(bool_mut(a)); | ^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:116:31 + --> tests/ui/debug_assert_with_mut_call.rs:116:31 | LL | debug_assert!(!(bool_ref(&u32_mut(&mut 3)))); | ^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert_eq!` - --> $DIR/debug_assert_with_mut_call.rs:120:22 + --> tests/ui/debug_assert_with_mut_call.rs:120:22 | LL | debug_assert_eq!(v.pop().unwrap(), 3); | ^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:125:19 + --> tests/ui/debug_assert_with_mut_call.rs:125:19 | LL | debug_assert!(bool_mut(&mut 3), "w/o format"); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:128:19 + --> tests/ui/debug_assert_with_mut_call.rs:128:19 | LL | debug_assert!(bool_mut(&mut 3), "{} format", "w/"); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:134:9 + --> tests/ui/debug_assert_with_mut_call.rs:134:9 | LL | bool_mut(&mut x); | ^^^^^^^^^^^^^^^^ error: do not call a function with mutable arguments inside of `debug_assert!` - --> $DIR/debug_assert_with_mut_call.rs:142:9 + --> tests/ui/debug_assert_with_mut_call.rs:142:9 | LL | bool_mut(&mut x); | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/decimal_literal_representation.stderr b/src/tools/clippy/tests/ui/decimal_literal_representation.stderr index f1d4d744e7312..824e7ec85ee00 100644 --- a/src/tools/clippy/tests/ui/decimal_literal_representation.stderr +++ b/src/tools/clippy/tests/ui/decimal_literal_representation.stderr @@ -1,5 +1,5 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:16:9 + --> tests/ui/decimal_literal_representation.rs:16:9 | LL | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` @@ -8,37 +8,37 @@ LL | 32_773, // 0x8005 = 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 + --> tests/ui/decimal_literal_representation.rs:17:9 | LL | 65_280, // 0xFF00 | ^^^^^^ help: consider: `0xFF00` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:18:9 + --> tests/ui/decimal_literal_representation.rs:18:9 | LL | 2_131_750_927, // 0x7F0F_F00F | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:19:9 + --> tests/ui/decimal_literal_representation.rs:19:9 | LL | 2_147_483_647, // 0x7FFF_FFFF | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:21:9 + --> tests/ui/decimal_literal_representation.rs:21:9 | LL | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:22:9 + --> tests/ui/decimal_literal_representation.rs:22:9 | LL | 32_773usize, // 0x8005_usize | ^^^^^^^^^^^ help: consider: `0x8005_usize` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:23:9 + --> tests/ui/decimal_literal_representation.rs:23:9 | LL | 2_131_750_927isize, // 0x7F0F_F00F_isize | ^^^^^^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F_isize` 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 6d34373886d5a..6c0dce6b5eafb 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 @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:12:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:12:1 | LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(tru = 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 + --> tests/ui/declare_interior_mutable_const/enums.rs:23:1 | LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/enums.rs:45:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:45:1 | LL | const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost { | ^---- @@ -33,56 +33,56 @@ LL | | }; | |__^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:60:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:60:5 | LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:61:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:61:5 | LL | const TO_BE_FROZEN_VARIANT: OptionalCell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:64:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:64:5 | LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:90:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:90:5 | LL | const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:102:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:102:5 | LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:105:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:105:5 | LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:111:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:111:5 | LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:118:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:118:5 | LL | / const UNFROZEN_VARIANT: BothOfCellAndGeneric = LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | |____________________________________________________________________^ error: a `const` item should never be interior mutable - --> $DIR/enums.rs:120:5 + --> tests/ui/declare_interior_mutable_const/enums.rs:120:5 | LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.rs b/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.rs index 1cec2980652c1..56a8d22cb1c81 100644 --- a/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.rs +++ b/src/tools/clippy/tests/ui/declare_interior_mutable_const/others.rs @@ -14,9 +14,10 @@ const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::n macro_rules! declare_const { ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; + //~^ ERROR: interior mutable }; } -declare_const!(_ONCE: Once = Once::new()); //~ ERROR: interior mutable +declare_const!(_ONCE: Once = Once::new()); // const ATOMIC_REF: &AtomicUsize = &AtomicUsize::new(7); // This will simply trigger E0492. @@ -49,7 +50,7 @@ mod issue_8493 { }; } - issue_8493!(); //~ ERROR: interior mutable + issue_8493!(); } fn main() {} 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 cc286b9f7f685..9dba0c952214b 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 @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/others.rs:9:1 + --> tests/ui/declare_interior_mutable_const/others.rs:9:1 | LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); = 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 + --> tests/ui/declare_interior_mutable_const/others.rs:10:1 | LL | const CELL: Cell = Cell::new(6); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | const CELL: Cell = Cell::new(6); | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/others.rs:11:1 + --> tests/ui/declare_interior_mutable_const/others.rs:11:1 | LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], V | make this a static item (maybe with lazy_static) error: a `const` item should never be interior mutable - --> $DIR/others.rs:16:9 + --> tests/ui/declare_interior_mutable_const/others.rs:16:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | declare_const!(_ONCE: Once = Once::new()); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should never be interior mutable - --> $DIR/others.rs:43:13 + --> tests/ui/declare_interior_mutable_const/others.rs:44:13 | LL | const _BAZ: Cell = Cell::new(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.rs b/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.rs index a6ccdd2707989..adc53891ef54e 100644 --- a/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.rs +++ b/src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.rs @@ -7,6 +7,7 @@ use std::sync::atomic::AtomicUsize; macro_rules! declare_const { ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; + //~^ ERROR: interior mutable }; } @@ -15,7 +16,7 @@ trait ConcreteTypes { const ATOMIC: AtomicUsize; //~ ERROR: interior mutable const INTEGER: u64; const STRING: String; - declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR: interior mutable + declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); } impl ConcreteTypes for u64 { 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 7647cd96fec77..328453efa244a 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 @@ -1,5 +1,5 @@ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:15:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:16:5 | LL | const ATOMIC: AtomicUsize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | const ATOMIC: AtomicUsize; = 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 + --> tests/ui/declare_interior_mutable_const/traits.rs:9:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -19,55 +19,55 @@ LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should never be interior mutable - --> $DIR/traits.rs:43:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:44:5 | LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:68:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:69:5 | LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:69:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:70:5 | LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:88:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:89:5 | LL | const BOUNDED: T::ToBeBounded; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:116:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:117:5 | LL | const SELF: Self = AtomicUsize::new(17); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:117:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:118:5 | LL | const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:125:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:126:5 | LL | const INDIRECT: Cell<*const T>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:141:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:142:5 | LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should never be interior mutable - --> $DIR/traits.rs:147:5 + --> tests/ui/declare_interior_mutable_const/traits.rs:148:5 | LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/def_id_nocore.stderr b/src/tools/clippy/tests/ui/def_id_nocore.stderr index 6a00331ec69f0..2718217313ff9 100644 --- a/src/tools/clippy/tests/ui/def_id_nocore.stderr +++ b/src/tools/clippy/tests/ui/def_id_nocore.stderr @@ -1,5 +1,5 @@ error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> $DIR/def_id_nocore.rs:27:19 + --> tests/ui/def_id_nocore.rs:27:19 | LL | pub fn as_ref(self) -> &'static str { | ^^^^ 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 434c72aa9b174..c0fa73515c034 100644 --- a/src/tools/clippy/tests/ui/default_constructed_unit_structs.stderr +++ b/src/tools/clippy/tests/ui/default_constructed_unit_structs.stderr @@ -1,5 +1,5 @@ error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:11:13 + --> tests/ui/default_constructed_unit_structs.rs:11:13 | LL | Self::default() | ^^^^^^^^^^^ help: remove this call to `default` @@ -8,31 +8,31 @@ LL | Self::default() = 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 + --> tests/ui/default_constructed_unit_structs.rs:53:31 | LL | inner: PhantomData::default(), | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:126:33 + --> tests/ui/default_constructed_unit_structs.rs:126:33 | LL | let _ = PhantomData::::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:127:42 + --> tests/ui/default_constructed_unit_structs.rs:127:42 | LL | let _: PhantomData = PhantomData::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:128:55 + --> tests/ui/default_constructed_unit_structs.rs:128:55 | LL | let _: PhantomData = std::marker::PhantomData::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct - --> $DIR/default_constructed_unit_structs.rs:129:23 + --> tests/ui/default_constructed_unit_structs.rs:129:23 | LL | let _ = UnitStruct::default(); | ^^^^^^^^^^^ help: remove this call to `default` 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 48d6c02d150d8..4bd4d060a3f75 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 @@ -1,5 +1,5 @@ error: `std::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty.rs:12:13 + --> tests/ui/default_instead_of_iter_empty.rs:12:13 | LL | let _ = std::iter::Empty::::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty::()` @@ -8,13 +8,13 @@ LL | let _ = std::iter::Empty::::default(); = 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 + --> tests/ui/default_instead_of_iter_empty.rs:13:13 | LL | let _ = std::iter::Empty::>::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty::>()` error: `std::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty.rs:14:41 + --> tests/ui/default_instead_of_iter_empty.rs:14:41 | LL | let _foo: std::iter::Empty = std::iter::Empty::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` diff --git a/src/tools/clippy/tests/ui/default_instead_of_iter_empty_no_std.stderr b/src/tools/clippy/tests/ui/default_instead_of_iter_empty_no_std.stderr index 747a31ecbf366..eb80da13e8506 100644 --- a/src/tools/clippy/tests/ui/default_instead_of_iter_empty_no_std.stderr +++ b/src/tools/clippy/tests/ui/default_instead_of_iter_empty_no_std.stderr @@ -1,5 +1,5 @@ error: `core::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty_no_std.rs:23:13 + --> tests/ui/default_instead_of_iter_empty_no_std.rs:23:13 | LL | let _ = core::iter::Empty::::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::iter::empty::()` @@ -8,7 +8,7 @@ LL | let _ = core::iter::Empty::::default(); = help: to override `-D warnings` add `#[allow(clippy::default_instead_of_iter_empty)]` error: `core::iter::empty()` is the more idiomatic way - --> $DIR/default_instead_of_iter_empty_no_std.rs:24:42 + --> tests/ui/default_instead_of_iter_empty_no_std.rs:24:42 | LL | let _foo: core::iter::Empty = core::iter::Empty::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::iter::empty()` 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 c95679c9eb81b..d7e4dbd637715 100644 --- a/src/tools/clippy/tests/ui/default_numeric_fallback_f64.stderr +++ b/src/tools/clippy/tests/ui/default_numeric_fallback_f64.stderr @@ -1,5 +1,5 @@ error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:21:17 + --> tests/ui/default_numeric_fallback_f64.rs:21:17 | LL | let x = 0.12; | ^^^^ help: consider adding suffix: `0.12_f64` @@ -8,133 +8,133 @@ LL | let x = 0.12; = 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 + --> tests/ui/default_numeric_fallback_f64.rs:22:18 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:22:22 + --> tests/ui/default_numeric_fallback_f64.rs:22:22 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `2.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:22:26 + --> tests/ui/default_numeric_fallback_f64.rs:22:26 | LL | let x = [1., 2., 3.]; | ^^ help: consider adding suffix: `3.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:28 + --> tests/ui/default_numeric_fallback_f64.rs:23:28 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:32 + --> tests/ui/default_numeric_fallback_f64.rs:23:32 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `2.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:46 + --> tests/ui/default_numeric_fallback_f64.rs:23:46 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `3.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:23:50 + --> tests/ui/default_numeric_fallback_f64.rs:23:50 | LL | let x = if true { (1., 2.) } else { (3., 4.) }; | ^^ help: consider adding suffix: `4.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:24:23 + --> tests/ui/default_numeric_fallback_f64.rs:24:23 | LL | let x = match 1. { | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:25:18 + --> tests/ui/default_numeric_fallback_f64.rs:25:18 | LL | _ => 1., | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:44:21 + --> tests/ui/default_numeric_fallback_f64.rs:44:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:52:21 + --> tests/ui/default_numeric_fallback_f64.rs:52:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:58:21 + --> tests/ui/default_numeric_fallback_f64.rs:58:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:66:21 + --> tests/ui/default_numeric_fallback_f64.rs:66:21 | LL | let y = 1.; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:82:27 + --> tests/ui/default_numeric_fallback_f64.rs:82:27 | LL | let f = || -> _ { 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:86:29 + --> tests/ui/default_numeric_fallback_f64.rs:86:29 | LL | let f = || -> f64 { 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:100:21 + --> tests/ui/default_numeric_fallback_f64.rs:100:21 | LL | generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:103:32 + --> tests/ui/default_numeric_fallback_f64.rs:103:32 | LL | let x: _ = generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:121:28 + --> tests/ui/default_numeric_fallback_f64.rs:121:28 | LL | GenericStruct { x: 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:124:36 + --> tests/ui/default_numeric_fallback_f64.rs:124:36 | LL | let _ = GenericStruct { x: 1. }; | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:142:24 + --> tests/ui/default_numeric_fallback_f64.rs:142:24 | LL | GenericEnum::X(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:162:23 + --> tests/ui/default_numeric_fallback_f64.rs:162:23 | LL | s.generic_arg(1.); | ^^ help: consider adding suffix: `1.0_f64` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_f64.rs:172:25 + --> tests/ui/default_numeric_fallback_f64.rs:172:25 | LL | inline!(let x = 22.;); | ^^^ help: consider adding suffix: `22.0_f64` 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 7663977fb65a4..9961a3669ef2b 100644 --- a/src/tools/clippy/tests/ui/default_numeric_fallback_i32.stderr +++ b/src/tools/clippy/tests/ui/default_numeric_fallback_i32.stderr @@ -1,5 +1,5 @@ error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:21:17 + --> tests/ui/default_numeric_fallback_i32.rs:21:17 | LL | let x = 22; | ^^ help: consider adding suffix: `22_i32` @@ -8,145 +8,145 @@ LL | let x = 22; = 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 + --> tests/ui/default_numeric_fallback_i32.rs:22:18 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:22:21 + --> tests/ui/default_numeric_fallback_i32.rs:22:21 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:22:24 + --> tests/ui/default_numeric_fallback_i32.rs:22:24 | LL | let x = [1, 2, 3]; | ^ help: consider adding suffix: `3_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:28 + --> tests/ui/default_numeric_fallback_i32.rs:23:28 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:31 + --> tests/ui/default_numeric_fallback_i32.rs:23:31 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:44 + --> tests/ui/default_numeric_fallback_i32.rs:23:44 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `3_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:23:47 + --> tests/ui/default_numeric_fallback_i32.rs:23:47 | LL | let x = if true { (1, 2) } else { (3, 4) }; | ^ help: consider adding suffix: `4_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:24:23 + --> tests/ui/default_numeric_fallback_i32.rs:24:23 | LL | let x = match 1 { | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:25:13 + --> tests/ui/default_numeric_fallback_i32.rs:25:13 | LL | 1 => 1, | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:25:18 + --> tests/ui/default_numeric_fallback_i32.rs:25:18 | LL | 1 => 1, | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:26:18 + --> tests/ui/default_numeric_fallback_i32.rs:26:18 | LL | _ => 2, | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:45:21 + --> tests/ui/default_numeric_fallback_i32.rs:45:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:53:21 + --> tests/ui/default_numeric_fallback_i32.rs:53:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:59:21 + --> tests/ui/default_numeric_fallback_i32.rs:59:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:67:21 + --> tests/ui/default_numeric_fallback_i32.rs:67:21 | LL | let y = 1; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:83:27 + --> tests/ui/default_numeric_fallback_i32.rs:83:27 | LL | let f = || -> _ { 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:87:29 + --> tests/ui/default_numeric_fallback_i32.rs:87:29 | LL | let f = || -> i32 { 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:101:21 + --> tests/ui/default_numeric_fallback_i32.rs:101:21 | LL | generic_arg(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:104:32 + --> tests/ui/default_numeric_fallback_i32.rs:104:32 | LL | let x: _ = generic_arg(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:122:28 + --> tests/ui/default_numeric_fallback_i32.rs:122:28 | LL | GenericStruct { x: 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:125:36 + --> tests/ui/default_numeric_fallback_i32.rs:125:36 | LL | let _ = GenericStruct { x: 1 }; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:143:24 + --> tests/ui/default_numeric_fallback_i32.rs:143:24 | LL | GenericEnum::X(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:163:23 + --> tests/ui/default_numeric_fallback_i32.rs:163:23 | LL | s.generic_arg(1); | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:173:25 + --> tests/ui/default_numeric_fallback_i32.rs:173:25 | LL | inline!(let x = 22;); | ^^ help: consider adding suffix: `22_i32` @@ -154,19 +154,19 @@ LL | inline!(let x = 22;); = note: this error originates in the macro `__inline_mac_fn_internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:215:29 + --> tests/ui/default_numeric_fallback_i32.rs:215:29 | LL | let data_i32 = vec![1, 2, 3]; | ^ help: consider adding suffix: `1_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:215:32 + --> tests/ui/default_numeric_fallback_i32.rs:215:32 | LL | let data_i32 = vec![1, 2, 3]; | ^ help: consider adding suffix: `2_i32` error: default numeric fallback might occur - --> $DIR/default_numeric_fallback_i32.rs:215:35 + --> tests/ui/default_numeric_fallback_i32.rs:215:35 | LL | let data_i32 = vec![1, 2, 3]; | ^ help: consider adding suffix: `3_i32` diff --git a/src/tools/clippy/tests/ui/default_trait_access.stderr b/src/tools/clippy/tests/ui/default_trait_access.stderr index e53c8e2c79ff1..276f03d79df1d 100644 --- a/src/tools/clippy/tests/ui/default_trait_access.stderr +++ b/src/tools/clippy/tests/ui/default_trait_access.stderr @@ -1,53 +1,53 @@ error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:13:22 + --> tests/ui/default_trait_access.rs:13:22 | LL | let s1: String = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `String::default()` | note: the lint level is defined here - --> $DIR/default_trait_access.rs:2:9 + --> tests/ui/default_trait_access.rs:2:9 | LL | #![deny(clippy::default_trait_access)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:17:22 + --> tests/ui/default_trait_access.rs:17:22 | LL | let s3: String = D2::default(); | ^^^^^^^^^^^^^ help: try: `String::default()` error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:19:22 + --> tests/ui/default_trait_access.rs:19:22 | LL | let s4: String = std::default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()` error: calling `String::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:23:22 + --> tests/ui/default_trait_access.rs:23:22 | LL | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `String::default()` error: calling `GenericDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:33:46 + --> tests/ui/default_trait_access.rs:33:46 | LL | let s11: GenericDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()` error: calling `TupleDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:39:36 + --> tests/ui/default_trait_access.rs:39:36 | LL | let s14: TupleDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()` error: calling `ArrayDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:41:36 + --> tests/ui/default_trait_access.rs:41:36 | LL | let s15: ArrayDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()` error: calling `TupleStructDerivedDefault::default()` is more clear than this expression - --> $DIR/default_trait_access.rs:45:42 + --> tests/ui/default_trait_access.rs:45:42 | LL | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` diff --git a/src/tools/clippy/tests/ui/default_union_representation.stderr b/src/tools/clippy/tests/ui/default_union_representation.stderr index 82f69ffeec373..c7ef70a0b8e7b 100644 --- a/src/tools/clippy/tests/ui/default_union_representation.stderr +++ b/src/tools/clippy/tests/ui/default_union_representation.stderr @@ -1,5 +1,5 @@ error: this union has the default representation - --> $DIR/default_union_representation.rs:4:1 + --> tests/ui/default_union_representation.rs:4:1 | LL | / union NoAttribute { LL | | @@ -13,7 +13,7 @@ LL | | } = 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 + --> tests/ui/default_union_representation.rs:17:1 | LL | / union ReprPacked { LL | | @@ -25,7 +25,7 @@ LL | | } = help: consider annotating `ReprPacked` with `#[repr(C)]` to explicitly specify memory layout error: this union has the default representation - --> $DIR/default_union_representation.rs:36:1 + --> tests/ui/default_union_representation.rs:36:1 | LL | / union ReprAlign { LL | | @@ -37,7 +37,7 @@ LL | | } = help: consider annotating `ReprAlign` with `#[repr(C)]` to explicitly specify memory layout error: this union has the default representation - --> $DIR/default_union_representation.rs:57:1 + --> tests/ui/default_union_representation.rs:57:1 | LL | / union ZSTAndTwoFields { LL | | diff --git a/src/tools/clippy/tests/ui/deprecated.stderr b/src/tools/clippy/tests/ui/deprecated.stderr index 388fcc2384668..a9cf04bea5257 100644 --- a/src/tools/clippy/tests/ui/deprecated.stderr +++ b/src/tools/clippy/tests/ui/deprecated.stderr @@ -1,5 +1,5 @@ error: lint `clippy::should_assert_eq` has been removed: `assert!()` will be more flexible with RFC 2011 - --> $DIR/deprecated.rs:5:9 + --> tests/ui/deprecated.rs:5:9 | LL | #![warn(clippy::should_assert_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,91 +8,91 @@ LL | #![warn(clippy::should_assert_eq)] = 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 + --> tests/ui/deprecated.rs:6:9 | LL | #![warn(clippy::extend_from_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::range_step_by_zero` has been removed: `iterator.step_by(0)` panics nowadays - --> $DIR/deprecated.rs:7:9 + --> tests/ui/deprecated.rs:7:9 | LL | #![warn(clippy::range_step_by_zero)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 - --> $DIR/deprecated.rs:8:9 + --> tests/ui/deprecated.rs:8:9 | LL | #![warn(clippy::unstable_as_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unstable_as_mut_slice` has been removed: `Vec::as_mut_slice` has been stabilized in 1.7 - --> $DIR/deprecated.rs:9:9 + --> tests/ui/deprecated.rs:9:9 | LL | #![warn(clippy::unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr - --> $DIR/deprecated.rs:10:9 + --> tests/ui/deprecated.rs:10:9 | LL | #![warn(clippy::misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::assign_ops` has been removed: using compound assignment operators (e.g., `+=`) is harmless - --> $DIR/deprecated.rs:11:9 + --> tests/ui/deprecated.rs:11:9 | LL | #![warn(clippy::assign_ops)] | ^^^^^^^^^^^^^^^^^^ error: lint `clippy::if_let_redundant_pattern_matching` has been removed: this lint has been changed to redundant_pattern_matching - --> $DIR/deprecated.rs:12:9 + --> tests/ui/deprecated.rs:12:9 | LL | #![warn(clippy::if_let_redundant_pattern_matching)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unsafe_vector_initialization` has been removed: the replacement suggested by this lint had substantially different behavior - --> $DIR/deprecated.rs:13:9 + --> tests/ui/deprecated.rs:13:9 | LL | #![warn(clippy::unsafe_vector_initialization)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::unused_collect` has been removed: `collect` has been marked as #[must_use] in rustc and that covers all cases of this lint - --> $DIR/deprecated.rs:14:9 + --> tests/ui/deprecated.rs:14:9 | LL | #![warn(clippy::unused_collect)] | ^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::replace_consts` has been removed: associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants - --> $DIR/deprecated.rs:15:9 + --> tests/ui/deprecated.rs:15:9 | LL | #![warn(clippy::replace_consts)] | ^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::regex_macro` has been removed: the regex! macro has been removed from the regex crate in 2018 - --> $DIR/deprecated.rs:16:9 + --> tests/ui/deprecated.rs:16:9 | LL | #![warn(clippy::regex_macro)] | ^^^^^^^^^^^^^^^^^^^ error: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint - --> $DIR/deprecated.rs:17:9 + --> tests/ui/deprecated.rs:17:9 | LL | #![warn(clippy::find_map)] | ^^^^^^^^^^^^^^^^ error: lint `clippy::filter_map` has been removed: this lint has been replaced by `manual_filter_map`, a more specific lint - --> $DIR/deprecated.rs:18:9 + --> tests/ui/deprecated.rs:18:9 | LL | #![warn(clippy::filter_map)] | ^^^^^^^^^^^^^^^^^^ error: lint `clippy::pub_enum_variant_names` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items - --> $DIR/deprecated.rs:19:9 + --> tests/ui/deprecated.rs:19:9 | LL | #![warn(clippy::pub_enum_variant_names)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items - --> $DIR/deprecated.rs:20:9 + --> tests/ui/deprecated.rs:20:9 | LL | #![warn(clippy::wrong_pub_self_convention)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/deprecated_old.stderr b/src/tools/clippy/tests/ui/deprecated_old.stderr index d27ad852f97ff..685bca64df59a 100644 --- a/src/tools/clippy/tests/ui/deprecated_old.stderr +++ b/src/tools/clippy/tests/ui/deprecated_old.stderr @@ -1,5 +1,5 @@ error: lint `unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7 - --> $DIR/deprecated_old.rs:1:8 + --> tests/ui/deprecated_old.rs:1:8 | LL | #[warn(unstable_as_slice)] | ^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | #[warn(unstable_as_slice)] = 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 + --> tests/ui/deprecated_old.rs:4:8 | LL | #[warn(unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^ error: lint `misaligned_transmute` has been removed: this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr - --> $DIR/deprecated_old.rs:6:8 + --> tests/ui/deprecated_old.rs:6:8 | LL | #[warn(misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/deref_addrof.stderr b/src/tools/clippy/tests/ui/deref_addrof.stderr index b01fa4df6b1f5..5e3cb417aa0e1 100644 --- a/src/tools/clippy/tests/ui/deref_addrof.stderr +++ b/src/tools/clippy/tests/ui/deref_addrof.stderr @@ -1,5 +1,5 @@ error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:23:13 + --> tests/ui/deref_addrof.rs:23:13 | LL | let b = *&a; | ^^^ help: try: `a` @@ -8,49 +8,49 @@ LL | let b = *&a; = help: to override `-D warnings` add `#[allow(clippy::deref_addrof)]` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:25:13 + --> tests/ui/deref_addrof.rs:25:13 | LL | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try: `get_number()` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:30:13 + --> tests/ui/deref_addrof.rs:30:13 | LL | let b = *&bytes[1..2][0]; | ^^^^^^^^^^^^^^^^ help: try: `bytes[1..2][0]` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:34:13 + --> tests/ui/deref_addrof.rs:34:13 | LL | let b = *&(a); | ^^^^^ help: try: `(a)` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:36:13 + --> tests/ui/deref_addrof.rs:36:13 | LL | let b = *(&a); | ^^^^^ help: try: `a` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:39:13 + --> tests/ui/deref_addrof.rs:39:13 | LL | let b = *((&a)); | ^^^^^^^ help: try: `a` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:41:13 + --> tests/ui/deref_addrof.rs:41:13 | LL | let b = *&&a; | ^^^^ help: try: `&a` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:43:14 + --> tests/ui/deref_addrof.rs:43:14 | LL | let b = **&aref; | ^^^^^^ help: try: `aref` error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:53:17 + --> tests/ui/deref_addrof.rs:53:17 | LL | inline!(*& $(@expr self)) | ^^^^^^^^^^^^^^^^ help: try: `$(@expr self)` @@ -58,7 +58,7 @@ LL | inline!(*& $(@expr self)) = note: this error originates in the macro `__inline_mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error: immediately dereferencing a reference - --> $DIR/deref_addrof.rs:57:17 + --> tests/ui/deref_addrof.rs:57:17 | LL | inline!(*&mut $(@expr self)) | ^^^^^^^^^^^^^^^^^^^ help: try: `$(@expr self)` 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 78ec73400162e..8905b14246740 100644 --- a/src/tools/clippy/tests/ui/deref_addrof_double_trigger.stderr +++ b/src/tools/clippy/tests/ui/deref_addrof_double_trigger.stderr @@ -1,5 +1,5 @@ error: immediately dereferencing a reference - --> $DIR/deref_addrof_double_trigger.rs:10:14 + --> tests/ui/deref_addrof_double_trigger.rs:10:14 | LL | let b = **&&a; | ^^^^ help: try: `&a` @@ -8,13 +8,13 @@ LL | let b = **&&a; = help: to override `-D warnings` add `#[allow(clippy::deref_addrof)]` error: immediately dereferencing a reference - --> $DIR/deref_addrof_double_trigger.rs:16:17 + --> tests/ui/deref_addrof_double_trigger.rs:16:17 | LL | let y = *&mut x; | ^^^^^^^ help: try: `x` error: immediately dereferencing a reference - --> $DIR/deref_addrof_double_trigger.rs:24:18 + --> tests/ui/deref_addrof_double_trigger.rs:24:18 | LL | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try: `&mut x` diff --git a/src/tools/clippy/tests/ui/deref_by_slicing.stderr b/src/tools/clippy/tests/ui/deref_by_slicing.stderr index 7b8144a9a6e19..17b00610899d6 100644 --- a/src/tools/clippy/tests/ui/deref_by_slicing.stderr +++ b/src/tools/clippy/tests/ui/deref_by_slicing.stderr @@ -1,5 +1,5 @@ error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:8:13 + --> tests/ui/deref_by_slicing.rs:8:13 | LL | let _ = &vec[..]; | ^^^^^^^^ help: dereference the original value instead: `&*vec` @@ -8,49 +8,49 @@ LL | let _ = &vec[..]; = help: to override `-D warnings` add `#[allow(clippy::deref_by_slicing)]` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:9:13 + --> tests/ui/deref_by_slicing.rs:9:13 | LL | let _ = &mut vec[..]; | ^^^^^^^^^^^^ help: dereference the original value instead: `&mut *vec` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:12:13 + --> tests/ui/deref_by_slicing.rs:12:13 | LL | let _ = &ref_vec[..]; | ^^^^^^^^^^^^ help: dereference the original value instead: `&**ref_vec` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:13:21 + --> tests/ui/deref_by_slicing.rs:13:21 | LL | let mut_slice = &mut ref_vec[..]; | ^^^^^^^^^^^^^^^^ help: dereference the original value instead: `&mut **ref_vec` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:14:13 + --> tests/ui/deref_by_slicing.rs:14:13 | LL | let _ = &mut mut_slice[..]; // Err, re-borrows slice | ^^^^^^^^^^^^^^^^^^ help: reborrow the original value instead: `&mut *mut_slice` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:17:13 + --> tests/ui/deref_by_slicing.rs:17:13 | LL | let _ = &s[..]; | ^^^^^^ help: dereference the original value instead: `&*s` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:20:18 + --> tests/ui/deref_by_slicing.rs:20:18 | LL | let _ = &mut &S[..]; // Err, re-borrows slice | ^^^^^^ help: reborrow the original value instead: `&*S` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:24:13 + --> tests/ui/deref_by_slicing.rs:24:13 | LL | let _ = &slice_ref[..]; // Err, derefs slice | ^^^^^^^^^^^^^^ help: dereference the original value instead: `*slice_ref` error: slicing when dereferencing would work - --> $DIR/deref_by_slicing.rs:27:13 + --> tests/ui/deref_by_slicing.rs:27:13 | LL | let _ = (&bytes[..]).read_to_end(&mut vec![]).unwrap(); // Err, re-borrows slice | ^^^^^^^^^^^^ help: reborrow the original value instead: `(&*bytes)` diff --git a/src/tools/clippy/tests/ui/derivable_impls.stderr b/src/tools/clippy/tests/ui/derivable_impls.stderr index 98e2f3612904a..0adb422373d86 100644 --- a/src/tools/clippy/tests/ui/derivable_impls.stderr +++ b/src/tools/clippy/tests/ui/derivable_impls.stderr @@ -1,5 +1,5 @@ error: this `impl` can be derived - --> $DIR/derivable_impls.rs:20:1 + --> tests/ui/derivable_impls.rs:20:1 | LL | / impl std::default::Default for FooDefault<'_> { LL | | fn default() -> Self { @@ -20,7 +20,7 @@ LL | struct FooDefault<'a> { | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:41:1 + --> tests/ui/derivable_impls.rs:41:1 | LL | / impl std::default::Default for TupleDefault { LL | | fn default() -> Self { @@ -37,7 +37,7 @@ LL | struct TupleDefault(bool, i32, u64); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:93:1 + --> tests/ui/derivable_impls.rs:93:1 | LL | / impl Default for StrDefault<'_> { LL | | fn default() -> Self { @@ -54,7 +54,7 @@ LL | struct StrDefault<'a>(&'a str); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:119:1 + --> tests/ui/derivable_impls.rs:119:1 | LL | / impl Default for Y { LL | | fn default() -> Self { @@ -71,7 +71,7 @@ LL | struct Y(u32); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:158:1 + --> tests/ui/derivable_impls.rs:158:1 | LL | / impl Default for WithoutSelfCurly { LL | | fn default() -> Self { @@ -88,7 +88,7 @@ LL | struct WithoutSelfCurly { | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:166:1 + --> tests/ui/derivable_impls.rs:166:1 | LL | / impl Default for WithoutSelfParan { LL | | fn default() -> Self { @@ -105,7 +105,7 @@ LL | struct WithoutSelfParan(bool); | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:216:1 + --> tests/ui/derivable_impls.rs:216:1 | LL | / impl Default for RepeatDefault1 { LL | | fn default() -> Self { @@ -122,7 +122,7 @@ LL | pub struct RepeatDefault1 { | error: this `impl` can be derived - --> $DIR/derivable_impls.rs:250:1 + --> tests/ui/derivable_impls.rs:250:1 | LL | / impl Default for SimpleEnum { LL | | fn default() -> Self { diff --git a/src/tools/clippy/tests/ui/derive.stderr b/src/tools/clippy/tests/ui/derive.stderr index 88942d9543226..d5f9d7cf2a2c8 100644 --- a/src/tools/clippy/tests/ui/derive.stderr +++ b/src/tools/clippy/tests/ui/derive.stderr @@ -1,5 +1,5 @@ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:8:1 + --> tests/ui/derive.rs:8:1 | LL | / impl Clone for Qux { LL | | @@ -10,7 +10,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:8:1 + --> tests/ui/derive.rs:8:1 | LL | / impl Clone for Qux { LL | | @@ -23,7 +23,7 @@ LL | | } = 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:33:1 + --> tests/ui/derive.rs:33:1 | LL | / impl<'a> Clone for Lt<'a> { LL | | @@ -34,7 +34,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:33:1 + --> tests/ui/derive.rs:33:1 | LL | / impl<'a> Clone for Lt<'a> { LL | | @@ -45,7 +45,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:45:1 + --> tests/ui/derive.rs:45:1 | LL | / impl Clone for BigArray { LL | | @@ -56,7 +56,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:45:1 + --> tests/ui/derive.rs:45:1 | LL | / impl Clone for BigArray { LL | | @@ -67,7 +67,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:57:1 + --> tests/ui/derive.rs:57:1 | LL | / impl Clone for FnPtr { LL | | @@ -78,7 +78,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:57:1 + --> tests/ui/derive.rs:57:1 | LL | / impl Clone for FnPtr { LL | | @@ -89,7 +89,7 @@ LL | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:78:1 + --> tests/ui/derive.rs:78:1 | LL | / impl Clone for Generic2 { LL | | @@ -100,7 +100,7 @@ LL | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:78:1 + --> tests/ui/derive.rs:78:1 | LL | / impl Clone for Generic2 { LL | | 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 7555c12b196d9..dcf32419baa29 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 @@ -1,11 +1,11 @@ error: you are deriving `Ord` but have implemented `PartialOrd` explicitly - --> $DIR/derive_ord_xor_partial_ord.rs:22:10 + --> tests/ui/derive_ord_xor_partial_ord.rs:22:10 | LL | #[derive(Ord, PartialEq, Eq)] | ^^^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:26:1 + --> tests/ui/derive_ord_xor_partial_ord.rs:26:1 | LL | impl PartialOrd for DeriveOrd { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,20 +14,20 @@ LL | impl PartialOrd for DeriveOrd { = 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 - --> $DIR/derive_ord_xor_partial_ord.rs:32:10 + --> tests/ui/derive_ord_xor_partial_ord.rs:32:10 | LL | #[derive(Ord, PartialEq, Eq)] | ^^^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:36:1 + --> tests/ui/derive_ord_xor_partial_ord.rs:36:1 | LL | impl PartialOrd for DeriveOrdWithExplicitTypeVariable { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are implementing `Ord` explicitly but have derived `PartialOrd` - --> $DIR/derive_ord_xor_partial_ord.rs:45:1 + --> tests/ui/derive_ord_xor_partial_ord.rs:45:1 | LL | / impl std::cmp::Ord for DerivePartialOrd { LL | | @@ -38,14 +38,14 @@ LL | | } | |_^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:42:10 + --> tests/ui/derive_ord_xor_partial_ord.rs:42:10 | LL | #[derive(PartialOrd, PartialEq, Eq)] | ^^^^^^^^^^ = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are implementing `Ord` explicitly but have derived `PartialOrd` - --> $DIR/derive_ord_xor_partial_ord.rs:66:5 + --> tests/ui/derive_ord_xor_partial_ord.rs:66:5 | LL | / impl Ord for DerivePartialOrdInUseOrd { LL | | @@ -56,7 +56,7 @@ LL | | } | |_____^ | note: `PartialOrd` implemented here - --> $DIR/derive_ord_xor_partial_ord.rs:63:14 + --> tests/ui/derive_ord_xor_partial_ord.rs:63:14 | LL | #[derive(PartialOrd, PartialEq, Eq)] | ^^^^^^^^^^ 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 abfd70e8c3d50..42b9895121ff5 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 @@ -1,5 +1,5 @@ error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:11:17 + --> tests/ui/derive_partial_eq_without_eq.rs:11:17 | LL | #[derive(Debug, PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` @@ -8,61 +8,61 @@ LL | #[derive(Debug, PartialEq)] = 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 + --> tests/ui/derive_partial_eq_without_eq.rs:53:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:59:10 + --> tests/ui/derive_partial_eq_without_eq.rs:59:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:65:10 + --> tests/ui/derive_partial_eq_without_eq.rs:65:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:68:10 + --> tests/ui/derive_partial_eq_without_eq.rs:68:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:74:10 + --> tests/ui/derive_partial_eq_without_eq.rs:74:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:80:10 + --> tests/ui/derive_partial_eq_without_eq.rs:80:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:93:17 + --> tests/ui/derive_partial_eq_without_eq.rs:93:17 | LL | #[derive(Debug, PartialEq, Clone)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:96:10 + --> tests/ui/derive_partial_eq_without_eq.rs:96:10 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:103:14 + --> tests/ui/derive_partial_eq_without_eq.rs:103:14 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` error: you are deriving `PartialEq` and can implement `Eq` - --> $DIR/derive_partial_eq_without_eq.rs:106:14 + --> tests/ui/derive_partial_eq_without_eq.rs:106:14 | LL | #[derive(PartialEq)] | ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq` diff --git a/src/tools/clippy/tests/ui/derived_hash_with_manual_eq.stderr b/src/tools/clippy/tests/ui/derived_hash_with_manual_eq.stderr index 8ef08f9fa5cbb..af4d247f95ba9 100644 --- a/src/tools/clippy/tests/ui/derived_hash_with_manual_eq.stderr +++ b/src/tools/clippy/tests/ui/derived_hash_with_manual_eq.stderr @@ -1,11 +1,11 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derived_hash_with_manual_eq.rs:12:10 + --> tests/ui/derived_hash_with_manual_eq.rs:12:10 | LL | #[derive(Hash)] | ^^^^ | note: `PartialEq` implemented here - --> $DIR/derived_hash_with_manual_eq.rs:16:1 + --> tests/ui/derived_hash_with_manual_eq.rs:16:1 | LL | impl PartialEq for Bar { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -13,13 +13,13 @@ LL | impl PartialEq for Bar { = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derived_hash_with_manual_eq.rs:22:10 + --> tests/ui/derived_hash_with_manual_eq.rs:22:10 | LL | #[derive(Hash)] | ^^^^ | note: `PartialEq` implemented here - --> $DIR/derived_hash_with_manual_eq.rs:26:1 + --> tests/ui/derived_hash_with_manual_eq.rs:26:1 | LL | impl PartialEq for Baz { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/disallowed_names.stderr b/src/tools/clippy/tests/ui/disallowed_names.stderr index 3387906a0e5c2..d131cad8e11e9 100644 --- a/src/tools/clippy/tests/ui/disallowed_names.stderr +++ b/src/tools/clippy/tests/ui/disallowed_names.stderr @@ -1,5 +1,5 @@ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:12:9 + --> tests/ui/disallowed_names.rs:12:9 | LL | fn test(foo: ()) {} | ^^^ @@ -8,79 +8,79 @@ LL | fn test(foo: ()) {} = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:17:9 + --> tests/ui/disallowed_names.rs:17:9 | LL | let foo = 42; | ^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:19:9 + --> tests/ui/disallowed_names.rs:19:9 | LL | let baz = 42; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:21:9 + --> tests/ui/disallowed_names.rs:21:9 | LL | let quux = 42; | ^^^^ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:33:10 + --> tests/ui/disallowed_names.rs:33:10 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:33:20 + --> tests/ui/disallowed_names.rs:33:20 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:33:26 + --> tests/ui/disallowed_names.rs:33:26 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^^ error: use of a disallowed/placeholder name `foo` - --> $DIR/disallowed_names.rs:41:19 + --> tests/ui/disallowed_names.rs:41:19 | LL | fn issue_1647(mut foo: u8) { | ^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:43:13 + --> tests/ui/disallowed_names.rs:43:13 | LL | let mut baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:45:21 + --> tests/ui/disallowed_names.rs:45:21 | LL | if let Some(mut quux) = Some(42) {} | ^^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:50:13 + --> tests/ui/disallowed_names.rs:50:13 | LL | let ref baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:52:21 + --> tests/ui/disallowed_names.rs:52:21 | LL | if let Some(ref quux) = Some(42) {} | ^^^^ error: use of a disallowed/placeholder name `baz` - --> $DIR/disallowed_names.rs:57:17 + --> tests/ui/disallowed_names.rs:57:17 | LL | let ref mut baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> $DIR/disallowed_names.rs:59:25 + --> tests/ui/disallowed_names.rs:59:25 | LL | if let Some(ref mut quux) = Some(42) {} | ^^^^ diff --git a/src/tools/clippy/tests/ui/disallowed_script_idents.stderr b/src/tools/clippy/tests/ui/disallowed_script_idents.stderr index bf5cbe306c681..c11655ab6021e 100644 --- a/src/tools/clippy/tests/ui/disallowed_script_idents.stderr +++ b/src/tools/clippy/tests/ui/disallowed_script_idents.stderr @@ -1,17 +1,17 @@ error: identifier `счётчик` has a Unicode script that is not allowed by configuration: Cyrillic - --> $DIR/disallowed_script_idents.rs:11:9 + --> tests/ui/disallowed_script_idents.rs:11:9 | LL | let счётчик = 10; | ^^^^^^^ | note: the lint level is defined here - --> $DIR/disallowed_script_idents.rs:1:9 + --> tests/ui/disallowed_script_idents.rs:1:9 | LL | #![deny(clippy::disallowed_script_idents)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: identifier `カウンタ` has a Unicode script that is not allowed by configuration: Katakana - --> $DIR/disallowed_script_idents.rs:14:9 + --> tests/ui/disallowed_script_idents.rs:14:9 | LL | let カウンタ = 10; | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/diverging_sub_expression.stderr b/src/tools/clippy/tests/ui/diverging_sub_expression.stderr index d8021c5d7ba83..f90c95696a9cc 100644 --- a/src/tools/clippy/tests/ui/diverging_sub_expression.stderr +++ b/src/tools/clippy/tests/ui/diverging_sub_expression.stderr @@ -1,5 +1,5 @@ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:20:10 + --> tests/ui/diverging_sub_expression.rs:20:10 | LL | b || diverge(); | ^^^^^^^^^ @@ -8,31 +8,31 @@ LL | b || diverge(); = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:23:10 + --> tests/ui/diverging_sub_expression.rs:23:10 | LL | b || A.foo(); | ^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:34:26 + --> tests/ui/diverging_sub_expression.rs:34:26 | LL | 6 => true || return, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:36:26 + --> tests/ui/diverging_sub_expression.rs:36:26 | LL | 7 => true || continue, | ^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:40:26 + --> tests/ui/diverging_sub_expression.rs:40:26 | LL | 3 => true || diverge(), | ^^^^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:44:30 + --> tests/ui/diverging_sub_expression.rs:44:30 | LL | _ => true || panic!("boo"), | ^^^^^^^^^^^^^ @@ -40,31 +40,31 @@ LL | _ => true || panic!("boo"), = 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 - --> $DIR/diverging_sub_expression.rs:48:29 + --> tests/ui/diverging_sub_expression.rs:48:29 | LL | 15 => true || { return; }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:50:30 + --> tests/ui/diverging_sub_expression.rs:50:30 | LL | 16 => false || { return; }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:53:29 + --> tests/ui/diverging_sub_expression.rs:53:29 | LL | 17 => true || { return }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:55:30 + --> tests/ui/diverging_sub_expression.rs:55:30 | LL | 18 => false || { return }, | ^^^^^^ error: sub-expression diverges - --> $DIR/diverging_sub_expression.rs:65:26 + --> tests/ui/diverging_sub_expression.rs:65:26 | LL | _ => true || break, | ^^^^^ diff --git a/src/tools/clippy/tests/ui/doc/doc-fixable.stderr b/src/tools/clippy/tests/ui/doc/doc-fixable.stderr index 033604e030a98..7db9ff2b83b69 100644 --- a/src/tools/clippy/tests/ui/doc/doc-fixable.stderr +++ b/src/tools/clippy/tests/ui/doc/doc-fixable.stderr @@ -1,5 +1,5 @@ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:9:9 + --> tests/ui/doc/doc-fixable.rs:9:9 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^ @@ -12,7 +12,7 @@ LL | /// The `foo_bar` function does _nothing_. See also foo::bar. (note the dot | ~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:9:51 + --> tests/ui/doc/doc-fixable.rs:9:51 | LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) | ^^^^^^^^ @@ -23,7 +23,7 @@ LL | /// The foo_bar function does _nothing_. See also `foo::bar`. (note the dot | ~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:10:83 + --> tests/ui/doc/doc-fixable.rs:10:83 | LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun | ^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. B | ~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:12:13 + --> tests/ui/doc/doc-fixable.rs:12:13 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. | ^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | /// Here be `::a::global:path`, and _::another::global::path_. :: is not a | ~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:12:36 + --> tests/ui/doc/doc-fixable.rs:12:36 | LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | /// Here be ::a::global:path, and _`::another::global::path`_. :: is not a | ~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:13:25 + --> tests/ui/doc/doc-fixable.rs:13:25 | LL | /// Import an item from ::awesome::global::blob:: (Intended postfix) | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | /// Import an item from `::awesome::global::blob::` (Intended postfix) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:14:31 + --> tests/ui/doc/doc-fixable.rs:14:31 | LL | /// These are the options for ::Cat: (Intended trailing single colon, shouldn't be linted) | ^^^^^ @@ -78,7 +78,7 @@ LL | /// These are the options for `::Cat`: (Intended trailing single colon, sho | ~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:15:22 + --> tests/ui/doc/doc-fixable.rs:15:22 | LL | /// That's not code ~NotInCodeBlock~. | ^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | /// That's not code ~`NotInCodeBlock`~. | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:16:5 + --> tests/ui/doc/doc-fixable.rs:16:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:30:5 + --> tests/ui/doc/doc-fixable.rs:30:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:37:5 + --> tests/ui/doc/doc-fixable.rs:37:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:51:5 + --> tests/ui/doc/doc-fixable.rs:51:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:75:5 + --> tests/ui/doc/doc-fixable.rs:75:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:92:5 + --> tests/ui/doc/doc-fixable.rs:92:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:100:8 + --> tests/ui/doc/doc-fixable.rs:100:8 | LL | /// ## CamelCaseThing | ^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | /// ## `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:103:7 + --> tests/ui/doc/doc-fixable.rs:103:7 | LL | /// # CamelCaseThing | ^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | /// # `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:105:22 + --> tests/ui/doc/doc-fixable.rs:105:22 | LL | /// Not a title #897 CamelCaseThing | ^^^^^^^^^^^^^^ @@ -188,7 +188,7 @@ LL | /// Not a title #897 `CamelCaseThing` | ~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:106:5 + --> tests/ui/doc/doc-fixable.rs:106:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +199,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:113:5 + --> tests/ui/doc/doc-fixable.rs:113:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -210,7 +210,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:126:5 + --> tests/ui/doc/doc-fixable.rs:126:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -221,7 +221,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:137:43 + --> tests/ui/doc/doc-fixable.rs:137:43 | LL | /** E.g., serialization of an empty list: FooBar | ^^^^^^ @@ -232,7 +232,7 @@ LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:142:5 + --> tests/ui/doc/doc-fixable.rs:142:5 | LL | And BarQuz too. | ^^^^^^ @@ -243,7 +243,7 @@ LL | And `BarQuz` too. | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:143:1 + --> tests/ui/doc/doc-fixable.rs:143:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -254,7 +254,7 @@ LL | `be_sure_we_got_to_the_end_of_it` | error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:148:43 + --> tests/ui/doc/doc-fixable.rs:148:43 | LL | /** E.g., serialization of an empty list: FooBar | ^^^^^^ @@ -265,7 +265,7 @@ LL | /** E.g., serialization of an empty list: `FooBar` | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:153:5 + --> tests/ui/doc/doc-fixable.rs:153:5 | LL | And BarQuz too. | ^^^^^^ @@ -276,7 +276,7 @@ LL | And `BarQuz` too. | ~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:154:1 + --> tests/ui/doc/doc-fixable.rs:154:1 | LL | be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -287,7 +287,7 @@ LL | `be_sure_we_got_to_the_end_of_it` | error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:165:5 + --> tests/ui/doc/doc-fixable.rs:165:5 | LL | /// be_sure_we_got_to_the_end_of_it | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -298,7 +298,7 @@ LL | /// `be_sure_we_got_to_the_end_of_it` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:184:22 + --> tests/ui/doc/doc-fixable.rs:184:22 | LL | /// An iterator over mycrate::Collection's values. | ^^^^^^^^^^^^^^^^^^^ @@ -309,7 +309,7 @@ LL | /// An iterator over `mycrate::Collection`'s values. | ~~~~~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:208:34 + --> tests/ui/doc/doc-fixable.rs:208:34 | LL | /// Foo \[bar\] \[baz\] \[qux\]. DocMarkdownLint | ^^^^^^^^^^^^^^^ @@ -320,7 +320,7 @@ LL | /// Foo \[bar\] \[baz\] \[qux\]. `DocMarkdownLint` | ~~~~~~~~~~~~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:231:22 + --> tests/ui/doc/doc-fixable.rs:231:22 | LL | /// There is no try (do() or do_not()). | ^^^^ @@ -331,7 +331,7 @@ LL | /// There is no try (`do()` or do_not()). | ~~~~~~ error: item in documentation is missing backticks - --> $DIR/doc-fixable.rs:231:30 + --> tests/ui/doc/doc-fixable.rs:231:30 | LL | /// There is no try (do() or do_not()). | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr index 89ad8db3916c2..56ef291362318 100644 --- a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr +++ b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr @@ -1,5 +1,5 @@ error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:7:5 + --> tests/ui/doc/unbalanced_ticks.rs:7:5 | LL | /// This is a doc comment with `unbalanced_tick marks and several words that | _____^ @@ -14,7 +14,7 @@ LL | | /// very `confusing_and_misleading`. = help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]` error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:14:5 + --> tests/ui/doc/unbalanced_ticks.rs:14:5 | LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/unbalanced_ticks.rs:17:32 + --> tests/ui/doc/unbalanced_ticks.rs:17:32 | LL | /// This paragraph is fine and should_be linted normally. | ^^^^^^^^^ @@ -33,7 +33,7 @@ LL | /// This paragraph is fine and `should_be` linted normally. | ~~~~~~~~~~~ error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:20:5 + --> tests/ui/doc/unbalanced_ticks.rs:20:5 | LL | /// Double unbalanced backtick from ``here to here` should lint. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | /// Double unbalanced backtick from ``here to here` should lint. = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/unbalanced_ticks.rs:34:8 + --> tests/ui/doc/unbalanced_ticks.rs:34:8 | LL | /// ## not_fine | ^^^^^^^^ @@ -52,7 +52,7 @@ LL | /// ## `not_fine` | ~~~~~~~~~~ error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:37:5 + --> tests/ui/doc/unbalanced_ticks.rs:37:5 | LL | /// ### `unbalanced | ^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | /// ### `unbalanced = help: a backtick may be missing a pair error: backticks are unbalanced - --> $DIR/unbalanced_ticks.rs:40:5 + --> tests/ui/doc/unbalanced_ticks.rs:40:5 | LL | /// - This `item has unbalanced tick marks | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | /// - This `item has unbalanced tick marks = help: a backtick may be missing a pair error: item in documentation is missing backticks - --> $DIR/unbalanced_ticks.rs:42:23 + --> tests/ui/doc/unbalanced_ticks.rs:42:23 | LL | /// - This item needs backticks_here | ^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/doc_errors.stderr b/src/tools/clippy/tests/ui/doc_errors.stderr index dc59675b9e5f2..c5b9479adace4 100644 --- a/src/tools/clippy/tests/ui/doc_errors.stderr +++ b/src/tools/clippy/tests/ui/doc_errors.stderr @@ -1,5 +1,5 @@ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:7:1 + --> tests/ui/doc_errors.rs:7:1 | LL | pub fn pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,37 +8,37 @@ LL | pub fn pub_fn_missing_errors_header() -> Result<(), ()> { = 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 + --> tests/ui/doc_errors.rs:13:1 | LL | pub async fn async_pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:19:1 + --> tests/ui/doc_errors.rs:19:1 | LL | pub fn pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:25:1 + --> tests/ui/doc_errors.rs:25:1 | LL | pub async fn async_pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:56:5 + --> tests/ui/doc_errors.rs:56:5 | LL | pub fn pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:62:5 + --> tests/ui/doc_errors.rs:62:5 | LL | pub async fn async_pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> $DIR/doc_errors.rs:113:5 + --> tests/ui/doc_errors.rs:113:5 | LL | fn trait_method_missing_errors_header() -> Result<(), ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 cd4f87c56b42d..e4be59c65719c 100644 --- a/src/tools/clippy/tests/ui/doc_link_with_quotes.stderr +++ b/src/tools/clippy/tests/ui/doc_link_with_quotes.stderr @@ -1,5 +1,5 @@ error: possible intra-doc link using quotes instead of backticks - --> $DIR/doc_link_with_quotes.rs:7:12 + --> tests/ui/doc_link_with_quotes.rs:7:12 | LL | /// Calls ['bar'] uselessly | ^^^^^ @@ -8,7 +8,7 @@ LL | /// Calls ['bar'] uselessly = help: to override `-D warnings` add `#[allow(clippy::doc_link_with_quotes)]` error: possible intra-doc link using quotes instead of backticks - --> $DIR/doc_link_with_quotes.rs:14:12 + --> tests/ui/doc_link_with_quotes.rs:14:12 | LL | /// Calls ["bar"] uselessly | ^^^^^ diff --git a/src/tools/clippy/tests/ui/doc_unsafe.stderr b/src/tools/clippy/tests/ui/doc_unsafe.stderr index ab3fb3c029dd3..4fcbe716951f6 100644 --- a/src/tools/clippy/tests/ui/doc_unsafe.stderr +++ b/src/tools/clippy/tests/ui/doc_unsafe.stderr @@ -1,5 +1,5 @@ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:9:1 + --> tests/ui/doc_unsafe.rs:9:1 | LL | pub unsafe fn destroy_the_planet() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | pub unsafe fn destroy_the_planet() { = 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 + --> tests/ui/doc_unsafe.rs:32:5 | LL | pub unsafe fn republished() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:40:5 + --> tests/ui/doc_unsafe.rs:40:5 | LL | unsafe fn woefully_underdocumented(self); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for unsafe trait missing `# Safety` section - --> $DIR/doc_unsafe.rs:46:1 + --> tests/ui/doc_unsafe.rs:46:1 | LL | pub unsafe trait UnsafeTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:76:5 + --> tests/ui/doc_unsafe.rs:76:5 | LL | pub unsafe fn more_undocumented_unsafe() -> Self { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe function's docs miss `# Safety` section - --> $DIR/doc_unsafe.rs:92:9 + --> tests/ui/doc_unsafe.rs:92:9 | LL | pub unsafe fn whee() { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/double_comparison.stderr b/src/tools/clippy/tests/ui/double_comparison.stderr index 02f0a960974b8..01ba7a8ee1083 100644 --- a/src/tools/clippy/tests/ui/double_comparison.stderr +++ b/src/tools/clippy/tests/ui/double_comparison.stderr @@ -1,5 +1,5 @@ error: this binary expression can be simplified - --> $DIR/double_comparison.rs:6:8 + --> tests/ui/double_comparison.rs:6:8 | LL | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` @@ -8,43 +8,43 @@ LL | if x == y || x < y { = help: to override `-D warnings` add `#[allow(clippy::double_comparisons)]` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:9:8 + --> tests/ui/double_comparison.rs:9:8 | LL | if x < y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:12:8 + --> tests/ui/double_comparison.rs:12:8 | LL | if x == y || x > y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:15:8 + --> tests/ui/double_comparison.rs:15:8 | LL | if x > y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:18:8 + --> tests/ui/double_comparison.rs:18:8 | LL | if x < y || x > y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:21:8 + --> tests/ui/double_comparison.rs:21:8 | LL | if x > y || x < y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:24:8 + --> tests/ui/double_comparison.rs:24:8 | LL | if x <= y && x >= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: this binary expression can be simplified - --> $DIR/double_comparison.rs:27:8 + --> tests/ui/double_comparison.rs:27:8 | LL | if x >= y && x <= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` diff --git a/src/tools/clippy/tests/ui/double_must_use.stderr b/src/tools/clippy/tests/ui/double_must_use.stderr index a2d87c59ecf8a..0f2154ecbcfab 100644 --- a/src/tools/clippy/tests/ui/double_must_use.stderr +++ b/src/tools/clippy/tests/ui/double_must_use.stderr @@ -1,5 +1,5 @@ error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` - --> $DIR/double_must_use.rs:5:1 + --> tests/ui/double_must_use.rs:5:1 | LL | pub fn must_use_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | pub fn must_use_result() -> Result<(), ()> { = 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 + --> tests/ui/double_must_use.rs:11:1 | LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { = help: either add some descriptive text or remove the attribute error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` - --> $DIR/double_must_use.rs:17:1 + --> tests/ui/double_must_use.rs:17:1 | LL | pub fn must_use_array() -> [Result<(), ()>; 1] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | pub fn must_use_array() -> [Result<(), ()>; 1] { = help: either add some descriptive text or remove the attribute error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` - --> $DIR/double_must_use.rs:34:1 + --> tests/ui/double_must_use.rs:34:1 | LL | async fn async_must_use_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/double_neg.stderr b/src/tools/clippy/tests/ui/double_neg.stderr index a4fa1688d577b..9a902d1323ccd 100644 --- a/src/tools/clippy/tests/ui/double_neg.stderr +++ b/src/tools/clippy/tests/ui/double_neg.stderr @@ -1,5 +1,5 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op - --> $DIR/double_neg.rs:7:5 + --> tests/ui/double_neg.rs:7:5 | LL | --x; | ^^^ diff --git a/src/tools/clippy/tests/ui/double_parens.stderr b/src/tools/clippy/tests/ui/double_parens.stderr index 8a010d8ccc045..aba301e9f072f 100644 --- a/src/tools/clippy/tests/ui/double_parens.stderr +++ b/src/tools/clippy/tests/ui/double_parens.stderr @@ -1,5 +1,5 @@ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:15:5 + --> tests/ui/double_parens.rs:15:5 | LL | ((0)) | ^^^^^ @@ -8,31 +8,31 @@ LL | ((0)) = help: to override `-D warnings` add `#[allow(clippy::double_parens)]` error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:21:14 + --> tests/ui/double_parens.rs:21:14 | LL | dummy_fn((0)); | ^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:26:20 + --> tests/ui/double_parens.rs:26:20 | LL | x.dummy_method((0)); | ^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:31:5 + --> tests/ui/double_parens.rs:31:5 | LL | ((1, 2)) | ^^^^^^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:36:5 + --> tests/ui/double_parens.rs:36:5 | LL | (()) | ^^^^ error: consider removing unnecessary double parentheses - --> $DIR/double_parens.rs:59:16 + --> tests/ui/double_parens.rs:59:16 | LL | assert_eq!(((1, 2)), (1, 2), "Error"); | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/drain_collect.stderr b/src/tools/clippy/tests/ui/drain_collect.stderr index 3364466ec80be..1dfd0f1e3463e 100644 --- a/src/tools/clippy/tests/ui/drain_collect.stderr +++ b/src/tools/clippy/tests/ui/drain_collect.stderr @@ -1,65 +1,65 @@ error: you seem to be trying to move all elements into a new `BinaryHeap` - --> $DIR/drain_collect.rs:7:5 + --> tests/ui/drain_collect.rs:7:5 | LL | b.drain().collect() | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` | note: the lint level is defined here - --> $DIR/drain_collect.rs:1:9 + --> tests/ui/drain_collect.rs:1:9 | LL | #![deny(clippy::drain_collect)] | ^^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to move all elements into a new `HashMap` - --> $DIR/drain_collect.rs:15:5 + --> tests/ui/drain_collect.rs:15:5 | LL | b.drain().collect() | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `HashSet` - --> $DIR/drain_collect.rs:23:5 + --> tests/ui/drain_collect.rs:23:5 | LL | b.drain().collect() | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:31:5 + --> tests/ui/drain_collect.rs:31:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:39:5 + --> tests/ui/drain_collect.rs:39:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:43:5 + --> tests/ui/drain_collect.rs:43:5 | LL | b.drain(0..).collect() | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:47:5 + --> tests/ui/drain_collect.rs:47:5 | LL | b.drain(..b.len()).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:51:5 + --> tests/ui/drain_collect.rs:51:5 | LL | b.drain(0..b.len()).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: you seem to be trying to move all elements into a new `Vec` - --> $DIR/drain_collect.rs:56:5 + --> tests/ui/drain_collect.rs:56:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(&mut b)` error: you seem to be trying to move all elements into a new `String` - --> $DIR/drain_collect.rs:64:5 + --> tests/ui/drain_collect.rs:64:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` diff --git a/src/tools/clippy/tests/ui/drop_non_drop.stderr b/src/tools/clippy/tests/ui/drop_non_drop.stderr index a571076f68cd2..fac89bf1f26a7 100644 --- a/src/tools/clippy/tests/ui/drop_non_drop.stderr +++ b/src/tools/clippy/tests/ui/drop_non_drop.stderr @@ -1,11 +1,11 @@ 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:22:5 + --> tests/ui/drop_non_drop.rs:22:5 | LL | drop(Foo); | ^^^^^^^^^ | note: argument has type `main::Foo` - --> $DIR/drop_non_drop.rs:22:10 + --> tests/ui/drop_non_drop.rs:22:10 | LL | drop(Foo); | ^^^ @@ -13,13 +13,13 @@ LL | drop(Foo); = 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 + --> tests/ui/drop_non_drop.rs:38:5 | LL | drop(Baz(Foo)); | ^^^^^^^^^^^^^^ | note: argument has type `main::Baz` - --> $DIR/drop_non_drop.rs:38:10 + --> tests/ui/drop_non_drop.rs:38:10 | LL | drop(Baz(Foo)); | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr b/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr index 53ee0c4e8c895..40a24b823d115 100644 --- a/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr +++ b/src/tools/clippy/tests/ui/duplicate_underscore_argument.stderr @@ -1,5 +1,5 @@ error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult - --> $DIR/duplicate_underscore_argument.rs:4:23 + --> tests/ui/duplicate_underscore_argument.rs:4:23 | LL | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ diff --git a/src/tools/clippy/tests/ui/duration_subsec.stderr b/src/tools/clippy/tests/ui/duration_subsec.stderr index 705683837123e..55e44f149cf1e 100644 --- a/src/tools/clippy/tests/ui/duration_subsec.stderr +++ b/src/tools/clippy/tests/ui/duration_subsec.stderr @@ -1,5 +1,5 @@ error: calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:9:24 + --> tests/ui/duration_subsec.rs:9:24 | LL | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` @@ -8,25 +8,25 @@ LL | let bad_millis_1 = dur.subsec_micros() / 1_000; = 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 + --> tests/ui/duration_subsec.rs:10:24 | LL | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` error: calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:15:22 + --> tests/ui/duration_subsec.rs:15:22 | LL | let bad_micros = dur.subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:20:13 + --> tests/ui/duration_subsec.rs:20:13 | LL | let _ = (&dur).subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()` error: calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:24:13 + --> tests/ui/duration_subsec.rs:24:13 | LL | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` diff --git a/src/tools/clippy/tests/ui/eager_transmute.stderr b/src/tools/clippy/tests/ui/eager_transmute.stderr index 5f42eec544fae..b9a4321d99efe 100644 --- a/src/tools/clippy/tests/ui/eager_transmute.stderr +++ b/src/tools/clippy/tests/ui/eager_transmute.stderr @@ -1,5 +1,5 @@ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:21:33 + --> tests/ui/eager_transmute.rs:21:33 | LL | (op < 4).then_some(unsafe { std::mem::transmute(op) }) | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | (op < 4).then(|| unsafe { std::mem::transmute(op) }) | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:27:33 + --> tests/ui/eager_transmute.rs:27:33 | LL | (op < 4).then_some(unsafe { std::mem::transmute::<_, Opcode>(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | (op < 4).then(|| unsafe { std::mem::transmute::<_, Opcode>(op) }); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:28:33 + --> tests/ui/eager_transmute.rs:28:33 | LL | (op > 4).then_some(unsafe { std::mem::transmute::<_, Opcode>(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | (op > 4).then(|| unsafe { std::mem::transmute::<_, Opcode>(op) }); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:29:34 + --> tests/ui/eager_transmute.rs:29:34 | LL | (op == 0).then_some(unsafe { std::mem::transmute::<_, Opcode>(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | (op == 0).then(|| unsafe { std::mem::transmute::<_, Opcode>(op) }); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:31:68 + --> tests/ui/eager_transmute.rs:31:68 | LL | let _: Option = (op > 0 && op < 10).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | let _: Option = (op > 0 && op < 10).then(|| unsafe { std::mem:: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:32:86 + --> tests/ui/eager_transmute.rs:32:86 | LL | let _: Option = (op > 0 && op < 10 && unrelated == 0).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | let _: Option = (op > 0 && op < 10 && unrelated == 0).then(|| u | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:35:84 + --> tests/ui/eager_transmute.rs:35:84 | LL | let _: Option = (op2.foo[0] > 0 && op2.foo[0] < 10).then_some(unsafe { std::mem::transmute(op2.foo[0]) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | let _: Option = (op2.foo[0] > 0 && op2.foo[0] < 10).then(|| uns | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:47:70 + --> tests/ui/eager_transmute.rs:47:70 | LL | let _: Option = (1..=3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: Option = (1..=3).contains(&op).then(|| unsafe { std::mem | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:48:83 + --> tests/ui/eager_transmute.rs:48:83 | LL | let _: Option = ((1..=3).contains(&op) || op == 4).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _: Option = ((1..=3).contains(&op) || op == 4).then(|| unsa | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:49:69 + --> tests/ui/eager_transmute.rs:49:69 | LL | let _: Option = (1..3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | let _: Option = (1..3).contains(&op).then(|| unsafe { std::mem: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:50:68 + --> tests/ui/eager_transmute.rs:50:68 | LL | let _: Option = (1..).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | let _: Option = (1..).contains(&op).then(|| unsafe { std::mem:: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:51:68 + --> tests/ui/eager_transmute.rs:51:68 | LL | let _: Option = (..3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | let _: Option = (..3).contains(&op).then(|| unsafe { std::mem:: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:52:69 + --> tests/ui/eager_transmute.rs:52:69 | LL | let _: Option = (..=3).contains(&op).then_some(unsafe { std::mem::transmute(op) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | let _: Option = (..=3).contains(&op).then(|| unsafe { std::mem: | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:61:24 + --> tests/ui/eager_transmute.rs:61:24 | LL | (op < 4).then_some(std::mem::transmute::<_, Opcode>(op)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | (op < 4).then(|| std::mem::transmute::<_, Opcode>(op)); | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:90:60 + --> tests/ui/eager_transmute.rs:90:60 | LL | let _: Option = (v1 > 0).then_some(unsafe { std::mem::transmute(v1) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | let _: Option = (v1 > 0).then(|| unsafe { std::mem::transmut | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:96:86 + --> tests/ui/eager_transmute.rs:96:86 | LL | let _: Option = (v2 < NonZeroU8::new(255).unwrap()).then_some(unsafe { std::mem::transmute(v2) }); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | let _: Option = (v2 < NonZeroU8::new(255).unwrap()).then(|| u | ~~~~ ++ error: this transmute is always evaluated eagerly, even if the condition is false - --> $DIR/eager_transmute.rs:102:93 + --> tests/ui/eager_transmute.rs:102:93 | LL | let _: Option = (v2 < NonZeroU8::new(255).unwrap()).then_some(unsafe { std::mem::transmute(v2) }); | ^^^^^^^^^^^^^^^^^^^^^^^ 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 b2bf4ac4d1b12..80355cb2dba6a 100644 --- a/src/tools/clippy/tests/ui/else_if_without_else.stderr +++ b/src/tools/clippy/tests/ui/else_if_without_else.stderr @@ -1,5 +1,5 @@ error: `if` expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:45:12 + --> tests/ui/else_if_without_else.rs:45:12 | LL | } else if bla2() { | ____________^ @@ -13,7 +13,7 @@ LL | | } = 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 + --> tests/ui/else_if_without_else.rs:54:12 | LL | } else if bla3() { | ____________^ diff --git a/src/tools/clippy/tests/ui/empty_docs.rs b/src/tools/clippy/tests/ui/empty_docs.rs new file mode 100644 index 0000000000000..c47a603e71b43 --- /dev/null +++ b/src/tools/clippy/tests/ui/empty_docs.rs @@ -0,0 +1,67 @@ +#![allow(unused)] +#![warn(clippy::empty_docs)] +mod outer { + //! + + /// this is a struct + struct Bananas { + /// count + count: usize, + } + + /// + enum Warn { + /// + A, + B, + } + + enum DontWarn { + /// i + A, + B, + } + + #[doc = ""] + fn warn_about_this() {} + + #[doc = ""] + #[doc = ""] + fn this_doesn_warn() {} + + #[doc = "a fine function"] + fn this_is_fine() {} + + /// + mod inner { + /// + fn dont_warn_inner_outer() { + //!w + } + + fn this_is_ok() { + //! + //! inside the function + } + + fn warn() { + /*! */ + } + + fn dont_warn() { + /*! dont warn me */ + } + + trait NoDoc { + /// + fn some() {} + } + } + + union Unite { + /// lint y + x: i32, + /// + y: i32, + } +} diff --git a/src/tools/clippy/tests/ui/empty_docs.stderr b/src/tools/clippy/tests/ui/empty_docs.stderr new file mode 100644 index 0000000000000..3f1d071fb13ce --- /dev/null +++ b/src/tools/clippy/tests/ui/empty_docs.stderr @@ -0,0 +1,77 @@ +error: empty doc comment + --> tests/ui/empty_docs.rs:4:5 + | +LL | //! + | ^^^ + | + = help: consider removing or filling it + = note: `-D clippy::empty-docs` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::empty_docs)]` + +error: empty doc comment + --> tests/ui/empty_docs.rs:12:5 + | +LL | /// + | ^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:14:9 + | +LL | /// + | ^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:25:5 + | +LL | #[doc = ""] + | ^^^^^^^^^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:28:5 + | +LL | / #[doc = ""] +LL | | #[doc = ""] + | |_______________^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:35:5 + | +LL | /// + | ^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:48:13 + | +LL | /*! */ + | ^^^^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:56:13 + | +LL | /// + | ^^^ + | + = help: consider removing or filling it + +error: empty doc comment + --> tests/ui/empty_docs.rs:64:9 + | +LL | /// + | ^^^ + | + = help: consider removing or filling it + +error: aborting due to 9 previous errors + diff --git a/src/tools/clippy/tests/ui/empty_drop.stderr b/src/tools/clippy/tests/ui/empty_drop.stderr index 5848eab744740..4223ddaf3fba5 100644 --- a/src/tools/clippy/tests/ui/empty_drop.stderr +++ b/src/tools/clippy/tests/ui/empty_drop.stderr @@ -1,5 +1,5 @@ error: empty drop implementation - --> $DIR/empty_drop.rs:7:1 + --> tests/ui/empty_drop.rs:7:1 | LL | / impl Drop for Foo { LL | | fn drop(&mut self) {} @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::empty_drop)]` error: empty drop implementation - --> $DIR/empty_drop.rs:23:1 + --> tests/ui/empty_drop.rs:23:1 | LL | / impl Drop for Baz { LL | | fn drop(&mut self) { diff --git a/src/tools/clippy/tests/ui/empty_enum.stderr b/src/tools/clippy/tests/ui/empty_enum.stderr index c9bd887643e90..6a1ded9298ed7 100644 --- a/src/tools/clippy/tests/ui/empty_enum.stderr +++ b/src/tools/clippy/tests/ui/empty_enum.stderr @@ -1,5 +1,5 @@ error: enum with no variants - --> $DIR/empty_enum.rs:5:1 + --> tests/ui/empty_enum.rs:5:1 | LL | enum Empty {} | ^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/empty_enum_variants_with_brackets.stderr b/src/tools/clippy/tests/ui/empty_enum_variants_with_brackets.stderr index 6b2f286147fab..2b187b8f755b4 100644 --- a/src/tools/clippy/tests/ui/empty_enum_variants_with_brackets.stderr +++ b/src/tools/clippy/tests/ui/empty_enum_variants_with_brackets.stderr @@ -1,5 +1,5 @@ error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:7:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:7:16 | LL | EmptyBraces {}, | ^^^ @@ -9,7 +9,7 @@ LL | EmptyBraces {}, = help: remove the brackets error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:8:21 + --> tests/ui/empty_enum_variants_with_brackets.rs:8:21 | LL | EmptyParentheses(), | ^^ @@ -17,7 +17,7 @@ LL | EmptyParentheses(), = help: remove the brackets error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:14:16 + --> tests/ui/empty_enum_variants_with_brackets.rs:14:16 | LL | EmptyBraces {}, | ^^^ @@ -25,7 +25,7 @@ LL | EmptyBraces {}, = help: remove the brackets error: enum variant has empty brackets - --> $DIR/empty_enum_variants_with_brackets.rs:15:21 + --> tests/ui/empty_enum_variants_with_brackets.rs:15:21 | LL | EmptyParentheses(), | ^^ 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 2cf5b5b0f5494..889ccf6ba19dd 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 @@ -1,5 +1,5 @@ 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:18:1 + --> tests/ui/empty_line_after_doc_comments.rs:18:1 | LL | / /// This should produce a warning LL | | @@ -10,7 +10,7 @@ LL | | fn with_doc_and_newline() { assert!(true)} = 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 + --> tests/ui/empty_line_after_doc_comments.rs:68:1 | LL | / /// This doc comment should produce a warning LL | | @@ -22,7 +22,7 @@ LL | | fn three_attributes() { assert!(true) } | |_ 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:70:1 + --> tests/ui/empty_line_after_doc_comments.rs:70:1 | LL | / /** This is also a doc comment and should produce a warning LL | | */ 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 0cb848c20dde7..1b5b00a4a83bb 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 @@ -1,5 +1,5 @@ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:11:1 + --> tests/ui/empty_line_after_outer_attribute.rs:11:1 | LL | / #[crate_type = "lib"] LL | | @@ -11,7 +11,7 @@ LL | | fn with_one_newline_and_comment() { assert!(true) } = 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 + --> tests/ui/empty_line_after_outer_attribute.rs:23:1 | LL | / #[crate_type = "lib"] LL | | @@ -19,7 +19,7 @@ LL | | fn with_one_newline() { assert!(true) } | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:28:1 + --> tests/ui/empty_line_after_outer_attribute.rs:28:1 | LL | / #[crate_type = "lib"] LL | | @@ -28,7 +28,7 @@ LL | | fn with_two_newlines() { assert!(true) } | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:35:1 + --> tests/ui/empty_line_after_outer_attribute.rs:35:1 | LL | / #[crate_type = "lib"] LL | | @@ -36,7 +36,7 @@ LL | | enum Baz { | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:43:1 + --> tests/ui/empty_line_after_outer_attribute.rs:43:1 | LL | / #[crate_type = "lib"] LL | | @@ -44,7 +44,7 @@ LL | | struct Foo { | |_ error: found an empty line after an outer attribute. Perhaps you forgot to add a `!` to make it an inner attribute? - --> $DIR/empty_line_after_outer_attribute.rs:51:1 + --> tests/ui/empty_line_after_outer_attribute.rs:51:1 | LL | / #[crate_type = "lib"] LL | | diff --git a/src/tools/clippy/tests/ui/empty_loop.stderr b/src/tools/clippy/tests/ui/empty_loop.stderr index 113556f673c8c..3ac93f4ece0cc 100644 --- a/src/tools/clippy/tests/ui/empty_loop.stderr +++ b/src/tools/clippy/tests/ui/empty_loop.stderr @@ -1,5 +1,5 @@ error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop.rs:9:5 + --> tests/ui/empty_loop.rs:9:5 | LL | loop {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | loop {} = help: to override `-D warnings` add `#[allow(clippy::empty_loop)]` error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop.rs:12:9 + --> tests/ui/empty_loop.rs:12:9 | LL | loop {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | loop {} = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop.rs:17:9 + --> tests/ui/empty_loop.rs:17:9 | LL | 'inner: loop {} | ^^^^^^^^^^^^^^^ 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 90200826472b1..f4a18204c3cef 100644 --- a/src/tools/clippy/tests/ui/empty_loop_no_std.stderr +++ b/src/tools/clippy/tests/ui/empty_loop_no_std.stderr @@ -1,5 +1,5 @@ error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop_no_std.rs:13:5 + --> tests/ui/empty_loop_no_std.rs:13:5 | LL | loop {} | ^^^^^^^ @@ -9,7 +9,7 @@ LL | loop {} = help: to override `-D warnings` add `#[allow(clippy::empty_loop)]` error: empty `loop {}` wastes CPU cycles - --> $DIR/empty_loop_no_std.rs:26:5 + --> tests/ui/empty_loop_no_std.rs:26:5 | LL | loop {} | ^^^^^^^ 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 4b8572d5c9ef6..e57249aec0238 100644 --- a/src/tools/clippy/tests/ui/empty_structs_with_brackets.stderr +++ b/src/tools/clippy/tests/ui/empty_structs_with_brackets.stderr @@ -1,5 +1,5 @@ error: found empty brackets on struct declaration - --> $DIR/empty_structs_with_brackets.rs:4:25 + --> tests/ui/empty_structs_with_brackets.rs:4:25 | LL | pub struct MyEmptyStruct {} // should trigger lint | ^^^ @@ -9,7 +9,7 @@ LL | pub struct MyEmptyStruct {} // should trigger lint = help: remove the brackets error: found empty brackets on struct declaration - --> $DIR/empty_structs_with_brackets.rs:5:26 + --> tests/ui/empty_structs_with_brackets.rs:5:26 | LL | struct MyEmptyTupleStruct(); // should trigger lint | ^^^ diff --git a/src/tools/clippy/tests/ui/endian_bytes.stderr b/src/tools/clippy/tests/ui/endian_bytes.stderr index a458c46fa69ac..3fc26dcab8869 100644 --- a/src/tools/clippy/tests/ui/endian_bytes.stderr +++ b/src/tools/clippy/tests/ui/endian_bytes.stderr @@ -1,5 +1,5 @@ error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:7:9 + --> tests/ui/endian_bytes.rs:7:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | fn host() { fn_body!(); } = 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 - --> $DIR/endian_bytes.rs:8:9 + --> tests/ui/endian_bytes.rs:8:9 | LL | 2i8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u16::to_ne_bytes` method - --> $DIR/endian_bytes.rs:9:9 + --> tests/ui/endian_bytes.rs:9:9 | LL | 2u16.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i16::to_ne_bytes` method - --> $DIR/endian_bytes.rs:10:9 + --> tests/ui/endian_bytes.rs:10:9 | LL | 2i16.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u32::to_ne_bytes` method - --> $DIR/endian_bytes.rs:11:9 + --> tests/ui/endian_bytes.rs:11:9 | LL | 2u32.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i32::to_ne_bytes` method - --> $DIR/endian_bytes.rs:12:9 + --> tests/ui/endian_bytes.rs:12:9 | LL | 2i32.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u64::to_ne_bytes` method - --> $DIR/endian_bytes.rs:13:9 + --> tests/ui/endian_bytes.rs:13:9 | LL | 2u64.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i64::to_ne_bytes` method - --> $DIR/endian_bytes.rs:14:9 + --> tests/ui/endian_bytes.rs:14:9 | LL | 2i64.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u128::to_ne_bytes` method - --> $DIR/endian_bytes.rs:15:9 + --> tests/ui/endian_bytes.rs:15:9 | LL | 2u128.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i128::to_ne_bytes` method - --> $DIR/endian_bytes.rs:16:9 + --> tests/ui/endian_bytes.rs:16:9 | LL | 2i128.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f32::to_ne_bytes` method - --> $DIR/endian_bytes.rs:17:9 + --> tests/ui/endian_bytes.rs:17:9 | LL | 2.0f32.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f64::to_ne_bytes` method - --> $DIR/endian_bytes.rs:18:9 + --> tests/ui/endian_bytes.rs:18:9 | LL | 2.0f64.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `usize::to_ne_bytes` method - --> $DIR/endian_bytes.rs:19:9 + --> tests/ui/endian_bytes.rs:19:9 | LL | 2usize.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `isize::to_ne_bytes` method - --> $DIR/endian_bytes.rs:20:9 + --> tests/ui/endian_bytes.rs:20:9 | LL | 2isize.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_ne_bytes` - --> $DIR/endian_bytes.rs:21:9 + --> tests/ui/endian_bytes.rs:21:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i8::from_ne_bytes` - --> $DIR/endian_bytes.rs:22:9 + --> tests/ui/endian_bytes.rs:22:9 | LL | i8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u16::from_ne_bytes` - --> $DIR/endian_bytes.rs:23:9 + --> tests/ui/endian_bytes.rs:23:9 | LL | u16::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i16::from_ne_bytes` - --> $DIR/endian_bytes.rs:24:9 + --> tests/ui/endian_bytes.rs:24:9 | LL | i16::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u32::from_ne_bytes` - --> $DIR/endian_bytes.rs:25:9 + --> tests/ui/endian_bytes.rs:25:9 | LL | u32::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i32::from_ne_bytes` - --> $DIR/endian_bytes.rs:26:9 + --> tests/ui/endian_bytes.rs:26:9 | LL | i32::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u64::from_ne_bytes` - --> $DIR/endian_bytes.rs:27:9 + --> tests/ui/endian_bytes.rs:27:9 | LL | u64::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i64::from_ne_bytes` - --> $DIR/endian_bytes.rs:28:9 + --> tests/ui/endian_bytes.rs:28:9 | LL | i64::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -265,7 +265,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u128::from_ne_bytes` - --> $DIR/endian_bytes.rs:29:9 + --> tests/ui/endian_bytes.rs:29:9 | LL | u128::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -277,7 +277,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i128::from_ne_bytes` - --> $DIR/endian_bytes.rs:30:9 + --> tests/ui/endian_bytes.rs:30:9 | LL | i128::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -289,7 +289,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `usize::from_ne_bytes` - --> $DIR/endian_bytes.rs:31:9 + --> tests/ui/endian_bytes.rs:31:9 | LL | usize::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -301,7 +301,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `isize::from_ne_bytes` - --> $DIR/endian_bytes.rs:32:9 + --> tests/ui/endian_bytes.rs:32:9 | LL | isize::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -313,7 +313,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f32::from_ne_bytes` - --> $DIR/endian_bytes.rs:33:9 + --> tests/ui/endian_bytes.rs:33:9 | LL | f32::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -325,7 +325,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f64::from_ne_bytes` - --> $DIR/endian_bytes.rs:34:9 + --> tests/ui/endian_bytes.rs:34:9 | LL | f64::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL | fn host() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:36:9 + --> tests/ui/endian_bytes.rs:36:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -351,7 +351,7 @@ LL | fn little() { fn_body!(); } = 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 - --> $DIR/endian_bytes.rs:37:9 + --> tests/ui/endian_bytes.rs:37:9 | LL | 2i8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -363,7 +363,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u16::to_le_bytes` method - --> $DIR/endian_bytes.rs:38:9 + --> tests/ui/endian_bytes.rs:38:9 | LL | 2u16.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -375,7 +375,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i16::to_le_bytes` method - --> $DIR/endian_bytes.rs:39:9 + --> tests/ui/endian_bytes.rs:39:9 | LL | 2i16.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -387,7 +387,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u32::to_le_bytes` method - --> $DIR/endian_bytes.rs:40:9 + --> tests/ui/endian_bytes.rs:40:9 | LL | 2u32.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -399,7 +399,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i32::to_le_bytes` method - --> $DIR/endian_bytes.rs:41:9 + --> tests/ui/endian_bytes.rs:41:9 | LL | 2i32.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -411,7 +411,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u64::to_le_bytes` method - --> $DIR/endian_bytes.rs:42:9 + --> tests/ui/endian_bytes.rs:42:9 | LL | 2u64.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -423,7 +423,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i64::to_le_bytes` method - --> $DIR/endian_bytes.rs:43:9 + --> tests/ui/endian_bytes.rs:43:9 | LL | 2i64.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u128::to_le_bytes` method - --> $DIR/endian_bytes.rs:44:9 + --> tests/ui/endian_bytes.rs:44:9 | LL | 2u128.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -447,7 +447,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `i128::to_le_bytes` method - --> $DIR/endian_bytes.rs:45:9 + --> tests/ui/endian_bytes.rs:45:9 | LL | 2i128.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f32::to_le_bytes` method - --> $DIR/endian_bytes.rs:46:9 + --> tests/ui/endian_bytes.rs:46:9 | LL | 2.0f32.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -471,7 +471,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `f64::to_le_bytes` method - --> $DIR/endian_bytes.rs:47:9 + --> tests/ui/endian_bytes.rs:47:9 | LL | 2.0f64.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -483,7 +483,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `usize::to_le_bytes` method - --> $DIR/endian_bytes.rs:48:9 + --> tests/ui/endian_bytes.rs:48:9 | LL | 2usize.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -495,7 +495,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `isize::to_le_bytes` method - --> $DIR/endian_bytes.rs:49:9 + --> tests/ui/endian_bytes.rs:49:9 | LL | 2isize.to_le_bytes(); | ^^^^^^^^^^^^^^^^^^^^ @@ -507,7 +507,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u8::from_le_bytes` - --> $DIR/endian_bytes.rs:50:9 + --> tests/ui/endian_bytes.rs:50:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -519,7 +519,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i8::from_le_bytes` - --> $DIR/endian_bytes.rs:51:9 + --> tests/ui/endian_bytes.rs:51:9 | LL | i8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -531,7 +531,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u16::from_le_bytes` - --> $DIR/endian_bytes.rs:52:9 + --> tests/ui/endian_bytes.rs:52:9 | LL | u16::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -543,7 +543,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i16::from_le_bytes` - --> $DIR/endian_bytes.rs:53:9 + --> tests/ui/endian_bytes.rs:53:9 | LL | i16::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -555,7 +555,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u32::from_le_bytes` - --> $DIR/endian_bytes.rs:54:9 + --> tests/ui/endian_bytes.rs:54:9 | LL | u32::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -567,7 +567,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i32::from_le_bytes` - --> $DIR/endian_bytes.rs:55:9 + --> tests/ui/endian_bytes.rs:55:9 | LL | i32::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -579,7 +579,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u64::from_le_bytes` - --> $DIR/endian_bytes.rs:56:9 + --> tests/ui/endian_bytes.rs:56:9 | LL | u64::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -591,7 +591,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i64::from_le_bytes` - --> $DIR/endian_bytes.rs:57:9 + --> tests/ui/endian_bytes.rs:57:9 | LL | i64::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -603,7 +603,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `u128::from_le_bytes` - --> $DIR/endian_bytes.rs:58:9 + --> tests/ui/endian_bytes.rs:58:9 | LL | u128::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -615,7 +615,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `i128::from_le_bytes` - --> $DIR/endian_bytes.rs:59:9 + --> tests/ui/endian_bytes.rs:59:9 | LL | i128::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -627,7 +627,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `usize::from_le_bytes` - --> $DIR/endian_bytes.rs:60:9 + --> tests/ui/endian_bytes.rs:60:9 | LL | usize::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -639,7 +639,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `isize::from_le_bytes` - --> $DIR/endian_bytes.rs:61:9 + --> tests/ui/endian_bytes.rs:61:9 | LL | isize::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -651,7 +651,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f32::from_le_bytes` - --> $DIR/endian_bytes.rs:62:9 + --> tests/ui/endian_bytes.rs:62:9 | LL | f32::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -663,7 +663,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the function `f64::from_le_bytes` - --> $DIR/endian_bytes.rs:63:9 + --> tests/ui/endian_bytes.rs:63:9 | LL | f64::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -675,7 +675,7 @@ LL | fn little() { fn_body!(); } = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) error: usage of the `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -687,7 +687,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = 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_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -699,7 +699,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = 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 `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -713,7 +713,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = 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` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -725,7 +725,7 @@ LL | fn host_encourage_little() { fn_body_smol!(); } = 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 `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -737,7 +737,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = 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_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -749,7 +749,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = 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 `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -761,7 +761,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = 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_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -773,7 +773,7 @@ LL | fn host_encourage_big() { fn_body_smol!(); } = 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 `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -784,7 +784,7 @@ LL | fn no_help() { fn_body_smol!(); } = 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_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -795,7 +795,7 @@ LL | fn no_help() { fn_body_smol!(); } = 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 `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -806,7 +806,7 @@ LL | fn no_help() { fn_body_smol!(); } = 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_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -817,7 +817,7 @@ LL | fn no_help() { fn_body_smol!(); } = 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 `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -828,7 +828,7 @@ LL | fn no_help() { fn_body_smol!(); } = 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` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -839,7 +839,7 @@ LL | fn no_help() { fn_body_smol!(); } = 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 `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -851,7 +851,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = 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_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -863,7 +863,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = 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 `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -875,7 +875,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = 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` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -887,7 +887,7 @@ LL | fn little_encourage_host() { fn_body_smol!(); } = 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 `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -899,7 +899,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = 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_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -911,7 +911,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = 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 `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -923,7 +923,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = 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_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -935,7 +935,7 @@ LL | fn little_encourage_big() { fn_body_smol!(); } = 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 `u8::to_le_bytes` method - --> $DIR/endian_bytes.rs:73:9 + --> tests/ui/endian_bytes.rs:73:9 | LL | 2u8.to_le_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -947,7 +947,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = 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_le_bytes` - --> $DIR/endian_bytes.rs:74:9 + --> tests/ui/endian_bytes.rs:74:9 | LL | u8::from_le_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -959,7 +959,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = 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 `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -971,7 +971,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = 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` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -983,7 +983,7 @@ LL | fn big_encourage_host() { fn_body_smol!(); } = 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 `u8::to_ne_bytes` method - --> $DIR/endian_bytes.rs:70:9 + --> tests/ui/endian_bytes.rs:70:9 | LL | 2u8.to_ne_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -995,7 +995,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); } = 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_ne_bytes` - --> $DIR/endian_bytes.rs:71:9 + --> tests/ui/endian_bytes.rs:71:9 | LL | u8::from_ne_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1007,7 +1007,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); } = 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 `u8::to_be_bytes` method - --> $DIR/endian_bytes.rs:76:9 + --> tests/ui/endian_bytes.rs:76:9 | LL | 2u8.to_be_bytes(); | ^^^^^^^^^^^^^^^^^ @@ -1019,7 +1019,7 @@ LL | fn big_encourage_little() { fn_body_smol!(); } = 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` - --> $DIR/endian_bytes.rs:77:9 + --> tests/ui/endian_bytes.rs:77:9 | LL | u8::from_be_bytes(todo!()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/entry.stderr b/src/tools/clippy/tests/ui/entry.stderr index b01f0a9a0e56b..ef4c36bcf546c 100644 --- a/src/tools/clippy/tests/ui/entry.stderr +++ b/src/tools/clippy/tests/ui/entry.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:24:5 + --> tests/ui/entry.rs:24:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -10,7 +10,7 @@ LL | | } = 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 + --> tests/ui/entry.rs:29:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -33,7 +33,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:38:5 + --> tests/ui/entry.rs:38:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -56,7 +56,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:47:5 + --> tests/ui/entry.rs:47:5 | LL | / if !m.contains_key(&k) { LL | | if true { @@ -80,7 +80,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:57:5 + --> tests/ui/entry.rs:57:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -97,7 +97,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:63:5 + --> tests/ui/entry.rs:63:5 | LL | / if !m.contains_key(&k) { LL | | match 0 { @@ -123,7 +123,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:75:5 + --> tests/ui/entry.rs:75:5 | LL | / if !m.contains_key(&k) { LL | | match 0 { @@ -147,7 +147,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:85:5 + --> tests/ui/entry.rs:85:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -188,7 +188,7 @@ LL + }); | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:119:5 + --> tests/ui/entry.rs:119:5 | LL | / if !m.contains_key(&m!(k)) { LL | | m.insert(m!(k), m!(v)); @@ -196,7 +196,7 @@ LL | | } | |_____^ help: try: `m.entry(m!(k)).or_insert_with(|| m!(v));` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:151:5 + --> tests/ui/entry.rs:151:5 | LL | / if !m.contains_key(&k) { LL | | let x = (String::new(), String::new()); diff --git a/src/tools/clippy/tests/ui/entry_btree.stderr b/src/tools/clippy/tests/ui/entry_btree.stderr index 63e9a0af8b6b3..290e6b7880541 100644 --- a/src/tools/clippy/tests/ui/entry_btree.stderr +++ b/src/tools/clippy/tests/ui/entry_btree.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `BTreeMap` - --> $DIR/entry_btree.rs:10:5 + --> tests/ui/entry_btree.rs:10:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); diff --git a/src/tools/clippy/tests/ui/entry_with_else.stderr b/src/tools/clippy/tests/ui/entry_with_else.stderr index 425e87122d57f..26b21b076b6c0 100644 --- a/src/tools/clippy/tests/ui/entry_with_else.stderr +++ b/src/tools/clippy/tests/ui/entry_with_else.stderr @@ -1,5 +1,5 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:14:5 + --> tests/ui/entry_with_else.rs:14:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -23,7 +23,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:20:5 + --> tests/ui/entry_with_else.rs:20:5 | LL | / if m.contains_key(&k) { LL | | m.insert(k, v); @@ -45,7 +45,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:26:5 + --> tests/ui/entry_with_else.rs:26:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -64,7 +64,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:32:5 + --> tests/ui/entry_with_else.rs:32:5 | LL | / if !m.contains_key(&k) { LL | | foo(); @@ -83,7 +83,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:38:5 + --> tests/ui/entry_with_else.rs:38:5 | LL | / if !m.contains_key(&k) { LL | | m.insert(k, v); @@ -105,7 +105,7 @@ LL + } | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:44:5 + --> tests/ui/entry_with_else.rs:44:5 | LL | / if m.contains_key(&k) { LL | | if true { m.insert(k, v) } else { m.insert(k, v2) } @@ -128,7 +128,7 @@ LL ~ }; | error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry_with_else.rs:50:5 + --> tests/ui/entry_with_else.rs:50:5 | LL | / if m.contains_key(&k) { LL | | foo(); diff --git a/src/tools/clippy/tests/ui/enum_clike_unportable_variant.stderr b/src/tools/clippy/tests/ui/enum_clike_unportable_variant.stderr index 93ad4daa97f77..741de179a497a 100644 --- a/src/tools/clippy/tests/ui/enum_clike_unportable_variant.stderr +++ b/src/tools/clippy/tests/ui/enum_clike_unportable_variant.stderr @@ -1,5 +1,5 @@ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:8:5 + --> tests/ui/enum_clike_unportable_variant.rs:8:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ @@ -8,49 +8,49 @@ LL | X = 0x1_0000_0000, = help: to override `-D warnings` add `#[allow(clippy::enum_clike_unportable_variant)]` error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:17:5 + --> tests/ui/enum_clike_unportable_variant.rs:17:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:21:5 + --> tests/ui/enum_clike_unportable_variant.rs:21:5 | LL | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:29:5 + --> tests/ui/enum_clike_unportable_variant.rs:29:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:31:5 + --> tests/ui/enum_clike_unportable_variant.rs:31:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:34:5 + --> tests/ui/enum_clike_unportable_variant.rs:34:5 | LL | C = (i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:41:5 + --> tests/ui/enum_clike_unportable_variant.rs:41:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:43:5 + --> tests/ui/enum_clike_unportable_variant.rs:43:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> $DIR/enum_clike_unportable_variant.rs:49:5 + --> tests/ui/enum_clike_unportable_variant.rs:49:5 | LL | X = ::Number, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/enum_glob_use.stderr b/src/tools/clippy/tests/ui/enum_glob_use.stderr index 8b94e67f87ea3..6825383b769d7 100644 --- a/src/tools/clippy/tests/ui/enum_glob_use.stderr +++ b/src/tools/clippy/tests/ui/enum_glob_use.stderr @@ -1,5 +1,5 @@ error: usage of wildcard import for enum variants - --> $DIR/enum_glob_use.rs:5:5 + --> tests/ui/enum_glob_use.rs:5:5 | LL | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::cmp::Ordering::Less` @@ -8,13 +8,13 @@ LL | use std::cmp::Ordering::*; = 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 + --> tests/ui/enum_glob_use.rs:11:5 | LL | use self::Enum::*; | ^^^^^^^^^^^^^ help: try: `self::Enum::Foo` error: usage of wildcard import for enum variants - --> $DIR/enum_glob_use.rs:15:13 + --> tests/ui/enum_glob_use.rs:15:13 | LL | use crate::Enum::*; | ^^^^^^^^^^^^^^ help: try: `crate::Enum::Foo` diff --git a/src/tools/clippy/tests/ui/enum_variants.stderr b/src/tools/clippy/tests/ui/enum_variants.stderr index b1e88de0fcf1c..aaac3cbb82dc1 100644 --- a/src/tools/clippy/tests/ui/enum_variants.stderr +++ b/src/tools/clippy/tests/ui/enum_variants.stderr @@ -1,5 +1,5 @@ error: variant name ends with the enum's name - --> $DIR/enum_variants.rs:16:5 + --> tests/ui/enum_variants.rs:16:5 | LL | cFoo, | ^^^^ @@ -8,7 +8,7 @@ LL | cFoo, = 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 + --> tests/ui/enum_variants.rs:14:1 | LL | / enum Foo { LL | | @@ -22,25 +22,25 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:30:5 + --> tests/ui/enum_variants.rs:30:5 | LL | FoodGood, | ^^^^^^^^ error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:32:5 + --> tests/ui/enum_variants.rs:32:5 | LL | FoodMiddle, | ^^^^^^^^^^ error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:34:5 + --> tests/ui/enum_variants.rs:34:5 | LL | FoodBad, | ^^^^^^^ error: all variants have the same prefix: `Food` - --> $DIR/enum_variants.rs:28:1 + --> tests/ui/enum_variants.rs:28:1 | LL | / enum Food { LL | | @@ -54,7 +54,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `CallType` - --> $DIR/enum_variants.rs:42:1 + --> tests/ui/enum_variants.rs:42:1 | LL | / enum BadCallType { LL | | @@ -67,7 +67,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `Constant` - --> $DIR/enum_variants.rs:55:1 + --> tests/ui/enum_variants.rs:55:1 | LL | / enum Consts { LL | | @@ -80,7 +80,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `C` - --> $DIR/enum_variants.rs:68:1 + --> tests/ui/enum_variants.rs:68:1 | LL | / enum Something { LL | | @@ -93,7 +93,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `WithOut` - --> $DIR/enum_variants.rs:91:1 + --> tests/ui/enum_variants.rs:91:1 | LL | / enum Seallll { LL | | @@ -106,7 +106,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `IData` - --> $DIR/enum_variants.rs:147:1 + --> tests/ui/enum_variants.rs:147:1 | LL | / enum IDataRequest { LL | | @@ -119,7 +119,7 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `HIData` - --> $DIR/enum_variants.rs:154:1 + --> tests/ui/enum_variants.rs:154:1 | LL | / enum HIDataRequest { LL | | @@ -132,7 +132,7 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `_Type` - --> $DIR/enum_variants.rs:175:5 + --> tests/ui/enum_variants.rs:175:5 | LL | / enum DoLint { LL | | @@ -146,7 +146,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `Type` - --> $DIR/enum_variants.rs:183:5 + --> tests/ui/enum_variants.rs:183:5 | LL | / enum DoLintToo { LL | | @@ -159,13 +159,13 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:212:9 + --> tests/ui/enum_variants.rs:212:9 | LL | DataDependent, | ^^^^^^^^^^^^^ error: variant name starts with the enum's name - --> $DIR/enum_variants.rs:217:9 + --> tests/ui/enum_variants.rs:217:9 | LL | DatasDependent, | ^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/eprint_with_newline.stderr b/src/tools/clippy/tests/ui/eprint_with_newline.stderr index 674b4fdaed50e..de450090a66e5 100644 --- a/src/tools/clippy/tests/ui/eprint_with_newline.stderr +++ b/src/tools/clippy/tests/ui/eprint_with_newline.stderr @@ -1,5 +1,5 @@ error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:5:5 + --> tests/ui/eprint_with_newline.rs:5:5 | LL | eprint!("Hello\n"); | ^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + eprintln!("Hello"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:8:5 + --> tests/ui/eprint_with_newline.rs:8:5 | LL | eprint!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + eprintln!("Hello {}", "world"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:10:5 + --> tests/ui/eprint_with_newline.rs:10:5 | LL | eprint!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + eprintln!("Hello {} {}", "world", "#2"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:12:5 + --> tests/ui/eprint_with_newline.rs:12:5 | LL | eprint!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + eprintln!("{}", 1265); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:14:5 + --> tests/ui/eprint_with_newline.rs:14:5 | LL | eprint!("\n"); | ^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + eprintln!(); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:37:5 + --> tests/ui/eprint_with_newline.rs:37:5 | LL | eprint!("\\\n"); | ^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + eprintln!("\\"); | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:46:5 + --> tests/ui/eprint_with_newline.rs:46:5 | LL | / eprint!( LL | | @@ -90,7 +90,7 @@ LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:51:5 + --> tests/ui/eprint_with_newline.rs:51:5 | LL | / eprint!( LL | | @@ -107,7 +107,7 @@ LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> $DIR/eprint_with_newline.rs:60:5 + --> tests/ui/eprint_with_newline.rs:60:5 | LL | eprint!("\\r\n"); | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/eq_op.stderr b/src/tools/clippy/tests/ui/eq_op.stderr index 2427ac0dda55f..bd3c115d8b8bc 100644 --- a/src/tools/clippy/tests/ui/eq_op.stderr +++ b/src/tools/clippy/tests/ui/eq_op.stderr @@ -1,5 +1,5 @@ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:7:13 + --> tests/ui/eq_op.rs:7:13 | LL | let _ = 1 == 1; | ^^^^^^ @@ -8,31 +8,31 @@ LL | let _ = 1 == 1; = help: to override `-D warnings` add `#[allow(clippy::eq_op)]` error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:10:13 + --> tests/ui/eq_op.rs:10:13 | LL | let _ = "no" == "no"; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:13:13 + --> tests/ui/eq_op.rs:13:13 | LL | let _ = false != false; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> $DIR/eq_op.rs:15:13 + --> tests/ui/eq_op.rs:15:13 | LL | let _ = 1.5 < 1.5; | ^^^^^^^^^ error: equal expressions as operands to `>=` - --> $DIR/eq_op.rs:17:13 + --> tests/ui/eq_op.rs:17:13 | LL | let _ = 1u64 >= 1u64; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:20:13 + --> tests/ui/eq_op.rs:20:13 | LL | let _ = x != x; | ^^^^^^ @@ -40,139 +40,139 @@ LL | let _ = x != x; = note: if you intended to check if the operand is NaN, use `.is_nan()` instead error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:25:13 + --> tests/ui/eq_op.rs:25:13 | LL | let _ = (1u32 as u64) & (1u32 as u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `^` - --> $DIR/eq_op.rs:29:17 + --> tests/ui/eq_op.rs:29:17 | LL | let _ = 1 ^ ((((((1)))))); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> $DIR/eq_op.rs:34:13 + --> tests/ui/eq_op.rs:34:13 | LL | let _ = (-(2) < -(2)); | ^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:36:13 + --> tests/ui/eq_op.rs:36:13 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:36:14 + --> tests/ui/eq_op.rs:36:14 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> $DIR/eq_op.rs:36:35 + --> tests/ui/eq_op.rs:36:35 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:40:13 + --> tests/ui/eq_op.rs:40:13 | LL | let _ = (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:44:13 + --> tests/ui/eq_op.rs:44:13 | LL | let _ = ([1] != [1]); | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> $DIR/eq_op.rs:46:13 + --> tests/ui/eq_op.rs:46:13 | LL | let _ = ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:51:13 + --> tests/ui/eq_op.rs:51:13 | LL | let _ = 1 + 1 == 2; | ^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:53:13 + --> tests/ui/eq_op.rs:53:13 | LL | let _ = 1 - 1 == 0; | ^^^^^^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:53:13 + --> tests/ui/eq_op.rs:53:13 | LL | let _ = 1 - 1 == 0; | ^^^^^ error: equal expressions as operands to `-` - --> $DIR/eq_op.rs:57:13 + --> tests/ui/eq_op.rs:57:13 | LL | let _ = 1 - 1; | ^^^^^ error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:59:13 + --> tests/ui/eq_op.rs:59:13 | LL | let _ = 1 / 1; | ^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:61:13 + --> tests/ui/eq_op.rs:61:13 | LL | let _ = true && true; | ^^^^^^^^^^^^ error: equal expressions as operands to `||` - --> $DIR/eq_op.rs:64:13 + --> tests/ui/eq_op.rs:64:13 | LL | let _ = true || true; | ^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:70:13 + --> tests/ui/eq_op.rs:70:13 | LL | let _ = a == b && b == a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:72:13 + --> tests/ui/eq_op.rs:72:13 | LL | let _ = a != b && b != a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:74:13 + --> tests/ui/eq_op.rs:74:13 | LL | let _ = a < b && b > a; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> $DIR/eq_op.rs:76:13 + --> tests/ui/eq_op.rs:76:13 | LL | let _ = a <= b && b >= a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:80:13 + --> tests/ui/eq_op.rs:80:13 | LL | let _ = a == a; | ^^^^^^ error: equal expressions as operands to `/` - --> $DIR/eq_op.rs:91:20 + --> tests/ui/eq_op.rs:91:20 | LL | const D: u32 = A / A; | ^^^^^ error: equal expressions as operands to `==` - --> $DIR/eq_op.rs:123:5 + --> tests/ui/eq_op.rs:123:5 | LL | (n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/eq_op_macros.stderr b/src/tools/clippy/tests/ui/eq_op_macros.stderr index 0df26607aa6e8..b114db0ca98e1 100644 --- a/src/tools/clippy/tests/ui/eq_op_macros.stderr +++ b/src/tools/clippy/tests/ui/eq_op_macros.stderr @@ -1,5 +1,5 @@ error: identical args used in this `assert_eq!` macro call - --> $DIR/eq_op_macros.rs:8:20 + --> tests/ui/eq_op_macros.rs:8:20 | LL | assert_eq!(a, a); | ^^^^ @@ -12,7 +12,7 @@ LL | assert_in_macro_def!(); = 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 - --> $DIR/eq_op_macros.rs:9:20 + --> tests/ui/eq_op_macros.rs:9:20 | LL | assert_ne!(a, a); | ^^^^ @@ -23,7 +23,7 @@ LL | assert_in_macro_def!(); = 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 `debug_assert_eq!` macro call - --> $DIR/eq_op_macros.rs:10:26 + --> tests/ui/eq_op_macros.rs:10:26 | LL | debug_assert_eq!(a, a); | ^^^^ @@ -34,7 +34,7 @@ LL | assert_in_macro_def!(); = 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 `debug_assert_ne!` macro call - --> $DIR/eq_op_macros.rs:11:26 + --> tests/ui/eq_op_macros.rs:11:26 | LL | debug_assert_ne!(a, a); | ^^^^ @@ -45,49 +45,49 @@ LL | assert_in_macro_def!(); = 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_eq!` macro call - --> $DIR/eq_op_macros.rs:23:16 + --> tests/ui/eq_op_macros.rs:23:16 | LL | assert_eq!(a, a); | ^^^^ error: identical args used in this `assert_eq!` macro call - --> $DIR/eq_op_macros.rs:25:16 + --> tests/ui/eq_op_macros.rs:25:16 | LL | assert_eq!(a + 1, a + 1); | ^^^^^^^^^^^^ error: identical args used in this `assert_ne!` macro call - --> $DIR/eq_op_macros.rs:33:16 + --> tests/ui/eq_op_macros.rs:33:16 | LL | assert_ne!(a, a); | ^^^^ error: identical args used in this `assert_ne!` macro call - --> $DIR/eq_op_macros.rs:35:16 + --> tests/ui/eq_op_macros.rs:35:16 | LL | assert_ne!(a + 1, a + 1); | ^^^^^^^^^^^^ error: identical args used in this `debug_assert_eq!` macro call - --> $DIR/eq_op_macros.rs:43:22 + --> tests/ui/eq_op_macros.rs:43:22 | LL | debug_assert_eq!(a, a); | ^^^^ error: identical args used in this `debug_assert_eq!` macro call - --> $DIR/eq_op_macros.rs:45:22 + --> tests/ui/eq_op_macros.rs:45:22 | LL | debug_assert_eq!(a + 1, a + 1); | ^^^^^^^^^^^^ error: identical args used in this `debug_assert_ne!` macro call - --> $DIR/eq_op_macros.rs:53:22 + --> tests/ui/eq_op_macros.rs:53:22 | LL | debug_assert_ne!(a, a); | ^^^^ error: identical args used in this `debug_assert_ne!` macro call - --> $DIR/eq_op_macros.rs:55:22 + --> tests/ui/eq_op_macros.rs:55:22 | LL | debug_assert_ne!(a + 1, a + 1); | ^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/equatable_if_let.stderr b/src/tools/clippy/tests/ui/equatable_if_let.stderr index 6cc19d829edc7..9e93a33cd7e21 100644 --- a/src/tools/clippy/tests/ui/equatable_if_let.stderr +++ b/src/tools/clippy/tests/ui/equatable_if_let.stderr @@ -1,5 +1,5 @@ error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:64:8 + --> tests/ui/equatable_if_let.rs:64:8 | LL | if let 2 = a {} | ^^^^^^^^^ help: try: `a == 2` @@ -8,79 +8,79 @@ LL | if let 2 = a {} = 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 + --> tests/ui/equatable_if_let.rs:65:8 | LL | if let Ordering::Greater = a.cmp(&b) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.cmp(&b) == Ordering::Greater` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:66:8 + --> tests/ui/equatable_if_let.rs:66:8 | LL | if let Some(2) = c {} | ^^^^^^^^^^^^^^^ help: try: `c == Some(2)` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:67:8 + --> tests/ui/equatable_if_let.rs:67:8 | LL | if let Struct { a: 2, b: false } = d {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `d == (Struct { a: 2, b: false })` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:68:8 + --> tests/ui/equatable_if_let.rs:68:8 | LL | if let Enum::TupleVariant(32, 64) = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::TupleVariant(32, 64)` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:69:8 + --> tests/ui/equatable_if_let.rs:69:8 | LL | if let Enum::RecordVariant { a: 64, b: 32 } = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == (Enum::RecordVariant { a: 64, b: 32 })` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:70:8 + --> tests/ui/equatable_if_let.rs:70:8 | LL | if let Enum::UnitVariant = e {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `e == Enum::UnitVariant` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:71:8 + --> tests/ui/equatable_if_let.rs:71:8 | LL | if let (Enum::UnitVariant, &Struct { a: 2, b: false }) = (e, &d) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(e, &d) == (Enum::UnitVariant, &Struct { a: 2, b: false })` error: this pattern matching can be expressed using `matches!` - --> $DIR/equatable_if_let.rs:80:8 + --> tests/ui/equatable_if_let.rs:80:8 | LL | if let NotPartialEq::A = f {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(f, NotPartialEq::A)` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:81:8 + --> tests/ui/equatable_if_let.rs:81:8 | LL | if let NotStructuralEq::A = g {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `g == NotStructuralEq::A` error: this pattern matching can be expressed using `matches!` - --> $DIR/equatable_if_let.rs:82:8 + --> tests/ui/equatable_if_let.rs:82:8 | LL | if let Some(NotPartialEq::A) = Some(f) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(Some(f), Some(NotPartialEq::A))` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:83:8 + --> tests/ui/equatable_if_let.rs:83:8 | LL | if let Some(NotStructuralEq::A) = Some(g) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(g) == Some(NotStructuralEq::A)` error: this pattern matching can be expressed using `matches!` - --> $DIR/equatable_if_let.rs:84:8 + --> tests/ui/equatable_if_let.rs:84:8 | LL | if let NoPartialEqStruct { a: 2, b: false } = h {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(h, NoPartialEqStruct { a: 2, b: false })` error: this pattern matching can be expressed using equality - --> $DIR/equatable_if_let.rs:86:8 + --> tests/ui/equatable_if_let.rs:86:8 | LL | if let inline!("abc") = "abc" { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"abc" == inline!("abc")` diff --git a/src/tools/clippy/tests/ui/erasing_op.stderr b/src/tools/clippy/tests/ui/erasing_op.stderr index 1b50a05cd228d..6ed8bffeb24d5 100644 --- a/src/tools/clippy/tests/ui/erasing_op.stderr +++ b/src/tools/clippy/tests/ui/erasing_op.stderr @@ -1,5 +1,5 @@ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:35:5 + --> tests/ui/erasing_op.rs:35:5 | LL | x * 0; | ^^^^^ @@ -8,25 +8,25 @@ LL | x * 0; = 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 + --> tests/ui/erasing_op.rs:38:5 | LL | 0 & x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:40:5 + --> tests/ui/erasing_op.rs:40:5 | LL | 0 / x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:43:5 + --> tests/ui/erasing_op.rs:43:5 | LL | 0 * Vec1 { x: 5 }; | ^^^^^^^^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:45:5 + --> tests/ui/erasing_op.rs:45:5 | LL | Vec1 { x: 5 } * 0; | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/err_expect.stderr b/src/tools/clippy/tests/ui/err_expect.stderr index da7cd47f0bb49..68f39cc45c5b1 100644 --- a/src/tools/clippy/tests/ui/err_expect.stderr +++ b/src/tools/clippy/tests/ui/err_expect.stderr @@ -1,5 +1,5 @@ error: called `.err().expect()` on a `Result` value - --> $DIR/err_expect.rs:10:16 + --> tests/ui/err_expect.rs:10:16 | LL | test_debug.err().expect("Testing debug type"); | ^^^^^^^^^^^^ help: try: `expect_err` @@ -8,7 +8,7 @@ LL | test_debug.err().expect("Testing debug type"); = help: to override `-D warnings` add `#[allow(clippy::err_expect)]` error: called `.err().expect()` on a `Result` value - --> $DIR/err_expect.rs:25:7 + --> tests/ui/err_expect.rs:25:7 | LL | x.err().expect("17"); | ^^^^^^^^^^^^ help: try: `expect_err` diff --git a/src/tools/clippy/tests/ui/error_impl_error.stderr b/src/tools/clippy/tests/ui/error_impl_error.stderr index d7a1aa829890c..087d43d1d083b 100644 --- a/src/tools/clippy/tests/ui/error_impl_error.stderr +++ b/src/tools/clippy/tests/ui/error_impl_error.stderr @@ -1,11 +1,11 @@ error: exported type named `Error` that implements `Error` - --> $DIR/error_impl_error.rs:7:16 + --> tests/ui/error_impl_error.rs:7:16 | LL | pub struct Error; | ^^^^^ | note: `Error` was implemented here - --> $DIR/error_impl_error.rs:16:5 + --> tests/ui/error_impl_error.rs:16:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,31 +13,31 @@ LL | impl std::error::Error for Error {} = 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 + --> tests/ui/error_impl_error.rs:21:21 | LL | pub(super) enum Error {} | ^^^^^ | note: `Error` was implemented here - --> $DIR/error_impl_error.rs:30:5 + --> tests/ui/error_impl_error.rs:30:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: exported type named `Error` that implements `Error` - --> $DIR/error_impl_error.rs:34:15 + --> tests/ui/error_impl_error.rs:34:15 | LL | pub union Error { | ^^^^^ | note: `Error` was implemented here - --> $DIR/error_impl_error.rs:52:5 + --> tests/ui/error_impl_error.rs:52:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: exported type alias named `Error` that implements `Error` - --> $DIR/error_impl_error.rs:56:14 + --> tests/ui/error_impl_error.rs:56:14 | LL | pub type Error = std::fmt::Error; | ^^^^^ diff --git a/src/tools/clippy/tests/ui/eta.stderr b/src/tools/clippy/tests/ui/eta.stderr index 945de466d8322..d9a8768a68217 100644 --- a/src/tools/clippy/tests/ui/eta.stderr +++ b/src/tools/clippy/tests/ui/eta.stderr @@ -1,5 +1,5 @@ error: redundant closure - --> $DIR/eta.rs:29:27 + --> tests/ui/eta.rs:29:27 | LL | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: replace the closure with the function itself: `foo` @@ -8,31 +8,31 @@ LL | let a = Some(1u8).map(|a| foo(a)); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` error: redundant closure - --> $DIR/eta.rs:33:40 + --> tests/ui/eta.rs:33:40 | LL | let _: Option> = true.then(|| vec![]); // special case vec! | ^^^^^^^^^ help: replace the closure with `Vec::new`: `std::vec::Vec::new` error: redundant closure - --> $DIR/eta.rs:34:35 + --> tests/ui/eta.rs:34:35 | LL | let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted? | ^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo2` error: redundant closure - --> $DIR/eta.rs:35:26 + --> tests/ui/eta.rs:35:26 | LL | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `below` error: redundant closure - --> $DIR/eta.rs:42:27 + --> tests/ui/eta.rs:42:27 | LL | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic` error: redundant closure - --> $DIR/eta.rs:94:51 + --> tests/ui/eta.rs:94:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo` @@ -41,151 +41,151 @@ LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_for_method_calls)]` error: redundant closure - --> $DIR/eta.rs:95:51 + --> tests/ui/eta.rs:95:51 | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo` error: redundant closure - --> $DIR/eta.rs:97:42 + --> tests/ui/eta.rs:97:42 | LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear()); | ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear` error: redundant closure - --> $DIR/eta.rs:101:29 + --> tests/ui/eta.rs:101:29 | LL | let e = Some("str").map(|s| s.to_string()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string` error: redundant closure - --> $DIR/eta.rs:102:27 + --> tests/ui/eta.rs:102:27 | LL | let e = Some('a').map(|s| s.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase` error: redundant closure - --> $DIR/eta.rs:104:65 + --> tests/ui/eta.rs:104:65 | LL | let e: std::vec::Vec = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase` error: redundant closure - --> $DIR/eta.rs:167:22 + --> tests/ui/eta.rs:167:22 | LL | requires_fn_once(|| x()); | ^^^^^^ help: replace the closure with the function itself: `x` error: redundant closure - --> $DIR/eta.rs:174:27 + --> tests/ui/eta.rs:174:27 | LL | let a = Some(1u8).map(|a| foo_ptr(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr` error: redundant closure - --> $DIR/eta.rs:179:27 + --> tests/ui/eta.rs:179:27 | LL | let a = Some(1u8).map(|a| closure(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure` error: redundant closure - --> $DIR/eta.rs:211:28 + --> tests/ui/eta.rs:211:28 | LL | x.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure - --> $DIR/eta.rs:212:28 + --> tests/ui/eta.rs:212:28 | LL | y.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure - --> $DIR/eta.rs:213:28 + --> tests/ui/eta.rs:213:28 | LL | z.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res` error: redundant closure - --> $DIR/eta.rs:220:21 + --> tests/ui/eta.rs:220:21 | LL | Some(1).map(|n| closure(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure` error: redundant closure - --> $DIR/eta.rs:224:21 + --> tests/ui/eta.rs:224:21 | LL | Some(1).map(|n| in_loop(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `in_loop` error: redundant closure - --> $DIR/eta.rs:317:18 + --> tests/ui/eta.rs:317:18 | LL | takes_fn_mut(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure - --> $DIR/eta.rs:320:19 + --> tests/ui/eta.rs:320:19 | LL | takes_fn_once(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure - --> $DIR/eta.rs:324:26 + --> tests/ui/eta.rs:324:26 | LL | move || takes_fn_mut(|| f_used_once()) | ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once` error: redundant closure - --> $DIR/eta.rs:336:19 + --> tests/ui/eta.rs:336:19 | LL | array_opt.map(|a| a.as_slice()); | ^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8; 3]>::as_slice` error: redundant closure - --> $DIR/eta.rs:339:19 + --> tests/ui/eta.rs:339:19 | LL | slice_opt.map(|s| s.len()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8]>::len` error: redundant closure - --> $DIR/eta.rs:342:17 + --> tests/ui/eta.rs:342:17 | LL | ptr_opt.map(|p| p.is_null()); | ^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<*const usize>::is_null` error: redundant closure - --> $DIR/eta.rs:346:17 + --> tests/ui/eta.rs:346:17 | LL | dyn_opt.map(|d| d.method_on_dyn()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `::method_on_dyn` error: redundant closure - --> $DIR/eta.rs:406:19 + --> tests/ui/eta.rs:406:19 | LL | let _ = f(&0, |x, y| f2(x, y)); | ^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `f2` error: redundant closure - --> $DIR/eta.rs:434:22 + --> tests/ui/eta.rs:434:22 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `Test::method` error: redundant closure - --> $DIR/eta.rs:438:22 + --> tests/ui/eta.rs:438:22 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `super::Outer::method` error: redundant closure - --> $DIR/eta.rs:451:18 + --> tests/ui/eta.rs:451:18 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `test_mod::Test::method` error: redundant closure - --> $DIR/eta.rs:458:30 + --> tests/ui/eta.rs:458:30 | LL | test.map(|t| t.method()) | ^^^^^^^^^^^^^^ help: replace the closure with the method itself: `crate::issue_10854::d::Test::method` diff --git a/src/tools/clippy/tests/ui/excessive_precision.stderr b/src/tools/clippy/tests/ui/excessive_precision.stderr index 5e7672e185af3..22dd96e53bdbe 100644 --- a/src/tools/clippy/tests/ui/excessive_precision.stderr +++ b/src/tools/clippy/tests/ui/excessive_precision.stderr @@ -1,5 +1,5 @@ error: float has excessive precision - --> $DIR/excessive_precision.rs:20:26 + --> tests/ui/excessive_precision.rs:20:26 | LL | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79_f32` @@ -8,85 +8,85 @@ LL | const BAD32_1: f32 = 0.123_456_789_f32; = help: to override `-D warnings` add `#[allow(clippy::excessive_precision)]` error: float has excessive precision - --> $DIR/excessive_precision.rs:21:26 + --> tests/ui/excessive_precision.rs:21:26 | LL | const BAD32_2: f32 = 0.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:22:26 + --> tests/ui/excessive_precision.rs:22:26 | LL | const BAD32_3: f32 = 0.100_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:23:29 + --> tests/ui/excessive_precision.rs:23:29 | LL | const BAD32_EDGE: f32 = 1.000_000_9; | ^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.000_001` error: float has excessive precision - --> $DIR/excessive_precision.rs:27:26 + --> tests/ui/excessive_precision.rs:27:26 | LL | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:30:22 + --> tests/ui/excessive_precision.rs:30:22 | LL | println!("{:?}", 8.888_888_888_888_888_888_888); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `8.888_888_888_888_89` error: float has excessive precision - --> $DIR/excessive_precision.rs:41:22 + --> tests/ui/excessive_precision.rs:41:22 | LL | let bad32: f32 = 1.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:42:26 + --> tests/ui/excessive_precision.rs:42:26 | LL | let bad32_suf: f32 = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` error: float has excessive precision - --> $DIR/excessive_precision.rs:43:21 + --> tests/ui/excessive_precision.rs:43:21 | LL | let bad32_inf = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8_f32` error: float has excessive precision - --> $DIR/excessive_precision.rs:53:36 + --> tests/ui/excessive_precision.rs:53:36 | LL | let bad_vec32: Vec = vec![0.123_456_789]; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:54:36 + --> tests/ui/excessive_precision.rs:54:36 | LL | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_123_456_78` error: float has excessive precision - --> $DIR/excessive_precision.rs:58:24 + --> tests/ui/excessive_precision.rs:58:24 | LL | let bad_e32: f32 = 1.123_456_788_888e-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8e-10` error: float has excessive precision - --> $DIR/excessive_precision.rs:61:27 + --> tests/ui/excessive_precision.rs:61:27 | LL | let bad_bige32: f32 = 1.123_456_788_888E-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8E-10` error: float has excessive precision - --> $DIR/excessive_precision.rs:70:13 + --> tests/ui/excessive_precision.rs:70:13 | LL | let _ = 2.225_073_858_507_201_1e-308_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `2.225_073_858_507_201e-308_f64` error: float has excessive precision - --> $DIR/excessive_precision.rs:73:13 + --> tests/ui/excessive_precision.rs:73:13 | LL | let _ = 1.000_000_000_000_001e-324_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0_f64` diff --git a/src/tools/clippy/tests/ui/exhaustive_items.stderr b/src/tools/clippy/tests/ui/exhaustive_items.stderr index ae43e81c0d31f..536fbe8d790f6 100644 --- a/src/tools/clippy/tests/ui/exhaustive_items.stderr +++ b/src/tools/clippy/tests/ui/exhaustive_items.stderr @@ -1,5 +1,5 @@ error: exported enums should not be exhaustive - --> $DIR/exhaustive_items.rs:9:5 + --> tests/ui/exhaustive_items.rs:9:5 | LL | / pub enum Exhaustive { LL | | Foo, @@ -10,7 +10,7 @@ LL | | } | |_____^ | note: the lint level is defined here - --> $DIR/exhaustive_items.rs:1:9 + --> tests/ui/exhaustive_items.rs:1:9 | LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL ~ pub enum Exhaustive { | error: exported enums should not be exhaustive - --> $DIR/exhaustive_items.rs:18:5 + --> tests/ui/exhaustive_items.rs:18:5 | LL | / pub enum ExhaustiveWithAttrs { LL | | Foo, @@ -38,7 +38,7 @@ LL ~ pub enum ExhaustiveWithAttrs { | error: exported structs should not be exhaustive - --> $DIR/exhaustive_items.rs:53:5 + --> tests/ui/exhaustive_items.rs:53:5 | LL | / pub struct Exhaustive { LL | | pub foo: u8, @@ -47,7 +47,7 @@ LL | | } | |_____^ | note: the lint level is defined here - --> $DIR/exhaustive_items.rs:1:35 + --> tests/ui/exhaustive_items.rs:1:35 | LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/exit1.stderr b/src/tools/clippy/tests/ui/exit1.stderr index bbe0762c8d128..2158314b7c7b1 100644 --- a/src/tools/clippy/tests/ui/exit1.stderr +++ b/src/tools/clippy/tests/ui/exit1.stderr @@ -1,5 +1,5 @@ error: usage of `process::exit` - --> $DIR/exit1.rs:5:9 + --> tests/ui/exit1.rs:5:9 | LL | std::process::exit(4); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/exit2.stderr b/src/tools/clippy/tests/ui/exit2.stderr index 19abbc6062a6e..ac782506c1923 100644 --- a/src/tools/clippy/tests/ui/exit2.stderr +++ b/src/tools/clippy/tests/ui/exit2.stderr @@ -1,5 +1,5 @@ error: usage of `process::exit` - --> $DIR/exit2.rs:4:5 + --> tests/ui/exit2.rs:4:5 | LL | std::process::exit(3); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/expect.stderr b/src/tools/clippy/tests/ui/expect.stderr index 35a258a85e4e9..c0ba3390aac59 100644 --- a/src/tools/clippy/tests/ui/expect.stderr +++ b/src/tools/clippy/tests/ui/expect.stderr @@ -1,5 +1,5 @@ error: used `expect()` on an `Option` value - --> $DIR/expect.rs:6:13 + --> tests/ui/expect.rs:6:13 | LL | let _ = opt.expect(""); | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = opt.expect(""); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `expect()` on a `Result` value - --> $DIR/expect.rs:12:13 + --> tests/ui/expect.rs:12:13 | LL | let _ = res.expect(""); | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = res.expect(""); = note: if this value is an `Err`, it will panic error: used `expect_err()` on a `Result` value - --> $DIR/expect.rs:14:13 + --> tests/ui/expect.rs:14:13 | LL | let _ = res.expect_err(""); | ^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/expect_fun_call.stderr b/src/tools/clippy/tests/ui/expect_fun_call.stderr index dd3976f3624c6..b41904d04fa4c 100644 --- a/src/tools/clippy/tests/ui/expect_fun_call.stderr +++ b/src/tools/clippy/tests/ui/expect_fun_call.stderr @@ -1,5 +1,5 @@ error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:37:26 + --> tests/ui/expect_fun_call.rs:37:26 | LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` @@ -8,85 +8,85 @@ LL | with_none_and_format.expect(&format!("Error {}: fake error", error_code = 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 + --> tests/ui/expect_fun_call.rs:40:26 | LL | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:43:37 + --> tests/ui/expect_fun_call.rs:43:37 | LL | with_none_and_format_with_macro.expect(format!("Error {}: fake error", one!()).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("Error {}: fake error", one!()))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:53:25 + --> tests/ui/expect_fun_call.rs:53:25 | LL | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:56:25 + --> tests/ui/expect_fun_call.rs:56:25 | LL | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:68:17 + --> tests/ui/expect_fun_call.rs:68:17 | LL | Some("foo").expect(format!("{} {}", 1, 2).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{} {}", 1, 2))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:89:21 + --> tests/ui/expect_fun_call.rs:89:21 | LL | Some("foo").expect(&get_string()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:90:21 + --> tests/ui/expect_fun_call.rs:90:21 | LL | Some("foo").expect(get_string().as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:91:21 + --> tests/ui/expect_fun_call.rs:91:21 | LL | Some("foo").expect(get_string().as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:93:21 + --> tests/ui/expect_fun_call.rs:93:21 | LL | Some("foo").expect(get_static_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_static_str()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:94:21 + --> tests/ui/expect_fun_call.rs:94:21 | LL | Some("foo").expect(get_non_static_str(&0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:98:16 + --> tests/ui/expect_fun_call.rs:98:16 | LL | Some(true).expect(&format!("key {}, {}", 1, 2)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("key {}, {}", 1, 2))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:104:17 + --> tests/ui/expect_fun_call.rs:104:17 | LL | opt_ref.expect(&format!("{:?}", opt_ref)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{:?}", opt_ref))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:108:20 + --> tests/ui/expect_fun_call.rs:108:20 | LL | format_capture.expect(&format!("{error_code}")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{error_code}"))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:111:30 + --> tests/ui/expect_fun_call.rs:111:30 | LL | format_capture_and_value.expect(&format!("{error_code}, {}", 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| panic!("{error_code}, {}", 1))` 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 2a418d8456635..43e0b9279e4b1 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 @@ -1,5 +1,5 @@ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:31:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:31:14 | LL | #[expect(dead_code)] | ^^^^^^^^^ @@ -8,31 +8,31 @@ LL | #[expect(dead_code)] = help: to override `-D warnings` add `#[allow(unfulfilled_lint_expectations)]` error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:37:18 + --> tests/ui/expect_tool_lint_rfc_2383.rs:37:18 | LL | #[expect(invalid_nan_comparisons)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:108:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:108:14 | LL | #[expect(clippy::almost_swapped)] | ^^^^^^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:116:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:116:14 | LL | #[expect(clippy::bytes_nth)] | ^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:122:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:122:14 | LL | #[expect(clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this lint expectation is unfulfilled - --> $DIR/expect_tool_lint_rfc_2383.rs:128:14 + --> tests/ui/expect_tool_lint_rfc_2383.rs:128:14 | LL | #[expect(clippy::overly_complex_bool_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/explicit_auto_deref.stderr b/src/tools/clippy/tests/ui/explicit_auto_deref.stderr index cc9eeeb504290..56a183de3487f 100644 --- a/src/tools/clippy/tests/ui/explicit_auto_deref.stderr +++ b/src/tools/clippy/tests/ui/explicit_auto_deref.stderr @@ -1,5 +1,5 @@ error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:68:19 + --> tests/ui/explicit_auto_deref.rs:68:19 | LL | let _: &str = &*s; | ^^^ help: try: `&s` @@ -8,265 +8,265 @@ LL | let _: &str = &*s; = 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 + --> tests/ui/explicit_auto_deref.rs:69:19 | LL | let _: &str = &*{ String::new() }; | ^^^^^^^^^^^^^^^^^^^ help: try: `&{ String::new() }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:70:19 + --> tests/ui/explicit_auto_deref.rs:70:19 | LL | let _: &str = &mut *{ String::new() }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut { String::new() }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:74:11 + --> tests/ui/explicit_auto_deref.rs:74:11 | LL | f_str(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:78:13 + --> tests/ui/explicit_auto_deref.rs:78:13 | LL | f_str_t(&*s, &*s); // Don't lint second param. | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:81:24 + --> tests/ui/explicit_auto_deref.rs:81:24 | LL | let _: &Box = &**b; | ^^^^ help: try: `&b` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:87:7 + --> tests/ui/explicit_auto_deref.rs:87:7 | LL | c(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:93:9 + --> tests/ui/explicit_auto_deref.rs:93:9 | LL | &**x | ^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:97:11 + --> tests/ui/explicit_auto_deref.rs:97:11 | LL | { &**x } | ^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:101:9 + --> tests/ui/explicit_auto_deref.rs:101:9 | LL | &**{ x } | ^^^^^^^^ help: try: `{ x }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:105:9 + --> tests/ui/explicit_auto_deref.rs:105:9 | LL | &***x | ^^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:122:12 + --> tests/ui/explicit_auto_deref.rs:122:12 | LL | f1(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:123:12 + --> tests/ui/explicit_auto_deref.rs:123:12 | LL | f2(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:124:12 + --> tests/ui/explicit_auto_deref.rs:124:12 | LL | f3(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:125:27 + --> tests/ui/explicit_auto_deref.rs:125:27 | LL | f4.callable_str()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:126:12 + --> tests/ui/explicit_auto_deref.rs:126:12 | LL | f5(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:127:12 + --> tests/ui/explicit_auto_deref.rs:127:12 | LL | f6(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:128:27 + --> tests/ui/explicit_auto_deref.rs:128:27 | LL | f7.callable_str()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:129:25 + --> tests/ui/explicit_auto_deref.rs:129:25 | LL | f8.callable_t()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:130:12 + --> tests/ui/explicit_auto_deref.rs:130:12 | LL | f9(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:131:13 + --> tests/ui/explicit_auto_deref.rs:131:13 | LL | f10(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:132:26 + --> tests/ui/explicit_auto_deref.rs:132:26 | LL | f11.callable_t()(&*x); | ^^^ help: try: `&x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:136:16 + --> tests/ui/explicit_auto_deref.rs:136:16 | LL | let _ = S1(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:141:21 + --> tests/ui/explicit_auto_deref.rs:141:21 | LL | let _ = S2 { s: &*s }; | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:157:30 + --> tests/ui/explicit_auto_deref.rs:157:30 | LL | let _ = Self::S1(&**s); | ^^^^ help: try: `s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:158:35 + --> tests/ui/explicit_auto_deref.rs:158:35 | LL | let _ = Self::S2 { s: &**s }; | ^^^^ help: try: `s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:161:20 + --> tests/ui/explicit_auto_deref.rs:161:20 | LL | let _ = E1::S1(&*s); | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:162:25 + --> tests/ui/explicit_auto_deref.rs:162:25 | LL | let _ = E1::S2 { s: &*s }; | ^^^ help: try: `&s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:180:13 + --> tests/ui/explicit_auto_deref.rs:180:13 | LL | let _ = (*b).foo; | ^^^^ help: try: `b` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:181:13 + --> tests/ui/explicit_auto_deref.rs:181:13 | LL | let _ = (**b).foo; | ^^^^^ help: try: `b` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:196:19 + --> tests/ui/explicit_auto_deref.rs:196:19 | LL | let _ = f_str(*ref_str); | ^^^^^^^^ help: try: `ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:198:19 + --> tests/ui/explicit_auto_deref.rs:198:19 | LL | let _ = f_str(**ref_ref_str); | ^^^^^^^^^^^^^ help: try: `ref_ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:208:12 + --> tests/ui/explicit_auto_deref.rs:208:12 | LL | f_str(&&*ref_str); // `needless_borrow` will suggest removing both references | ^^^^^^^^^ help: try: `ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:209:12 + --> tests/ui/explicit_auto_deref.rs:209:12 | LL | f_str(&&**ref_str); // `needless_borrow` will suggest removing only one reference | ^^^^^^^^^^ help: try: `ref_str` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:218:41 + --> tests/ui/explicit_auto_deref.rs:218:41 | LL | let _ = || -> &'static str { return *s }; | ^^ help: try: `s` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:237:9 + --> tests/ui/explicit_auto_deref.rs:237:9 | LL | &**x | ^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:260:8 + --> tests/ui/explicit_auto_deref.rs:260:8 | LL | c1(*x); | ^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:263:20 + --> tests/ui/explicit_auto_deref.rs:263:20 | LL | return *x; | ^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:265:9 + --> tests/ui/explicit_auto_deref.rs:265:9 | LL | *x | ^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:299:20 + --> tests/ui/explicit_auto_deref.rs:299:20 | LL | Some(x) => &mut *x, | ^^^^^^^ help: try: `x` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:332:22 + --> tests/ui/explicit_auto_deref.rs:332:22 | LL | let _ = &mut (*{ x.u }).x; | ^^^^^^^^^^ help: try: `{ x.u }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:338:22 + --> tests/ui/explicit_auto_deref.rs:338:22 | LL | let _ = &mut (**x.u).x; | ^^^^^^^ help: try: `(*x.u)` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:339:22 + --> tests/ui/explicit_auto_deref.rs:339:22 | LL | let _ = &mut (**{ x.u }).x; | ^^^^^^^^^^^ help: try: `{ x.u }` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:343:22 + --> tests/ui/explicit_auto_deref.rs:343:22 | LL | let _ = &mut (*x.u).x; | ^^^^^^ help: try: `x.u` error: deref which would be done by auto-deref - --> $DIR/explicit_auto_deref.rs:344:22 + --> tests/ui/explicit_auto_deref.rs:344:22 | LL | let _ = &mut (*{ x.u }).x; | ^^^^^^^^^^ help: try: `{ x.u }` diff --git a/src/tools/clippy/tests/ui/explicit_counter_loop.stderr b/src/tools/clippy/tests/ui/explicit_counter_loop.stderr index aef979072525b..e28f8783f9c36 100644 --- a/src/tools/clippy/tests/ui/explicit_counter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_counter_loop.stderr @@ -1,5 +1,5 @@ error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:7:5 + --> tests/ui/explicit_counter_loop.rs:7:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` @@ -8,49 +8,49 @@ LL | for _v in &vec { = 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 + --> tests/ui/explicit_counter_loop.rs:15:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:21:5 + --> tests/ui/explicit_counter_loop.rs:21:5 | LL | for _v in &mut vec { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter_mut().enumerate()` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:27:5 + --> tests/ui/explicit_counter_loop.rs:27:5 | LL | for _v in vec { | ^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.into_iter().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:115:9 + --> tests/ui/explicit_counter_loop.rs:115:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:127:9 + --> tests/ui/explicit_counter_loop.rs:127:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:186:9 + --> tests/ui/explicit_counter_loop.rs:186:9 | LL | for _i in 3..10 { | ^^^^^^^^^^^^^^^ help: consider using: `for (count, _i) in (3..10).enumerate()` error: the variable `idx_usize` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:227:9 + --> tests/ui/explicit_counter_loop.rs:227:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_usize, _item) in slice.iter().enumerate()` error: the variable `idx_u32` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:240:9 + --> tests/ui/explicit_counter_loop.rs:240:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_u32, _item) in (0_u32..).zip(slice.iter())` diff --git a/src/tools/clippy/tests/ui/explicit_deref_methods.stderr b/src/tools/clippy/tests/ui/explicit_deref_methods.stderr index eb7059367a203..aab862baf5991 100644 --- a/src/tools/clippy/tests/ui/explicit_deref_methods.stderr +++ b/src/tools/clippy/tests/ui/explicit_deref_methods.stderr @@ -1,5 +1,5 @@ error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:54:19 + --> tests/ui/explicit_deref_methods.rs:54:19 | LL | let b: &str = a.deref(); | ^^^^^^^^^ help: try: `&*a` @@ -8,67 +8,67 @@ LL | let b: &str = a.deref(); = help: to override `-D warnings` add `#[allow(clippy::explicit_deref_methods)]` error: explicit `deref_mut` method call - --> $DIR/explicit_deref_methods.rs:56:23 + --> tests/ui/explicit_deref_methods.rs:56:23 | LL | let b: &mut str = a.deref_mut(); | ^^^^^^^^^^^^^ help: try: `&mut **a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:59:39 + --> tests/ui/explicit_deref_methods.rs:59:39 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:59:50 + --> tests/ui/explicit_deref_methods.rs:59:50 | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:61:20 + --> tests/ui/explicit_deref_methods.rs:61:20 | LL | println!("{}", a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:64:11 + --> tests/ui/explicit_deref_methods.rs:64:11 | LL | match a.deref() { | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:68:28 + --> tests/ui/explicit_deref_methods.rs:68:28 | LL | let b: String = concat(a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:70:13 + --> tests/ui/explicit_deref_methods.rs:70:13 | LL | let b = just_return(a).deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:72:28 + --> tests/ui/explicit_deref_methods.rs:72:28 | LL | let b: String = concat(just_return(a).deref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:74:19 + --> tests/ui/explicit_deref_methods.rs:74:19 | LL | let b: &str = a.deref().deref(); | ^^^^^^^^^^^^^^^^^ help: try: `&**a` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:77:13 + --> tests/ui/explicit_deref_methods.rs:77:13 | LL | let b = opt_a.unwrap().deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*opt_a.unwrap()` error: explicit `deref` method call - --> $DIR/explicit_deref_methods.rs:114:31 + --> tests/ui/explicit_deref_methods.rs:114:31 | LL | let b: &str = expr_deref!(a.deref()); | ^^^^^^^^^ help: try: `&*a` diff --git a/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed b/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed index 2521bce6a58e1..6d67488a71309 100644 --- a/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed +++ b/src/tools/clippy/tests/ui/explicit_into_iter_loop.fixed @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::explicit_into_iter_loop)] fn main() { diff --git a/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs b/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs index 9eac96d182b9f..14630c07c5cc4 100644 --- a/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs +++ b/src/tools/clippy/tests/ui/explicit_into_iter_loop.rs @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::explicit_into_iter_loop)] fn main() { 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 c03647ab43367..f0e2048e036f5 100644 --- a/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_into_iter_loop.stderr @@ -1,5 +1,5 @@ error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:9:18 + --> tests/ui/explicit_into_iter_loop.rs:10:18 | LL | for _ in iterator.into_iter() {} | ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator` @@ -8,31 +8,31 @@ LL | for _ in iterator.into_iter() {} = 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 + --> tests/ui/explicit_into_iter_loop.rs:23:14 | LL | for _ in t.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:25:14 + --> tests/ui/explicit_into_iter_loop.rs:26:14 | LL | for _ in r.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `r` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:33:14 + --> tests/ui/explicit_into_iter_loop.rs:34:14 | LL | for _ in mr.into_iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&*mr` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:45:14 + --> tests/ui/explicit_into_iter_loop.rs:46:14 | LL | for _ in u.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut u` error: it is more concise to loop over containers instead of using explicit iteration methods - --> $DIR/explicit_into_iter_loop.rs:48:14 + --> tests/ui/explicit_into_iter_loop.rs:49:14 | LL | for _ in mr.into_iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *mr` diff --git a/src/tools/clippy/tests/ui/explicit_iter_loop.fixed b/src/tools/clippy/tests/ui/explicit_iter_loop.fixed index f08397defa539..06229a52a18c4 100644 --- a/src/tools/clippy/tests/ui/explicit_iter_loop.fixed +++ b/src/tools/clippy/tests/ui/explicit_iter_loop.fixed @@ -5,7 +5,8 @@ clippy::needless_borrow, clippy::deref_addrof, clippy::unnecessary_mut_passed, - dead_code + dead_code, + non_local_definitions, )] use core::slice; diff --git a/src/tools/clippy/tests/ui/explicit_iter_loop.rs b/src/tools/clippy/tests/ui/explicit_iter_loop.rs index 2ee6825d445c2..c2bf45ab2e990 100644 --- a/src/tools/clippy/tests/ui/explicit_iter_loop.rs +++ b/src/tools/clippy/tests/ui/explicit_iter_loop.rs @@ -5,7 +5,8 @@ clippy::needless_borrow, clippy::deref_addrof, clippy::unnecessary_mut_passed, - dead_code + dead_code, + non_local_definitions, )] use core::slice; diff --git a/src/tools/clippy/tests/ui/explicit_iter_loop.stderr b/src/tools/clippy/tests/ui/explicit_iter_loop.stderr index 725d9b63cf8d6..c646e61aa0456 100644 --- a/src/tools/clippy/tests/ui/explicit_iter_loop.stderr +++ b/src/tools/clippy/tests/ui/explicit_iter_loop.stderr @@ -1,113 +1,113 @@ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:17:14 + --> tests/ui/explicit_iter_loop.rs:18:14 | LL | for _ in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` | note: the lint level is defined here - --> $DIR/explicit_iter_loop.rs:1:9 + --> tests/ui/explicit_iter_loop.rs:1:9 | LL | #![deny(clippy::explicit_iter_loop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:18:14 + --> tests/ui/explicit_iter_loop.rs:19:14 | LL | for _ in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:21:14 + --> tests/ui/explicit_iter_loop.rs:22:14 | LL | for _ in rvec.iter() {} | ^^^^^^^^^^^ help: to write this more concisely, try: `rvec` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:30:14 + --> tests/ui/explicit_iter_loop.rs:31:14 | LL | for _ in [1, 2, 3].iter() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:34:14 + --> tests/ui/explicit_iter_loop.rs:35:14 | LL | for _ in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:35:14 + --> tests/ui/explicit_iter_loop.rs:36:14 | LL | for _ in [0; 33].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 33]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:38:14 + --> tests/ui/explicit_iter_loop.rs:39:14 | LL | for _ in ll.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&ll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:40:14 + --> tests/ui/explicit_iter_loop.rs:41:14 | LL | for _ in rll.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `rll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:43:14 + --> tests/ui/explicit_iter_loop.rs:44:14 | LL | for _ in vd.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&vd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:45:14 + --> tests/ui/explicit_iter_loop.rs:46:14 | LL | for _ in rvd.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `rvd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:48:14 + --> tests/ui/explicit_iter_loop.rs:49:14 | LL | for _ in bh.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bh` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:51:14 + --> tests/ui/explicit_iter_loop.rs:52:14 | LL | for _ in hm.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hm` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:54:14 + --> tests/ui/explicit_iter_loop.rs:55:14 | LL | for _ in bt.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bt` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:57:14 + --> tests/ui/explicit_iter_loop.rs:58:14 | LL | for _ in hs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:60:14 + --> tests/ui/explicit_iter_loop.rs:61:14 | LL | for _ in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:149:14 + --> tests/ui/explicit_iter_loop.rs:150:14 | LL | for _ in x.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `&x` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:150:14 + --> tests/ui/explicit_iter_loop.rs:151:14 | LL | for _ in x.iter_mut() {} | ^^^^^^^^^^^^ help: to write this more concisely, try: `&mut x` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/explicit_iter_loop.rs:153:14 + --> tests/ui/explicit_iter_loop.rs:154:14 | LL | for _ in r.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `r` diff --git a/src/tools/clippy/tests/ui/explicit_write.stderr b/src/tools/clippy/tests/ui/explicit_write.stderr index 26aad266bbfc4..0d22f02c36f2e 100644 --- a/src/tools/clippy/tests/ui/explicit_write.stderr +++ b/src/tools/clippy/tests/ui/explicit_write.stderr @@ -1,5 +1,5 @@ error: use of `write!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:23:9 + --> tests/ui/explicit_write.rs:23:9 | LL | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `print!("test")` @@ -8,73 +8,73 @@ LL | write!(std::io::stdout(), "test").unwrap(); = help: to override `-D warnings` add `#[allow(clippy::explicit_write)]` error: use of `write!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:24:9 + --> tests/ui/explicit_write.rs:24:9 | LL | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprint!("test")` error: use of `writeln!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:25:9 + --> tests/ui/explicit_write.rs:25:9 | LL | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `println!("test")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:26:9 + --> tests/ui/explicit_write.rs:26:9 | LL | writeln!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("test")` error: use of `stdout().write_fmt(...).unwrap()` - --> $DIR/explicit_write.rs:27:9 + --> tests/ui/explicit_write.rs:27:9 | LL | std::io::stdout().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `print!("test")` error: use of `stderr().write_fmt(...).unwrap()` - --> $DIR/explicit_write.rs:28:9 + --> tests/ui/explicit_write.rs:28:9 | LL | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprint!("test")` error: use of `writeln!(stdout(), ...).unwrap()` - --> $DIR/explicit_write.rs:31:9 + --> tests/ui/explicit_write.rs:31:9 | LL | writeln!(std::io::stdout(), "test\ntest").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `println!("test\ntest")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:32:9 + --> tests/ui/explicit_write.rs:32:9 | LL | writeln!(std::io::stderr(), "test\ntest").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("test\ntest")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:35:9 + --> tests/ui/explicit_write.rs:35:9 | LL | writeln!(std::io::stderr(), "with {}", value).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {}", value)` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:36:9 + --> tests/ui/explicit_write.rs:36:9 | LL | writeln!(std::io::stderr(), "with {} {}", 2, value).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {} {}", 2, value)` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:37:9 + --> tests/ui/explicit_write.rs:37:9 | LL | writeln!(std::io::stderr(), "with {value}").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("with {value}")` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:38:9 + --> tests/ui/explicit_write.rs:38:9 | LL | writeln!(std::io::stderr(), "macro arg {}", one!()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("macro arg {}", one!())` error: use of `writeln!(stderr(), ...).unwrap()` - --> $DIR/explicit_write.rs:40:9 + --> tests/ui/explicit_write.rs:40:9 | LL | writeln!(std::io::stderr(), "{:w$}", value, w = width).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `eprintln!("{:w$}", value, w = width)` diff --git a/src/tools/clippy/tests/ui/extend_with_drain.stderr b/src/tools/clippy/tests/ui/extend_with_drain.stderr index e0bd5a620e78f..444cc82bbae7c 100644 --- a/src/tools/clippy/tests/ui/extend_with_drain.stderr +++ b/src/tools/clippy/tests/ui/extend_with_drain.stderr @@ -1,5 +1,5 @@ error: use of `extend` instead of `append` for adding the full range of a second vector - --> $DIR/extend_with_drain.rs:8:5 + --> tests/ui/extend_with_drain.rs:8:5 | LL | vec2.extend(vec1.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec2.append(&mut vec1)` @@ -8,19 +8,19 @@ LL | vec2.extend(vec1.drain(..)); = 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 + --> tests/ui/extend_with_drain.rs:13:5 | LL | vec4.extend(vec3.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec4.append(&mut vec3)` error: use of `extend` instead of `append` for adding the full range of a second vector - --> $DIR/extend_with_drain.rs:17:5 + --> tests/ui/extend_with_drain.rs:17:5 | LL | vec11.extend(return_vector().drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec11.append(&mut return_vector())` error: use of `extend` instead of `append` for adding the full range of a second vector - --> $DIR/extend_with_drain.rs:48:5 + --> tests/ui/extend_with_drain.rs:48:5 | LL | y.extend(ref_x.drain(..)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `y.append(ref_x)` diff --git a/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr b/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr index 8790fe5a5b1a5..56292cb5d1a51 100644 --- a/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr +++ b/src/tools/clippy/tests/ui/extra_unused_lifetimes.stderr @@ -1,5 +1,5 @@ error: this lifetime isn't used in the function definition - --> $DIR/extra_unused_lifetimes.rs:19:14 + --> tests/ui/extra_unused_lifetimes.rs:19:14 | LL | fn unused_lt<'a>(x: u8) {} | ^^ @@ -8,31 +8,31 @@ LL | fn unused_lt<'a>(x: u8) {} = 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 + --> tests/ui/extra_unused_lifetimes.rs:46:10 | LL | fn x<'a>(&self) {} | ^^ error: this lifetime isn't used in the function definition - --> $DIR/extra_unused_lifetimes.rs:72:22 + --> tests/ui/extra_unused_lifetimes.rs:72:22 | LL | fn unused_lt<'a>(x: u8) {} | ^^ error: this lifetime isn't used in the impl - --> $DIR/extra_unused_lifetimes.rs:83:10 + --> tests/ui/extra_unused_lifetimes.rs:83:10 | LL | impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar { | ^^ error: this lifetime isn't used in the impl - --> $DIR/extra_unused_lifetimes.rs:89:10 + --> tests/ui/extra_unused_lifetimes.rs:89:10 | LL | impl<'b> Scalar { | ^^ error: this lifetime isn't used in the function definition - --> $DIR/extra_unused_lifetimes.rs:90:26 + --> tests/ui/extra_unused_lifetimes.rs:90:26 | LL | pub fn something<'c>() -> Self { | ^^ 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 9a179076c4824..928c0038c2c3d 100644 --- a/src/tools/clippy/tests/ui/extra_unused_type_parameters.stderr +++ b/src/tools/clippy/tests/ui/extra_unused_type_parameters.stderr @@ -1,5 +1,5 @@ error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:9:13 + --> tests/ui/extra_unused_type_parameters.rs:9:13 | LL | fn unused_ty(x: u8) { | ^^^ help: consider removing the parameter @@ -8,19 +8,19 @@ LL | fn unused_ty(x: u8) { = 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 + --> tests/ui/extra_unused_type_parameters.rs:13:16 | LL | fn unused_multi(x: u8) { | ^^^^^^ help: consider removing the parameters error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:17:21 + --> tests/ui/extra_unused_type_parameters.rs:17:21 | LL | fn unused_with_lt<'a, T>(x: &'a u8) { | ^^^ help: consider removing the parameter error: type parameters go unused in function definition: T, V - --> $DIR/extra_unused_type_parameters.rs:29:19 + --> tests/ui/extra_unused_type_parameters.rs:29:19 | LL | fn unused_bounded(x: U) { | ^^^^^^^^^^^^ ^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL + fn unused_bounded(x: U) { | error: type parameters go unused in function definition: A, D, E - --> $DIR/extra_unused_type_parameters.rs:33:16 + --> tests/ui/extra_unused_type_parameters.rs:33:16 | LL | fn some_unused, E>(b: B, c: C) { | ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,19 +44,19 @@ LL + fn some_unused(b: B, c: C) { | error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:58:22 + --> tests/ui/extra_unused_type_parameters.rs:58:22 | LL | fn unused_ty_impl(&self) { | ^^^ help: consider removing the parameter error: type parameters go unused in function definition: A, B - --> $DIR/extra_unused_type_parameters.rs:80:17 + --> tests/ui/extra_unused_type_parameters.rs:80:17 | LL | fn unused_opaque(dummy: impl Default) { | ^^^^^^ help: consider removing the parameters error: type parameter `U` goes unused in function definition - --> $DIR/extra_unused_type_parameters.rs:93:56 + --> tests/ui/extra_unused_type_parameters.rs:93:56 | LL | fn unused_with_priv_trait_bound() { | ^^^ help: consider removing the parameter 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 a216c4363075f..0765c41609368 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 @@ -1,5 +1,5 @@ error: type parameter `T` goes unused in function definition - --> $DIR/extra_unused_type_parameters_unfixable.rs:3:24 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:3:24 | LL | fn unused_where_clause(x: U) | ^ @@ -9,7 +9,7 @@ LL | fn unused_where_clause(x: U) = 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 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:11:30 | LL | fn unused_multi_where_clause(x: U) | ^ ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn unused_multi_where_clause(x: U) = help: consider removing the parameters error: type parameters go unused in function definition: T, U, V - --> $DIR/extra_unused_type_parameters_unfixable.rs:19:28 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:19:28 | LL | fn unused_all_where_clause() | ^ ^^^^^^^^^^ ^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/fallible_impl_from.stderr b/src/tools/clippy/tests/ui/fallible_impl_from.stderr index 96074ca89ea0f..62496148924e1 100644 --- a/src/tools/clippy/tests/ui/fallible_impl_from.stderr +++ b/src/tools/clippy/tests/ui/fallible_impl_from.stderr @@ -1,5 +1,5 @@ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:6:1 + --> tests/ui/fallible_impl_from.rs:6:1 | LL | / impl From for Foo { LL | | @@ -11,18 +11,18 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:9:13 + --> tests/ui/fallible_impl_from.rs:9:13 | LL | Foo(s.parse().unwrap()) | ^^^^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/fallible_impl_from.rs:1:9 + --> tests/ui/fallible_impl_from.rs:1:9 | LL | #![deny(clippy::fallible_impl_from)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:28:1 + --> tests/ui/fallible_impl_from.rs:28:1 | LL | / impl From for Invalid { LL | | @@ -35,14 +35,14 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:32:13 + --> tests/ui/fallible_impl_from.rs:32:13 | LL | panic!(); | ^^^^^^^^ = 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: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:38:1 + --> tests/ui/fallible_impl_from.rs:38:1 | LL | / impl From> for Invalid { LL | | @@ -55,7 +55,7 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:41:17 + --> tests/ui/fallible_impl_from.rs:41:17 | LL | let s = s.unwrap(); | ^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | panic!("{:?}", s); = 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: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:57:1 + --> tests/ui/fallible_impl_from.rs:57:1 | LL | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { LL | | @@ -82,7 +82,7 @@ LL | | } | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail note: potential failure(s) - --> $DIR/fallible_impl_from.rs:60:12 + --> tests/ui/fallible_impl_from.rs:60:12 | LL | if s.parse::().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 a8cf84bd4114a..bc03283492085 100644 --- a/src/tools/clippy/tests/ui/field_reassign_with_default.stderr +++ b/src/tools/clippy/tests/ui/field_reassign_with_default.stderr @@ -1,11 +1,11 @@ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:56:5 + --> tests/ui/field_reassign_with_default.rs:56:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:55:5 + --> tests/ui/field_reassign_with_default.rs:55:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,121 +13,121 @@ LL | let mut a: A = Default::default(); = 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 + --> tests/ui/field_reassign_with_default.rs:96:5 | LL | a.j = 43; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { j: 43, i: 42 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:95:5 + --> tests/ui/field_reassign_with_default.rs:95:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:101:5 + --> tests/ui/field_reassign_with_default.rs:101:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, j: 44 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:100:5 + --> tests/ui/field_reassign_with_default.rs:100:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:107:5 + --> tests/ui/field_reassign_with_default.rs:107:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:106:5 + --> tests/ui/field_reassign_with_default.rs:106:5 | LL | let mut a = A::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:117:5 + --> tests/ui/field_reassign_with_default.rs:117:5 | LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `main::A { i: Default::default(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:116:5 + --> tests/ui/field_reassign_with_default.rs:116:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:121:5 + --> tests/ui/field_reassign_with_default.rs:121:5 | LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `main::A { i: Default::default(), j: 45 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:120:5 + --> tests/ui/field_reassign_with_default.rs:120:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:143:5 + --> tests/ui/field_reassign_with_default.rs:143:5 | LL | a.i = vec![1]; | ^^^^^^^^^^^^^^ | note: consider initializing the variable with `C { i: vec![1], ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:142:5 + --> tests/ui/field_reassign_with_default.rs:142:5 | LL | let mut a: C = C::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:161:5 + --> tests/ui/field_reassign_with_default.rs:161:5 | LL | a.i = true; | ^^^^^^^^^^^ | note: consider initializing the variable with `Wrapper:: { i: true }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:160:5 + --> tests/ui/field_reassign_with_default.rs:160:5 | LL | let mut a: Wrapper = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:164:5 + --> tests/ui/field_reassign_with_default.rs:164:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `WrapperMulti:: { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:163:5 + --> tests/ui/field_reassign_with_default.rs:163:5 | LL | let mut a: WrapperMulti = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:235:13 + --> tests/ui/field_reassign_with_default.rs:235:13 | LL | f.name = name.len(); | ^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `issue6312::ImplDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:234:13 + --> tests/ui/field_reassign_with_default.rs:234:13 | LL | let mut f = ImplDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:251:13 + --> tests/ui/field_reassign_with_default.rs:251:13 | LL | f.name = name.len(); | ^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `issue6312::NoDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:250:13 + --> tests/ui/field_reassign_with_default.rs:250:13 | LL | let mut f = NoDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/filetype_is_file.stderr b/src/tools/clippy/tests/ui/filetype_is_file.stderr index 8876ad5c9bbce..0c66910c1b616 100644 --- a/src/tools/clippy/tests/ui/filetype_is_file.stderr +++ b/src/tools/clippy/tests/ui/filetype_is_file.stderr @@ -1,5 +1,5 @@ error: `FileType::is_file()` only covers regular files - --> $DIR/filetype_is_file.rs:9:8 + --> tests/ui/filetype_is_file.rs:9:8 | LL | if fs::metadata("foo.txt")?.file_type().is_file() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | if fs::metadata("foo.txt")?.file_type().is_file() { = 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 + --> tests/ui/filetype_is_file.rs:15:8 | LL | if !fs::metadata("foo.txt")?.file_type().is_file() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | if !fs::metadata("foo.txt")?.file_type().is_file() { = help: use `FileType::is_dir()` instead error: `FileType::is_file()` only covers regular files - --> $DIR/filetype_is_file.rs:21:9 + --> tests/ui/filetype_is_file.rs:21:9 | LL | if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 fab6987913a10..088b9ba128675 100644 --- a/src/tools/clippy/tests/ui/filter_map_bool_then.stderr +++ b/src/tools/clippy/tests/ui/filter_map_bool_then.stderr @@ -1,5 +1,5 @@ error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:19:22 + --> tests/ui/filter_map_bool_then.rs:19:22 | 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)` @@ -8,55 +8,55 @@ LL | v.clone().iter().filter_map(|i| (i % 2 == 0).then(|| i + 1)); = 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 + --> tests/ui/filter_map_bool_then.rs:20:27 | LL | v.clone().into_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)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:23:10 + --> tests/ui/filter_map_bool_then.rs:23:10 | LL | .filter_map(|i| -> Option<_> { (i % 2 == 0).then(|| i + 1) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:27:10 + --> tests/ui/filter_map_bool_then.rs:27:10 | LL | .filter_map(|i| (i % 2 == 0).then(|| i + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i % 2 == 0)).map(|i| i + 1)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:31:10 + --> tests/ui/filter_map_bool_then.rs:31:10 | LL | .filter_map(|i| (i.clone() % 2 == 0).then(|| i + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i.clone() % 2 == 0)).map(|i| i + 1)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:37:22 + --> tests/ui/filter_map_bool_then.rs:37:22 | LL | v.clone().iter().filter_map(|i| (i == &NonCopy).then(|| i)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&i| (i == &NonCopy)).map(|i| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:61:50 + --> tests/ui/filter_map_bool_then.rs:61:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| *b).map(|(i, b)| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:65:50 + --> tests/ui/filter_map_bool_then.rs:65:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| ***b).map(|(i, b)| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:69:50 + --> tests/ui/filter_map_bool_then.rs:69:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| **b).map(|(i, b)| i)` error: usage of `bool::then` in `filter_map` - --> $DIR/filter_map_bool_then.rs:80:50 + --> tests/ui/filter_map_bool_then.rs:80:50 | LL | let _: Vec = bools.iter().enumerate().filter_map(|(i, b)| b.then(|| i)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `filter` then `map` instead: `filter(|&(i, b)| ****b).map(|(i, b)| i)` diff --git a/src/tools/clippy/tests/ui/filter_map_identity.stderr b/src/tools/clippy/tests/ui/filter_map_identity.stderr index a08477695c931..5aa46ad6d2375 100644 --- a/src/tools/clippy/tests/ui/filter_map_identity.stderr +++ b/src/tools/clippy/tests/ui/filter_map_identity.stderr @@ -1,5 +1,5 @@ error: use of `filter_map` with an identity function - --> $DIR/filter_map_identity.rs:6:22 + --> tests/ui/filter_map_identity.rs:6:22 | LL | let _ = iterator.filter_map(|x| x); | ^^^^^^^^^^^^^^^^^ help: try: `flatten()` @@ -8,19 +8,19 @@ LL | let _ = iterator.filter_map(|x| x); = 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 + --> tests/ui/filter_map_identity.rs:9:22 | LL | let _ = iterator.filter_map(std::convert::identity); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> $DIR/filter_map_identity.rs:13:22 + --> tests/ui/filter_map_identity.rs:13:22 | LL | let _ = iterator.filter_map(identity); | ^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> $DIR/filter_map_identity.rs:16:22 + --> tests/ui/filter_map_identity.rs:16:22 | LL | let _ = iterator.filter_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` diff --git a/src/tools/clippy/tests/ui/filter_map_next.stderr b/src/tools/clippy/tests/ui/filter_map_next.stderr index 07760d8837a39..cd3ffe3aa7f01 100644 --- a/src/tools/clippy/tests/ui/filter_map_next.stderr +++ b/src/tools/clippy/tests/ui/filter_map_next.stderr @@ -1,5 +1,5 @@ error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead - --> $DIR/filter_map_next.rs:7:26 + --> tests/ui/filter_map_next.rs:7:26 | LL | let _: Option = vec![1, 2, 3, 4, 5, 6] | __________________________^ 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 0edf4e6e07d46..2c6148f3f4b6b 100644 --- a/src/tools/clippy/tests/ui/filter_map_next_fixable.stderr +++ b/src/tools/clippy/tests/ui/filter_map_next_fixable.stderr @@ -1,5 +1,5 @@ error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead - --> $DIR/filter_map_next_fixable.rs:7:32 + --> tests/ui/filter_map_next_fixable.rs:7:32 | LL | let element: Option = a.iter().filter_map(|s| s.parse().ok()).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.iter().find_map(|s| s.parse().ok())` @@ -8,7 +8,7 @@ LL | let element: Option = a.iter().filter_map(|s| s.parse().ok()).next = 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 + --> tests/ui/filter_map_next_fixable.rs:20:26 | LL | let _: Option = a.iter().filter_map(|s| s.parse().ok()).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.iter().find_map(|s| s.parse().ok())` diff --git a/src/tools/clippy/tests/ui/flat_map_identity.stderr b/src/tools/clippy/tests/ui/flat_map_identity.stderr index d6fcc14fc5630..496fd972a498f 100644 --- a/src/tools/clippy/tests/ui/flat_map_identity.stderr +++ b/src/tools/clippy/tests/ui/flat_map_identity.stderr @@ -1,5 +1,5 @@ error: use of `flat_map` with an identity function - --> $DIR/flat_map_identity.rs:8:22 + --> tests/ui/flat_map_identity.rs:8:22 | LL | let _ = iterator.flat_map(|x| x); | ^^^^^^^^^^^^^^^ help: try: `flatten()` @@ -8,13 +8,13 @@ LL | let _ = iterator.flat_map(|x| x); = 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 + --> tests/ui/flat_map_identity.rs:11:22 | LL | let _ = iterator.flat_map(convert::identity); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `flat_map` with an identity function - --> $DIR/flat_map_identity.rs:14:22 + --> tests/ui/flat_map_identity.rs:14:22 | LL | let _ = iterator.flat_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` diff --git a/src/tools/clippy/tests/ui/flat_map_option.stderr b/src/tools/clippy/tests/ui/flat_map_option.stderr index e0a59daf6a8f8..6e151965fad53 100644 --- a/src/tools/clippy/tests/ui/flat_map_option.stderr +++ b/src/tools/clippy/tests/ui/flat_map_option.stderr @@ -1,5 +1,5 @@ error: used `flat_map` where `filter_map` could be used instead - --> $DIR/flat_map_option.rs:7:24 + --> tests/ui/flat_map_option.rs:7:24 | LL | let _ = [1].iter().flat_map(c); | ^^^^^^^^ help: try: `filter_map` @@ -8,7 +8,7 @@ LL | let _ = [1].iter().flat_map(c); = 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 + --> tests/ui/flat_map_option.rs:8:24 | LL | let _ = [1].iter().flat_map(Some); | ^^^^^^^^ help: try: `filter_map` diff --git a/src/tools/clippy/tests/ui/float_arithmetic.stderr b/src/tools/clippy/tests/ui/float_arithmetic.stderr index da4ca976792f5..66455f061455e 100644 --- a/src/tools/clippy/tests/ui/float_arithmetic.stderr +++ b/src/tools/clippy/tests/ui/float_arithmetic.stderr @@ -1,5 +1,5 @@ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:15:5 + --> tests/ui/float_arithmetic.rs:15:5 | LL | f * 2.0; | ^^^^^^^ @@ -8,97 +8,97 @@ LL | f * 2.0; = help: to override `-D warnings` add `#[allow(clippy::float_arithmetic)]` error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:19:5 + --> tests/ui/float_arithmetic.rs:19:5 | LL | 1.0 + f; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:21:5 + --> tests/ui/float_arithmetic.rs:21:5 | LL | f * 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:23:5 + --> tests/ui/float_arithmetic.rs:23:5 | LL | f / 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:25:5 + --> tests/ui/float_arithmetic.rs:25:5 | LL | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:27:5 + --> tests/ui/float_arithmetic.rs:27:5 | LL | -f; | ^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:30:5 + --> tests/ui/float_arithmetic.rs:30:5 | LL | f += 1.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:32:5 + --> tests/ui/float_arithmetic.rs:32:5 | LL | f -= 1.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:34:5 + --> tests/ui/float_arithmetic.rs:34:5 | LL | f *= 2.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:36:5 + --> tests/ui/float_arithmetic.rs:36:5 | LL | f /= 2.0; | ^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:43:5 + --> tests/ui/float_arithmetic.rs:43:5 | LL | 3.1_f32 + &1.2_f32; | ^^^^^^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:45:5 + --> tests/ui/float_arithmetic.rs:45:5 | LL | &3.4_f32 + 1.5_f32; | ^^^^^^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:47:5 + --> tests/ui/float_arithmetic.rs:47:5 | LL | &3.5_f32 + &1.3_f32; | ^^^^^^^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:53:5 + --> tests/ui/float_arithmetic.rs:53:5 | LL | a + f | ^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:58:5 + --> tests/ui/float_arithmetic.rs:58:5 | LL | f1 + f2 | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:63:5 + --> tests/ui/float_arithmetic.rs:63:5 | LL | f1 + f2 | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/float_arithmetic.rs:68:5 + --> tests/ui/float_arithmetic.rs:68:5 | LL | (&f1 + &f2) | ^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/float_cmp.stderr b/src/tools/clippy/tests/ui/float_cmp.stderr index 217e2987917ab..49b65184f7311 100644 --- a/src/tools/clippy/tests/ui/float_cmp.stderr +++ b/src/tools/clippy/tests/ui/float_cmp.stderr @@ -1,5 +1,5 @@ error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:70:5 + --> tests/ui/float_cmp.rs:70:5 | LL | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE as f64 - 2.0).abs() > error_margin` @@ -9,7 +9,7 @@ LL | ONE as f64 != 2.0; = help: to override `-D warnings` add `#[allow(clippy::float_cmp)]` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:77:5 + --> tests/ui/float_cmp.rs:77:5 | LL | x == 1.0; | ^^^^^^^^ help: consider comparing them within some margin of error: `(x - 1.0).abs() < error_margin` @@ -17,7 +17,7 @@ LL | x == 1.0; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:82:5 + --> tests/ui/float_cmp.rs:82:5 | LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(twice(x) - twice(ONE as f64)).abs() > error_margin` @@ -25,7 +25,7 @@ LL | twice(x) != twice(ONE as f64); = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:104:5 + --> tests/ui/float_cmp.rs:104:5 | LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(NON_ZERO_ARRAY[i] - NON_ZERO_ARRAY[j]).abs() < error_margin` @@ -33,7 +33,7 @@ LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` arrays - --> $DIR/float_cmp.rs:111:5 + --> tests/ui/float_cmp.rs:111:5 | LL | a1 == a2; | ^^^^^^^^ @@ -41,7 +41,7 @@ LL | a1 == a2; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` - --> $DIR/float_cmp.rs:114:5 + --> tests/ui/float_cmp.rs:114:5 | LL | a1[0] == a2[0]; | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(a1[0] - a2[0]).abs() < error_margin` diff --git a/src/tools/clippy/tests/ui/float_cmp_const.stderr b/src/tools/clippy/tests/ui/float_cmp_const.stderr index 856aaa2ea716d..bffd2acc2e049 100644 --- a/src/tools/clippy/tests/ui/float_cmp_const.stderr +++ b/src/tools/clippy/tests/ui/float_cmp_const.stderr @@ -1,5 +1,5 @@ error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:16:5 + --> tests/ui/float_cmp_const.rs:16:5 | LL | 1f32 == ONE; | ^^^^^^^^^^^ help: consider comparing them within some margin of error: `(1f32 - ONE).abs() < error_margin` @@ -9,7 +9,7 @@ LL | 1f32 == ONE; = 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 + --> tests/ui/float_cmp_const.rs:19:5 | LL | TWO == ONE; | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() < error_margin` @@ -17,7 +17,7 @@ LL | TWO == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:22:5 + --> tests/ui/float_cmp_const.rs:22:5 | LL | TWO != ONE; | ^^^^^^^^^^ help: consider comparing them within some margin of error: `(TWO - ONE).abs() > error_margin` @@ -25,7 +25,7 @@ LL | TWO != ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:25:5 + --> tests/ui/float_cmp_const.rs:25:5 | LL | ONE + ONE == TWO; | ^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(ONE + ONE - TWO).abs() < error_margin` @@ -33,7 +33,7 @@ LL | ONE + ONE == TWO; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:29:5 + --> tests/ui/float_cmp_const.rs:29:5 | LL | x as f32 == ONE; | ^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x as f32 - ONE).abs() < error_margin` @@ -41,7 +41,7 @@ LL | x as f32 == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:34:5 + --> tests/ui/float_cmp_const.rs:34:5 | LL | v == ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() < error_margin` @@ -49,7 +49,7 @@ LL | v == ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant - --> $DIR/float_cmp_const.rs:37:5 + --> tests/ui/float_cmp_const.rs:37:5 | LL | v != ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() > error_margin` @@ -57,7 +57,7 @@ LL | v != ONE; = note: `f32::EPSILON` and `f64::EPSILON` are available for the `error_margin` error: strict comparison of `f32` or `f64` constant arrays - --> $DIR/float_cmp_const.rs:71:5 + --> tests/ui/float_cmp_const.rs:71:5 | LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 155699f6fcf0e..0124dd983a391 100644 --- a/src/tools/clippy/tests/ui/float_equality_without_abs.stderr +++ b/src/tools/clippy/tests/ui/float_equality_without_abs.stderr @@ -1,5 +1,5 @@ error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:4:5 + --> tests/ui/float_equality_without_abs.rs:4:5 | LL | (a - b) < f32::EPSILON | -------^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | (a - b) < f32::EPSILON = 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 + --> tests/ui/float_equality_without_abs.rs:15:13 | LL | let _ = (a - b) < f32::EPSILON; | -------^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | let _ = (a - b) < f32::EPSILON; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:17:13 + --> tests/ui/float_equality_without_abs.rs:17:13 | LL | let _ = a - b < f32::EPSILON; | -----^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _ = a - b < f32::EPSILON; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:19:13 + --> tests/ui/float_equality_without_abs.rs:19:13 | LL | let _ = a - b.abs() < f32::EPSILON; | -----------^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = a - b.abs() < f32::EPSILON; | help: add `.abs()`: `(a - b.abs()).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:21:13 + --> tests/ui/float_equality_without_abs.rs:21:13 | LL | let _ = (a as f64 - b as f64) < f64::EPSILON; | ---------------------^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | let _ = (a as f64 - b as f64) < f64::EPSILON; | help: add `.abs()`: `(a as f64 - b as f64).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:23:13 + --> tests/ui/float_equality_without_abs.rs:23:13 | LL | let _ = 1.0 - 2.0 < f32::EPSILON; | ---------^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | let _ = 1.0 - 2.0 < f32::EPSILON; | help: add `.abs()`: `(1.0 - 2.0).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:26:13 + --> tests/ui/float_equality_without_abs.rs:26:13 | LL | let _ = f32::EPSILON > (a - b); | ^^^^^^^^^^^^^^^------- @@ -58,7 +58,7 @@ LL | let _ = f32::EPSILON > (a - b); | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:28:13 + --> tests/ui/float_equality_without_abs.rs:28:13 | LL | let _ = f32::EPSILON > a - b; | ^^^^^^^^^^^^^^^----- @@ -66,7 +66,7 @@ LL | let _ = f32::EPSILON > a - b; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:30:13 + --> tests/ui/float_equality_without_abs.rs:30:13 | LL | let _ = f32::EPSILON > a - b.abs(); | ^^^^^^^^^^^^^^^----------- @@ -74,7 +74,7 @@ LL | let _ = f32::EPSILON > a - b.abs(); | help: add `.abs()`: `(a - b.abs()).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:32:13 + --> tests/ui/float_equality_without_abs.rs:32:13 | LL | let _ = f64::EPSILON > (a as f64 - b as f64); | ^^^^^^^^^^^^^^^--------------------- @@ -82,7 +82,7 @@ LL | let _ = f64::EPSILON > (a as f64 - b as f64); | help: add `.abs()`: `(a as f64 - b as f64).abs()` error: float equality check without `.abs()` - --> $DIR/float_equality_without_abs.rs:34:13 + --> tests/ui/float_equality_without_abs.rs:34:13 | LL | let _ = f32::EPSILON > 1.0 - 2.0; | ^^^^^^^^^^^^^^^--------- diff --git a/src/tools/clippy/tests/ui/floating_point_abs.stderr b/src/tools/clippy/tests/ui/floating_point_abs.stderr index fbc5783824d6f..f5a778c5b7650 100644 --- a/src/tools/clippy/tests/ui/floating_point_abs.stderr +++ b/src/tools/clippy/tests/ui/floating_point_abs.stderr @@ -1,5 +1,5 @@ error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:15:5 + --> tests/ui/floating_point_abs.rs:15:5 | LL | if num >= 0.0 { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` @@ -8,43 +8,43 @@ LL | if num >= 0.0 { num } else { -num } = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:19:5 + --> tests/ui/floating_point_abs.rs:19:5 | LL | if 0.0 < num { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:23:5 + --> tests/ui/floating_point_abs.rs:23:5 | LL | if a.a > 0.0 { a.a } else { -a.a } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:27:5 + --> tests/ui/floating_point_abs.rs:27:5 | LL | if 0.0 >= num { -num } else { num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` error: manual implementation of `abs` method - --> $DIR/floating_point_abs.rs:31:5 + --> tests/ui/floating_point_abs.rs:31:5 | LL | if a.a < 0.0 { -a.a } else { a.a } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:35:5 + --> tests/ui/floating_point_abs.rs:35:5 | LL | if num < 0.0 { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:39:5 + --> tests/ui/floating_point_abs.rs:39:5 | LL | if 0.0 >= num { num } else { -num } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` error: manual implementation of negation of `abs` method - --> $DIR/floating_point_abs.rs:44:12 + --> tests/ui/floating_point_abs.rs:44:12 | LL | a: if a.a >= 0.0 { -a.a } else { a.a }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()` diff --git a/src/tools/clippy/tests/ui/floating_point_exp.stderr b/src/tools/clippy/tests/ui/floating_point_exp.stderr index 6b64b9b600821..a19edf87e2448 100644 --- a/src/tools/clippy/tests/ui/floating_point_exp.stderr +++ b/src/tools/clippy/tests/ui/floating_point_exp.stderr @@ -1,5 +1,5 @@ error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:6:13 + --> tests/ui/floating_point_exp.rs:6:13 | LL | let _ = x.exp() - 1.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` @@ -8,25 +8,25 @@ LL | let _ = x.exp() - 1.0; = 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 + --> tests/ui/floating_point_exp.rs:7:13 | LL | let _ = x.exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:8:13 + --> tests/ui/floating_point_exp.rs:8:13 | LL | let _ = (x as f32).exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).exp_m1()` error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:14:13 + --> tests/ui/floating_point_exp.rs:14:13 | LL | let _ = x.exp() - 1.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` error: (e.pow(x) - 1) can be computed more accurately - --> $DIR/floating_point_exp.rs:15:13 + --> tests/ui/floating_point_exp.rs:15:13 | LL | let _ = x.exp() - 1.0 + 2.0; | ^^^^^^^^^^^^^ help: consider using: `x.exp_m1()` diff --git a/src/tools/clippy/tests/ui/floating_point_hypot.stderr b/src/tools/clippy/tests/ui/floating_point_hypot.stderr index 21e0bd8b5810f..8942e86910da1 100644 --- a/src/tools/clippy/tests/ui/floating_point_hypot.stderr +++ b/src/tools/clippy/tests/ui/floating_point_hypot.stderr @@ -1,5 +1,5 @@ error: hypotenuse can be computed more accurately - --> $DIR/floating_point_hypot.rs:6:13 + --> tests/ui/floating_point_hypot.rs:6:13 | LL | let _ = (x * x + y * y).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)` @@ -8,13 +8,13 @@ LL | let _ = (x * x + y * y).sqrt(); = help: to override `-D warnings` add `#[allow(clippy::imprecise_flops)]` error: hypotenuse can be computed more accurately - --> $DIR/floating_point_hypot.rs:7:13 + --> tests/ui/floating_point_hypot.rs:7:13 | LL | let _ = ((x + 1f32) * (x + 1f32) + y * y).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 1f32).hypot(y)` error: hypotenuse can be computed more accurately - --> $DIR/floating_point_hypot.rs:8:13 + --> tests/ui/floating_point_hypot.rs:8:13 | LL | let _ = (x.powi(2) + y.powi(2)).sqrt(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)` diff --git a/src/tools/clippy/tests/ui/floating_point_log.stderr b/src/tools/clippy/tests/ui/floating_point_log.stderr index a426f4c3dde81..3a449a98eadd5 100644 --- a/src/tools/clippy/tests/ui/floating_point_log.stderr +++ b/src/tools/clippy/tests/ui/floating_point_log.stderr @@ -1,5 +1,5 @@ error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:9:13 + --> tests/ui/floating_point_log.rs:9:13 | LL | let _ = x.log(2f32); | ^^^^^^^^^^^ help: consider using: `x.log2()` @@ -8,55 +8,55 @@ LL | let _ = x.log(2f32); = 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 + --> tests/ui/floating_point_log.rs:10:13 | LL | let _ = x.log(10f32); | ^^^^^^^^^^^^ help: consider using: `x.log10()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:11:13 + --> tests/ui/floating_point_log.rs:11:13 | LL | let _ = x.log(std::f32::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:12:13 + --> tests/ui/floating_point_log.rs:12:13 | LL | let _ = x.log(TWO); | ^^^^^^^^^^ help: consider using: `x.log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:13:13 + --> tests/ui/floating_point_log.rs:13:13 | LL | let _ = x.log(E); | ^^^^^^^^ help: consider using: `x.ln()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:14:13 + --> tests/ui/floating_point_log.rs:14:13 | LL | let _ = (x as f32).log(2f32); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:17:13 + --> tests/ui/floating_point_log.rs:17:13 | LL | let _ = x.log(2f64); | ^^^^^^^^^^^ help: consider using: `x.log2()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:18:13 + --> tests/ui/floating_point_log.rs:18:13 | LL | let _ = x.log(10f64); | ^^^^^^^^^^^^ help: consider using: `x.log10()` error: logarithm for bases 2, 10 and e can be computed more accurately - --> $DIR/floating_point_log.rs:19:13 + --> tests/ui/floating_point_log.rs:19:13 | LL | let _ = x.log(std::f64::consts::E); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.ln()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:24:13 + --> tests/ui/floating_point_log.rs:24:13 | LL | let _ = (1f32 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` @@ -65,115 +65,115 @@ LL | let _ = (1f32 + 2.).ln(); = 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 + --> tests/ui/floating_point_log.rs:25:13 | LL | let _ = (1f32 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f32.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:26:13 + --> tests/ui/floating_point_log.rs:26:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:27:13 + --> tests/ui/floating_point_log.rs:27:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:28:13 + --> tests/ui/floating_point_log.rs:28:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:29:13 + --> tests/ui/floating_point_log.rs:29:13 | LL | let _ = (1.0 + x.powi(3) / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x.powi(3) / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:30:13 + --> tests/ui/floating_point_log.rs:30:13 | LL | let _ = (1.0 + (std::f32::consts::E - 1.0)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(std::f32::consts::E - 1.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:31:13 + --> tests/ui/floating_point_log.rs:31:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:32:13 + --> tests/ui/floating_point_log.rs:32:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:33:13 + --> tests/ui/floating_point_log.rs:33:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:34:13 + --> tests/ui/floating_point_log.rs:34:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:42:13 + --> tests/ui/floating_point_log.rs:42:13 | LL | let _ = (1f64 + 2.).ln(); | ^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:43:13 + --> tests/ui/floating_point_log.rs:43:13 | LL | let _ = (1f64 + 2.0).ln(); | ^^^^^^^^^^^^^^^^^ help: consider using: `2.0f64.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:44:13 + --> tests/ui/floating_point_log.rs:44:13 | LL | let _ = (1.0 + x).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:45:13 + --> tests/ui/floating_point_log.rs:45:13 | LL | let _ = (1.0 + x / 2.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:46:13 + --> tests/ui/floating_point_log.rs:46:13 | LL | let _ = (1.0 + x.powi(3)).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:47:13 + --> tests/ui/floating_point_log.rs:47:13 | LL | let _ = (x + 1.0).ln(); | ^^^^^^^^^^^^^^ help: consider using: `x.ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:48:13 + --> tests/ui/floating_point_log.rs:48:13 | LL | let _ = (x.powi(3) + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(3).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:49:13 + --> tests/ui/floating_point_log.rs:49:13 | LL | let _ = (x + 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x + 2.0).ln_1p()` error: ln(1 + x) can be computed more accurately - --> $DIR/floating_point_log.rs:50:13 + --> tests/ui/floating_point_log.rs:50:13 | LL | let _ = (x / 2.0 + 1.0).ln(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x / 2.0).ln_1p()` diff --git a/src/tools/clippy/tests/ui/floating_point_logbase.stderr b/src/tools/clippy/tests/ui/floating_point_logbase.stderr index 463bdb84c1595..8dfc57b133c68 100644 --- a/src/tools/clippy/tests/ui/floating_point_logbase.stderr +++ b/src/tools/clippy/tests/ui/floating_point_logbase.stderr @@ -1,5 +1,5 @@ error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:7:13 + --> tests/ui/floating_point_logbase.rs:7:13 | LL | let _ = x.ln() / y.ln(); | ^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` @@ -8,25 +8,25 @@ LL | let _ = x.ln() / y.ln(); = 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 + --> tests/ui/floating_point_logbase.rs:8:13 | LL | let _ = (x as f32).ln() / y.ln(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).log(y)` error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:9:13 + --> tests/ui/floating_point_logbase.rs:9:13 | LL | let _ = x.log2() / y.log2(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:10:13 + --> tests/ui/floating_point_logbase.rs:10:13 | LL | let _ = x.log10() / y.log10(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` error: log base can be expressed more clearly - --> $DIR/floating_point_logbase.rs:11:13 + --> tests/ui/floating_point_logbase.rs:11:13 | LL | let _ = x.log(5f32) / y.log(5f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.log(y)` 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 38dbefbe14c66..3e1a071de7377 100644 --- a/src/tools/clippy/tests/ui/floating_point_mul_add.stderr +++ b/src/tools/clippy/tests/ui/floating_point_mul_add.stderr @@ -1,5 +1,5 @@ error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:20:13 + --> tests/ui/floating_point_mul_add.rs:20:13 | LL | let _ = a * b + c; | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` @@ -8,73 +8,73 @@ LL | let _ = a * b + c; = 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 + --> tests/ui/floating_point_mul_add.rs:21:13 | LL | let _ = a * b - c; | ^^^^^^^^^ help: consider using: `a.mul_add(b, -c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:22:13 + --> tests/ui/floating_point_mul_add.rs:22:13 | LL | let _ = c + a * b; | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:23:13 + --> tests/ui/floating_point_mul_add.rs:23:13 | LL | let _ = c - a * b; | ^^^^^^^^^ help: consider using: `a.mul_add(-b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:24:13 + --> tests/ui/floating_point_mul_add.rs:24:13 | LL | let _ = a + 2.0 * 4.0; | ^^^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4.0, a)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:25:13 + --> tests/ui/floating_point_mul_add.rs:25:13 | LL | let _ = a + 2. * 4.; | ^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4., a)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:27:13 + --> tests/ui/floating_point_mul_add.rs:27:13 | LL | let _ = (a * b) + c; | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:28:13 + --> tests/ui/floating_point_mul_add.rs:28:13 | LL | let _ = c + (a * b); | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:29:13 + --> tests/ui/floating_point_mul_add.rs:29:13 | LL | let _ = a * b * c + d; | ^^^^^^^^^^^^^ help: consider using: `(a * b).mul_add(c, d)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:31:13 + --> tests/ui/floating_point_mul_add.rs:31:13 | LL | let _ = a.mul_add(b, c) * a.mul_add(b, c) + a.mul_add(b, c) + c; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `a.mul_add(b, c).mul_add(a.mul_add(b, c), a.mul_add(b, c))` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:32:13 + --> tests/ui/floating_point_mul_add.rs:32:13 | LL | let _ = 1234.567_f64 * 45.67834_f64 + 0.0004_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1234.567_f64.mul_add(45.67834_f64, 0.0004_f64)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:34:13 + --> tests/ui/floating_point_mul_add.rs:34:13 | LL | let _ = (a * a + b).sqrt(); | ^^^^^^^^^^^ help: consider using: `a.mul_add(a, b)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_mul_add.rs:37:13 + --> tests/ui/floating_point_mul_add.rs:37:13 | LL | let _ = a - (b * u as f64); | ^^^^^^^^^^^^^^^^^^ help: consider using: `b.mul_add(-(u as f64), a)` diff --git a/src/tools/clippy/tests/ui/floating_point_powf.stderr b/src/tools/clippy/tests/ui/floating_point_powf.stderr index 0ff8f82d9a7dd..bd3fa771fe50e 100644 --- a/src/tools/clippy/tests/ui/floating_point_powf.stderr +++ b/src/tools/clippy/tests/ui/floating_point_powf.stderr @@ -1,5 +1,5 @@ error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:6:13 + --> tests/ui/floating_point_powf.rs:6:13 | LL | let _ = 2f32.powf(x); | ^^^^^^^^^^^^ help: consider using: `x.exp2()` @@ -8,43 +8,43 @@ LL | let _ = 2f32.powf(x); = 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 + --> tests/ui/floating_point_powf.rs:7:13 | LL | let _ = 2f32.powf(3.1); | ^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:8:13 + --> tests/ui/floating_point_powf.rs:8:13 | LL | let _ = 2f32.powf(-3.1); | ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:9:13 + --> tests/ui/floating_point_powf.rs:9:13 | LL | let _ = std::f32::consts::E.powf(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:10:13 + --> tests/ui/floating_point_powf.rs:10:13 | LL | let _ = std::f32::consts::E.powf(3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f32.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:11:13 + --> tests/ui/floating_point_powf.rs:11:13 | LL | let _ = std::f32::consts::E.powf(-3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f32).exp()` error: square-root of a number can be computed more efficiently and accurately - --> $DIR/floating_point_powf.rs:12:13 + --> tests/ui/floating_point_powf.rs:12:13 | LL | let _ = x.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:13:13 + --> tests/ui/floating_point_powf.rs:13:13 | LL | let _ = x.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` @@ -53,139 +53,139 @@ LL | let _ = x.powf(1.0 / 3.0); = 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 + --> tests/ui/floating_point_powf.rs:14:13 | LL | let _ = (x as f32).powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).cbrt()` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:15:13 + --> tests/ui/floating_point_powf.rs:15:13 | LL | let _ = x.powf(3.0); | ^^^^^^^^^^^ help: consider using: `x.powi(3)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:16:13 + --> tests/ui/floating_point_powf.rs:16:13 | LL | let _ = x.powf(-2.0); | ^^^^^^^^^^^^ help: consider using: `x.powi(-2)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:17:13 + --> tests/ui/floating_point_powf.rs:17:13 | LL | let _ = x.powf(16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(16_777_215)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:18:13 + --> tests/ui/floating_point_powf.rs:18:13 | LL | let _ = x.powf(-16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-16_777_215)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:19:13 + --> tests/ui/floating_point_powf.rs:19:13 | LL | let _ = (x as f32).powf(-16_777_215.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(-16_777_215)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:20:13 + --> tests/ui/floating_point_powf.rs:20:13 | LL | let _ = (x as f32).powf(3.0); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x as f32).powi(3)` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:21:13 + --> tests/ui/floating_point_powf.rs:21:13 | LL | let _ = (1.5_f32 + 1.0).powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(1.5_f32 + 1.0).cbrt()` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:22:13 + --> tests/ui/floating_point_powf.rs:22:13 | LL | let _ = 1.5_f64.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.cbrt()` error: square-root of a number can be computed more efficiently and accurately - --> $DIR/floating_point_powf.rs:23:13 + --> tests/ui/floating_point_powf.rs:23:13 | LL | let _ = 1.5_f64.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.sqrt()` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:24:13 + --> tests/ui/floating_point_powf.rs:24:13 | LL | let _ = 1.5_f64.powf(3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `1.5_f64.powi(3)` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:33:13 + --> tests/ui/floating_point_powf.rs:33:13 | LL | let _ = 2f64.powf(x); | ^^^^^^^^^^^^ help: consider using: `x.exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:34:13 + --> tests/ui/floating_point_powf.rs:34:13 | LL | let _ = 2f64.powf(3.1); | ^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:35:13 + --> tests/ui/floating_point_powf.rs:35:13 | LL | let _ = 2f64.powf(-3.1); | ^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp2()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:36:13 + --> tests/ui/floating_point_powf.rs:36:13 | LL | let _ = std::f64::consts::E.powf(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:37:13 + --> tests/ui/floating_point_powf.rs:37:13 | LL | let _ = std::f64::consts::E.powf(3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `3.1f64.exp()` error: exponent for bases 2 and e can be computed more accurately - --> $DIR/floating_point_powf.rs:38:13 + --> tests/ui/floating_point_powf.rs:38:13 | LL | let _ = std::f64::consts::E.powf(-3.1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-3.1f64).exp()` error: square-root of a number can be computed more efficiently and accurately - --> $DIR/floating_point_powf.rs:39:13 + --> tests/ui/floating_point_powf.rs:39:13 | LL | let _ = x.powf(1.0 / 2.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.sqrt()` error: cube-root of a number can be computed more accurately - --> $DIR/floating_point_powf.rs:40:13 + --> tests/ui/floating_point_powf.rs:40:13 | LL | let _ = x.powf(1.0 / 3.0); | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:41:13 + --> tests/ui/floating_point_powf.rs:41:13 | LL | let _ = x.powf(3.0); | ^^^^^^^^^^^ help: consider using: `x.powi(3)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:42:13 + --> tests/ui/floating_point_powf.rs:42:13 | LL | let _ = x.powf(-2.0); | ^^^^^^^^^^^^ help: consider using: `x.powi(-2)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:43:13 + --> tests/ui/floating_point_powf.rs:43:13 | LL | let _ = x.powf(-2_147_483_648.0); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(-2_147_483_648)` error: exponentiation with integer powers can be computed more efficiently - --> $DIR/floating_point_powf.rs:44:13 + --> tests/ui/floating_point_powf.rs:44:13 | LL | let _ = x.powf(2_147_483_647.0); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.powi(2_147_483_647)` diff --git a/src/tools/clippy/tests/ui/floating_point_powi.stderr b/src/tools/clippy/tests/ui/floating_point_powi.stderr index ddf20ff40ba26..dfed20cb8c5a4 100644 --- a/src/tools/clippy/tests/ui/floating_point_powi.stderr +++ b/src/tools/clippy/tests/ui/floating_point_powi.stderr @@ -1,5 +1,5 @@ error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:9:13 + --> tests/ui/floating_point_powi.rs:9:13 | LL | let _ = x.powi(2) + y; | ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)` @@ -8,79 +8,79 @@ LL | let _ = x.powi(2) + y; = 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 + --> tests/ui/floating_point_powi.rs:10:13 | LL | let _ = x.powi(2) - y; | ^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, -y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:11:13 + --> tests/ui/floating_point_powi.rs:11:13 | LL | let _ = x + y.powi(2); | ^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:12:13 + --> tests/ui/floating_point_powi.rs:12:13 | LL | let _ = x - y.powi(2); | ^^^^^^^^^^^^^ help: consider using: `y.mul_add(-y, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:13:13 + --> tests/ui/floating_point_powi.rs:13:13 | LL | let _ = x + (y as f32).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y as f32).mul_add(y as f32, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:14:13 + --> tests/ui/floating_point_powi.rs:14:13 | LL | let _ = (x.powi(2) + y).sqrt(); | ^^^^^^^^^^^^^^^ help: consider using: `x.mul_add(x, y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:15:13 + --> tests/ui/floating_point_powi.rs:15:13 | LL | let _ = (x + y.powi(2)).sqrt(); | ^^^^^^^^^^^^^^^ help: consider using: `y.mul_add(y, x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:17:13 + --> tests/ui/floating_point_powi.rs:17:13 | LL | let _ = (x - 1.0).powi(2) - y; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:18:13 + --> tests/ui/floating_point_powi.rs:18:13 | LL | let _ = (x - 1.0).powi(2) - y + 3.0; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -y)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:19:13 + --> tests/ui/floating_point_powi.rs:19:13 | LL | let _ = (x - 1.0).powi(2) - (y + 3.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(x - 1.0).mul_add(x - 1.0, -(y + 3.0))` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:20:13 + --> tests/ui/floating_point_powi.rs:20:13 | LL | let _ = x - (y + 1.0).powi(2); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0).mul_add(-(y + 1.0), x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:21:13 + --> tests/ui/floating_point_powi.rs:21:13 | LL | let _ = x - (3.0 * y).powi(2); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(3.0 * y).mul_add(-(3.0 * y), x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:22:13 + --> tests/ui/floating_point_powi.rs:22:13 | LL | let _ = x - (y + 1.0 + x).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0 + x).mul_add(-(y + 1.0 + x), x)` error: multiply and add expressions can be calculated more efficiently and accurately - --> $DIR/floating_point_powi.rs:23:13 + --> tests/ui/floating_point_powi.rs:23:13 | LL | let _ = x - (y + 1.0 + 2.0).powi(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(y + 1.0 + 2.0).mul_add(-(y + 1.0 + 2.0), x)` diff --git a/src/tools/clippy/tests/ui/floating_point_rad.stderr b/src/tools/clippy/tests/ui/floating_point_rad.stderr index e7b42de04bdfb..64674342c2b99 100644 --- a/src/tools/clippy/tests/ui/floating_point_rad.stderr +++ b/src/tools/clippy/tests/ui/floating_point_rad.stderr @@ -1,5 +1,5 @@ error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:11:13 + --> tests/ui/floating_point_rad.rs:11:13 | LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_radians()` @@ -8,43 +8,43 @@ LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; = 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 + --> tests/ui/floating_point_rad.rs:12:13 | LL | let _ = degrees as f64 * 180.0 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:17:13 + --> tests/ui/floating_point_rad.rs:17:13 | LL | let _ = x * 180f32 / std::f32::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:18:13 + --> tests/ui/floating_point_rad.rs:18:13 | LL | let _ = 90. * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_degrees()` error: conversion to degrees can be done more accurately - --> $DIR/floating_point_rad.rs:19:13 + --> tests/ui/floating_point_rad.rs:19:13 | LL | let _ = 90.5 * 180f64 / std::f64::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_degrees()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:20:13 + --> tests/ui/floating_point_rad.rs:20:13 | LL | let _ = x * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_radians()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:21:13 + --> tests/ui/floating_point_rad.rs:21:13 | LL | let _ = 90. * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_radians()` error: conversion to radians can be done more accurately - --> $DIR/floating_point_rad.rs:22:13 + --> tests/ui/floating_point_rad.rs:22:13 | LL | let _ = 90.5 * std::f32::consts::PI / 180f32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_radians()` diff --git a/src/tools/clippy/tests/ui/fn_address_comparisons.stderr b/src/tools/clippy/tests/ui/fn_address_comparisons.stderr index be7fa62f1b790..e6de7e358075d 100644 --- a/src/tools/clippy/tests/ui/fn_address_comparisons.stderr +++ b/src/tools/clippy/tests/ui/fn_address_comparisons.stderr @@ -1,5 +1,5 @@ error: comparing with a non-unique address of a function item - --> $DIR/fn_address_comparisons.rs:15:13 + --> tests/ui/fn_address_comparisons.rs:15:13 | LL | let _ = f == a; | ^^^^^^ @@ -8,7 +8,7 @@ LL | let _ = f == a; = 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 + --> tests/ui/fn_address_comparisons.rs:18:13 | LL | let _ = f != a; | ^^^^^^ 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 f529d8cc4110b..f211a435af989 100644 --- a/src/tools/clippy/tests/ui/fn_params_excessive_bools.stderr +++ b/src/tools/clippy/tests/ui/fn_params_excessive_bools.stderr @@ -1,5 +1,5 @@ error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:19:1 + --> tests/ui/fn_params_excessive_bools.rs:19:1 | LL | fn g(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | fn g(_: bool, _: bool, _: bool, _: bool) {} = 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 + --> tests/ui/fn_params_excessive_bools.rs:23:1 | LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn t(_: S, _: S, _: Box, _: Vec, _: bool, _: bool, _: bool, _: bool = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:29:5 + --> tests/ui/fn_params_excessive_bools.rs:29:5 | LL | fn f(_: bool, _: bool, _: bool, _: bool); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn f(_: bool, _: bool, _: bool, _: bool); = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:34:5 + --> tests/ui/fn_params_excessive_bools.rs:34:5 | LL | fn i(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | fn i(_: bool, _: bool, _: bool, _: bool) {} = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:39:5 + --> tests/ui/fn_params_excessive_bools.rs:39:5 | LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {} = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:55:5 + --> tests/ui/fn_params_excessive_bools.rs:55:5 | LL | / fn n(_: bool, _: u32, _: bool, _: Box, _: bool, _: bool) { LL | | @@ -53,7 +53,7 @@ LL | | } = help: consider refactoring bools into two-variant enums error: more than 3 bools in function parameters - --> $DIR/fn_params_excessive_bools.rs:57:9 + --> tests/ui/fn_params_excessive_bools.rs:57:9 | LL | fn nn(_: bool, _: bool, _: bool, _: bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr index ea08d8c9cc162..65991a3989ac6 100644 --- a/src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr +++ b/src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr @@ -1,5 +1,5 @@ error: casting function pointer `foo` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:10:13 + --> tests/ui/fn_to_numeric_cast.rs:10:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` @@ -8,13 +8,13 @@ LL | let _ = foo as i8; = 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:11:13 + --> tests/ui/fn_to_numeric_cast.rs:11:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i32` - --> $DIR/fn_to_numeric_cast.rs:12:13 + --> tests/ui/fn_to_numeric_cast.rs:12:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: try: `foo as usize` @@ -23,121 +23,121 @@ LL | let _ = foo as i32; = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]` error: casting function pointer `foo` to `i64` - --> $DIR/fn_to_numeric_cast.rs:13:13 + --> tests/ui/fn_to_numeric_cast.rs:13:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i128` - --> $DIR/fn_to_numeric_cast.rs:14:13 + --> tests/ui/fn_to_numeric_cast.rs:14:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `isize` - --> $DIR/fn_to_numeric_cast.rs:15:13 + --> tests/ui/fn_to_numeric_cast.rs:15:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:17:13 + --> tests/ui/fn_to_numeric_cast.rs:17:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:18:13 + --> tests/ui/fn_to_numeric_cast.rs:18:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u32` - --> $DIR/fn_to_numeric_cast.rs:19:13 + --> tests/ui/fn_to_numeric_cast.rs:19:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u64` - --> $DIR/fn_to_numeric_cast.rs:20:13 + --> tests/ui/fn_to_numeric_cast.rs:20:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u128` - --> $DIR/fn_to_numeric_cast.rs:21:13 + --> tests/ui/fn_to_numeric_cast.rs:21:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `abc` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:34:13 + --> tests/ui/fn_to_numeric_cast.rs:34:13 | LL | let _ = abc as i8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:35:13 + --> tests/ui/fn_to_numeric_cast.rs:35:13 | LL | let _ = abc as i16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i32` - --> $DIR/fn_to_numeric_cast.rs:36:13 + --> tests/ui/fn_to_numeric_cast.rs:36:13 | LL | let _ = abc as i32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i64` - --> $DIR/fn_to_numeric_cast.rs:37:13 + --> tests/ui/fn_to_numeric_cast.rs:37:13 | LL | let _ = abc as i64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i128` - --> $DIR/fn_to_numeric_cast.rs:38:13 + --> tests/ui/fn_to_numeric_cast.rs:38:13 | LL | let _ = abc as i128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `isize` - --> $DIR/fn_to_numeric_cast.rs:39:13 + --> tests/ui/fn_to_numeric_cast.rs:39:13 | LL | let _ = abc as isize; | ^^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:41:13 + --> tests/ui/fn_to_numeric_cast.rs:41:13 | LL | let _ = abc as u8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:42:13 + --> tests/ui/fn_to_numeric_cast.rs:42:13 | LL | let _ = abc as u16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u32` - --> $DIR/fn_to_numeric_cast.rs:43:13 + --> tests/ui/fn_to_numeric_cast.rs:43:13 | LL | let _ = abc as u32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u64` - --> $DIR/fn_to_numeric_cast.rs:44:13 + --> tests/ui/fn_to_numeric_cast.rs:44:13 | LL | let _ = abc as u64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u128` - --> $DIR/fn_to_numeric_cast.rs:45:13 + --> tests/ui/fn_to_numeric_cast.rs:45:13 | LL | let _ = abc as u128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `f` to `i32` - --> $DIR/fn_to_numeric_cast.rs:52:5 + --> tests/ui/fn_to_numeric_cast.rs:52:5 | LL | f as i32 | ^^^^^^^^ help: try: `f as usize` diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr index 62f3bfa70ea50..58f55f19a745f 100644 --- a/src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr +++ b/src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr @@ -1,5 +1,5 @@ error: casting function pointer `foo` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:10:13 + --> tests/ui/fn_to_numeric_cast.rs:10:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: try: `foo as usize` @@ -8,19 +8,19 @@ LL | let _ = foo as i8; = 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:11:13 + --> tests/ui/fn_to_numeric_cast.rs:11:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:12:13 + --> tests/ui/fn_to_numeric_cast.rs:12:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `i64` - --> $DIR/fn_to_numeric_cast.rs:13:13 + --> tests/ui/fn_to_numeric_cast.rs:13:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: try: `foo as usize` @@ -29,115 +29,115 @@ LL | let _ = foo as i64; = 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:14:13 + --> tests/ui/fn_to_numeric_cast.rs:14:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `isize` - --> $DIR/fn_to_numeric_cast.rs:15:13 + --> tests/ui/fn_to_numeric_cast.rs:15:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:17:13 + --> tests/ui/fn_to_numeric_cast.rs:17:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:18:13 + --> tests/ui/fn_to_numeric_cast.rs:18:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:19:13 + --> tests/ui/fn_to_numeric_cast.rs:19:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u64` - --> $DIR/fn_to_numeric_cast.rs:20:13 + --> tests/ui/fn_to_numeric_cast.rs:20:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `foo` to `u128` - --> $DIR/fn_to_numeric_cast.rs:21:13 + --> tests/ui/fn_to_numeric_cast.rs:21:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: try: `foo as usize` error: casting function pointer `abc` to `i8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:34:13 + --> tests/ui/fn_to_numeric_cast.rs:34:13 | LL | let _ = abc as i8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:35:13 + --> tests/ui/fn_to_numeric_cast.rs:35:13 | LL | let _ = abc as i16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:36:13 + --> tests/ui/fn_to_numeric_cast.rs:36:13 | LL | let _ = abc as i32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i64` - --> $DIR/fn_to_numeric_cast.rs:37:13 + --> tests/ui/fn_to_numeric_cast.rs:37:13 | LL | let _ = abc as i64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `i128` - --> $DIR/fn_to_numeric_cast.rs:38:13 + --> tests/ui/fn_to_numeric_cast.rs:38:13 | LL | let _ = abc as i128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `isize` - --> $DIR/fn_to_numeric_cast.rs:39:13 + --> tests/ui/fn_to_numeric_cast.rs:39:13 | LL | let _ = abc as isize; | ^^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u8`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:41:13 + --> tests/ui/fn_to_numeric_cast.rs:41:13 | LL | let _ = abc as u8; | ^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u16`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:42:13 + --> tests/ui/fn_to_numeric_cast.rs:42:13 | LL | let _ = abc as u16; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:43:13 + --> tests/ui/fn_to_numeric_cast.rs:43:13 | LL | let _ = abc as u32; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u64` - --> $DIR/fn_to_numeric_cast.rs:44:13 + --> tests/ui/fn_to_numeric_cast.rs:44:13 | LL | let _ = abc as u64; | ^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `abc` to `u128` - --> $DIR/fn_to_numeric_cast.rs:45:13 + --> tests/ui/fn_to_numeric_cast.rs:45:13 | LL | let _ = abc as u128; | ^^^^^^^^^^^ help: try: `abc as usize` error: casting function pointer `f` to `i32`, which truncates the value - --> $DIR/fn_to_numeric_cast.rs:52:5 + --> tests/ui/fn_to_numeric_cast.rs:52:5 | LL | f as i32 | ^^^^^^^^ help: try: `f as usize` 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 a1514c87b5ec8..e5bb8d1326975 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 @@ -1,5 +1,5 @@ error: casting function pointer `foo` to `i8` - --> $DIR/fn_to_numeric_cast_any.rs:23:13 + --> tests/ui/fn_to_numeric_cast_any.rs:23:13 | LL | let _ = foo as i8; | ^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i8` @@ -8,97 +8,97 @@ LL | let _ = foo as i8; = 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 + --> tests/ui/fn_to_numeric_cast_any.rs:26:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i16` error: casting function pointer `foo` to `i32` - --> $DIR/fn_to_numeric_cast_any.rs:28:13 + --> tests/ui/fn_to_numeric_cast_any.rs:28:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i32` error: casting function pointer `foo` to `i64` - --> $DIR/fn_to_numeric_cast_any.rs:30:13 + --> tests/ui/fn_to_numeric_cast_any.rs:30:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i64` error: casting function pointer `foo` to `i128` - --> $DIR/fn_to_numeric_cast_any.rs:32:13 + --> tests/ui/fn_to_numeric_cast_any.rs:32:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as i128` error: casting function pointer `foo` to `isize` - --> $DIR/fn_to_numeric_cast_any.rs:34:13 + --> tests/ui/fn_to_numeric_cast_any.rs:34:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as isize` error: casting function pointer `foo` to `u8` - --> $DIR/fn_to_numeric_cast_any.rs:37:13 + --> tests/ui/fn_to_numeric_cast_any.rs:37:13 | LL | let _ = foo as u8; | ^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u8` error: casting function pointer `foo` to `u16` - --> $DIR/fn_to_numeric_cast_any.rs:39:13 + --> tests/ui/fn_to_numeric_cast_any.rs:39:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u16` error: casting function pointer `foo` to `u32` - --> $DIR/fn_to_numeric_cast_any.rs:41:13 + --> tests/ui/fn_to_numeric_cast_any.rs:41:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u32` error: casting function pointer `foo` to `u64` - --> $DIR/fn_to_numeric_cast_any.rs:43:13 + --> tests/ui/fn_to_numeric_cast_any.rs:43:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u64` error: casting function pointer `foo` to `u128` - --> $DIR/fn_to_numeric_cast_any.rs:45:13 + --> tests/ui/fn_to_numeric_cast_any.rs:45:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as u128` error: casting function pointer `foo` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:47:13 + --> tests/ui/fn_to_numeric_cast_any.rs:47:13 | LL | let _ = foo as usize; | ^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as usize` error: casting function pointer `Struct::static_method` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:52:13 + --> tests/ui/fn_to_numeric_cast_any.rs:52:13 | LL | let _ = Struct::static_method as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `Struct::static_method() as usize` error: casting function pointer `f` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:57:5 + --> tests/ui/fn_to_numeric_cast_any.rs:57:5 | LL | f as usize | ^^^^^^^^^^ help: did you mean to invoke the function?: `f() as usize` error: casting function pointer `T::static_method` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:62:5 + --> tests/ui/fn_to_numeric_cast_any.rs:62:5 | LL | T::static_method as usize | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `T::static_method() as usize` error: casting function pointer `(clos as fn(u32) -> u32)` to `usize` - --> $DIR/fn_to_numeric_cast_any.rs:69:13 + --> tests/ui/fn_to_numeric_cast_any.rs:69:13 | LL | let _ = (clos as fn(u32) -> u32) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `(clos as fn(u32) -> u32)() as usize` error: casting function pointer `foo` to `*const ()` - --> $DIR/fn_to_numeric_cast_any.rs:74:13 + --> tests/ui/fn_to_numeric_cast_any.rs:74:13 | LL | let _ = foo as *const (); | ^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `foo() as *const ()` diff --git a/src/tools/clippy/tests/ui/for_kv_map.stderr b/src/tools/clippy/tests/ui/for_kv_map.stderr index d29617e24f244..f4ce473d095bf 100644 --- a/src/tools/clippy/tests/ui/for_kv_map.stderr +++ b/src/tools/clippy/tests/ui/for_kv_map.stderr @@ -1,5 +1,5 @@ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:9:19 + --> tests/ui/for_kv_map.rs:9:19 | LL | for (_, v) in &m { | ^^ @@ -12,7 +12,7 @@ LL | for v in m.values() { | ~ ~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:16:19 + --> tests/ui/for_kv_map.rs:16:19 | LL | for (_, v) in &*m { | ^^^ @@ -23,7 +23,7 @@ LL | for v in (*m).values() { | ~ ~~~~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:25:19 + --> tests/ui/for_kv_map.rs:25:19 | LL | for (_, v) in &mut m { | ^^^^^^ @@ -34,7 +34,7 @@ LL | for v in m.values_mut() { | ~ ~~~~~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> $DIR/for_kv_map.rs:31:19 + --> tests/ui/for_kv_map.rs:31:19 | LL | for (_, v) in &mut *m { | ^^^^^^^ @@ -45,7 +45,7 @@ LL | for v in (*m).values_mut() { | ~ ~~~~~~~~~~~~~~~~~ error: you seem to want to iterate on a map's keys - --> $DIR/for_kv_map.rs:38:24 + --> tests/ui/for_kv_map.rs:38:24 | LL | for (k, _value) in rm { | ^^ diff --git a/src/tools/clippy/tests/ui/forget_non_drop.stderr b/src/tools/clippy/tests/ui/forget_non_drop.stderr index c0fa433c479df..e121984154c73 100644 --- a/src/tools/clippy/tests/ui/forget_non_drop.stderr +++ b/src/tools/clippy/tests/ui/forget_non_drop.stderr @@ -1,11 +1,11 @@ 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:13:5 + --> tests/ui/forget_non_drop.rs:13:5 | LL | forget(Foo); | ^^^^^^^^^^^ | note: argument has type `main::Foo` - --> $DIR/forget_non_drop.rs:13:12 + --> tests/ui/forget_non_drop.rs:13:12 | LL | forget(Foo); | ^^^ @@ -13,13 +13,13 @@ LL | forget(Foo); = 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 + --> tests/ui/forget_non_drop.rs:25:5 | LL | forget(Baz(Foo)); | ^^^^^^^^^^^^^^^^ | note: argument has type `main::Baz` - --> $DIR/forget_non_drop.rs:25:12 + --> tests/ui/forget_non_drop.rs:25:12 | LL | forget(Baz(Foo)); | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/format.stderr b/src/tools/clippy/tests/ui/format.stderr index e02fdb1e41519..faa80b48000f9 100644 --- a/src/tools/clippy/tests/ui/format.stderr +++ b/src/tools/clippy/tests/ui/format.stderr @@ -1,5 +1,5 @@ error: useless use of `format!` - --> $DIR/format.rs:19:5 + --> tests/ui/format.rs:19:5 | LL | format!("foo"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` @@ -8,19 +8,19 @@ LL | format!("foo"); = help: to override `-D warnings` add `#[allow(clippy::useless_format)]` error: useless use of `format!` - --> $DIR/format.rs:20:5 + --> tests/ui/format.rs:20:5 | LL | format!("{{}}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()` error: useless use of `format!` - --> $DIR/format.rs:21:5 + --> tests/ui/format.rs:21:5 | LL | format!("{{}} abc {{}}"); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()` error: useless use of `format!` - --> $DIR/format.rs:22:5 + --> tests/ui/format.rs:22:5 | LL | / format!( LL | | r##"foo {{}} @@ -35,67 +35,67 @@ LL ~ " bar"##.to_string(); | error: useless use of `format!` - --> $DIR/format.rs:27:13 + --> tests/ui/format.rs:27:13 | LL | let _ = format!(""); | ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()` error: useless use of `format!` - --> $DIR/format.rs:29:5 + --> tests/ui/format.rs:29:5 | LL | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` error: useless use of `format!` - --> $DIR/format.rs:37:5 + --> tests/ui/format.rs:37:5 | LL | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()` error: useless use of `format!` - --> $DIR/format.rs:67:5 + --> tests/ui/format.rs:67:5 | LL | format!("{}", 42.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()` error: useless use of `format!` - --> $DIR/format.rs:69:5 + --> tests/ui/format.rs:69:5 | LL | format!("{}", x.display().to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()` error: useless use of `format!` - --> $DIR/format.rs:73:18 + --> tests/ui/format.rs:73:18 | LL | let _ = Some(format!("{}", a + "bar")); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"` error: useless use of `format!` - --> $DIR/format.rs:77:22 + --> tests/ui/format.rs:77:22 | LL | let _s: String = format!("{}", &*v.join("\n")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("\n")).to_string()` error: useless use of `format!` - --> $DIR/format.rs:83:13 + --> tests/ui/format.rs:83:13 | LL | let _ = format!("{x}"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` - --> $DIR/format.rs:85:13 + --> tests/ui/format.rs:85:13 | LL | let _ = format!("{y}", y = x); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` - --> $DIR/format.rs:89:13 + --> tests/ui/format.rs:89:13 | LL | let _ = format!("{abc}"); | ^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `abc.to_string()` error: useless use of `format!` - --> $DIR/format.rs:91:13 + --> tests/ui/format.rs:91:13 | LL | let _ = format!("{xx}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `xx.to_string()` diff --git a/src/tools/clippy/tests/ui/format_args.stderr b/src/tools/clippy/tests/ui/format_args.stderr index 2f1714296d6c8..f20cf9eca2f9d 100644 --- a/src/tools/clippy/tests/ui/format_args.stderr +++ b/src/tools/clippy/tests/ui/format_args.stderr @@ -1,5 +1,5 @@ error: `to_string` applied to a type that implements `Display` in `format!` args - --> $DIR/format_args.rs:77:72 + --> tests/ui/format_args.rs:77:72 | LL | let _ = format!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this @@ -8,145 +8,145 @@ LL | let _ = format!("error: something failed at {}", Location::caller().to_ = 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:81:27 + --> tests/ui/format_args.rs:81:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `writeln!` args - --> $DIR/format_args.rs:86:27 + --> tests/ui/format_args.rs:86:27 | LL | Location::caller().to_string() | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:88:63 + --> tests/ui/format_args.rs:88:63 | LL | print!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:89:65 + --> tests/ui/format_args.rs:89:65 | LL | println!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `eprint!` args - --> $DIR/format_args.rs:90:64 + --> tests/ui/format_args.rs:90:64 | LL | eprint!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `eprintln!` args - --> $DIR/format_args.rs:91:66 + --> tests/ui/format_args.rs:91:66 | LL | eprintln!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `format_args!` args - --> $DIR/format_args.rs:92:77 + --> tests/ui/format_args.rs:92:77 | LL | let _ = format_args!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert!` args - --> $DIR/format_args.rs:93:70 + --> tests/ui/format_args.rs:93:70 | LL | assert!(true, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert_eq!` args - --> $DIR/format_args.rs:94:73 + --> tests/ui/format_args.rs:94:73 | LL | assert_eq!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `assert_ne!` args - --> $DIR/format_args.rs:95:73 + --> tests/ui/format_args.rs:95:73 | LL | assert_ne!(0, 0, "error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `panic!` args - --> $DIR/format_args.rs:96:63 + --> tests/ui/format_args.rs:96:63 | LL | panic!("error: something failed at {}", Location::caller().to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:97:20 + --> tests/ui/format_args.rs:97:20 | LL | println!("{}", X(1).to_string()); | ^^^^^^^^^^^^^^^^ help: use this: `*X(1)` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:98:20 + --> tests/ui/format_args.rs:98:20 | LL | println!("{}", Y(&X(1)).to_string()); | ^^^^^^^^^^^^^^^^^^^^ help: use this: `***Y(&X(1))` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:99:24 + --> tests/ui/format_args.rs:99:24 | LL | println!("{}", Z(1).to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:100:20 + --> tests/ui/format_args.rs:100:20 | LL | println!("{}", x.to_string()); | ^^^^^^^^^^^^^ help: use this: `**x` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:101:20 + --> tests/ui/format_args.rs:101:20 | LL | println!("{}", x_ref.to_string()); | ^^^^^^^^^^^^^^^^^ help: use this: `***x_ref` error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:103:39 + --> tests/ui/format_args.rs:103:39 | LL | println!("{foo}{bar}", foo = "foo".to_string(), bar = "bar"); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:104:52 + --> tests/ui/format_args.rs:104:52 | LL | println!("{foo}{bar}", foo = "foo", bar = "bar".to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:105:39 + --> tests/ui/format_args.rs:105:39 | LL | println!("{foo}{bar}", bar = "bar".to_string(), foo = "foo"); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:106:52 + --> tests/ui/format_args.rs:106:52 | LL | println!("{foo}{bar}", bar = "bar", foo = "foo".to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:118:37 + --> tests/ui/format_args.rs:118:37 | LL | print!("{}", (Location::caller().to_string())); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args - --> $DIR/format_args.rs:119:39 + --> tests/ui/format_args.rs:119:39 | LL | print!("{}", ((Location::caller()).to_string())); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `format!` args - --> $DIR/format_args.rs:147:38 + --> tests/ui/format_args.rs:147:38 | LL | let x = format!("{} {}", a, b.to_string()); | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `println!` args - --> $DIR/format_args.rs:161:24 + --> tests/ui/format_args.rs:161:24 | LL | println!("{}", original[..10].to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use this: `&original[..10]` diff --git a/src/tools/clippy/tests/ui/format_args_unfixable.stderr b/src/tools/clippy/tests/ui/format_args_unfixable.stderr index 3ffe2f6c89440..20cd0bb8c5541 100644 --- a/src/tools/clippy/tests/ui/format_args_unfixable.stderr +++ b/src/tools/clippy/tests/ui/format_args_unfixable.stderr @@ -1,5 +1,5 @@ error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:26:5 + --> tests/ui/format_args_unfixable.rs:26:5 | LL | println!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | println!("error: {}", format!("something failed at {}", Location::calle = help: to override `-D warnings` add `#[allow(clippy::format_in_format_args)]` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:28:5 + --> tests/ui/format_args_unfixable.rs:28:5 | LL | println!("{}: {}", error, format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | println!("{}: {}", error, format!("something failed at {}", Location::c = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:30:5 + --> tests/ui/format_args_unfixable.rs:30:5 | LL | println!("{:?}: {}", error, format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | println!("{:?}: {}", error, format!("something failed at {}", Location: = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:32:5 + --> tests/ui/format_args_unfixable.rs:32:5 | LL | println!("{{}}: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | println!("{{}}: {}", format!("something failed at {}", Location::caller = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:34:5 + --> tests/ui/format_args_unfixable.rs:34:5 | LL | println!(r#"error: "{}""#, format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | println!(r#"error: "{}""#, format!("something failed at {}", Location:: = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:36:5 + --> tests/ui/format_args_unfixable.rs:36:5 | LL | println!("error: {}", format!(r#"something failed at "{}""#, Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | println!("error: {}", format!(r#"something failed at "{}""#, Location:: = help: or consider changing `format!` to `format_args!` error: `format!` in `println!` args - --> $DIR/format_args_unfixable.rs:38:5 + --> tests/ui/format_args_unfixable.rs:38:5 | LL | println!("error: {}", format!("something failed at {} {0}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | println!("error: {}", format!("something failed at {} {0}", Location::c = help: or consider changing `format!` to `format_args!` error: `format!` in `format!` args - --> $DIR/format_args_unfixable.rs:40:13 + --> tests/ui/format_args_unfixable.rs:40:13 | LL | let _ = format!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = format!("error: {}", format!("something failed at {}", Location = help: or consider changing `format!` to `format_args!` error: `format!` in `write!` args - --> $DIR/format_args_unfixable.rs:42:13 + --> tests/ui/format_args_unfixable.rs:42:13 | LL | let _ = write!( | _____________^ @@ -88,7 +88,7 @@ LL | | ); = help: or consider changing `format!` to `format_args!` error: `format!` in `writeln!` args - --> $DIR/format_args_unfixable.rs:48:13 + --> tests/ui/format_args_unfixable.rs:48:13 | LL | let _ = writeln!( | _____________^ @@ -103,7 +103,7 @@ LL | | ); = help: or consider changing `format!` to `format_args!` error: `format!` in `print!` args - --> $DIR/format_args_unfixable.rs:54:5 + --> tests/ui/format_args_unfixable.rs:54:5 | LL | print!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | print!("error: {}", format!("something failed at {}", Location::caller( = help: or consider changing `format!` to `format_args!` error: `format!` in `eprint!` args - --> $DIR/format_args_unfixable.rs:56:5 + --> tests/ui/format_args_unfixable.rs:56:5 | LL | eprint!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | eprint!("error: {}", format!("something failed at {}", Location::caller = help: or consider changing `format!` to `format_args!` error: `format!` in `eprintln!` args - --> $DIR/format_args_unfixable.rs:58:5 + --> tests/ui/format_args_unfixable.rs:58:5 | LL | eprintln!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | eprintln!("error: {}", format!("something failed at {}", Location::call = help: or consider changing `format!` to `format_args!` error: `format!` in `format_args!` args - --> $DIR/format_args_unfixable.rs:60:13 + --> tests/ui/format_args_unfixable.rs:60:13 | LL | let _ = format_args!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL | let _ = format_args!("error: {}", format!("something failed at {}", Loc = help: or consider changing `format!` to `format_args!` error: `format!` in `assert!` args - --> $DIR/format_args_unfixable.rs:62:5 + --> tests/ui/format_args_unfixable.rs:62:5 | LL | assert!(true, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +148,7 @@ LL | assert!(true, "error: {}", format!("something failed at {}", Location:: = help: or consider changing `format!` to `format_args!` error: `format!` in `assert_eq!` args - --> $DIR/format_args_unfixable.rs:64:5 + --> tests/ui/format_args_unfixable.rs:64:5 | LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: or consider changing `format!` to `format_args!` error: `format!` in `assert_ne!` args - --> $DIR/format_args_unfixable.rs:66:5 + --> tests/ui/format_args_unfixable.rs:66:5 | LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: or consider changing `format!` to `format_args!` error: `format!` in `panic!` args - --> $DIR/format_args_unfixable.rs:68:5 + --> tests/ui/format_args_unfixable.rs:68:5 | LL | panic!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/format_collect.stderr b/src/tools/clippy/tests/ui/format_collect.stderr index 340218ccf2c9f..863b457a7905c 100644 --- a/src/tools/clippy/tests/ui/format_collect.stderr +++ b/src/tools/clippy/tests/ui/format_collect.stderr @@ -1,16 +1,16 @@ error: use of `format!` to build up a string from an iterator - --> $DIR/format_collect.rs:5:5 + --> tests/ui/format_collect.rs:5:5 | LL | bytes.iter().map(|b| format!("{b:02X}")).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: call `fold` instead - --> $DIR/format_collect.rs:5:18 + --> tests/ui/format_collect.rs:5:18 | LL | bytes.iter().map(|b| format!("{b:02X}")).collect() | ^^^ help: ... and use the `write!` macro here - --> $DIR/format_collect.rs:5:26 + --> tests/ui/format_collect.rs:5:26 | LL | bytes.iter().map(|b| format!("{b:02X}")).collect() | ^^^^^^^^^^^^^^^^^^ @@ -19,25 +19,25 @@ LL | bytes.iter().map(|b| format!("{b:02X}")).collect() = 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 + --> tests/ui/format_collect.rs:11:5 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: call `fold` instead - --> $DIR/format_collect.rs:11:18 + --> tests/ui/format_collect.rs:11:18 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^ help: ... and use the `write!` macro here - --> $DIR/format_collect.rs:11:32 + --> tests/ui/format_collect.rs:11:32 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^^^^^^^^^^^^^^^^ = note: this can be written more efficiently by appending to a `String` directly error: use of `format!` to build up a string from an iterator - --> $DIR/format_collect.rs:26:5 + --> tests/ui/format_collect.rs:26:5 | LL | / (1..10) LL | | @@ -49,12 +49,12 @@ LL | | .collect() | |__________________^ | help: call `fold` instead - --> $DIR/format_collect.rs:28:10 + --> tests/ui/format_collect.rs:28:10 | LL | .map(|s| { | ^^^ help: ... and use the `write!` macro here - --> $DIR/format_collect.rs:30:13 + --> tests/ui/format_collect.rs:30:13 | LL | format!("{s} {y}") | ^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/format_push_string.stderr b/src/tools/clippy/tests/ui/format_push_string.stderr index 545915b56b56b..a9520600f52a4 100644 --- a/src/tools/clippy/tests/ui/format_push_string.stderr +++ b/src/tools/clippy/tests/ui/format_push_string.stderr @@ -1,5 +1,5 @@ error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:5:5 + --> tests/ui/format_push_string.rs:5:5 | LL | string += &format!("{:?}", 1234); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | string += &format!("{:?}", 1234); = help: to override `-D warnings` add `#[allow(clippy::format_push_string)]` error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:7:5 + --> tests/ui/format_push_string.rs:7:5 | LL | string.push_str(&format!("{:?}", 5678)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | string.push_str(&format!("{:?}", 5678)); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:15:13 + --> tests/ui/format_push_string.rs:15:13 | LL | / hex += &(if upper { LL | | @@ -30,7 +30,7 @@ LL | | }); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:28:9 + --> tests/ui/format_push_string.rs:28:9 | LL | / s += &(if let Some(_a) = Some(1234) { LL | | @@ -43,7 +43,7 @@ LL | | }); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> $DIR/format_push_string.rs:35:9 + --> tests/ui/format_push_string.rs:35:9 | LL | / s += &(match Some(1234) { LL | | diff --git a/src/tools/clippy/tests/ui/formatting.stderr b/src/tools/clippy/tests/ui/formatting.stderr index d4eb8e511c8f9..e823e6512b8df 100644 --- a/src/tools/clippy/tests/ui/formatting.stderr +++ b/src/tools/clippy/tests/ui/formatting.stderr @@ -1,5 +1,5 @@ error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:16:6 + --> tests/ui/formatting.rs:16:6 | LL | a =- 35; | ^^^^ @@ -9,7 +9,7 @@ LL | a =- 35; = 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 + --> tests/ui/formatting.rs:19:6 | LL | a =* &191; | ^^^^ @@ -17,7 +17,7 @@ LL | a =* &191; = note: to remove this lint, use either `*=` or `= *` error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:24:6 + --> tests/ui/formatting.rs:24:6 | LL | b =! false; | ^^^^ @@ -25,7 +25,7 @@ LL | b =! false; = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:35:19 + --> tests/ui/formatting.rs:35:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -35,7 +35,7 @@ LL | -1, -2, -3 // <= no comma here = help: to override `-D warnings` add `#[allow(clippy::possible_missing_comma)]` error: possibly missing a comma here - --> $DIR/formatting.rs:41:19 + --> tests/ui/formatting.rs:41:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -43,7 +43,7 @@ LL | -1, -2, -3 // <= no comma here = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:80:11 + --> tests/ui/formatting.rs:80:11 | LL | -1 | ^ diff --git a/src/tools/clippy/tests/ui/four_forward_slashes.stderr b/src/tools/clippy/tests/ui/four_forward_slashes.stderr index 6450c5f94601a..a2218ea4d10b0 100644 --- a/src/tools/clippy/tests/ui/four_forward_slashes.stderr +++ b/src/tools/clippy/tests/ui/four_forward_slashes.stderr @@ -1,5 +1,5 @@ error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:12:1 + --> tests/ui/four_forward_slashes.rs:12:1 | LL | / //// whoops LL | | fn a() {} @@ -13,7 +13,7 @@ LL + /// whoops | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:15:1 + --> tests/ui/four_forward_slashes.rs:15:1 | LL | / //// whoops LL | | #[allow(dead_code)] @@ -26,7 +26,7 @@ LL + /// whoops | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:19:1 + --> tests/ui/four_forward_slashes.rs:19:1 | LL | / //// whoops LL | | //// two borked comments! @@ -41,7 +41,7 @@ LL ~ /// two borked comments! | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:27:1 + --> tests/ui/four_forward_slashes.rs:27:1 | LL | / //// between attributes LL | | #[allow(dead_code)] @@ -54,7 +54,7 @@ LL + /// between attributes | error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes.rs:31:1 + --> tests/ui/four_forward_slashes.rs:31:1 | LL | / //// not very start of contents LL | | fn h() {} 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 f49b7a0977fef..23937034b7e28 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 @@ -1,5 +1,5 @@ error: this item has comments with 4 forward slashes (`////`). These look like doc comments, but they aren't - --> $DIR/four_forward_slashes_first_line.rs:1:1 + --> tests/ui/four_forward_slashes_first_line.rs:1:1 | LL | / //// borked doc comment on the first line. doesn't combust! LL | | fn a() {} 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 6e86341d1574d..0824a526b793d 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 @@ -1,5 +1,5 @@ error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:17:9 + --> tests/ui/from_iter_instead_of_collect.rs:17:9 | LL | >::from_iter(iter.into_iter().copied()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `iter.into_iter().copied().collect::()` @@ -8,85 +8,85 @@ LL | >::from_iter(iter.into_iter().copied()) = 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 + --> tests/ui/from_iter_instead_of_collect.rs:23:13 | LL | let _ = Vec::from_iter(iter_expr); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `iter_expr.collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:25:13 + --> tests/ui/from_iter_instead_of_collect.rs:25:13 | LL | let _ = HashMap::::from_iter(vec![5, 5, 5, 5].iter().enumerate()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `vec![5, 5, 5, 5].iter().enumerate().collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:30:19 + --> tests/ui/from_iter_instead_of_collect.rs:30:19 | LL | assert_eq!(a, Vec::from_iter(0..3)); | ^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:31:19 + --> tests/ui/from_iter_instead_of_collect.rs:31:19 | LL | assert_eq!(a, Vec::::from_iter(0..3)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:33:17 + --> tests/ui/from_iter_instead_of_collect.rs:33:17 | LL | let mut b = VecDeque::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:36:17 + --> tests/ui/from_iter_instead_of_collect.rs:36:17 | LL | let mut b = VecDeque::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:41:21 + --> tests/ui/from_iter_instead_of_collect.rs:41:21 | LL | let mut b = collections::VecDeque::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:46:14 + --> tests/ui/from_iter_instead_of_collect.rs:46:14 | LL | let bm = BTreeMap::from_iter(values.iter().cloned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `values.iter().cloned().collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:47:19 + --> tests/ui/from_iter_instead_of_collect.rs:47:19 | LL | let mut bar = BTreeMap::from_iter(bm.range(0..2)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `bm.range(0..2).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:50:19 + --> tests/ui/from_iter_instead_of_collect.rs:50:19 | LL | let mut bts = BTreeSet::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:54:17 + --> tests/ui/from_iter_instead_of_collect.rs:54:17 | LL | let _ = collections::BTreeSet::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:55:17 + --> tests/ui/from_iter_instead_of_collect.rs:55:17 | LL | let _ = collections::BTreeSet::::from_iter(0..3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `(0..3).collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:58:15 + --> tests/ui/from_iter_instead_of_collect.rs:58:15 | LL | for _i in Vec::from_iter([1, 2, 3].iter()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `[1, 2, 3].iter().collect::>()` error: usage of `FromIterator::from_iter` - --> $DIR/from_iter_instead_of_collect.rs:59:15 + --> tests/ui/from_iter_instead_of_collect.rs:59:15 | LL | for _i in Vec::<&i32>::from_iter([1, 2, 3].iter()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `.collect()` instead of `::from_iter()`: `[1, 2, 3].iter().collect::>()` diff --git a/src/tools/clippy/tests/ui/from_over_into.fixed b/src/tools/clippy/tests/ui/from_over_into.fixed index 4a68505ee0b1c..a33c1ea5738b9 100644 --- a/src/tools/clippy/tests/ui/from_over_into.fixed +++ b/src/tools/clippy/tests/ui/from_over_into.fixed @@ -1,5 +1,6 @@ #![feature(type_alias_impl_trait)] #![warn(clippy::from_over_into)] +#![allow(non_local_definitions)] #![allow(unused)] // this should throw an error diff --git a/src/tools/clippy/tests/ui/from_over_into.rs b/src/tools/clippy/tests/ui/from_over_into.rs index bf3ed0c2b6422..6cd811ae401e2 100644 --- a/src/tools/clippy/tests/ui/from_over_into.rs +++ b/src/tools/clippy/tests/ui/from_over_into.rs @@ -1,5 +1,6 @@ #![feature(type_alias_impl_trait)] #![warn(clippy::from_over_into)] +#![allow(non_local_definitions)] #![allow(unused)] // this should throw an error diff --git a/src/tools/clippy/tests/ui/from_over_into.stderr b/src/tools/clippy/tests/ui/from_over_into.stderr index f1370ed844fa9..0649a6cb0f3ec 100644 --- a/src/tools/clippy/tests/ui/from_over_into.stderr +++ b/src/tools/clippy/tests/ui/from_over_into.stderr @@ -1,5 +1,5 @@ error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:8:1 + --> tests/ui/from_over_into.rs:9:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL ~ StringWrapper(val) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:16:1 + --> tests/ui/from_over_into.rs:17:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL ~ SelfType(String::new()) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:31:1 + --> tests/ui/from_over_into.rs:32:1 | LL | impl Into for X { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL ~ let _: X = val; | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:43:1 + --> tests/ui/from_over_into.rs:44:1 | LL | impl core::convert::Into for crate::ExplicitPaths { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL ~ val.0 | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:63:1 + --> tests/ui/from_over_into.rs:64:1 | LL | impl Into for PathInExpansion { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL ~ fn from(val: PathInExpansion) -> Self { | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:85:5 + --> tests/ui/from_over_into.rs:86:5 | LL | impl Into> for Vec { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL ~ FromOverInto(val) | error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true - --> $DIR/from_over_into.rs:95:5 + --> tests/ui/from_over_into.rs:96:5 | LL | impl Into<()> for Hello { | ^^^^^^^^^^^^^^^^^^^^^^^ 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 8ef36f082e0ef..1776b86e40dd3 100644 --- a/src/tools/clippy/tests/ui/from_over_into_unfixable.stderr +++ b/src/tools/clippy/tests/ui/from_over_into_unfixable.stderr @@ -1,5 +1,5 @@ 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:11:1 + --> tests/ui/from_over_into_unfixable.rs:11:1 | LL | impl Into for String { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | impl Into for String { = 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 + --> tests/ui/from_over_into_unfixable.rs:20:1 | LL | impl Into for &'static [u8] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | impl Into for &'static [u8] { = help: replace the `Into` implementation with `From<&'static [u8]>` 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:30:1 + --> tests/ui/from_over_into_unfixable.rs:30:1 | LL | impl Into for ContainsVal { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | impl Into for ContainsVal { = help: replace the `Into` implementation with `From` 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:42:1 + --> tests/ui/from_over_into_unfixable.rs:42:1 | LL | impl Into> for Lval { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 6e1ad0d99c49f..e5bcb783d18b5 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 @@ -1,11 +1,11 @@ error: creating a `Box` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:11:22 + --> tests/ui/from_raw_with_void_ptr.rs:11:22 | LL | let _ = unsafe { Box::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:11:36 + --> tests/ui/from_raw_with_void_ptr.rs:11:36 | LL | let _ = unsafe { Box::from_raw(ptr) }; | ^^^ @@ -13,49 +13,49 @@ LL | let _ = unsafe { Box::from_raw(ptr) }; = 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 + --> tests/ui/from_raw_with_void_ptr.rs:23:22 | LL | let _ = unsafe { Rc::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:23:35 + --> tests/ui/from_raw_with_void_ptr.rs:23:35 | LL | let _ = unsafe { Rc::from_raw(ptr) }; | ^^^ error: creating a `Arc` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:28:22 + --> tests/ui/from_raw_with_void_ptr.rs:28:22 | LL | let _ = unsafe { Arc::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:28:36 + --> tests/ui/from_raw_with_void_ptr.rs:28:36 | LL | let _ = unsafe { Arc::from_raw(ptr) }; | ^^^ error: creating a `Weak` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:33:22 + --> tests/ui/from_raw_with_void_ptr.rs:33:22 | LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:33:46 + --> tests/ui/from_raw_with_void_ptr.rs:33:46 | LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; | ^^^ error: creating a `Weak` from a void raw pointer - --> $DIR/from_raw_with_void_ptr.rs:38:22 + --> tests/ui/from_raw_with_void_ptr.rs:38:22 | LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> $DIR/from_raw_with_void_ptr.rs:38:48 + --> tests/ui/from_raw_with_void_ptr.rs:38:48 | LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; | ^^^ 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 439dcff74d9c9..4aa84eca26120 100644 --- a/src/tools/clippy/tests/ui/from_str_radix_10.stderr +++ b/src/tools/clippy/tests/ui/from_str_radix_10.stderr @@ -1,5 +1,5 @@ error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:28:5 + --> tests/ui/from_str_radix_10.rs:28:5 | LL | u32::from_str_radix("30", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"30".parse::()` @@ -8,43 +8,43 @@ LL | u32::from_str_radix("30", 10)?; = 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 + --> tests/ui/from_str_radix_10.rs:31:5 | LL | i64::from_str_radix("24", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"24".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:33:5 + --> tests/ui/from_str_radix_10.rs:33:5 | LL | isize::from_str_radix("100", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"100".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:35:5 + --> tests/ui/from_str_radix_10.rs:35:5 | LL | u8::from_str_radix("7", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"7".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:37:5 + --> tests/ui/from_str_radix_10.rs:37:5 | LL | u16::from_str_radix(&("10".to_owned() + "5"), 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("10".to_owned() + "5").parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:39:5 + --> tests/ui/from_str_radix_10.rs:39:5 | LL | i128::from_str_radix(Test + Test, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(Test + Test).parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:43:5 + --> tests/ui/from_str_radix_10.rs:43:5 | LL | i32::from_str_radix(string, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> $DIR/from_str_radix_10.rs:47:5 + --> tests/ui/from_str_radix_10.rs:47:5 | LL | i32::from_str_radix(&stringier, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `stringier.parse::()` diff --git a/src/tools/clippy/tests/ui/functions.stderr b/src/tools/clippy/tests/ui/functions.stderr index 4b06cd0388990..8fdceb8d8cd07 100644 --- a/src/tools/clippy/tests/ui/functions.stderr +++ b/src/tools/clippy/tests/ui/functions.stderr @@ -1,5 +1,5 @@ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:8:1 + --> tests/ui/functions.rs:8:1 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f = 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 + --> tests/ui/functions.rs:13:1 | LL | / fn bad_multiline( LL | | @@ -20,19 +20,19 @@ LL | | ) { | |_^ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:48:5 + --> tests/ui/functions.rs:48:5 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:58:5 + --> tests/ui/functions.rs:58:5 | LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:68:34 + --> tests/ui/functions.rs:68:34 | LL | println!("{}", unsafe { *p }); | ^ @@ -41,67 +41,67 @@ LL | println!("{}", unsafe { *p }); = 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 + --> tests/ui/functions.rs:71:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:73:33 + --> tests/ui/functions.rs:73:33 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:85:30 + --> tests/ui/functions.rs:85:30 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:87:31 + --> tests/ui/functions.rs:87:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:89:29 + --> tests/ui/functions.rs:89:29 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:96:30 + --> tests/ui/functions.rs:96:30 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:98:31 + --> tests/ui/functions.rs:98:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:100:29 + --> tests/ui/functions.rs:100:29 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:110:34 + --> tests/ui/functions.rs:110:34 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:112:35 + --> tests/ui/functions.rs:112:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:114:33 + --> tests/ui/functions.rs:114:33 | LL | unsafe { std::ptr::read(p) }; | ^ diff --git a/src/tools/clippy/tests/ui/functions_maxlines.stderr b/src/tools/clippy/tests/ui/functions_maxlines.stderr index 497acc0a65ea0..f42a2b2a22a2f 100644 --- a/src/tools/clippy/tests/ui/functions_maxlines.stderr +++ b/src/tools/clippy/tests/ui/functions_maxlines.stderr @@ -1,5 +1,5 @@ error: this function has too many lines (102/100) - --> $DIR/functions_maxlines.rs:58:1 + --> tests/ui/functions_maxlines.rs:58:1 | LL | / fn bad_lines() { LL | | diff --git a/src/tools/clippy/tests/ui/future_not_send.stderr b/src/tools/clippy/tests/ui/future_not_send.stderr index 7ef4947f1d6c5..67677d6367aaa 100644 --- a/src/tools/clippy/tests/ui/future_not_send.stderr +++ b/src/tools/clippy/tests/ui/future_not_send.stderr @@ -1,11 +1,11 @@ error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:7:1 + --> tests/ui/future_not_send.rs:7:1 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:9:20 + --> tests/ui/future_not_send.rs:9:20 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { | -- has type `std::rc::Rc<[u8]>` which is not `Send` @@ -14,7 +14,7 @@ LL | async { true }.await | ^^^^^ await occurs here, with `rc` maybe used later = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/future_not_send.rs:7:39 + --> tests/ui/future_not_send.rs:7:39 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^ has type `&std::cell::Cell` which is not `Send`, because `std::cell::Cell` is not `Sync` @@ -23,13 +23,13 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { = 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:1 + --> tests/ui/future_not_send.rs:12:1 | LL | pub async fn public_future(rc: Rc<[u8]>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:14:20 + --> tests/ui/future_not_send.rs:14:20 | LL | pub async fn public_future(rc: Rc<[u8]>) { | -- has type `std::rc::Rc<[u8]>` which is not `Send` @@ -39,45 +39,45 @@ LL | async { true }.await; = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:21:1 + --> tests/ui/future_not_send.rs:21:1 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future2` is not `Send` | note: captured value is not `Send` - --> $DIR/future_not_send.rs:21:26 + --> tests/ui/future_not_send.rs:21:26 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^ has type `std::rc::Rc<[u8]>` which is not `Send` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/future_not_send.rs:21:40 + --> tests/ui/future_not_send.rs:21:40 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { | ^^^^ has type `&std::cell::Cell` which is not `Send`, because `std::cell::Cell` is not `Sync` = note: `std::cell::Cell` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:26:1 + --> tests/ui/future_not_send.rs:26:1 | LL | pub async fn public_future2(rc: Rc<[u8]>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future2` is not `Send` | note: captured value is not `Send` - --> $DIR/future_not_send.rs:26:29 + --> tests/ui/future_not_send.rs:26:29 | LL | pub async fn public_future2(rc: Rc<[u8]>) {} | ^^ has type `std::rc::Rc<[u8]>` which is not `Send` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:38:5 + --> tests/ui/future_not_send.rs:38:5 | LL | async fn private_future(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:40:24 + --> tests/ui/future_not_send.rs:40:24 | LL | async fn private_future(&self) -> usize { | ----- has type `&Dummy` which is not `Send` @@ -87,20 +87,20 @@ LL | async { true }.await; = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:44:5 + --> tests/ui/future_not_send.rs:44:5 | LL | pub async fn public_future(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send` | note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> $DIR/future_not_send.rs:44:32 + --> tests/ui/future_not_send.rs:44:32 | LL | pub async fn public_future(&self) { | ^^^^^ has type `&Dummy` which is not `Send`, because `Dummy` is not `Sync` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:55:1 + --> tests/ui/future_not_send.rs:55:1 | LL | / async fn generic_future(t: T) -> T LL | | @@ -109,7 +109,7 @@ LL | | T: Send, | |____________^ future returned by `generic_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> $DIR/future_not_send.rs:61:20 + --> tests/ui/future_not_send.rs:61:20 | LL | let rt = &t; | -- has type `&T` which is not `Send` @@ -118,13 +118,13 @@ LL | async { true }.await; = note: `T` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> $DIR/future_not_send.rs:73:1 + --> tests/ui/future_not_send.rs:73:1 | LL | async fn unclear_future(t: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `unclear_future` is not `Send` | note: captured value is not `Send` - --> $DIR/future_not_send.rs:73:28 + --> tests/ui/future_not_send.rs:73:28 | LL | async fn unclear_future(t: T) {} | ^ has type `T` which is not `Send` diff --git a/src/tools/clippy/tests/ui/get_first.stderr b/src/tools/clippy/tests/ui/get_first.stderr index 7474a2ada6691..155d341b5a77d 100644 --- a/src/tools/clippy/tests/ui/get_first.stderr +++ b/src/tools/clippy/tests/ui/get_first.stderr @@ -1,5 +1,5 @@ error: accessing first element with `x.get(0)` - --> $DIR/get_first.rs:17:13 + --> tests/ui/get_first.rs:17:13 | LL | let _ = x.get(0); | ^^^^^^^^ help: try: `x.first()` @@ -8,25 +8,25 @@ LL | let _ = x.get(0); = help: to override `-D warnings` add `#[allow(clippy::get_first)]` error: accessing first element with `y.get(0)` - --> $DIR/get_first.rs:23:13 + --> tests/ui/get_first.rs:23:13 | LL | let _ = y.get(0); | ^^^^^^^^ help: try: `y.first()` error: accessing first element with `z.get(0)` - --> $DIR/get_first.rs:29:13 + --> tests/ui/get_first.rs:29:13 | LL | let _ = z.get(0); | ^^^^^^^^ help: try: `z.first()` error: accessing first element with `vecdeque.get(0)` - --> $DIR/get_first.rs:35:13 + --> tests/ui/get_first.rs:35:13 | LL | let _ = vecdeque.get(0); | ^^^^^^^^^^^^^^^ help: try: `vecdeque.front()` error: accessing first element with `non_primitives.get(0)` - --> $DIR/get_first.rs:48:13 + --> tests/ui/get_first.rs:48:13 | LL | let _ = non_primitives.get(0); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `non_primitives.first()` 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 0056adc57f22c..ba08f5db7cfae 100644 --- a/src/tools/clippy/tests/ui/get_last_with_len.stderr +++ b/src/tools/clippy/tests/ui/get_last_with_len.stderr @@ -1,5 +1,5 @@ error: accessing last element with `x.get(x.len() - 1)` - --> $DIR/get_last_with_len.rs:8:13 + --> tests/ui/get_last_with_len.rs:8:13 | LL | let _ = x.get(x.len() - 1); | ^^^^^^^^^^^^^^^^^^ help: try: `x.last()` @@ -8,31 +8,31 @@ LL | let _ = x.get(x.len() - 1); = 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 + --> tests/ui/get_last_with_len.rs:32:13 | LL | let _ = s.field.get(s.field.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.field.last()` error: accessing last element with `slice.get(slice.len() - 1)` - --> $DIR/get_last_with_len.rs:37:13 + --> tests/ui/get_last_with_len.rs:37:13 | LL | let _ = slice.get(slice.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `slice.last()` error: accessing last element with `array.get(array.len() - 1)` - --> $DIR/get_last_with_len.rs:40:13 + --> tests/ui/get_last_with_len.rs:40:13 | LL | let _ = array.get(array.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `array.last()` error: accessing last element with `deq.get(deq.len() - 1)` - --> $DIR/get_last_with_len.rs:43:13 + --> tests/ui/get_last_with_len.rs:43:13 | LL | let _ = deq.get(deq.len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `deq.back()` error: accessing last element with `nested[0].get(nested[0].len() - 1)` - --> $DIR/get_last_with_len.rs:46:13 + --> tests/ui/get_last_with_len.rs:46:13 | LL | let _ = nested[0].get(nested[0].len() - 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `nested[0].last()` diff --git a/src/tools/clippy/tests/ui/get_unwrap.stderr b/src/tools/clippy/tests/ui/get_unwrap.stderr index 700f3cfec4e0b..a08b6657dcc7c 100644 --- a/src/tools/clippy/tests/ui/get_unwrap.stderr +++ b/src/tools/clippy/tests/ui/get_unwrap.stderr @@ -1,17 +1,17 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:37:17 + --> tests/ui/get_unwrap.rs:37:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` | note: the lint level is defined here - --> $DIR/get_unwrap.rs:9:9 + --> tests/ui/get_unwrap.rs:9:9 | LL | #![deny(clippy::get_unwrap)] | ^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:37:17 + --> tests/ui/get_unwrap.rs:37:17 | LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,13 +22,13 @@ LL | let _ = boxed_slice.get(1).unwrap(); = 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:38:17 + --> tests/ui/get_unwrap.rs:38:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:38:17 + --> tests/ui/get_unwrap.rs:38:17 | LL | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,13 +37,13 @@ LL | let _ = some_slice.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:39:17 + --> tests/ui/get_unwrap.rs:39:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:39:17 + --> tests/ui/get_unwrap.rs:39:17 | LL | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,13 +52,13 @@ LL | let _ = some_vec.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:40:17 + --> tests/ui/get_unwrap.rs:40:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:40:17 + --> tests/ui/get_unwrap.rs:40:17 | LL | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,13 +67,13 @@ LL | let _ = some_vecdeque.get(0).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:41:17 + --> tests/ui/get_unwrap.rs:41:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_hashmap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:41:17 + --> tests/ui/get_unwrap.rs:41:17 | LL | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -82,13 +82,13 @@ LL | let _ = some_hashmap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:42:17 + --> tests/ui/get_unwrap.rs:42:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&some_btreemap[&1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:42:17 + --> tests/ui/get_unwrap.rs:42:17 | LL | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,13 +97,13 @@ LL | let _ = some_btreemap.get(&1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:46:21 + --> tests/ui/get_unwrap.rs:46:21 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:46:22 + --> tests/ui/get_unwrap.rs:46:22 | LL | let _: u8 = *boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,13 +112,13 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:51:9 + --> tests/ui/get_unwrap.rs:51:9 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:51:10 + --> tests/ui/get_unwrap.rs:51:10 | LL | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,13 +127,13 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:52:9 + --> tests/ui/get_unwrap.rs:52:9 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_slice[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:52:10 + --> tests/ui/get_unwrap.rs:52:10 | LL | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,13 +142,13 @@ LL | *some_slice.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:53:9 + --> tests/ui/get_unwrap.rs:53:9 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:53:10 + --> tests/ui/get_unwrap.rs:53:10 | LL | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,13 +157,13 @@ LL | *some_vec.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:54:9 + --> tests/ui/get_unwrap.rs:54:9 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vecdeque[0]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:54:10 + --> tests/ui/get_unwrap.rs:54:10 | LL | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -172,13 +172,13 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1; = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:66:17 + --> tests/ui/get_unwrap.rs:66:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:66:17 + --> tests/ui/get_unwrap.rs:66:17 | LL | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -187,13 +187,13 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:67:17 + --> tests/ui/get_unwrap.rs:67:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `some_vec[0..1]` error: used `unwrap()` on an `Option` value - --> $DIR/get_unwrap.rs:67:17 + --> tests/ui/get_unwrap.rs:67:17 | LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -202,25 +202,25 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); = help: consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:77:24 + --> tests/ui/get_unwrap.rs:77:24 | LL | let _x: &i32 = f.get(1 + 2).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `&f[1 + 2]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:80:18 + --> tests/ui/get_unwrap.rs:80:18 | LL | let _x = f.get(1 + 2).unwrap().to_string(); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `f[1 + 2]` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:83:18 + --> tests/ui/get_unwrap.rs:83:18 | LL | let _x = f.get(1 + 2).unwrap().abs(); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `f[1 + 2]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:100:33 + --> tests/ui/get_unwrap.rs:100:33 | LL | let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut rest[linidx(j, k) - linidx(i, k) - 1]` diff --git a/src/tools/clippy/tests/ui/identity_op.stderr b/src/tools/clippy/tests/ui/identity_op.stderr index 6bb980035c1a4..9fff86b86f9f6 100644 --- a/src/tools/clippy/tests/ui/identity_op.stderr +++ b/src/tools/clippy/tests/ui/identity_op.stderr @@ -1,5 +1,5 @@ error: this operation has no effect - --> $DIR/identity_op.rs:44:5 + --> tests/ui/identity_op.rs:44:5 | LL | x + 0; | ^^^^^ help: consider reducing it to: `x` @@ -8,307 +8,307 @@ LL | x + 0; = help: to override `-D warnings` add `#[allow(clippy::identity_op)]` error: this operation has no effect - --> $DIR/identity_op.rs:46:5 + --> tests/ui/identity_op.rs:46:5 | LL | x + (1 - 1); | ^^^^^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:49:5 + --> tests/ui/identity_op.rs:49:5 | LL | 0 + x; | ^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:53:5 + --> tests/ui/identity_op.rs:53:5 | LL | x | (0); | ^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:57:5 + --> tests/ui/identity_op.rs:57:5 | LL | x * 1; | ^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:59:5 + --> tests/ui/identity_op.rs:59:5 | LL | 1 * x; | ^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:66:5 + --> tests/ui/identity_op.rs:66:5 | LL | -1 & x; | ^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:70:5 + --> tests/ui/identity_op.rs:70:5 | LL | u & 255; | ^^^^^^^ help: consider reducing it to: `u` error: this operation has no effect - --> $DIR/identity_op.rs:74:5 + --> tests/ui/identity_op.rs:74:5 | LL | 42 << 0; | ^^^^^^^ help: consider reducing it to: `42` error: this operation has no effect - --> $DIR/identity_op.rs:76:5 + --> tests/ui/identity_op.rs:76:5 | LL | 1 >> 0; | ^^^^^^ help: consider reducing it to: `1` error: this operation has no effect - --> $DIR/identity_op.rs:78:5 + --> tests/ui/identity_op.rs:78:5 | LL | 42 >> 0; | ^^^^^^^ help: consider reducing it to: `42` error: this operation has no effect - --> $DIR/identity_op.rs:80:5 + --> tests/ui/identity_op.rs:80:5 | LL | &x >> 0; | ^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:82:5 + --> tests/ui/identity_op.rs:82:5 | LL | x >> &0; | ^^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:90:5 + --> tests/ui/identity_op.rs:90:5 | LL | 2 % 3; | ^^^^^ help: consider reducing it to: `2` error: this operation has no effect - --> $DIR/identity_op.rs:92:5 + --> tests/ui/identity_op.rs:92:5 | LL | -2 % 3; | ^^^^^^ help: consider reducing it to: `-2` error: this operation has no effect - --> $DIR/identity_op.rs:94:5 + --> tests/ui/identity_op.rs:94:5 | LL | 2 % -3 + x; | ^^^^^^ help: consider reducing it to: `2` error: this operation has no effect - --> $DIR/identity_op.rs:96:5 + --> tests/ui/identity_op.rs:96:5 | LL | -2 % -3 + x; | ^^^^^^^ help: consider reducing it to: `-2` error: this operation has no effect - --> $DIR/identity_op.rs:98:9 + --> tests/ui/identity_op.rs:98:9 | LL | x + 1 % 3; | ^^^^^ help: consider reducing it to: `1` error: this operation has no effect - --> $DIR/identity_op.rs:107:5 + --> tests/ui/identity_op.rs:107:5 | LL | 0 + if b { 1 } else { 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:109:5 + --> tests/ui/identity_op.rs:109:5 | LL | 0 + if b { 1 } else { 2 } + if b { 3 } else { 4 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:111:5 + --> tests/ui/identity_op.rs:111:5 | LL | 0 + match a { 0 => 10, _ => 20 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` error: this operation has no effect - --> $DIR/identity_op.rs:113:5 + --> tests/ui/identity_op.rs:113:5 | LL | 0 + match a { 0 => 10, _ => 20 } + match a { 0 => 30, _ => 40 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` error: this operation has no effect - --> $DIR/identity_op.rs:115:5 + --> tests/ui/identity_op.rs:115:5 | LL | 0 + if b { 1 } else { 2 } + match a { 0 => 30, _ => 40 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:117:5 + --> tests/ui/identity_op.rs:117:5 | LL | 0 + match a { 0 => 10, _ => 20 } + if b { 3 } else { 4 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(match a { 0 => 10, _ => 20 })` error: this operation has no effect - --> $DIR/identity_op.rs:119:5 + --> tests/ui/identity_op.rs:119:5 | LL | (if b { 1 } else { 2 }) + 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if b { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:122:5 + --> tests/ui/identity_op.rs:122:5 | LL | 0 + { a } + 3; | ^^^^^^^^^ help: consider reducing it to: `({ a })` error: this operation has no effect - --> $DIR/identity_op.rs:124:5 + --> tests/ui/identity_op.rs:124:5 | LL | 0 + { a } * 2; | ^^^^^^^^^^^^^ help: consider reducing it to: `({ a } * 2)` error: this operation has no effect - --> $DIR/identity_op.rs:126:5 + --> tests/ui/identity_op.rs:126:5 | LL | 0 + loop { let mut c = 0; if c == 10 { break c; } c += 1; } + { a * 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(loop { let mut c = 0; if c == 10 { break c; } c += 1; })` error: this operation has no effect - --> $DIR/identity_op.rs:133:7 + --> tests/ui/identity_op.rs:133:7 | LL | f(1 * a + { 8 * 5 }); | ^^^^^ help: consider reducing it to: `a` error: this operation has no effect - --> $DIR/identity_op.rs:135:7 + --> tests/ui/identity_op.rs:135:7 | LL | f(0 + if b { 1 } else { 2 } + 3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `if b { 1 } else { 2 }` error: this operation has no effect - --> $DIR/identity_op.rs:138:20 + --> tests/ui/identity_op.rs:138:20 | LL | const _: i32 = { 2 * 4 } + 0 + 3; | ^^^^^^^^^^^^^ help: consider reducing it to: `{ 2 * 4 }` error: this operation has no effect - --> $DIR/identity_op.rs:140:20 + --> tests/ui/identity_op.rs:140:20 | LL | const _: i32 = 0 + { 1 + 2 * 3 } + 3; | ^^^^^^^^^^^^^^^^^ help: consider reducing it to: `{ 1 + 2 * 3 }` error: this operation has no effect - --> $DIR/identity_op.rs:143:5 + --> tests/ui/identity_op.rs:143:5 | LL | 0 + a as usize; | ^^^^^^^^^^^^^^ help: consider reducing it to: `a as usize` error: this operation has no effect - --> $DIR/identity_op.rs:145:13 + --> tests/ui/identity_op.rs:145:13 | LL | let _ = 0 + a as usize; | ^^^^^^^^^^^^^^ help: consider reducing it to: `a as usize` error: this operation has no effect - --> $DIR/identity_op.rs:147:5 + --> tests/ui/identity_op.rs:147:5 | LL | 0 + { a } as usize; | ^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `({ a } as usize)` error: this operation has no effect - --> $DIR/identity_op.rs:150:9 + --> tests/ui/identity_op.rs:150:9 | LL | 2 * (0 + { a }); | ^^^^^^^^^^^ help: consider reducing it to: `{ a }` error: this operation has no effect - --> $DIR/identity_op.rs:152:5 + --> tests/ui/identity_op.rs:152:5 | LL | 1 * ({ a } + 4); | ^^^^^^^^^^^^^^^ help: consider reducing it to: `(({ a } + 4))` error: this operation has no effect - --> $DIR/identity_op.rs:154:5 + --> tests/ui/identity_op.rs:154:5 | LL | 1 * 1; | ^^^^^ help: consider reducing it to: `1` error: this operation has no effect - --> $DIR/identity_op.rs:159:18 + --> tests/ui/identity_op.rs:159:18 | LL | let _: i32 = &x + 0; | ^^^^^^ help: consider reducing it to: `x` error: this operation has no effect - --> $DIR/identity_op.rs:164:5 + --> tests/ui/identity_op.rs:164:5 | LL | 0 + if a { 1 } else { 2 } + if b { 3 } else { 5 } | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(if a { 1 } else { 2 })` error: this operation has no effect - --> $DIR/identity_op.rs:175:22 + --> tests/ui/identity_op.rs:175:22 | LL | let _: i32 = *x + 0; | ^^^^^^ help: consider reducing it to: `*x` error: this operation has no effect - --> $DIR/identity_op.rs:177:22 + --> tests/ui/identity_op.rs:177:22 | LL | let _: i32 = x + 0; | ^^^^^ help: consider reducing it to: `*x` error: this operation has no effect - --> $DIR/identity_op.rs:182:22 + --> tests/ui/identity_op.rs:182:22 | LL | let _: i32 = **x + 0; | ^^^^^^^ help: consider reducing it to: `**x` error: this operation has no effect - --> $DIR/identity_op.rs:185:22 + --> tests/ui/identity_op.rs:185:22 | LL | let _: i32 = *x + 0; | ^^^^^^ help: consider reducing it to: `**x` error: this operation has no effect - --> $DIR/identity_op.rs:191:22 + --> tests/ui/identity_op.rs:191:22 | LL | let _: i32 = ***x + 0; | ^^^^^^^^ help: consider reducing it to: `***x` error: this operation has no effect - --> $DIR/identity_op.rs:193:22 + --> tests/ui/identity_op.rs:193:22 | LL | let _: i32 = **x + 0; | ^^^^^^^ help: consider reducing it to: `***x` error: this operation has no effect - --> $DIR/identity_op.rs:196:22 + --> tests/ui/identity_op.rs:196:22 | LL | let _: i32 = *&x + 0; | ^^^^^^^ help: consider reducing it to: `*&x` error: this operation has no effect - --> $DIR/identity_op.rs:198:22 + --> tests/ui/identity_op.rs:198:22 | LL | let _: i32 = **&&x + 0; | ^^^^^^^^^ help: consider reducing it to: `**&&x` error: this operation has no effect - --> $DIR/identity_op.rs:200:22 + --> tests/ui/identity_op.rs:200:22 | LL | let _: i32 = *&*&x + 0; | ^^^^^^^^^ help: consider reducing it to: `*&*&x` error: this operation has no effect - --> $DIR/identity_op.rs:202:22 + --> tests/ui/identity_op.rs:202:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `**&&*&x` error: this operation has no effect - --> $DIR/identity_op.rs:209:22 + --> tests/ui/identity_op.rs:209:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `***&&*&x` error: this operation has no effect - --> $DIR/identity_op.rs:211:22 + --> tests/ui/identity_op.rs:211:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `***&&*&x` diff --git a/src/tools/clippy/tests/ui/if_let_mutex.stderr b/src/tools/clippy/tests/ui/if_let_mutex.stderr index 8934294430b25..6e0115c23af68 100644 --- a/src/tools/clippy/tests/ui/if_let_mutex.stderr +++ b/src/tools/clippy/tests/ui/if_let_mutex.stderr @@ -1,5 +1,5 @@ error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock - --> $DIR/if_let_mutex.rs:10:5 + --> tests/ui/if_let_mutex.rs:10:5 | LL | if let Err(locked) = m.lock() { | ^ - this Mutex will remain locked for the entire `if let`-block... @@ -19,7 +19,7 @@ LL | | }; = 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 + --> tests/ui/if_let_mutex.rs:23:5 | LL | if let Some(locked) = m.lock().unwrap().deref() { | ^ - this Mutex will remain locked for the entire `if let`-block... @@ -37,7 +37,7 @@ LL | | }; = help: move the lock call outside of the `if let ...` expression error: calling `Mutex::lock` inside the scope of another `Mutex::lock` causes a deadlock - --> $DIR/if_let_mutex.rs:45:5 + --> tests/ui/if_let_mutex.rs:45:5 | LL | if let Ok(i) = mutex.lock() { | ^ ----- this Mutex will remain locked for the entire `if let`-block... diff --git a/src/tools/clippy/tests/ui/if_not_else.stderr b/src/tools/clippy/tests/ui/if_not_else.stderr index 8b86f82fa8ee0..92fed7b1bf700 100644 --- a/src/tools/clippy/tests/ui/if_not_else.stderr +++ b/src/tools/clippy/tests/ui/if_not_else.stderr @@ -1,5 +1,5 @@ error: unnecessary boolean `not` operation - --> $DIR/if_not_else.rs:12:5 + --> tests/ui/if_not_else.rs:12:5 | LL | / if !bla() { LL | | @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::if_not_else)]` error: unnecessary `!=` operation - --> $DIR/if_not_else.rs:18:5 + --> tests/ui/if_not_else.rs:18:5 | LL | / if 4 != 5 { LL | | 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 281f30f88b46d..b76da3fb1cb58 100644 --- a/src/tools/clippy/tests/ui/if_same_then_else.stderr +++ b/src/tools/clippy/tests/ui/if_same_then_else.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:23:13 + --> tests/ui/if_same_then_else.rs:23:13 | LL | if true { | _____________^ @@ -12,7 +12,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:31:12 + --> tests/ui/if_same_then_else.rs:31:12 | LL | } else { | ____________^ @@ -27,43 +27,43 @@ LL | | } = 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 + --> tests/ui/if_same_then_else.rs:67:21 | LL | let _ = if true { 0.0 } else { 0.0 }; | ^^^^^^^ | note: same as this - --> $DIR/if_same_then_else.rs:67:34 + --> tests/ui/if_same_then_else.rs:67:34 | LL | let _ = if true { 0.0 } else { 0.0 }; | ^^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:70:21 + --> tests/ui/if_same_then_else.rs:70:21 | LL | let _ = if true { -0.0 } else { -0.0 }; | ^^^^^^^^ | note: same as this - --> $DIR/if_same_then_else.rs:70:35 + --> tests/ui/if_same_then_else.rs:70:35 | LL | let _ = if true { -0.0 } else { -0.0 }; | ^^^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:82:21 + --> tests/ui/if_same_then_else.rs:82:21 | LL | let _ = if true { 42 } else { 42 }; | ^^^^^^ | note: same as this - --> $DIR/if_same_then_else.rs:82:33 + --> tests/ui/if_same_then_else.rs:82:33 | LL | let _ = if true { 42 } else { 42 }; | ^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:85:13 + --> tests/ui/if_same_then_else.rs:85:13 | LL | if true { | _____________^ @@ -76,7 +76,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else.rs:92:12 + --> tests/ui/if_same_then_else.rs:92:12 | LL | } else { | ____________^ @@ -89,7 +89,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else.rs:238:14 + --> tests/ui/if_same_then_else.rs:238:14 | LL | if x { | ______________^ @@ -98,7 +98,7 @@ LL | | } else { | |_________^ | note: same as this - --> $DIR/if_same_then_else.rs:240:16 + --> tests/ui/if_same_then_else.rs:240:16 | LL | } else { | ________________^ 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 4e7a7c87dc54b..93507eb2c6fde 100644 --- a/src/tools/clippy/tests/ui/if_same_then_else2.stderr +++ b/src/tools/clippy/tests/ui/if_same_then_else2.stderr @@ -1,5 +1,5 @@ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:15:13 + --> tests/ui/if_same_then_else2.rs:15:13 | LL | if true { | _____________^ @@ -12,7 +12,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:24:12 + --> tests/ui/if_same_then_else2.rs:24:12 | LL | } else { | ____________^ @@ -27,7 +27,7 @@ LL | | } = 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 + --> tests/ui/if_same_then_else2.rs:36:13 | LL | if true { | _____________^ @@ -36,7 +36,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:38:12 + --> tests/ui/if_same_then_else2.rs:38:12 | LL | } else { | ____________^ @@ -45,7 +45,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:43:13 + --> tests/ui/if_same_then_else2.rs:43:13 | LL | if true { | _____________^ @@ -54,7 +54,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:45:12 + --> tests/ui/if_same_then_else2.rs:45:12 | LL | } else { | ____________^ @@ -63,19 +63,19 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:93:21 + --> tests/ui/if_same_then_else2.rs:93:21 | LL | let _ = if true { f32::NAN } else { f32::NAN }; | ^^^^^^^^^^^^ | note: same as this - --> $DIR/if_same_then_else2.rs:93:39 + --> tests/ui/if_same_then_else2.rs:93:39 | LL | let _ = if true { f32::NAN } else { f32::NAN }; | ^^^^^^^^^^^^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:96:13 + --> tests/ui/if_same_then_else2.rs:96:13 | LL | if true { | _____________^ @@ -84,7 +84,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:98:12 + --> tests/ui/if_same_then_else2.rs:98:12 | LL | } else { | ____________^ @@ -93,7 +93,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> $DIR/if_same_then_else2.rs:120:20 + --> tests/ui/if_same_then_else2.rs:120:20 | LL | } else if true { | ____________________^ @@ -103,7 +103,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/if_same_then_else2.rs:123:12 + --> tests/ui/if_same_then_else2.rs:123:12 | LL | } else { | ____________^ 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 9b3d65cc803ac..e0a95aebdc134 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 @@ -1,5 +1,5 @@ error: this could be simplified with `bool::then` - --> $DIR/if_then_some_else_none.rs:6:13 + --> tests/ui/if_then_some_else_none.rs:6:13 | LL | let _ = if foo() { | _____________^ @@ -16,7 +16,7 @@ LL | | }; = 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:15:13 + --> tests/ui/if_then_some_else_none.rs:15:13 | LL | let _ = if matches!(true, true) { | _____________^ @@ -31,7 +31,7 @@ LL | | }; = help: consider using `bool::then` like: `matches!(true, true).then(|| { /* snippet */ matches!(true, false) })` error: this could be simplified with `bool::then_some` - --> $DIR/if_then_some_else_none.rs:25:28 + --> tests/ui/if_then_some_else_none.rs:25:28 | LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); = help: consider using `bool::then_some` like: `(o < 32).then_some(o)` error: this could be simplified with `bool::then_some` - --> $DIR/if_then_some_else_none.rs:30:13 + --> tests/ui/if_then_some_else_none.rs:30:13 | LL | let _ = if !x { Some(0) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | let _ = if !x { Some(0) } else { None }; = help: consider using `bool::then_some` like: `(!x).then_some(0)` error: this could be simplified with `bool::then` - --> $DIR/if_then_some_else_none.rs:86:13 + --> tests/ui/if_then_some_else_none.rs:86:13 | LL | let _ = if foo() { | _____________^ diff --git a/src/tools/clippy/tests/ui/ifs_same_cond.stderr b/src/tools/clippy/tests/ui/ifs_same_cond.stderr index c5cd6b2c42e5a..81fbb921e8463 100644 --- a/src/tools/clippy/tests/ui/ifs_same_cond.stderr +++ b/src/tools/clippy/tests/ui/ifs_same_cond.stderr @@ -1,11 +1,11 @@ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:14:15 + --> tests/ui/ifs_same_cond.rs:14:15 | LL | } else if b { | ^ | note: same as this - --> $DIR/ifs_same_cond.rs:13:8 + --> tests/ui/ifs_same_cond.rs:13:8 | LL | if b { | ^ @@ -13,37 +13,37 @@ LL | if b { = 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 + --> tests/ui/ifs_same_cond.rs:19:15 | LL | } else if a == 1 { | ^^^^^^ | note: same as this - --> $DIR/ifs_same_cond.rs:18:8 + --> tests/ui/ifs_same_cond.rs:18:8 | LL | if a == 1 { | ^^^^^^ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:25:15 + --> tests/ui/ifs_same_cond.rs:25:15 | LL | } else if 2 * a == 1 { | ^^^^^^^^^^ | note: same as this - --> $DIR/ifs_same_cond.rs:23:8 + --> tests/ui/ifs_same_cond.rs:23:8 | LL | if 2 * a == 1 { | ^^^^^^^^^^ error: this `if` has the same condition as a previous `if` - --> $DIR/ifs_same_cond.rs:58:15 + --> tests/ui/ifs_same_cond.rs:58:15 | LL | } else if a.contains("ah") { | ^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/ifs_same_cond.rs:57:8 + --> tests/ui/ifs_same_cond.rs:57:8 | LL | if a.contains("ah") { | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr b/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr index 18ca7ebbcf2c4..00a254e39192c 100644 --- a/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr +++ b/src/tools/clippy/tests/ui/ignored_unit_patterns.stderr @@ -1,5 +1,5 @@ error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:16:12 + --> tests/ui/ignored_unit_patterns.rs:16:12 | LL | Ok(_) => {}, | ^ help: use `()` instead of `_`: `()` @@ -8,49 +8,49 @@ LL | Ok(_) => {}, = help: to override `-D warnings` add `#[allow(clippy::ignored_unit_patterns)]` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:17:13 + --> tests/ui/ignored_unit_patterns.rs:17:13 | LL | Err(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:19:15 + --> tests/ui/ignored_unit_patterns.rs:19:15 | LL | if let Ok(_) = foo() {} | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:21:28 + --> tests/ui/ignored_unit_patterns.rs:21:28 | LL | let _ = foo().map_err(|_| todo!()); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:27:16 + --> tests/ui/ignored_unit_patterns.rs:27:16 | LL | Ok(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:29:17 + --> tests/ui/ignored_unit_patterns.rs:29:17 | LL | Err(_) => {}, | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:41:9 + --> tests/ui/ignored_unit_patterns.rs:41:9 | LL | let _ = foo().unwrap(); | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:50:13 + --> tests/ui/ignored_unit_patterns.rs:50:13 | LL | (1, _) => unimplemented!(), | ^ help: use `()` instead of `_`: `()` error: matching over `()` is more explicit - --> $DIR/ignored_unit_patterns.rs:57:13 + --> tests/ui/ignored_unit_patterns.rs:57:13 | LL | for (x, _) in v { | ^ help: use `()` instead of `_`: `()` diff --git a/src/tools/clippy/tests/ui/impl.stderr b/src/tools/clippy/tests/ui/impl.stderr index 833a106062a38..bb906957a0d33 100644 --- a/src/tools/clippy/tests/ui/impl.stderr +++ b/src/tools/clippy/tests/ui/impl.stderr @@ -1,5 +1,5 @@ error: multiple implementations of this structure - --> $DIR/impl.rs:10:1 + --> tests/ui/impl.rs:10:1 | LL | / impl MyStruct { LL | | @@ -8,7 +8,7 @@ LL | | } | |_^ | note: first implementation here - --> $DIR/impl.rs:6:1 + --> tests/ui/impl.rs:6:1 | LL | / impl MyStruct { LL | | fn first() {} @@ -18,7 +18,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::multiple_inherent_impl)]` error: multiple implementations of this structure - --> $DIR/impl.rs:25:5 + --> tests/ui/impl.rs:25:5 | LL | / impl super::MyStruct { LL | | @@ -27,7 +27,7 @@ LL | | } | |_____^ | note: first implementation here - --> $DIR/impl.rs:6:1 + --> tests/ui/impl.rs:6:1 | LL | / impl MyStruct { LL | | fn first() {} @@ -35,7 +35,7 @@ LL | | } | |_^ error: multiple implementations of this structure - --> $DIR/impl.rs:46:1 + --> tests/ui/impl.rs:46:1 | LL | / impl WithArgs { LL | | @@ -44,7 +44,7 @@ LL | | } | |_^ | note: first implementation here - --> $DIR/impl.rs:43:1 + --> tests/ui/impl.rs:43:1 | LL | / impl WithArgs { LL | | fn f2() {} @@ -52,13 +52,13 @@ LL | | } | |_^ error: multiple implementations of this structure - --> $DIR/impl.rs:68:1 + --> tests/ui/impl.rs:68:1 | LL | impl OneAllowedImpl {} // Lint, only one of the three blocks is allowed. | ^^^^^^^^^^^^^^^^^^^^^^ | note: first implementation here - --> $DIR/impl.rs:65:1 + --> tests/ui/impl.rs:65:1 | LL | impl OneAllowedImpl {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr b/src/tools/clippy/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr index afc35ef98459b..7328f563ce13d 100644 --- a/src/tools/clippy/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr +++ b/src/tools/clippy/tests/ui/impl_hash_with_borrow_str_and_bytes.stderr @@ -1,5 +1,5 @@ error: the semantics of `Borrow` around `Hash` can't be satisfied when both `Borrow` and `Borrow<[u8]>` are implemented - --> $DIR/impl_hash_with_borrow_str_and_bytes.rs:10:6 + --> tests/ui/impl_hash_with_borrow_str_and_bytes.rs:10:6 | LL | impl Hash for ExampleType { | ^^^^ @@ -13,7 +13,7 @@ LL | impl Hash for ExampleType { = help: to override `-D warnings` add `#[allow(clippy::impl_hash_borrow_with_str_and_bytes)]` error: the semantics of `Borrow` around `Hash` can't be satisfied when both `Borrow` and `Borrow<[u8]>` are implemented - --> $DIR/impl_hash_with_borrow_str_and_bytes.rs:73:10 + --> tests/ui/impl_hash_with_borrow_str_and_bytes.rs:73:10 | LL | #[derive(Hash)] | ^^^^ @@ -26,7 +26,7 @@ LL | #[derive(Hash)] = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) error: the semantics of `Borrow` around `Hash` can't be satisfied when both `Borrow` and `Borrow<[u8]>` are implemented - --> $DIR/impl_hash_with_borrow_str_and_bytes.rs:117:6 + --> tests/ui/impl_hash_with_borrow_str_and_bytes.rs:117:6 | LL | impl Hash for GenericExampleType2 { | ^^^^ 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 0ae7a3672d190..0ec0a34ea8db9 100644 --- a/src/tools/clippy/tests/ui/impl_trait_in_params.stderr +++ b/src/tools/clippy/tests/ui/impl_trait_in_params.stderr @@ -1,5 +1,5 @@ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:9:13 + --> tests/ui/impl_trait_in_params.rs:9:13 | LL | pub fn a(_: impl Trait) {} | ^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | pub fn a<{ /* Generic name */ }: Trait>(_: impl Trait) {} | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:11:29 + --> tests/ui/impl_trait_in_params.rs:11:29 | LL | pub fn c(_: C, _: impl Trait) {} | ^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | pub fn c(_: C, _: impl Trait) {} | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:36:17 + --> tests/ui/impl_trait_in_params.rs:36:17 | LL | pub fn h(_: impl Trait) {} | ^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | pub fn h<{ /* Generic name */ }: Trait>(_: impl Trait) {} | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> $DIR/impl_trait_in_params.rs:39:45 + --> tests/ui/impl_trait_in_params.rs:39:45 | LL | pub fn k>(_: K, _: impl AnotherTrait) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/implicit_clone.stderr b/src/tools/clippy/tests/ui/implicit_clone.stderr index 64c31e65175ab..31c212eba2c8d 100644 --- a/src/tools/clippy/tests/ui/implicit_clone.stderr +++ b/src/tools/clippy/tests/ui/implicit_clone.stderr @@ -1,5 +1,5 @@ error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:65:13 + --> tests/ui/implicit_clone.rs:65:13 | LL | let _ = vec.to_owned(); | ^^^^^^^^^^^^^^ help: consider using: `vec.clone()` @@ -8,61 +8,61 @@ LL | let _ = vec.to_owned(); = 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 + --> tests/ui/implicit_clone.rs:66:13 | LL | let _ = vec.to_vec(); | ^^^^^^^^^^^^ help: consider using: `vec.clone()` error: implicitly cloning a `Vec` by calling `to_vec` on its dereferenced type - --> $DIR/implicit_clone.rs:71:13 + --> tests/ui/implicit_clone.rs:71:13 | LL | let _ = vec_ref.to_vec(); | ^^^^^^^^^^^^^^^^ help: consider using: `vec_ref.clone()` error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:83:13 + --> tests/ui/implicit_clone.rs:83:13 | LL | let _ = str.to_owned(); | ^^^^^^^^^^^^^^ help: consider using: `str.clone()` error: implicitly cloning a `Kitten` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:87:13 + --> tests/ui/implicit_clone.rs:87:13 | LL | let _ = kitten.to_owned(); | ^^^^^^^^^^^^^^^^^ help: consider using: `kitten.clone()` error: implicitly cloning a `PathBuf` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:97:13 + --> tests/ui/implicit_clone.rs:97:13 | LL | let _ = pathbuf.to_owned(); | ^^^^^^^^^^^^^^^^^^ help: consider using: `pathbuf.clone()` error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type - --> $DIR/implicit_clone.rs:98:13 + --> tests/ui/implicit_clone.rs:98:13 | LL | let _ = pathbuf.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `pathbuf.clone()` error: implicitly cloning a `OsString` by calling `to_owned` on its dereferenced type - --> $DIR/implicit_clone.rs:101:13 + --> tests/ui/implicit_clone.rs:101:13 | LL | let _ = os_string.to_owned(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `os_string.clone()` error: implicitly cloning a `OsString` by calling `to_os_string` on its dereferenced type - --> $DIR/implicit_clone.rs:102:13 + --> tests/ui/implicit_clone.rs:102:13 | LL | let _ = os_string.to_os_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `os_string.clone()` error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type - --> $DIR/implicit_clone.rs:113:13 + --> tests/ui/implicit_clone.rs:113:13 | LL | let _ = pathbuf_ref.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(*pathbuf_ref).clone()` error: implicitly cloning a `PathBuf` by calling `to_path_buf` on its dereferenced type - --> $DIR/implicit_clone.rs:116:13 + --> tests/ui/implicit_clone.rs:116:13 | LL | let _ = pathbuf_ref.to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(**pathbuf_ref).clone()` diff --git a/src/tools/clippy/tests/ui/implicit_hasher.stderr b/src/tools/clippy/tests/ui/implicit_hasher.stderr index a27590288bc48..a3df8edf389be 100644 --- a/src/tools/clippy/tests/ui/implicit_hasher.stderr +++ b/src/tools/clippy/tests/ui/implicit_hasher.stderr @@ -1,29 +1,29 @@ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:14:1 + --> tests/ui/implicit_hasher.rs:14:1 | LL | pub trait Foo: Sized { | ^^^^^^^^^^^^^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:71:1 + --> tests/ui/implicit_hasher.rs:71:1 | LL | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:74:1 + --> tests/ui/implicit_hasher.rs:74:1 | LL | pub mod gen { | ^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:92:1 + --> tests/ui/implicit_hasher.rs:92:1 | LL | pub mod test_macro; | ^^^^^^^^^^^^^^^^^^^ error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:96:1 + --> tests/ui/implicit_hasher.rs:96:1 | LL | external! { | ^^^^^^^^^ @@ -31,7 +31,7 @@ LL | external! { = note: this error originates in the macro `external` (in Nightly builds, run with -Z macro-backtrace for more info) error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]` - --> $DIR/implicit_hasher.rs:101:1 + --> tests/ui/implicit_hasher.rs:101:1 | LL | pub async fn election_vote(_data: HashMap) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/implicit_return.stderr b/src/tools/clippy/tests/ui/implicit_return.stderr index 1edc6cc6f7788..3ffed273e0f16 100644 --- a/src/tools/clippy/tests/ui/implicit_return.stderr +++ b/src/tools/clippy/tests/ui/implicit_return.stderr @@ -1,5 +1,5 @@ error: missing `return` statement - --> $DIR/implicit_return.rs:11:5 + --> tests/ui/implicit_return.rs:11:5 | LL | true | ^^^^ help: add `return` as shown: `return true` @@ -8,85 +8,85 @@ LL | true = help: to override `-D warnings` add `#[allow(clippy::implicit_return)]` error: missing `return` statement - --> $DIR/implicit_return.rs:15:15 + --> tests/ui/implicit_return.rs:15:15 | LL | if true { true } else { false } | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:15:29 + --> tests/ui/implicit_return.rs:15:29 | LL | if true { true } else { false } | ^^^^^ help: add `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:21:17 + --> tests/ui/implicit_return.rs:21:17 | LL | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:22:20 + --> tests/ui/implicit_return.rs:22:20 | LL | false => { true }, | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:35:9 + --> tests/ui/implicit_return.rs:35:9 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:42:13 + --> tests/ui/implicit_return.rs:42:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:50:13 + --> tests/ui/implicit_return.rs:50:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:68:18 + --> tests/ui/implicit_return.rs:68:18 | LL | let _ = || { true }; | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:69:16 + --> tests/ui/implicit_return.rs:69:16 | LL | let _ = || true; | ^^^^ help: add `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:77:5 + --> tests/ui/implicit_return.rs:77:5 | LL | format!("test {}", "test") | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")` error: missing `return` statement - --> $DIR/implicit_return.rs:86:5 + --> tests/ui/implicit_return.rs:86:5 | LL | m!(true, false) | ^^^^^^^^^^^^^^^ help: add `return` as shown: `return m!(true, false)` error: missing `return` statement - --> $DIR/implicit_return.rs:92:13 + --> tests/ui/implicit_return.rs:92:13 | LL | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing `return` statement - --> $DIR/implicit_return.rs:97:17 + --> tests/ui/implicit_return.rs:97:17 | LL | break 'outer false; | ^^^^^^^^^^^^^^^^^^ help: change `break` to `return` as shown: `return false` error: missing `return` statement - --> $DIR/implicit_return.rs:112:5 + --> tests/ui/implicit_return.rs:112:5 | LL | / loop { LL | | m!(true); @@ -101,7 +101,7 @@ LL + } | error: missing `return` statement - --> $DIR/implicit_return.rs:126:5 + --> tests/ui/implicit_return.rs:126:5 | LL | true | ^^^^ help: add `return` as shown: `return true` diff --git a/src/tools/clippy/tests/ui/implicit_saturating_add.stderr b/src/tools/clippy/tests/ui/implicit_saturating_add.stderr index 7119c8bf6fad0..4fb9282bc91db 100644 --- a/src/tools/clippy/tests/ui/implicit_saturating_add.stderr +++ b/src/tools/clippy/tests/ui/implicit_saturating_add.stderr @@ -1,5 +1,5 @@ error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:21:5 + --> tests/ui/implicit_saturating_add.rs:21:5 | LL | / if u_8 != u8::MAX { LL | | u_8 += 1; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_add)]` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:25:5 + --> tests/ui/implicit_saturating_add.rs:25:5 | LL | / if u_8 < u8::MAX { LL | | u_8 += 1; @@ -18,7 +18,7 @@ LL | | } | |_____^ help: use instead: `u_8 = u_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:33:5 + --> tests/ui/implicit_saturating_add.rs:33:5 | LL | / if u_16 != u16::MAX { LL | | u_16 += 1; @@ -26,7 +26,7 @@ LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:37:5 + --> tests/ui/implicit_saturating_add.rs:37:5 | LL | / if u_16 < u16::MAX { LL | | u_16 += 1; @@ -34,7 +34,7 @@ LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:41:5 + --> tests/ui/implicit_saturating_add.rs:41:5 | LL | / if u16::MAX > u_16 { LL | | u_16 += 1; @@ -42,7 +42,7 @@ LL | | } | |_____^ help: use instead: `u_16 = u_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:45:5 + --> tests/ui/implicit_saturating_add.rs:45:5 | LL | / if u_32 != u32::MAX { LL | | u_32 += 1; @@ -50,7 +50,7 @@ LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:49:5 + --> tests/ui/implicit_saturating_add.rs:49:5 | LL | / if u_32 < u32::MAX { LL | | u_32 += 1; @@ -58,7 +58,7 @@ LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:53:5 + --> tests/ui/implicit_saturating_add.rs:53:5 | LL | / if u32::MAX > u_32 { LL | | u_32 += 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ help: use instead: `u_32 = u_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:57:5 + --> tests/ui/implicit_saturating_add.rs:57:5 | LL | / if u_64 != u64::MAX { LL | | u_64 += 1; @@ -74,7 +74,7 @@ LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:61:5 + --> tests/ui/implicit_saturating_add.rs:61:5 | LL | / if u_64 < u64::MAX { LL | | u_64 += 1; @@ -82,7 +82,7 @@ LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:65:5 + --> tests/ui/implicit_saturating_add.rs:65:5 | LL | / if u64::MAX > u_64 { LL | | u_64 += 1; @@ -90,7 +90,7 @@ LL | | } | |_____^ help: use instead: `u_64 = u_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:69:5 + --> tests/ui/implicit_saturating_add.rs:69:5 | LL | / if i_8 != i8::MAX { LL | | i_8 += 1; @@ -98,7 +98,7 @@ LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:73:5 + --> tests/ui/implicit_saturating_add.rs:73:5 | LL | / if i_8 < i8::MAX { LL | | i_8 += 1; @@ -106,7 +106,7 @@ LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:77:5 + --> tests/ui/implicit_saturating_add.rs:77:5 | LL | / if i8::MAX > i_8 { LL | | i_8 += 1; @@ -114,7 +114,7 @@ LL | | } | |_____^ help: use instead: `i_8 = i_8.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:81:5 + --> tests/ui/implicit_saturating_add.rs:81:5 | LL | / if i_16 != i16::MAX { LL | | i_16 += 1; @@ -122,7 +122,7 @@ LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:85:5 + --> tests/ui/implicit_saturating_add.rs:85:5 | LL | / if i_16 < i16::MAX { LL | | i_16 += 1; @@ -130,7 +130,7 @@ LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:89:5 + --> tests/ui/implicit_saturating_add.rs:89:5 | LL | / if i16::MAX > i_16 { LL | | i_16 += 1; @@ -138,7 +138,7 @@ LL | | } | |_____^ help: use instead: `i_16 = i_16.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:93:5 + --> tests/ui/implicit_saturating_add.rs:93:5 | LL | / if i_32 != i32::MAX { LL | | i_32 += 1; @@ -146,7 +146,7 @@ LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:97:5 + --> tests/ui/implicit_saturating_add.rs:97:5 | LL | / if i_32 < i32::MAX { LL | | i_32 += 1; @@ -154,7 +154,7 @@ LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:101:5 + --> tests/ui/implicit_saturating_add.rs:101:5 | LL | / if i32::MAX > i_32 { LL | | i_32 += 1; @@ -162,7 +162,7 @@ LL | | } | |_____^ help: use instead: `i_32 = i_32.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:105:5 + --> tests/ui/implicit_saturating_add.rs:105:5 | LL | / if i_64 != i64::MAX { LL | | i_64 += 1; @@ -170,7 +170,7 @@ LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:109:5 + --> tests/ui/implicit_saturating_add.rs:109:5 | LL | / if i_64 < i64::MAX { LL | | i_64 += 1; @@ -178,7 +178,7 @@ LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:113:5 + --> tests/ui/implicit_saturating_add.rs:113:5 | LL | / if i64::MAX > i_64 { LL | | i_64 += 1; @@ -186,7 +186,7 @@ LL | | } | |_____^ help: use instead: `i_64 = i_64.saturating_add(1);` error: manual saturating add detected - --> $DIR/implicit_saturating_add.rs:149:12 + --> tests/ui/implicit_saturating_add.rs:149:12 | LL | } else if u_32 < u32::MAX { | ____________^ diff --git a/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr b/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr index 6e026d1a69875..59a9ddbff2d6e 100644 --- a/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr +++ b/src/tools/clippy/tests/ui/implicit_saturating_sub.stderr @@ -1,5 +1,5 @@ error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:27:5 + --> tests/ui/implicit_saturating_sub.rs:27:5 | LL | / if u_8 > 0 { LL | | u_8 = u_8 - 1; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_sub)]` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:34:13 + --> tests/ui/implicit_saturating_sub.rs:34:13 | LL | / if u_8 > 0 { LL | | u_8 -= 1; @@ -18,7 +18,7 @@ LL | | } | |_____________^ help: try: `u_8 = u_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:48:5 + --> tests/ui/implicit_saturating_sub.rs:48:5 | LL | / if u_16 > 0 { LL | | u_16 -= 1; @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try: `u_16 = u_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:58:5 + --> tests/ui/implicit_saturating_sub.rs:58:5 | LL | / if u_32 != 0 { LL | | u_32 -= 1; @@ -34,7 +34,7 @@ LL | | } | |_____^ help: try: `u_32 = u_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:79:5 + --> tests/ui/implicit_saturating_sub.rs:79:5 | LL | / if u_64 > 0 { LL | | u_64 -= 1; @@ -42,7 +42,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:84:5 + --> tests/ui/implicit_saturating_sub.rs:84:5 | LL | / if 0 < u_64 { LL | | u_64 -= 1; @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:89:5 + --> tests/ui/implicit_saturating_sub.rs:89:5 | LL | / if 0 != u_64 { LL | | u_64 -= 1; @@ -58,7 +58,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:110:5 + --> tests/ui/implicit_saturating_sub.rs:110:5 | LL | / if u_usize > 0 { LL | | u_usize -= 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ help: try: `u_usize = u_usize.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:122:5 + --> tests/ui/implicit_saturating_sub.rs:122:5 | LL | / if i_8 > i8::MIN { LL | | i_8 -= 1; @@ -74,7 +74,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:127:5 + --> tests/ui/implicit_saturating_sub.rs:127:5 | LL | / if i_8 > i8::MIN { LL | | i_8 -= 1; @@ -82,7 +82,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:132:5 + --> tests/ui/implicit_saturating_sub.rs:132:5 | LL | / if i_8 != i8::MIN { LL | | i_8 -= 1; @@ -90,7 +90,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:137:5 + --> tests/ui/implicit_saturating_sub.rs:137:5 | LL | / if i_8 != i8::MIN { LL | | i_8 -= 1; @@ -98,7 +98,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:147:5 + --> tests/ui/implicit_saturating_sub.rs:147:5 | LL | / if i_16 > i16::MIN { LL | | i_16 -= 1; @@ -106,7 +106,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:152:5 + --> tests/ui/implicit_saturating_sub.rs:152:5 | LL | / if i_16 > i16::MIN { LL | | i_16 -= 1; @@ -114,7 +114,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:157:5 + --> tests/ui/implicit_saturating_sub.rs:157:5 | LL | / if i_16 != i16::MIN { LL | | i_16 -= 1; @@ -122,7 +122,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:162:5 + --> tests/ui/implicit_saturating_sub.rs:162:5 | LL | / if i_16 != i16::MIN { LL | | i_16 -= 1; @@ -130,7 +130,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:172:5 + --> tests/ui/implicit_saturating_sub.rs:172:5 | LL | / if i_32 > i32::MIN { LL | | i_32 -= 1; @@ -138,7 +138,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:177:5 + --> tests/ui/implicit_saturating_sub.rs:177:5 | LL | / if i_32 > i32::MIN { LL | | i_32 -= 1; @@ -146,7 +146,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:182:5 + --> tests/ui/implicit_saturating_sub.rs:182:5 | LL | / if i_32 != i32::MIN { LL | | i_32 -= 1; @@ -154,7 +154,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:187:5 + --> tests/ui/implicit_saturating_sub.rs:187:5 | LL | / if i_32 != i32::MIN { LL | | i_32 -= 1; @@ -162,7 +162,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:197:5 + --> tests/ui/implicit_saturating_sub.rs:197:5 | LL | / if i64::MIN < i_64 { LL | | i_64 -= 1; @@ -170,7 +170,7 @@ LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:202:5 + --> tests/ui/implicit_saturating_sub.rs:202:5 | LL | / if i64::MIN != i_64 { LL | | i_64 -= 1; @@ -178,7 +178,7 @@ LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:207:5 + --> tests/ui/implicit_saturating_sub.rs:207:5 | LL | / if i64::MIN < i_64 { LL | | i_64 -= 1; diff --git a/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed b/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed index fa117aaddcd60..6fd4cbd80fe4e 100644 --- a/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed +++ b/src/tools/clippy/tests/ui/implied_bounds_in_impls.fixed @@ -1,5 +1,6 @@ #![warn(clippy::implied_bounds_in_impls)] #![allow(dead_code)] +#![feature(impl_trait_in_assoc_type, type_alias_impl_trait)] use std::ops::{Deref, DerefMut}; @@ -121,4 +122,55 @@ mod issue11435 { fn f3() -> impl Trait4 {} } +fn issue11880() { + trait X { + type T; + type U; + } + trait Y: X { + type T; + type V; + } + impl X for () { + type T = i32; + type U = String; + } + impl Y for () { + type T = u32; + type V = Vec; + } + + // Can't constrain `X::T` through `Y` + fn f() -> impl X + Y {} + fn f2() -> impl X + Y {} + + // X::T is never constrained in the first place, so it can be omitted + // and left unconstrained + fn f3() -> impl Y {} + fn f4() -> impl Y {} + fn f5() -> impl Y {} +} + +fn apit(_: impl DerefMut) {} + +trait Rpitit { + fn f() -> impl DerefMut; +} + +trait Atpit { + type Assoc; + fn define() -> Self::Assoc; +} +impl Atpit for () { + type Assoc = impl DerefMut; + fn define() -> Self::Assoc { + &mut [] as &mut [()] + } +} + +type Tait = impl DerefMut; +fn define() -> Tait { + &mut [] as &mut [()] +} + fn main() {} diff --git a/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs b/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs index c96aac151a7d0..52076c9f998ef 100644 --- a/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs +++ b/src/tools/clippy/tests/ui/implied_bounds_in_impls.rs @@ -1,5 +1,6 @@ #![warn(clippy::implied_bounds_in_impls)] #![allow(dead_code)] +#![feature(impl_trait_in_assoc_type, type_alias_impl_trait)] use std::ops::{Deref, DerefMut}; @@ -121,4 +122,55 @@ mod issue11435 { fn f3() -> impl Trait3 + Trait4 {} } +fn issue11880() { + trait X { + type T; + type U; + } + trait Y: X { + type T; + type V; + } + impl X for () { + type T = i32; + type U = String; + } + impl Y for () { + type T = u32; + type V = Vec; + } + + // Can't constrain `X::T` through `Y` + fn f() -> impl X + Y {} + fn f2() -> impl X + Y {} + + // X::T is never constrained in the first place, so it can be omitted + // and left unconstrained + fn f3() -> impl X + Y {} + fn f4() -> impl X + Y {} + fn f5() -> impl X + Y {} +} + +fn apit(_: impl Deref + DerefMut) {} + +trait Rpitit { + fn f() -> impl Deref + DerefMut; +} + +trait Atpit { + type Assoc; + fn define() -> Self::Assoc; +} +impl Atpit for () { + type Assoc = impl Deref + DerefMut; + fn define() -> Self::Assoc { + &mut [] as &mut [()] + } +} + +type Tait = impl Deref + DerefMut; +fn define() -> Tait { + &mut [] as &mut [()] +} + fn main() {} 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 fb44f2aba1744..805532a568020 100644 --- a/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr +++ b/src/tools/clippy/tests/ui/implied_bounds_in_impls.stderr @@ -1,5 +1,5 @@ error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:12:36 + --> tests/ui/implied_bounds_in_impls.rs:13:36 | LL | fn deref_derefmut(x: T) -> impl Deref + DerefMut { | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + fn deref_derefmut(x: T) -> impl DerefMut { | error: this bound is already specified as the supertrait of `GenericSubtrait` - --> $DIR/implied_bounds_in_impls.rs:29:37 + --> tests/ui/implied_bounds_in_impls.rs:30:37 | LL | fn generics_implied() -> impl GenericTrait + GenericSubtrait | ^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + fn generics_implied() -> impl GenericSubtrait | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, V>` - --> $DIR/implied_bounds_in_impls.rs:35:40 + --> tests/ui/implied_bounds_in_impls.rs:36:40 | LL | fn generics_implied_multi() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), i32, V> {} | ^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + fn generics_implied_multi() -> impl GenericTrait2 + GenericSubtrait<( | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, V>` - --> $DIR/implied_bounds_in_impls.rs:35:60 + --> tests/ui/implied_bounds_in_impls.rs:36:60 | LL | fn generics_implied_multi() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), i32, V> {} | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + fn generics_implied_multi() -> impl GenericTrait + GenericSubtrait< | error: this bound is already specified as the supertrait of `GenericSubtrait<(), T, V>` - --> $DIR/implied_bounds_in_impls.rs:37:44 + --> tests/ui/implied_bounds_in_impls.rs:38:44 | LL | fn generics_implied_multi2() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), T, V> | ^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + fn generics_implied_multi2() -> impl GenericTrait2 + GenericSubtra | error: this bound is already specified as the supertrait of `GenericSubtrait<(), T, V>` - --> $DIR/implied_bounds_in_impls.rs:37:62 + --> tests/ui/implied_bounds_in_impls.rs:38:62 | LL | fn generics_implied_multi2() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), T, V> | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + fn generics_implied_multi2() -> impl GenericTrait + GenericSubtrai | error: this bound is already specified as the supertrait of `GenericSubtrait<(), i32, ()>` - --> $DIR/implied_bounds_in_impls.rs:47:28 + --> tests/ui/implied_bounds_in_impls.rs:48:28 | LL | fn generics_same() -> impl GenericTrait + GenericSubtrait<(), i32, ()> {} | ^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + fn generics_same() -> impl GenericSubtrait<(), i32, ()> {} | error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:51:20 + --> tests/ui/implied_bounds_in_impls.rs:52:20 | LL | fn f() -> impl Deref + DerefMut; | ^^^^^ @@ -97,7 +97,7 @@ LL + fn f() -> impl DerefMut; | error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:56:20 + --> tests/ui/implied_bounds_in_impls.rs:57:20 | LL | fn f() -> impl Deref + DerefMut { | ^^^^^ @@ -109,7 +109,7 @@ LL + fn f() -> impl DerefMut { | error: this bound is already specified as the supertrait of `DerefMut` - --> $DIR/implied_bounds_in_impls.rs:62:20 + --> tests/ui/implied_bounds_in_impls.rs:63:20 | LL | fn f() -> impl Deref + DerefMut { | ^^^^^ @@ -121,7 +121,7 @@ LL + fn f() -> impl DerefMut { | error: this bound is already specified as the supertrait of `PartialOrd` - --> $DIR/implied_bounds_in_impls.rs:73:41 + --> tests/ui/implied_bounds_in_impls.rs:74:41 | LL | fn default_generic_param1() -> impl PartialEq + PartialOrd + Debug {} | ^^^^^^^^^ @@ -133,7 +133,7 @@ LL + fn default_generic_param1() -> impl PartialOrd + Debug {} | error: this bound is already specified as the supertrait of `PartialOrd` - --> $DIR/implied_bounds_in_impls.rs:74:54 + --> tests/ui/implied_bounds_in_impls.rs:75:54 | LL | fn default_generic_param2() -> impl PartialOrd + PartialEq + Debug {} | ^^^^^^^^^ @@ -145,7 +145,7 @@ LL + fn default_generic_param2() -> impl PartialOrd + Debug {} | error: this bound is already specified as the supertrait of `DoubleEndedIterator` - --> $DIR/implied_bounds_in_impls.rs:87:26 + --> tests/ui/implied_bounds_in_impls.rs:88:26 | LL | fn my_iter() -> impl Iterator + DoubleEndedIterator { | ^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + fn my_iter() -> impl DoubleEndedIterator { | error: this bound is already specified as the supertrait of `Copy` - --> $DIR/implied_bounds_in_impls.rs:92:27 + --> tests/ui/implied_bounds_in_impls.rs:93:27 | LL | fn f() -> impl Copy + Clone { | ^^^^^ @@ -169,7 +169,7 @@ LL + fn f() -> impl Copy { | error: this bound is already specified as the supertrait of `Trait2` - --> $DIR/implied_bounds_in_impls.rs:106:21 + --> tests/ui/implied_bounds_in_impls.rs:107:21 | LL | fn f2() -> impl Trait1 + Trait2 {} | ^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + fn f2() -> impl Trait2 {} | error: this bound is already specified as the supertrait of `Trait4` - --> $DIR/implied_bounds_in_impls.rs:121:21 + --> tests/ui/implied_bounds_in_impls.rs:122:21 | LL | fn f3() -> impl Trait3 + Trait4 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -192,5 +192,89 @@ LL - fn f3() -> impl Trait3 + Trait4 impl Trait4 {} | -error: aborting due to 16 previous errors +error: this bound is already specified as the supertrait of `Y` + --> tests/ui/implied_bounds_in_impls.rs:149:21 + | +LL | fn f3() -> impl X + Y {} + | ^ + | +help: try removing this bound + | +LL - fn f3() -> impl X + Y {} +LL + fn f3() -> impl Y {} + | + +error: this bound is already specified as the supertrait of `Y` + --> tests/ui/implied_bounds_in_impls.rs:150:21 + | +LL | fn f4() -> impl X + Y {} + | ^ + | +help: try removing this bound + | +LL - fn f4() -> impl X + Y {} +LL + fn f4() -> impl Y {} + | + +error: this bound is already specified as the supertrait of `Y` + --> tests/ui/implied_bounds_in_impls.rs:151:21 + | +LL | fn f5() -> impl X + Y {} + | ^^^^^^^^^^^^^ + | +help: try removing this bound + | +LL - fn f5() -> impl X + Y {} +LL + fn f5() -> impl Y {} + | + +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:154:17 + | +LL | fn apit(_: impl Deref + DerefMut) {} + | ^^^^^ + | +help: try removing this bound + | +LL - fn apit(_: impl Deref + DerefMut) {} +LL + fn apit(_: impl DerefMut) {} + | + +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:157:20 + | +LL | fn f() -> impl Deref + DerefMut; + | ^^^^^ + | +help: try removing this bound + | +LL - fn f() -> impl Deref + DerefMut; +LL + fn f() -> impl DerefMut; + | + +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:165:23 + | +LL | type Assoc = impl Deref + DerefMut; + | ^^^^^ + | +help: try removing this bound + | +LL - type Assoc = impl Deref + DerefMut; +LL + type Assoc = impl DerefMut; + | + +error: this bound is already specified as the supertrait of `DerefMut` + --> tests/ui/implied_bounds_in_impls.rs:171:18 + | +LL | type Tait = impl Deref + DerefMut; + | ^^^^^ + | +help: try removing this bound + | +LL - type Tait = impl Deref + DerefMut; +LL + type Tait = impl DerefMut; + | + +error: aborting due to 23 previous errors diff --git a/src/tools/clippy/tests/ui/incompatible_msrv.rs b/src/tools/clippy/tests/ui/incompatible_msrv.rs index a92017fb0f626..8ef1f554bc35d 100644 --- a/src/tools/clippy/tests/ui/incompatible_msrv.rs +++ b/src/tools/clippy/tests/ui/incompatible_msrv.rs @@ -4,6 +4,7 @@ use std::collections::hash_map::Entry; use std::collections::HashMap; +use std::future::Future; use std::thread::sleep; use std::time::Duration; @@ -20,4 +21,16 @@ fn foo() { //~^ ERROR: is `1.3.0` but this item is stable since `1.4.0` } +#[test] +fn test() { + sleep(Duration::new(1, 0)); +} + +#[clippy::msrv = "1.63.0"] +async fn issue12273(v: impl Future) { + // `.await` desugaring has a call to `IntoFuture::into_future` marked #[stable(since = "1.64.0")], + // but its stability is ignored + v.await; +} + fn main() {} diff --git a/src/tools/clippy/tests/ui/incompatible_msrv.stderr b/src/tools/clippy/tests/ui/incompatible_msrv.stderr index bd5ecd6ed2ffb..34f01c3e14a17 100644 --- a/src/tools/clippy/tests/ui/incompatible_msrv.stderr +++ b/src/tools/clippy/tests/ui/incompatible_msrv.stderr @@ -1,5 +1,5 @@ error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.10.0` - --> $DIR/incompatible_msrv.rs:12:39 + --> tests/ui/incompatible_msrv.rs:13:39 | LL | assert_eq!(map.entry("poneyland").key(), &"poneyland"); | ^^^^^ @@ -8,13 +8,13 @@ LL | assert_eq!(map.entry("poneyland").key(), &"poneyland"); = help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]` error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.12.0` - --> $DIR/incompatible_msrv.rs:15:11 + --> tests/ui/incompatible_msrv.rs:16:11 | LL | v.into_key(); | ^^^^^^^^^^ error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.4.0` - --> $DIR/incompatible_msrv.rs:19:5 + --> tests/ui/incompatible_msrv.rs:20:5 | LL | sleep(Duration::new(1, 0)); | ^^^^^ diff --git a/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr b/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr index 6aeb33edafd3c..173b824935c8f 100644 --- a/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr +++ b/src/tools/clippy/tests/ui/inconsistent_digit_grouping.stderr @@ -1,5 +1,5 @@ error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:16 + --> tests/ui/inconsistent_digit_grouping.rs:25:16 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` @@ -8,61 +8,61 @@ LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:26 + --> tests/ui/inconsistent_digit_grouping.rs:25:26 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^ help: consider: `12_345_678` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:38 + --> tests/ui/inconsistent_digit_grouping.rs:25:38 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `1_234_567` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:48 + --> tests/ui/inconsistent_digit_grouping.rs:25:48 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1_234.567_8_f32` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:25:64 + --> tests/ui/inconsistent_digit_grouping.rs:25:64 | LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1.234_567_8_f32` error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:28:13 + --> tests/ui/inconsistent_digit_grouping.rs:28:13 | LL | let _ = 0x100000; | ^^^^^^^^ help: consider: `0x0010_0000` | note: the lint level is defined here - --> $DIR/inconsistent_digit_grouping.rs:2:8 + --> tests/ui/inconsistent_digit_grouping.rs:2:8 | LL | #[deny(clippy::unreadable_literal)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:29:13 + --> tests/ui/inconsistent_digit_grouping.rs:29:13 | LL | let _ = 0x1000000; | ^^^^^^^^^ help: consider: `0x0100_0000` error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:30:13 + --> tests/ui/inconsistent_digit_grouping.rs:30:13 | LL | let _ = 0x10000000; | ^^^^^^^^^^ help: consider: `0x1000_0000` error: long literal lacking separators - --> $DIR/inconsistent_digit_grouping.rs:31:13 + --> tests/ui/inconsistent_digit_grouping.rs:31:13 | LL | let _ = 0x100000000_u64; | ^^^^^^^^^^^^^^^ help: consider: `0x0001_0000_0000_u64` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:34:18 + --> tests/ui/inconsistent_digit_grouping.rs:34:18 | LL | let _: f32 = 1_23_456.; | ^^^^^^^^^ help: consider: `123_456.` diff --git a/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr b/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr index fc080d7ec057d..1192271f911fd 100644 --- a/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr +++ b/src/tools/clippy/tests/ui/inconsistent_struct_constructor.stderr @@ -1,5 +1,5 @@ error: struct constructor field order is inconsistent with struct definition field order - --> $DIR/inconsistent_struct_constructor.rs:28:9 + --> tests/ui/inconsistent_struct_constructor.rs:28:9 | LL | Foo { y, x, z }; | ^^^^^^^^^^^^^^^ help: try: `Foo { x, y, z }` @@ -8,7 +8,7 @@ LL | Foo { y, x, z }; = 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 + --> tests/ui/inconsistent_struct_constructor.rs:55:9 | LL | / Foo { LL | | z, diff --git a/src/tools/clippy/tests/ui/index_refutable_slice/if_let_slice_binding.stderr b/src/tools/clippy/tests/ui/index_refutable_slice/if_let_slice_binding.stderr index f0e635954c5a9..14e0f931f2401 100644 --- a/src/tools/clippy/tests/ui/index_refutable_slice/if_let_slice_binding.stderr +++ b/src/tools/clippy/tests/ui/index_refutable_slice/if_let_slice_binding.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:14:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:14:17 | LL | if let Some(slice) = slice { | ^^^^^ | note: the lint level is defined here - --> $DIR/if_let_slice_binding.rs:1:9 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:21:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:21:17 | LL | if let Some(slice) = slice { | ^^^^^ @@ -34,7 +34,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:28:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:28:17 | LL | if let Some(slice) = slice { | ^^^^^ @@ -50,7 +50,7 @@ LL ~ println!("{}", slice_0); | error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:36:26 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:36:26 | LL | if let SomeEnum::One(slice) | SomeEnum::Three(slice) = slice_wrapped { | ^^^^^ @@ -65,7 +65,7 @@ LL | println!("{}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:44:29 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:44:29 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { | ^ @@ -80,7 +80,7 @@ LL | println!("{} -> {}", a_2, b[1]); | ~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:44:38 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:44:38 | LL | if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { | ^ @@ -95,7 +95,7 @@ LL | println!("{} -> {}", a[2], b_1); | ~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:53:21 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:53:21 | LL | if let Some(ref slice) = slice { | ^^^^^ @@ -110,7 +110,7 @@ LL | println!("{:?}", slice_1); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:62:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:62:17 | LL | if let Some(slice) = &slice { | ^^^^^ @@ -125,7 +125,7 @@ LL | println!("{:?}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:132:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:132:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ @@ -140,7 +140,7 @@ LL | println!("This is awesome! {}", slice_0); | ~~~~~~~ error: this binding can be a slice pattern to avoid indexing - --> $DIR/if_let_slice_binding.rs:140:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:140:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ diff --git a/src/tools/clippy/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr b/src/tools/clippy/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr index 429861e993e82..caccd0f9295e1 100644 --- a/src/tools/clippy/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr +++ b/src/tools/clippy/tests/ui/index_refutable_slice/slice_indexing_in_macro.stderr @@ -1,11 +1,11 @@ error: this binding can be a slice pattern to avoid indexing - --> $DIR/slice_indexing_in_macro.rs:23:21 + --> tests/ui/index_refutable_slice/slice_indexing_in_macro.rs:23:21 | LL | if let Some(slice) = slice; | ^^^^^ | note: the lint level is defined here - --> $DIR/slice_indexing_in_macro.rs:1:9 + --> tests/ui/index_refutable_slice/slice_indexing_in_macro.rs:1:9 | LL | #![deny(clippy::index_refutable_slice)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr index 2996e31a1aa26..06a4defcb9314 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr +++ b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr @@ -1,5 +1,5 @@ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:14:20 + --> tests/ui/indexing_slicing_index.rs:14:20 | LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false. | ^^^^^^^^^^ @@ -10,19 +10,19 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/indexing_slicing_index.rs:46:14 + --> tests/ui/indexing_slicing_index.rs:46:14 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant encountered - --> $DIR/indexing_slicing_index.rs:46:5 + --> tests/ui/indexing_slicing_index.rs:46:5 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^^^^^^^^^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:27:5 + --> tests/ui/indexing_slicing_index.rs:27:5 | LL | x[index]; | ^^^^^^^^ @@ -30,7 +30,7 @@ LL | x[index]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:30:5 + --> tests/ui/indexing_slicing_index.rs:30:5 | LL | x[4]; | ^^^^ @@ -39,13 +39,13 @@ LL | x[4]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:32:5 + --> tests/ui/indexing_slicing_index.rs:32:5 | LL | x[1 << 3]; | ^^^^^^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:43:14 + --> tests/ui/indexing_slicing_index.rs:43:14 | LL | const { &ARR[idx()] }; | ^^^^^^^^^^ @@ -54,7 +54,7 @@ LL | const { &ARR[idx()] }; = note: the suggestion might not be applicable in constant blocks error: indexing may panic - --> $DIR/indexing_slicing_index.rs:46:14 + --> tests/ui/indexing_slicing_index.rs:46:14 | LL | const { &ARR[idx4()] }; | ^^^^^^^^^^^ @@ -63,13 +63,13 @@ LL | const { &ARR[idx4()] }; = note: the suggestion might not be applicable in constant blocks error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:53:5 + --> tests/ui/indexing_slicing_index.rs:53:5 | LL | y[4]; | ^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:56:5 + --> tests/ui/indexing_slicing_index.rs:56:5 | LL | v[0]; | ^^^^ @@ -77,7 +77,7 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:58:5 + --> tests/ui/indexing_slicing_index.rs:58:5 | LL | v[10]; | ^^^^^ @@ -85,7 +85,7 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:60:5 + --> tests/ui/indexing_slicing_index.rs:60:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -93,13 +93,13 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:68:5 + --> tests/ui/indexing_slicing_index.rs:68:5 | LL | x[N]; | ^^^^ error: indexing may panic - --> $DIR/indexing_slicing_index.rs:71:5 + --> tests/ui/indexing_slicing_index.rs:71:5 | LL | v[N]; | ^^^^ @@ -107,7 +107,7 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/indexing_slicing_index.rs:73:5 + --> tests/ui/indexing_slicing_index.rs:73:5 | LL | v[M]; | ^^^^ @@ -115,7 +115,7 @@ LL | v[M]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: index is out of bounds - --> $DIR/indexing_slicing_index.rs:77:13 + --> tests/ui/indexing_slicing_index.rs:77:13 | LL | let _ = x[4]; | ^^^^ diff --git a/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr b/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr index eebe67810a024..790d4a41f5b1e 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr +++ b/src/tools/clippy/tests/ui/indexing_slicing_slice.stderr @@ -1,5 +1,5 @@ error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:12:6 + --> tests/ui/indexing_slicing_slice.rs:12:6 | LL | &x[index..]; | ^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | &x[index..]; = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:14:6 + --> tests/ui/indexing_slicing_slice.rs:14:6 | LL | &x[..index]; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | &x[..index]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:16:6 + --> tests/ui/indexing_slicing_slice.rs:16:6 | LL | &x[index_from..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | &x[index_from..index_to]; = help: consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:18:6 + --> tests/ui/indexing_slicing_slice.rs:18:6 | LL | &x[index_from..][..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | &x[index_from..][..index_to]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:18:6 + --> tests/ui/indexing_slicing_slice.rs:18:6 | LL | &x[index_from..][..index_to]; | ^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | &x[index_from..][..index_to]; = help: consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:21:6 + --> tests/ui/indexing_slicing_slice.rs:21:6 | LL | &x[5..][..10]; | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | &x[5..][..10]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:21:8 + --> tests/ui/indexing_slicing_slice.rs:21:8 | LL | &x[5..][..10]; | ^ @@ -58,7 +58,7 @@ LL | &x[5..][..10]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:25:6 + --> tests/ui/indexing_slicing_slice.rs:25:6 | LL | &x[0..][..3]; | ^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | &x[0..][..3]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:27:6 + --> tests/ui/indexing_slicing_slice.rs:27:6 | LL | &x[1..][..5]; | ^^^^^^^^^^^ @@ -74,19 +74,19 @@ LL | &x[1..][..5]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:35:12 + --> tests/ui/indexing_slicing_slice.rs:35:12 | LL | &y[0..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:37:11 + --> tests/ui/indexing_slicing_slice.rs:37:11 | LL | &y[..=4]; | ^ error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:43:6 + --> tests/ui/indexing_slicing_slice.rs:43:6 | LL | &v[10..100]; | ^^^^^^^^^^ @@ -94,7 +94,7 @@ LL | &v[10..100]; = help: consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:45:6 + --> tests/ui/indexing_slicing_slice.rs:45:6 | LL | &x[10..][..100]; | ^^^^^^^^^^^^^^ @@ -102,13 +102,13 @@ LL | &x[10..][..100]; = help: consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing_slice.rs:45:8 + --> tests/ui/indexing_slicing_slice.rs:45:8 | LL | &x[10..][..100]; | ^^ error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:48:6 + --> tests/ui/indexing_slicing_slice.rs:48:6 | LL | &v[10..]; | ^^^^^^^ @@ -116,7 +116,7 @@ LL | &v[10..]; = help: consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic - --> $DIR/indexing_slicing_slice.rs:50:6 + --> tests/ui/indexing_slicing_slice.rs:50:6 | LL | &v[..100]; | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/ineffective_open_options.stderr b/src/tools/clippy/tests/ui/ineffective_open_options.stderr index 7dc5322232c00..0d6933bb449e8 100644 --- a/src/tools/clippy/tests/ui/ineffective_open_options.stderr +++ b/src/tools/clippy/tests/ui/ineffective_open_options.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `.write(true)` because there is `.append(true)` - --> $DIR/ineffective_open_options.rs:8:9 + --> tests/ui/ineffective_open_options.rs:8:9 | LL | .write(true) | ^^^^^^^^^^^^ help: remove `.write(true)` @@ -8,7 +8,7 @@ LL | .write(true) = help: to override `-D warnings` add `#[allow(clippy::ineffective_open_options)]` error: unnecessary use of `.write(true)` because there is `.append(true)` - --> $DIR/ineffective_open_options.rs:16:9 + --> tests/ui/ineffective_open_options.rs:16:9 | LL | .write(true) | ^^^^^^^^^^^^ help: remove `.write(true)` diff --git a/src/tools/clippy/tests/ui/inefficient_to_string.stderr b/src/tools/clippy/tests/ui/inefficient_to_string.stderr index 4b93465c4f9dd..e71e667cf0cfe 100644 --- a/src/tools/clippy/tests/ui/inefficient_to_string.stderr +++ b/src/tools/clippy/tests/ui/inefficient_to_string.stderr @@ -1,18 +1,18 @@ error: calling `to_string` on `&&str` - --> $DIR/inefficient_to_string.rs:10:21 + --> tests/ui/inefficient_to_string.rs:10:21 | LL | let _: String = rrstr.to_string(); | ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrstr).to_string()` | = help: `&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString` note: the lint level is defined here - --> $DIR/inefficient_to_string.rs:1:9 + --> tests/ui/inefficient_to_string.rs:1:9 | LL | #![deny(clippy::inefficient_to_string)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `to_string` on `&&&str` - --> $DIR/inefficient_to_string.rs:11:21 + --> tests/ui/inefficient_to_string.rs:11:21 | LL | let _: String = rrrstr.to_string(); | ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstr).to_string()` @@ -20,7 +20,7 @@ LL | let _: String = rrrstr.to_string(); = help: `&&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString` error: calling `to_string` on `&&std::string::String` - --> $DIR/inefficient_to_string.rs:19:21 + --> tests/ui/inefficient_to_string.rs:19:21 | LL | let _: String = rrstring.to_string(); | ^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrstring).to_string()` @@ -28,7 +28,7 @@ LL | let _: String = rrstring.to_string(); = help: `&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString` error: calling `to_string` on `&&&std::string::String` - --> $DIR/inefficient_to_string.rs:20:21 + --> tests/ui/inefficient_to_string.rs:20:21 | LL | let _: String = rrrstring.to_string(); | ^^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstring).to_string()` @@ -36,7 +36,7 @@ LL | let _: String = rrrstring.to_string(); = help: `&&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString` error: calling `to_string` on `&&std::borrow::Cow<'_, str>` - --> $DIR/inefficient_to_string.rs:28:21 + --> tests/ui/inefficient_to_string.rs:28:21 | LL | let _: String = rrcow.to_string(); | ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrcow).to_string()` @@ -44,7 +44,7 @@ LL | let _: String = rrcow.to_string(); = help: `&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString` error: calling `to_string` on `&&&std::borrow::Cow<'_, str>` - --> $DIR/inefficient_to_string.rs:29:21 + --> tests/ui/inefficient_to_string.rs:29:21 | LL | let _: String = rrrcow.to_string(); | ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrcow).to_string()` diff --git a/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr b/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr index 93851aae82bd7..b709fd8630e99 100644 --- a/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr +++ b/src/tools/clippy/tests/ui/infallible_destructuring_match.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:28:5 + --> tests/ui/infallible_destructuring_match.rs:28:5 | LL | / let data = match wrapper { LL | | SingleVariantEnum::Variant(i) => i, @@ -10,7 +10,7 @@ LL | | }; = 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 + --> tests/ui/infallible_destructuring_match.rs:60:5 | LL | / let data = match wrapper { LL | | TupleStruct(i) => i, @@ -18,7 +18,7 @@ LL | | }; | |______^ help: try: `let TupleStruct(data) = wrapper;` error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:84:5 + --> tests/ui/infallible_destructuring_match.rs:84:5 | LL | / let data = match wrapper { LL | | TupleStructWithNonCopy(ref n) => n, @@ -26,7 +26,7 @@ LL | | }; | |______^ help: try: `let TupleStructWithNonCopy(ref data) = wrapper;` error: you seem to be trying to use `match` to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:103:5 + --> tests/ui/infallible_destructuring_match.rs:103:5 | LL | / let data = match wrapper { LL | | Ok(i) => i, diff --git a/src/tools/clippy/tests/ui/infinite_iter.stderr b/src/tools/clippy/tests/ui/infinite_iter.stderr index d0d0f0db443bb..e33d83b75edb0 100644 --- a/src/tools/clippy/tests/ui/infinite_iter.stderr +++ b/src/tools/clippy/tests/ui/infinite_iter.stderr @@ -1,29 +1,29 @@ error: infinite iteration detected - --> $DIR/infinite_iter.rs:11:5 + --> tests/ui/infinite_iter.rs:11:5 | LL | repeat(0_u8).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/infinite_iter.rs:9:8 + --> tests/ui/infinite_iter.rs:9:8 | LL | #[deny(clippy::infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:14:5 + --> tests/ui/infinite_iter.rs:14:5 | LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:17:5 + --> tests/ui/infinite_iter.rs:17:5 | LL | (0..8_u64).chain(0..).max(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:25:5 + --> tests/ui/infinite_iter.rs:25:5 | LL | / (0..8_u32) LL | | @@ -34,37 +34,37 @@ LL | | .for_each(|x| println!("{}", x)); | |________________________________________^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:34:5 + --> tests/ui/infinite_iter.rs:34:5 | LL | (0_usize..).flat_map(|x| 0..x).product::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:37:5 + --> tests/ui/infinite_iter.rs:37:5 | LL | (0_u64..).filter(|x| x % 2 == 0).last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:48:5 + --> tests/ui/infinite_iter.rs:48:5 | LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/infinite_iter.rs:45:8 + --> tests/ui/infinite_iter.rs:45:8 | LL | #[deny(clippy::maybe_infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:51:5 + --> tests/ui/infinite_iter.rs:51:5 | LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:54:5 + --> tests/ui/infinite_iter.rs:54:5 | LL | / (1..) LL | | @@ -76,31 +76,31 @@ LL | | .min(); | |______________^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:62:5 + --> tests/ui/infinite_iter.rs:62:5 | LL | (0..).find(|x| *x == 24); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:65:5 + --> tests/ui/infinite_iter.rs:65:5 | LL | (0..).position(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:68:5 + --> tests/ui/infinite_iter.rs:68:5 | LL | (0..).any(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:71:5 + --> tests/ui/infinite_iter.rs:71:5 | LL | (0..).all(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:97:31 + --> tests/ui/infinite_iter.rs:97:31 | LL | let _: HashSet = (0..).collect(); | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/infinite_loop.stderr b/src/tools/clippy/tests/ui/infinite_loop.stderr index a78e47d02290c..7ba1374d64f46 100644 --- a/src/tools/clippy/tests/ui/infinite_loop.stderr +++ b/src/tools/clippy/tests/ui/infinite_loop.stderr @@ -1,5 +1,5 @@ error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:22:11 + --> tests/ui/infinite_loop.rs:22:11 | LL | while y < 10 { | ^^^^^^ @@ -8,7 +8,7 @@ LL | while y < 10 { = note: `#[deny(clippy::while_immutable_condition)]` on by default error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:29:11 + --> tests/ui/infinite_loop.rs:29:11 | LL | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | while y < 10 && x < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:38:11 + --> tests/ui/infinite_loop.rs:38:11 | LL | while !cond { | ^^^^^ @@ -24,7 +24,7 @@ LL | while !cond { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:84:11 + --> tests/ui/infinite_loop.rs:84:11 | LL | while i < 3 { | ^^^^^ @@ -32,7 +32,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:91:11 + --> tests/ui/infinite_loop.rs:91:11 | LL | while i < 3 && j > 0 { | ^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | while i < 3 && j > 0 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:97:11 + --> tests/ui/infinite_loop.rs:97:11 | LL | while i < 3 { | ^^^^^ @@ -48,7 +48,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:114:11 + --> tests/ui/infinite_loop.rs:114:11 | LL | while i < 3 { | ^^^^^ @@ -56,7 +56,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:121:11 + --> tests/ui/infinite_loop.rs:121:11 | LL | while i < 3 { | ^^^^^ @@ -64,7 +64,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:189:15 + --> tests/ui/infinite_loop.rs:189:15 | LL | while self.count < n { | ^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | while self.count < n { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:199:11 + --> tests/ui/infinite_loop.rs:199:11 | LL | while y < 10 { | ^^^^^^ @@ -82,7 +82,7 @@ LL | while y < 10 { = help: rewrite it as `if cond { loop { } }` error: variables in the condition are not mutated in the loop body - --> $DIR/infinite_loop.rs:208:11 + --> tests/ui/infinite_loop.rs:208:11 | LL | while y < 10 { | ^^^^^^ diff --git a/src/tools/clippy/tests/ui/infinite_loops.rs b/src/tools/clippy/tests/ui/infinite_loops.rs index 646f1eca56d01..52fbbaa8e31e9 100644 --- a/src/tools/clippy/tests/ui/infinite_loops.rs +++ b/src/tools/clippy/tests/ui/infinite_loops.rs @@ -1,7 +1,12 @@ //@no-rustfix +//@aux-build:proc_macros.rs + #![allow(clippy::never_loop)] #![warn(clippy::infinite_loop)] +extern crate proc_macros; +use proc_macros::{external, with_span}; + fn do_something() {} fn no_break() { @@ -363,4 +368,26 @@ fn inf_loop_in_res() -> Result<(), i32> { }) } +with_span! { span + fn no_loop() {} +} + +with_span! { span + fn with_loop() { + loop { + do_nothing(); + } + } +} + +fn do_nothing() {} + +fn span_inside_fn() { + with_span! { span + loop { + do_nothing(); + } + } +} + fn main() {} diff --git a/src/tools/clippy/tests/ui/infinite_loops.stderr b/src/tools/clippy/tests/ui/infinite_loops.stderr index 771fbfa44ee9f..ec6bd81dc1759 100644 --- a/src/tools/clippy/tests/ui/infinite_loops.stderr +++ b/src/tools/clippy/tests/ui/infinite_loops.stderr @@ -1,5 +1,5 @@ error: infinite loop detected - --> $DIR/infinite_loops.rs:8:5 + --> tests/ui/infinite_loops.rs:13:5 | LL | / loop { LL | | @@ -15,7 +15,7 @@ LL | fn no_break() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:15:5 + --> tests/ui/infinite_loops.rs:20:5 | LL | / loop { LL | | @@ -32,7 +32,7 @@ LL | fn all_inf() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:17:9 + --> tests/ui/infinite_loops.rs:22:9 | LL | / loop { LL | | @@ -49,7 +49,7 @@ LL | fn all_inf() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:19:13 + --> tests/ui/infinite_loops.rs:24:13 | LL | / loop { LL | | @@ -63,7 +63,7 @@ LL | fn all_inf() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:33:5 + --> tests/ui/infinite_loops.rs:38:5 | LL | / loop { LL | | @@ -74,7 +74,7 @@ LL | | } = help: if this is not intended, try adding a `break` or `return` condition in the loop error: infinite loop detected - --> $DIR/infinite_loops.rs:46:5 + --> tests/ui/infinite_loops.rs:51:5 | LL | / loop { LL | | fn inner_fn() -> ! { @@ -90,7 +90,7 @@ LL | fn no_break_never_ret_noise() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:89:5 + --> tests/ui/infinite_loops.rs:94:5 | LL | / loop { LL | | @@ -107,7 +107,7 @@ LL | fn break_inner_but_not_outer_1(cond: bool) -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:100:5 + --> tests/ui/infinite_loops.rs:105:5 | LL | / loop { LL | | @@ -124,7 +124,7 @@ LL | fn break_inner_but_not_outer_2(cond: bool) -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:114:9 + --> tests/ui/infinite_loops.rs:119:9 | LL | / loop { LL | | @@ -138,7 +138,7 @@ LL | fn break_outer_but_not_inner() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:137:9 + --> tests/ui/infinite_loops.rs:142:9 | LL | / loop { LL | | @@ -155,7 +155,7 @@ LL | fn break_wrong_loop(cond: bool) -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:177:5 + --> tests/ui/infinite_loops.rs:182:5 | LL | / loop { LL | | @@ -172,7 +172,7 @@ LL | fn match_like() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:218:5 + --> tests/ui/infinite_loops.rs:223:5 | LL | / loop { LL | | @@ -186,7 +186,7 @@ LL | fn match_like() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:223:5 + --> tests/ui/infinite_loops.rs:228:5 | LL | / loop { LL | | @@ -203,7 +203,7 @@ LL | fn match_like() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:328:9 + --> tests/ui/infinite_loops.rs:333:9 | LL | / loop { LL | | @@ -217,7 +217,7 @@ LL | fn problematic_trait_method() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:338:9 + --> tests/ui/infinite_loops.rs:343:9 | LL | / loop { LL | | @@ -231,7 +231,7 @@ LL | fn could_be_problematic() -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:347:9 + --> tests/ui/infinite_loops.rs:352:9 | LL | / loop { LL | | @@ -245,7 +245,7 @@ LL | let _loop_forever = || -> ! { | ++++ error: infinite loop detected - --> $DIR/infinite_loops.rs:361:8 + --> tests/ui/infinite_loops.rs:366:8 | LL | Ok(loop { | ________^ diff --git a/src/tools/clippy/tests/ui/inherent_to_string.stderr b/src/tools/clippy/tests/ui/inherent_to_string.stderr index cf8d09180191b..eb22525a24919 100644 --- a/src/tools/clippy/tests/ui/inherent_to_string.stderr +++ b/src/tools/clippy/tests/ui/inherent_to_string.stderr @@ -1,5 +1,5 @@ error: implementation of inherent method `to_string(&self) -> String` for type `A` - --> $DIR/inherent_to_string.rs:22:5 + --> tests/ui/inherent_to_string.rs:22:5 | LL | / fn to_string(&self) -> String { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/inherent_to_string.rs:47:5 | LL | / fn to_string(&self) -> String { LL | | 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 60f6eb8dff082..89db710fabe77 100644 --- a/src/tools/clippy/tests/ui/inline_fn_without_body.stderr +++ b/src/tools/clippy/tests/ui/inline_fn_without_body.stderr @@ -1,5 +1,5 @@ error: use of `#[inline]` on trait method `default_inline` which has no body - --> $DIR/inline_fn_without_body.rs:5:5 + --> tests/ui/inline_fn_without_body.rs:5:5 | LL | #[inline] | _____-^^^^^^^^ @@ -10,7 +10,7 @@ LL | | fn default_inline(); = 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 + --> tests/ui/inline_fn_without_body.rs:8:5 | LL | #[inline(always)] | _____-^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | | fn always_inline(); | |____- help: remove error: use of `#[inline]` on trait method `never_inline` which has no body - --> $DIR/inline_fn_without_body.rs:11:5 + --> tests/ui/inline_fn_without_body.rs:11:5 | LL | #[inline(never)] | _____-^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/inspect_for_each.stderr b/src/tools/clippy/tests/ui/inspect_for_each.stderr index 8bd4fe3987c5d..3c2dee15ebd5b 100644 --- a/src/tools/clippy/tests/ui/inspect_for_each.stderr +++ b/src/tools/clippy/tests/ui/inspect_for_each.stderr @@ -1,5 +1,5 @@ error: called `inspect(..).for_each(..)` on an `Iterator` - --> $DIR/inspect_for_each.rs:7:19 + --> tests/ui/inspect_for_each.rs:7:19 | LL | a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| { | ___________________^ diff --git a/src/tools/clippy/tests/ui/int_plus_one.stderr b/src/tools/clippy/tests/ui/int_plus_one.stderr index 6a62eac7cc476..cedac14f350d4 100644 --- a/src/tools/clippy/tests/ui/int_plus_one.stderr +++ b/src/tools/clippy/tests/ui/int_plus_one.stderr @@ -1,5 +1,5 @@ error: unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:7:13 + --> tests/ui/int_plus_one.rs:7:13 | LL | let _ = x >= y + 1; | ^^^^^^^^^^ help: change it to: `x > y` @@ -8,19 +8,19 @@ LL | let _ = x >= y + 1; = 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 + --> tests/ui/int_plus_one.rs:8:13 | LL | let _ = y + 1 <= x; | ^^^^^^^^^^ help: change it to: `y < x` error: unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:10:13 + --> tests/ui/int_plus_one.rs:10:13 | LL | let _ = x - 1 >= y; | ^^^^^^^^^^ help: change it to: `x > y` error: unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:11:13 + --> tests/ui/int_plus_one.rs:11:13 | LL | let _ = y <= x - 1; | ^^^^^^^^^^ help: change it to: `y < x` diff --git a/src/tools/clippy/tests/ui/integer_division.stderr b/src/tools/clippy/tests/ui/integer_division.stderr index 420f0f30e77cf..5f0d905a48b63 100644 --- a/src/tools/clippy/tests/ui/integer_division.stderr +++ b/src/tools/clippy/tests/ui/integer_division.stderr @@ -1,5 +1,5 @@ error: integer division - --> $DIR/integer_division.rs:5:13 + --> tests/ui/integer_division.rs:5:13 | LL | let n = 1 / 2; | ^^^^^ @@ -9,7 +9,7 @@ LL | let n = 1 / 2; = help: to override `-D warnings` add `#[allow(clippy::integer_division)]` error: integer division - --> $DIR/integer_division.rs:7:13 + --> tests/ui/integer_division.rs:7:13 | LL | let o = 1 / two; | ^^^^^^^ @@ -17,7 +17,7 @@ LL | let o = 1 / two; = help: division of integers may cause loss of precision. consider using floats error: integer division - --> $DIR/integer_division.rs:9:13 + --> tests/ui/integer_division.rs:9:13 | LL | let p = two / 4; | ^^^^^^^ 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 481957d50e205..0e9d485f1a9d9 100644 --- a/src/tools/clippy/tests/ui/into_iter_on_ref.stderr +++ b/src/tools/clippy/tests/ui/into_iter_on_ref.stderr @@ -1,5 +1,5 @@ error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` - --> $DIR/into_iter_on_ref.rs:13:30 + --> tests/ui/into_iter_on_ref.rs:13:30 | LL | let _ = (&vec![1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` @@ -8,157 +8,157 @@ LL | let _ = (&vec![1, 2, 3]).into_iter(); = 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 + --> tests/ui/into_iter_on_ref.rs:14:46 | LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` - --> $DIR/into_iter_on_ref.rs:15:41 + --> tests/ui/into_iter_on_ref.rs:15:41 | LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` - --> $DIR/into_iter_on_ref.rs:16:44 + --> tests/ui/into_iter_on_ref.rs:16:44 | LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:18:32 + --> tests/ui/into_iter_on_ref.rs:18:32 | LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:19:36 + --> tests/ui/into_iter_on_ref.rs:19:36 | LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:20:40 + --> tests/ui/into_iter_on_ref.rs:20:40 | LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Option` - --> $DIR/into_iter_on_ref.rs:22:24 + --> tests/ui/into_iter_on_ref.rs:22:24 | LL | let _ = (&Some(4)).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Option` - --> $DIR/into_iter_on_ref.rs:23:28 + --> tests/ui/into_iter_on_ref.rs:23:28 | LL | let _ = (&mut Some(5)).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Result` - --> $DIR/into_iter_on_ref.rs:24:32 + --> tests/ui/into_iter_on_ref.rs:24:32 | LL | let _ = (&Ok::<_, i32>(6)).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Result` - --> $DIR/into_iter_on_ref.rs:25:37 + --> tests/ui/into_iter_on_ref.rs:25:37 | LL | let _ = (&mut Err::(7)).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` - --> $DIR/into_iter_on_ref.rs:26:34 + --> tests/ui/into_iter_on_ref.rs:26:34 | LL | let _ = (&Vec::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Vec` - --> $DIR/into_iter_on_ref.rs:27:38 + --> tests/ui/into_iter_on_ref.rs:27:38 | LL | let _ = (&mut Vec::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeMap` - --> $DIR/into_iter_on_ref.rs:28:44 + --> tests/ui/into_iter_on_ref.rs:28:44 | LL | let _ = (&BTreeMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `BTreeMap` - --> $DIR/into_iter_on_ref.rs:29:48 + --> tests/ui/into_iter_on_ref.rs:29:48 | LL | let _ = (&mut BTreeMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `VecDeque` - --> $DIR/into_iter_on_ref.rs:30:39 + --> tests/ui/into_iter_on_ref.rs:30:39 | LL | let _ = (&VecDeque::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `VecDeque` - --> $DIR/into_iter_on_ref.rs:31:43 + --> tests/ui/into_iter_on_ref.rs:31:43 | LL | let _ = (&mut VecDeque::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `LinkedList` - --> $DIR/into_iter_on_ref.rs:32:41 + --> tests/ui/into_iter_on_ref.rs:32:41 | LL | let _ = (&LinkedList::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `LinkedList` - --> $DIR/into_iter_on_ref.rs:33:45 + --> tests/ui/into_iter_on_ref.rs:33:45 | LL | let _ = (&mut LinkedList::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashMap` - --> $DIR/into_iter_on_ref.rs:34:43 + --> tests/ui/into_iter_on_ref.rs:34:43 | LL | let _ = (&HashMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `HashMap` - --> $DIR/into_iter_on_ref.rs:35:47 + --> tests/ui/into_iter_on_ref.rs:35:47 | LL | let _ = (&mut HashMap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeSet` - --> $DIR/into_iter_on_ref.rs:37:39 + --> tests/ui/into_iter_on_ref.rs:37:39 | LL | let _ = (&BTreeSet::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BinaryHeap` - --> $DIR/into_iter_on_ref.rs:38:41 + --> tests/ui/into_iter_on_ref.rs:38:41 | LL | let _ = (&BinaryHeap::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashSet` - --> $DIR/into_iter_on_ref.rs:39:38 + --> tests/ui/into_iter_on_ref.rs:39:38 | LL | let _ = (&HashSet::::new()).into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Path` - --> $DIR/into_iter_on_ref.rs:40:43 + --> tests/ui/into_iter_on_ref.rs:40:43 | LL | let _ = std::path::Path::new("12/34").into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `PathBuf` - --> $DIR/into_iter_on_ref.rs:41:47 + --> tests/ui/into_iter_on_ref.rs:41:47 | LL | let _ = std::path::PathBuf::from("12/34").into_iter(); | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> $DIR/into_iter_on_ref.rs:43:26 + --> tests/ui/into_iter_on_ref.rs:43:26 | LL | let _ = (&[1, 2, 3]).into_iter().next(); | ^^^^^^^^^ help: call directly: `iter` diff --git a/src/tools/clippy/tests/ui/into_iter_without_iter.stderr b/src/tools/clippy/tests/ui/into_iter_without_iter.stderr index a232c7cecc577..533a7f6859354 100644 --- a/src/tools/clippy/tests/ui/into_iter_without_iter.stderr +++ b/src/tools/clippy/tests/ui/into_iter_without_iter.stderr @@ -1,5 +1,5 @@ error: `IntoIterator` implemented for a reference type without an `iter` method - --> $DIR/into_iter_without_iter.rs:9:1 + --> tests/ui/into_iter_without_iter.rs:9:1 | LL | / impl<'a> IntoIterator for &'a S1 { LL | | @@ -23,7 +23,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter_mut` method - --> $DIR/into_iter_without_iter.rs:17:1 + --> tests/ui/into_iter_without_iter.rs:17:1 | LL | / impl<'a> IntoIterator for &'a mut S1 { LL | | @@ -45,7 +45,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter` method - --> $DIR/into_iter_without_iter.rs:27:1 + --> tests/ui/into_iter_without_iter.rs:27:1 | LL | / impl<'a, T> IntoIterator for &'a S2 { LL | | @@ -67,7 +67,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter_mut` method - --> $DIR/into_iter_without_iter.rs:35:1 + --> tests/ui/into_iter_without_iter.rs:35:1 | LL | / impl<'a, T> IntoIterator for &'a mut S2 { LL | | @@ -89,7 +89,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter_mut` method - --> $DIR/into_iter_without_iter.rs:86:1 + --> tests/ui/into_iter_without_iter.rs:86:1 | LL | / impl<'a, T> IntoIterator for &mut S4<'a, T> { LL | | @@ -111,7 +111,7 @@ LL + } | error: `IntoIterator` implemented for a reference type without an `iter` method - --> $DIR/into_iter_without_iter.rs:120:9 + --> tests/ui/into_iter_without_iter.rs:120:9 | LL | / impl<'a> IntoIterator for &'a Issue12037 { LL | | type IntoIter = std::slice::Iter<'a, u8>; diff --git a/src/tools/clippy/tests/ui/invalid_null_ptr_usage.stderr b/src/tools/clippy/tests/ui/invalid_null_ptr_usage.stderr index 22efa0d84ad42..54d79ba1aeb4f 100644 --- a/src/tools/clippy/tests/ui/invalid_null_ptr_usage.stderr +++ b/src/tools/clippy/tests/ui/invalid_null_ptr_usage.stderr @@ -1,5 +1,5 @@ error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:3:59 + --> tests/ui/invalid_null_ptr_usage.rs:3:59 | LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` @@ -7,145 +7,145 @@ LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), = note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:4:59 + --> tests/ui/invalid_null_ptr_usage.rs:4:59 | LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:6:63 + --> tests/ui/invalid_null_ptr_usage.rs:6:63 | LL | let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:8:33 + --> tests/ui/invalid_null_ptr_usage.rs:8:33 | LL | std::ptr::copy::(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:9:73 + --> tests/ui/invalid_null_ptr_usage.rs:9:73 | LL | std::ptr::copy::(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:11:48 + --> tests/ui/invalid_null_ptr_usage.rs:11:48 | LL | std::ptr::copy_nonoverlapping::(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:12:88 + --> tests/ui/invalid_null_ptr_usage.rs:12:88 | LL | std::ptr::copy_nonoverlapping::(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:17:36 + --> tests/ui/invalid_null_ptr_usage.rs:17:36 | LL | let _a: A = std::ptr::read(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:18:36 + --> tests/ui/invalid_null_ptr_usage.rs:18:36 | LL | let _a: A = std::ptr::read(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:20:46 + --> tests/ui/invalid_null_ptr_usage.rs:20:46 | LL | let _a: A = std::ptr::read_unaligned(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:21:46 + --> tests/ui/invalid_null_ptr_usage.rs:21:46 | LL | let _a: A = std::ptr::read_unaligned(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:23:45 + --> tests/ui/invalid_null_ptr_usage.rs:23:45 | LL | let _a: A = std::ptr::read_volatile(std::ptr::null()); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:24:45 + --> tests/ui/invalid_null_ptr_usage.rs:24:45 | LL | let _a: A = std::ptr::read_volatile(std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:26:39 + --> tests/ui/invalid_null_ptr_usage.rs:26:39 | LL | let _a: A = std::ptr::replace(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:28:69 + --> tests/ui/invalid_null_ptr_usage.rs:28:69 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null(), 0); | ^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:29:69 + --> tests/ui/invalid_null_ptr_usage.rs:29:69 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:31:73 + --> tests/ui/invalid_null_ptr_usage.rs:31:73 | LL | let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:33:29 + --> tests/ui/invalid_null_ptr_usage.rs:33:29 | LL | std::ptr::swap::(std::ptr::null_mut(), &mut A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:34:37 + --> tests/ui/invalid_null_ptr_usage.rs:34:37 | LL | std::ptr::swap::(&mut A, std::ptr::null_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:36:44 + --> tests/ui/invalid_null_ptr_usage.rs:36:44 | LL | std::ptr::swap_nonoverlapping::(std::ptr::null_mut(), &mut A, 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:37:52 + --> tests/ui/invalid_null_ptr_usage.rs:37:52 | LL | std::ptr::swap_nonoverlapping::(&mut A, std::ptr::null_mut(), 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:39:25 + --> tests/ui/invalid_null_ptr_usage.rs:39:25 | LL | std::ptr::write(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:41:35 + --> tests/ui/invalid_null_ptr_usage.rs:41:35 | LL | std::ptr::write_unaligned(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:43:34 + --> tests/ui/invalid_null_ptr_usage.rs:43:34 | LL | std::ptr::write_volatile(std::ptr::null_mut(), A); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` error: pointer must be non-null - --> $DIR/invalid_null_ptr_usage.rs:45:40 + --> tests/ui/invalid_null_ptr_usage.rs:45:40 | LL | std::ptr::write_bytes::(std::ptr::null_mut(), 42, 0); | ^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()` diff --git a/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr b/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr index a57b4b02dce3a..b1fbe29515775 100644 --- a/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr +++ b/src/tools/clippy/tests/ui/invalid_upcast_comparisons.stderr @@ -1,5 +1,5 @@ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:21:5 + --> tests/ui/invalid_upcast_comparisons.rs:21:5 | LL | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ @@ -8,157 +8,157 @@ LL | (u8 as u32) > 300; = 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 + --> tests/ui/invalid_upcast_comparisons.rs:24:5 | LL | (u8 as i32) > 300; | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:26:5 + --> tests/ui/invalid_upcast_comparisons.rs:26:5 | LL | (u8 as u32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:28:5 + --> tests/ui/invalid_upcast_comparisons.rs:28:5 | LL | (u8 as i32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:30:5 + --> tests/ui/invalid_upcast_comparisons.rs:30:5 | LL | 300 < (u8 as u32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:32:5 + --> tests/ui/invalid_upcast_comparisons.rs:32:5 | LL | 300 < (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:34:5 + --> tests/ui/invalid_upcast_comparisons.rs:34:5 | LL | 300 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:36:5 + --> tests/ui/invalid_upcast_comparisons.rs:36:5 | LL | 300 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:39:5 + --> tests/ui/invalid_upcast_comparisons.rs:39:5 | LL | (u8 as u32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:41:5 + --> tests/ui/invalid_upcast_comparisons.rs:41:5 | LL | (u8 as i32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:43:5 + --> tests/ui/invalid_upcast_comparisons.rs:43:5 | LL | (u8 as u32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:45:5 + --> tests/ui/invalid_upcast_comparisons.rs:45:5 | LL | (u8 as i32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:47:5 + --> tests/ui/invalid_upcast_comparisons.rs:47:5 | LL | 300 >= (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:49:5 + --> tests/ui/invalid_upcast_comparisons.rs:49:5 | LL | 300 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:51:5 + --> tests/ui/invalid_upcast_comparisons.rs:51:5 | LL | 300 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:53:5 + --> tests/ui/invalid_upcast_comparisons.rs:53:5 | LL | 300 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:57:5 + --> tests/ui/invalid_upcast_comparisons.rs:57:5 | LL | (u8 as i32) < 0; | ^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:59:5 + --> tests/ui/invalid_upcast_comparisons.rs:59:5 | LL | -5 != (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:62:5 + --> tests/ui/invalid_upcast_comparisons.rs:62:5 | LL | (u8 as i32) >= 0; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:64:5 + --> tests/ui/invalid_upcast_comparisons.rs:64:5 | LL | -5 == (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:68:5 + --> tests/ui/invalid_upcast_comparisons.rs:68:5 | LL | 1337 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:70:5 + --> tests/ui/invalid_upcast_comparisons.rs:70:5 | LL | 1337 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:73:5 + --> tests/ui/invalid_upcast_comparisons.rs:73:5 | LL | 1337 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:75:5 + --> tests/ui/invalid_upcast_comparisons.rs:75:5 | LL | 1337 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:90:5 + --> tests/ui/invalid_upcast_comparisons.rs:90:5 | LL | (u8 as i32) > -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:92:5 + --> tests/ui/invalid_upcast_comparisons.rs:92:5 | LL | (u8 as i32) < -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:109:5 + --> tests/ui/invalid_upcast_comparisons.rs:109:5 | LL | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ 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 28040c3a9c26d..f26183ddab84d 100644 --- a/src/tools/clippy/tests/ui/is_digit_ascii_radix.stderr +++ b/src/tools/clippy/tests/ui/is_digit_ascii_radix.stderr @@ -1,5 +1,5 @@ error: use of `char::is_digit` with literal radix of 10 - --> $DIR/is_digit_ascii_radix.rs:9:13 + --> tests/ui/is_digit_ascii_radix.rs:9:13 | LL | let _ = c.is_digit(10); | ^^^^^^^^^^^^^^ help: try: `c.is_ascii_digit()` @@ -8,13 +8,13 @@ LL | let _ = c.is_digit(10); = 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 + --> tests/ui/is_digit_ascii_radix.rs:10:13 | LL | let _ = c.is_digit(16); | ^^^^^^^^^^^^^^ help: try: `c.is_ascii_hexdigit()` error: use of `char::is_digit` with literal radix of 16 - --> $DIR/is_digit_ascii_radix.rs:11:13 + --> tests/ui/is_digit_ascii_radix.rs:11:13 | LL | let _ = c.is_digit(0x10); | ^^^^^^^^^^^^^^^^ help: try: `c.is_ascii_hexdigit()` diff --git a/src/tools/clippy/tests/ui/issue-3145.stderr b/src/tools/clippy/tests/ui/issue-3145.stderr index 51debc9b72f82..b7dacd484e9af 100644 --- a/src/tools/clippy/tests/ui/issue-3145.stderr +++ b/src/tools/clippy/tests/ui/issue-3145.stderr @@ -1,5 +1,5 @@ error: expected `,`, found `a` - --> $DIR/issue-3145.rs:2:19 + --> tests/ui/issue-3145.rs:2:19 | LL | println!("{}" a); | ^ expected `,` diff --git a/src/tools/clippy/tests/ui/issue-7447.stderr b/src/tools/clippy/tests/ui/issue-7447.stderr index 51ecac4559c95..5e28c1423840f 100644 --- a/src/tools/clippy/tests/ui/issue-7447.stderr +++ b/src/tools/clippy/tests/ui/issue-7447.stderr @@ -1,5 +1,5 @@ error: sub-expression diverges - --> $DIR/issue-7447.rs:26:15 + --> tests/ui/issue-7447.rs:26:15 | LL | byte_view(panic!()); | ^^^^^^^^ @@ -9,7 +9,7 @@ LL | byte_view(panic!()); = 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 - --> $DIR/issue-7447.rs:29:19 + --> tests/ui/issue-7447.rs:29:19 | LL | group_entries(panic!()); | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/issue_2356.stderr b/src/tools/clippy/tests/ui/issue_2356.stderr index 860c545c7b827..eae2ce97fc6b1 100644 --- a/src/tools/clippy/tests/ui/issue_2356.stderr +++ b/src/tools/clippy/tests/ui/issue_2356.stderr @@ -1,11 +1,11 @@ error: this loop could be written as a `for` loop - --> $DIR/issue_2356.rs:17:9 + --> tests/ui/issue_2356.rs:17:9 | LL | while let Some(e) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for e in it` | note: the lint level is defined here - --> $DIR/issue_2356.rs:1:9 + --> tests/ui/issue_2356.rs:1:9 | LL | #![deny(clippy::while_let_on_iterator)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/issue_4266.stderr b/src/tools/clippy/tests/ui/issue_4266.stderr index 692de2ae58c09..c0e8179158969 100644 --- a/src/tools/clippy/tests/ui/issue_4266.stderr +++ b/src/tools/clippy/tests/ui/issue_4266.stderr @@ -1,5 +1,5 @@ error: the following explicit lifetimes could be elided: 'a - --> $DIR/issue_4266.rs:4:16 + --> tests/ui/issue_4266.rs:4:16 | LL | async fn sink1<'a>(_: &'a str) {} // lint | ^^ ^^ @@ -8,13 +8,13 @@ LL | async fn sink1<'a>(_: &'a str) {} // lint = 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 + --> tests/ui/issue_4266.rs:10:21 | LL | async fn one_to_one<'a>(s: &'a str) -> &'a str { | ^^ ^^ error: methods called `new` usually take no `self` - --> $DIR/issue_4266.rs:31:22 + --> tests/ui/issue_4266.rs:31:22 | LL | pub async fn new(&mut self) -> Self { | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/items_after_statement.stderr b/src/tools/clippy/tests/ui/items_after_statement.stderr index fa494f2174895..0f1989d4c9fc5 100644 --- a/src/tools/clippy/tests/ui/items_after_statement.stderr +++ b/src/tools/clippy/tests/ui/items_after_statement.stderr @@ -1,5 +1,5 @@ error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/items_after_statement.rs:13:5 + --> tests/ui/items_after_statement.rs:13:5 | LL | / fn foo() { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/items_after_statement.rs:22:5 | LL | / fn foo() { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/items_after_statement.rs:36:13 + --> tests/ui/items_after_statement.rs:36:13 | LL | / fn say_something() { LL | | println!("something"); diff --git a/src/tools/clippy/tests/ui/items_after_test_module/in_submodule.stderr b/src/tools/clippy/tests/ui/items_after_test_module/in_submodule.stderr index 30aa90d29bf8c..8aa6b809cd1e7 100644 --- a/src/tools/clippy/tests/ui/items_after_test_module/in_submodule.stderr +++ b/src/tools/clippy/tests/ui/items_after_test_module/in_submodule.stderr @@ -1,5 +1,5 @@ error: items after a test module - --> $DIR/auxiliary/submodule.rs:2:1 + --> tests/ui/items_after_test_module/auxiliary/submodule.rs:2:1 | LL | mod tests {} | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/items_after_test_module/root_module.stderr b/src/tools/clippy/tests/ui/items_after_test_module/root_module.stderr index 17b07cc32f4e3..bed8d4bd5a00c 100644 --- a/src/tools/clippy/tests/ui/items_after_test_module/root_module.stderr +++ b/src/tools/clippy/tests/ui/items_after_test_module/root_module.stderr @@ -1,5 +1,5 @@ error: items after a test module - --> $DIR/root_module.rs:12:1 + --> tests/ui/items_after_test_module/root_module.rs:12:1 | LL | mod tests { | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/iter_cloned_collect.stderr b/src/tools/clippy/tests/ui/iter_cloned_collect.stderr index aa7fb98a7c8ad..e8d82ec2c1b39 100644 --- a/src/tools/clippy/tests/ui/iter_cloned_collect.stderr +++ b/src/tools/clippy/tests/ui/iter_cloned_collect.stderr @@ -1,5 +1,5 @@ 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:8:27 + --> tests/ui/iter_cloned_collect.rs:8:27 | LL | let v2: Vec = v.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` @@ -8,13 +8,13 @@ LL | let v2: Vec = v.iter().cloned().collect(); = 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 + --> tests/ui/iter_cloned_collect.rs:13:38 | LL | let _: Vec = vec![1, 2, 3].iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` 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:18:24 + --> tests/ui/iter_cloned_collect.rs:18:24 | LL | .to_bytes() | ________________________^ @@ -24,13 +24,13 @@ LL | | .collect(); | |______________________^ help: try: `.to_vec()` 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:26:24 + --> tests/ui/iter_cloned_collect.rs:26:24 | LL | let _: Vec<_> = arr.iter().cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` error: called `iter().copied().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/iter_cloned_collect.rs:29:26 + --> tests/ui/iter_cloned_collect.rs:29:26 | LL | let _: Vec = v.iter().copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()` diff --git a/src/tools/clippy/tests/ui/iter_count.stderr b/src/tools/clippy/tests/ui/iter_count.stderr index 2882b7d28505f..b703310731f34 100644 --- a/src/tools/clippy/tests/ui/iter_count.stderr +++ b/src/tools/clippy/tests/ui/iter_count.stderr @@ -1,5 +1,5 @@ error: called `.iter().count()` on a `slice` - --> $DIR/iter_count.rs:54:6 + --> tests/ui/iter_count.rs:54:6 | LL | &vec[..].iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` @@ -8,145 +8,145 @@ LL | &vec[..].iter().count(); = help: to override `-D warnings` add `#[allow(clippy::iter_count)]` error: called `.iter().count()` on a `Vec` - --> $DIR/iter_count.rs:55:5 + --> tests/ui/iter_count.rs:55:5 | LL | vec.iter().count(); | ^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` error: called `.iter().count()` on a `slice` - --> $DIR/iter_count.rs:56:5 + --> tests/ui/iter_count.rs:56:5 | LL | boxed_slice.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `boxed_slice.len()` error: called `.iter().count()` on a `VecDeque` - --> $DIR/iter_count.rs:57:5 + --> tests/ui/iter_count.rs:57:5 | LL | vec_deque.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` error: called `.iter().count()` on a `HashSet` - --> $DIR/iter_count.rs:58:5 + --> tests/ui/iter_count.rs:58:5 | LL | hash_set.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_set.len()` error: called `.iter().count()` on a `HashMap` - --> $DIR/iter_count.rs:59:5 + --> tests/ui/iter_count.rs:59:5 | LL | hash_map.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` error: called `.iter().count()` on a `BTreeMap` - --> $DIR/iter_count.rs:60:5 + --> tests/ui/iter_count.rs:60:5 | LL | b_tree_map.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` error: called `.iter().count()` on a `BTreeSet` - --> $DIR/iter_count.rs:61:5 + --> tests/ui/iter_count.rs:61:5 | LL | b_tree_set.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_set.len()` error: called `.iter().count()` on a `LinkedList` - --> $DIR/iter_count.rs:62:5 + --> tests/ui/iter_count.rs:62:5 | LL | linked_list.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` error: called `.iter().count()` on a `BinaryHeap` - --> $DIR/iter_count.rs:63:5 + --> tests/ui/iter_count.rs:63:5 | LL | binary_heap.iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `binary_heap.len()` error: called `.iter_mut().count()` on a `Vec` - --> $DIR/iter_count.rs:65:5 + --> tests/ui/iter_count.rs:65:5 | LL | vec.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` error: called `.iter_mut().count()` on a `slice` - --> $DIR/iter_count.rs:66:6 + --> tests/ui/iter_count.rs:66:6 | LL | &vec[..].iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` error: called `.iter_mut().count()` on a `VecDeque` - --> $DIR/iter_count.rs:67:5 + --> tests/ui/iter_count.rs:67:5 | LL | vec_deque.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` error: called `.iter_mut().count()` on a `HashMap` - --> $DIR/iter_count.rs:68:5 + --> tests/ui/iter_count.rs:68:5 | LL | hash_map.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` error: called `.iter_mut().count()` on a `BTreeMap` - --> $DIR/iter_count.rs:69:5 + --> tests/ui/iter_count.rs:69:5 | LL | b_tree_map.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` error: called `.iter_mut().count()` on a `LinkedList` - --> $DIR/iter_count.rs:70:5 + --> tests/ui/iter_count.rs:70:5 | LL | linked_list.iter_mut().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` error: called `.into_iter().count()` on a `slice` - --> $DIR/iter_count.rs:72:6 + --> tests/ui/iter_count.rs:72:6 | LL | &vec[..].into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` error: called `.into_iter().count()` on a `Vec` - --> $DIR/iter_count.rs:73:5 + --> tests/ui/iter_count.rs:73:5 | LL | vec.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` error: called `.into_iter().count()` on a `VecDeque` - --> $DIR/iter_count.rs:74:5 + --> tests/ui/iter_count.rs:74:5 | LL | vec_deque.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec_deque.len()` error: called `.into_iter().count()` on a `HashSet` - --> $DIR/iter_count.rs:75:5 + --> tests/ui/iter_count.rs:75:5 | LL | hash_set.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_set.len()` error: called `.into_iter().count()` on a `HashMap` - --> $DIR/iter_count.rs:76:5 + --> tests/ui/iter_count.rs:76:5 | LL | hash_map.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `hash_map.len()` error: called `.into_iter().count()` on a `BTreeMap` - --> $DIR/iter_count.rs:77:5 + --> tests/ui/iter_count.rs:77:5 | LL | b_tree_map.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_map.len()` error: called `.into_iter().count()` on a `BTreeSet` - --> $DIR/iter_count.rs:78:5 + --> tests/ui/iter_count.rs:78:5 | LL | b_tree_set.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b_tree_set.len()` error: called `.into_iter().count()` on a `LinkedList` - --> $DIR/iter_count.rs:79:5 + --> tests/ui/iter_count.rs:79:5 | LL | linked_list.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` error: called `.into_iter().count()` on a `BinaryHeap` - --> $DIR/iter_count.rs:80:5 + --> tests/ui/iter_count.rs:80:5 | LL | binary_heap.into_iter().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `binary_heap.len()` diff --git a/src/tools/clippy/tests/ui/iter_filter_is_ok.stderr b/src/tools/clippy/tests/ui/iter_filter_is_ok.stderr index d99e2e0446da8..0aff60224e0e0 100644 --- a/src/tools/clippy/tests/ui/iter_filter_is_ok.stderr +++ b/src/tools/clippy/tests/ui/iter_filter_is_ok.stderr @@ -1,5 +1,5 @@ error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:11:56 + --> tests/ui/iter_filter_is_ok.rs:11:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(Result::is_ok); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` @@ -8,67 +8,67 @@ LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(Result::is_ok = help: to override `-D warnings` add `#[allow(clippy::iter_filter_is_ok)]` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:13:56 + --> tests/ui/iter_filter_is_ok.rs:13:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:16:49 + --> tests/ui/iter_filter_is_ok.rs:16:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:21:56 + --> tests/ui/iter_filter_is_ok.rs:21:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:24:56 + --> tests/ui/iter_filter_is_ok.rs:24:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:28:49 + --> tests/ui/iter_filter_is_ok.rs:28:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|&o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:35:14 + --> tests/ui/iter_filter_is_ok.rs:35:14 | LL | .filter(std::result::Result::is_ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:40:14 + --> tests/ui/iter_filter_is_ok.rs:40:14 | LL | .filter(|a| std::result::Result::is_ok(a)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:43:56 + --> tests/ui/iter_filter_is_ok.rs:43:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| { std::result::Result::is_ok(a) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:48:56 + --> tests/ui/iter_filter_is_ok.rs:48:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:51:56 + --> tests/ui/iter_filter_is_ok.rs:51:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> $DIR/iter_filter_is_ok.rs:55:49 + --> tests/ui/iter_filter_is_ok.rs:55:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|ref o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` diff --git a/src/tools/clippy/tests/ui/iter_filter_is_some.fixed b/src/tools/clippy/tests/ui/iter_filter_is_some.fixed index abc3a47fa46a7..8a818c0c6728d 100644 --- a/src/tools/clippy/tests/ui/iter_filter_is_some.fixed +++ b/src/tools/clippy/tests/ui/iter_filter_is_some.fixed @@ -4,7 +4,8 @@ clippy::result_filter_map, clippy::needless_borrow, clippy::option_filter_map, - clippy::redundant_closure + clippy::redundant_closure, + clippy::unnecessary_get_then_check )] use std::collections::HashMap; diff --git a/src/tools/clippy/tests/ui/iter_filter_is_some.rs b/src/tools/clippy/tests/ui/iter_filter_is_some.rs index c74775a82ba07..9eda93a259218 100644 --- a/src/tools/clippy/tests/ui/iter_filter_is_some.rs +++ b/src/tools/clippy/tests/ui/iter_filter_is_some.rs @@ -4,7 +4,8 @@ clippy::result_filter_map, clippy::needless_borrow, clippy::option_filter_map, - clippy::redundant_closure + clippy::redundant_closure, + clippy::unnecessary_get_then_check )] use std::collections::HashMap; diff --git a/src/tools/clippy/tests/ui/iter_filter_is_some.stderr b/src/tools/clippy/tests/ui/iter_filter_is_some.stderr index 2eb00633e88fc..54aff892b1f0f 100644 --- a/src/tools/clippy/tests/ui/iter_filter_is_some.stderr +++ b/src/tools/clippy/tests/ui/iter_filter_is_some.stderr @@ -1,5 +1,5 @@ error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:14:58 + --> tests/ui/iter_filter_is_some.rs:15:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(Option::is_some); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` @@ -8,55 +8,55 @@ LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(Option::is_ = help: to override `-D warnings` add `#[allow(clippy::iter_filter_is_some)]` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:16:58 + --> tests/ui/iter_filter_is_some.rs:17:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:19:58 + --> tests/ui/iter_filter_is_some.rs:20:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:26:14 + --> tests/ui/iter_filter_is_some.rs:27:14 | LL | .filter(std::option::Option::is_some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:31:14 + --> tests/ui/iter_filter_is_some.rs:32:14 | LL | .filter(|a| std::option::Option::is_some(a)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:34:58 + --> tests/ui/iter_filter_is_some.rs:35:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| { std::option::Option::is_some(a) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:39:58 + --> tests/ui/iter_filter_is_some.rs:40:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:43:58 + --> tests/ui/iter_filter_is_some.rs:44:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:48:58 + --> tests/ui/iter_filter_is_some.rs:49:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> $DIR/iter_filter_is_some.rs:52:58 + --> tests/ui/iter_filter_is_some.rs:53:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` diff --git a/src/tools/clippy/tests/ui/iter_kv_map.stderr b/src/tools/clippy/tests/ui/iter_kv_map.stderr index 471615978e1e5..ad23dba55cb6a 100644 --- a/src/tools/clippy/tests/ui/iter_kv_map.stderr +++ b/src/tools/clippy/tests/ui/iter_kv_map.stderr @@ -1,5 +1,5 @@ error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:14:13 + --> tests/ui/iter_kv_map.rs:14:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` @@ -8,73 +8,73 @@ LL | let _ = map.iter().map(|(key, _)| key).collect::>(); = 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 + --> tests/ui/iter_kv_map.rs:15:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:16:13 + --> tests/ui/iter_kv_map.rs:16:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:18:13 + --> tests/ui/iter_kv_map.rs:18:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:19:13 + --> tests/ui/iter_kv_map.rs:19:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:21:13 + --> tests/ui/iter_kv_map.rs:21:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:22:13 + --> tests/ui/iter_kv_map.rs:22:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:24:13 + --> tests/ui/iter_kv_map.rs:24:13 | LL | let _ = map.clone().iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:25:13 + --> tests/ui/iter_kv_map.rs:25:13 | LL | let _ = map.iter().map(|(key, _)| key).filter(|x| *x % 2 == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:35:13 + --> tests/ui/iter_kv_map.rs:35:13 | LL | let _ = map.iter().map(|(key, _value)| key * 9).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys().map(|key| key * 9)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:36:13 + --> tests/ui/iter_kv_map.rs:36:13 | LL | let _ = map.iter().map(|(_key, value)| value * 17).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|value| value * 17)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:39:13 + --> tests/ui/iter_kv_map.rs:39:13 | LL | let _ = map.clone().into_iter().map(|(_, ref val)| ref_acceptor(val)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|ref val| ref_acceptor(val))` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:42:13 + --> tests/ui/iter_kv_map.rs:42:13 | LL | let _ = map | _____________^ @@ -96,85 +96,85 @@ LL + }) | error: iterating on a map's values - --> $DIR/iter_kv_map.rs:52:13 + --> tests/ui/iter_kv_map.rs:52:13 | LL | let _ = map.clone().into_iter().map(|(_, mut val)| val).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:56:13 + --> tests/ui/iter_kv_map.rs:56:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:57:13 + --> tests/ui/iter_kv_map.rs:57:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:58:13 + --> tests/ui/iter_kv_map.rs:58:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:60:13 + --> tests/ui/iter_kv_map.rs:60:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:61:13 + --> tests/ui/iter_kv_map.rs:61:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:63:13 + --> tests/ui/iter_kv_map.rs:63:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:64:13 + --> tests/ui/iter_kv_map.rs:64:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:66:13 + --> tests/ui/iter_kv_map.rs:66:13 | LL | let _ = map.clone().iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:67:13 + --> tests/ui/iter_kv_map.rs:67:13 | LL | let _ = map.iter().map(|(key, _)| key).filter(|x| *x % 2 == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:77:13 + --> tests/ui/iter_kv_map.rs:77:13 | LL | let _ = map.iter().map(|(key, _value)| key * 9).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys().map(|key| key * 9)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:78:13 + --> tests/ui/iter_kv_map.rs:78:13 | LL | let _ = map.iter().map(|(_key, value)| value * 17).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|value| value * 17)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:81:13 + --> tests/ui/iter_kv_map.rs:81:13 | LL | let _ = map.clone().into_iter().map(|(_, ref val)| ref_acceptor(val)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|ref val| ref_acceptor(val))` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:84:13 + --> tests/ui/iter_kv_map.rs:84:13 | LL | let _ = map | _____________^ @@ -196,67 +196,67 @@ LL + }) | error: iterating on a map's values - --> $DIR/iter_kv_map.rs:94:13 + --> tests/ui/iter_kv_map.rs:94:13 | LL | let _ = map.clone().into_iter().map(|(_, mut val)| val).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:109:13 + --> tests/ui/iter_kv_map.rs:109:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:111:13 + --> tests/ui/iter_kv_map.rs:111:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:113:13 + --> tests/ui/iter_kv_map.rs:113:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:122:13 + --> tests/ui/iter_kv_map.rs:122:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:124:13 + --> tests/ui/iter_kv_map.rs:124:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:127:13 + --> tests/ui/iter_kv_map.rs:127:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:129:13 + --> tests/ui/iter_kv_map.rs:129:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` error: iterating on a map's keys - --> $DIR/iter_kv_map.rs:132:13 + --> tests/ui/iter_kv_map.rs:132:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:134:13 + --> tests/ui/iter_kv_map.rs:134:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> $DIR/iter_kv_map.rs:136:13 + --> tests/ui/iter_kv_map.rs:136:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` diff --git a/src/tools/clippy/tests/ui/iter_next_loop.stderr b/src/tools/clippy/tests/ui/iter_next_loop.stderr index 5871d21e49157..85c23f4e70944 100644 --- a/src/tools/clippy/tests/ui/iter_next_loop.stderr +++ b/src/tools/clippy/tests/ui/iter_next_loop.stderr @@ -1,5 +1,5 @@ error[E0423]: expected value, found macro `vec` - --> $DIR/iter_next_loop.rs:6:14 + --> tests/ui/iter_next_loop.rs:6:14 | LL | for _ in vec.iter().next() {} | ^^^ not a value diff --git a/src/tools/clippy/tests/ui/iter_next_slice.stderr b/src/tools/clippy/tests/ui/iter_next_slice.stderr index e6b4bd6c0b480..55cce2b9103da 100644 --- a/src/tools/clippy/tests/ui/iter_next_slice.stderr +++ b/src/tools/clippy/tests/ui/iter_next_slice.stderr @@ -1,5 +1,5 @@ error: using `.iter().next()` on an array - --> $DIR/iter_next_slice.rs:9:13 + --> tests/ui/iter_next_slice.rs:9:13 | LL | let _ = s.iter().next(); | ^^^^^^^^^^^^^^^ help: try calling: `s.first()` @@ -8,19 +8,19 @@ LL | let _ = s.iter().next(); = 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 + --> tests/ui/iter_next_slice.rs:12:13 | LL | let _ = s[2..].iter().next(); | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `s.get(2)` error: using `.iter().next()` on a Slice without end index - --> $DIR/iter_next_slice.rs:15:13 + --> tests/ui/iter_next_slice.rs:15:13 | LL | let _ = v[5..].iter().next(); | ^^^^^^^^^^^^^^^^^^^^ help: try calling: `v.get(5)` error: using `.iter().next()` on an array - --> $DIR/iter_next_slice.rs:18:13 + --> tests/ui/iter_next_slice.rs:18:13 | LL | let _ = v.iter().next(); | ^^^^^^^^^^^^^^^ help: try calling: `v.first()` 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 c695b1932d356..c3ee8bae772d5 100644 --- a/src/tools/clippy/tests/ui/iter_not_returning_iterator.stderr +++ b/src/tools/clippy/tests/ui/iter_not_returning_iterator.stderr @@ -1,5 +1,5 @@ error: this method is named `iter` but its return type does not implement `Iterator` - --> $DIR/iter_not_returning_iterator.rs:30:5 + --> tests/ui/iter_not_returning_iterator.rs:30:5 | LL | fn iter(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | fn iter(&self) -> Counter2 { = 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 + --> tests/ui/iter_not_returning_iterator.rs:36:5 | LL | fn iter_mut(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this method is named `iter` but its return type does not implement `Iterator` - --> $DIR/iter_not_returning_iterator.rs:53:5 + --> tests/ui/iter_not_returning_iterator.rs:53:5 | LL | fn iter(&self) -> Self::I; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/iter_nth.stderr b/src/tools/clippy/tests/ui/iter_nth.stderr index 162e6c3384941..c5dd0c99727be 100644 --- a/src/tools/clippy/tests/ui/iter_nth.stderr +++ b/src/tools/clippy/tests/ui/iter_nth.stderr @@ -1,5 +1,5 @@ error: called `.iter().nth()` on a `Vec` - --> $DIR/iter_nth.rs:34:23 + --> tests/ui/iter_nth.rs:34:23 | LL | let bad_vec = some_vec.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let bad_vec = some_vec.iter().nth(3); = help: to override `-D warnings` add `#[allow(clippy::iter_nth)]` error: called `.iter().nth()` on a slice - --> $DIR/iter_nth.rs:35:26 + --> tests/ui/iter_nth.rs:35:26 | LL | let bad_slice = &some_vec[..].iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let bad_slice = &some_vec[..].iter().nth(3); = help: calling `.get()` is both faster and more readable error: called `.iter().nth()` on a slice - --> $DIR/iter_nth.rs:36:31 + --> tests/ui/iter_nth.rs:36:31 | LL | let bad_boxed_slice = boxed_slice.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let bad_boxed_slice = boxed_slice.iter().nth(3); = help: calling `.get()` is both faster and more readable error: called `.iter().nth()` on a `VecDeque` - --> $DIR/iter_nth.rs:37:29 + --> tests/ui/iter_nth.rs:37:29 | LL | let bad_vec_deque = some_vec_deque.iter().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let bad_vec_deque = some_vec_deque.iter().nth(3); = help: calling `.get()` is both faster and more readable error: called `.iter_mut().nth()` on a `Vec` - --> $DIR/iter_nth.rs:42:23 + --> tests/ui/iter_nth.rs:42:23 | LL | let bad_vec = some_vec.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let bad_vec = some_vec.iter_mut().nth(3); = help: calling `.get_mut()` is both faster and more readable error: called `.iter_mut().nth()` on a slice - --> $DIR/iter_nth.rs:45:26 + --> tests/ui/iter_nth.rs:45:26 | LL | let bad_slice = &some_vec[..].iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let bad_slice = &some_vec[..].iter_mut().nth(3); = help: calling `.get_mut()` is both faster and more readable error: called `.iter_mut().nth()` on a `VecDeque` - --> $DIR/iter_nth.rs:48:29 + --> tests/ui/iter_nth.rs:48:29 | LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/iter_nth_zero.stderr b/src/tools/clippy/tests/ui/iter_nth_zero.stderr index 939fd0063c0b1..b5e5cf45c26bf 100644 --- a/src/tools/clippy/tests/ui/iter_nth_zero.stderr +++ b/src/tools/clippy/tests/ui/iter_nth_zero.stderr @@ -1,5 +1,5 @@ error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent - --> $DIR/iter_nth_zero.rs:18:14 + --> tests/ui/iter_nth_zero.rs:18:14 | LL | let _x = s.iter().nth(0); | ^^^^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `s.iter().next()` @@ -8,13 +8,13 @@ LL | let _x = s.iter().nth(0); = 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 + --> tests/ui/iter_nth_zero.rs:23:14 | LL | let _y = iter.nth(0); | ^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter.next()` error: called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent - --> $DIR/iter_nth_zero.rs:28:22 + --> tests/ui/iter_nth_zero.rs:28:22 | LL | let _unwrapped = iter2.nth(0).unwrap(); | ^^^^^^^^^^^^ help: try calling `.next()` instead of `.nth(0)`: `iter2.next()` 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 57a5320199665..ade20ff26a019 100644 --- a/src/tools/clippy/tests/ui/iter_on_empty_collections.stderr +++ b/src/tools/clippy/tests/ui/iter_on_empty_collections.stderr @@ -1,5 +1,5 @@ error: `into_iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:5:16 + --> tests/ui/iter_on_empty_collections.rs:5:16 | LL | assert_eq!([].into_iter().next(), Option::::None); | ^^^^^^^^^^^^^^ help: try: `std::iter::empty()` @@ -8,31 +8,31 @@ LL | assert_eq!([].into_iter().next(), Option::::None); = 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 + --> tests/ui/iter_on_empty_collections.rs:6:16 | LL | assert_eq!([].iter_mut().next(), Option::<&mut i32>::None); | ^^^^^^^^^^^^^ help: try: `std::iter::empty()` error: `iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:7:16 + --> tests/ui/iter_on_empty_collections.rs:7:16 | LL | assert_eq!([].iter().next(), Option::<&i32>::None); | ^^^^^^^^^ help: try: `std::iter::empty()` error: `into_iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:8:16 + --> tests/ui/iter_on_empty_collections.rs:8:16 | LL | assert_eq!(None.into_iter().next(), Option::::None); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` error: `iter_mut` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:9:16 + --> tests/ui/iter_on_empty_collections.rs:9:16 | LL | assert_eq!(None.iter_mut().next(), Option::<&mut i32>::None); | ^^^^^^^^^^^^^^^ help: try: `std::iter::empty()` error: `iter` call on an empty collection - --> $DIR/iter_on_empty_collections.rs:10:16 + --> tests/ui/iter_on_empty_collections.rs:10:16 | LL | assert_eq!(None.iter().next(), Option::<&i32>::None); | ^^^^^^^^^^^ help: try: `std::iter::empty()` 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 00398f541e9a1..0252c859581b6 100644 --- a/src/tools/clippy/tests/ui/iter_on_single_items.stderr +++ b/src/tools/clippy/tests/ui/iter_on_single_items.stderr @@ -1,5 +1,5 @@ error: `into_iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:5:16 + --> tests/ui/iter_on_single_items.rs:5:16 | LL | assert_eq!([123].into_iter().next(), Some(123)); | ^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(123)` @@ -8,31 +8,31 @@ LL | assert_eq!([123].into_iter().next(), Some(123)); = 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 + --> tests/ui/iter_on_single_items.rs:6:16 | LL | assert_eq!([123].iter_mut().next(), Some(&mut 123)); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&mut 123)` error: `iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:7:16 + --> tests/ui/iter_on_single_items.rs:7:16 | LL | assert_eq!([123].iter().next(), Some(&123)); | ^^^^^^^^^^^^ help: try: `std::iter::once(&123)` error: `into_iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:8:16 + --> tests/ui/iter_on_single_items.rs:8:16 | LL | assert_eq!(Some(123).into_iter().next(), Some(123)); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(123)` error: `iter_mut` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:9:16 + --> tests/ui/iter_on_single_items.rs:9:16 | LL | assert_eq!(Some(123).iter_mut().next(), Some(&mut 123)); | ^^^^^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&mut 123)` error: `iter` call on a collection with only one item - --> $DIR/iter_on_single_items.rs:10:16 + --> tests/ui/iter_on_single_items.rs:10:16 | LL | assert_eq!(Some(123).iter().next(), Some(&123)); | ^^^^^^^^^^^^^^^^ help: try: `std::iter::once(&123)` diff --git a/src/tools/clippy/tests/ui/iter_out_of_bounds.stderr b/src/tools/clippy/tests/ui/iter_out_of_bounds.stderr index f235faec8e59c..96df04251fc9e 100644 --- a/src/tools/clippy/tests/ui/iter_out_of_bounds.stderr +++ b/src/tools/clippy/tests/ui/iter_out_of_bounds.stderr @@ -1,18 +1,18 @@ error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:12:14 + --> tests/ui/iter_out_of_bounds.rs:12:14 | LL | for _ in [1, 2, 3].iter().skip(4) { | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this operation is useless and will create an empty iterator note: the lint level is defined here - --> $DIR/iter_out_of_bounds.rs:3:9 + --> tests/ui/iter_out_of_bounds.rs:3:9 | LL | #![deny(clippy::iter_out_of_bounds)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:16:19 + --> tests/ui/iter_out_of_bounds.rs:16:19 | LL | for (i, _) in [1, 2, 3].iter().take(4).enumerate() { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | for (i, _) in [1, 2, 3].iter().take(4).enumerate() { = note: this operation is useless and the returned iterator will simply yield the same items error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:22:14 + --> tests/ui/iter_out_of_bounds.rs:22:14 | LL | for _ in (&&&&&&[1, 2, 3]).iter().take(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | for _ in (&&&&&&[1, 2, 3]).iter().take(4) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:25:14 + --> tests/ui/iter_out_of_bounds.rs:25:14 | LL | for _ in [1, 2, 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | for _ in [1, 2, 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:28:14 + --> tests/ui/iter_out_of_bounds.rs:28:14 | LL | for _ in [1; 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | for _ in [1; 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:34:14 + --> tests/ui/iter_out_of_bounds.rs:34:14 | LL | for _ in vec![1, 2, 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | for _ in vec![1, 2, 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:37:14 + --> tests/ui/iter_out_of_bounds.rs:37:14 | LL | for _ in vec![1; 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | for _ in vec![1; 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:41:14 + --> tests/ui/iter_out_of_bounds.rs:41:14 | LL | for _ in x.iter().skip(4) {} | ^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | for _ in x.iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:45:14 + --> tests/ui/iter_out_of_bounds.rs:45:14 | LL | for _ in x.iter().skip(n) {} | ^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | for _ in x.iter().skip(n) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:50:14 + --> tests/ui/iter_out_of_bounds.rs:50:14 | LL | for _ in empty().skip(1) {} | ^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | for _ in empty().skip(1) {} = note: this operation is useless and will create an empty iterator error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:53:14 + --> tests/ui/iter_out_of_bounds.rs:53:14 | LL | for _ in empty().take(1) {} | ^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | for _ in empty().take(1) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.skip()` call skips more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:56:14 + --> tests/ui/iter_out_of_bounds.rs:56:14 | LL | for _ in std::iter::once(1).skip(2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | for _ in std::iter::once(1).skip(2) {} = note: this operation is useless and will create an empty iterator error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:59:14 + --> tests/ui/iter_out_of_bounds.rs:59:14 | LL | for _ in std::iter::once(1).take(2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | for _ in std::iter::once(1).take(2) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.take()` call takes more items than the iterator will produce - --> $DIR/iter_out_of_bounds.rs:62:14 + --> tests/ui/iter_out_of_bounds.rs:62:14 | LL | for x in [].iter().take(1) { | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/iter_over_hash_type.stderr b/src/tools/clippy/tests/ui/iter_over_hash_type.stderr index cf420fb8e996e..6afe69ee20e1d 100644 --- a/src/tools/clippy/tests/ui/iter_over_hash_type.stderr +++ b/src/tools/clippy/tests/ui/iter_over_hash_type.stderr @@ -1,5 +1,5 @@ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:18:5 + --> tests/ui/iter_over_hash_type.rs:18:5 | LL | / for x in &hash_set { LL | | let _ = x; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::iter_over_hash_type)]` error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:21:5 + --> tests/ui/iter_over_hash_type.rs:21:5 | LL | / for x in hash_set.iter() { LL | | let _ = x; @@ -18,7 +18,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:24:5 + --> tests/ui/iter_over_hash_type.rs:24:5 | LL | / for x in hash_set.clone() { LL | | let _ = x; @@ -26,7 +26,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:27:5 + --> tests/ui/iter_over_hash_type.rs:27:5 | LL | / for x in hash_set.drain() { LL | | let _ = x; @@ -34,7 +34,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:32:5 + --> tests/ui/iter_over_hash_type.rs:32:5 | LL | / for (x, y) in &hash_map { LL | | let _ = (x, y); @@ -42,7 +42,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:35:5 + --> tests/ui/iter_over_hash_type.rs:35:5 | LL | / for x in hash_map.keys() { LL | | let _ = x; @@ -50,7 +50,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:38:5 + --> tests/ui/iter_over_hash_type.rs:38:5 | LL | / for x in hash_map.values() { LL | | let _ = x; @@ -58,7 +58,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:41:5 + --> tests/ui/iter_over_hash_type.rs:41:5 | LL | / for x in hash_map.values_mut() { LL | | *x += 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:44:5 + --> tests/ui/iter_over_hash_type.rs:44:5 | LL | / for x in hash_map.iter() { LL | | let _ = x; @@ -74,7 +74,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:47:5 + --> tests/ui/iter_over_hash_type.rs:47:5 | LL | / for x in hash_map.clone() { LL | | let _ = x; @@ -82,7 +82,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:50:5 + --> tests/ui/iter_over_hash_type.rs:50:5 | LL | / for x in hash_map.drain() { LL | | let _ = x; @@ -90,7 +90,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:55:5 + --> tests/ui/iter_over_hash_type.rs:55:5 | LL | / for x in fx_hash_set { LL | | let _ = x; @@ -98,7 +98,7 @@ LL | | } | |_____^ error: iteration over unordered hash-based type - --> $DIR/iter_over_hash_type.rs:58:5 + --> tests/ui/iter_over_hash_type.rs:58:5 | LL | / for x in fx_hash_map { LL | | let _ = x; diff --git a/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr b/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr index a9a739688ebf2..7a822a79494b7 100644 --- a/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr +++ b/src/tools/clippy/tests/ui/iter_overeager_cloned.stderr @@ -1,5 +1,5 @@ error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:7:29 + --> tests/ui/iter_overeager_cloned.rs:7:29 | LL | let _: Option = vec.iter().cloned().last(); | ^^^^^^^^^^---------------- @@ -10,7 +10,7 @@ LL | let _: Option = vec.iter().cloned().last(); = 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 + --> tests/ui/iter_overeager_cloned.rs:9:29 | LL | let _: Option = vec.iter().chain(vec.iter()).cloned().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------- @@ -18,7 +18,7 @@ LL | let _: Option = vec.iter().chain(vec.iter()).cloned().next(); | help: try: `.next().cloned()` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:11:20 + --> tests/ui/iter_overeager_cloned.rs:11:20 | LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------- @@ -29,7 +29,7 @@ LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count(); = help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:13:21 + --> tests/ui/iter_overeager_cloned.rs:13:21 | LL | let _: Vec<_> = vec.iter().cloned().take(2).collect(); | ^^^^^^^^^^----------------- @@ -37,7 +37,7 @@ LL | let _: Vec<_> = vec.iter().cloned().take(2).collect(); | help: try: `.take(2).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:15:21 + --> tests/ui/iter_overeager_cloned.rs:15:21 | LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect(); | ^^^^^^^^^^----------------- @@ -45,7 +45,7 @@ LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect(); | help: try: `.skip(2).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:17:13 + --> tests/ui/iter_overeager_cloned.rs:17:13 | LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------- @@ -53,7 +53,7 @@ LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2); | help: try: `.nth(2).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:19:13 + --> tests/ui/iter_overeager_cloned.rs:19:13 | LL | let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))] | _____________^ @@ -69,7 +69,7 @@ LL ~ .flatten().cloned(); | error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:24:13 + --> tests/ui/iter_overeager_cloned.rs:24:13 | LL | let _ = vec.iter().cloned().filter(|x| x.starts_with('2')); | ^^^^^^^^^^---------------------------------------- @@ -77,7 +77,7 @@ LL | let _ = vec.iter().cloned().filter(|x| x.starts_with('2')); | help: try: `.filter(|&x| x.starts_with('2')).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:26:13 + --> tests/ui/iter_overeager_cloned.rs:26:13 | LL | let _ = vec.iter().cloned().find(|x| x == "2"); | ^^^^^^^^^^---------------------------- @@ -85,7 +85,7 @@ LL | let _ = vec.iter().cloned().find(|x| x == "2"); | help: try: `.find(|&x| x == "2").cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:30:17 + --> tests/ui/iter_overeager_cloned.rs:30:17 | LL | let _ = vec.iter().cloned().filter(f); | ^^^^^^^^^^------------------- @@ -93,7 +93,7 @@ LL | let _ = vec.iter().cloned().filter(f); | help: try: `.filter(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:31:17 + --> tests/ui/iter_overeager_cloned.rs:31:17 | LL | let _ = vec.iter().cloned().find(f); | ^^^^^^^^^^----------------- @@ -101,7 +101,7 @@ LL | let _ = vec.iter().cloned().find(f); | help: try: `.find(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:37:17 + --> tests/ui/iter_overeager_cloned.rs:37:17 | LL | let _ = vec.iter().cloned().filter(f); | ^^^^^^^^^^------------------- @@ -109,7 +109,7 @@ LL | let _ = vec.iter().cloned().filter(f); | help: try: `.filter(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:38:17 + --> tests/ui/iter_overeager_cloned.rs:38:17 | LL | let _ = vec.iter().cloned().find(f); | ^^^^^^^^^^----------------- @@ -117,7 +117,7 @@ LL | let _ = vec.iter().cloned().find(f); | help: try: `.find(|&x| f(x)).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:45:9 + --> tests/ui/iter_overeager_cloned.rs:45:9 | LL | iter.cloned().filter(move |(&a, b)| a == 1 && b == &target) | ^^^^------------------------------------------------------- @@ -125,7 +125,7 @@ LL | iter.cloned().filter(move |(&a, b)| a == 1 && b == &target) | help: try: `.filter(move |&(&a, b)| a == 1 && b == &target).cloned()` error: unnecessarily eager cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:56:13 + --> tests/ui/iter_overeager_cloned.rs:56:13 | LL | iter.cloned().filter(move |S { a, b }| **a == 1 && b == &target) | ^^^^------------------------------------------------------------ @@ -133,7 +133,7 @@ LL | iter.cloned().filter(move |S { a, b }| **a == 1 && b == &target | help: try: `.filter(move |&S { a, b }| **a == 1 && b == &target).cloned()` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:60:13 + --> tests/ui/iter_overeager_cloned.rs:60:13 | LL | let _ = vec.iter().cloned().map(|x| x.len()); | ^^^^^^^^^^-------------------------- @@ -141,7 +141,7 @@ LL | let _ = vec.iter().cloned().map(|x| x.len()); | help: try: `.map(|x| x.len())` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:65:13 + --> tests/ui/iter_overeager_cloned.rs:65:13 | LL | let _ = vec.iter().cloned().for_each(|x| assert!(!x.is_empty())); | ^^^^^^^^^^---------------------------------------------- @@ -149,7 +149,7 @@ LL | let _ = vec.iter().cloned().for_each(|x| assert!(!x.is_empty())); | help: try: `.for_each(|x| assert!(!x.is_empty()))` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:67:13 + --> tests/ui/iter_overeager_cloned.rs:67:13 | LL | let _ = vec.iter().cloned().all(|x| x.len() == 1); | ^^^^^^^^^^------------------------------- @@ -157,7 +157,7 @@ LL | let _ = vec.iter().cloned().all(|x| x.len() == 1); | help: try: `.all(|x| x.len() == 1)` error: unneeded cloning of iterator items - --> $DIR/iter_overeager_cloned.rs:69:13 + --> tests/ui/iter_overeager_cloned.rs:69:13 | LL | let _ = vec.iter().cloned().any(|x| x.len() == 1); | ^^^^^^^^^^------------------------------- diff --git a/src/tools/clippy/tests/ui/iter_skip_next.stderr b/src/tools/clippy/tests/ui/iter_skip_next.stderr index 39b173e758693..0fa04465ff156 100644 --- a/src/tools/clippy/tests/ui/iter_skip_next.stderr +++ b/src/tools/clippy/tests/ui/iter_skip_next.stderr @@ -1,5 +1,5 @@ error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:17:28 + --> tests/ui/iter_skip_next.rs:17:28 | LL | let _ = some_vec.iter().skip(42).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(42)` @@ -8,37 +8,37 @@ LL | let _ = some_vec.iter().skip(42).next(); = help: to override `-D warnings` add `#[allow(clippy::iter_skip_next)]` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:18:36 + --> tests/ui/iter_skip_next.rs:18:36 | LL | let _ = some_vec.iter().cycle().skip(42).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(42)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:19:20 + --> tests/ui/iter_skip_next.rs:19:20 | LL | let _ = (1..10).skip(10).next(); | ^^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(10)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:20:33 + --> tests/ui/iter_skip_next.rs:20:33 | LL | let _ = &some_vec[..].iter().skip(3).next(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(3)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:28:26 + --> tests/ui/iter_skip_next.rs:28:26 | LL | let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:30:29 + --> tests/ui/iter_skip_next.rs:30:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next.rs:36:29 + --> tests/ui/iter_skip_next.rs:36:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` 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 09a467793bd12..9bfffb07ca62d 100644 --- a/src/tools/clippy/tests/ui/iter_skip_next_unfixable.stderr +++ b/src/tools/clippy/tests/ui/iter_skip_next_unfixable.stderr @@ -1,11 +1,11 @@ error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next_unfixable.rs:9:26 + --> tests/ui/iter_skip_next_unfixable.rs:9:26 | LL | let _: Vec<&str> = sp.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` | help: for this change `sp` has to be mutable - --> $DIR/iter_skip_next_unfixable.rs:8:9 + --> tests/ui/iter_skip_next_unfixable.rs:8:9 | LL | let sp = test_string.split('|').map(|s| s.trim()); | ^^ @@ -13,25 +13,25 @@ LL | let sp = test_string.split('|').map(|s| s.trim()); = 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 + --> tests/ui/iter_skip_next_unfixable.rs:12:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` | help: for this change `s` has to be mutable - --> $DIR/iter_skip_next_unfixable.rs:11:17 + --> tests/ui/iter_skip_next_unfixable.rs:11:17 | LL | if let Some(s) = Some(test_string.split('|').map(|s| s.trim())) { | ^ error: called `skip(..).next()` on an iterator - --> $DIR/iter_skip_next_unfixable.rs:19:29 + --> tests/ui/iter_skip_next_unfixable.rs:19:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` | help: for this change `s` has to be mutable - --> $DIR/iter_skip_next_unfixable.rs:15:17 + --> tests/ui/iter_skip_next_unfixable.rs:15:17 | LL | fn check(s: T) | ^ diff --git a/src/tools/clippy/tests/ui/iter_skip_zero.stderr b/src/tools/clippy/tests/ui/iter_skip_zero.stderr index 6b8b3b1056acf..ef46db8433778 100644 --- a/src/tools/clippy/tests/ui/iter_skip_zero.stderr +++ b/src/tools/clippy/tests/ui/iter_skip_zero.stderr @@ -1,5 +1,5 @@ error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:11:35 + --> tests/ui/iter_skip_zero.rs:11:35 | LL | let _ = [1, 2, 3].iter().skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -9,7 +9,7 @@ LL | let _ = [1, 2, 3].iter().skip(0); = help: to override `-D warnings` add `#[allow(clippy::iter_skip_zero)]` error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:12:39 + --> tests/ui/iter_skip_zero.rs:12:39 | LL | let _ = vec![1, 2, 3].iter().skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -17,7 +17,7 @@ LL | let _ = vec![1, 2, 3].iter().skip(0); = note: this call to `skip` does nothing and is useless; remove it error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:13:34 + --> tests/ui/iter_skip_zero.rs:13:34 | LL | let _ = once([1, 2, 3]).skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -25,7 +25,7 @@ LL | let _ = once([1, 2, 3]).skip(0); = note: this call to `skip` does nothing and is useless; remove it error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:14:71 + --> tests/ui/iter_skip_zero.rs:14:71 | LL | let _ = vec![1, 2, 3].iter().chain([1, 2, 3].iter().skip(0)).skip(0); | ^ help: if you meant to skip the first element, use: `1` @@ -33,7 +33,7 @@ LL | let _ = vec![1, 2, 3].iter().chain([1, 2, 3].iter().skip(0)).skip(0); = note: this call to `skip` does nothing and is useless; remove it error: usage of `.skip(0)` - --> $DIR/iter_skip_zero.rs:14:62 + --> tests/ui/iter_skip_zero.rs:14:62 | LL | let _ = vec![1, 2, 3].iter().chain([1, 2, 3].iter().skip(0)).skip(0); | ^ help: if you meant to skip the first element, use: `1` diff --git a/src/tools/clippy/tests/ui/iter_with_drain.stderr b/src/tools/clippy/tests/ui/iter_with_drain.stderr index ac04f9396f5d2..265e18c263be8 100644 --- a/src/tools/clippy/tests/ui/iter_with_drain.stderr +++ b/src/tools/clippy/tests/ui/iter_with_drain.stderr @@ -1,5 +1,5 @@ error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:10:34 + --> tests/ui/iter_with_drain.rs:10:34 | LL | let mut a: BinaryHeap<_> = a.drain(..).collect(); | ^^^^^^^^^ help: try: `into_iter()` @@ -8,31 +8,31 @@ LL | let mut a: BinaryHeap<_> = a.drain(..).collect(); = help: to override `-D warnings` add `#[allow(clippy::iter_with_drain)]` error: `drain(..)` used on a `VecDeque` - --> $DIR/iter_with_drain.rs:13:27 + --> tests/ui/iter_with_drain.rs:13:27 | LL | let mut a: Vec<_> = a.drain(..).collect(); | ^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:14:34 + --> tests/ui/iter_with_drain.rs:14:34 | LL | let mut a: HashMap<_, _> = a.drain(..).map(|x| (x.clone(), x)).collect(); | ^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:20:34 + --> tests/ui/iter_with_drain.rs:20:34 | LL | let mut a: BinaryHeap<_> = a.drain(0..).collect(); | ^^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `VecDeque` - --> $DIR/iter_with_drain.rs:23:27 + --> tests/ui/iter_with_drain.rs:23:27 | LL | let mut a: Vec<_> = a.drain(..a.len()).collect(); | ^^^^^^^^^^^^^^^^ help: try: `into_iter()` error: `drain(..)` used on a `Vec` - --> $DIR/iter_with_drain.rs:24:34 + --> tests/ui/iter_with_drain.rs:24:34 | LL | let mut a: HashMap<_, _> = a.drain(0..a.len()).map(|x| (x.clone(), x)).collect(); | ^^^^^^^^^^^^^^^^^ help: try: `into_iter()` diff --git a/src/tools/clippy/tests/ui/iter_without_into_iter.stderr b/src/tools/clippy/tests/ui/iter_without_into_iter.stderr index 4cf20e2aa56c9..382a7606f48c6 100644 --- a/src/tools/clippy/tests/ui/iter_without_into_iter.stderr +++ b/src/tools/clippy/tests/ui/iter_without_into_iter.stderr @@ -1,5 +1,5 @@ error: `iter` method without an `IntoIterator` impl for `&S1` - --> $DIR/iter_without_into_iter.rs:8:5 + --> tests/ui/iter_without_into_iter.rs:8:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'_, u8> { LL | | @@ -22,7 +22,7 @@ LL + } | error: `iter_mut` method without an `IntoIterator` impl for `&mut S1` - --> $DIR/iter_without_into_iter.rs:12:5 + --> tests/ui/iter_without_into_iter.rs:12:5 | LL | / pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, u8> { LL | | @@ -43,7 +43,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&S3<'a>` - --> $DIR/iter_without_into_iter.rs:28:5 + --> tests/ui/iter_without_into_iter.rs:28:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'_, u8> { LL | | @@ -64,7 +64,7 @@ LL + } | error: `iter_mut` method without an `IntoIterator` impl for `&mut S3<'a>` - --> $DIR/iter_without_into_iter.rs:32:5 + --> tests/ui/iter_without_into_iter.rs:32:5 | LL | / pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, u8> { LL | | @@ -85,7 +85,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&S8` - --> $DIR/iter_without_into_iter.rs:69:5 + --> tests/ui/iter_without_into_iter.rs:69:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'static, T> { LL | | todo!() @@ -105,7 +105,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&S9` - --> $DIR/iter_without_into_iter.rs:77:5 + --> tests/ui/iter_without_into_iter.rs:77:5 | LL | / pub fn iter(&self) -> std::slice::Iter<'_, T> { LL | | @@ -126,7 +126,7 @@ LL + } | error: `iter_mut` method without an `IntoIterator` impl for `&mut S9` - --> $DIR/iter_without_into_iter.rs:81:5 + --> tests/ui/iter_without_into_iter.rs:81:5 | LL | / pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, T> { LL | | @@ -147,7 +147,7 @@ LL + } | error: `iter` method without an `IntoIterator` impl for `&Issue12037` - --> $DIR/iter_without_into_iter.rs:130:13 + --> tests/ui/iter_without_into_iter.rs:130:13 | LL | / fn iter(&self) -> std::slice::Iter<'_, u8> { LL | | todo!() 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 20ea29322e858..4156642d6dbb8 100644 --- a/src/tools/clippy/tests/ui/iterator_step_by_zero.stderr +++ b/src/tools/clippy/tests/ui/iterator_step_by_zero.stderr @@ -1,5 +1,5 @@ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:4:13 + --> tests/ui/iterator_step_by_zero.rs:4:13 | LL | let _ = vec!["A", "B", "B"].iter().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,37 +8,37 @@ LL | let _ = vec!["A", "B", "B"].iter().step_by(0); = 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 + --> tests/ui/iterator_step_by_zero.rs:7:13 | LL | let _ = "XXX".chars().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:9:13 + --> tests/ui/iterator_step_by_zero.rs:9:13 | LL | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:19:13 + --> tests/ui/iterator_step_by_zero.rs:19:13 | LL | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:21:13 + --> tests/ui/iterator_step_by_zero.rs:21:13 | LL | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:25:13 + --> tests/ui/iterator_step_by_zero.rs:25:13 | LL | let _ = x.step_by(0); | ^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> $DIR/iterator_step_by_zero.rs:30:13 + --> tests/ui/iterator_step_by_zero.rs:30:13 | LL | let _ = v1.iter().step_by(2 / 3); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/join_absolute_paths.stderr b/src/tools/clippy/tests/ui/join_absolute_paths.stderr index ab4d189ca3a22..e7fd5508823ae 100644 --- a/src/tools/clippy/tests/ui/join_absolute_paths.stderr +++ b/src/tools/clippy/tests/ui/join_absolute_paths.stderr @@ -1,5 +1,5 @@ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:10:15 + --> tests/ui/join_absolute_paths.rs:10:15 | LL | path.join("/sh"); | ^^^^^ @@ -17,7 +17,7 @@ LL | PathBuf::from("/sh"); | ~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:14:15 + --> tests/ui/join_absolute_paths.rs:14:15 | LL | path.join("\\user"); | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | PathBuf::from("\\user"); | ~~~~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:18:15 + --> tests/ui/join_absolute_paths.rs:18:15 | LL | path.join("/sh"); | ^^^^^ @@ -49,7 +49,7 @@ LL | PathBuf::from("/sh"); | ~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> $DIR/join_absolute_paths.rs:22:15 + --> tests/ui/join_absolute_paths.rs:22:15 | LL | path.join(r#"/sh"#); | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/large_const_arrays.stderr b/src/tools/clippy/tests/ui/large_const_arrays.stderr index e522550ffcbdc..88f921b81f721 100644 --- a/src/tools/clippy/tests/ui/large_const_arrays.stderr +++ b/src/tools/clippy/tests/ui/large_const_arrays.stderr @@ -1,5 +1,5 @@ error: large array defined as const - --> $DIR/large_const_arrays.rs:10:1 + --> tests/ui/large_const_arrays.rs:10:1 | LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000]; | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | pub(crate) const FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000]; = help: to override `-D warnings` add `#[allow(clippy::large_const_arrays)]` error: large array defined as const - --> $DIR/large_const_arrays.rs:11:1 + --> tests/ui/large_const_arrays.rs:11:1 | LL | pub const FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | pub const FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:12:1 + --> tests/ui/large_const_arrays.rs:12:1 | LL | const FOO: [u32; 1_000_000] = [0u32; 1_000_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | const FOO: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:21:5 + --> tests/ui/large_const_arrays.rs:21:5 | LL | pub const BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | pub const BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:22:5 + --> tests/ui/large_const_arrays.rs:22:5 | LL | const BAR: [u32; 1_000_000] = [0u32; 1_000_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | const BAR: [u32; 1_000_000] = [0u32; 1_000_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:23:5 + --> tests/ui/large_const_arrays.rs:23:5 | LL | pub const BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | pub const BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:24:5 + --> tests/ui/large_const_arrays.rs:24:5 | LL | const BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +58,7 @@ LL | const BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:25:5 + --> tests/ui/large_const_arrays.rs:25:5 | LL | pub const BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000]; | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL | pub const BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000]; | help: make this a static item: `static` error: large array defined as const - --> $DIR/large_const_arrays.rs:26:5 + --> tests/ui/large_const_arrays.rs:26:5 | LL | const BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000]; | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/large_digit_groups.stderr b/src/tools/clippy/tests/ui/large_digit_groups.stderr index e5f37a6cce96b..da34a91bc3bcf 100644 --- a/src/tools/clippy/tests/ui/large_digit_groups.stderr +++ b/src/tools/clippy/tests/ui/large_digit_groups.stderr @@ -1,5 +1,5 @@ error: digits of hex, binary or octal literal not in groups of equal size - --> $DIR/large_digit_groups.rs:22:9 + --> tests/ui/large_digit_groups.rs:22:9 | LL | 0xd_e_adbee_f_usize, | ^^^^^^^^^^^^^^^^^^^ help: consider: `0xdead_beef_usize` @@ -8,7 +8,7 @@ LL | 0xd_e_adbee_f_usize, = help: to override `-D warnings` add `#[allow(clippy::unusual_byte_groupings)]` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:23:9 + --> tests/ui/large_digit_groups.rs:23:9 | LL | 1_23456_f32, | ^^^^^^^^^^^ help: consider: `123_456_f32` @@ -17,19 +17,19 @@ LL | 1_23456_f32, = help: to override `-D warnings` add `#[allow(clippy::large_digit_groups)]` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:24:9 + --> tests/ui/large_digit_groups.rs:24:9 | LL | 1_23456.12_f32, | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:25:9 + --> tests/ui/large_digit_groups.rs:25:9 | LL | 1_23456.12345_f64, | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f64` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:26:9 + --> tests/ui/large_digit_groups.rs:26:9 | LL | 1_23456.12345_6_f64, | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f64` diff --git a/src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr b/src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr index 0e0eee21cf30a..ff4f1a7f312cb 100644 --- a/src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr +++ b/src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr @@ -1,5 +1,5 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:11:1 + --> tests/ui/large_enum_variant.rs:11:1 | LL | / enum LargeEnum { LL | | A(i32), @@ -17,7 +17,7 @@ LL | B(Box<[i32; 8000]>), | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:35:1 + --> tests/ui/large_enum_variant.rs:35:1 | LL | / enum LargeEnum2 { LL | | VariantOk(i32, u32), @@ -33,7 +33,7 @@ LL | ContainingLargeEnum(Box), | ~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:40:1 + --> tests/ui/large_enum_variant.rs:40:1 | LL | / enum LargeEnum3 { LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), @@ -50,7 +50,7 @@ LL | ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>), | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:46:1 + --> tests/ui/large_enum_variant.rs:46:1 | LL | / enum LargeEnum4 { LL | | VariantOk(i32, u32), @@ -66,7 +66,7 @@ LL | StructLikeLarge { x: Box<[i32; 8000]>, y: i32 }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:51:1 + --> tests/ui/large_enum_variant.rs:51:1 | LL | / enum LargeEnum5 { LL | | VariantOk(i32, u32), @@ -82,7 +82,7 @@ LL | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:67:1 + --> tests/ui/large_enum_variant.rs:67:1 | LL | / enum LargeEnum7 { LL | | A, @@ -99,7 +99,7 @@ LL | B(Box<[u8; 1255]>), | ~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:73:1 + --> tests/ui/large_enum_variant.rs:73:1 | LL | / enum LargeEnum8 { LL | | VariantOk(i32, u32), @@ -115,7 +115,7 @@ LL | ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]> | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:78:1 + --> tests/ui/large_enum_variant.rs:78:1 | LL | / enum LargeEnum9 { LL | | A(Struct<()>), @@ -131,7 +131,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:83:1 + --> tests/ui/large_enum_variant.rs:83:1 | LL | / enum LargeEnumOk2 { LL | | A(T), @@ -147,7 +147,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:88:1 + --> tests/ui/large_enum_variant.rs:88:1 | LL | / enum LargeEnumOk3 { LL | | A(Struct), @@ -163,7 +163,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:103:1 + --> tests/ui/large_enum_variant.rs:103:1 | LL | / enum CopyableLargeEnum { LL | | A(bool), @@ -174,18 +174,18 @@ LL | | } | |_^ the entire enum is at least 64004 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:103:6 + --> tests/ui/large_enum_variant.rs:103:6 | LL | enum CopyableLargeEnum { | ^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:105:5 + --> tests/ui/large_enum_variant.rs:105:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:108:1 + --> tests/ui/large_enum_variant.rs:108:1 | LL | / enum ManuallyCopyLargeEnum { LL | | A(bool), @@ -196,18 +196,18 @@ LL | | } | |_^ the entire enum is at least 64004 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:108:6 + --> tests/ui/large_enum_variant.rs:108:6 | LL | enum ManuallyCopyLargeEnum { | ^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:110:5 + --> tests/ui/large_enum_variant.rs:110:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:121:1 + --> tests/ui/large_enum_variant.rs:121:1 | LL | / enum SomeGenericPossiblyCopyEnum { LL | | A(bool, std::marker::PhantomData), @@ -218,18 +218,18 @@ LL | | } | |_^ the entire enum is at least 32004 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:121:6 + --> tests/ui/large_enum_variant.rs:121:6 | LL | enum SomeGenericPossiblyCopyEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:123:5 + --> tests/ui/large_enum_variant.rs:123:5 | LL | B([u64; 4000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:134:1 + --> tests/ui/large_enum_variant.rs:134:1 | LL | / enum LargeEnumWithGenerics { LL | | Small, @@ -245,7 +245,7 @@ LL | Large(Box<(T, [u8; 512])>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:143:1 + --> tests/ui/large_enum_variant.rs:143:1 | LL | / enum WithGenerics { LL | | Large([Foo; 64]), @@ -261,7 +261,7 @@ LL | Large(Box<[Foo; 64]>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:153:1 + --> tests/ui/large_enum_variant.rs:153:1 | LL | / enum LargeEnumOfConst { LL | | Ok, diff --git a/src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr b/src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr index 3eba43e05ece5..805cb406f8344 100644 --- a/src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr +++ b/src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr @@ -1,5 +1,5 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:11:1 + --> tests/ui/large_enum_variant.rs:11:1 | LL | / enum LargeEnum { LL | | A(i32), @@ -17,7 +17,7 @@ LL | B(Box<[i32; 8000]>), | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:35:1 + --> tests/ui/large_enum_variant.rs:35:1 | LL | / enum LargeEnum2 { LL | | VariantOk(i32, u32), @@ -33,7 +33,7 @@ LL | ContainingLargeEnum(Box), | ~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:40:1 + --> tests/ui/large_enum_variant.rs:40:1 | LL | / enum LargeEnum3 { LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), @@ -50,7 +50,7 @@ LL | ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>), | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:46:1 + --> tests/ui/large_enum_variant.rs:46:1 | LL | / enum LargeEnum4 { LL | | VariantOk(i32, u32), @@ -66,7 +66,7 @@ LL | StructLikeLarge { x: Box<[i32; 8000]>, y: i32 }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:51:1 + --> tests/ui/large_enum_variant.rs:51:1 | LL | / enum LargeEnum5 { LL | | VariantOk(i32, u32), @@ -82,7 +82,7 @@ LL | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:67:1 + --> tests/ui/large_enum_variant.rs:67:1 | LL | / enum LargeEnum7 { LL | | A, @@ -99,7 +99,7 @@ LL | B(Box<[u8; 1255]>), | ~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:73:1 + --> tests/ui/large_enum_variant.rs:73:1 | LL | / enum LargeEnum8 { LL | | VariantOk(i32, u32), @@ -115,7 +115,7 @@ LL | ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]> | ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:78:1 + --> tests/ui/large_enum_variant.rs:78:1 | LL | / enum LargeEnum9 { LL | | A(Struct<()>), @@ -131,7 +131,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:83:1 + --> tests/ui/large_enum_variant.rs:83:1 | LL | / enum LargeEnumOk2 { LL | | A(T), @@ -147,7 +147,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:88:1 + --> tests/ui/large_enum_variant.rs:88:1 | LL | / enum LargeEnumOk3 { LL | | A(Struct), @@ -163,7 +163,7 @@ LL | B(Box), | ~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:103:1 + --> tests/ui/large_enum_variant.rs:103:1 | LL | / enum CopyableLargeEnum { LL | | A(bool), @@ -174,18 +174,18 @@ LL | | } | |_^ the entire enum is at least 64008 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:103:6 + --> tests/ui/large_enum_variant.rs:103:6 | LL | enum CopyableLargeEnum { | ^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:105:5 + --> tests/ui/large_enum_variant.rs:105:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:108:1 + --> tests/ui/large_enum_variant.rs:108:1 | LL | / enum ManuallyCopyLargeEnum { LL | | A(bool), @@ -196,18 +196,18 @@ LL | | } | |_^ the entire enum is at least 64008 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:108:6 + --> tests/ui/large_enum_variant.rs:108:6 | LL | enum ManuallyCopyLargeEnum { | ^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:110:5 + --> tests/ui/large_enum_variant.rs:110:5 | LL | B([u64; 8000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:121:1 + --> tests/ui/large_enum_variant.rs:121:1 | LL | / enum SomeGenericPossiblyCopyEnum { LL | | A(bool, std::marker::PhantomData), @@ -218,18 +218,18 @@ LL | | } | |_^ the entire enum is at least 32008 bytes | note: boxing a variant would require the type no longer be `Copy` - --> $DIR/large_enum_variant.rs:121:6 + --> tests/ui/large_enum_variant.rs:121:6 | LL | enum SomeGenericPossiblyCopyEnum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:123:5 + --> tests/ui/large_enum_variant.rs:123:5 | LL | B([u64; 4000]), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:134:1 + --> tests/ui/large_enum_variant.rs:134:1 | LL | / enum LargeEnumWithGenerics { LL | | Small, @@ -245,7 +245,7 @@ LL | Large(Box<(T, [u8; 512])>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:143:1 + --> tests/ui/large_enum_variant.rs:143:1 | LL | / enum WithGenerics { LL | | Large([Foo; 64]), @@ -261,7 +261,7 @@ LL | Large(Box<[Foo; 64]>), | ~~~~~~~~~~~~~~~~~~~ error: large size difference between variants - --> $DIR/large_enum_variant.rs:153:1 + --> tests/ui/large_enum_variant.rs:153:1 | LL | / enum LargeEnumOfConst { LL | | Ok, diff --git a/src/tools/clippy/tests/ui/large_futures.stderr b/src/tools/clippy/tests/ui/large_futures.stderr index 861366dafac6d..5709c7b77a0a5 100644 --- a/src/tools/clippy/tests/ui/large_futures.stderr +++ b/src/tools/clippy/tests/ui/large_futures.stderr @@ -1,5 +1,5 @@ error: large future with a size of 16385 bytes - --> $DIR/large_futures.rs:11:9 + --> tests/ui/large_futures.rs:11:9 | LL | big_fut([0u8; 1024 * 16]).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(big_fut([0u8; 1024 * 16]))` @@ -8,37 +8,37 @@ LL | big_fut([0u8; 1024 * 16]).await; = 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 + --> tests/ui/large_futures.rs:15:5 | LL | f.await | ^ help: consider `Box::pin` on it: `Box::pin(f)` error: large future with a size of 16387 bytes - --> $DIR/large_futures.rs:20:9 + --> tests/ui/large_futures.rs:20:9 | LL | wait().await; | ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())` error: large future with a size of 16387 bytes - --> $DIR/large_futures.rs:25:13 + --> tests/ui/large_futures.rs:25:13 | LL | wait().await; | ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())` error: large future with a size of 65540 bytes - --> $DIR/large_futures.rs:33:5 + --> tests/ui/large_futures.rs:33:5 | LL | foo().await; | ^^^^^ help: consider `Box::pin` on it: `Box::pin(foo())` error: large future with a size of 49159 bytes - --> $DIR/large_futures.rs:35:5 + --> tests/ui/large_futures.rs:35:5 | LL | calls_fut(fut).await; | ^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(calls_fut(fut))` error: large future with a size of 65540 bytes - --> $DIR/large_futures.rs:48:5 + --> tests/ui/large_futures.rs:48:5 | LL | / async { LL | | @@ -59,7 +59,7 @@ LL + }) | error: large future with a size of 65540 bytes - --> $DIR/large_futures.rs:60:13 + --> tests/ui/large_futures.rs:60:13 | LL | / async { LL | | let x = [0i32; 1024 * 16]; diff --git a/src/tools/clippy/tests/ui/large_stack_arrays.stderr b/src/tools/clippy/tests/ui/large_stack_arrays.stderr index 0dfb6732b02a5..007ca61c2de13 100644 --- a/src/tools/clippy/tests/ui/large_stack_arrays.stderr +++ b/src/tools/clippy/tests/ui/large_stack_arrays.stderr @@ -1,5 +1,5 @@ error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:29:14 + --> tests/ui/large_stack_arrays.rs:29:14 | LL | let _x = [build(); 3]; | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _x = [build(); 3]; = 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 + --> tests/ui/large_stack_arrays.rs:32:14 | LL | let _y = [build(), build(), build()]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _y = [build(), build(), build()]; = help: consider allocating on the heap with `vec![build(), build(), build()].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:38:9 + --> tests/ui/large_stack_arrays.rs:38:9 | LL | [0u32; 20_000_000], | ^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | [0u32; 20_000_000], = help: consider allocating on the heap with `vec![0u32; 20_000_000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:40:9 + --> tests/ui/large_stack_arrays.rs:40:9 | LL | [S { data: [0; 32] }; 5000], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | [S { data: [0; 32] }; 5000], = help: consider allocating on the heap with `vec![S { data: [0; 32] }; 5000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:42:9 + --> tests/ui/large_stack_arrays.rs:42:9 | LL | [Some(""); 20_000_000], | ^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | [Some(""); 20_000_000], = help: consider allocating on the heap with `vec![Some(""); 20_000_000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:44:9 + --> tests/ui/large_stack_arrays.rs:44:9 | LL | [E::T(0); 5000], | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | [E::T(0); 5000], = help: consider allocating on the heap with `vec![E::T(0); 5000].into_boxed_slice()` error: allocating a local array larger than 512000 bytes - --> $DIR/large_stack_arrays.rs:46:9 + --> tests/ui/large_stack_arrays.rs:46:9 | LL | [0u8; usize::MAX], | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/large_stack_frames.stderr b/src/tools/clippy/tests/ui/large_stack_frames.stderr index 12a458db807e1..b99500fd9c34d 100644 --- a/src/tools/clippy/tests/ui/large_stack_frames.stderr +++ b/src/tools/clippy/tests/ui/large_stack_frames.stderr @@ -1,5 +1,5 @@ error: this function allocates a large amount of stack space - --> $DIR/large_stack_frames.rs:25:1 + --> tests/ui/large_stack_frames.rs:25:1 | LL | / fn many_small_arrays() { LL | | @@ -15,7 +15,7 @@ LL | | } = 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 + --> tests/ui/large_stack_frames.rs:36:1 | LL | / fn large_return_value() -> ArrayDefault<1_000_000> { LL | | @@ -27,7 +27,7 @@ LL | | } = note: allocating large amounts of stack space can overflow the stack error: this function allocates a large amount of stack space - --> $DIR/large_stack_frames.rs:42:1 + --> tests/ui/large_stack_frames.rs:42:1 | LL | / fn large_fn_arg(x: ArrayDefault<1_000_000>) { LL | | 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 b3f102cc498d8..5b42ab9e02ac4 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 @@ -1,5 +1,5 @@ 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:20:11 + --> tests/ui/large_types_passed_by_value.rs:20:11 | LL | fn bad(a: LargeAndCopy) {} | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` @@ -8,43 +8,43 @@ LL | fn bad(a: LargeAndCopy) {} = 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 + --> tests/ui/large_types_passed_by_value.rs:25:37 | LL | fn other_is_not_ok(self, other: LargeAndCopy) {} | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` 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:31:36 + --> tests/ui/large_types_passed_by_value.rs:31:36 | LL | fn devoure_array(&self, array: [u8; 6666]); | ^^^^^^^^^^ help: consider passing by reference instead: `&[u8; 6666]` 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:32:34 + --> tests/ui/large_types_passed_by_value.rs:32:34 | LL | fn devoure_tuple(&self, tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider passing by reference instead: `&(LargeAndCopy, LargeAndCopy)` 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:33:50 + --> tests/ui/large_types_passed_by_value.rs:33:50 | LL | fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^ help: consider passing by reference instead: `&[u8; 6666]` 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:33:67 + --> tests/ui/large_types_passed_by_value.rs:33:67 | LL | fn devoure_array_and_tuple_wow(&self, array: [u8; 6666], tup: (LargeAndCopy, LargeAndCopy)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider passing by reference instead: `&(LargeAndCopy, LargeAndCopy)` 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:58:17 + --> tests/ui/large_types_passed_by_value.rs:58:17 | LL | fn foo_never(x: LargeAndCopy) { | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` 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:62:11 + --> tests/ui/large_types_passed_by_value.rs:62:11 | LL | fn foo(x: LargeAndCopy) { | ^^^^^^^^^^^^ help: consider passing by reference instead: `&LargeAndCopy` 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 8e51c28b33003..11d0d855fc0b8 100644 --- a/src/tools/clippy/tests/ui/len_without_is_empty.stderr +++ b/src/tools/clippy/tests/ui/len_without_is_empty.stderr @@ -1,5 +1,5 @@ error: struct `PubOne` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:7:5 + --> tests/ui/len_without_is_empty.rs:7:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | pub fn len(&self) -> isize { = 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 + --> tests/ui/len_without_is_empty.rs:57:1 | LL | / pub trait PubTraitsToo { LL | | @@ -17,45 +17,45 @@ LL | | } | |_^ error: struct `HasIsEmpty` has a public `len` method, but a private `is_empty` method - --> $DIR/len_without_is_empty.rs:71:5 + --> tests/ui/len_without_is_empty.rs:71:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:76:5 + --> tests/ui/len_without_is_empty.rs:76:5 | LL | fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `HasWrongIsEmpty` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:84:5 + --> tests/ui/len_without_is_empty.rs:84:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:89:5 + --> tests/ui/len_without_is_empty.rs:89:5 | LL | pub fn is_empty(&self, x: u32) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` error: struct `MismatchedSelf` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:97:5 + --> tests/ui/len_without_is_empty.rs:97:5 | LL | pub fn len(self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:102:5 + --> tests/ui/len_without_is_empty.rs:102:5 | LL | pub fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(self) -> bool` error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_without_is_empty.rs:177:1 + --> tests/ui/len_without_is_empty.rs:177:1 | LL | / pub trait DependsOnFoo: Foo { LL | | @@ -64,33 +64,33 @@ LL | | } | |_^ error: struct `OptionalLen3` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:223:5 + --> tests/ui/len_without_is_empty.rs:223:5 | LL | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:229:5 + --> tests/ui/len_without_is_empty.rs:229:5 | LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` error: struct `ResultLen` has a public `len` method, but the `is_empty` method has an unexpected signature - --> $DIR/len_without_is_empty.rs:236:5 + --> tests/ui/len_without_is_empty.rs:236:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> $DIR/len_without_is_empty.rs:243:5 + --> tests/ui/len_without_is_empty.rs:243:5 | LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` or `(&self) -> Result error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:236:5 + --> tests/ui/len_without_is_empty.rs:236:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | pub fn len(&self) -> Result { = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]` error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:250:5 + --> tests/ui/len_without_is_empty.rs:250:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | pub fn len(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:255:5 + --> tests/ui/len_without_is_empty.rs:255:5 | LL | pub fn is_empty(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL | pub fn is_empty(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> $DIR/len_without_is_empty.rs:263:5 + --> tests/ui/len_without_is_empty.rs:263:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -124,25 +124,25 @@ LL | pub fn len(&self) -> Result { = help: use a custom `Error` type instead error: struct `AsyncLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:305:5 + --> tests/ui/len_without_is_empty.rs:305:5 | LL | pub async fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `AsyncOptionLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:318:5 + --> tests/ui/len_without_is_empty.rs:318:5 | LL | pub async fn len(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `AsyncResultLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:340:5 + --> tests/ui/len_without_is_empty.rs:340:5 | LL | pub async fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `Alias2` has a public `len` method, but no `is_empty` method - --> $DIR/len_without_is_empty.rs:456:5 + --> tests/ui/len_without_is_empty.rs:456:5 | LL | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/len_zero.stderr b/src/tools/clippy/tests/ui/len_zero.stderr index e1f2434415d0f..b1f04c94de665 100644 --- a/src/tools/clippy/tests/ui/len_zero.stderr +++ b/src/tools/clippy/tests/ui/len_zero.stderr @@ -1,5 +1,5 @@ error: length comparison to zero - --> $DIR/len_zero.rs:82:8 + --> tests/ui/len_zero.rs:82:8 | LL | if x.len() == 0 { | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` @@ -8,13 +8,13 @@ LL | if x.len() == 0 { = help: to override `-D warnings` add `#[allow(clippy::len_zero)]` error: length comparison to zero - --> $DIR/len_zero.rs:86:8 + --> tests/ui/len_zero.rs:86:8 | LL | if "".len() == 0 {} | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:95:20 + --> tests/ui/len_zero.rs:95:20 | LL | println!("{}", *s1 == ""); | ^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s1.is_empty()` @@ -23,121 +23,121 @@ LL | println!("{}", *s1 == ""); = help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]` error: comparison to empty slice - --> $DIR/len_zero.rs:96:20 + --> tests/ui/len_zero.rs:96:20 | LL | println!("{}", **s2 == ""); | ^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s2.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:97:20 + --> tests/ui/len_zero.rs:97:20 | LL | println!("{}", ***s3 == ""); | ^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s3.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:98:20 + --> tests/ui/len_zero.rs:98:20 | LL | println!("{}", ****s4 == ""); | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s4.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:99:20 + --> tests/ui/len_zero.rs:99:20 | LL | println!("{}", *****s5 == ""); | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s5.is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:100:20 + --> tests/ui/len_zero.rs:100:20 | LL | println!("{}", ******(s6) == ""); | ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(s6).is_empty()` error: comparison to empty slice - --> $DIR/len_zero.rs:103:20 + --> tests/ui/len_zero.rs:103:20 | LL | println!("{}", &**d2s == ""); | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(**d2s).is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:118:8 + --> tests/ui/len_zero.rs:118:8 | LL | if has_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:121:8 + --> tests/ui/len_zero.rs:121:8 | LL | if has_is_empty.len() != 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:124:8 + --> tests/ui/len_zero.rs:124:8 | LL | if has_is_empty.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:127:8 + --> tests/ui/len_zero.rs:127:8 | LL | if has_is_empty.len() < 1 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:130:8 + --> tests/ui/len_zero.rs:130:8 | LL | if has_is_empty.len() >= 1 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:141:8 + --> tests/ui/len_zero.rs:141:8 | LL | if 0 == has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:144:8 + --> tests/ui/len_zero.rs:144:8 | LL | if 0 != has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:147:8 + --> tests/ui/len_zero.rs:147:8 | LL | if 0 < has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:150:8 + --> tests/ui/len_zero.rs:150:8 | LL | if 1 <= has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:153:8 + --> tests/ui/len_zero.rs:153:8 | LL | if 1 > has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:167:8 + --> tests/ui/len_zero.rs:167:8 | LL | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:179:6 + --> tests/ui/len_zero.rs:179:6 | LL | (has_is_empty.len() > 0).then(|| println!("This can happen.")); | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:180:6 + --> tests/ui/len_zero.rs:180:6 | LL | (has_is_empty.len() == 0).then(|| println!("Or this!")); | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:184:8 + --> tests/ui/len_zero.rs:184:8 | LL | if b.len() != 0 {} | ^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!b.is_empty()` diff --git a/src/tools/clippy/tests/ui/len_zero_ranges.stderr b/src/tools/clippy/tests/ui/len_zero_ranges.stderr index 1922e9b304443..0b2991e15ea32 100644 --- a/src/tools/clippy/tests/ui/len_zero_ranges.stderr +++ b/src/tools/clippy/tests/ui/len_zero_ranges.stderr @@ -1,5 +1,5 @@ error: length comparison to zero - --> $DIR/len_zero_ranges.rs:7:17 + --> tests/ui/len_zero_ranges.rs:7:17 | LL | let _ = (0..42).len() == 0; | ^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0..42).is_empty()` @@ -8,7 +8,7 @@ LL | let _ = (0..42).len() == 0; = help: to override `-D warnings` add `#[allow(clippy::len_zero)]` error: length comparison to zero - --> $DIR/len_zero_ranges.rs:11:17 + --> tests/ui/len_zero_ranges.rs:11:17 | LL | let _ = (0_u8..=42).len() == 0; | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0_u8..=42).is_empty()` diff --git a/src/tools/clippy/tests/ui/let_and_return.stderr b/src/tools/clippy/tests/ui/let_and_return.stderr index fe60072d13f84..f614a5739a860 100644 --- a/src/tools/clippy/tests/ui/let_and_return.stderr +++ b/src/tools/clippy/tests/ui/let_and_return.stderr @@ -1,5 +1,5 @@ error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:9:5 + --> tests/ui/let_and_return.rs:9:5 | LL | let x = 5; | ---------- unnecessary `let` binding @@ -15,7 +15,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:17:9 + --> tests/ui/let_and_return.rs:17:9 | LL | let x = 5; | ---------- unnecessary `let` binding @@ -29,7 +29,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:80:5 + --> tests/ui/let_and_return.rs:80:5 | LL | let line = stdin.lock().lines().next().unwrap().unwrap(); | --------------------------------------------------------- unnecessary `let` binding @@ -43,7 +43,7 @@ LL ~ stdin.lock().lines().next().unwrap().unwrap() | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:171:13 + --> tests/ui/let_and_return.rs:171:13 | LL | let clone = Arc::clone(&self.foo); | ---------------------------------- unnecessary `let` binding @@ -57,7 +57,7 @@ LL ~ (Arc::clone(&self.foo)) as _ | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:190:13 + --> tests/ui/let_and_return.rs:190:13 | LL | / let result = match self { LL | | E::A(x) => x, diff --git a/src/tools/clippy/tests/ui/let_if_seq.stderr b/src/tools/clippy/tests/ui/let_if_seq.stderr index bfb4bb9d0d2fd..87ad20dc27ee3 100644 --- a/src/tools/clippy/tests/ui/let_if_seq.stderr +++ b/src/tools/clippy/tests/ui/let_if_seq.stderr @@ -1,5 +1,5 @@ error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:66:5 + --> tests/ui/let_if_seq.rs:66:5 | LL | / let mut foo = 0; LL | | @@ -14,7 +14,7 @@ LL | | } = 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 + --> tests/ui/let_if_seq.rs:73:5 | LL | / let mut bar = 0; LL | | @@ -28,7 +28,7 @@ LL | | } = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:83:5 + --> tests/ui/let_if_seq.rs:83:5 | LL | / let quz; LL | | @@ -40,7 +40,7 @@ LL | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:113:5 + --> tests/ui/let_if_seq.rs:113:5 | LL | / let mut baz = 0; LL | | diff --git a/src/tools/clippy/tests/ui/let_underscore_future.stderr b/src/tools/clippy/tests/ui/let_underscore_future.stderr index ef927a8083bcc..66aeb5035394d 100644 --- a/src/tools/clippy/tests/ui/let_underscore_future.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_future.stderr @@ -1,5 +1,5 @@ error: non-binding `let` on a future - --> $DIR/let_underscore_future.rs:14:5 + --> tests/ui/let_underscore_future.rs:14:5 | LL | let _ = some_async_fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = some_async_fn(); = help: to override `-D warnings` add `#[allow(clippy::let_underscore_future)]` error: non-binding `let` on a future - --> $DIR/let_underscore_future.rs:16:5 + --> tests/ui/let_underscore_future.rs:16:5 | LL | let _ = custom(); | ^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = custom(); = help: consider awaiting the future or dropping explicitly with `std::mem::drop` error: non-binding `let` on a future - --> $DIR/let_underscore_future.rs:21:5 + --> tests/ui/let_underscore_future.rs:21:5 | LL | let _ = future; | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/let_underscore_lock.stderr b/src/tools/clippy/tests/ui/let_underscore_lock.stderr index ac6e0978e637b..a38309dd4fab0 100644 --- a/src/tools/clippy/tests/ui/let_underscore_lock.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_lock.stderr @@ -1,5 +1,5 @@ error: non-binding `let` on a synchronization lock - --> $DIR/let_underscore_lock.rs:10:5 + --> tests/ui/let_underscore_lock.rs:10:5 | LL | let _ = p_m.lock(); | ^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = p_m.lock(); = 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 + --> tests/ui/let_underscore_lock.rs:14:5 | LL | let _ = p_m1.lock(); | ^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = p_m1.lock(); = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` error: non-binding `let` on a synchronization lock - --> $DIR/let_underscore_lock.rs:18:5 + --> tests/ui/let_underscore_lock.rs:18:5 | LL | let _ = p_rw.read(); | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = p_rw.read(); = help: consider using an underscore-prefixed named binding or dropping explicitly with `std::mem::drop` error: non-binding `let` on a synchronization lock - --> $DIR/let_underscore_lock.rs:20:5 + --> tests/ui/let_underscore_lock.rs:20:5 | LL | let _ = p_rw.write(); | ^^^^^^^^^^^^^^^^^^^^^ 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 83d0372e668cc..e8785b92b8158 100644 --- a/src/tools/clippy/tests/ui/let_underscore_must_use.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_must_use.stderr @@ -1,5 +1,5 @@ error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:67:5 + --> tests/ui/let_underscore_must_use.rs:67:5 | LL | let _ = f(); | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | let _ = f(); = 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 + --> tests/ui/let_underscore_must_use.rs:69:5 | LL | let _ = g(); | ^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = g(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:72:5 + --> tests/ui/let_underscore_must_use.rs:72:5 | LL | let _ = l(0_u32); | ^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = l(0_u32); = help: consider explicitly using function result error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:77:5 + --> tests/ui/let_underscore_must_use.rs:77:5 | LL | let _ = s.f(); | ^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = s.f(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:79:5 + --> tests/ui/let_underscore_must_use.rs:79:5 | LL | let _ = s.g(); | ^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = s.g(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:83:5 + --> tests/ui/let_underscore_must_use.rs:83:5 | LL | let _ = S::h(); | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = S::h(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:85:5 + --> tests/ui/let_underscore_must_use.rs:85:5 | LL | let _ = S::p(); | ^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = S::p(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:88:5 + --> tests/ui/let_underscore_must_use.rs:88:5 | LL | let _ = S::a(); | ^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = S::a(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:91:5 + --> tests/ui/let_underscore_must_use.rs:91:5 | LL | let _ = if true { Ok(()) } else { Err(()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = if true { Ok(()) } else { Err(()) }; = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> $DIR/let_underscore_must_use.rs:96:5 + --> tests/ui/let_underscore_must_use.rs:96:5 | LL | let _ = a.is_ok(); | ^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _ = a.is_ok(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:99:5 + --> tests/ui/let_underscore_must_use.rs:99:5 | LL | let _ = a.map(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = a.map(|_| ()); = help: consider explicitly using expression value error: non-binding `let` on an expression with `#[must_use]` type - --> $DIR/let_underscore_must_use.rs:102:5 + --> tests/ui/let_underscore_must_use.rs:102:5 | LL | let _ = a; | ^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/let_underscore_untyped.stderr b/src/tools/clippy/tests/ui/let_underscore_untyped.stderr index 0e5647fa1e92c..1dd51e1e59b10 100644 --- a/src/tools/clippy/tests/ui/let_underscore_untyped.stderr +++ b/src/tools/clippy/tests/ui/let_underscore_untyped.stderr @@ -1,11 +1,11 @@ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:51:5 + --> tests/ui/let_underscore_untyped.rs:51:5 | LL | let _ = a(); | ^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:51:10 + --> tests/ui/let_underscore_untyped.rs:51:10 | LL | let _ = a(); | ^ @@ -13,49 +13,49 @@ LL | let _ = a(); = 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 + --> tests/ui/let_underscore_untyped.rs:52:5 | LL | let _ = b(1); | ^^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:52:10 + --> tests/ui/let_underscore_untyped.rs:52:10 | LL | let _ = b(1); | ^ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:54:5 + --> tests/ui/let_underscore_untyped.rs:54:5 | LL | let _ = d(&1); | ^^^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:54:10 + --> tests/ui/let_underscore_untyped.rs:54:10 | LL | let _ = d(&1); | ^ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:55:5 + --> tests/ui/let_underscore_untyped.rs:55:5 | LL | let _ = e(); | ^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:55:10 + --> tests/ui/let_underscore_untyped.rs:55:10 | LL | let _ = e(); | ^ error: non-binding `let` without a type annotation - --> $DIR/let_underscore_untyped.rs:56:5 + --> tests/ui/let_underscore_untyped.rs:56:5 | LL | let _ = f(); | ^^^^^^^^^^^^ | help: consider adding a type annotation - --> $DIR/let_underscore_untyped.rs:56:10 + --> tests/ui/let_underscore_untyped.rs:56:10 | LL | let _ = f(); | ^ diff --git a/src/tools/clippy/tests/ui/let_unit.stderr b/src/tools/clippy/tests/ui/let_unit.stderr index 00a3c439ba06f..0f1f3d7822348 100644 --- a/src/tools/clippy/tests/ui/let_unit.stderr +++ b/src/tools/clippy/tests/ui/let_unit.stderr @@ -1,5 +1,5 @@ error: this let-binding has unit value - --> $DIR/let_unit.rs:12:5 + --> tests/ui/let_unit.rs:12:5 | LL | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `println!("x");` @@ -8,7 +8,7 @@ LL | let _x = println!("x"); = help: to override `-D warnings` add `#[allow(clippy::let_unit_value)]` error: this let-binding has unit value - --> $DIR/let_unit.rs:60:5 + --> tests/ui/let_unit.rs:60:5 | LL | / let _ = v LL | | .into_iter() @@ -31,7 +31,7 @@ LL + .unwrap(); | error: this let-binding has unit value - --> $DIR/let_unit.rs:109:5 + --> tests/ui/let_unit.rs:109:5 | LL | / let x = match Some(0) { LL | | None => f2(1), 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 d4c9ba19c39f5..29ec25a5b2acc 100644 --- a/src/tools/clippy/tests/ui/let_with_type_underscore.stderr +++ b/src/tools/clippy/tests/ui/let_with_type_underscore.stderr @@ -1,11 +1,11 @@ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:15:5 + --> tests/ui/let_with_type_underscore.rs:15:5 | LL | let x: _ = 1; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:15:10 + --> tests/ui/let_with_type_underscore.rs:15:10 | LL | let x: _ = 1; | ^^^ @@ -13,49 +13,49 @@ LL | let x: _ = 1; = 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 + --> tests/ui/let_with_type_underscore.rs:16:5 | LL | let _: _ = 2; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:16:10 + --> tests/ui/let_with_type_underscore.rs:16:10 | LL | let _: _ = 2; | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:17:5 + --> tests/ui/let_with_type_underscore.rs:17:5 | LL | let x: _ = func(); | ^^^^^^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:17:10 + --> tests/ui/let_with_type_underscore.rs:17:10 | LL | let x: _ = func(); | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:18:5 + --> tests/ui/let_with_type_underscore.rs:18:5 | LL | let x: _; | ^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:18:10 + --> tests/ui/let_with_type_underscore.rs:18:10 | LL | let x: _; | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:25:5 + --> tests/ui/let_with_type_underscore.rs:25:5 | LL | let x : _ = 1; | ^^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:25:10 + --> tests/ui/let_with_type_underscore.rs:25:10 | LL | let x : _ = 1; | ^^^^ 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 9833ab16473c8..558c0532be95a 100644 --- a/src/tools/clippy/tests/ui/lines_filter_map_ok.stderr +++ b/src/tools/clippy/tests/ui/lines_filter_map_ok.stderr @@ -1,11 +1,11 @@ error: `filter_map()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:9:31 + --> tests/ui/lines_filter_map_ok.rs:9:31 | LL | BufReader::new(f).lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:9:5 + --> tests/ui/lines_filter_map_ok.rs:9:5 | LL | BufReader::new(f).lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,61 +13,61 @@ LL | BufReader::new(f).lines().filter_map(Result::ok).for_each(|_| ()); = 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 + --> tests/ui/lines_filter_map_ok.rs:12:31 | LL | BufReader::new(f).lines().flat_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:12:5 + --> tests/ui/lines_filter_map_ok.rs:12:5 | LL | BufReader::new(f).lines().flat_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `flatten()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:15:31 + --> tests/ui/lines_filter_map_ok.rs:15:31 | LL | BufReader::new(f).lines().flatten().for_each(|_| ()); | ^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:15:5 + --> tests/ui/lines_filter_map_ok.rs:15:5 | LL | BufReader::new(f).lines().flatten().for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `filter_map()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:19:25 + --> tests/ui/lines_filter_map_ok.rs:19:25 | LL | io::stdin().lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:19:5 + --> tests/ui/lines_filter_map_ok.rs:19:5 | LL | io::stdin().lines().filter_map(Result::ok).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^ error: `filter_map()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:21:25 + --> tests/ui/lines_filter_map_ok.rs:21:25 | LL | io::stdin().lines().filter_map(|x| x.ok()).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:21:5 + --> tests/ui/lines_filter_map_ok.rs:21:5 | LL | io::stdin().lines().filter_map(|x| x.ok()).for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^ error: `flatten()` will run forever if the iterator repeatedly produces an `Err` - --> $DIR/lines_filter_map_ok.rs:23:25 + --> tests/ui/lines_filter_map_ok.rs:23:25 | LL | io::stdin().lines().flatten().for_each(|_| ()); | ^^^^^^^^^ help: replace with: `map_while(Result::ok)` | note: this expression returning a `std::io::Lines` may produce an infinite number of `Err` in case of a read error - --> $DIR/lines_filter_map_ok.rs:23:5 + --> tests/ui/lines_filter_map_ok.rs:23:5 | LL | io::stdin().lines().flatten().for_each(|_| ()); | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/linkedlist.stderr b/src/tools/clippy/tests/ui/linkedlist.stderr index 792af4dd06e8d..d19176c7b0d21 100644 --- a/src/tools/clippy/tests/ui/linkedlist.stderr +++ b/src/tools/clippy/tests/ui/linkedlist.stderr @@ -1,5 +1,5 @@ error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:8:10 + --> tests/ui/linkedlist.rs:8:10 | LL | const C: LinkedList = LinkedList::new(); | ^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | const C: LinkedList = LinkedList::new(); = 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 + --> tests/ui/linkedlist.rs:10:11 | LL | static S: LinkedList = LinkedList::new(); | ^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static S: LinkedList = LinkedList::new(); = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:14:16 + --> tests/ui/linkedlist.rs:14:16 | LL | type Baz = LinkedList; | ^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type Baz = LinkedList; = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:16:15 + --> tests/ui/linkedlist.rs:16:15 | LL | fn foo(_: LinkedList); | ^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | fn foo(_: LinkedList); = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:18:23 + --> tests/ui/linkedlist.rs:18:23 | LL | const BAR: Option>; | ^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | const BAR: Option>; = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:29:29 + --> tests/ui/linkedlist.rs:29:29 | LL | priv_linked_list_field: LinkedList, | ^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | priv_linked_list_field: LinkedList, = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:34:15 + --> tests/ui/linkedlist.rs:34:15 | LL | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn foo(_: LinkedList) {} = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:40:34 + --> tests/ui/linkedlist.rs:40:34 | LL | fn test(my_favorite_linked_list: LinkedList) {} | ^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn test(my_favorite_linked_list: LinkedList) {} = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> $DIR/linkedlist.rs:42:25 + --> tests/ui/linkedlist.rs:42:25 | LL | fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/literals.stderr b/src/tools/clippy/tests/ui/literals.stderr index bc755b1123db3..564e0bc4f7472 100644 --- a/src/tools/clippy/tests/ui/literals.stderr +++ b/src/tools/clippy/tests/ui/literals.stderr @@ -1,5 +1,5 @@ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:13:15 + --> tests/ui/literals.rs:13:15 | LL | let ok4 = 0xab_cd_i32; | ^^^^^^^^^^^ help: remove the underscore: `0xab_cdi32` @@ -8,19 +8,19 @@ LL | let ok4 = 0xab_cd_i32; = 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 + --> tests/ui/literals.rs:16:15 | LL | let ok5 = 0xAB_CD_u32; | ^^^^^^^^^^^ help: remove the underscore: `0xAB_CDu32` error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:18:15 + --> tests/ui/literals.rs:18:15 | LL | let ok5 = 0xAB_CD_isize; | ^^^^^^^^^^^^^ help: remove the underscore: `0xAB_CDisize` error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:20:17 + --> tests/ui/literals.rs:20:17 | LL | let fail1 = 0xabCD; | ^^^^^^ @@ -29,31 +29,31 @@ LL | let fail1 = 0xabCD; = 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 + --> tests/ui/literals.rs:23:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ help: remove the underscore: `0xabCDu32` error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:23:17 + --> tests/ui/literals.rs:23:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:26:17 + --> tests/ui/literals.rs:26:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ help: remove the underscore: `0xabCDisize` error: inconsistent casing in hexadecimal literal - --> $DIR/literals.rs:26:17 + --> tests/ui/literals.rs:26:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ error: integer type suffix should be separated by an underscore - --> $DIR/literals.rs:29:27 + --> tests/ui/literals.rs:29:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ help: add an underscore: `000_123_usize` @@ -62,7 +62,7 @@ LL | let fail_multi_zero = 000_123usize; = help: to override `-D warnings` add `#[allow(clippy::unseparated_literal_suffix)]` error: this is a decimal constant - --> $DIR/literals.rs:29:27 + --> tests/ui/literals.rs:29:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ @@ -79,13 +79,13 @@ LL | let fail_multi_zero = 0o123usize; | ~~~~~~~~~~ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:36:16 + --> tests/ui/literals.rs:36:16 | LL | let ok10 = 0_i64; | ^^^^^ help: remove the underscore: `0i64` error: this is a decimal constant - --> $DIR/literals.rs:38:17 + --> tests/ui/literals.rs:38:17 | LL | let fail8 = 0123; | ^^^^ @@ -100,13 +100,13 @@ LL | let fail8 = 0o123; | ~~~~~ error: integer type suffix should not be separated by an underscore - --> $DIR/literals.rs:48:16 + --> tests/ui/literals.rs:48:16 | LL | let ok17 = 0x123_4567_8901_usize; | ^^^^^^^^^^^^^^^^^^^^^ help: remove the underscore: `0x123_4567_8901usize` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:52:18 + --> tests/ui/literals.rs:52:18 | LL | let fail19 = 12_3456_21; | ^^^^^^^^^^ help: consider: `12_345_621` @@ -115,19 +115,19 @@ LL | let fail19 = 12_3456_21; = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:55:18 + --> tests/ui/literals.rs:55:18 | LL | let fail22 = 3__4___23; | ^^^^^^^^^ help: consider: `3_423` error: digits grouped inconsistently by underscores - --> $DIR/literals.rs:57:18 + --> tests/ui/literals.rs:57:18 | LL | let fail23 = 3__16___23; | ^^^^^^^^^^ help: consider: `31_623` error: digits of hex, binary or octal literal not in groups of equal size - --> $DIR/literals.rs:60:18 + --> tests/ui/literals.rs:60:18 | LL | let fail24 = 0xAB_ABC_AB; | ^^^^^^^^^^^ help: consider: `0x0ABA_BCAB` @@ -136,7 +136,7 @@ LL | let fail24 = 0xAB_ABC_AB; = help: to override `-D warnings` add `#[allow(clippy::unusual_byte_groupings)]` error: this is a decimal constant - --> $DIR/literals.rs:70:13 + --> tests/ui/literals.rs:70:13 | LL | let _ = 08; | ^^ @@ -147,7 +147,7 @@ LL | let _ = 8; | ~ error: this is a decimal constant - --> $DIR/literals.rs:72:13 + --> tests/ui/literals.rs:72:13 | LL | let _ = 09; | ^^ @@ -158,7 +158,7 @@ LL | let _ = 9; | ~ error: this is a decimal constant - --> $DIR/literals.rs:74:13 + --> tests/ui/literals.rs:74:13 | LL | let _ = 089; | ^^^ diff --git a/src/tools/clippy/tests/ui/lossy_float_literal.stderr b/src/tools/clippy/tests/ui/lossy_float_literal.stderr index ea787f5726aaf..7904719141c18 100644 --- a/src/tools/clippy/tests/ui/lossy_float_literal.stderr +++ b/src/tools/clippy/tests/ui/lossy_float_literal.stderr @@ -1,5 +1,5 @@ error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:6:18 + --> tests/ui/lossy_float_literal.rs:6:18 | LL | let _: f32 = 16_777_217.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_216.0` @@ -8,61 +8,61 @@ LL | let _: f32 = 16_777_217.0; = 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 + --> tests/ui/lossy_float_literal.rs:7:18 | LL | let _: f32 = 16_777_219.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:8:18 + --> tests/ui/lossy_float_literal.rs:8:18 | LL | let _: f32 = 16_777_219.; | ^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:9:18 + --> tests/ui/lossy_float_literal.rs:9:18 | LL | let _: f32 = 16_777_219.000; | ^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:10:13 + --> tests/ui/lossy_float_literal.rs:10:13 | LL | let _ = 16_777_219f32; | ^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220_f32` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:11:19 + --> tests/ui/lossy_float_literal.rs:11:19 | LL | let _: f32 = -16_777_219.0; | ^^^^^^^^^^^^ help: consider changing the type or replacing it with: `16_777_220.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:12:18 + --> tests/ui/lossy_float_literal.rs:12:18 | LL | let _: f64 = 9_007_199_254_740_993.0; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:13:18 + --> tests/ui/lossy_float_literal.rs:13:18 | LL | let _: f64 = 9_007_199_254_740_993.; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:14:18 + --> tests/ui/lossy_float_literal.rs:14:18 | LL | let _: f64 = 9_007_199_254_740_993.00; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:15:13 + --> tests/ui/lossy_float_literal.rs:15:13 | LL | let _ = 9_007_199_254_740_993f64; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992_f64` error: literal cannot be represented as the underlying type without loss of precision - --> $DIR/lossy_float_literal.rs:16:19 + --> tests/ui/lossy_float_literal.rs:16:19 | LL | let _: f64 = -9_007_199_254_740_993.0; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or replacing it with: `9_007_199_254_740_992.0` diff --git a/src/tools/clippy/tests/ui/macro_use_imports.stderr b/src/tools/clippy/tests/ui/macro_use_imports.stderr index 5524e7e5642df..a3733b1c0c96c 100644 --- a/src/tools/clippy/tests/ui/macro_use_imports.stderr +++ b/src/tools/clippy/tests/ui/macro_use_imports.stderr @@ -1,5 +1,5 @@ error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:19:5 + --> tests/ui/macro_use_imports.rs:19:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};` @@ -8,19 +8,19 @@ LL | #[macro_use] = 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 + --> tests/ui/macro_use_imports.rs:23:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::mut_mut, inner::try_err};` error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:25:5 + --> tests/ui/macro_use_imports.rs:25:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;` error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:21:5 + --> tests/ui/macro_use_imports.rs:21:5 | LL | #[macro_use] | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;` diff --git a/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr b/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr index b19cca4d5f91d..57015933d40a9 100644 --- a/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr +++ b/src/tools/clippy/tests/ui/manual_assert.edition2018.stderr @@ -1,5 +1,5 @@ error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:30:5 + --> tests/ui/manual_assert.rs:30:5 | LL | / if !a.is_empty() { LL | | panic!("qaqaq{:?}", a); @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_assert)]` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:33:5 + --> tests/ui/manual_assert.rs:33:5 | LL | / if !a.is_empty() { LL | | panic!("qwqwq"); @@ -18,7 +18,7 @@ LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:50:5 + --> tests/ui/manual_assert.rs:50:5 | LL | / if b.is_empty() { LL | | panic!("panic1"); @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:53:5 + --> tests/ui/manual_assert.rs:53:5 | LL | / if b.is_empty() && a.is_empty() { LL | | panic!("panic2"); @@ -34,7 +34,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:56:5 + --> tests/ui/manual_assert.rs:56:5 | LL | / if a.is_empty() && !b.is_empty() { LL | | panic!("panic3"); @@ -42,7 +42,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:59:5 + --> tests/ui/manual_assert.rs:59:5 | LL | / if b.is_empty() || a.is_empty() { LL | | panic!("panic4"); @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:62:5 + --> tests/ui/manual_assert.rs:62:5 | LL | / if a.is_empty() || !b.is_empty() { LL | | panic!("panic5"); @@ -58,7 +58,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:65:5 + --> tests/ui/manual_assert.rs:65:5 | LL | / if a.is_empty() { LL | | panic!("with expansion {}", one!()) @@ -66,7 +66,7 @@ LL | | } | |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:77:5 + --> tests/ui/manual_assert.rs:77:5 | LL | / if a > 2 { LL | | // comment diff --git a/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr b/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr index b19cca4d5f91d..57015933d40a9 100644 --- a/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr +++ b/src/tools/clippy/tests/ui/manual_assert.edition2021.stderr @@ -1,5 +1,5 @@ error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:30:5 + --> tests/ui/manual_assert.rs:30:5 | LL | / if !a.is_empty() { LL | | panic!("qaqaq{:?}", a); @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_assert)]` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:33:5 + --> tests/ui/manual_assert.rs:33:5 | LL | / if !a.is_empty() { LL | | panic!("qwqwq"); @@ -18,7 +18,7 @@ LL | | } | |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:50:5 + --> tests/ui/manual_assert.rs:50:5 | LL | / if b.is_empty() { LL | | panic!("panic1"); @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:53:5 + --> tests/ui/manual_assert.rs:53:5 | LL | / if b.is_empty() && a.is_empty() { LL | | panic!("panic2"); @@ -34,7 +34,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:56:5 + --> tests/ui/manual_assert.rs:56:5 | LL | / if a.is_empty() && !b.is_empty() { LL | | panic!("panic3"); @@ -42,7 +42,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:59:5 + --> tests/ui/manual_assert.rs:59:5 | LL | / if b.is_empty() || a.is_empty() { LL | | panic!("panic4"); @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:62:5 + --> tests/ui/manual_assert.rs:62:5 | LL | / if a.is_empty() || !b.is_empty() { LL | | panic!("panic5"); @@ -58,7 +58,7 @@ LL | | } | |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:65:5 + --> tests/ui/manual_assert.rs:65:5 | LL | / if a.is_empty() { LL | | panic!("with expansion {}", one!()) @@ -66,7 +66,7 @@ LL | | } | |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());` error: only a `panic!` in `if`-then statement - --> $DIR/manual_assert.rs:77:5 + --> tests/ui/manual_assert.rs:77:5 | LL | / if a > 2 { LL | | // comment diff --git a/src/tools/clippy/tests/ui/manual_async_fn.stderr b/src/tools/clippy/tests/ui/manual_async_fn.stderr index c0c471912e494..c50af5a49883a 100644 --- a/src/tools/clippy/tests/ui/manual_async_fn.stderr +++ b/src/tools/clippy/tests/ui/manual_async_fn.stderr @@ -1,5 +1,5 @@ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:6:1 + --> tests/ui/manual_async_fn.rs:6:1 | LL | fn fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | fn fut() -> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:11:1 + --> tests/ui/manual_async_fn.rs:11:1 | LL | fn fut2() ->impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | fn fut2() ->impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:16:1 + --> tests/ui/manual_async_fn.rs:16:1 | LL | fn fut3()-> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | fn fut3()-> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:20:1 + --> tests/ui/manual_async_fn.rs:20:1 | LL | fn empty_fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | fn empty_fut() -> impl Future {} | ~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:25:1 + --> tests/ui/manual_async_fn.rs:25:1 | LL | fn empty_fut2() ->impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | fn empty_fut2() ->impl Future {} | ~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:30:1 + --> tests/ui/manual_async_fn.rs:30:1 | LL | fn empty_fut3()-> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | fn empty_fut3()-> impl Future {} | ~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:34:1 + --> tests/ui/manual_async_fn.rs:34:1 | LL | fn core_fut() -> impl core::future::Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | fn core_fut() -> impl core::future::Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:56:5 + --> tests/ui/manual_async_fn.rs:56:5 | LL | fn inh_fut() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + } | error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:91:1 + --> tests/ui/manual_async_fn.rs:91:1 | LL | fn elided(_: &i32) -> impl Future + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +148,7 @@ LL | fn elided(_: &i32) -> impl Future + '_ { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:100:1 + --> tests/ui/manual_async_fn.rs:100:1 | LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future + 'a + 'b { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future + | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:129:1 + --> tests/ui/manual_async_fn.rs:129:1 | LL | pub fn issue_10450() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +178,7 @@ LL | pub fn issue_10450() -> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:133:1 + --> tests/ui/manual_async_fn.rs:133:1 | LL | pub(crate) fn issue_10450_2() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | pub(crate) fn issue_10450_2() -> impl Future { 42 } | ~~~~~~ error: this function can be simplified using the `async fn` syntax - --> $DIR/manual_async_fn.rs:137:1 + --> tests/ui/manual_async_fn.rs:137:1 | LL | pub(self) fn issue_10450_3() -> impl Future { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/manual_bits.stderr b/src/tools/clippy/tests/ui/manual_bits.stderr index 2f2ed5909c1a5..4383aa49df9b4 100644 --- a/src/tools/clippy/tests/ui/manual_bits.stderr +++ b/src/tools/clippy/tests/ui/manual_bits.stderr @@ -1,5 +1,5 @@ error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:14:5 + --> tests/ui/manual_bits.rs:14:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` @@ -8,169 +8,169 @@ LL | size_of::() * 8; = 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 + --> tests/ui/manual_bits.rs:15:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:16:5 + --> tests/ui/manual_bits.rs:16:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:17:5 + --> tests/ui/manual_bits.rs:17:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:18:5 + --> tests/ui/manual_bits.rs:18:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `i128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:19:5 + --> tests/ui/manual_bits.rs:19:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `isize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:21:5 + --> tests/ui/manual_bits.rs:21:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `u8::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:22:5 + --> tests/ui/manual_bits.rs:22:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:23:5 + --> tests/ui/manual_bits.rs:23:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:24:5 + --> tests/ui/manual_bits.rs:24:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:25:5 + --> tests/ui/manual_bits.rs:25:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:26:5 + --> tests/ui/manual_bits.rs:26:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `usize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:28:5 + --> tests/ui/manual_bits.rs:28:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `i8::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:29:5 + --> tests/ui/manual_bits.rs:29:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:30:5 + --> tests/ui/manual_bits.rs:30:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:31:5 + --> tests/ui/manual_bits.rs:31:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `i64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:32:5 + --> tests/ui/manual_bits.rs:32:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `i128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:33:5 + --> tests/ui/manual_bits.rs:33:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `isize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:35:5 + --> tests/ui/manual_bits.rs:35:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `u8::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:36:5 + --> tests/ui/manual_bits.rs:36:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u16::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:37:5 + --> tests/ui/manual_bits.rs:37:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u32::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:38:5 + --> tests/ui/manual_bits.rs:38:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `u64::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:39:5 + --> tests/ui/manual_bits.rs:39:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:40:5 + --> tests/ui/manual_bits.rs:40:5 | LL | 8 * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `usize::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:50:5 + --> tests/ui/manual_bits.rs:50:5 | LL | size_of::() * 8; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `Word::BITS as usize` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:54:18 + --> tests/ui/manual_bits.rs:54:18 | LL | let _: u32 = (size_of::() * 8) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:55:18 + --> tests/ui/manual_bits.rs:55:18 | LL | let _: u32 = (size_of::() * 8).try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `u128::BITS` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:56:13 + --> tests/ui/manual_bits.rs:56:13 | LL | let _ = (size_of::() * 8).pow(5); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(u128::BITS as usize)` error: usage of `mem::size_of::()` to obtain the size of `T` in bits - --> $DIR/manual_bits.rs:57:14 + --> tests/ui/manual_bits.rs:57:14 | LL | let _ = &(size_of::() * 8); | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(u128::BITS as usize)` diff --git a/src/tools/clippy/tests/ui/manual_c_str_literals.stderr b/src/tools/clippy/tests/ui/manual_c_str_literals.stderr index 8de4e16f010d6..9c70bddb81c18 100644 --- a/src/tools/clippy/tests/ui/manual_c_str_literals.stderr +++ b/src/tools/clippy/tests/ui/manual_c_str_literals.stderr @@ -1,5 +1,5 @@ error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:31:5 + --> tests/ui/manual_c_str_literals.rs:31:5 | LL | CStr::from_bytes_with_nul(b"foo\0"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` @@ -8,73 +8,73 @@ LL | CStr::from_bytes_with_nul(b"foo\0"); = help: to override `-D warnings` add `#[allow(clippy::manual_c_str_literals)]` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:35:5 + --> tests/ui/manual_c_str_literals.rs:35:5 | LL | CStr::from_bytes_with_nul(b"foo\0"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:36:5 + --> tests/ui/manual_c_str_literals.rs:36:5 | LL | CStr::from_bytes_with_nul(b"foo\x00"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:37:5 + --> tests/ui/manual_c_str_literals.rs:37:5 | LL | CStr::from_bytes_with_nul(b"foo\0").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::new` with a byte string literal - --> $DIR/manual_c_str_literals.rs:38:5 + --> tests/ui/manual_c_str_literals.rs:38:5 | LL | CStr::from_bytes_with_nul(b"foo\\0sdsd\0").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo\\0sdsd"` error: calling `CStr::from_ptr` with a byte string literal - --> $DIR/manual_c_str_literals.rs:43:14 + --> tests/ui/manual_c_str_literals.rs:43:14 | LL | unsafe { CStr::from_ptr(b"foo\0".as_ptr().cast()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: calling `CStr::from_ptr` with a byte string literal - --> $DIR/manual_c_str_literals.rs:44:14 + --> tests/ui/manual_c_str_literals.rs:44:14 | LL | unsafe { CStr::from_ptr(b"foo\0".as_ptr() as *const _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:45:23 + --> tests/ui/manual_c_str_literals.rs:45:23 | LL | let _: *const _ = b"foo\0".as_ptr(); | ^^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:46:23 + --> tests/ui/manual_c_str_literals.rs:46:23 | LL | let _: *const _ = "foo\0".as_ptr(); | ^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:49:23 + --> tests/ui/manual_c_str_literals.rs:49:23 | LL | let _: *const _ = b"foo\0".as_ptr().cast::(); | ^^^^^^^^ help: use a `c""` literal: `c"foo"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:52:13 + --> tests/ui/manual_c_str_literals.rs:52:13 | LL | let _ = "电脑\\\0".as_ptr(); | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑\\"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:53:13 + --> tests/ui/manual_c_str_literals.rs:53:13 | LL | let _ = "电脑\0".as_ptr(); | ^^^^^^^^ help: use a `c""` literal: `c"电脑"` error: manually constructing a nul-terminated string - --> $DIR/manual_c_str_literals.rs:54:13 + --> tests/ui/manual_c_str_literals.rs:54:13 | LL | let _ = "电脑\x00".as_ptr(); | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑"` diff --git a/src/tools/clippy/tests/ui/manual_clamp.stderr b/src/tools/clippy/tests/ui/manual_clamp.stderr index 2fa68ede12614..52c816f2b347b 100644 --- a/src/tools/clippy/tests/ui/manual_clamp.stderr +++ b/src/tools/clippy/tests/ui/manual_clamp.stderr @@ -1,5 +1,5 @@ error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:94:5 + --> tests/ui/manual_clamp.rs:94:5 | LL | / if x9 < min { LL | | @@ -15,7 +15,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_clamp)]` error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:113:5 + --> tests/ui/manual_clamp.rs:113:5 | LL | / if x11 > max { LL | | @@ -29,7 +29,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:123:5 + --> tests/ui/manual_clamp.rs:123:5 | LL | / if min > x12 { LL | | @@ -43,7 +43,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:133:5 + --> tests/ui/manual_clamp.rs:133:5 | LL | / if max < x13 { LL | | @@ -57,7 +57,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:227:5 + --> tests/ui/manual_clamp.rs:227:5 | LL | / if max < x33 { LL | | @@ -71,7 +71,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:21:14 + --> tests/ui/manual_clamp.rs:21:14 | LL | let x0 = if max < input { | ______________^ @@ -86,7 +86,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:31:14 + --> tests/ui/manual_clamp.rs:31:14 | LL | let x1 = if input > max { | ______________^ @@ -101,7 +101,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:41:14 + --> tests/ui/manual_clamp.rs:41:14 | LL | let x2 = if input < min { | ______________^ @@ -116,7 +116,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:51:14 + --> tests/ui/manual_clamp.rs:51:14 | LL | let x3 = if min > input { | ______________^ @@ -131,7 +131,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:61:14 + --> tests/ui/manual_clamp.rs:61:14 | LL | let x4 = input.max(min).min(max); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)` @@ -139,7 +139,7 @@ LL | let x4 = input.max(min).min(max); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:65:14 + --> tests/ui/manual_clamp.rs:65:14 | LL | let x5 = input.min(max).max(min); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)` @@ -147,7 +147,7 @@ LL | let x5 = input.min(max).max(min); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:69:14 + --> tests/ui/manual_clamp.rs:69:14 | LL | let x6 = match input { | ______________^ @@ -162,7 +162,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:77:14 + --> tests/ui/manual_clamp.rs:77:14 | LL | let x7 = match input { | ______________^ @@ -177,7 +177,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:85:14 + --> tests/ui/manual_clamp.rs:85:14 | LL | let x8 = match input { | ______________^ @@ -192,7 +192,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:103:15 + --> tests/ui/manual_clamp.rs:103:15 | LL | let x10 = match input { | _______________^ @@ -207,7 +207,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:142:15 + --> tests/ui/manual_clamp.rs:142:15 | LL | let x14 = if input > CONST_MAX { | _______________^ @@ -222,7 +222,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:153:19 + --> tests/ui/manual_clamp.rs:153:19 | LL | let x15 = if input > max { | ___________________^ @@ -238,7 +238,7 @@ LL | | }; = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:166:19 + --> tests/ui/manual_clamp.rs:166:19 | LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -246,7 +246,7 @@ LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:169:19 + --> tests/ui/manual_clamp.rs:169:19 | LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -254,7 +254,7 @@ LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:172:19 + --> tests/ui/manual_clamp.rs:172:19 | LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -262,7 +262,7 @@ LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:175:19 + --> tests/ui/manual_clamp.rs:175:19 | LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -270,7 +270,7 @@ LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:178:19 + --> tests/ui/manual_clamp.rs:178:19 | LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -278,7 +278,7 @@ LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:181:19 + --> tests/ui/manual_clamp.rs:181:19 | LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -286,7 +286,7 @@ LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:184:19 + --> tests/ui/manual_clamp.rs:184:19 | LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -294,7 +294,7 @@ LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:187:19 + --> tests/ui/manual_clamp.rs:187:19 | LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -302,7 +302,7 @@ LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:191:19 + --> tests/ui/manual_clamp.rs:191:19 | LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -311,7 +311,7 @@ LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:194:19 + --> tests/ui/manual_clamp.rs:194:19 | LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -320,7 +320,7 @@ LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:197:19 + --> tests/ui/manual_clamp.rs:197:19 | LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -329,7 +329,7 @@ LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:200:19 + --> tests/ui/manual_clamp.rs:200:19 | LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -338,7 +338,7 @@ LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:203:19 + --> tests/ui/manual_clamp.rs:203:19 | LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -347,7 +347,7 @@ LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:206:19 + --> tests/ui/manual_clamp.rs:206:19 | LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -356,7 +356,7 @@ LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:209:19 + --> tests/ui/manual_clamp.rs:209:19 | LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -365,7 +365,7 @@ LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:212:19 + --> tests/ui/manual_clamp.rs:212:19 | LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -374,7 +374,7 @@ LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:217:5 + --> tests/ui/manual_clamp.rs:217:5 | LL | / if x32 < min { LL | | @@ -388,7 +388,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:389:13 + --> tests/ui/manual_clamp.rs:389:13 | LL | let _ = if input < min { | _____________^ diff --git a/src/tools/clippy/tests/ui/manual_filter.stderr b/src/tools/clippy/tests/ui/manual_filter.stderr index b23ad887eb2c5..3add706d7f73c 100644 --- a/src/tools/clippy/tests/ui/manual_filter.stderr +++ b/src/tools/clippy/tests/ui/manual_filter.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:5:5 + --> tests/ui/manual_filter.rs:5:5 | LL | / match Some(0) { LL | | None => None, @@ -14,7 +14,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_filter)]` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:16:5 + --> tests/ui/manual_filter.rs:16:5 | LL | / match Some(1) { LL | | Some(x) => { @@ -26,7 +26,7 @@ LL | | }; | |_____^ help: try: `Some(1).filter(|&x| x <= 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:27:5 + --> tests/ui/manual_filter.rs:27:5 | LL | / match Some(2) { LL | | Some(x) => { @@ -38,7 +38,7 @@ LL | | }; | |_____^ help: try: `Some(2).filter(|&x| x <= 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:38:5 + --> tests/ui/manual_filter.rs:38:5 | LL | / match Some(3) { LL | | Some(x) => { @@ -50,7 +50,7 @@ LL | | }; | |_____^ help: try: `Some(3).filter(|&x| x > 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:50:5 + --> tests/ui/manual_filter.rs:50:5 | LL | / match y { LL | | // Some(4) @@ -62,7 +62,7 @@ LL | | }; | |_____^ help: try: `y.filter(|&x| x <= 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:62:5 + --> tests/ui/manual_filter.rs:62:5 | LL | / match Some(5) { LL | | Some(x) => { @@ -74,7 +74,7 @@ LL | | }; | |_____^ help: try: `Some(5).filter(|&x| x > 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:73:5 + --> tests/ui/manual_filter.rs:73:5 | LL | / match Some(6) { LL | | Some(ref x) => { @@ -86,7 +86,7 @@ LL | | }; | |_____^ help: try: `Some(6).as_ref().filter(|&x| x > &0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:85:5 + --> tests/ui/manual_filter.rs:85:5 | LL | / match Some(String::new()) { LL | | Some(x) => { @@ -98,7 +98,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).filter(|x| external_cond)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:96:5 + --> tests/ui/manual_filter.rs:96:5 | LL | / if let Some(x) = Some(7) { LL | | if external_cond { Some(x) } else { None } @@ -108,7 +108,7 @@ LL | | }; | |_____^ help: try: `Some(7).filter(|&x| external_cond)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:102:5 + --> tests/ui/manual_filter.rs:102:5 | LL | / match &Some(8) { LL | | &Some(x) => { @@ -120,7 +120,7 @@ LL | | }; | |_____^ help: try: `Some(8).filter(|&x| x != 0)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:113:5 + --> tests/ui/manual_filter.rs:113:5 | LL | / match Some(9) { LL | | Some(x) => { @@ -132,7 +132,7 @@ LL | | }; | |_____^ help: try: `Some(9).filter(|&x| x > 10 && x < 100)` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:139:5 + --> tests/ui/manual_filter.rs:139:5 | LL | / match Some(11) { LL | | // Lint, statement is preserved by `.filter` @@ -152,7 +152,7 @@ LL ~ }); | error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:183:13 + --> tests/ui/manual_filter.rs:183:13 | LL | let _ = match Some(14) { | _____________^ @@ -165,7 +165,7 @@ LL | | }; | |_____^ help: try: `Some(14).filter(|&x| unsafe { f(x) })` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:193:13 + --> tests/ui/manual_filter.rs:193:13 | LL | let _ = match Some(15) { | _____________^ @@ -175,7 +175,7 @@ LL | | }; | |_____^ help: try: `Some(15).filter(|&x| unsafe { f(x) })` error: manual implementation of `Option::filter` - --> $DIR/manual_filter.rs:201:12 + --> tests/ui/manual_filter.rs:201:12 | LL | } else if let Some(x) = Some(16) { | ____________^ diff --git a/src/tools/clippy/tests/ui/manual_filter_map.stderr b/src/tools/clippy/tests/ui/manual_filter_map.stderr index cf64bb25951a3..2e50567278319 100644 --- a/src/tools/clippy/tests/ui/manual_filter_map.stderr +++ b/src/tools/clippy/tests/ui/manual_filter_map.stderr @@ -1,11 +1,11 @@ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:9:19 + --> tests/ui/manual_filter_map.rs:9:19 | LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:9:30 + --> tests/ui/manual_filter_map.rs:9:30 | LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^ @@ -13,31 +13,31 @@ LL | let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap = 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:12:19 + --> tests/ui/manual_filter_map.rs:12:19 | LL | let _ = (0..).filter(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:12:31 + --> tests/ui/manual_filter_map.rs:12:31 | LL | let _ = (0..).filter(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:15:19 + --> tests/ui/manual_filter_map.rs:15:19 | LL | let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_res(a).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:15:31 + --> tests/ui/manual_filter_map.rs:15:31 | LL | let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:18:10 + --> tests/ui/manual_filter_map.rs:18:10 | LL | .filter(|&x| to_ref(to_opt(x)).is_some()) | __________^ @@ -45,13 +45,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:18:22 + --> tests/ui/manual_filter_map.rs:18:22 | LL | .filter(|&x| to_ref(to_opt(x)).is_some()) | ^^^^^^^^^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:21:10 + --> tests/ui/manual_filter_map.rs:21:10 | LL | .filter(|x| to_ref(to_opt(*x)).is_some()) | __________^ @@ -59,13 +59,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:21:21 + --> tests/ui/manual_filter_map.rs:21:21 | LL | .filter(|x| to_ref(to_opt(*x)).is_some()) | ^^^^^^^^^^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:25:10 + --> tests/ui/manual_filter_map.rs:25:10 | LL | .filter(|&x| to_ref(to_res(x)).is_ok()) | __________^ @@ -73,13 +73,13 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:25:22 + --> tests/ui/manual_filter_map.rs:25:22 | LL | .filter(|&x| to_ref(to_res(x)).is_ok()) | ^^^^^^^^^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:28:10 + --> tests/ui/manual_filter_map.rs:28:10 | LL | .filter(|x| to_ref(to_res(*x)).is_ok()) | __________^ @@ -87,13 +87,13 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `filter_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:28:21 + --> tests/ui/manual_filter_map.rs:28:21 | LL | .filter(|x| to_ref(to_res(*x)).is_ok()) | ^^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:34:27 + --> tests/ui/manual_filter_map.rs:34:27 | LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` @@ -102,79 +102,79 @@ LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap() = 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:35:28 + --> tests/ui/manual_filter_map.rs:35:28 | LL | iter::<&Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:36:31 + --> tests/ui/manual_filter_map.rs:36:31 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:37:31 + --> tests/ui/manual_filter_map.rs:37:31 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:37:41 + --> tests/ui/manual_filter_map.rs:37:41 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:39:30 + --> tests/ui/manual_filter_map.rs:39:30 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:40:31 + --> tests/ui/manual_filter_map.rs:40:31 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:41:32 + --> tests/ui/manual_filter_map.rs:41:32 | LL | iter::<&&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:42:31 + --> tests/ui/manual_filter_map.rs:42:31 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:43:32 + --> tests/ui/manual_filter_map.rs:43:32 | LL | iter::<&Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:44:35 + --> tests/ui/manual_filter_map.rs:44:35 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_filter_map.rs:45:35 + --> tests/ui/manual_filter_map.rs:45:35 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned().ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_filter_map.rs:45:45 + --> tests/ui/manual_filter_map.rs:45:45 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:93:10 + --> tests/ui/manual_filter_map.rs:93:10 | LL | .filter(|f| f.option_field.is_some()) | __________^ @@ -182,7 +182,7 @@ LL | | .map(|f| f.option_field.clone().unwrap()); | |_________________________________________________^ help: try: `filter_map(|f| f.option_field.clone())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:98:10 + --> tests/ui/manual_filter_map.rs:98:10 | LL | .filter(|f| f.ref_field.is_some()) | __________^ @@ -190,7 +190,7 @@ LL | | .map(|f| f.ref_field.cloned().unwrap()); | |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.cloned())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:103:10 + --> tests/ui/manual_filter_map.rs:103:10 | LL | .filter(|f| f.ref_field.is_some()) | __________^ @@ -198,7 +198,7 @@ LL | | .map(|f| f.ref_field.copied().unwrap()); | |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.copied())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:108:10 + --> tests/ui/manual_filter_map.rs:108:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -206,7 +206,7 @@ LL | | .map(|f| f.result_field.clone().unwrap()); | |_________________________________________________^ help: try: `filter_map(|f| f.result_field.clone().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:113:10 + --> tests/ui/manual_filter_map.rs:113:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -214,7 +214,7 @@ LL | | .map(|f| f.result_field.as_ref().unwrap()); | |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_ref().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:118:10 + --> tests/ui/manual_filter_map.rs:118:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -222,7 +222,7 @@ LL | | .map(|f| f.result_field.as_deref().unwrap()); | |____________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:123:10 + --> tests/ui/manual_filter_map.rs:123:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -230,7 +230,7 @@ LL | | .map(|f| f.result_field.as_mut().unwrap()); | |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_mut().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:128:10 + --> tests/ui/manual_filter_map.rs:128:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -238,7 +238,7 @@ LL | | .map(|f| f.result_field.as_deref_mut().unwrap()); | |________________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref_mut().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:133:10 + --> tests/ui/manual_filter_map.rs:133:10 | LL | .filter(|f| f.result_field.is_ok()) | __________^ @@ -246,7 +246,7 @@ LL | | .map(|f| f.result_field.to_owned().unwrap()); | |____________________________________________________^ help: try: `filter_map(|f| f.result_field.to_owned().ok())` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:146:27 + --> tests/ui/manual_filter_map.rs:146:27 | LL | let _x = iter.clone().filter(|x| matches!(x, Enum::A(_))).map(|x| match x { | ___________________________^ @@ -256,7 +256,7 @@ LL | | }); | |______^ help: try: `filter_map(|x| match x { Enum::A(s) => Some(s), _ => None })` error: `filter(..).map(..)` can be simplified as `filter_map(..)` - --> $DIR/manual_filter_map.rs:156:10 + --> tests/ui/manual_filter_map.rs:156:10 | LL | .filter(|x| matches!(x, Enum::A(_))) | __________^ diff --git a/src/tools/clippy/tests/ui/manual_find.stderr b/src/tools/clippy/tests/ui/manual_find.stderr index 286ad54625d7d..eb55a0c11f244 100644 --- a/src/tools/clippy/tests/ui/manual_find.stderr +++ b/src/tools/clippy/tests/ui/manual_find.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Iterator::find` - --> $DIR/manual_find.rs:5:5 + --> tests/ui/manual_find.rs:5:5 | LL | / for s in strings { LL | | @@ -15,7 +15,7 @@ LL | | None = help: to override `-D warnings` add `#[allow(clippy::manual_find)]` error: manual implementation of `Iterator::find` - --> $DIR/manual_find.rs:16:5 + --> tests/ui/manual_find.rs:16:5 | LL | / for (s, _) in arr { LL | | diff --git a/src/tools/clippy/tests/ui/manual_find_fixable.stderr b/src/tools/clippy/tests/ui/manual_find_fixable.stderr index 387d1509c136c..c3f48fb9f98a3 100644 --- a/src/tools/clippy/tests/ui/manual_find_fixable.stderr +++ b/src/tools/clippy/tests/ui/manual_find_fixable.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:10:5 + --> tests/ui/manual_find_fixable.rs:10:5 | LL | / for &v in ARRAY { LL | | if v == n { @@ -13,7 +13,7 @@ LL | | None = help: to override `-D warnings` add `#[allow(clippy::manual_find)]` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:19:5 + --> tests/ui/manual_find_fixable.rs:19:5 | LL | / for (a, _) in arr { LL | | if a % 2 == 0 { @@ -24,7 +24,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|(a, _)| a).find(|&a| a % 2 == 0)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:32:5 + --> tests/ui/manual_find_fixable.rs:32:5 | LL | / for el in arr { LL | | if el.name.len() == 10 { @@ -37,7 +37,7 @@ LL | | None = note: you may need to dereference some variables error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:42:5 + --> tests/ui/manual_find_fixable.rs:42:5 | LL | / for Tuple(a, _) in arr { LL | | if a >= 3 { @@ -48,7 +48,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|Tuple(a, _)| a).find(|&a| a >= 3)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:57:5 + --> tests/ui/manual_find_fixable.rs:57:5 | LL | / for el in arr { LL | | if el.should_keep() { @@ -61,7 +61,7 @@ LL | | None = note: you may need to dereference some variables error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:67:5 + --> tests/ui/manual_find_fixable.rs:67:5 | LL | / for el in arr { LL | | if f(el) == 20 { @@ -72,7 +72,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.into_iter().find(|&el| f(el) == 20)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:77:5 + --> tests/ui/manual_find_fixable.rs:77:5 | LL | / for &el in arr.values() { LL | | if f(el) { @@ -83,7 +83,7 @@ LL | | None | |________^ help: replace with an iterator: `arr.values().find(|&&el| f(el)).copied()` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:86:5 + --> tests/ui/manual_find_fixable.rs:86:5 | LL | / for el in arr { LL | | if el.is_true { @@ -96,7 +96,7 @@ LL | | None = note: you may need to dereference some variables error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:116:5 + --> tests/ui/manual_find_fixable.rs:116:5 | LL | / for (_, &x) in v { LL | | if x > 10 { @@ -107,7 +107,7 @@ LL | | None | |________^ help: replace with an iterator: `v.into_iter().map(|(_, &x)| x).find(|&x| x > 10)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:125:5 + --> tests/ui/manual_find_fixable.rs:125:5 | LL | / for &(_, &x) in v { LL | | if x > 10 { @@ -118,7 +118,7 @@ LL | | None | |________^ help: replace with an iterator: `v.iter().map(|&(_, &x)| x).find(|&x| x > 10)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:134:5 + --> tests/ui/manual_find_fixable.rs:134:5 | LL | / for x in arr { LL | | if x >= 5 { @@ -129,7 +129,7 @@ LL | | return None; | |________________^ help: replace with an iterator: `arr.into_iter().find(|&x| x >= 5)` error: manual implementation of `Iterator::find` - --> $DIR/manual_find_fixable.rs:189:9 + --> tests/ui/manual_find_fixable.rs:189:9 | LL | / for x in arr { LL | | if x < 1 { diff --git a/src/tools/clippy/tests/ui/manual_find_map.stderr b/src/tools/clippy/tests/ui/manual_find_map.stderr index 0526382323d36..2722d59f52a90 100644 --- a/src/tools/clippy/tests/ui/manual_find_map.stderr +++ b/src/tools/clippy/tests/ui/manual_find_map.stderr @@ -1,11 +1,11 @@ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:9:19 + --> tests/ui/manual_find_map.rs:9:19 | LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:9:28 + --> tests/ui/manual_find_map.rs:9:28 | LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap()); | ^^^^^^^^^^ @@ -13,31 +13,31 @@ LL | let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap() = 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:12:19 + --> tests/ui/manual_find_map.rs:12:19 | LL | let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:12:29 + --> tests/ui/manual_find_map.rs:12:29 | LL | let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi")); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:15:19 + --> tests/ui/manual_find_map.rs:15:19 | LL | let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_res(a).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:15:29 + --> tests/ui/manual_find_map.rs:15:29 | LL | let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1)); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:18:10 + --> tests/ui/manual_find_map.rs:18:10 | LL | .find(|&x| to_ref(to_opt(x)).is_some()) | __________^ @@ -45,13 +45,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:18:20 + --> tests/ui/manual_find_map.rs:18:20 | LL | .find(|&x| to_ref(to_opt(x)).is_some()) | ^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:21:10 + --> tests/ui/manual_find_map.rs:21:10 | LL | .find(|x| to_ref(to_opt(*x)).is_some()) | __________^ @@ -59,13 +59,13 @@ LL | | .map(|y| to_ref(to_opt(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| *to_ref(to_opt(y)))` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:21:19 + --> tests/ui/manual_find_map.rs:21:19 | LL | .find(|x| to_ref(to_opt(*x)).is_some()) | ^^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:25:10 + --> tests/ui/manual_find_map.rs:25:10 | LL | .find(|&x| to_ref(to_res(x)).is_ok()) | __________^ @@ -73,13 +73,13 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:25:20 + --> tests/ui/manual_find_map.rs:25:20 | LL | .find(|&x| to_ref(to_res(x)).is_ok()) | ^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:28:10 + --> tests/ui/manual_find_map.rs:28:10 | LL | .find(|x| to_ref(to_res(*x)).is_ok()) | __________^ @@ -87,109 +87,109 @@ LL | | .map(|y| to_ref(to_res(y)).unwrap()); | |____________________________________________^ help: try: `find_map(|y| to_ref(to_res(y)).ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:28:19 + --> tests/ui/manual_find_map.rs:28:19 | LL | .find(|x| to_ref(to_res(*x)).is_ok()) | ^^^^^^^^^^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:34:26 + --> tests/ui/manual_find_map.rs:34:26 | LL | iter::>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x)` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:35:27 + --> tests/ui/manual_find_map.rs:35:27 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| *x)` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:36:28 + --> tests/ui/manual_find_map.rs:36:28 | LL | iter::<&&Option>().find(|x| x.is_some()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| **x)` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:37:27 + --> tests/ui/manual_find_map.rs:37:27 | LL | iter::>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:38:28 + --> tests/ui/manual_find_map.rs:38:28 | LL | iter::<&Option<&u8>>().find(|x| x.is_some()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:39:31 + --> tests/ui/manual_find_map.rs:39:31 | LL | iter::<&Option>().find(|x| x.is_some()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:40:31 + --> tests/ui/manual_find_map.rs:40:31 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:40:41 + --> tests/ui/manual_find_map.rs:40:41 | LL | iter::>().find(|&x| to_ref(x).is_some()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:42:30 + --> tests/ui/manual_find_map.rs:42:30 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:43:31 + --> tests/ui/manual_find_map.rs:43:31 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:44:32 + --> tests/ui/manual_find_map.rs:44:32 | LL | iter::<&&Result>().find(|x| x.is_ok()).map(|x| x.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:45:31 + --> tests/ui/manual_find_map.rs:45:31 | LL | iter::>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:46:32 + --> tests/ui/manual_find_map.rs:46:32 | LL | iter::<&Result<&u8, ()>>().find(|x| x.is_ok()).map(|x| x.cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.cloned().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:47:35 + --> tests/ui/manual_find_map.rs:47:35 | LL | iter::<&Result>().find(|x| x.is_ok()).map(|x| x.as_deref().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|x| x.as_deref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:48:35 + --> tests/ui/manual_find_map.rs:48:35 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|y| to_ref(y).cloned().ok())` | note: the suggestion might change the behavior of the program when merging `filter` and `map`, because this expression potentially contains side effects and will only execute once - --> $DIR/manual_find_map.rs:48:45 + --> tests/ui/manual_find_map.rs:48:45 | LL | iter::>().find(|&x| to_ref(x).is_ok()).map(|y| to_ref(y).cloned().unwrap()); | ^^^^^^^^^ error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:96:10 + --> tests/ui/manual_find_map.rs:96:10 | LL | .find(|f| f.option_field.is_some()) | __________^ @@ -197,7 +197,7 @@ LL | | .map(|f| f.option_field.clone().unwrap()); | |_________________________________________________^ help: try: `find_map(|f| f.option_field.clone())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:101:10 + --> tests/ui/manual_find_map.rs:101:10 | LL | .find(|f| f.ref_field.is_some()) | __________^ @@ -205,7 +205,7 @@ LL | | .map(|f| f.ref_field.cloned().unwrap()); | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.cloned())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:106:10 + --> tests/ui/manual_find_map.rs:106:10 | LL | .find(|f| f.ref_field.is_some()) | __________^ @@ -213,7 +213,7 @@ LL | | .map(|f| f.ref_field.copied().unwrap()); | |_______________________________________________^ help: try: `find_map(|f| f.ref_field.copied())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:111:10 + --> tests/ui/manual_find_map.rs:111:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -221,7 +221,7 @@ LL | | .map(|f| f.result_field.clone().unwrap()); | |_________________________________________________^ help: try: `find_map(|f| f.result_field.clone().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:116:10 + --> tests/ui/manual_find_map.rs:116:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -229,7 +229,7 @@ LL | | .map(|f| f.result_field.as_ref().unwrap()); | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_ref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:121:10 + --> tests/ui/manual_find_map.rs:121:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -237,7 +237,7 @@ LL | | .map(|f| f.result_field.as_deref().unwrap()); | |____________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:126:10 + --> tests/ui/manual_find_map.rs:126:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -245,7 +245,7 @@ LL | | .map(|f| f.result_field.as_mut().unwrap()); | |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_mut().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:131:10 + --> tests/ui/manual_find_map.rs:131:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ @@ -253,7 +253,7 @@ LL | | .map(|f| f.result_field.as_deref_mut().unwrap()); | |________________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref_mut().ok())` error: `find(..).map(..)` can be simplified as `find_map(..)` - --> $DIR/manual_find_map.rs:136:10 + --> tests/ui/manual_find_map.rs:136:10 | LL | .find(|f| f.result_field.is_ok()) | __________^ diff --git a/src/tools/clippy/tests/ui/manual_flatten.stderr b/src/tools/clippy/tests/ui/manual_flatten.stderr index aa5c2104f6548..3b64d9ef859d6 100644 --- a/src/tools/clippy/tests/ui/manual_flatten.stderr +++ b/src/tools/clippy/tests/ui/manual_flatten.stderr @@ -1,5 +1,5 @@ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:7:5 + --> tests/ui/manual_flatten.rs:7:5 | LL | for n in x { | ^ - help: try: `x.into_iter().flatten()` @@ -13,7 +13,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:9:9 + --> tests/ui/manual_flatten.rs:9:9 | LL | / if let Some(y) = n { LL | | println!("{}", y); @@ -23,7 +23,7 @@ LL | | } = 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 + --> tests/ui/manual_flatten.rs:16:5 | LL | for n in y.clone() { | ^ --------- help: try: `y.clone().into_iter().flatten()` @@ -37,7 +37,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:18:9 + --> tests/ui/manual_flatten.rs:18:9 | LL | / if let Ok(n) = n { LL | | println!("{}", n); @@ -45,7 +45,7 @@ LL | | }; | |_________^ error: unnecessary `if let` since only the `Ok` variant of the iterator element is used - --> $DIR/manual_flatten.rs:24:5 + --> tests/ui/manual_flatten.rs:24:5 | LL | for n in &y { | ^ -- help: try: `y.iter().flatten()` @@ -59,7 +59,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:26:9 + --> tests/ui/manual_flatten.rs:26:9 | LL | / if let Ok(n) = n { LL | | println!("{}", n); @@ -67,7 +67,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Ok` variant of the iterator element is used - --> $DIR/manual_flatten.rs:33:5 + --> tests/ui/manual_flatten.rs:33:5 | LL | for n in z { | ^ - help: try: `z.iter().flatten()` @@ -81,7 +81,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:35:9 + --> tests/ui/manual_flatten.rs:35:9 | LL | / if let Ok(n) = n { LL | | println!("{}", n); @@ -89,7 +89,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:43:5 + --> tests/ui/manual_flatten.rs:43:5 | LL | for n in z { | ^ - help: try: `z.flatten()` @@ -103,7 +103,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:45:9 + --> tests/ui/manual_flatten.rs:45:9 | LL | / if let Some(m) = n { LL | | println!("{}", m); @@ -111,7 +111,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:77:5 + --> tests/ui/manual_flatten.rs:77:5 | LL | for n in &vec_of_ref { | ^ ----------- help: try: `vec_of_ref.iter().copied().flatten()` @@ -125,7 +125,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:79:9 + --> tests/ui/manual_flatten.rs:79:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); @@ -133,7 +133,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:85:5 + --> tests/ui/manual_flatten.rs:85:5 | LL | for n in vec_of_ref { | ^ ---------- help: try: `vec_of_ref.iter().copied().flatten()` @@ -147,7 +147,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:87:9 + --> tests/ui/manual_flatten.rs:87:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); @@ -155,7 +155,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:93:5 + --> tests/ui/manual_flatten.rs:93:5 | LL | for n in slice_of_ref { | ^ ------------ help: try: `slice_of_ref.iter().copied().flatten()` @@ -169,7 +169,7 @@ LL | | } | |_____^ | help: ...and remove the `if let` statement in the for loop - --> $DIR/manual_flatten.rs:95:9 + --> tests/ui/manual_flatten.rs:95:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); @@ -177,7 +177,7 @@ LL | | } | |_________^ error: unnecessary `if let` since only the `Some` variant of the iterator element is used - --> $DIR/manual_flatten.rs:124:5 + --> tests/ui/manual_flatten.rs:124:5 | LL | / for n in vec![ LL | | @@ -189,7 +189,7 @@ LL | | } | |_____^ | help: remove the `if let` statement in the for loop and then... - --> $DIR/manual_flatten.rs:130:9 + --> tests/ui/manual_flatten.rs:130:9 | LL | / if let Some(n) = n { LL | | println!("{:?}", n); diff --git a/src/tools/clippy/tests/ui/manual_float_methods.stderr b/src/tools/clippy/tests/ui/manual_float_methods.stderr index 680ab2efa094f..dae96839262d1 100644 --- a/src/tools/clippy/tests/ui/manual_float_methods.stderr +++ b/src/tools/clippy/tests/ui/manual_float_methods.stderr @@ -1,5 +1,5 @@ error: manually checking if a float is infinite - --> $DIR/manual_float_methods.rs:23:8 + --> tests/ui/manual_float_methods.rs:23:8 | LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()` @@ -8,7 +8,7 @@ LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {} = 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 + --> tests/ui/manual_float_methods.rs:24:8 | LL | if x != f32::INFINITY && x != f32::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -29,13 +29,13 @@ LL | if !x.is_infinite() {} | ~~~~~~~~~~~~~~~~ error: manually checking if a float is infinite - --> $DIR/manual_float_methods.rs:25:8 + --> tests/ui/manual_float_methods.rs:25:8 | LL | if x == INFINITE || x == NEG_INFINITE {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()` error: manually checking if a float is finite - --> $DIR/manual_float_methods.rs:26:8 + --> tests/ui/manual_float_methods.rs:26:8 | LL | if x != INFINITE && x != NEG_INFINITE {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | if !x.is_infinite() {} | ~~~~~~~~~~~~~~~~ error: manually checking if a float is infinite - --> $DIR/manual_float_methods.rs:28:8 + --> tests/ui/manual_float_methods.rs:28:8 | LL | if x == f64::INFINITY || x == f64::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()` error: manually checking if a float is finite - --> $DIR/manual_float_methods.rs:29:8 + --> tests/ui/manual_float_methods.rs:29:8 | LL | if x != f64::INFINITY && x != f64::NEG_INFINITY {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/manual_hash_one.stderr b/src/tools/clippy/tests/ui/manual_hash_one.stderr index 3ce6f41e1f910..bcff36d9bafc1 100644 --- a/src/tools/clippy/tests/ui/manual_hash_one.stderr +++ b/src/tools/clippy/tests/ui/manual_hash_one.stderr @@ -1,5 +1,5 @@ error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:9:5 + --> tests/ui/manual_hash_one.rs:9:5 | LL | hasher.finish() | ^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL ~ b.hash_one(&true) | error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:15:13 + --> tests/ui/manual_hash_one.rs:15:13 | LL | let _ = hasher.finish(); | ^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL ~ let _ = b.hash_one(&s[4..10]); | error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:21:13 + --> tests/ui/manual_hash_one.rs:21:13 | LL | let _ = hasher.finish(); | ^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL ~ let _ = b.hash_one(&v); | error: manual implementation of `BuildHasher::hash_one` - --> $DIR/manual_hash_one.rs:88:13 + --> tests/ui/manual_hash_one.rs:88:13 | LL | let _ = hasher.finish(); | ^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr b/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr index 56d0b9cd77b26..e8ffeb5f8ca3e 100644 --- a/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr +++ b/src/tools/clippy/tests/ui/manual_instant_elapsed.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Instant::elapsed` - --> $DIR/manual_instant_elapsed.rs:17:20 + --> tests/ui/manual_instant_elapsed.rs:17:20 | LL | let duration = Instant::now() - prev_instant; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `prev_instant.elapsed()` @@ -8,7 +8,7 @@ LL | let duration = Instant::now() - prev_instant; = help: to override `-D warnings` add `#[allow(clippy::manual_instant_elapsed)]` error: manual implementation of `Instant::elapsed` - --> $DIR/manual_instant_elapsed.rs:26:5 + --> tests/ui/manual_instant_elapsed.rs:26:5 | LL | Instant::now() - *ref_to_instant; // to ensure parens are added correctly | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*ref_to_instant).elapsed()` 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 f69522c5ff84c..3632077ec8086 100644 --- a/src/tools/clippy/tests/ui/manual_is_ascii_check.stderr +++ b/src/tools/clippy/tests/ui/manual_is_ascii_check.stderr @@ -1,5 +1,5 @@ error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:5:13 + --> tests/ui/manual_is_ascii_check.rs:5:13 | LL | assert!(matches!('x', 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_lowercase()` @@ -8,127 +8,127 @@ LL | assert!(matches!('x', 'a'..='z')); = 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 + --> tests/ui/manual_is_ascii_check.rs:6:13 | LL | assert!(matches!('X', 'A'..='Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:7:13 + --> tests/ui/manual_is_ascii_check.rs:7:13 | LL | assert!(matches!(b'x', b'a'..=b'z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'x'.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:8:13 + --> tests/ui/manual_is_ascii_check.rs:8:13 | LL | assert!(matches!(b'X', b'A'..=b'Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'X'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:11:13 + --> tests/ui/manual_is_ascii_check.rs:11:13 | LL | assert!(matches!(num, '0'..='9')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:12:13 + --> tests/ui/manual_is_ascii_check.rs:12:13 | LL | assert!(matches!(b'1', b'0'..=b'9')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:13:13 + --> tests/ui/manual_is_ascii_check.rs:13:13 | LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:17:5 + --> tests/ui/manual_is_ascii_check.rs:17:5 | LL | (b'0'..=b'9').contains(&b'0'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'0'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:18:5 + --> tests/ui/manual_is_ascii_check.rs:18:5 | LL | (b'a'..=b'z').contains(&b'a'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'a'.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:19:5 + --> tests/ui/manual_is_ascii_check.rs:19:5 | LL | (b'A'..=b'Z').contains(&b'A'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'A'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:21:5 + --> tests/ui/manual_is_ascii_check.rs:21:5 | LL | ('0'..='9').contains(&'0'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'0'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:22:5 + --> tests/ui/manual_is_ascii_check.rs:22:5 | LL | ('a'..='z').contains(&'a'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'a'.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:23:5 + --> tests/ui/manual_is_ascii_check.rs:23:5 | LL | ('A'..='Z').contains(&'A'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'A'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:26:5 + --> tests/ui/manual_is_ascii_check.rs:26:5 | LL | ('0'..='9').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:27:5 + --> tests/ui/manual_is_ascii_check.rs:27:5 | LL | ('a'..='z').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_lowercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:28:5 + --> tests/ui/manual_is_ascii_check.rs:28:5 | LL | ('A'..='Z').contains(cool_letter); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cool_letter.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:41:13 + --> tests/ui/manual_is_ascii_check.rs:41:13 | LL | assert!(matches!(b'1', b'0'..=b'9')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:42:13 + --> tests/ui/manual_is_ascii_check.rs:42:13 | LL | assert!(matches!('X', 'A'..='Z')); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:43:13 + --> tests/ui/manual_is_ascii_check.rs:43:13 | LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:44:13 + --> tests/ui/manual_is_ascii_check.rs:44:13 | LL | assert!(matches!('x', '0'..='9' | 'a'..='f' | 'A'..='F')); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_hexdigit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:55:23 + --> tests/ui/manual_is_ascii_check.rs:55:23 | LL | const FOO: bool = matches!('x', '0'..='9'); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_digit()` error: manual check for common ascii range - --> $DIR/manual_is_ascii_check.rs:56:23 + --> tests/ui/manual_is_ascii_check.rs:56:23 | LL | const BAR: bool = matches!('x', '0'..='9' | 'a'..='f' | 'A'..='F'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_hexdigit()` diff --git a/src/tools/clippy/tests/ui/manual_is_variant_and.stderr b/src/tools/clippy/tests/ui/manual_is_variant_and.stderr index c243de098dc67..d3ff7cf8b316a 100644 --- a/src/tools/clippy/tests/ui/manual_is_variant_and.stderr +++ b/src/tools/clippy/tests/ui/manual_is_variant_and.stderr @@ -1,5 +1,5 @@ error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:13:17 + --> tests/ui/manual_is_variant_and.rs:13:17 | LL | let _ = opt.map(|x| x > 1) | _________________^ @@ -11,7 +11,7 @@ LL | | .unwrap_or_default(); = help: to override `-D warnings` add `#[allow(clippy::manual_is_variant_and)]` error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:17:17 + --> tests/ui/manual_is_variant_and.rs:17:17 | LL | let _ = opt.map(|x| { | _________________^ @@ -28,13 +28,13 @@ LL ~ }); | error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:21:17 + --> tests/ui/manual_is_variant_and.rs:21:17 | LL | let _ = opt.map(|x| x > 1).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_some_and(|x| x > 1)` error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:23:10 + --> tests/ui/manual_is_variant_and.rs:23:10 | LL | .map(|x| x > 1) | __________^ @@ -42,13 +42,13 @@ LL | | .unwrap_or_default(); | |____________________________^ help: use: `is_some_and(|x| x > 1)` error: called `map().unwrap_or_default()` on an `Option` value - --> $DIR/manual_is_variant_and.rs:30:18 + --> tests/ui/manual_is_variant_and.rs:30:18 | LL | let _ = opt2.map(char::is_alphanumeric).unwrap_or_default(); // should lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_some_and(char::is_alphanumeric)` error: called `map().unwrap_or_default()` on a `Result` value - --> $DIR/manual_is_variant_and.rs:39:17 + --> tests/ui/manual_is_variant_and.rs:39:17 | LL | let _ = res.map(|x| { | _________________^ @@ -65,7 +65,7 @@ LL ~ }); | error: called `map().unwrap_or_default()` on a `Result` value - --> $DIR/manual_is_variant_and.rs:43:17 + --> tests/ui/manual_is_variant_and.rs:43:17 | LL | let _ = res.map(|x| x > 1) | _________________^ @@ -73,7 +73,7 @@ LL | | .unwrap_or_default(); | |____________________________^ help: use: `is_ok_and(|x| x > 1)` error: called `map().unwrap_or_default()` on a `Result` value - --> $DIR/manual_is_variant_and.rs:50:18 + --> tests/ui/manual_is_variant_and.rs:50:18 | LL | let _ = res2.map(char::is_alphanumeric).unwrap_or_default(); // should lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_ok_and(char::is_alphanumeric)` diff --git a/src/tools/clippy/tests/ui/manual_let_else.stderr b/src/tools/clippy/tests/ui/manual_let_else.stderr index 3beaf766efb13..b6433fc460c92 100644 --- a/src/tools/clippy/tests/ui/manual_let_else.stderr +++ b/src/tools/clippy/tests/ui/manual_let_else.stderr @@ -1,5 +1,5 @@ error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:27:5 + --> tests/ui/manual_let_else.rs:27:5 | LL | let v = if let Some(v_some) = g() { v_some } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };` @@ -8,7 +8,7 @@ LL | let v = if let Some(v_some) = g() { v_some } else { return }; = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:30:5 + --> tests/ui/manual_let_else.rs:30:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -26,7 +26,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:37:5 + --> tests/ui/manual_let_else.rs:37:5 | LL | / let v = if let Some(v) = g() { LL | | @@ -47,25 +47,25 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:49:9 + --> tests/ui/manual_let_else.rs:49:9 | LL | let v = if let Some(v_some) = g() { v_some } else { continue }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { continue };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:51:9 + --> tests/ui/manual_let_else.rs:51:9 | LL | let v = if let Some(v_some) = g() { v_some } else { break }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { break };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:56:5 + --> tests/ui/manual_let_else.rs:56:5 | LL | let v = if let Some(v_some) = g() { v_some } else { panic!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { panic!() };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:60:5 + --> tests/ui/manual_let_else.rs:60:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -83,7 +83,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:68:5 + --> tests/ui/manual_let_else.rs:68:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -101,7 +101,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:76:5 + --> tests/ui/manual_let_else.rs:76:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -121,7 +121,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:85:5 + --> tests/ui/manual_let_else.rs:85:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -141,7 +141,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:94:5 + --> tests/ui/manual_let_else.rs:94:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -168,7 +168,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:110:5 + --> tests/ui/manual_let_else.rs:110:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -190,7 +190,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:121:5 + --> tests/ui/manual_let_else.rs:121:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -217,7 +217,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:137:5 + --> tests/ui/manual_let_else.rs:137:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -239,7 +239,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:148:5 + --> tests/ui/manual_let_else.rs:148:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -257,7 +257,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:156:5 + --> tests/ui/manual_let_else.rs:156:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -278,7 +278,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:166:5 + --> tests/ui/manual_let_else.rs:166:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -299,7 +299,7 @@ LL + } }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:176:5 + --> tests/ui/manual_let_else.rs:176:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -328,7 +328,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:194:5 + --> tests/ui/manual_let_else.rs:194:5 | LL | / let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) { LL | | @@ -346,7 +346,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:202:5 + --> tests/ui/manual_let_else.rs:202:5 | LL | / let (w, S { v }) = if let (Some(v_some), w_some) = (g().map(|_| S { v: 0 }), 0) { LL | | @@ -364,7 +364,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:212:13 + --> tests/ui/manual_let_else.rs:212:13 | LL | let $n = if let Some(v) = $e { v } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some($n) = g() else { return };` @@ -375,19 +375,19 @@ LL | create_binding_if_some!(w, g()); = note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info) error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:221:5 + --> tests/ui/manual_let_else.rs:221:5 | LL | let v = if let Variant::A(a, 0) = e() { a } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(v, 0) = e() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:225:5 + --> tests/ui/manual_let_else.rs:225:5 | LL | let mut v = if let Variant::B(b) = e() { b } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::B(mut v) = e() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:230:5 + --> tests/ui/manual_let_else.rs:230:5 | LL | / let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested { LL | | @@ -405,19 +405,19 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:237:5 + --> tests/ui/manual_let_else.rs:237:5 | LL | let v = if let Variant::A(.., a) = e() { a } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(.., v) = e() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:241:5 + --> tests/ui/manual_let_else.rs:241:5 | LL | let w = if let (Some(v), ()) = (g(), ()) { v } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let (Some(w), ()) = (g(), ()) else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:245:5 + --> tests/ui/manual_let_else.rs:245:5 | LL | / let w = if let Some(S { v: x }) = Some(S { v: 0 }) { LL | | @@ -435,7 +435,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:253:5 + --> tests/ui/manual_let_else.rs:253:5 | LL | / let v = if let Some(S { v: x }) = Some(S { v: 0 }) { LL | | @@ -453,7 +453,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:261:5 + --> tests/ui/manual_let_else.rs:261:5 | LL | / let (x, S { v }, w) = if let Some(U { v, w, x }) = None::>> { LL | | @@ -471,7 +471,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else.rs:378:5 + --> tests/ui/manual_let_else.rs:378:5 | LL | / let _ = match ff { LL | | 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 18bfe324ba76a..3c0065f64033f 100644 --- a/src/tools/clippy/tests/ui/manual_let_else_match.stderr +++ b/src/tools/clippy/tests/ui/manual_let_else_match.stderr @@ -1,5 +1,5 @@ error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:36:5 + --> tests/ui/manual_let_else_match.rs:36:5 | LL | / let v = match g() { LL | | @@ -13,7 +13,7 @@ LL | | }; = 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 + --> tests/ui/manual_let_else_match.rs:43:5 | LL | / let v = match g() { LL | | @@ -23,7 +23,7 @@ LL | | }; | |______^ help: consider writing: `let Some(v) = g() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:51:9 + --> tests/ui/manual_let_else_match.rs:51:9 | LL | / let v = match h() { LL | | @@ -33,7 +33,7 @@ LL | | }; | |__________^ help: consider writing: `let ((Some(v), None) | (None, Some(v))) = h() else { continue };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:57:9 + --> tests/ui/manual_let_else_match.rs:57:9 | LL | / let v = match build_enum() { LL | | @@ -43,7 +43,7 @@ LL | | }; | |__________^ help: consider writing: `let (Variant::Bar(v) | Variant::Baz(v)) = build_enum() else { continue };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:66:5 + --> tests/ui/manual_let_else_match.rs:66:5 | LL | / let v = match f() { LL | | @@ -53,7 +53,7 @@ LL | | }; | |______^ help: consider writing: `let Ok(v) = f() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:73:5 + --> tests/ui/manual_let_else_match.rs:73:5 | LL | / let v = match f().map_err(|_| ()) { LL | | @@ -63,7 +63,7 @@ LL | | }; | |______^ help: consider writing: `let Ok(v) = f().map_err(|_| ()) else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:81:5 + --> tests/ui/manual_let_else_match.rs:81:5 | LL | / let _value = match f { LL | | @@ -73,7 +73,7 @@ LL | | }; | |______^ help: consider writing: `let (Variant::Bar(_value) | Variant::Baz(_value)) = f else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:87:5 + --> tests/ui/manual_let_else_match.rs:87:5 | LL | / let _value = match Some(build_enum()) { LL | | @@ -83,7 +83,7 @@ LL | | }; | |______^ help: consider writing: `let Some(Variant::Bar(_value) | Variant::Baz(_value)) = Some(build_enum()) else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:94:5 + --> tests/ui/manual_let_else_match.rs:94:5 | LL | / let data = match data.as_slice() { LL | | @@ -93,7 +93,7 @@ LL | | }; | |______^ help: consider writing: `let ([data @ .., 0, 0, 0, 0] | [data @ .., 0, 0] | [data @ .., 0]) = data.as_slice() else { return };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_match.rs:175:5 + --> tests/ui/manual_let_else_match.rs:175:5 | LL | / let msg = match Some("hi") { LL | | 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 dec6947697a7e..434872ca26777 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 @@ -1,5 +1,5 @@ error: this `let...else` may be rewritten with the `?` operator - --> $DIR/manual_let_else_question_mark.rs:29:5 + --> tests/ui/manual_let_else_question_mark.rs:29:5 | LL | let Some(v) = g() else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let v = g()?;` @@ -8,19 +8,19 @@ LL | let Some(v) = g() else { return None }; = 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 + --> tests/ui/manual_let_else_question_mark.rs:35:5 | LL | let Some((v, w)) = g() else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let (v, w) = g()?;` error: this block may be rewritten with the `?` operator - --> $DIR/manual_let_else_question_mark.rs:38:13 + --> tests/ui/manual_let_else_question_mark.rs:38:13 | LL | let v = if let Some(v_some) = g() { v_some } else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `g()?` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_question_mark.rs:42:5 + --> tests/ui/manual_let_else_question_mark.rs:42:5 | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -39,7 +39,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_question_mark.rs:53:9 + --> tests/ui/manual_let_else_question_mark.rs:53:9 | LL | / let v = match g() { LL | | Some(v_some) => v_some, @@ -48,13 +48,13 @@ LL | | }; | |__________^ help: consider writing: `let Some(v) = g() else { return None };` error: this could be rewritten as `let...else` - --> $DIR/manual_let_else_question_mark.rs:63:9 + --> tests/ui/manual_let_else_question_mark.rs:63:9 | LL | let v = if let Some(v_some) = g() { v_some } else { return None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return None };` error: this `let...else` may be rewritten with the `?` operator - --> $DIR/manual_let_else_question_mark.rs:71:5 + --> tests/ui/manual_let_else_question_mark.rs:71:5 | LL | / let Some(x) = y else { LL | | return None; 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 3e92bd0238c3a..78395eb7d6648 100644 --- a/src/tools/clippy/tests/ui/manual_main_separator_str.stderr +++ b/src/tools/clippy/tests/ui/manual_main_separator_str.stderr @@ -1,5 +1,5 @@ error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` - --> $DIR/manual_main_separator_str.rs:21:19 + --> tests/ui/manual_main_separator_str.rs:21:19 | LL | let _: &str = &MAIN_SEPARATOR.to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` @@ -8,19 +8,19 @@ LL | let _: &str = &MAIN_SEPARATOR.to_string(); = 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 + --> tests/ui/manual_main_separator_str.rs:22:17 | LL | let _ = len(&MAIN_SEPARATOR.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` - --> $DIR/manual_main_separator_str.rs:23:23 + --> tests/ui/manual_main_separator_str.rs:23:23 | LL | let _: Vec = MAIN_SEPARATOR.to_string().encode_utf16().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` error: taking a reference on `std::path::MAIN_SEPARATOR` conversion to `String` - --> $DIR/manual_main_separator_str.rs:27:12 + --> tests/ui/manual_main_separator_str.rs:27:12 | LL | f: &MAIN_SEPARATOR.to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `std::path::MAIN_SEPARATOR_STR` diff --git a/src/tools/clippy/tests/ui/manual_map_option.stderr b/src/tools/clippy/tests/ui/manual_map_option.stderr index 3754a982cb9bc..47cc18303ba57 100644 --- a/src/tools/clippy/tests/ui/manual_map_option.stderr +++ b/src/tools/clippy/tests/ui/manual_map_option.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:14:5 + --> tests/ui/manual_map_option.rs:14:5 | LL | / match Some(0) { LL | | Some(_) => Some(2), @@ -11,7 +11,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_map)]` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:19:5 + --> tests/ui/manual_map_option.rs:19:5 | LL | / match Some(0) { LL | | Some(x) => Some(x + 1), @@ -20,7 +20,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| x + 1)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:24:5 + --> tests/ui/manual_map_option.rs:24:5 | LL | / match Some("") { LL | | Some(x) => Some(x.is_empty()), @@ -29,7 +29,7 @@ LL | | }; | |_____^ help: try: `Some("").map(|x| x.is_empty())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:29:5 + --> tests/ui/manual_map_option.rs:29:5 | LL | / if let Some(x) = Some(0) { LL | | Some(!x) @@ -39,7 +39,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| !x)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:36:5 + --> tests/ui/manual_map_option.rs:36:5 | LL | / match Some(0) { LL | | Some(x) => { Some(std::convert::identity(x)) } @@ -48,7 +48,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(std::convert::identity)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:41:5 + --> tests/ui/manual_map_option.rs:41:5 | LL | / match Some(&String::new()) { LL | | Some(x) => Some(str::len(x)), @@ -57,7 +57,7 @@ LL | | }; | |_____^ help: try: `Some(&String::new()).map(|x| str::len(x))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:51:5 + --> tests/ui/manual_map_option.rs:51:5 | LL | / match &Some([0, 1]) { LL | | Some(x) => Some(x[0]), @@ -66,7 +66,7 @@ LL | | }; | |_____^ help: try: `Some([0, 1]).as_ref().map(|x| x[0])` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:56:5 + --> tests/ui/manual_map_option.rs:56:5 | LL | / match &Some(0) { LL | | &Some(x) => Some(x * 2), @@ -75,7 +75,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| x * 2)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:61:5 + --> tests/ui/manual_map_option.rs:61:5 | LL | / match Some(String::new()) { LL | | Some(ref x) => Some(x.is_empty()), @@ -84,7 +84,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.is_empty())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:66:5 + --> tests/ui/manual_map_option.rs:66:5 | LL | / match &&Some(String::new()) { LL | | Some(x) => Some(x.len()), @@ -93,7 +93,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.len())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:71:5 + --> tests/ui/manual_map_option.rs:71:5 | LL | / match &&Some(0) { LL | | &&Some(x) => Some(x + x), @@ -102,7 +102,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| x + x)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:84:9 + --> tests/ui/manual_map_option.rs:84:9 | LL | / match &mut Some(String::new()) { LL | | Some(x) => Some(x.push_str("")), @@ -111,7 +111,7 @@ LL | | }; | |_________^ help: try: `Some(String::new()).as_mut().map(|x| x.push_str(""))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:90:5 + --> tests/ui/manual_map_option.rs:90:5 | LL | / match &mut Some(String::new()) { LL | | Some(ref x) => Some(x.len()), @@ -120,7 +120,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.len())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:95:5 + --> tests/ui/manual_map_option.rs:95:5 | LL | / match &mut &Some(String::new()) { LL | | Some(x) => Some(x.is_empty()), @@ -129,7 +129,7 @@ LL | | }; | |_____^ help: try: `Some(String::new()).as_ref().map(|x| x.is_empty())` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:100:5 + --> tests/ui/manual_map_option.rs:100:5 | LL | / match Some((0, 1, 2)) { LL | | Some((x, y, z)) => Some(x + y + z), @@ -138,7 +138,7 @@ LL | | }; | |_____^ help: try: `Some((0, 1, 2)).map(|(x, y, z)| x + y + z)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:105:5 + --> tests/ui/manual_map_option.rs:105:5 | LL | / match Some([1, 2, 3]) { LL | | Some([first, ..]) => Some(first), @@ -147,7 +147,7 @@ LL | | }; | |_____^ help: try: `Some([1, 2, 3]).map(|[first, ..]| first)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:110:5 + --> tests/ui/manual_map_option.rs:110:5 | LL | / match &Some((String::new(), "test")) { LL | | Some((x, y)) => Some((y, x)), @@ -156,7 +156,7 @@ LL | | }; | |_____^ help: try: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:168:5 + --> tests/ui/manual_map_option.rs:168:5 | LL | / match Some(0) { LL | | Some(x) => Some(vec![x]), @@ -165,7 +165,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| vec![x])` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:173:5 + --> tests/ui/manual_map_option.rs:173:5 | LL | / match option_env!("") { LL | | Some(x) => Some(String::from(x)), @@ -174,7 +174,7 @@ LL | | }; | |_____^ help: try: `option_env!("").map(String::from)` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:193:12 + --> tests/ui/manual_map_option.rs:193:12 | LL | } else if let Some(x) = Some(0) { | ____________^ @@ -185,7 +185,7 @@ LL | | }; | |_____^ help: try: `{ Some(0).map(|x| x + 1) }` error: manual implementation of `Option::map` - --> $DIR/manual_map_option.rs:201:12 + --> tests/ui/manual_map_option.rs:201:12 | LL | } else if let Some(x) = Some(0) { | ____________^ 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 d3754f22d8996..78e4677544bc8 100644 --- a/src/tools/clippy/tests/ui/manual_map_option_2.stderr +++ b/src/tools/clippy/tests/ui/manual_map_option_2.stderr @@ -1,5 +1,5 @@ error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:6:13 + --> tests/ui/manual_map_option_2.rs:6:13 | LL | let _ = match Some(0) { | _____________^ @@ -22,7 +22,7 @@ LL ~ }); | error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:48:13 + --> tests/ui/manual_map_option_2.rs:48:13 | LL | let _ = match &s { | _____________^ @@ -32,7 +32,7 @@ LL | | }; | |_____^ help: try: `s.as_ref().map(|x| { if let Some(ref s) = s { (x.clone(), s) } else { panic!() } })` error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:58:17 + --> tests/ui/manual_map_option_2.rs:58:17 | LL | let _ = match Some(0) { | _________________^ @@ -42,7 +42,7 @@ LL | | }; | |_________^ help: try: `Some(0).map(|x| f(x))` error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:63:13 + --> tests/ui/manual_map_option_2.rs:63:13 | LL | let _ = match Some(0) { | _____________^ @@ -52,7 +52,7 @@ LL | | }; | |_____^ help: try: `Some(0).map(|x| unsafe { f(x) })` error: manual implementation of `Option::map` - --> $DIR/manual_map_option_2.rs:67:13 + --> tests/ui/manual_map_option_2.rs:67:13 | LL | let _ = match Some(0) { | _____________^ 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 3f000fbab6994..41a991e9688f5 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 @@ -1,5 +1,5 @@ error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:5:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:5:5 | LL | / for i in 3..src.len() { LL | | @@ -13,7 +13,7 @@ LL | | } = 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 + --> tests/ui/manual_memcpy/with_loop_counters.rs:13:5 | LL | / for i in 3..src.len() { LL | | @@ -23,7 +23,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..(src.len() - 3)].copy_from_slice(&src[3..]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:20:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:20:5 | LL | / for i in 0..src.len() { LL | | @@ -33,7 +33,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(src.len() + 3)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:27:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:27:5 | LL | / for i in 0..src.len() { LL | | @@ -43,7 +43,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[3..(src.len() + 3)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:34:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:34:5 | LL | / for i in 3..(3 + src.len()) { LL | | @@ -53,7 +53,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(3 + src.len())].copy_from_slice(&src[..(3 + src.len() - 3)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:41:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:41:5 | LL | / for i in 5..src.len() { LL | | @@ -63,7 +63,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[5..src.len()].copy_from_slice(&src[(3 - 2)..((src.len() - 2) + 3 - 5)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:48:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:48:5 | LL | / for i in 0..dst.len() { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[2..(dst.len() + 2)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:55:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:55:5 | LL | / for i in 3..10 { LL | | @@ -83,7 +83,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..10].copy_from_slice(&src[5..(10 + 5 - 3)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:63:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:63:5 | LL | / for i in 0..src.len() { LL | | @@ -101,7 +101,7 @@ LL + dst2[30..(src.len() + 30)].copy_from_slice(&src[..]); | error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:74:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:74:5 | LL | / for i in 0..1 << 1 { LL | | @@ -111,7 +111,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(0 << 1)..((1 << 1) + (0 << 1))].copy_from_slice(&src[2..((1 << 1) + 2)]);` error: it looks like you're manually copying between slices - --> $DIR/with_loop_counters.rs:82:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:82:5 | LL | / for i in 3..src.len() { LL | | 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 4b5cd274da78f..55cca1fb584a0 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 @@ -1,5 +1,5 @@ error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:8:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:8:5 | LL | / for i in 0..src.len() { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/manual_memcpy/without_loop_counters.rs:15:5 | LL | / for i in 0..src.len() { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[10..(src.len() + 10)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:21:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:21:5 | LL | / for i in 0..src.len() { LL | | @@ -30,7 +30,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[10..(src.len() + 10)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:27:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:27:5 | LL | / for i in 11..src.len() { LL | | @@ -39,7 +39,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[11..src.len()].copy_from_slice(&src[(11 - 10)..(src.len() - 10)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:33:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:33:5 | LL | / for i in 0..dst.len() { LL | | @@ -48,7 +48,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..dst.len()]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:47:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:47:5 | LL | / for i in 10..256 { LL | | @@ -64,7 +64,7 @@ LL + dst2[(10 + 500)..(256 + 500)].copy_from_slice(&src[10..256]); | error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:60:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:60:5 | LL | / for i in 10..LOOP_OFFSET { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].copy_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:74:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:74:5 | LL | / for i in 0..src_vec.len() { LL | | @@ -82,7 +82,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst_vec[..src_vec.len()].copy_from_slice(&src_vec[..]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:104:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:104:5 | LL | / for i in from..from + src.len() { LL | | @@ -91,7 +91,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + src.len())].copy_from_slice(&src[..(from + src.len() - from)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:109:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:109:5 | LL | / for i in from..from + 3 { LL | | @@ -100,7 +100,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + 3)].copy_from_slice(&src[..(from + 3 - from)]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:115:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:115:5 | LL | / for i in 0..5 { LL | | @@ -109,7 +109,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:121:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:121:5 | LL | / for i in 0..0 { LL | | @@ -118,7 +118,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..0].copy_from_slice(&src[..0]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:145:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:145:5 | LL | / for i in 0..4 { LL | | @@ -127,7 +127,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..4]);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:151:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:151:5 | LL | / for i in 0..5 { LL | | @@ -136,7 +136,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:157:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:157:5 | LL | / for i in 0..5 { LL | | @@ -145,7 +145,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> $DIR/without_loop_counters.rs:165:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:165:5 | LL | / for i in 0..src.len() { LL | | diff --git a/src/tools/clippy/tests/ui/manual_next_back.stderr b/src/tools/clippy/tests/ui/manual_next_back.stderr index a63d266dd623f..c7e1ceca437cc 100644 --- a/src/tools/clippy/tests/ui/manual_next_back.stderr +++ b/src/tools/clippy/tests/ui/manual_next_back.stderr @@ -1,5 +1,5 @@ error: manual backwards iteration - --> $DIR/manual_next_back.rs:32:20 + --> tests/ui/manual_next_back.rs:32:20 | LL | let _ = (0..10).rev().next().unwrap(); | ^^^^^^^^^^^^^ help: use: `.next_back()` @@ -8,7 +8,7 @@ LL | let _ = (0..10).rev().next().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::manual_next_back)]` error: manual backwards iteration - --> $DIR/manual_next_back.rs:33:32 + --> tests/ui/manual_next_back.rs:33:32 | LL | let _ = "something".bytes().rev().next(); | ^^^^^^^^^^^^^ help: use: `.next_back()` 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 c4b13a577a96b..ee43b8ddc0246 100644 --- a/src/tools/clippy/tests/ui/manual_non_exhaustive_enum.stderr +++ b/src/tools/clippy/tests/ui/manual_non_exhaustive_enum.stderr @@ -1,5 +1,5 @@ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_enum.rs:5:1 + --> tests/ui/manual_non_exhaustive_enum.rs:5:1 | LL | enum E { | ^----- @@ -15,7 +15,7 @@ LL | | } | |_^ | help: remove this variant - --> $DIR/manual_non_exhaustive_enum.rs:10:5 + --> tests/ui/manual_non_exhaustive_enum.rs:10:5 | LL | _C, | ^^ @@ -23,7 +23,7 @@ LL | _C, = 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:30:1 + --> tests/ui/manual_non_exhaustive_enum.rs:30:1 | LL | enum NoUnderscore { | ^---------------- @@ -38,7 +38,7 @@ LL | | } | |_^ | help: remove this variant - --> $DIR/manual_non_exhaustive_enum.rs:34:5 + --> tests/ui/manual_non_exhaustive_enum.rs:34:5 | LL | C, | ^ 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 0b88b19691e13..1cab812988a34 100644 --- a/src/tools/clippy/tests/ui/manual_non_exhaustive_struct.stderr +++ b/src/tools/clippy/tests/ui/manual_non_exhaustive_struct.stderr @@ -1,5 +1,5 @@ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:5:5 + --> tests/ui/manual_non_exhaustive_struct.rs:5:5 | LL | struct S { | ^------- @@ -14,7 +14,7 @@ LL | | } | |_____^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:9:9 + --> tests/ui/manual_non_exhaustive_struct.rs:9:9 | LL | _c: (), | ^^^^^^ @@ -22,7 +22,7 @@ LL | _c: (), = 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 + --> tests/ui/manual_non_exhaustive_struct.rs:14:5 | LL | / struct Sp { LL | | @@ -33,13 +33,13 @@ LL | | } | |_____^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:18:9 + --> tests/ui/manual_non_exhaustive_struct.rs:18:9 | LL | _c: (), | ^^^^^^ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:29:5 + --> tests/ui/manual_non_exhaustive_struct.rs:29:5 | LL | struct NoUnderscore { | ^------------------ @@ -53,13 +53,13 @@ LL | | } | |_____^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:32:9 + --> tests/ui/manual_non_exhaustive_struct.rs:32:9 | LL | c: (), | ^^^^^ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:56:5 + --> tests/ui/manual_non_exhaustive_struct.rs:56:5 | LL | struct T(pub i32, pub i32, ()); | --------^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,19 +67,19 @@ LL | struct T(pub i32, pub i32, ()); | help: add the attribute: `#[non_exhaustive] struct T` | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:56:32 + --> tests/ui/manual_non_exhaustive_struct.rs:56:32 | LL | struct T(pub i32, pub i32, ()); | ^^ error: this seems like a manual implementation of the non-exhaustive pattern - --> $DIR/manual_non_exhaustive_struct.rs:61:5 + --> tests/ui/manual_non_exhaustive_struct.rs:61:5 | LL | struct Tp(pub i32, pub i32, ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove this field - --> $DIR/manual_non_exhaustive_struct.rs:61:33 + --> tests/ui/manual_non_exhaustive_struct.rs:61:33 | LL | struct Tp(pub i32, pub i32, ()); | ^^ diff --git a/src/tools/clippy/tests/ui/manual_ok_or.stderr b/src/tools/clippy/tests/ui/manual_ok_or.stderr index 89df6cdbedbcc..2441a75b5c46e 100644 --- a/src/tools/clippy/tests/ui/manual_ok_or.stderr +++ b/src/tools/clippy/tests/ui/manual_ok_or.stderr @@ -1,5 +1,5 @@ error: this pattern reimplements `Option::ok_or` - --> $DIR/manual_ok_or.rs:11:5 + --> tests/ui/manual_ok_or.rs:11:5 | LL | foo.map_or(Err("error"), |v| Ok(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")` @@ -8,13 +8,13 @@ LL | foo.map_or(Err("error"), |v| Ok(v)); = 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 + --> tests/ui/manual_ok_or.rs:14:5 | LL | foo.map_or(Err("error"), Ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `foo.ok_or("error")` error: called `map_or(Err(_), Ok)` on an `Option` value - --> $DIR/manual_ok_or.rs:14:5 + --> tests/ui/manual_ok_or.rs:14:5 | LL | foo.map_or(Err("error"), Ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `ok_or`: `foo.ok_or("error")` @@ -23,13 +23,13 @@ LL | foo.map_or(Err("error"), Ok); = help: to override `-D warnings` add `#[allow(clippy::option_map_or_err_ok)]` error: this pattern reimplements `Option::ok_or` - --> $DIR/manual_ok_or.rs:17:5 + --> tests/ui/manual_ok_or.rs:17:5 | LL | None::.map_or(Err("error"), |v| Ok(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `None::.ok_or("error")` error: this pattern reimplements `Option::ok_or` - --> $DIR/manual_ok_or.rs:21:5 + --> tests/ui/manual_ok_or.rs:21:5 | LL | / foo.map_or(Err::( LL | | &format!( diff --git a/src/tools/clippy/tests/ui/manual_range_patterns.stderr b/src/tools/clippy/tests/ui/manual_range_patterns.stderr index fbeb9455769df..7c19fdd475f19 100644 --- a/src/tools/clippy/tests/ui/manual_range_patterns.stderr +++ b/src/tools/clippy/tests/ui/manual_range_patterns.stderr @@ -1,5 +1,5 @@ error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:8:25 + --> tests/ui/manual_range_patterns.rs:8:25 | LL | let _ = matches!(f, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` @@ -8,109 +8,109 @@ LL | let _ = matches!(f, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10); = 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 + --> tests/ui/manual_range_patterns.rs:9:25 | LL | let _ = matches!(f, 4 | 2 | 3 | 1 | 5 | 6 | 9 | 7 | 8 | 10); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:16:25 + --> tests/ui/manual_range_patterns.rs:16:25 | LL | let _ = matches!(f, 1 | (2..=4)); | ^^^^^^^^^^^ help: try: `1..=4` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:17:25 + --> tests/ui/manual_range_patterns.rs:17:25 | LL | let _ = matches!(f, 1 | (2..4)); | ^^^^^^^^^^ help: try: `1..4` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:18:25 + --> tests/ui/manual_range_patterns.rs:18:25 | LL | let _ = matches!(f, (1..=10) | (2..=13) | (14..=48324728) | 48324729); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=48324729` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:19:25 + --> tests/ui/manual_range_patterns.rs:19:25 | LL | let _ = matches!(f, 0 | (1..=10) | 48324730 | (2..=13) | (14..=48324728) | 48324729); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0..=48324730` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:20:25 + --> tests/ui/manual_range_patterns.rs:20:25 | LL | let _ = matches!(f, 0..=1 | 0..=2 | 0..=3); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `0..=3` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:23:9 + --> tests/ui/manual_range_patterns.rs:23:9 | LL | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => true, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:26:25 + --> tests/ui/manual_range_patterns.rs:26:25 | LL | let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1 | 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-5..=3` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:28:25 + --> tests/ui/manual_range_patterns.rs:28:25 | LL | let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_001); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-1_000_001..=1_000_001` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:31:17 + --> tests/ui/manual_range_patterns.rs:31:17 | LL | matches!(f, 0x00 | 0x01 | 0x02 | 0x03); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0x00..=0x03` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:32:17 + --> tests/ui/manual_range_patterns.rs:32:17 | LL | matches!(f, 0x00..=0x05 | 0x06 | 0x07); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0x00..=0x07` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:33:17 + --> tests/ui/manual_range_patterns.rs:33:17 | LL | matches!(f, -0x09 | -0x08 | -0x07..=0x00); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-0x09..=0x00` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:35:17 + --> tests/ui/manual_range_patterns.rs:35:17 | LL | matches!(f, 0..5 | 5); | ^^^^^^^^ help: try: `0..=5` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:36:17 + --> tests/ui/manual_range_patterns.rs:36:17 | LL | matches!(f, 0 | 1..5); | ^^^^^^^^ help: try: `0..5` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:38:17 + --> tests/ui/manual_range_patterns.rs:38:17 | LL | matches!(f, 0..=5 | 6..10); | ^^^^^^^^^^^^^ help: try: `0..10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:39:17 + --> tests/ui/manual_range_patterns.rs:39:17 | LL | matches!(f, 0..5 | 5..=10); | ^^^^^^^^^^^^^ help: try: `0..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:40:17 + --> tests/ui/manual_range_patterns.rs:40:17 | LL | matches!(f, 5..=10 | 0..5); | ^^^^^^^^^^^^^ help: try: `0..=10` error: this OR pattern can be rewritten using a range - --> $DIR/manual_range_patterns.rs:44:26 + --> tests/ui/manual_range_patterns.rs:44:26 | LL | matches!($e, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10` diff --git a/src/tools/clippy/tests/ui/manual_rem_euclid.stderr b/src/tools/clippy/tests/ui/manual_rem_euclid.stderr index f296f264665ca..a19fdadb1c9bd 100644 --- a/src/tools/clippy/tests/ui/manual_rem_euclid.stderr +++ b/src/tools/clippy/tests/ui/manual_rem_euclid.stderr @@ -1,5 +1,5 @@ error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:13:18 + --> tests/ui/manual_rem_euclid.rs:13:18 | LL | let _: i32 = ((value % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` @@ -8,31 +8,31 @@ LL | let _: i32 = ((value % 4) + 4) % 4; = help: to override `-D warnings` add `#[allow(clippy::manual_rem_euclid)]` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:14:18 + --> tests/ui/manual_rem_euclid.rs:14:18 | LL | let _: i32 = (4 + (value % 4)) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:15:18 + --> tests/ui/manual_rem_euclid.rs:15:18 | LL | let _: i32 = (value % 4 + 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:16:18 + --> tests/ui/manual_rem_euclid.rs:16:18 | LL | let _: i32 = (4 + value % 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:17:22 + --> tests/ui/manual_rem_euclid.rs:17:22 | LL | let _: i32 = 1 + (4 + value % 4) % 4; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:37:22 + --> tests/ui/manual_rem_euclid.rs:37:22 | LL | let _: i32 = ((value % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)` @@ -40,25 +40,25 @@ LL | let _: i32 = ((value % 4) + 4) % 4; = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:49:5 + --> tests/ui/manual_rem_euclid.rs:49:5 | LL | ((num % 4) + 4) % 4 | ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:54:5 + --> tests/ui/manual_rem_euclid.rs:54:5 | LL | ((num % 4) + 4) % 4 | ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:66:18 + --> tests/ui/manual_rem_euclid.rs:66:18 | LL | let _: i32 = ((x % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)` error: manual `rem_euclid` implementation - --> $DIR/manual_rem_euclid.rs:79:18 + --> tests/ui/manual_rem_euclid.rs:79:18 | LL | let _: i32 = ((x % 4) + 4) % 4; | ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)` diff --git a/src/tools/clippy/tests/ui/manual_retain.stderr b/src/tools/clippy/tests/ui/manual_retain.stderr index 2c872f3b430e8..c25c804df7581 100644 --- a/src/tools/clippy/tests/ui/manual_retain.stderr +++ b/src/tools/clippy/tests/ui/manual_retain.stderr @@ -1,5 +1,5 @@ error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:25:5 + --> tests/ui/manual_retain.rs:25:5 | 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)` @@ -8,43 +8,43 @@ LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect(); = help: to override `-D warnings` add `#[allow(clippy::manual_retain)]` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:26:5 + --> tests/ui/manual_retain.rs:26:5 | LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:27:5 + --> tests/ui/manual_retain.rs:27:5 | LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:31:5 + --> tests/ui/manual_retain.rs:31:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:32:5 + --> tests/ui/manual_retain.rs:32:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:62:5 + --> tests/ui/manual_retain.rs:62:5 | LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:63:5 + --> tests/ui/manual_retain.rs:63:5 | LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:64:5 + --> tests/ui/manual_retain.rs:64:5 | LL | / btree_map = btree_map LL | | .into_iter() @@ -53,49 +53,49 @@ LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:89:5 + --> tests/ui/manual_retain.rs:89:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:90:5 + --> tests/ui/manual_retain.rs:90:5 | LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:91:5 + --> tests/ui/manual_retain.rs:91:5 | LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:95:5 + --> tests/ui/manual_retain.rs:95:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:96:5 + --> tests/ui/manual_retain.rs:96:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:126:5 + --> tests/ui/manual_retain.rs:126:5 | LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:127:5 + --> tests/ui/manual_retain.rs:127:5 | LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:128:5 + --> tests/ui/manual_retain.rs:128:5 | LL | / hash_map = hash_map LL | | .into_iter() @@ -104,133 +104,133 @@ LL | | .collect(); | |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:152:5 + --> tests/ui/manual_retain.rs:152:5 | LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:153:5 + --> tests/ui/manual_retain.rs:153:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:154:5 + --> tests/ui/manual_retain.rs:154:5 | LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:158:5 + --> tests/ui/manual_retain.rs:158:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:159:5 + --> tests/ui/manual_retain.rs:159:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:188:5 + --> tests/ui/manual_retain.rs:188:5 | LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:200:5 + --> tests/ui/manual_retain.rs:200:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:201:5 + --> tests/ui/manual_retain.rs:201:5 | LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:202:5 + --> tests/ui/manual_retain.rs:202:5 | LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:206:5 + --> tests/ui/manual_retain.rs:206:5 | LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:207:5 + --> tests/ui/manual_retain.rs:207:5 | LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:229:5 + --> tests/ui/manual_retain.rs:229:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:230:5 + --> tests/ui/manual_retain.rs:230:5 | LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:231:5 + --> tests/ui/manual_retain.rs:231:5 | LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:288:5 + --> tests/ui/manual_retain.rs:288:5 | LL | vec = vec.into_iter().filter(|(x, y)| *x == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|(x, y)| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:292:5 + --> tests/ui/manual_retain.rs:292:5 | LL | tuples = tuples.into_iter().filter(|(_, n)| *n > 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(_, n)| *n > 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:309:5 + --> tests/ui/manual_retain.rs:309:5 | LL | vec = vec.iter().filter(|&&x| x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:310:5 + --> tests/ui/manual_retain.rs:310:5 | LL | vec = vec.iter().filter(|&&x| x == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:311:5 + --> tests/ui/manual_retain.rs:311:5 | LL | vec = vec.into_iter().filter(|&x| x == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:314:5 + --> tests/ui/manual_retain.rs:314:5 | LL | vec = vec.iter().filter(|&x| *x == 0).copied().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:315:5 + --> tests/ui/manual_retain.rs:315:5 | LL | vec = vec.iter().filter(|&x| *x == 0).cloned().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` error: this expression can be written more simply using `.retain()` - --> $DIR/manual_retain.rs:316:5 + --> tests/ui/manual_retain.rs:316:5 | LL | vec = vec.into_iter().filter(|x| *x == 0).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)` diff --git a/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr b/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr index 3ce108b1ca81e..b6a8df0f84e13 100644 --- a/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr +++ b/src/tools/clippy/tests/ui/manual_saturating_arithmetic.stderr @@ -1,5 +1,5 @@ error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:6:13 + --> tests/ui/manual_saturating_arithmetic.rs:6:13 | LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)` @@ -8,19 +8,19 @@ LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value()); = help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:7:13 + --> tests/ui/manual_saturating_arithmetic.rs:7:13 | LL | let _ = 1u32.checked_add(1).unwrap_or(u32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:8:13 + --> tests/ui/manual_saturating_arithmetic.rs:8:13 | LL | let _ = 1u8.checked_add(1).unwrap_or(255); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u8.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:9:13 + --> tests/ui/manual_saturating_arithmetic.rs:9:13 | LL | let _ = 1u128 | _____________^ @@ -29,49 +29,49 @@ LL | | .unwrap_or(340_282_366_920_938_463_463_374_607_431_768_211_455); | |_______________________________________________________________________^ help: consider using `saturating_add`: `1u128.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:14:13 + --> tests/ui/manual_saturating_arithmetic.rs:14:13 | LL | let _ = 1u32.checked_mul(1).unwrap_or(u32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_mul`: `1u32.saturating_mul(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:16:13 + --> tests/ui/manual_saturating_arithmetic.rs:16:13 | LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:17:13 + --> tests/ui/manual_saturating_arithmetic.rs:17:13 | LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:18:13 + --> tests/ui/manual_saturating_arithmetic.rs:18:13 | LL | let _ = 1u8.checked_sub(1).unwrap_or(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u8.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:22:13 + --> tests/ui/manual_saturating_arithmetic.rs:22:13 | LL | let _ = 1i32.checked_add(1).unwrap_or(i32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:23:13 + --> tests/ui/manual_saturating_arithmetic.rs:23:13 | LL | let _ = 1i32.checked_add(1).unwrap_or(i32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:24:13 + --> tests/ui/manual_saturating_arithmetic.rs:24:13 | LL | let _ = 1i8.checked_add(1).unwrap_or(127); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:25:13 + --> tests/ui/manual_saturating_arithmetic.rs:25:13 | LL | let _ = 1i128 | _____________^ @@ -80,25 +80,25 @@ LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727); | |_______________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:28:13 + --> tests/ui/manual_saturating_arithmetic.rs:28:13 | LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:29:13 + --> tests/ui/manual_saturating_arithmetic.rs:29:13 | LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:30:13 + --> tests/ui/manual_saturating_arithmetic.rs:30:13 | LL | let _ = 1i8.checked_add(-1).unwrap_or(-128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:31:13 + --> tests/ui/manual_saturating_arithmetic.rs:31:13 | LL | let _ = 1i128 | _____________^ @@ -107,25 +107,25 @@ LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); | |________________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:38:13 + --> tests/ui/manual_saturating_arithmetic.rs:38:13 | LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::min_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:39:13 + --> tests/ui/manual_saturating_arithmetic.rs:39:13 | LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:40:13 + --> tests/ui/manual_saturating_arithmetic.rs:40:13 | LL | let _ = 1i8.checked_sub(1).unwrap_or(-128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:41:13 + --> tests/ui/manual_saturating_arithmetic.rs:41:13 | LL | let _ = 1i128 | _____________^ @@ -134,25 +134,25 @@ LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); | |________________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:44:13 + --> tests/ui/manual_saturating_arithmetic.rs:44:13 | LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::max_value()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:45:13 + --> tests/ui/manual_saturating_arithmetic.rs:45:13 | LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:46:13 + --> tests/ui/manual_saturating_arithmetic.rs:46:13 | LL | let _ = 1i8.checked_sub(-1).unwrap_or(127); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(-1)` error: manual saturating arithmetic - --> $DIR/manual_saturating_arithmetic.rs:47:13 + --> tests/ui/manual_saturating_arithmetic.rs:47:13 | LL | let _ = 1i128 | _____________^ 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 ebdb748137a90..4bd8a4fdf17b7 100644 --- a/src/tools/clippy/tests/ui/manual_slice_size_calculation.stderr +++ b/src/tools/clippy/tests/ui/manual_slice_size_calculation.stderr @@ -1,5 +1,5 @@ error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:15:13 + --> tests/ui/manual_slice_size_calculation.rs:15:13 | LL | let _ = s_i32.len() * size_of::(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` @@ -8,37 +8,37 @@ LL | let _ = s_i32.len() * size_of::(); // WARNING = 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 + --> tests/ui/manual_slice_size_calculation.rs:16:13 | LL | let _ = size_of::() * s_i32.len(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:17:13 + --> tests/ui/manual_slice_size_calculation.rs:17:13 | LL | let _ = size_of::() * s_i32.len() * 5; // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:21:13 + --> tests/ui/manual_slice_size_calculation.rs:21:13 | LL | let _ = len * size_of::(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:22:13 + --> tests/ui/manual_slice_size_calculation.rs:22:13 | LL | let _ = s_i32.len() * size; // WARNING | ^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:23:13 + --> tests/ui/manual_slice_size_calculation.rs:23:13 | LL | let _ = len * size; // WARNING | ^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation - --> $DIR/manual_slice_size_calculation.rs:25:13 + --> tests/ui/manual_slice_size_calculation.rs:25:13 | LL | let _ = external!(&[1u64][..]).len() * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(external!(&[1u64][..]))` diff --git a/src/tools/clippy/tests/ui/manual_split_once.stderr b/src/tools/clippy/tests/ui/manual_split_once.stderr index 494a035edc3ab..b4e51f473cf4d 100644 --- a/src/tools/clippy/tests/ui/manual_split_once.stderr +++ b/src/tools/clippy/tests/ui/manual_split_once.stderr @@ -1,5 +1,5 @@ error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:11:13 + --> tests/ui/manual_split_once.rs:11:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` @@ -8,79 +8,79 @@ LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::manual_split_once)]` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:12:13 + --> tests/ui/manual_split_once.rs:12:13 | LL | let _ = "key=value".splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:13:18 + --> tests/ui/manual_split_once.rs:13:18 | LL | let (_, _) = "key=value".splitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=')` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:16:13 + --> tests/ui/manual_split_once.rs:16:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:19:13 + --> tests/ui/manual_split_once.rs:19:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:22:13 + --> tests/ui/manual_split_once.rs:22:13 | LL | let _ = s.splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:25:17 + --> tests/ui/manual_split_once.rs:25:17 | LL | let _ = s.splitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:26:17 + --> tests/ui/manual_split_once.rs:26:17 | LL | let _ = s.splitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:27:17 + --> tests/ui/manual_split_once.rs:27:17 | LL | let _ = s.rsplitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:28:17 + --> tests/ui/manual_split_once.rs:28:17 | LL | let _ = s.rsplitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:36:13 + --> tests/ui/manual_split_once.rs:36:13 | LL | let _ = "key=value".rsplitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').unwrap().0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:37:18 + --> tests/ui/manual_split_once.rs:37:18 | LL | let (_, _) = "key=value".rsplitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').map(|(x, y)| (y, x))` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:38:13 + --> tests/ui/manual_split_once.rs:38:13 | LL | let _ = s.rsplitn(2, '=').nth(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=').map(|x| x.0)` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:42:5 + --> tests/ui/manual_split_once.rs:42:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL + | error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:46:5 + --> tests/ui/manual_split_once.rs:46:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL + | error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:50:5 + --> tests/ui/manual_split_once.rs:50:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + | error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:54:5 + --> tests/ui/manual_split_once.rs:54:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -180,13 +180,13 @@ LL + | error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:139:13 + --> tests/ui/manual_split_once.rs:139:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:141:5 + --> tests/ui/manual_split_once.rs:141:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/manual_str_repeat.fixed b/src/tools/clippy/tests/ui/manual_str_repeat.fixed index 888a466278ccc..5f2f1bd9916d8 100644 --- a/src/tools/clippy/tests/ui/manual_str_repeat.fixed +++ b/src/tools/clippy/tests/ui/manual_str_repeat.fixed @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::manual_str_repeat)] use std::borrow::Cow; diff --git a/src/tools/clippy/tests/ui/manual_str_repeat.rs b/src/tools/clippy/tests/ui/manual_str_repeat.rs index a366351ffa45a..3e3c7f4db4a27 100644 --- a/src/tools/clippy/tests/ui/manual_str_repeat.rs +++ b/src/tools/clippy/tests/ui/manual_str_repeat.rs @@ -1,3 +1,4 @@ +#![allow(non_local_definitions)] #![warn(clippy::manual_str_repeat)] use std::borrow::Cow; diff --git a/src/tools/clippy/tests/ui/manual_str_repeat.stderr b/src/tools/clippy/tests/ui/manual_str_repeat.stderr index 9a13aa9722737..d4f8786fb5f10 100644 --- a/src/tools/clippy/tests/ui/manual_str_repeat.stderr +++ b/src/tools/clippy/tests/ui/manual_str_repeat.stderr @@ -1,5 +1,5 @@ error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:7:21 + --> tests/ui/manual_str_repeat.rs:8:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)` @@ -8,55 +8,55 @@ LL | let _: String = std::iter::repeat("test").take(10).collect(); = 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 + --> tests/ui/manual_str_repeat.rs:9:21 | LL | let _: String = std::iter::repeat('x').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"x".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:9:21 + --> tests/ui/manual_str_repeat.rs:10:21 | LL | let _: String = std::iter::repeat('\'').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"'".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:10:21 + --> tests/ui/manual_str_repeat.rs:11:21 | LL | let _: String = std::iter::repeat('"').take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"\"".repeat(10)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:14:13 + --> tests/ui/manual_str_repeat.rs:15:13 | LL | let _ = repeat(x).take(count + 2).collect::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count + 2)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:23:21 + --> tests/ui/manual_str_repeat.rs:24:21 | LL | let _: String = repeat(*x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*x).repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:32:21 + --> tests/ui/manual_str_repeat.rs:33:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:44:21 + --> tests/ui/manual_str_repeat.rs:45:21 | LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Cow::Borrowed("test").repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:47:21 + --> tests/ui/manual_str_repeat.rs:48:21 | LL | let _: String = repeat(x).take(count).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)` error: manual implementation of `str::repeat` using iterators - --> $DIR/manual_str_repeat.rs:62:21 + --> tests/ui/manual_str_repeat.rs:63:21 | LL | let _: String = std::iter::repeat("test").take(10).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)` diff --git a/src/tools/clippy/tests/ui/manual_string_new.stderr b/src/tools/clippy/tests/ui/manual_string_new.stderr index cb2d78c39ed15..6b434f405d31c 100644 --- a/src/tools/clippy/tests/ui/manual_string_new.stderr +++ b/src/tools/clippy/tests/ui/manual_string_new.stderr @@ -1,5 +1,5 @@ error: empty String is being created manually - --> $DIR/manual_string_new.rs:14:13 + --> tests/ui/manual_string_new.rs:14:13 | LL | let _ = "".to_string(); | ^^^^^^^^^^^^^^ help: consider using: `String::new()` @@ -8,49 +8,49 @@ LL | let _ = "".to_string(); = help: to override `-D warnings` add `#[allow(clippy::manual_string_new)]` error: empty String is being created manually - --> $DIR/manual_string_new.rs:17:13 + --> tests/ui/manual_string_new.rs:17:13 | LL | let _ = "".to_owned(); | ^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:20:21 + --> tests/ui/manual_string_new.rs:20:21 | LL | let _: String = "".into(); | ^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:27:13 + --> tests/ui/manual_string_new.rs:27:13 | LL | let _ = String::from(""); | ^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:28:13 + --> tests/ui/manual_string_new.rs:28:13 | LL | let _ = ::from(""); | ^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:33:13 + --> tests/ui/manual_string_new.rs:33:13 | LL | let _ = String::try_from("").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:39:21 + --> tests/ui/manual_string_new.rs:39:21 | LL | let _: String = From::from(""); | ^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:44:21 + --> tests/ui/manual_string_new.rs:44:21 | LL | let _: String = TryFrom::try_from("").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` error: empty String is being created manually - --> $DIR/manual_string_new.rs:47:21 + --> tests/ui/manual_string_new.rs:47:21 | LL | let _: String = TryFrom::try_from("").expect("this should warn"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()` diff --git a/src/tools/clippy/tests/ui/manual_strip.stderr b/src/tools/clippy/tests/ui/manual_strip.stderr index 0bf6975b1e363..d2d4f765310b9 100644 --- a/src/tools/clippy/tests/ui/manual_strip.stderr +++ b/src/tools/clippy/tests/ui/manual_strip.stderr @@ -1,11 +1,11 @@ error: stripping a prefix manually - --> $DIR/manual_strip.rs:7:24 + --> tests/ui/manual_strip.rs:7:24 | LL | str::to_string(&s["ab".len()..]); | ^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:6:5 + --> tests/ui/manual_strip.rs:6:5 | LL | if s.starts_with("ab") { | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,13 +23,13 @@ LL ~ .to_string(); | error: stripping a suffix manually - --> $DIR/manual_strip.rs:16:24 + --> tests/ui/manual_strip.rs:16:24 | LL | str::to_string(&s[..s.len() - "bc".len()]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the suffix was tested here - --> $DIR/manual_strip.rs:15:5 + --> tests/ui/manual_strip.rs:15:5 | LL | if s.ends_with("bc") { | ^^^^^^^^^^^^^^^^^^^^^ @@ -45,13 +45,13 @@ LL ~ .to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:26:24 + --> tests/ui/manual_strip.rs:26:24 | LL | str::to_string(&s[1..]); | ^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:25:5 + --> tests/ui/manual_strip.rs:25:5 | LL | if s.starts_with('a') { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -64,13 +64,13 @@ LL ~ .to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:34:24 + --> tests/ui/manual_strip.rs:34:24 | LL | str::to_string(&s[prefix.len()..]); | ^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:33:5 + --> tests/ui/manual_strip.rs:33:5 | LL | if s.starts_with(prefix) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,13 +81,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:41:24 + --> tests/ui/manual_strip.rs:41:24 | LL | str::to_string(&s[PREFIX.len()..]); | ^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:40:5 + --> tests/ui/manual_strip.rs:40:5 | LL | if s.starts_with(PREFIX) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,13 +100,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:49:24 + --> tests/ui/manual_strip.rs:49:24 | LL | str::to_string(&TARGET[prefix.len()..]); | ^^^^^^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:48:5 + --> tests/ui/manual_strip.rs:48:5 | LL | if TARGET.starts_with(prefix) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -117,13 +117,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:56:9 + --> tests/ui/manual_strip.rs:56:9 | LL | s1[2..].to_uppercase(); | ^^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:55:5 + --> tests/ui/manual_strip.rs:55:5 | LL | if s1.starts_with("ab") { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -134,13 +134,13 @@ LL ~ .to_uppercase(); | error: stripping a prefix manually - --> $DIR/manual_strip.rs:87:9 + --> tests/ui/manual_strip.rs:87:9 | LL | s[1..].to_string(); | ^^^^^^ | note: the prefix was tested here - --> $DIR/manual_strip.rs:86:5 + --> tests/ui/manual_strip.rs:86:5 | LL | if s.starts_with('a') { | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/manual_try_fold.stderr b/src/tools/clippy/tests/ui/manual_try_fold.stderr index 4eb3e302b2143..bc075e87d71f5 100644 --- a/src/tools/clippy/tests/ui/manual_try_fold.stderr +++ b/src/tools/clippy/tests/ui/manual_try_fold.stderr @@ -1,5 +1,5 @@ error: usage of `Iterator::fold` on a type that implements `Try` - --> $DIR/manual_try_fold.rs:59:10 + --> tests/ui/manual_try_fold.rs:59:10 | LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` @@ -8,19 +8,19 @@ LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) = 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 + --> tests/ui/manual_try_fold.rs:63:10 | LL | .fold(NotOption(0i32, 0i32), |sum, i| NotOption(0i32, 0i32)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(..., |sum, i| ...)` error: usage of `Iterator::fold` on a type that implements `Try` - --> $DIR/manual_try_fold.rs:66:10 + --> tests/ui/manual_try_fold.rs:66:10 | LL | .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` error: usage of `Iterator::fold` on a type that implements `Try` - --> $DIR/manual_try_fold.rs:96:10 + --> tests/ui/manual_try_fold.rs:96:10 | LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` diff --git a/src/tools/clippy/tests/ui/manual_unwrap_or.stderr b/src/tools/clippy/tests/ui/manual_unwrap_or.stderr index 3a0759dccaf20..511b79881ac3f 100644 --- a/src/tools/clippy/tests/ui/manual_unwrap_or.stderr +++ b/src/tools/clippy/tests/ui/manual_unwrap_or.stderr @@ -1,5 +1,5 @@ error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:6:5 + --> tests/ui/manual_unwrap_or.rs:6:5 | LL | / match Some(1) { LL | | Some(i) => i, @@ -11,7 +11,7 @@ LL | | }; = 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 + --> tests/ui/manual_unwrap_or.rs:12:5 | LL | / match Some(1) { LL | | None => 42, @@ -20,7 +20,7 @@ LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(42)` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:18:5 + --> tests/ui/manual_unwrap_or.rs:18:5 | LL | / match Some(1) { LL | | Some(i) => i, @@ -29,7 +29,7 @@ LL | | }; | |_____^ help: replace with: `Some(1).unwrap_or(1 + 42)` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:25:5 + --> tests/ui/manual_unwrap_or.rs:25:5 | LL | / match Some(1) { LL | | Some(i) => i, @@ -50,7 +50,7 @@ LL ~ }); | error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:35:5 + --> tests/ui/manual_unwrap_or.rs:35:5 | LL | / match Some("Bob") { LL | | Some(i) => i, @@ -59,7 +59,7 @@ LL | | }; | |_____^ help: replace with: `Some("Bob").unwrap_or("Alice")` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:85:5 + --> tests/ui/manual_unwrap_or.rs:85:5 | LL | / match Ok::(1) { LL | | Ok(i) => i, @@ -68,7 +68,7 @@ LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:92:5 + --> tests/ui/manual_unwrap_or.rs:92:5 | LL | / match a { LL | | Ok(i) => i, @@ -77,7 +77,7 @@ LL | | }; | |_____^ help: replace with: `a.unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:98:5 + --> tests/ui/manual_unwrap_or.rs:98:5 | LL | / match Ok(1) as Result { LL | | Ok(i) => i, @@ -86,7 +86,7 @@ LL | | }; | |_____^ help: replace with: `(Ok(1) as Result).unwrap_or(42)` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:111:5 + --> tests/ui/manual_unwrap_or.rs:111:5 | LL | / match s.method() { LL | | Some(i) => i, @@ -95,7 +95,7 @@ LL | | }; | |_____^ help: replace with: `s.method().unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:117:5 + --> tests/ui/manual_unwrap_or.rs:117:5 | LL | / match Ok::(1) { LL | | Err(_) => 42, @@ -104,7 +104,7 @@ LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:123:5 + --> tests/ui/manual_unwrap_or.rs:123:5 | LL | / match Ok::(1) { LL | | Ok(i) => i, @@ -113,7 +113,7 @@ LL | | }; | |_____^ help: replace with: `Ok::(1).unwrap_or(1 + 42)` error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:130:5 + --> tests/ui/manual_unwrap_or.rs:130:5 | LL | / match Ok::(1) { LL | | Ok(i) => i, @@ -134,7 +134,7 @@ LL ~ }); | error: this pattern reimplements `Result::unwrap_or` - --> $DIR/manual_unwrap_or.rs:140:5 + --> tests/ui/manual_unwrap_or.rs:140:5 | LL | / match Ok::<&str, &str>("Bob") { LL | | Ok(i) => i, @@ -143,7 +143,7 @@ LL | | }; | |_____^ help: replace with: `Ok::<&str, &str>("Bob").unwrap_or("Alice")` error: this pattern reimplements `Option::unwrap_or` - --> $DIR/manual_unwrap_or.rs:200:17 + --> tests/ui/manual_unwrap_or.rs:200:17 | LL | let _ = match some_macro!() { | _________________^ 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 37387c8c320f2..8d444b80aaffa 100644 --- a/src/tools/clippy/tests/ui/manual_while_let_some.stderr +++ b/src/tools/clippy/tests/ui/manual_while_let_some.stderr @@ -1,5 +1,5 @@ error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:21:9 + --> tests/ui/manual_while_let_some.rs:21:9 | LL | let number = numbers.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL ~ | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:29:9 + --> tests/ui/manual_while_let_some.rs:29:9 | LL | let number = val.numbers.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL ~ | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:33:20 + --> tests/ui/manual_while_let_some.rs:33:20 | LL | accept_i32(numbers.pop().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL ~ accept_i32(element); | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:37:20 + --> tests/ui/manual_while_let_some.rs:37:20 | LL | accept_i32(numbers.pop().expect("")); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL ~ accept_i32(element); | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:80:9 + --> tests/ui/manual_while_let_some.rs:80:9 | LL | let (a, b) = numbers.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL ~ | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:84:26 + --> tests/ui/manual_while_let_some.rs:84:26 | LL | accept_i32_tuple(numbers.pop().unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL ~ accept_i32_tuple(element); | error: you seem to be trying to pop elements from a `Vec` in a loop - --> $DIR/manual_while_let_some.rs:89:9 + --> tests/ui/manual_while_let_some.rs:89:9 | LL | let Foo { a, b } = results.pop().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 688158cff6b03..131836ef7c882 100644 --- a/src/tools/clippy/tests/ui/many_single_char_names.stderr +++ b/src/tools/clippy/tests/ui/many_single_char_names.stderr @@ -1,5 +1,5 @@ error: 5 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:5:9 + --> tests/ui/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -14,7 +14,7 @@ LL | let e: i32; = 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 + --> tests/ui/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -28,7 +28,7 @@ LL | let f: i32; | ^ error: 5 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:5:9 + --> tests/ui/many_single_char_names.rs:5:9 | LL | let a: i32; | ^ @@ -40,13 +40,13 @@ LL | e => panic!(), | ^ error: 8 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:34:13 + --> tests/ui/many_single_char_names.rs:34:13 | LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} | ^ ^ ^ ^ ^ ^ ^ ^ error: 8 bindings with single-character names in scope - --> $DIR/many_single_char_names.rs:38:10 + --> tests/ui/many_single_char_names.rs:38:10 | LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!(); | ^ ^ ^ ^ ^ ^ ^ ^ diff --git a/src/tools/clippy/tests/ui/map_clone.stderr b/src/tools/clippy/tests/ui/map_clone.stderr index 2c86a67fab8d6..1a26a26a4cacb 100644 --- a/src/tools/clippy/tests/ui/map_clone.stderr +++ b/src/tools/clippy/tests/ui/map_clone.stderr @@ -1,5 +1,5 @@ error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:13:22 + --> tests/ui/map_clone.rs:13:22 | 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()` @@ -8,85 +8,85 @@ LL | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); = help: to override `-D warnings` add `#[allow(clippy::map_clone)]` error: you are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:14:26 + --> tests/ui/map_clone.rs:14:26 | LL | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()` error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:15:23 + --> tests/ui/map_clone.rs:15:23 | LL | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![42, 43].iter().copied()` error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:17:26 + --> tests/ui/map_clone.rs:17:26 | LL | let _: Option = Some(&16).map(|b| *b); | ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&16).copied()` error: you are using an explicit closure for copying elements - --> $DIR/map_clone.rs:18:25 + --> tests/ui/map_clone.rs:18:25 | LL | let _: Option = Some(&1).map(|x| x.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&1).copied()` error: you are needlessly cloning iterator elements - --> $DIR/map_clone.rs:29:29 + --> tests/ui/map_clone.rs:29:29 | LL | let _ = std::env::args().map(|v| v.clone()); | ^^^^^^^^^^^^^^^^^^^ help: remove the `map` call error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:68:13 + --> tests/ui/map_clone.rs:68:13 | LL | let y = x.map(|x| String::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:70:13 + --> tests/ui/map_clone.rs:70:13 | LL | let y = x.map(Clone::clone); | ^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:73:13 + --> tests/ui/map_clone.rs:73:13 | LL | let y = x.map(String::clone); | ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:79:13 + --> tests/ui/map_clone.rs:79:13 | LL | let y = x.map(|x| u32::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:82:13 + --> tests/ui/map_clone.rs:82:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:94:13 + --> tests/ui/map_clone.rs:94:13 | LL | let y = x.map(|x| String::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:97:13 + --> tests/ui/map_clone.rs:97:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:103:13 + --> tests/ui/map_clone.rs:103:13 | LL | let y = x.map(|x| u32::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> $DIR/map_clone.rs:106:13 + --> tests/ui/map_clone.rs:106:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` 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 1a505d4cecc32..8d147340e16aa 100644 --- a/src/tools/clippy/tests/ui/map_collect_result_unit.stderr +++ b/src/tools/clippy/tests/ui/map_collect_result_unit.stderr @@ -1,5 +1,5 @@ error: `.map().collect()` can be replaced with `.try_for_each()` - --> $DIR/map_collect_result_unit.rs:5:17 + --> tests/ui/map_collect_result_unit.rs:5:17 | LL | let _ = (0..3).map(|t| Err(t + 1)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(0..3).try_for_each(|t| Err(t + 1))` @@ -8,7 +8,7 @@ LL | let _ = (0..3).map(|t| Err(t + 1)).collect::>(); = 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 + --> tests/ui/map_collect_result_unit.rs:6:32 | LL | let _: Result<(), _> = (0..3).map(|t| Err(t + 1)).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(0..3).try_for_each(|t| Err(t + 1))` diff --git a/src/tools/clippy/tests/ui/map_err.stderr b/src/tools/clippy/tests/ui/map_err.stderr index eb6742ff23382..702c5e9783a4d 100644 --- a/src/tools/clippy/tests/ui/map_err.stderr +++ b/src/tools/clippy/tests/ui/map_err.stderr @@ -1,5 +1,5 @@ error: `map_err(|_|...` wildcard pattern discards the original error - --> $DIR/map_err.rs:22:32 + --> tests/ui/map_err.rs:22:32 | LL | println!("{:?}", x.map_err(|_| Errors::Ignored)); | ^^^ diff --git a/src/tools/clippy/tests/ui/map_flatten.stderr b/src/tools/clippy/tests/ui/map_flatten.stderr index a65d8f75ddd2a..a5837b97617db 100644 --- a/src/tools/clippy/tests/ui/map_flatten.stderr +++ b/src/tools/clippy/tests/ui/map_flatten.stderr @@ -1,5 +1,5 @@ error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten.rs:8:10 + --> tests/ui/map_flatten.rs:8:10 | LL | .map(|x| { | __________^ @@ -27,7 +27,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Result` - --> $DIR/map_flatten.rs:20:10 + --> tests/ui/map_flatten.rs:20:10 | LL | .map(|x| { | __________^ @@ -52,7 +52,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Result` - --> $DIR/map_flatten.rs:33:10 + --> tests/ui/map_flatten.rs:33:10 | LL | .map(|res| { | __________^ @@ -78,7 +78,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten.rs:46:10 + --> tests/ui/map_flatten.rs:46:10 | LL | .map(|some_value| { | __________^ diff --git a/src/tools/clippy/tests/ui/map_flatten_fixable.stderr b/src/tools/clippy/tests/ui/map_flatten_fixable.stderr index e5387eead2e0c..128c95146aa2c 100644 --- a/src/tools/clippy/tests/ui/map_flatten_fixable.stderr +++ b/src/tools/clippy/tests/ui/map_flatten_fixable.stderr @@ -1,5 +1,5 @@ error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:16:47 + --> tests/ui/map_flatten_fixable.rs:16:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)` @@ -8,43 +8,43 @@ LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().coll = help: to override `-D warnings` add `#[allow(clippy::map_flatten)]` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:17:47 + --> tests/ui/map_flatten_fixable.rs:17:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:18:47 + --> tests/ui/map_flatten_fixable.rs:18:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:19:47 + --> tests/ui/map_flatten_fixable.rs:19:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:22:47 + --> tests/ui/map_flatten_fixable.rs:22:47 | LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)` error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten_fixable.rs:25:40 + --> tests/ui/map_flatten_fixable.rs:25:40 | LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` error: called `map(..).flatten()` on `Result` - --> $DIR/map_flatten_fixable.rs:28:42 + --> tests/ui/map_flatten_fixable.rs:28:42 | LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten(); | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)` error: called `map(..).flatten()` on `Iterator` - --> $DIR/map_flatten_fixable.rs:37:10 + --> tests/ui/map_flatten_fixable.rs:37:10 | LL | .map(|n| match n { | __________^ @@ -73,7 +73,7 @@ LL ~ }); | error: called `map(..).flatten()` on `Option` - --> $DIR/map_flatten_fixable.rs:57:10 + --> tests/ui/map_flatten_fixable.rs:57:10 | LL | .map(|_| { | __________^ diff --git a/src/tools/clippy/tests/ui/map_identity.stderr b/src/tools/clippy/tests/ui/map_identity.stderr index ea077d66d6401..0a0dc9c8f075b 100644 --- a/src/tools/clippy/tests/ui/map_identity.stderr +++ b/src/tools/clippy/tests/ui/map_identity.stderr @@ -1,5 +1,5 @@ error: unnecessary map of the identity function - --> $DIR/map_identity.rs:7:47 + --> tests/ui/map_identity.rs:7:47 | LL | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect(); | ^^^^^^^^^^^^^^^^^^ help: remove the call to `map` @@ -8,25 +8,25 @@ LL | let _: Vec<_> = x.iter().map(not_identity).map(|x| return x).collect(); = help: to override `-D warnings` add `#[allow(clippy::map_identity)]` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:8:57 + --> tests/ui/map_identity.rs:8:57 | LL | let _: Vec<_> = x.iter().map(std::convert::identity).map(|y| y).collect(); | ^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:8:29 + --> tests/ui/map_identity.rs:8:29 | LL | let _: Vec<_> = x.iter().map(std::convert::identity).map(|y| y).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:9:32 + --> tests/ui/map_identity.rs:9:32 | LL | let _: Option = Some(3).map(|x| x); | ^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:10:36 + --> tests/ui/map_identity.rs:10:36 | LL | let _: Result = Ok(-3).map(|x| { | ____________________________________^ @@ -35,19 +35,19 @@ LL | | }); | |______^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:20:36 + --> tests/ui/map_identity.rs:20:36 | LL | let _: Result = Ok(1).map_err(|a| a); | ^^^^^^^^^^^^^^^ help: remove the call to `map_err` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:30:22 + --> tests/ui/map_identity.rs:30:22 | LL | let _ = x.clone().map(|(x, y)| (x, y)); | ^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:31:22 + --> tests/ui/map_identity.rs:31:22 | LL | let _ = x.clone().map(|(x, y)| { | ______________________^ @@ -56,19 +56,19 @@ LL | | }); | |______^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:34:22 + --> tests/ui/map_identity.rs:34:22 | LL | let _ = x.clone().map(|(x, y)| return (x, y)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:37:22 + --> tests/ui/map_identity.rs:37:22 | LL | let _ = y.clone().map(|(x, y, (z, (w,)))| (x, y, (z, (w,)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` error: unnecessary map of the identity function - --> $DIR/map_identity.rs:66:30 + --> tests/ui/map_identity.rs:66:30 | LL | let _ = x.iter().copied().map(|(x, y)| (x, y)); | ^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `map` diff --git a/src/tools/clippy/tests/ui/map_unwrap_or.stderr b/src/tools/clippy/tests/ui/map_unwrap_or.stderr index 54ddd1402e3df..d6ddd09c188c6 100644 --- a/src/tools/clippy/tests/ui/map_unwrap_or.stderr +++ b/src/tools/clippy/tests/ui/map_unwrap_or.stderr @@ -1,5 +1,5 @@ error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:17:13 + --> tests/ui/map_unwrap_or.rs:17:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -16,7 +16,7 @@ LL + let _ = opt.map_or(0, |x| x + 1); | error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:21:13 + --> tests/ui/map_unwrap_or.rs:21:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -34,7 +34,7 @@ LL ~ ); | error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:25:13 + --> tests/ui/map_unwrap_or.rs:25:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -51,7 +51,7 @@ LL ~ }, |x| x + 1); | error: called `map().unwrap_or(None)` on an `Option` value - --> $DIR/map_unwrap_or.rs:30:13 + --> tests/ui/map_unwrap_or.rs:30:13 | LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ LL + let _ = opt.and_then(|x| Some(x + 1)); | error: called `map().unwrap_or(None)` on an `Option` value - --> $DIR/map_unwrap_or.rs:32:13 + --> tests/ui/map_unwrap_or.rs:32:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -81,7 +81,7 @@ LL ~ ); | error: called `map().unwrap_or(None)` on an `Option` value - --> $DIR/map_unwrap_or.rs:36:13 + --> tests/ui/map_unwrap_or.rs:36:13 | LL | let _ = opt | _____________^ @@ -96,7 +96,7 @@ LL + .and_then(|x| Some(x + 1)); | error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:47:13 + --> tests/ui/map_unwrap_or.rs:47:13 | LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p)); | error: called `map().unwrap_or_else()` on an `Option` value - --> $DIR/map_unwrap_or.rs:51:13 + --> tests/ui/map_unwrap_or.rs:51:13 | LL | let _ = opt.map(|x| { | _____________^ @@ -118,7 +118,7 @@ LL | | ).unwrap_or_else(|| 0); | |__________________________^ error: called `map().unwrap_or_else()` on an `Option` value - --> $DIR/map_unwrap_or.rs:55:13 + --> tests/ui/map_unwrap_or.rs:55:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -128,7 +128,7 @@ LL | | ); | |_________^ error: called `map().unwrap_or(false)` on an `Option` value - --> $DIR/map_unwrap_or.rs:61:13 + --> tests/ui/map_unwrap_or.rs:61:13 | LL | let _ = opt.map(|x| x > 5).unwrap_or(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -140,7 +140,7 @@ LL + let _ = opt.is_some_and(|x| x > 5); | error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or.rs:71:13 + --> tests/ui/map_unwrap_or.rs:71:13 | LL | let _ = res.map(|x| { | _____________^ @@ -150,7 +150,7 @@ LL | | ).unwrap_or_else(|_e| 0); | |____________________________^ error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or.rs:75:13 + --> tests/ui/map_unwrap_or.rs:75:13 | LL | let _ = res.map(|x| x + 1) | _____________^ @@ -160,13 +160,13 @@ LL | | }); | |__________^ error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or.rs:99:13 + --> tests/ui/map_unwrap_or.rs:99:13 | LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or_else(|_e| 0, |x| x + 1)` error: called `map().unwrap_or()` on an `Option` value - --> $DIR/map_unwrap_or.rs:106:13 + --> tests/ui/map_unwrap_or.rs:106:13 | LL | let _ = opt.map(|x| x > 5).unwrap_or(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +178,7 @@ LL + let _ = opt.map_or(false, |x| x > 5); | error: called `map().unwrap_or(false)` on an `Option` value - --> $DIR/map_unwrap_or.rs:113:13 + --> tests/ui/map_unwrap_or.rs:113:13 | LL | let _ = opt.map(|x| x > 5).unwrap_or(false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 d1a9fdd6ecffd..89a7c979f6e92 100644 --- a/src/tools/clippy/tests/ui/map_unwrap_or_fixable.stderr +++ b/src/tools/clippy/tests/ui/map_unwrap_or_fixable.stderr @@ -1,5 +1,5 @@ error: called `map().unwrap_or_else()` on an `Option` value - --> $DIR/map_unwrap_or_fixable.rs:16:13 + --> tests/ui/map_unwrap_or_fixable.rs:16:13 | LL | let _ = opt.map(|x| x + 1) | _____________^ @@ -11,7 +11,7 @@ LL | | .unwrap_or_else(|| 0); = help: to override `-D warnings` add `#[allow(clippy::map_unwrap_or)]` error: called `map().unwrap_or_else()` on a `Result` value - --> $DIR/map_unwrap_or_fixable.rs:46:13 + --> tests/ui/map_unwrap_or_fixable.rs:46:13 | LL | let _ = res.map(|x| x + 1) | _____________^ diff --git a/src/tools/clippy/tests/ui/match_as_ref.stderr b/src/tools/clippy/tests/ui/match_as_ref.stderr index cb0191370eaa0..97b121424d932 100644 --- a/src/tools/clippy/tests/ui/match_as_ref.stderr +++ b/src/tools/clippy/tests/ui/match_as_ref.stderr @@ -1,5 +1,5 @@ error: use `as_ref()` instead - --> $DIR/match_as_ref.rs:6:33 + --> tests/ui/match_as_ref.rs:6:33 | LL | let borrowed: Option<&()> = match owned { | _________________________________^ @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::match_as_ref)]` error: use `as_mut()` instead - --> $DIR/match_as_ref.rs:12:39 + --> tests/ui/match_as_ref.rs:12:39 | LL | let borrow_mut: Option<&mut ()> = match mut_owned { | _______________________________________^ @@ -22,7 +22,7 @@ LL | | }; | |_____^ help: try: `mut_owned.as_mut()` error: use `as_ref()` instead - --> $DIR/match_as_ref.rs:30:13 + --> tests/ui/match_as_ref.rs:30:13 | LL | / match self.source { LL | | Some(ref s) => Some(s), diff --git a/src/tools/clippy/tests/ui/match_bool.stderr b/src/tools/clippy/tests/ui/match_bool.stderr index 369f4e1c6fab3..1303e082daf2f 100644 --- a/src/tools/clippy/tests/ui/match_bool.stderr +++ b/src/tools/clippy/tests/ui/match_bool.stderr @@ -1,5 +1,5 @@ error: this boolean expression can be simplified - --> $DIR/match_bool.rs:36:11 + --> tests/ui/match_bool.rs:36:11 | LL | match test && test { | ^^^^^^^^^^^^ help: try: `test` @@ -8,7 +8,7 @@ LL | match test && test { = 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 + --> tests/ui/match_bool.rs:7:5 | LL | / match test { LL | | @@ -18,13 +18,13 @@ LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if test { 0 } else { 42 }` | note: the lint level is defined here - --> $DIR/match_bool.rs:2:9 + --> tests/ui/match_bool.rs:2:9 | LL | #![deny(clippy::match_bool)] | ^^^^^^^^^^^^^^^^^^ error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:14:5 + --> tests/ui/match_bool.rs:14:5 | LL | / match option == 1 { LL | | @@ -34,7 +34,7 @@ LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if option == 1 { 1 } else { 0 }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:20:5 + --> tests/ui/match_bool.rs:20:5 | LL | / match test { LL | | @@ -53,7 +53,7 @@ LL ~ }; | error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:28:5 + --> tests/ui/match_bool.rs:28:5 | LL | / match test { LL | | @@ -72,7 +72,7 @@ LL ~ }; | error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:36:5 + --> tests/ui/match_bool.rs:36:5 | LL | / match test && test { LL | | @@ -91,7 +91,7 @@ LL ~ }; | error: equal expressions as operands to `&&` - --> $DIR/match_bool.rs:36:11 + --> tests/ui/match_bool.rs:36:11 | LL | match test && test { | ^^^^^^^^^^^^ @@ -99,7 +99,7 @@ LL | match test && test { = note: `#[deny(clippy::eq_op)]` on by default error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:48:5 + --> tests/ui/match_bool.rs:48:5 | LL | / match test { LL | | 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 c702523783e73..201b977e558eb 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 @@ -1,5 +1,5 @@ error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:14:14 + --> tests/ui/match_expr_like_matches_macro.rs:14:14 | LL | let _y = match x { | ______________^ @@ -12,7 +12,7 @@ LL | | }; = 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 + --> tests/ui/match_expr_like_matches_macro.rs:20:14 | LL | let _w = match x { | ______________^ @@ -25,7 +25,7 @@ LL | | }; = 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 + --> tests/ui/match_expr_like_matches_macro.rs:26:14 | LL | let _z = match x { | ______________^ @@ -35,7 +35,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:32:15 + --> tests/ui/match_expr_like_matches_macro.rs:32:15 | LL | let _zz = match x { | _______________^ @@ -45,13 +45,13 @@ LL | | }; | |_____^ help: try: `!matches!(x, Some(r) if r == 0)` error: if let .. else expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:38:16 + --> tests/ui/match_expr_like_matches_macro.rs:38:16 | LL | let _zzz = if let Some(5) = x { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(x, Some(5))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:62:20 + --> tests/ui/match_expr_like_matches_macro.rs:62:20 | LL | let _ans = match x { | ____________________^ @@ -62,7 +62,7 @@ LL | | }; | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:72:20 + --> tests/ui/match_expr_like_matches_macro.rs:72:20 | LL | let _ans = match x { | ____________________^ @@ -75,7 +75,7 @@ LL | | }; | |_________^ help: try: `matches!(x, E::A(_) | E::B(_))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:82:20 + --> tests/ui/match_expr_like_matches_macro.rs:82:20 | LL | let _ans = match x { | ____________________^ @@ -86,7 +86,7 @@ LL | | }; | |_________^ help: try: `!matches!(x, E::B(_) | E::C)` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:142:18 + --> tests/ui/match_expr_like_matches_macro.rs:142:18 | LL | let _z = match &z { | __________________^ @@ -96,7 +96,7 @@ LL | | }; | |_________^ help: try: `matches!(z, Some(3))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:151:18 + --> tests/ui/match_expr_like_matches_macro.rs:151:18 | LL | let _z = match &z { | __________________^ @@ -106,7 +106,7 @@ LL | | }; | |_________^ help: try: `matches!(&z, Some(3))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:168:21 + --> tests/ui/match_expr_like_matches_macro.rs:168:21 | LL | let _ = match &z { | _____________________^ @@ -116,7 +116,7 @@ LL | | }; | |_____________^ help: try: `matches!(&z, AnEnum::X)` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:182:20 + --> tests/ui/match_expr_like_matches_macro.rs:182:20 | LL | let _res = match &val { | ____________________^ @@ -126,7 +126,7 @@ LL | | }; | |_________^ help: try: `matches!(&val, &Some(ref _a))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:194:20 + --> tests/ui/match_expr_like_matches_macro.rs:194:20 | LL | let _res = match &val { | ____________________^ @@ -136,7 +136,7 @@ LL | | }; | |_________^ help: try: `matches!(&val, &Some(ref _a))` error: match expression looks like `matches!` macro - --> $DIR/match_expr_like_matches_macro.rs:252:14 + --> tests/ui/match_expr_like_matches_macro.rs:252:14 | LL | let _y = match Some(5) { | ______________^ 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 140a458cb9a4c..e31db37841379 100644 --- a/src/tools/clippy/tests/ui/match_on_vec_items.stderr +++ b/src/tools/clippy/tests/ui/match_on_vec_items.stderr @@ -1,5 +1,5 @@ error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:10:11 + --> tests/ui/match_on_vec_items.rs:10:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` @@ -8,43 +8,43 @@ LL | match arr[idx] { = 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 + --> tests/ui/match_on_vec_items.rs:19:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:33:11 + --> tests/ui/match_on_vec_items.rs:33:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:41:11 + --> tests/ui/match_on_vec_items.rs:41:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:55:11 + --> tests/ui/match_on_vec_items.rs:55:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:63:11 + --> tests/ui/match_on_vec_items.rs:63:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:77:11 + --> tests/ui/match_on_vec_items.rs:77:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> $DIR/match_on_vec_items.rs:85:11 + --> tests/ui/match_on_vec_items.rs:85:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` diff --git a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr index 322c704f2aa28..1a6c5746c3dd2 100644 --- a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr +++ b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr @@ -1,11 +1,11 @@ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:12:9 + --> tests/ui/match_overlapping_arm.rs:12:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:14:9 + --> tests/ui/match_overlapping_arm.rs:14:9 | LL | 0..=11 => println!("0..=11"), | ^^^^^^ @@ -13,85 +13,85 @@ LL | 0..=11 => println!("0..=11"), = help: to override `-D warnings` add `#[allow(clippy::match_overlapping_arm)]` error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:19:9 + --> tests/ui/match_overlapping_arm.rs:19:9 | LL | 0..=5 => println!("0..=5"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:22:9 + --> tests/ui/match_overlapping_arm.rs:22:9 | LL | FOO..=11 => println!("FOO..=11"), | ^^^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:57:9 + --> tests/ui/match_overlapping_arm.rs:57:9 | LL | 0..11 => println!("0..11"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:59:9 + --> tests/ui/match_overlapping_arm.rs:59:9 | LL | 0..=11 => println!("0..=11"), | ^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:83:9 + --> tests/ui/match_overlapping_arm.rs:83:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:82:9 + --> tests/ui/match_overlapping_arm.rs:82:9 | LL | 5..14 => println!("5..14"), | ^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:89:9 + --> tests/ui/match_overlapping_arm.rs:89:9 | LL | 0..7 => println!("0..7"), | ^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:91:9 + --> tests/ui/match_overlapping_arm.rs:91:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:102:9 + --> tests/ui/match_overlapping_arm.rs:102:9 | LL | ..=23 => println!("..=23"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:104:9 + --> tests/ui/match_overlapping_arm.rs:104:9 | LL | ..26 => println!("..26"), | ^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:112:9 + --> tests/ui/match_overlapping_arm.rs:112:9 | LL | 21..=30 => (), | ^^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:114:9 + --> tests/ui/match_overlapping_arm.rs:114:9 | LL | 21..=40 => (), | ^^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:127:9 + --> tests/ui/match_overlapping_arm.rs:127:9 | LL | 0..=0x0000_0000_0000_00ff => (), | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:129:9 + --> tests/ui/match_overlapping_arm.rs:129:9 | LL | 0..=0x0000_0000_0000_ffff => (), | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/match_ref_pats.stderr b/src/tools/clippy/tests/ui/match_ref_pats.stderr index e3bb2824aa070..fc01ab0a919a1 100644 --- a/src/tools/clippy/tests/ui/match_ref_pats.stderr +++ b/src/tools/clippy/tests/ui/match_ref_pats.stderr @@ -1,5 +1,5 @@ error: you don't need to add `&` to all patterns - --> $DIR/match_ref_pats.rs:8:9 + --> tests/ui/match_ref_pats.rs:8:9 | LL | / match v { LL | | &Some(v) => println!("{:?}", v), @@ -17,7 +17,7 @@ LL ~ None => println!("none"), | error: you don't need to add `&` to both the expression and the patterns - --> $DIR/match_ref_pats.rs:25:5 + --> tests/ui/match_ref_pats.rs:25:5 | LL | / match &w { LL | | &Some(v) => println!("{:?}", v), @@ -33,7 +33,7 @@ LL ~ None => println!("none"), | error: redundant pattern matching, consider using `is_none()` - --> $DIR/match_ref_pats.rs:37:12 + --> tests/ui/match_ref_pats.rs:37:12 | LL | if let &None = a { | -------^^^^^---- help: try: `if a.is_none()` @@ -42,13 +42,13 @@ LL | if let &None = a { = 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 + --> tests/ui/match_ref_pats.rs:42:12 | LL | if let &None = &b { | -------^^^^^----- help: try: `if b.is_none()` error: you don't need to add `&` to all patterns - --> $DIR/match_ref_pats.rs:102:9 + --> tests/ui/match_ref_pats.rs:102:9 | LL | / match foobar_variant!(0) { LL | | &FooBar::Foo => println!("Foo"), diff --git a/src/tools/clippy/tests/ui/match_result_ok.stderr b/src/tools/clippy/tests/ui/match_result_ok.stderr index de0361bd6b41e..0d42d59dc0136 100644 --- a/src/tools/clippy/tests/ui/match_result_ok.stderr +++ b/src/tools/clippy/tests/ui/match_result_ok.stderr @@ -1,5 +1,5 @@ error: matching on `Some` with `ok()` is redundant - --> $DIR/match_result_ok.rs:8:5 + --> tests/ui/match_result_ok.rs:8:5 | LL | if let Some(y) = x.parse().ok() { y } else { 0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | if let Ok(y) = x.parse() { y } else { 0 } | ~~~~~~~~~~~~~~~~~~~~~~~~ error: matching on `Some` with `ok()` is redundant - --> $DIR/match_result_ok.rs:18:9 + --> tests/ui/match_result_ok.rs:18:9 | LL | if let Some(y) = x . parse() . ok () { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if let Ok(y) = x . parse() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: matching on `Some` with `ok()` is redundant - --> $DIR/match_result_ok.rs:44:5 + --> tests/ui/match_result_ok.rs:44:5 | LL | while let Some(a) = wat.next().ok() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/match_same_arms.stderr b/src/tools/clippy/tests/ui/match_same_arms.stderr index 824dcfdce8374..a926570b60ada 100644 --- a/src/tools/clippy/tests/ui/match_same_arms.stderr +++ b/src/tools/clippy/tests/ui/match_same_arms.stderr @@ -1,12 +1,12 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms.rs:12:9 + --> tests/ui/match_same_arms.rs:12:9 | LL | Abc::A => 0, | ^^^^^^^^^^^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms.rs:14:9 + --> tests/ui/match_same_arms.rs:14:9 | LL | _ => 0, | ^^^^^^ @@ -14,7 +14,7 @@ LL | _ => 0, = 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 + --> tests/ui/match_same_arms.rs:18:9 | LL | (1, .., 3) => 42, | ----------^^^^^^ @@ -23,13 +23,13 @@ LL | (1, .., 3) => 42, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:19:9 + --> tests/ui/match_same_arms.rs:19:9 | LL | (.., 3) => 42, | ^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:25:9 + --> tests/ui/match_same_arms.rs:25:9 | LL | 51 => 1, | --^^^^^ @@ -38,13 +38,13 @@ LL | 51 => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:24:9 + --> tests/ui/match_same_arms.rs:24:9 | LL | 42 => 1, | ^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:26:9 + --> tests/ui/match_same_arms.rs:26:9 | LL | 41 => 2, | --^^^^^ @@ -53,13 +53,13 @@ LL | 41 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:27:9 + --> tests/ui/match_same_arms.rs:27:9 | LL | 52 => 2, | ^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:33:9 + --> tests/ui/match_same_arms.rs:33:9 | LL | 2 => 2, | -^^^^^ @@ -68,13 +68,13 @@ LL | 2 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:32:9 + --> tests/ui/match_same_arms.rs:32:9 | LL | 1 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:35:9 + --> tests/ui/match_same_arms.rs:35:9 | LL | 3 => 2, | -^^^^^ @@ -83,13 +83,13 @@ LL | 3 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:32:9 + --> tests/ui/match_same_arms.rs:32:9 | LL | 1 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:33:9 + --> tests/ui/match_same_arms.rs:33:9 | LL | 2 => 2, | -^^^^^ @@ -98,13 +98,13 @@ LL | 2 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:35:9 + --> tests/ui/match_same_arms.rs:35:9 | LL | 3 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:52:17 + --> tests/ui/match_same_arms.rs:52:17 | LL | CommandInfo::External { name, .. } => name.to_string(), | ----------------------------------^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | CommandInfo::External { name, .. } => name.to_string(), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:51:17 + --> tests/ui/match_same_arms.rs:51:17 | LL | CommandInfo::BuiltIn { name, .. } => name.to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/match_same_arms2.rs b/src/tools/clippy/tests/ui/match_same_arms2.rs index 3428ff4590602..85ad0962eb4bf 100644 --- a/src/tools/clippy/tests/ui/match_same_arms2.rs +++ b/src/tools/clippy/tests/ui/match_same_arms2.rs @@ -67,6 +67,20 @@ fn match_same_arms() { _ => (), } + // No warning because guards are different + let _ = match Some(42) { + Some(a) if a == 42 => a, + Some(a) if a == 24 => a, + Some(_) => 24, + None => 0, + }; + + let _ = match (Some(42), Some(42)) { + (Some(a), None) if a == 42 => a, + (None, Some(a)) if a == 42 => a, //~ ERROR: this match arm has an identical body to another arm + _ => 0, + }; + match (Some(42), Some(42)) { (Some(a), ..) => bar(a), //~ ERROR: this match arm has an identical body to another arm (.., Some(a)) => bar(a), diff --git a/src/tools/clippy/tests/ui/match_same_arms2.stderr b/src/tools/clippy/tests/ui/match_same_arms2.stderr index 512ca7413a795..f4c38c1af8975 100644 --- a/src/tools/clippy/tests/ui/match_same_arms2.stderr +++ b/src/tools/clippy/tests/ui/match_same_arms2.stderr @@ -1,5 +1,5 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms2.rs:15:9 + --> tests/ui/match_same_arms2.rs:15:9 | LL | / 42 => { LL | | foo(); @@ -12,7 +12,7 @@ LL | | }, | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms2.rs:24:9 + --> tests/ui/match_same_arms2.rs:24:9 | LL | / _ => { LL | | foo(); @@ -26,7 +26,7 @@ LL | | }, = 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 + --> tests/ui/match_same_arms2.rs:38:9 | LL | 51 => foo(), | --^^^^^^^^^ @@ -35,13 +35,13 @@ LL | 51 => foo(), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:37:9 + --> tests/ui/match_same_arms2.rs:37:9 | LL | 42 => foo(), | ^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:44:9 + --> tests/ui/match_same_arms2.rs:44:9 | LL | None => 24, | ----^^^^^^ @@ -50,13 +50,13 @@ LL | None => 24, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:43:9 + --> tests/ui/match_same_arms2.rs:43:9 | LL | Some(_) => 24, | ^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:66:9 + --> tests/ui/match_same_arms2.rs:66:9 | LL | (None, Some(a)) => bar(a), | ---------------^^^^^^^^^^ @@ -65,13 +65,28 @@ LL | (None, Some(a)) => bar(a), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:65:9 + --> tests/ui/match_same_arms2.rs:65:9 | LL | (Some(a), None) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:71:9 + --> tests/ui/match_same_arms2.rs:80:9 + | +LL | (None, Some(a)) if a == 42 => a, + | ---------------^^^^^^^^^^^^^^^^ + | | + | help: try merging the arm patterns: `(None, Some(a)) | (Some(a), None)` + | + = help: or try changing either arm body +note: other arm here + --> tests/ui/match_same_arms2.rs:79:9 + | +LL | (Some(a), None) if a == 42 => a, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this match arm has an identical body to another arm + --> tests/ui/match_same_arms2.rs:85:9 | LL | (Some(a), ..) => bar(a), | -------------^^^^^^^^^^ @@ -80,13 +95,13 @@ LL | (Some(a), ..) => bar(a), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:72:9 + --> tests/ui/match_same_arms2.rs:86:9 | LL | (.., Some(a)) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:105:9 + --> tests/ui/match_same_arms2.rs:119:9 | LL | (Ok(x), Some(_)) => println!("ok {}", x), | ----------------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,13 +110,13 @@ LL | (Ok(x), Some(_)) => println!("ok {}", x), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:106:9 + --> tests/ui/match_same_arms2.rs:120:9 | LL | (Ok(_), Some(x)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:121:9 + --> tests/ui/match_same_arms2.rs:135:9 | LL | Ok(_) => println!("ok"), | -----^^^^^^^^^^^^^^^^^^ @@ -110,13 +125,13 @@ LL | Ok(_) => println!("ok"), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:120:9 + --> tests/ui/match_same_arms2.rs:134:9 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:148:9 + --> tests/ui/match_same_arms2.rs:162:9 | LL | 1 => { | ^ help: try merging the arm patterns: `1 | 0` @@ -128,7 +143,7 @@ LL | | }, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:145:9 + --> tests/ui/match_same_arms2.rs:159:9 | LL | / 0 => { LL | | empty!(0); @@ -136,7 +151,7 @@ LL | | }, | |_________^ error: match expression looks like `matches!` macro - --> $DIR/match_same_arms2.rs:167:16 + --> tests/ui/match_same_arms2.rs:181:16 | LL | let _ans = match x { | ________________^ @@ -150,7 +165,7 @@ LL | | }; = 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 + --> tests/ui/match_same_arms2.rs:213:9 | LL | Foo::X(0) => 1, | ---------^^^^^ @@ -159,13 +174,13 @@ LL | Foo::X(0) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:201:9 + --> tests/ui/match_same_arms2.rs:215:9 | LL | Foo::Z(_) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:209:9 + --> tests/ui/match_same_arms2.rs:223:9 | LL | Foo::Z(_) => 1, | ---------^^^^^ @@ -174,13 +189,13 @@ LL | Foo::Z(_) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:207:9 + --> tests/ui/match_same_arms2.rs:221:9 | LL | Foo::X(0) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:232:9 + --> tests/ui/match_same_arms2.rs:246:9 | LL | Some(Bar { y: 0, x: 5, .. }) => 1, | ----------------------------^^^^^ @@ -189,13 +204,13 @@ LL | Some(Bar { y: 0, x: 5, .. }) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:229:9 + --> tests/ui/match_same_arms2.rs:243:9 | LL | Some(Bar { x: 0, y: 5, .. }) => 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:246:9 + --> tests/ui/match_same_arms2.rs:260:9 | LL | 1 => cfg!(not_enable), | -^^^^^^^^^^^^^^^^^^^^ @@ -204,10 +219,10 @@ LL | 1 => cfg!(not_enable), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:245:9 + --> tests/ui/match_same_arms2.rs:259:9 | LL | 0 => cfg!(not_enable), | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 13 previous errors +error: aborting due to 14 previous errors 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 ae6b02ab1b507..cf2a75354e15c 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 @@ -1,12 +1,12 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms_non_exhaustive.rs:45:9 + --> tests/ui/match_same_arms_non_exhaustive.rs:45:9 | LL | Ordering::AcqRel | Ordering::SeqCst => repeat(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms_non_exhaustive.rs:47:9 + --> tests/ui/match_same_arms_non_exhaustive.rs:47:9 | LL | _ => repeat(), | ^^^^^^^^^^^^^ @@ -14,14 +14,14 @@ LL | _ => repeat(), = 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:59:13 + --> tests/ui/match_same_arms_non_exhaustive.rs:59:13 | LL | Ordering::AcqRel | Ordering::SeqCst => repeat(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms_non_exhaustive.rs:61:13 + --> tests/ui/match_same_arms_non_exhaustive.rs:61:13 | LL | _ => repeat(), | ^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/match_single_binding.stderr b/src/tools/clippy/tests/ui/match_single_binding.stderr index 81ec200dfc7a0..19ab85180ad28 100644 --- a/src/tools/clippy/tests/ui/match_single_binding.stderr +++ b/src/tools/clippy/tests/ui/match_single_binding.stderr @@ -1,5 +1,5 @@ error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:33:5 + --> tests/ui/match_single_binding.rs:33:5 | LL | / match (a, b, c) { LL | | (x, y, z) => { @@ -19,7 +19,7 @@ LL + } | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:39:5 + --> tests/ui/match_single_binding.rs:39:5 | LL | / match (a, b, c) { LL | | (x, y, z) => println!("{} {} {}", x, y, z), @@ -33,7 +33,7 @@ LL + println!("{} {} {}", x, y, z); | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:56:5 + --> tests/ui/match_single_binding.rs:56:5 | LL | / match a { LL | | _ => println!("whatever"), @@ -41,7 +41,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("whatever");` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:60:5 + --> tests/ui/match_single_binding.rs:60:5 | LL | / match a { LL | | _ => { @@ -60,7 +60,7 @@ LL + } | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:67:5 + --> tests/ui/match_single_binding.rs:67:5 | LL | / match a { LL | | _ => { @@ -82,7 +82,7 @@ LL + } | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:77:5 + --> tests/ui/match_single_binding.rs:77:5 | LL | / match p { LL | | Point { x, y } => println!("Coords: ({}, {})", x, y), @@ -96,7 +96,7 @@ LL + println!("Coords: ({}, {})", x, y); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:81:5 + --> tests/ui/match_single_binding.rs:81:5 | LL | / match p { LL | | Point { x: x1, y: y1 } => println!("Coords: ({}, {})", x1, y1), @@ -110,7 +110,7 @@ LL + println!("Coords: ({}, {})", x1, y1); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:86:5 + --> tests/ui/match_single_binding.rs:86:5 | LL | / match x { LL | | ref r => println!("Got a reference to {}", r), @@ -124,7 +124,7 @@ LL + println!("Got a reference to {}", r); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:91:5 + --> tests/ui/match_single_binding.rs:91:5 | LL | / match x { LL | | ref mut mr => println!("Got a mutable reference to {}", mr), @@ -138,7 +138,7 @@ LL + println!("Got a mutable reference to {}", mr); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:95:5 + --> tests/ui/match_single_binding.rs:95:5 | LL | / let product = match coords() { LL | | Point { x, y } => x * y, @@ -152,7 +152,7 @@ LL + let product = x * y; | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:103:18 + --> tests/ui/match_single_binding.rs:103:18 | LL | .map(|i| match i.unwrap() { | __________________^ @@ -169,7 +169,7 @@ LL ~ }) | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:129:5 + --> tests/ui/match_single_binding.rs:129:5 | LL | / match x { LL | | // => @@ -178,7 +178,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("Not an array index start")` error: this assignment could be simplified - --> $DIR/match_single_binding.rs:138:5 + --> tests/ui/match_single_binding.rs:138:5 | LL | / val = match val.split_at(idx) { LL | | (pre, suf) => { @@ -198,7 +198,7 @@ LL ~ }; | error: this match could be replaced by its scrutinee and body - --> $DIR/match_single_binding.rs:151:16 + --> tests/ui/match_single_binding.rs:151:16 | LL | let _ = || match side_effects() { | ________________^ @@ -215,7 +215,7 @@ LL ~ }; | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:157:5 + --> tests/ui/match_single_binding.rs:157:5 | LL | / match r { LL | | x => match x { @@ -240,7 +240,7 @@ LL ~ }; | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:170:5 + --> tests/ui/match_single_binding.rs:170:5 | LL | / match 1 { LL | | _ => (), @@ -248,7 +248,7 @@ LL | | } | |_____^ help: consider using the match body instead: `();` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:174:13 + --> tests/ui/match_single_binding.rs:174:13 | LL | let a = match 1 { | _____________^ @@ -257,7 +257,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:178:5 + --> tests/ui/match_single_binding.rs:178:5 | LL | / match 1 { LL | | _ => side_effects(), @@ -265,7 +265,7 @@ LL | | } | |_____^ help: consider using the match body instead: `side_effects();` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:182:13 + --> tests/ui/match_single_binding.rs:182:13 | LL | let b = match 1 { | _____________^ @@ -274,7 +274,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `side_effects()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:186:5 + --> tests/ui/match_single_binding.rs:186:5 | LL | / match 1 { LL | | _ => println!("1"), @@ -282,7 +282,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("1");` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:190:13 + --> tests/ui/match_single_binding.rs:190:13 | LL | let c = match 1 { | _____________^ @@ -291,7 +291,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `println!("1")` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:195:9 + --> tests/ui/match_single_binding.rs:195:9 | LL | / match 1 { LL | | _ => (), @@ -299,7 +299,7 @@ LL | | }, | |_________^ help: consider using the match body instead: `()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:198:9 + --> tests/ui/match_single_binding.rs:198:9 | LL | / match 1 { LL | | _ => side_effects(), @@ -307,7 +307,7 @@ LL | | }, | |_________^ help: consider using the match body instead: `side_effects()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:201:9 + --> tests/ui/match_single_binding.rs:201:9 | LL | / match 1 { LL | | _ => println!("1"), diff --git a/src/tools/clippy/tests/ui/match_single_binding2.stderr b/src/tools/clippy/tests/ui/match_single_binding2.stderr index e7b9ef8a1cda9..38659596af1ff 100644 --- a/src/tools/clippy/tests/ui/match_single_binding2.stderr +++ b/src/tools/clippy/tests/ui/match_single_binding2.stderr @@ -1,5 +1,5 @@ error: this match could be written as a `let` statement - --> $DIR/match_single_binding2.rs:17:36 + --> tests/ui/match_single_binding2.rs:17:36 | LL | Some((iter, _item)) => match iter.size_hint() { | ____________________________________^ @@ -18,7 +18,7 @@ LL ~ }, | error: this match could be written as a `let` statement - --> $DIR/match_single_binding2.rs:30:13 + --> tests/ui/match_single_binding2.rs:30:13 | LL | / match get_tup() { LL | | (a, b) => println!("a {:?} and b {:?}", a, b), @@ -32,7 +32,7 @@ LL + println!("a {:?} and b {:?}", a, b) | error: this match could be replaced by its scrutinee and body - --> $DIR/match_single_binding2.rs:41:5 + --> tests/ui/match_single_binding2.rs:41:5 | LL | / match side_effects() { LL | | _ => println!("Side effects"), @@ -46,7 +46,7 @@ LL + println!("Side effects"); | error: this match could be replaced by its scrutinee and body - --> $DIR/match_single_binding2.rs:48:5 + --> tests/ui/match_single_binding2.rs:48:5 | LL | / match match x { LL | | 0 => 1, 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 b178fb7512cdb..67e9ccaf6d2fb 100644 --- a/src/tools/clippy/tests/ui/match_str_case_mismatch.stderr +++ b/src/tools/clippy/tests/ui/match_str_case_mismatch.stderr @@ -1,5 +1,5 @@ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:112:9 + --> tests/ui/match_str_case_mismatch.rs:112:9 | LL | "Bar" => {}, | ^^^^^ @@ -12,7 +12,7 @@ LL | "bar" => {}, | ~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:122:9 + --> tests/ui/match_str_case_mismatch.rs:122:9 | LL | "~!@#$%^&*()-_=+Foo" => {}, | ^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | "~!@#$%^&*()-_=+foo" => {}, | ~~~~~~~~~~~~~~~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:134:9 + --> tests/ui/match_str_case_mismatch.rs:134:9 | LL | "Воды" => {}, | ^^^^^^ @@ -34,7 +34,7 @@ LL | "воды" => {}, | ~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:145:9 + --> tests/ui/match_str_case_mismatch.rs:145:9 | LL | "barDz" => {}, | ^^^^^^ @@ -45,7 +45,7 @@ LL | "bardz" => {}, | ~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:155:9 + --> tests/ui/match_str_case_mismatch.rs:155:9 | LL | "bARʁ" => {}, | ^^^^^^ @@ -56,7 +56,7 @@ LL | "BARʁ" => {}, | ~~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:165:9 + --> tests/ui/match_str_case_mismatch.rs:165:9 | LL | "Bar" => {}, | ^^^^^ @@ -67,7 +67,7 @@ LL | "bar" => {}, | ~~~~~ error: this `match` arm has a differing case than its expression - --> $DIR/match_str_case_mismatch.rs:180:9 + --> tests/ui/match_str_case_mismatch.rs:180:9 | 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 c120aec5b23b3..3145665a341e8 100644 --- a/src/tools/clippy/tests/ui/match_wild_err_arm.stderr +++ b/src/tools/clippy/tests/ui/match_wild_err_arm.stderr @@ -1,5 +1,5 @@ error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:24:9 + --> tests/ui/match_wild_err_arm.rs:24:9 | LL | Err(_) => panic!("err"), | ^^^^^^ @@ -9,7 +9,7 @@ LL | Err(_) => panic!("err"), = 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 + --> tests/ui/match_wild_err_arm.rs:32:9 | LL | Err(_) => panic!(), | ^^^^^^ @@ -17,7 +17,7 @@ LL | Err(_) => panic!(), = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable error: `Err(_)` matches all errors - --> $DIR/match_wild_err_arm.rs:40:9 + --> tests/ui/match_wild_err_arm.rs:40:9 | LL | Err(_) => { | ^^^^^^ @@ -25,7 +25,7 @@ LL | Err(_) => { = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable error: `Err(_e)` matches all errors - --> $DIR/match_wild_err_arm.rs:50:9 + --> tests/ui/match_wild_err_arm.rs:50:9 | LL | Err(_e) => panic!(), | ^^^^^^^ 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 e07d3bdd32e6b..5cc50c823b2ca 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 @@ -1,5 +1,5 @@ error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:22:13 + --> tests/ui/match_wildcard_for_single_variants.rs:22:13 | LL | _ => (), | ^ help: try: `Self::Rgb(..)` @@ -8,55 +8,55 @@ LL | _ => (), = 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 + --> tests/ui/match_wildcard_for_single_variants.rs:32:9 | LL | _ => {}, | ^ help: try: `Foo::C` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:42:9 + --> tests/ui/match_wildcard_for_single_variants.rs:42:9 | LL | _ => {}, | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:50:9 + --> tests/ui/match_wildcard_for_single_variants.rs:50:9 | LL | _ => {}, | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:56:9 + --> tests/ui/match_wildcard_for_single_variants.rs:56:9 | LL | _ => {}, | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:73:9 + --> tests/ui/match_wildcard_for_single_variants.rs:73:9 | LL | &_ => (), | ^^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:82:9 + --> tests/ui/match_wildcard_for_single_variants.rs:82:9 | LL | _ => (), | ^ help: try: `C::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:89:9 + --> tests/ui/match_wildcard_for_single_variants.rs:89:9 | LL | _ => (), | ^ help: try: `Color::Blue` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:124:13 + --> tests/ui/match_wildcard_for_single_variants.rs:124:13 | LL | _ => (), | ^ help: try: `Enum::__Private` error: wildcard matches only a single variant and will also match any future added variants - --> $DIR/match_wildcard_for_single_variants.rs:151:13 + --> tests/ui/match_wildcard_for_single_variants.rs:151:13 | LL | _ => 2, | ^ help: try: `Foo::B` diff --git a/src/tools/clippy/tests/ui/mem_forget.stderr b/src/tools/clippy/tests/ui/mem_forget.stderr index a5ab150317a1b..3b0e839e0871a 100644 --- a/src/tools/clippy/tests/ui/mem_forget.stderr +++ b/src/tools/clippy/tests/ui/mem_forget.stderr @@ -1,5 +1,5 @@ error: usage of `mem::forget` on `Drop` type - --> $DIR/mem_forget.rs:14:5 + --> tests/ui/mem_forget.rs:14:5 | LL | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | memstuff::forget(six); = help: to override `-D warnings` add `#[allow(clippy::mem_forget)]` error: usage of `mem::forget` on `Drop` type - --> $DIR/mem_forget.rs:19:5 + --> tests/ui/mem_forget.rs:19:5 | LL | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | std::mem::forget(seven); = note: argument has type `std::rc::Rc` error: usage of `mem::forget` on `Drop` type - --> $DIR/mem_forget.rs:24:5 + --> tests/ui/mem_forget.rs:24:5 | LL | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | forgetSomething(eight); = note: argument has type `std::vec::Vec` error: usage of `mem::forget` on type with `Drop` fields - --> $DIR/mem_forget.rs:29:5 + --> tests/ui/mem_forget.rs:29:5 | LL | std::mem::forget(string); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/mem_replace.fixed b/src/tools/clippy/tests/ui/mem_replace.fixed index 453d0bcc57c53..78d8b3e9bce6b 100644 --- a/src/tools/clippy/tests/ui/mem_replace.fixed +++ b/src/tools/clippy/tests/ui/mem_replace.fixed @@ -71,6 +71,14 @@ fn dont_lint_primitive() { let _ = std::mem::replace(&mut pint, 0); } +// lint is disabled for expressions that are not used because changing to `take` is not the +// recommended fix. Additionally, the `replace` is #[must_use], so that lint will provide +// the correct suggestion +fn dont_lint_not_used() { + let mut s = String::from("foo"); + std::mem::replace(&mut s, String::default()); +} + fn main() { replace_option_with_none(); replace_with_default(); diff --git a/src/tools/clippy/tests/ui/mem_replace.rs b/src/tools/clippy/tests/ui/mem_replace.rs index 0c4e0f6032d8e..28915bf6daee8 100644 --- a/src/tools/clippy/tests/ui/mem_replace.rs +++ b/src/tools/clippy/tests/ui/mem_replace.rs @@ -71,6 +71,14 @@ fn dont_lint_primitive() { let _ = std::mem::replace(&mut pint, 0); } +// lint is disabled for expressions that are not used because changing to `take` is not the +// recommended fix. Additionally, the `replace` is #[must_use], so that lint will provide +// the correct suggestion +fn dont_lint_not_used() { + let mut s = String::from("foo"); + std::mem::replace(&mut s, String::default()); +} + fn main() { replace_option_with_none(); replace_with_default(); diff --git a/src/tools/clippy/tests/ui/mem_replace.stderr b/src/tools/clippy/tests/ui/mem_replace.stderr index ae5f4e5340a2a..44be2c9b63d75 100644 --- a/src/tools/clippy/tests/ui/mem_replace.stderr +++ b/src/tools/clippy/tests/ui/mem_replace.stderr @@ -1,5 +1,5 @@ error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:14:13 + --> tests/ui/mem_replace.rs:14:13 | LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` @@ -8,13 +8,13 @@ LL | let _ = mem::replace(&mut an_option, None); = 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 + --> tests/ui/mem_replace.rs:16:13 | LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:21:13 + --> tests/ui/mem_replace.rs:21:13 | LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` @@ -23,127 +23,127 @@ LL | let _ = std::mem::replace(&mut s, String::default()); = 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 + --> tests/ui/mem_replace.rs:24:13 | LL | let _ = std::mem::replace(s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:25:13 + --> tests/ui/mem_replace.rs:25:13 | LL | let _ = std::mem::replace(s, Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:28:13 + --> tests/ui/mem_replace.rs:28:13 | LL | let _ = std::mem::replace(&mut v, Vec::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:29:13 + --> tests/ui/mem_replace.rs:29:13 | LL | let _ = std::mem::replace(&mut v, Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:30:13 + --> tests/ui/mem_replace.rs:30:13 | LL | let _ = std::mem::replace(&mut v, Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:31:13 + --> tests/ui/mem_replace.rs:31:13 | LL | let _ = std::mem::replace(&mut v, vec![]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:34:13 + --> tests/ui/mem_replace.rs:34:13 | LL | let _ = std::mem::replace(&mut hash_map, HashMap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_map)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:37:13 + --> tests/ui/mem_replace.rs:37:13 | LL | let _ = std::mem::replace(&mut btree_map, BTreeMap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_map)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:40:13 + --> tests/ui/mem_replace.rs:40:13 | LL | let _ = std::mem::replace(&mut vd, VecDeque::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut vd)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:43:13 + --> tests/ui/mem_replace.rs:43:13 | LL | let _ = std::mem::replace(&mut hash_set, HashSet::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_set)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:46:13 + --> tests/ui/mem_replace.rs:46:13 | LL | let _ = std::mem::replace(&mut btree_set, BTreeSet::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_set)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:49:13 + --> tests/ui/mem_replace.rs:49:13 | LL | let _ = std::mem::replace(&mut list, LinkedList::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut list)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:52:13 + --> tests/ui/mem_replace.rs:52:13 | LL | let _ = std::mem::replace(&mut binary_heap, BinaryHeap::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut binary_heap)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:55:13 + --> tests/ui/mem_replace.rs:55:13 | LL | let _ = std::mem::replace(&mut tuple, (vec![], BinaryHeap::new())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut tuple)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:58:13 + --> tests/ui/mem_replace.rs:58:13 | LL | let _ = std::mem::replace(&mut refstr, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut refstr)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:61:13 + --> tests/ui/mem_replace.rs:61:13 | LL | let _ = std::mem::replace(&mut slice, &[]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut slice)` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:89:13 + --> tests/ui/mem_replace.rs:97:13 | LL | let _ = std::mem::replace(&mut s, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:119:13 + --> tests/ui/mem_replace.rs:127:13 | LL | let _ = std::mem::replace(&mut f.0, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `f.0.take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:120:13 + --> tests/ui/mem_replace.rs:128:13 | LL | let _ = std::mem::replace(&mut *f, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `(*f).take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:121:13 + --> tests/ui/mem_replace.rs:129:13 | LL | let _ = std::mem::replace(&mut b.opt, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `b.opt.take()` error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace.rs:123:13 + --> tests/ui/mem_replace.rs:131:13 | LL | let _ = std::mem::replace(&mut b.val, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut b.val)` diff --git a/src/tools/clippy/tests/ui/mem_replace_macro.rs b/src/tools/clippy/tests/ui/mem_replace_macro.rs index 132873858b7c5..c14ea2942f3ed 100644 --- a/src/tools/clippy/tests/ui/mem_replace_macro.rs +++ b/src/tools/clippy/tests/ui/mem_replace_macro.rs @@ -7,6 +7,6 @@ use proc_macros::{external, inline_macros}; #[inline_macros] fn main() { let s = &mut String::from("foo"); - inline!(std::mem::replace($s, Default::default())); - external!(std::mem::replace($s, Default::default())); + let _ = inline!(std::mem::replace($s, Default::default())); + let _ = external!(std::mem::replace($s, Default::default())); } diff --git a/src/tools/clippy/tests/ui/mem_replace_macro.stderr b/src/tools/clippy/tests/ui/mem_replace_macro.stderr index c6435e94e9673..0c98200bf04e5 100644 --- a/src/tools/clippy/tests/ui/mem_replace_macro.stderr +++ b/src/tools/clippy/tests/ui/mem_replace_macro.stderr @@ -1,8 +1,8 @@ error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take` - --> $DIR/mem_replace_macro.rs:10:13 + --> tests/ui/mem_replace_macro.rs:10:21 | -LL | inline!(std::mem::replace($s, Default::default())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _ = 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)]` diff --git a/src/tools/clippy/tests/ui/mem_replace_no_std.stderr b/src/tools/clippy/tests/ui/mem_replace_no_std.stderr index 744fb5a15876e..eea538da4277a 100644 --- a/src/tools/clippy/tests/ui/mem_replace_no_std.stderr +++ b/src/tools/clippy/tests/ui/mem_replace_no_std.stderr @@ -1,5 +1,5 @@ error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:24:13 + --> tests/ui/mem_replace_no_std.rs:24:13 | LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` @@ -8,13 +8,13 @@ LL | let _ = mem::replace(&mut an_option, None); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_option_with_none)]` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:26:13 + --> tests/ui/mem_replace_no_std.rs:26:13 | LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` error: replacing a value of type `T` with `T::default()` is better expressed using `core::mem::take` - --> $DIR/mem_replace_no_std.rs:31:13 + --> tests/ui/mem_replace_no_std.rs:31:13 | LL | let _ = mem::replace(&mut refstr, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::mem::take(&mut refstr)` @@ -23,25 +23,25 @@ LL | let _ = mem::replace(&mut refstr, ""); = 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 `core::mem::take` - --> $DIR/mem_replace_no_std.rs:34:13 + --> tests/ui/mem_replace_no_std.rs:34:13 | LL | let _ = mem::replace(&mut slice, &[]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::mem::take(&mut slice)` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:77:13 + --> tests/ui/mem_replace_no_std.rs:77:13 | LL | let _ = mem::replace(&mut f.0, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `f.0.take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:78:13 + --> tests/ui/mem_replace_no_std.rs:78:13 | LL | let _ = mem::replace(&mut *f, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `(*f).take()` error: replacing an `Option` with `None` - --> $DIR/mem_replace_no_std.rs:79:13 + --> tests/ui/mem_replace_no_std.rs:79:13 | LL | let _ = mem::replace(&mut b.opt, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `b.opt.take()` diff --git a/src/tools/clippy/tests/ui/methods.stderr b/src/tools/clippy/tests/ui/methods.stderr index e32b3b336af65..2e2bd3d874f51 100644 --- a/src/tools/clippy/tests/ui/methods.stderr +++ b/src/tools/clippy/tests/ui/methods.stderr @@ -1,5 +1,5 @@ error: methods called `new` usually return `Self` - --> $DIR/methods.rs:103:5 + --> tests/ui/methods.rs:103:5 | LL | / fn new() -> i32 { LL | | 0 @@ -10,7 +10,7 @@ LL | | } = 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 + --> tests/ui/methods.rs:124:13 | LL | let _ = v.iter().filter(|&x| { | _____________^ diff --git a/src/tools/clippy/tests/ui/methods_fixable.stderr b/src/tools/clippy/tests/ui/methods_fixable.stderr index f290c20e5e989..852e7a224a6e3 100644 --- a/src/tools/clippy/tests/ui/methods_fixable.stderr +++ b/src/tools/clippy/tests/ui/methods_fixable.stderr @@ -1,5 +1,5 @@ error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead - --> $DIR/methods_fixable.rs:9:13 + --> tests/ui/methods_fixable.rs:9:13 | LL | let _ = v.iter().filter(|&x| *x < 0).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `v.iter().find(|&x| *x < 0)` diff --git a/src/tools/clippy/tests/ui/methods_unfixable.stderr b/src/tools/clippy/tests/ui/methods_unfixable.stderr index 771e10cbe105c..76691860f819d 100644 --- a/src/tools/clippy/tests/ui/methods_unfixable.stderr +++ b/src/tools/clippy/tests/ui/methods_unfixable.stderr @@ -1,11 +1,11 @@ error: called `filter(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(..)` instead - --> $DIR/methods_unfixable.rs:9:13 + --> tests/ui/methods_unfixable.rs:9:13 | LL | let _ = iter.filter(|_| true).next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `iter.find(|_| true)` | help: you will also need to make `iter` mutable, because `find` takes `&mut self` - --> $DIR/methods_unfixable.rs:8:9 + --> tests/ui/methods_unfixable.rs:8:9 | LL | let iter = (0..10); | ^^^^ diff --git a/src/tools/clippy/tests/ui/min_ident_chars.rs b/src/tools/clippy/tests/ui/min_ident_chars.rs index f99c35d5c57c4..1d89f26b6ee4d 100644 --- a/src/tools/clippy/tests/ui/min_ident_chars.rs +++ b/src/tools/clippy/tests/ui/min_ident_chars.rs @@ -37,6 +37,12 @@ struct Vec4 { struct AA(T, E); +trait Trait { + const A: u32 = 0; + type A; + fn a() {} +} + fn main() { // Allowed idents let w = 1; diff --git a/src/tools/clippy/tests/ui/min_ident_chars.stderr b/src/tools/clippy/tests/ui/min_ident_chars.stderr index e4181157ea23b..3dd5c9561fd02 100644 --- a/src/tools/clippy/tests/ui/min_ident_chars.stderr +++ b/src/tools/clippy/tests/ui/min_ident_chars.stderr @@ -1,5 +1,5 @@ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:9:8 + --> tests/ui/min_ident_chars.rs:9:8 | LL | struct A { | ^ @@ -8,172 +8,190 @@ LL | struct A { = help: to override `-D warnings` add `#[allow(clippy::min_ident_chars)]` error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:10:5 + --> tests/ui/min_ident_chars.rs:10:5 | LL | a: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:12:5 + --> tests/ui/min_ident_chars.rs:12:5 | LL | A: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:13:5 + --> tests/ui/min_ident_chars.rs:13:5 | LL | I: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:16:8 + --> tests/ui/min_ident_chars.rs:16:8 | LL | struct B(u32); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:18:8 + --> tests/ui/min_ident_chars.rs:18:8 | LL | struct O { | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:19:5 + --> tests/ui/min_ident_chars.rs:19:5 | LL | o: u32, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:24:6 + --> tests/ui/min_ident_chars.rs:24:6 | LL | enum C { | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:25:5 + --> tests/ui/min_ident_chars.rs:25:5 | LL | D, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:26:5 + --> tests/ui/min_ident_chars.rs:26:5 | LL | E, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:27:5 + --> tests/ui/min_ident_chars.rs:27:5 | LL | F, | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:51:9 + --> tests/ui/min_ident_chars.rs:41:11 + | +LL | const A: u32 = 0; + | ^ + +error: this ident consists of a single char + --> tests/ui/min_ident_chars.rs:42:10 + | +LL | type A; + | ^ + +error: this ident consists of a single char + --> tests/ui/min_ident_chars.rs:43:8 + | +LL | fn a() {} + | ^ + +error: this ident consists of a single char + --> tests/ui/min_ident_chars.rs:57:9 | LL | let h = 1; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:52:9 + --> tests/ui/min_ident_chars.rs:58:9 | LL | let e = 2; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:53:9 + --> tests/ui/min_ident_chars.rs:59:9 | LL | let l = 3; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:54:9 + --> tests/ui/min_ident_chars.rs:60:9 | LL | let l = 4; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:55:9 + --> tests/ui/min_ident_chars.rs:61:9 | LL | let o = 6; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:59:10 + --> tests/ui/min_ident_chars.rs:65:10 | LL | let (h, o, w) = (1, 2, 3); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:59:13 + --> tests/ui/min_ident_chars.rs:65:13 | LL | let (h, o, w) = (1, 2, 3); | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:60:10 + --> tests/ui/min_ident_chars.rs:66:10 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:60:14 + --> tests/ui/min_ident_chars.rs:66:14 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:60:17 + --> tests/ui/min_ident_chars.rs:66:17 | LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:62:16 + --> tests/ui/min_ident_chars.rs:68:16 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:62:19 + --> tests/ui/min_ident_chars.rs:68:19 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:62:29 + --> tests/ui/min_ident_chars.rs:68:29 | LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:66:9 + --> tests/ui/min_ident_chars.rs:72:9 | LL | let o = 1; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:67:9 + --> tests/ui/min_ident_chars.rs:73:9 | LL | let o = O { o }; | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:81:4 + --> tests/ui/min_ident_chars.rs:87:4 | LL | fn b() {} | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:82:21 + --> tests/ui/min_ident_chars.rs:88:21 | LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 { | ^ error: this ident consists of a single char - --> $DIR/min_ident_chars.rs:82:29 + --> tests/ui/min_ident_chars.rs:88:29 | LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 { | ^ -error: aborting due to 29 previous errors +error: aborting due to 32 previous errors diff --git a/src/tools/clippy/tests/ui/min_max.stderr b/src/tools/clippy/tests/ui/min_max.stderr index e9c64e56b619e..bb1a82e320d97 100644 --- a/src/tools/clippy/tests/ui/min_max.stderr +++ b/src/tools/clippy/tests/ui/min_max.stderr @@ -1,5 +1,5 @@ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:22:5 + --> tests/ui/min_max.rs:22:5 | LL | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ @@ -8,73 +8,73 @@ LL | min(1, max(3, x)); = 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 + --> tests/ui/min_max.rs:25:5 | LL | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:27:5 + --> tests/ui/min_max.rs:27:5 | LL | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:29:5 + --> tests/ui/min_max.rs:29:5 | LL | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:32:5 + --> tests/ui/min_max.rs:32:5 | LL | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:43:5 + --> tests/ui/min_max.rs:43:5 | LL | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:45:5 + --> tests/ui/min_max.rs:45:5 | LL | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:51:5 + --> tests/ui/min_max.rs:51:5 | LL | x.min(1).max(3); | ^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:53:5 + --> tests/ui/min_max.rs:53:5 | LL | x.max(3).min(1); | ^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:55:5 + --> tests/ui/min_max.rs:55:5 | LL | f.max(3f32).min(1f32); | ^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:62:5 + --> tests/ui/min_max.rs:62:5 | LL | max(x.min(1), 3); | ^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:66:5 + --> tests/ui/min_max.rs:66:5 | LL | s.max("Zoo").min("Apple"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> $DIR/min_max.rs:68:5 + --> tests/ui/min_max.rs:68:5 | LL | s.min("Apple").max("Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/min_rust_version_attr.stderr b/src/tools/clippy/tests/ui/min_rust_version_attr.stderr index 3c8555c62446c..809b1cfe73bf0 100644 --- a/src/tools/clippy/tests/ui/min_rust_version_attr.stderr +++ b/src/tools/clippy/tests/ui/min_rust_version_attr.stderr @@ -1,5 +1,5 @@ error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:13:19 + --> tests/ui/min_rust_version_attr.rs:13:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let log2_10 = 3.321928094887362; = note: `#[deny(clippy::approx_constant)]` on by default error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:19:19 + --> tests/ui/min_rust_version_attr.rs:19:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:30:19 + --> tests/ui/min_rust_version_attr.rs:30:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:41:19 + --> tests/ui/min_rust_version_attr.rs:41:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:52:19 + --> tests/ui/min_rust_version_attr.rs:52:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> $DIR/min_rust_version_attr.rs:60:27 + --> tests/ui/min_rust_version_attr.rs:60:27 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/min_rust_version_invalid_attr.stderr b/src/tools/clippy/tests/ui/min_rust_version_invalid_attr.stderr index cf8392f03165d..cf0d08a5d21ad 100644 --- a/src/tools/clippy/tests/ui/min_rust_version_invalid_attr.stderr +++ b/src/tools/clippy/tests/ui/min_rust_version_invalid_attr.stderr @@ -1,35 +1,35 @@ error: `invalid.version` is not a valid Rust version - --> $DIR/min_rust_version_invalid_attr.rs:2:1 + --> tests/ui/min_rust_version_invalid_attr.rs:2:1 | LL | #![clippy::msrv = "invalid.version"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `invalid.version` is not a valid Rust version - --> $DIR/min_rust_version_invalid_attr.rs:7:1 + --> tests/ui/min_rust_version_invalid_attr.rs:7:1 | LL | #[clippy::msrv = "invalid.version"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `clippy::msrv` is defined multiple times - --> $DIR/min_rust_version_invalid_attr.rs:14:5 + --> tests/ui/min_rust_version_invalid_attr.rs:14:5 | LL | #![clippy::msrv = "1.10.1"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first definition found here - --> $DIR/min_rust_version_invalid_attr.rs:12:5 + --> tests/ui/min_rust_version_invalid_attr.rs:12:5 | LL | #![clippy::msrv = "1.40"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `clippy::msrv` is defined multiple times - --> $DIR/min_rust_version_invalid_attr.rs:19:9 + --> tests/ui/min_rust_version_invalid_attr.rs:19:9 | LL | #![clippy::msrv = "1.0.0"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first definition found here - --> $DIR/min_rust_version_invalid_attr.rs:18:9 + --> tests/ui/min_rust_version_invalid_attr.rs:18:9 | LL | #![clippy::msrv = "1"] | ^^^^^^^^^^^^^^^^^^^^^^ 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 795d043e2ac76..7f7a4e9d6f623 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 @@ -1,5 +1,5 @@ error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:4:1 + --> tests/ui/mismatched_target_os_non_unix.rs:4:1 | LL | #[cfg(hermit)] | ^^^^^^------^^ @@ -10,7 +10,7 @@ LL | #[cfg(hermit)] = 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 + --> tests/ui/mismatched_target_os_non_unix.rs:7:1 | LL | #[cfg(wasi)] | ^^^^^^----^^ @@ -18,7 +18,7 @@ LL | #[cfg(wasi)] | help: try: `target_os = "wasi"` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:10:1 + --> tests/ui/mismatched_target_os_non_unix.rs:10:1 | LL | #[cfg(none)] | ^^^^^^----^^ @@ -26,7 +26,7 @@ LL | #[cfg(none)] | help: try: `target_os = "none"` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:14:1 + --> tests/ui/mismatched_target_os_non_unix.rs:14:1 | LL | #[cfg(all(not(windows), wasi))] | ^^^^^^^^^^^^^^^^^^^^^^^^----^^^ 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 261c33754e70e..3071bad1324b8 100644 --- a/src/tools/clippy/tests/ui/mismatched_target_os_unix.stderr +++ b/src/tools/clippy/tests/ui/mismatched_target_os_unix.stderr @@ -1,5 +1,5 @@ error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:4:1 + --> tests/ui/mismatched_target_os_unix.rs:4:1 | LL | #[cfg(linux)] | ^^^^^^-----^^ @@ -11,7 +11,7 @@ LL | #[cfg(linux)] = 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 + --> tests/ui/mismatched_target_os_unix.rs:7:1 | LL | #[cfg(freebsd)] | ^^^^^^-------^^ @@ -21,7 +21,7 @@ LL | #[cfg(freebsd)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:10:1 + --> tests/ui/mismatched_target_os_unix.rs:10:1 | LL | #[cfg(dragonfly)] | ^^^^^^---------^^ @@ -31,7 +31,7 @@ LL | #[cfg(dragonfly)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:13:1 + --> tests/ui/mismatched_target_os_unix.rs:13:1 | LL | #[cfg(openbsd)] | ^^^^^^-------^^ @@ -41,7 +41,7 @@ LL | #[cfg(openbsd)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:16:1 + --> tests/ui/mismatched_target_os_unix.rs:16:1 | LL | #[cfg(netbsd)] | ^^^^^^------^^ @@ -51,7 +51,7 @@ LL | #[cfg(netbsd)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:19:1 + --> tests/ui/mismatched_target_os_unix.rs:19:1 | LL | #[cfg(macos)] | ^^^^^^-----^^ @@ -61,7 +61,7 @@ LL | #[cfg(macos)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:22:1 + --> tests/ui/mismatched_target_os_unix.rs:22:1 | LL | #[cfg(ios)] | ^^^^^^---^^ @@ -71,7 +71,7 @@ LL | #[cfg(ios)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:25:1 + --> tests/ui/mismatched_target_os_unix.rs:25:1 | LL | #[cfg(android)] | ^^^^^^-------^^ @@ -81,7 +81,7 @@ LL | #[cfg(android)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:28:1 + --> tests/ui/mismatched_target_os_unix.rs:28:1 | LL | #[cfg(emscripten)] | ^^^^^^----------^^ @@ -91,7 +91,7 @@ LL | #[cfg(emscripten)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:31:1 + --> tests/ui/mismatched_target_os_unix.rs:31:1 | LL | #[cfg(fuchsia)] | ^^^^^^-------^^ @@ -101,7 +101,7 @@ LL | #[cfg(fuchsia)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:34:1 + --> tests/ui/mismatched_target_os_unix.rs:34:1 | LL | #[cfg(haiku)] | ^^^^^^-----^^ @@ -111,7 +111,7 @@ LL | #[cfg(haiku)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:37:1 + --> tests/ui/mismatched_target_os_unix.rs:37:1 | LL | #[cfg(illumos)] | ^^^^^^-------^^ @@ -121,7 +121,7 @@ LL | #[cfg(illumos)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:40:1 + --> tests/ui/mismatched_target_os_unix.rs:40:1 | LL | #[cfg(l4re)] | ^^^^^^----^^ @@ -131,7 +131,7 @@ LL | #[cfg(l4re)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:43:1 + --> tests/ui/mismatched_target_os_unix.rs:43:1 | LL | #[cfg(redox)] | ^^^^^^-----^^ @@ -141,7 +141,7 @@ LL | #[cfg(redox)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:46:1 + --> tests/ui/mismatched_target_os_unix.rs:46:1 | LL | #[cfg(solaris)] | ^^^^^^-------^^ @@ -151,7 +151,7 @@ LL | #[cfg(solaris)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:49:1 + --> tests/ui/mismatched_target_os_unix.rs:49:1 | LL | #[cfg(vxworks)] | ^^^^^^-------^^ @@ -161,7 +161,7 @@ LL | #[cfg(vxworks)] = help: did you mean `unix`? error: operating system used in target family position - --> $DIR/mismatched_target_os_unix.rs:53:1 + --> tests/ui/mismatched_target_os_unix.rs:53:1 | LL | #[cfg(all(not(any(solaris, linux)), freebsd))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 8edbe329503ac..214d9d734d1bb 100644 --- a/src/tools/clippy/tests/ui/mismatching_type_param_order.stderr +++ b/src/tools/clippy/tests/ui/mismatching_type_param_order.stderr @@ -1,5 +1,5 @@ error: `Foo` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:11:20 + --> tests/ui/mismatching_type_param_order.rs:11:20 | LL | impl Foo {} | ^ @@ -9,7 +9,7 @@ LL | impl Foo {} = 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 + --> tests/ui/mismatching_type_param_order.rs:11:23 | LL | impl Foo {} | ^ @@ -17,7 +17,7 @@ LL | impl Foo {} = help: try `B`, or a name that does not conflict with `Foo`'s generic params error: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:16:23 + --> tests/ui/mismatching_type_param_order.rs:16:23 | LL | impl Foo {} | ^ @@ -25,7 +25,7 @@ LL | impl Foo {} = help: try `B`, or a name that does not conflict with `Foo`'s generic params error: `FooLifetime` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:28:44 + --> tests/ui/mismatching_type_param_order.rs:28:44 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | ^ @@ -33,7 +33,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} = help: try `A`, or a name that does not conflict with `FooLifetime`'s generic params error: `FooLifetime` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:28:47 + --> tests/ui/mismatching_type_param_order.rs:28:47 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | ^ @@ -41,7 +41,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} = help: try `B`, or a name that does not conflict with `FooLifetime`'s generic params error: `FooEnum` has a similarly named generic type parameter `C` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:46:27 + --> tests/ui/mismatching_type_param_order.rs:46:27 | LL | impl FooEnum {} | ^ @@ -49,7 +49,7 @@ LL | impl FooEnum {} = help: try `A`, or a name that does not conflict with `FooEnum`'s generic params error: `FooEnum` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:46:30 + --> tests/ui/mismatching_type_param_order.rs:46:30 | LL | impl FooEnum {} | ^ @@ -57,7 +57,7 @@ LL | impl FooEnum {} = help: try `B`, or a name that does not conflict with `FooEnum`'s generic params error: `FooEnum` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:46:33 + --> tests/ui/mismatching_type_param_order.rs:46:33 | LL | impl FooEnum {} | ^ @@ -65,7 +65,7 @@ LL | impl FooEnum {} = help: try `C`, or a name that does not conflict with `FooEnum`'s generic params error: `FooUnion` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:60:31 + --> tests/ui/mismatching_type_param_order.rs:60:31 | LL | impl FooUnion where A: Copy {} | ^ @@ -73,7 +73,7 @@ LL | impl FooUnion where A: Copy {} = help: try `A`, or a name that does not conflict with `FooUnion`'s generic params error: `FooUnion` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> $DIR/mismatching_type_param_order.rs:60:34 + --> tests/ui/mismatching_type_param_order.rs:60:34 | LL | impl FooUnion where A: Copy {} | ^ diff --git a/src/tools/clippy/tests/ui/misnamed_getters.stderr b/src/tools/clippy/tests/ui/misnamed_getters.stderr index 120a3f3112ef1..056fa2be92151 100644 --- a/src/tools/clippy/tests/ui/misnamed_getters.stderr +++ b/src/tools/clippy/tests/ui/misnamed_getters.stderr @@ -1,5 +1,5 @@ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:12:5 + --> tests/ui/misnamed_getters.rs:12:5 | LL | / fn a(&self) -> &u8 { LL | | @@ -13,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::misnamed_getters)]` error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:17:5 + --> tests/ui/misnamed_getters.rs:17:5 | LL | / fn a_mut(&mut self) -> &mut u8 { LL | | @@ -23,7 +23,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:22:5 + --> tests/ui/misnamed_getters.rs:22:5 | LL | / fn b(self) -> u8 { LL | | @@ -33,7 +33,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:27:5 + --> tests/ui/misnamed_getters.rs:27:5 | LL | / fn b_mut(&mut self) -> &mut u8 { LL | | @@ -43,7 +43,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:32:5 + --> tests/ui/misnamed_getters.rs:32:5 | LL | / fn c(&self) -> &u8 { LL | | @@ -53,7 +53,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:37:5 + --> tests/ui/misnamed_getters.rs:37:5 | LL | / fn c_mut(&mut self) -> &mut u8 { LL | | @@ -63,7 +63,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:49:5 + --> tests/ui/misnamed_getters.rs:49:5 | LL | / unsafe fn a(&self) -> &u8 { LL | | @@ -73,7 +73,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:53:5 + --> tests/ui/misnamed_getters.rs:53:5 | LL | / unsafe fn a_mut(&mut self) -> &mut u8 { LL | | @@ -83,7 +83,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:58:5 + --> tests/ui/misnamed_getters.rs:58:5 | LL | / unsafe fn b(self) -> u8 { LL | | @@ -93,7 +93,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:63:5 + --> tests/ui/misnamed_getters.rs:63:5 | LL | / unsafe fn b_mut(&mut self) -> &mut u8 { LL | | @@ -103,7 +103,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:76:5 + --> tests/ui/misnamed_getters.rs:76:5 | LL | / unsafe fn a_unchecked(&self) -> &u8 { LL | | @@ -113,7 +113,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:80:5 + --> tests/ui/misnamed_getters.rs:80:5 | LL | / unsafe fn a_unchecked_mut(&mut self) -> &mut u8 { LL | | @@ -123,7 +123,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:85:5 + --> tests/ui/misnamed_getters.rs:85:5 | LL | / unsafe fn b_unchecked(self) -> u8 { LL | | @@ -133,7 +133,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:90:5 + --> tests/ui/misnamed_getters.rs:90:5 | LL | / unsafe fn b_unchecked_mut(&mut self) -> &mut u8 { LL | | @@ -143,7 +143,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:123:5 + --> tests/ui/misnamed_getters.rs:123:5 | LL | / fn a(&self) -> &u8 { LL | | @@ -153,7 +153,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:127:5 + --> tests/ui/misnamed_getters.rs:127:5 | LL | / fn a_mut(&mut self) -> &mut u8 { LL | | @@ -163,7 +163,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:132:5 + --> tests/ui/misnamed_getters.rs:132:5 | LL | / fn d(&self) -> &u8 { LL | | @@ -173,7 +173,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> $DIR/misnamed_getters.rs:136:5 + --> tests/ui/misnamed_getters.rs:136:5 | LL | / fn d_mut(&mut self) -> &mut u8 { LL | | diff --git a/src/tools/clippy/tests/ui/missing_assert_message.stderr b/src/tools/clippy/tests/ui/missing_assert_message.stderr index e07f52e3f66c6..c4fb7e3b154e4 100644 --- a/src/tools/clippy/tests/ui/missing_assert_message.stderr +++ b/src/tools/clippy/tests/ui/missing_assert_message.stderr @@ -1,5 +1,5 @@ error: assert without any message - --> $DIR/missing_assert_message.rs:12:5 + --> tests/ui/missing_assert_message.rs:12:5 | LL | assert!(foo()); | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | assert!(foo()); = help: to override `-D warnings` add `#[allow(clippy::missing_assert_message)]` error: assert without any message - --> $DIR/missing_assert_message.rs:14:5 + --> tests/ui/missing_assert_message.rs:14:5 | LL | assert_eq!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | assert_eq!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:16:5 + --> tests/ui/missing_assert_message.rs:16:5 | LL | assert_ne!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | assert_ne!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:18:5 + --> tests/ui/missing_assert_message.rs:18:5 | LL | debug_assert!(foo()); | ^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | debug_assert!(foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:20:5 + --> tests/ui/missing_assert_message.rs:20:5 | LL | debug_assert_eq!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | debug_assert_eq!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:22:5 + --> tests/ui/missing_assert_message.rs:22:5 | LL | debug_assert_ne!(foo(), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | debug_assert_ne!(foo(), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:28:5 + --> tests/ui/missing_assert_message.rs:28:5 | LL | assert!(bar!(true)); | ^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | assert!(bar!(true)); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:30:5 + --> tests/ui/missing_assert_message.rs:30:5 | LL | assert!(bar!(true, false)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | assert!(bar!(true, false)); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:32:5 + --> tests/ui/missing_assert_message.rs:32:5 | LL | assert_eq!(bar!(true), foo()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | assert_eq!(bar!(true), foo()); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:34:5 + --> tests/ui/missing_assert_message.rs:34:5 | LL | assert_ne!(bar!(true, true), bar!(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | assert_ne!(bar!(true, true), bar!(true)); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:40:5 + --> tests/ui/missing_assert_message.rs:40:5 | LL | assert!(foo(),); | ^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | assert!(foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:42:5 + --> tests/ui/missing_assert_message.rs:42:5 | LL | assert_eq!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | assert_eq!(foo(), foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:44:5 + --> tests/ui/missing_assert_message.rs:44:5 | LL | assert_ne!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | assert_ne!(foo(), foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:46:5 + --> tests/ui/missing_assert_message.rs:46:5 | LL | debug_assert!(foo(),); | ^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | debug_assert!(foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:48:5 + --> tests/ui/missing_assert_message.rs:48:5 | LL | debug_assert_eq!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | debug_assert_eq!(foo(), foo(),); = help: consider describing why the failing assert is problematic error: assert without any message - --> $DIR/missing_assert_message.rs:50:5 + --> tests/ui/missing_assert_message.rs:50:5 | LL | debug_assert_ne!(foo(), foo(),); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/missing_asserts_for_indexing.stderr b/src/tools/clippy/tests/ui/missing_asserts_for_indexing.stderr index 61dce6ccc6c6a..2e63cd4a0e503 100644 --- a/src/tools/clippy/tests/ui/missing_asserts_for_indexing.stderr +++ b/src/tools/clippy/tests/ui/missing_asserts_for_indexing.stderr @@ -1,5 +1,5 @@ error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:30:5 + --> tests/ui/missing_asserts_for_indexing.rs:30:5 | LL | assert!(v.len() < 5); | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -7,27 +7,27 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:5 + --> tests/ui/missing_asserts_for_indexing.rs:30:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:12 + --> tests/ui/missing_asserts_for_indexing.rs:30:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:19 + --> tests/ui/missing_asserts_for_indexing.rs:30:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:26 + --> tests/ui/missing_asserts_for_indexing.rs:30:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:30:33 + --> tests/ui/missing_asserts_for_indexing.rs:30:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ @@ -36,7 +36,7 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:36:5 + --> tests/ui/missing_asserts_for_indexing.rs:36:5 | LL | assert!(v.len() <= 5); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -44,34 +44,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:5 + --> tests/ui/missing_asserts_for_indexing.rs:36:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:12 + --> tests/ui/missing_asserts_for_indexing.rs:36:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:19 + --> tests/ui/missing_asserts_for_indexing.rs:36:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:26 + --> tests/ui/missing_asserts_for_indexing.rs:36:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:36:33 + --> tests/ui/missing_asserts_for_indexing.rs:36:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:42:5 + --> tests/ui/missing_asserts_for_indexing.rs:42:5 | LL | assert!(v.len() > 3); | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -79,34 +79,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:5 + --> tests/ui/missing_asserts_for_indexing.rs:42:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:12 + --> tests/ui/missing_asserts_for_indexing.rs:42:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:19 + --> tests/ui/missing_asserts_for_indexing.rs:42:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:26 + --> tests/ui/missing_asserts_for_indexing.rs:42:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:42:33 + --> tests/ui/missing_asserts_for_indexing.rs:42:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:48:5 + --> tests/ui/missing_asserts_for_indexing.rs:48:5 | LL | assert!(v.len() >= 4); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -114,34 +114,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:5 + --> tests/ui/missing_asserts_for_indexing.rs:48:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:12 + --> tests/ui/missing_asserts_for_indexing.rs:48:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:19 + --> tests/ui/missing_asserts_for_indexing.rs:48:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:26 + --> tests/ui/missing_asserts_for_indexing.rs:48:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:48:33 + --> tests/ui/missing_asserts_for_indexing.rs:48:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:66:13 + --> tests/ui/missing_asserts_for_indexing.rs:66:13 | LL | assert!(v.len() >= 3); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 3)` @@ -152,19 +152,19 @@ LL | | let _ = v[1..4]; | |___________________^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:66:13 + --> tests/ui/missing_asserts_for_indexing.rs:66:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:68:13 + --> tests/ui/missing_asserts_for_indexing.rs:68:13 | LL | let _ = v[1..4]; | ^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:80:13 + --> tests/ui/missing_asserts_for_indexing.rs:80:13 | LL | assert!(v.len() >= 4); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -175,19 +175,19 @@ LL | | let _ = v[1..=4]; | |____________________^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:80:13 + --> tests/ui/missing_asserts_for_indexing.rs:80:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:82:13 + --> tests/ui/missing_asserts_for_indexing.rs:82:13 | LL | let _ = v[1..=4]; | ^^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:95:13 + --> tests/ui/missing_asserts_for_indexing.rs:95:13 | LL | assert!(v1.len() >= 12); | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` @@ -196,19 +196,19 @@ LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:95:13 + --> tests/ui/missing_asserts_for_indexing.rs:95:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:95:21 + --> tests/ui/missing_asserts_for_indexing.rs:95:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:97:13 + --> tests/ui/missing_asserts_for_indexing.rs:97:13 | LL | assert!(v2.len() >= 15); | ----------------------- help: provide the highest index that is indexed with: `assert!(v2.len() > 15)` @@ -217,19 +217,19 @@ LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:97:13 + --> tests/ui/missing_asserts_for_indexing.rs:97:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:97:21 + --> tests/ui/missing_asserts_for_indexing.rs:97:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:103:13 + --> tests/ui/missing_asserts_for_indexing.rs:103:13 | LL | assert!(v1.len() >= 12); | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` @@ -238,19 +238,19 @@ LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:103:13 + --> tests/ui/missing_asserts_for_indexing.rs:103:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:103:21 + --> tests/ui/missing_asserts_for_indexing.rs:103:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:127:13 + --> tests/ui/missing_asserts_for_indexing.rs:127:13 | LL | assert!(v1.len() == 2); | ---------------------- help: provide the highest index that is indexed with: `assert!(v1.len() == 3)` @@ -259,24 +259,24 @@ LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:127:13 + --> tests/ui/missing_asserts_for_indexing.rs:127:13 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:127:21 + --> tests/ui/missing_asserts_for_indexing.rs:127:21 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:127:29 + --> tests/ui/missing_asserts_for_indexing.rs:127:29 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> $DIR/missing_asserts_for_indexing.rs:131:13 + --> tests/ui/missing_asserts_for_indexing.rs:131:13 | LL | assert!(2 == v3.len()); | ---------------------- help: provide the highest index that is indexed with: `assert!(v3.len() == 3)` @@ -285,17 +285,17 @@ LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:131:13 + --> tests/ui/missing_asserts_for_indexing.rs:131:13 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:131:21 + --> tests/ui/missing_asserts_for_indexing.rs:131:21 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing.rs:131:29 + --> tests/ui/missing_asserts_for_indexing.rs:131:29 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ diff --git a/src/tools/clippy/tests/ui/missing_asserts_for_indexing_unfixable.stderr b/src/tools/clippy/tests/ui/missing_asserts_for_indexing_unfixable.stderr index 12e0542279836..b575e09966ce1 100644 --- a/src/tools/clippy/tests/ui/missing_asserts_for_indexing_unfixable.stderr +++ b/src/tools/clippy/tests/ui/missing_asserts_for_indexing_unfixable.stderr @@ -1,32 +1,32 @@ error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:5 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v.len() > 4);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:5 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:12 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:19 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:26 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:5:33 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:5:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ @@ -35,7 +35,7 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:10:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 | LL | let _ = v[0]; | _____________^ @@ -45,19 +45,19 @@ LL | | let _ = v[1..4]; | = help: consider asserting the length before indexing: `assert!(v.len() > 3);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:10:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:12:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:12:13 | LL | let _ = v[1..4]; | ^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:16:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:16:13 | LL | let a = v[0]; | _____________^ @@ -68,112 +68,112 @@ LL | | let c = v[2]; | = help: consider asserting the length before indexing: `assert!(v.len() > 2);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:16:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:16:13 | LL | let a = v[0]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:18:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:18:13 | LL | let b = v[1]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:19:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:19:13 | LL | let c = v[2]; | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:24:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v1.len() > 12);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:24:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:24:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:24:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:25:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:25:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:25:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:25:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:31:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:31:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:31:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:31:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:40:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:13 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(f.v.len() > 1);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:40:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:13 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:40:22 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:40:22 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> $DIR/missing_asserts_for_indexing_unfixable.rs:54:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:13 | LL | let _ = x[0] + x[1]; | ^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(x.len() > 1);` note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:54:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:13 | LL | let _ = x[0] + x[1]; | ^^^^ note: slice indexed here - --> $DIR/missing_asserts_for_indexing_unfixable.rs:54:20 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:54:20 | LL | let _ = x[0] + x[1]; | ^^^^ 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 b3a8ad8fa717e..082459fd82120 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 @@ -1,5 +1,5 @@ error: this could be a `const fn` - --> $DIR/could_be_const.rs:14:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:14:5 | LL | / pub fn new() -> Self { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/missing_const_for_fn/could_be_const.rs:20:5 | LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:27:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:27:1 | LL | / fn one() -> i32 { LL | | @@ -30,7 +30,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:33:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:33:1 | LL | / fn two() -> i32 { LL | | @@ -40,7 +40,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:40:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:40:1 | LL | / fn string() -> String { LL | | @@ -49,7 +49,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:46:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:46:1 | LL | / unsafe fn four() -> i32 { LL | | @@ -58,7 +58,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:52:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:52:1 | LL | / fn generic(t: T) -> T { LL | | @@ -67,7 +67,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:61:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:61:1 | LL | / fn generic_arr(t: [T; 1]) -> T { LL | | @@ -76,7 +76,7 @@ LL | | } | |_^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:75:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:75:9 | LL | / pub fn b(self, a: &A) -> B { LL | | @@ -85,7 +85,7 @@ LL | | } | |_________^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:85:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:85:5 | LL | / fn const_fn_stabilized_before_msrv(byte: u8) { LL | | @@ -94,7 +94,7 @@ LL | | } | |_____^ error: this could be a `const fn` - --> $DIR/could_be_const.rs:97:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:97:1 | LL | / fn msrv_1_46() -> i32 { LL | | diff --git a/src/tools/clippy/tests/ui/missing_doc.stderr b/src/tools/clippy/tests/ui/missing_doc.stderr index 1d8007fa5b0fc..7e66e2097e90f 100644 --- a/src/tools/clippy/tests/ui/missing_doc.stderr +++ b/src/tools/clippy/tests/ui/missing_doc.stderr @@ -1,5 +1,5 @@ error: missing documentation for a type alias - --> $DIR/missing_doc.rs:16:1 + --> tests/ui/missing_doc.rs:16:1 | LL | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | type Typedef = String; = 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 + --> tests/ui/missing_doc.rs:19:1 | LL | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing_doc.rs:25:1 + --> tests/ui/missing_doc.rs:25:1 | LL | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/missing_doc.rs:39:1 + --> tests/ui/missing_doc.rs:39:1 | LL | / enum Baz { LL | | BazA { a: isize, b: isize }, @@ -29,43 +29,43 @@ LL | | } | |_^ error: missing documentation for a variant - --> $DIR/missing_doc.rs:40:5 + --> tests/ui/missing_doc.rs:40:5 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc.rs:40:12 + --> tests/ui/missing_doc.rs:40:12 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc.rs:40:22 + --> tests/ui/missing_doc.rs:40:22 | LL | BazA { a: isize, b: isize }, | ^^^^^^^^ error: missing documentation for a variant - --> $DIR/missing_doc.rs:41:5 + --> tests/ui/missing_doc.rs:41:5 | LL | BarB, | ^^^^ error: missing documentation for a constant - --> $DIR/missing_doc.rs:65:1 + --> tests/ui/missing_doc.rs:65:1 | LL | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing_doc.rs:74:1 + --> tests/ui/missing_doc.rs:74:1 | LL | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing_doc.rs:83:1 + --> tests/ui/missing_doc.rs:83:1 | LL | / mod internal_impl { LL | | /// dox @@ -77,13 +77,13 @@ LL | | } | |_^ error: missing documentation for a function - --> $DIR/missing_doc.rs:88:5 + --> tests/ui/missing_doc.rs:88:5 | LL | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing_doc.rs:94:9 + --> tests/ui/missing_doc.rs:94:9 | LL | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 3aa9781c2f1da..a421fb986d3a5 100644 --- a/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr +++ b/src/tools/clippy/tests/ui/missing_doc_crate_missing.stderr @@ -1,5 +1,5 @@ error: missing documentation for the crate - --> $DIR/missing_doc_crate_missing.rs:1:1 + --> tests/ui/missing_doc_crate_missing.rs:1:1 | LL | / #![warn(clippy::missing_docs_in_private_items)] LL | | diff --git a/src/tools/clippy/tests/ui/missing_doc_impl.stderr b/src/tools/clippy/tests/ui/missing_doc_impl.stderr index e303b7b7d9fdb..e2052c346df8f 100644 --- a/src/tools/clippy/tests/ui/missing_doc_impl.stderr +++ b/src/tools/clippy/tests/ui/missing_doc_impl.stderr @@ -1,5 +1,5 @@ error: missing documentation for a struct - --> $DIR/missing_doc_impl.rs:13:1 + --> tests/ui/missing_doc_impl.rs:13:1 | LL | / struct Foo { LL | | a: isize, @@ -11,25 +11,25 @@ LL | | } = 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 + --> tests/ui/missing_doc_impl.rs:14:5 | LL | a: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc_impl.rs:15:5 + --> tests/ui/missing_doc_impl.rs:15:5 | LL | b: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing_doc_impl.rs:20:5 + --> tests/ui/missing_doc_impl.rs:20:5 | LL | b: isize, | ^^^^^^^^ error: missing documentation for an associated function - --> $DIR/missing_doc_impl.rs:67:5 + --> tests/ui/missing_doc_impl.rs:67:5 | LL | / pub fn new() -> Self { LL | | Foo { a: 0, b: 0 } @@ -37,13 +37,13 @@ LL | | } | |_____^ error: missing documentation for an associated function - --> $DIR/missing_doc_impl.rs:70:5 + --> tests/ui/missing_doc_impl.rs:70:5 | LL | fn bar() {} | ^^^^^^^^^^^ error: missing documentation for an associated function - --> $DIR/missing_doc_impl.rs:78:5 + --> tests/ui/missing_doc_impl.rs:78:5 | LL | / fn foo2() -> u32 { LL | | 1 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 481b2c6321778..6f8a9abe9228d 100644 --- a/src/tools/clippy/tests/ui/missing_fields_in_debug.stderr +++ b/src/tools/clippy/tests/ui/missing_fields_in_debug.stderr @@ -1,5 +1,5 @@ error: manual `Debug` impl does not include all fields - --> $DIR/missing_fields_in_debug.rs:13:1 + --> tests/ui/missing_fields_in_debug.rs:13:1 | LL | / impl fmt::Debug for NamedStruct1Ignored { LL | | @@ -11,7 +11,7 @@ LL | | } | |_^ | note: this field is unused - --> $DIR/missing_fields_in_debug.rs:10:5 + --> tests/ui/missing_fields_in_debug.rs:10:5 | LL | hidden: u32, | ^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | hidden: u32, = 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 + --> tests/ui/missing_fields_in_debug.rs:32:1 | LL | / impl fmt::Debug for NamedStructMultipleIgnored { LL | | @@ -33,17 +33,17 @@ LL | | } | |_^ | note: this field is unused - --> $DIR/missing_fields_in_debug.rs:26:5 + --> tests/ui/missing_fields_in_debug.rs:26:5 | LL | hidden: u32, | ^^^^^^^^^^^ note: this field is unused - --> $DIR/missing_fields_in_debug.rs:27:5 + --> tests/ui/missing_fields_in_debug.rs:27:5 | LL | hidden2: String, | ^^^^^^^^^^^^^^^ note: this field is unused - --> $DIR/missing_fields_in_debug.rs:29:5 + --> tests/ui/missing_fields_in_debug.rs:29:5 | LL | hidden4: ((((u8), u16), u32), u64), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | hidden4: ((((u8), u16), u32), u64), = help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields error: manual `Debug` impl does not include all fields - --> $DIR/missing_fields_in_debug.rs:94:1 + --> tests/ui/missing_fields_in_debug.rs:94:1 | LL | / impl fmt::Debug for MultiExprDebugImpl { LL | | @@ -63,7 +63,7 @@ LL | | } | |_^ | note: this field is unused - --> $DIR/missing_fields_in_debug.rs:90:5 + --> tests/ui/missing_fields_in_debug.rs:90:5 | LL | b: String, | ^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/missing_inline.stderr b/src/tools/clippy/tests/ui/missing_inline.stderr index da2a2a7fedd46..c2bb37141a025 100644 --- a/src/tools/clippy/tests/ui/missing_inline.stderr +++ b/src/tools/clippy/tests/ui/missing_inline.stderr @@ -1,5 +1,5 @@ error: missing `#[inline]` for a function - --> $DIR/missing_inline.rs:20:1 + --> tests/ui/missing_inline.rs:20:1 | LL | pub fn pub_foo() {} | ^^^^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | pub fn pub_foo() {} = 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 + --> tests/ui/missing_inline.rs:39:5 | LL | fn PubBar_b() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:55:5 + --> tests/ui/missing_inline.rs:55:5 | LL | fn PubBar_a() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:58:5 + --> tests/ui/missing_inline.rs:58:5 | LL | fn PubBar_b() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:61:5 + --> tests/ui/missing_inline.rs:61:5 | LL | fn PubBar_c() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:73:5 + --> tests/ui/missing_inline.rs:73:5 | LL | pub fn PubFooImpl() {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/missing_panics_doc.stderr b/src/tools/clippy/tests/ui/missing_panics_doc.stderr index efee485508ec8..c6a939d86f7c7 100644 --- a/src/tools/clippy/tests/ui/missing_panics_doc.stderr +++ b/src/tools/clippy/tests/ui/missing_panics_doc.stderr @@ -1,11 +1,11 @@ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:13:1 + --> tests/ui/missing_panics_doc.rs:13:1 | LL | pub fn unwrap() { | ^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:15:5 + --> tests/ui/missing_panics_doc.rs:15:5 | LL | result.unwrap() | ^^^^^^^^^^^^^^^ @@ -13,133 +13,133 @@ LL | result.unwrap() = 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 + --> tests/ui/missing_panics_doc.rs:19:1 | LL | pub fn panic() { | ^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:20:5 + --> tests/ui/missing_panics_doc.rs:20:5 | LL | panic!("This function panics") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:24:1 + --> tests/ui/missing_panics_doc.rs:24:1 | LL | pub fn inner_body(opt: Option) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:27:13 + --> tests/ui/missing_panics_doc.rs:27:13 | LL | panic!() | ^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:33:1 + --> tests/ui/missing_panics_doc.rs:33:1 | LL | pub fn unreachable_and_panic() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:34:39 + --> tests/ui/missing_panics_doc.rs:34:39 | LL | if true { unreachable!() } else { panic!() } | ^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:38:1 + --> tests/ui/missing_panics_doc.rs:38:1 | LL | pub fn assert_eq() { | ^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:40:5 + --> tests/ui/missing_panics_doc.rs:40:5 | LL | assert_eq!(x, 0); | ^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:44:1 + --> tests/ui/missing_panics_doc.rs:44:1 | LL | pub fn assert_ne() { | ^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:46:5 + --> tests/ui/missing_panics_doc.rs:46:5 | LL | assert_ne!(x, 0); | ^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:151:5 + --> tests/ui/missing_panics_doc.rs:151:5 | LL | pub fn option_unwrap(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:153:9 + --> tests/ui/missing_panics_doc.rs:153:9 | LL | o.unwrap() | ^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:156:5 + --> tests/ui/missing_panics_doc.rs:156:5 | LL | pub fn option_expect(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:158:9 + --> tests/ui/missing_panics_doc.rs:158:9 | LL | o.expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:161:5 + --> tests/ui/missing_panics_doc.rs:161:5 | LL | pub fn result_unwrap(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:163:9 + --> tests/ui/missing_panics_doc.rs:163:9 | LL | res.unwrap() | ^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:166:5 + --> tests/ui/missing_panics_doc.rs:166:5 | LL | pub fn result_expect(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:168:9 + --> tests/ui/missing_panics_doc.rs:168:9 | LL | res.expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:171:5 + --> tests/ui/missing_panics_doc.rs:171:5 | LL | pub fn last_unwrap(v: &[u32]) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:172:10 + --> tests/ui/missing_panics_doc.rs:172:10 | LL | *v.last().unwrap() | ^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section - --> $DIR/missing_panics_doc.rs:175:5 + --> tests/ui/missing_panics_doc.rs:175:5 | LL | pub fn last_expect(v: &[u32]) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here - --> $DIR/missing_panics_doc.rs:176:10 + --> tests/ui/missing_panics_doc.rs:176:10 | LL | *v.last().expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/missing_spin_loop.stderr b/src/tools/clippy/tests/ui/missing_spin_loop.stderr index a84c19d592617..12f4b53a3d187 100644 --- a/src/tools/clippy/tests/ui/missing_spin_loop.stderr +++ b/src/tools/clippy/tests/ui/missing_spin_loop.stderr @@ -1,5 +1,5 @@ error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:10:37 + --> tests/ui/missing_spin_loop.rs:10:37 | LL | while b.load(Ordering::Acquire) {} | ^^ help: try: `{ std::hint::spin_loop() }` @@ -8,31 +8,31 @@ LL | while b.load(Ordering::Acquire) {} = 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 + --> tests/ui/missing_spin_loop.rs:12:37 | LL | while !b.load(Ordering::SeqCst) {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:14:46 + --> tests/ui/missing_spin_loop.rs:14:46 | LL | while b.load(Ordering::Acquire) == false {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:16:49 + --> tests/ui/missing_spin_loop.rs:16:49 | LL | while { true == b.load(Ordering::Acquire) } {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:18:93 + --> tests/ui/missing_spin_loop.rs:18:93 | LL | while b.compare_exchange(true, false, Ordering::Acquire, Ordering::Relaxed) != Ok(true) {} | ^^ help: try: `{ std::hint::spin_loop() }` error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop.rs:20:94 + --> tests/ui/missing_spin_loop.rs:20:94 | LL | while Ok(false) != b.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed) {} | ^^ help: try: `{ std::hint::spin_loop() }` 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 d84d06088ba35..7911620d32c50 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 @@ -1,5 +1,5 @@ error: busy-waiting loop should at least have a spin loop hint - --> $DIR/missing_spin_loop_no_std.rs:12:37 + --> tests/ui/missing_spin_loop_no_std.rs:12:37 | LL | while b.load(Ordering::Acquire) {} | ^^ help: try: `{ core::hint::spin_loop() }` diff --git a/src/tools/clippy/tests/ui/missing_trait_methods.stderr b/src/tools/clippy/tests/ui/missing_trait_methods.stderr index 3e20a51e0842f..f5d5d4418b287 100644 --- a/src/tools/clippy/tests/ui/missing_trait_methods.stderr +++ b/src/tools/clippy/tests/ui/missing_trait_methods.stderr @@ -1,11 +1,11 @@ error: missing trait method provided by default: `provided` - --> $DIR/missing_trait_methods.rs:22:1 + --> tests/ui/missing_trait_methods.rs:22:1 | LL | impl A for Partial {} | ^^^^^^^^^^^^^^^^^^ | help: implement the method - --> $DIR/missing_trait_methods.rs:5:5 + --> tests/ui/missing_trait_methods.rs:5:5 | LL | fn provided() {} | ^^^^^^^^^^^^^ @@ -13,13 +13,13 @@ LL | fn provided() {} = 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 + --> tests/ui/missing_trait_methods.rs:25:1 | LL | impl B for Partial { | ^^^^^^^^^^^^^^^^^^ | help: implement the method - --> $DIR/missing_trait_methods.rs:15:5 + --> tests/ui/missing_trait_methods.rs:15:5 | LL | fn b<'a, T: AsRef<[u8]>>(a: &'a T) -> &'a [u8] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/mistyped_literal_suffix.stderr b/src/tools/clippy/tests/ui/mistyped_literal_suffix.stderr index ecd73497a8e78..56bfb06d8e669 100644 --- a/src/tools/clippy/tests/ui/mistyped_literal_suffix.stderr +++ b/src/tools/clippy/tests/ui/mistyped_literal_suffix.stderr @@ -1,5 +1,5 @@ error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:16:18 + --> tests/ui/mistyped_literal_suffix.rs:16:18 | LL | let fail14 = 2_32; | ^^^^ help: did you mean to write: `2_i32` @@ -7,91 +7,91 @@ LL | let fail14 = 2_32; = note: `#[deny(clippy::mistyped_literal_suffixes)]` on by default error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:17:18 + --> tests/ui/mistyped_literal_suffix.rs:17:18 | LL | let fail15 = 4_64; | ^^^^ help: did you mean to write: `4_i64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:18:18 + --> tests/ui/mistyped_literal_suffix.rs:18:18 | LL | let fail16 = 7_8; // | ^^^ help: did you mean to write: `7_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:19:18 + --> tests/ui/mistyped_literal_suffix.rs:19:18 | LL | let fail17 = 23_16; // | ^^^^^ help: did you mean to write: `23_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:22:18 + --> tests/ui/mistyped_literal_suffix.rs:22:18 | LL | let fail20 = 2__8; // | ^^^^ help: did you mean to write: `2_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:23:18 + --> tests/ui/mistyped_literal_suffix.rs:23:18 | LL | let fail21 = 4___16; // | ^^^^^^ help: did you mean to write: `4_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:26:18 + --> tests/ui/mistyped_literal_suffix.rs:26:18 | LL | let fail25 = 1E2_32; | ^^^^^^ help: did you mean to write: `1E2_f32` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:27:18 + --> tests/ui/mistyped_literal_suffix.rs:27:18 | LL | let fail26 = 43E7_64; | ^^^^^^^ help: did you mean to write: `43E7_f64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:28:18 + --> tests/ui/mistyped_literal_suffix.rs:28:18 | LL | let fail27 = 243E17_32; | ^^^^^^^^^ help: did you mean to write: `243E17_f32` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:29:18 + --> tests/ui/mistyped_literal_suffix.rs:29:18 | LL | let fail28 = 241251235E723_64; | ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:33:18 + --> tests/ui/mistyped_literal_suffix.rs:33:18 | LL | let fail30 = 127_8; // should be i8 | ^^^^^ help: did you mean to write: `127_i8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:34:18 + --> tests/ui/mistyped_literal_suffix.rs:34:18 | LL | let fail31 = 240_8; // should be u8 | ^^^^^ help: did you mean to write: `240_u8` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:36:18 + --> tests/ui/mistyped_literal_suffix.rs:36:18 | LL | let fail33 = 0x1234_16; | ^^^^^^^^^ help: did you mean to write: `0x1234_i16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:37:18 + --> tests/ui/mistyped_literal_suffix.rs:37:18 | LL | let fail34 = 0xABCD_16; | ^^^^^^^^^ help: did you mean to write: `0xABCD_u16` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:39:18 + --> tests/ui/mistyped_literal_suffix.rs:39:18 | LL | let fail36 = 0xFFFF_FFFF_FFFF_FFFF_64; // u64 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to write: `0xFFFF_FFFF_FFFF_FFFF_u64` error: mistyped literal suffix - --> $DIR/mistyped_literal_suffix.rs:45:13 + --> tests/ui/mistyped_literal_suffix.rs:45:13 | LL | let _ = 1.12345E1_32; | ^^^^^^^^^^^^ help: did you mean to write: `1.123_45E1_f32` 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 3dad98815c618..796d4ccd26b72 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 @@ -1,11 +1,11 @@ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:14:9 + --> tests/ui/mixed_read_write_in_expression.rs:14:9 | LL | } + x; | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:12:9 + --> tests/ui/mixed_read_write_in_expression.rs:12:9 | LL | x = 1; | ^^^^^ @@ -13,37 +13,37 @@ LL | x = 1; = 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 + --> tests/ui/mixed_read_write_in_expression.rs:18:5 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:20:9 + --> tests/ui/mixed_read_write_in_expression.rs:20:9 | LL | x = 20; | ^^^^^^ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:32:12 + --> tests/ui/mixed_read_write_in_expression.rs:32:12 | LL | a: x, | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:35:13 + --> tests/ui/mixed_read_write_in_expression.rs:35:13 | LL | x = 6; | ^^^^^ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:42:9 + --> tests/ui/mixed_read_write_in_expression.rs:42:9 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:44:13 + --> tests/ui/mixed_read_write_in_expression.rs:44:13 | LL | x = 20; | ^^^^^^ diff --git a/src/tools/clippy/tests/ui/module_inception.stderr b/src/tools/clippy/tests/ui/module_inception.stderr index d5856614f91f1..455f5372747a4 100644 --- a/src/tools/clippy/tests/ui/module_inception.stderr +++ b/src/tools/clippy/tests/ui/module_inception.stderr @@ -1,5 +1,5 @@ error: module has the same name as its containing module - --> $DIR/module_inception.rs:5:9 + --> tests/ui/module_inception.rs:5:9 | LL | / pub mod bar2 { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/module_inception.rs:12:5 | LL | / pub mod foo2 { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: module has the same name as its containing module - --> $DIR/module_inception.rs:20:9 + --> tests/ui/module_inception.rs:20:9 | LL | / mod bar { LL | | @@ -30,7 +30,7 @@ LL | | } | |_________^ error: module has the same name as its containing module - --> $DIR/module_inception.rs:26:5 + --> tests/ui/module_inception.rs:26:5 | LL | / mod foo { LL | | diff --git a/src/tools/clippy/tests/ui/module_name_repetitions.stderr b/src/tools/clippy/tests/ui/module_name_repetitions.stderr index 1854d3a859a7a..bffb08f6f879f 100644 --- a/src/tools/clippy/tests/ui/module_name_repetitions.stderr +++ b/src/tools/clippy/tests/ui/module_name_repetitions.stderr @@ -1,5 +1,5 @@ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:8:12 + --> tests/ui/module_name_repetitions.rs:8:12 | LL | pub fn foo_bar() {} | ^^^^^^^ @@ -8,25 +8,25 @@ LL | pub fn foo_bar() {} = 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 + --> tests/ui/module_name_repetitions.rs:11:12 | LL | pub fn bar_foo() {} | ^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:13:16 + --> tests/ui/module_name_repetitions.rs:13:16 | LL | pub struct FooCake; | ^^^^^^^ error: item name ends with its containing module's name - --> $DIR/module_name_repetitions.rs:15:14 + --> tests/ui/module_name_repetitions.rs:15:14 | LL | pub enum CakeFoo {} | ^^^^^^^ error: item name starts with its containing module's name - --> $DIR/module_name_repetitions.rs:17:16 + --> tests/ui/module_name_repetitions.rs:17:16 | LL | pub struct Foo7Bar; | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr b/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr index 46c8d0288a358..fa3a64cfb7146 100644 --- a/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr +++ b/src/tools/clippy/tests/ui/modulo_arithmetic_float.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on constants with different signs: `-1.600 % 2.100` - --> $DIR/modulo_arithmetic_float.rs:6:5 + --> tests/ui/modulo_arithmetic_float.rs:6:5 | LL | -1.6 % 2.1; | ^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | -1.6 % 2.1; = 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 + --> tests/ui/modulo_arithmetic_float.rs:9:5 | LL | 1.6 % -2.1; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | 1.6 % -2.1; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on constants with different signs: `-1.200 % 3.400` - --> $DIR/modulo_arithmetic_float.rs:12:5 + --> tests/ui/modulo_arithmetic_float.rs:12:5 | LL | (1.1 - 2.3) % (1.1 + 2.3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | (1.1 - 2.3) % (1.1 + 2.3); = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on constants with different signs: `3.400 % -1.200` - --> $DIR/modulo_arithmetic_float.rs:15:5 + --> tests/ui/modulo_arithmetic_float.rs:15:5 | LL | (1.1 + 2.3) % (1.1 - 2.3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | (1.1 + 2.3) % (1.1 - 2.3); = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:22:5 + --> tests/ui/modulo_arithmetic_float.rs:22:5 | LL | a_f32 % b_f32; | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | a_f32 % b_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:25:5 + --> tests/ui/modulo_arithmetic_float.rs:25:5 | LL | b_f32 % a_f32; | ^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | b_f32 % a_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:28:5 + --> tests/ui/modulo_arithmetic_float.rs:28:5 | LL | b_f32 %= a_f32; | ^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | b_f32 %= a_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:34:5 + --> tests/ui/modulo_arithmetic_float.rs:34:5 | LL | a_f64 % b_f64; | ^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | a_f64 % b_f64; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:37:5 + --> tests/ui/modulo_arithmetic_float.rs:37:5 | LL | b_f64 % a_f64; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | b_f64 % a_f64; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_float.rs:40:5 + --> tests/ui/modulo_arithmetic_float.rs:40:5 | LL | b_f64 %= a_f64; | ^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr b/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr index 033a016c0e6f1..f1cfe791a03b0 100644 --- a/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr +++ b/src/tools/clippy/tests/ui/modulo_arithmetic_integral.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:8:5 + --> tests/ui/modulo_arithmetic_integral.rs:8:5 | LL | a % b; | ^^^^^ @@ -10,7 +10,7 @@ LL | a % b; = 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 + --> tests/ui/modulo_arithmetic_integral.rs:11:5 | LL | b % a; | ^^^^^ @@ -19,7 +19,7 @@ LL | b % a; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:14:5 + --> tests/ui/modulo_arithmetic_integral.rs:14:5 | LL | b %= a; | ^^^^^^ @@ -28,7 +28,7 @@ LL | b %= a; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:20:5 + --> tests/ui/modulo_arithmetic_integral.rs:20:5 | LL | a_i8 % b_i8; | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | a_i8 % b_i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:23:5 + --> tests/ui/modulo_arithmetic_integral.rs:23:5 | LL | b_i8 %= a_i8; | ^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | b_i8 %= a_i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:29:5 + --> tests/ui/modulo_arithmetic_integral.rs:29:5 | LL | a_i16 % b_i16; | ^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | a_i16 % b_i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:32:5 + --> tests/ui/modulo_arithmetic_integral.rs:32:5 | LL | b_i16 %= a_i16; | ^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | b_i16 %= a_i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:38:5 + --> tests/ui/modulo_arithmetic_integral.rs:38:5 | LL | a_i32 % b_i32; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | a_i32 % b_i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:41:5 + --> tests/ui/modulo_arithmetic_integral.rs:41:5 | LL | b_i32 %= a_i32; | ^^^^^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | b_i32 %= a_i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:47:5 + --> tests/ui/modulo_arithmetic_integral.rs:47:5 | LL | a_i64 % b_i64; | ^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | a_i64 % b_i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:50:5 + --> tests/ui/modulo_arithmetic_integral.rs:50:5 | LL | b_i64 %= a_i64; | ^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | b_i64 %= a_i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:56:5 + --> tests/ui/modulo_arithmetic_integral.rs:56:5 | LL | a_i128 % b_i128; | ^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | a_i128 % b_i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:59:5 + --> tests/ui/modulo_arithmetic_integral.rs:59:5 | LL | b_i128 %= a_i128; | ^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | b_i128 %= a_i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:65:5 + --> tests/ui/modulo_arithmetic_integral.rs:65:5 | LL | a_isize % b_isize; | ^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | a_isize % b_isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:68:5 + --> tests/ui/modulo_arithmetic_integral.rs:68:5 | LL | b_isize %= a_isize; | ^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | b_isize %= a_isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:74:5 + --> tests/ui/modulo_arithmetic_integral.rs:74:5 | LL | a % b; | ^^^^^ @@ -145,7 +145,7 @@ LL | a % b; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> $DIR/modulo_arithmetic_integral.rs:77:5 + --> tests/ui/modulo_arithmetic_integral.rs:77:5 | LL | b %= a; | ^^^^^^ 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 47ed2261a7b66..722d9b83660ee 100644 --- a/src/tools/clippy/tests/ui/modulo_arithmetic_integral_const.stderr +++ b/src/tools/clippy/tests/ui/modulo_arithmetic_integral_const.stderr @@ -1,5 +1,5 @@ error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:11:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:11:5 | LL | -1 % 2; | ^^^^^^ @@ -10,7 +10,7 @@ LL | -1 % 2; = 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 + --> tests/ui/modulo_arithmetic_integral_const.rs:14:5 | LL | 1 % -2; | ^^^^^^ @@ -19,7 +19,7 @@ LL | 1 % -2; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 3` - --> $DIR/modulo_arithmetic_integral_const.rs:17:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:17:5 | LL | (1 - 2) % (1 + 2); | ^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | (1 - 2) % (1 + 2); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `3 % -1` - --> $DIR/modulo_arithmetic_integral_const.rs:20:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:20:5 | LL | (1 + 2) % (1 - 2); | ^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | (1 + 2) % (1 - 2); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-35 % 300000` - --> $DIR/modulo_arithmetic_integral_const.rs:23:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:23:5 | LL | 35 * (7 - 4 * 2) % (-500 * -600); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | 35 * (7 - 4 * 2) % (-500 * -600); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:27:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:27:5 | LL | -1i8 % 2i8; | ^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | -1i8 % 2i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:30:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:30:5 | LL | 1i8 % -2i8; | ^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | 1i8 % -2i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:33:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:33:5 | LL | -1i16 % 2i16; | ^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | -1i16 % 2i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:36:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:36:5 | LL | 1i16 % -2i16; | ^^^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | 1i16 % -2i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:39:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:39:5 | LL | -1i32 % 2i32; | ^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | -1i32 % 2i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:42:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:42:5 | LL | 1i32 % -2i32; | ^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | 1i32 % -2i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:45:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:45:5 | LL | -1i64 % 2i64; | ^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | -1i64 % 2i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:48:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:48:5 | LL | 1i64 % -2i64; | ^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | 1i64 % -2i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:51:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:51:5 | LL | -1i128 % 2i128; | ^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | -1i128 % 2i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:54:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:54:5 | LL | 1i128 % -2i128; | ^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | 1i128 % -2i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> $DIR/modulo_arithmetic_integral_const.rs:57:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:57:5 | LL | -1isize % 2isize; | ^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | -1isize % 2isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> $DIR/modulo_arithmetic_integral_const.rs:60:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:60:5 | LL | 1isize % -2isize; | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/modulo_one.stderr b/src/tools/clippy/tests/ui/modulo_one.stderr index 06bbb0f5d9a80..aedcf24eae71e 100644 --- a/src/tools/clippy/tests/ui/modulo_one.stderr +++ b/src/tools/clippy/tests/ui/modulo_one.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/modulo_one.rs:15:5 + --> tests/ui/modulo_one.rs:15:5 | LL | i32::MIN % (-1); | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow @@ -7,13 +7,13 @@ LL | i32::MIN % (-1); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/modulo_one.rs:33:5 + --> tests/ui/modulo_one.rs:33:5 | LL | INT_MIN % NEG_ONE; | ^^^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: any number modulo 1 will be 0 - --> $DIR/modulo_one.rs:8:5 + --> tests/ui/modulo_one.rs:8:5 | LL | 10 % 1; | ^^^^^^ @@ -22,31 +22,31 @@ LL | 10 % 1; = 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 + --> tests/ui/modulo_one.rs:11:5 | LL | 10 % -1; | ^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> $DIR/modulo_one.rs:15:5 + --> tests/ui/modulo_one.rs:15:5 | LL | i32::MIN % (-1); | ^^^^^^^^^^^^^^^ error: any number modulo 1 will be 0 - --> $DIR/modulo_one.rs:24:5 + --> tests/ui/modulo_one.rs:24:5 | LL | 2 % ONE; | ^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> $DIR/modulo_one.rs:28:5 + --> tests/ui/modulo_one.rs:28:5 | LL | 2 % NEG_ONE; | ^^^^^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> $DIR/modulo_one.rs:33:5 + --> tests/ui/modulo_one.rs:33:5 | LL | INT_MIN % NEG_ONE; | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/multi_assignments.stderr b/src/tools/clippy/tests/ui/multi_assignments.stderr index 9719b5e66847b..53c22fcdb4c07 100644 --- a/src/tools/clippy/tests/ui/multi_assignments.stderr +++ b/src/tools/clippy/tests/ui/multi_assignments.stderr @@ -1,5 +1,5 @@ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:4:5 + --> tests/ui/multi_assignments.rs:4:5 | LL | a = b = c; | ^^^^^^^^^ @@ -8,31 +8,31 @@ LL | a = b = c; = help: to override `-D warnings` add `#[allow(clippy::multi_assignments)]` error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:7:5 + --> tests/ui/multi_assignments.rs:7:5 | LL | a = b = c = d; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:7:9 + --> tests/ui/multi_assignments.rs:7:9 | LL | a = b = c = d; | ^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:10:5 + --> tests/ui/multi_assignments.rs:10:5 | LL | a = b = { c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:12:5 + --> tests/ui/multi_assignments.rs:12:5 | LL | a = { b = c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:14:5 + --> tests/ui/multi_assignments.rs:14:5 | LL | a = (b = c); | ^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/multiple_bound_locations.rs b/src/tools/clippy/tests/ui/multiple_bound_locations.rs new file mode 100644 index 0000000000000..de9d994782ece --- /dev/null +++ b/src/tools/clippy/tests/ui/multiple_bound_locations.rs @@ -0,0 +1,60 @@ +#![warn(clippy::multiple_bound_locations)] + +fn ty(a: F) +//~^ ERROR: bound is defined in more than one place +where + F: Sized, +{ +} + +fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) +//~^ ERROR: bound is defined in more than one place +where + 'b: 'c, +{ +} + +fn ty_pred() +//~^ ERROR: bound is defined in more than one place +where + for<'a> F: Send + 'a, +{ +} + +struct B; + +impl B { + fn ty(a: F) + //~^ ERROR: bound is defined in more than one place + where + F: Sized, + { + } + + fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) + //~^ ERROR: bound is defined in more than one place + where + 'b: 'c, + { + } + + fn ty_pred() + //~^ ERROR: bound is defined in more than one place + where + for<'a> F: Send + 'a, + { + } +} + +struct C(F); + +impl C { + fn foo(_f: F) -> Self + where + F: std::fmt::Display, + { + todo!() + } +} + +fn main() {} diff --git a/src/tools/clippy/tests/ui/multiple_bound_locations.stderr b/src/tools/clippy/tests/ui/multiple_bound_locations.stderr new file mode 100644 index 0000000000000..22dd2e0a55249 --- /dev/null +++ b/src/tools/clippy/tests/ui/multiple_bound_locations.stderr @@ -0,0 +1,59 @@ +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:3:7 + | +LL | fn ty(a: F) + | ^ +... +LL | F: Sized, + | ^ + | + = note: `-D clippy::multiple-bound-locations` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::multiple_bound_locations)]` + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:10:17 + | +LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) + | ^^ +... +LL | 'b: 'c, + | ^^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:17:12 + | +LL | fn ty_pred() + | ^ +... +LL | for<'a> F: Send + 'a, + | ^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:27:11 + | +LL | fn ty(a: F) + | ^ +... +LL | F: Sized, + | ^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:34:21 + | +LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) + | ^^ +... +LL | 'b: 'c, + | ^^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:41:16 + | +LL | fn ty_pred() + | ^ +... +LL | for<'a> F: Send + 'a, + | ^ + +error: aborting due to 6 previous errors + 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 4803a5089ab25..cff85ae115e08 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 @@ -1,5 +1,5 @@ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:36:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:36:5 | LL | / unsafe { LL | | STATIC += 1; @@ -8,12 +8,12 @@ LL | | } | |_____^ | note: modification of a mutable static occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:37:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:37:9 | LL | STATIC += 1; | ^^^^^^^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:38:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:38:9 | LL | not_very_safe(); | ^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | not_very_safe(); = 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 + --> tests/ui/multiple_unsafe_ops_per_block.rs:45:5 | LL | / unsafe { LL | | drop(u.u); @@ -30,18 +30,18 @@ LL | | } | |_____^ | note: union field access occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:46:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:46:14 | LL | drop(u.u); | ^^^ note: raw pointer dereference occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:47:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:47:9 | LL | *raw_ptr(); | ^^^^^^^^^^ error: this `unsafe` block contains 3 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:52:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:52:5 | LL | / unsafe { LL | | asm!("nop"); @@ -51,23 +51,23 @@ LL | | } | |_____^ | note: inline assembly used here - --> $DIR/multiple_unsafe_ops_per_block.rs:53:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:53:9 | LL | asm!("nop"); | ^^^^^^^^^^^ note: unsafe method call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:54:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:54:9 | LL | sample.not_very_safe(); | ^^^^^^^^^^^^^^^^^^^^^^ note: modification of a mutable static occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:55:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:55:9 | LL | STATIC = 0; | ^^^^^^^^^^ error: this `unsafe` block contains 6 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:61:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:61:5 | LL | / unsafe { LL | | drop(u.u); @@ -79,55 +79,55 @@ LL | | } | |_____^ | note: union field access occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:62:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:62:14 | LL | drop(u.u); | ^^^ note: access of a mutable static occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:63:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:63:14 | LL | drop(STATIC); | ^^^^^^ note: unsafe method call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:64:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:64:9 | LL | sample.not_very_safe(); | ^^^^^^^^^^^^^^^^^^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:65:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:65:9 | LL | not_very_safe(); | ^^^^^^^^^^^^^^^ note: raw pointer dereference occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:66:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:66:9 | LL | *raw_ptr(); | ^^^^^^^^^^ note: inline assembly used here - --> $DIR/multiple_unsafe_ops_per_block.rs:67:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:67:9 | LL | asm!("nop"); | ^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:105:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:105:5 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:105:14 + --> tests/ui/multiple_unsafe_ops_per_block.rs:105:14 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: raw pointer dereference occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:105:39 + --> tests/ui/multiple_unsafe_ops_per_block.rs:105:39 | LL | unsafe { char::from_u32_unchecked(*ptr.cast::()) } | ^^^^^^^^^^^^^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:123:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:123:5 | LL | / unsafe { LL | | x(); @@ -136,18 +136,18 @@ LL | | } | |_____^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:124:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:124:9 | LL | x(); | ^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:125:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:125:9 | LL | x(); | ^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:134:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:134:9 | LL | / unsafe { LL | | T::X(); @@ -156,18 +156,18 @@ LL | | } | |_________^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:135:13 + --> tests/ui/multiple_unsafe_ops_per_block.rs:135:13 | LL | T::X(); | ^^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:136:13 + --> tests/ui/multiple_unsafe_ops_per_block.rs:136:13 | LL | T::X(); | ^^^^^^ error: this `unsafe` block contains 2 unsafe operations, expected only one - --> $DIR/multiple_unsafe_ops_per_block.rs:144:5 + --> tests/ui/multiple_unsafe_ops_per_block.rs:144:5 | LL | / unsafe { LL | | x.0(); @@ -176,12 +176,12 @@ LL | | } | |_____^ | note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:145:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:145:9 | LL | x.0(); | ^^^^^ note: unsafe function call occurs here - --> $DIR/multiple_unsafe_ops_per_block.rs:146:9 + --> tests/ui/multiple_unsafe_ops_per_block.rs:146:9 | LL | x.0(); | ^^^^^ diff --git a/src/tools/clippy/tests/ui/must_use_candidates.stderr b/src/tools/clippy/tests/ui/must_use_candidates.stderr index 98175dbd45848..c64636ba44258 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.stderr +++ b/src/tools/clippy/tests/ui/must_use_candidates.stderr @@ -1,5 +1,5 @@ error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:11:1 + --> tests/ui/must_use_candidates.rs:11:1 | LL | pub fn pure(i: u8) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8` @@ -8,25 +8,25 @@ LL | pub fn pure(i: u8) -> u8 { = 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:16:5 + --> tests/ui/must_use_candidates.rs:16:5 | LL | pub fn inherent_pure(&self) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:47:1 + --> tests/ui/must_use_candidates.rs:47:1 | LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:59:1 + --> tests/ui/must_use_candidates.rs:59:1 | LL | pub fn rcd(_x: Rc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn rcd(_x: Rc) -> bool` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:67:1 + --> tests/ui/must_use_candidates.rs:67:1 | LL | pub fn arcd(_x: Arc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc) -> bool` diff --git a/src/tools/clippy/tests/ui/must_use_unit.stderr b/src/tools/clippy/tests/ui/must_use_unit.stderr index f2ee185857d3e..c2ee2edda7dc5 100644 --- a/src/tools/clippy/tests/ui/must_use_unit.stderr +++ b/src/tools/clippy/tests/ui/must_use_unit.stderr @@ -1,5 +1,5 @@ error: this unit-returning function has a `#[must_use]` attribute - --> $DIR/must_use_unit.rs:10:1 + --> tests/ui/must_use_unit.rs:10:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -10,7 +10,7 @@ LL | pub fn must_use_default() {} = 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 + --> tests/ui/must_use_unit.rs:13:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -18,7 +18,7 @@ LL | pub fn must_use_unit() -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this unit-returning function has a `#[must_use]` attribute - --> $DIR/must_use_unit.rs:16:1 + --> tests/ui/must_use_unit.rs:16:1 | LL | #[must_use = "With note"] | ------------------------- help: remove the attribute diff --git a/src/tools/clippy/tests/ui/mut_from_ref.stderr b/src/tools/clippy/tests/ui/mut_from_ref.stderr index 38f47b9ad7b52..34fe91b5b3acb 100644 --- a/src/tools/clippy/tests/ui/mut_from_ref.stderr +++ b/src/tools/clippy/tests/ui/mut_from_ref.stderr @@ -1,11 +1,11 @@ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:7:39 + --> tests/ui/mut_from_ref.rs:7:39 | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:7:29 + --> tests/ui/mut_from_ref.rs:7:29 | LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ @@ -13,61 +13,61 @@ LL | fn this_wont_hurt_a_bit(&self) -> &mut Foo { = 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 + --> tests/ui/mut_from_ref.rs:14:25 | LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:14:16 + --> tests/ui/mut_from_ref.rs:14:16 | LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:24:21 + --> tests/ui/mut_from_ref.rs:24:21 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:24:12 + --> tests/ui/mut_from_ref.rs:24:12 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:29:50 + --> tests/ui/mut_from_ref.rs:29:50 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:29:25 + --> tests/ui/mut_from_ref.rs:29:25 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:34:67 + --> tests/ui/mut_from_ref.rs:34:67 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:34:27 + --> tests/ui/mut_from_ref.rs:34:27 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:49:35 + --> tests/ui/mut_from_ref.rs:49:35 | LL | unsafe fn also_broken(x: &u32) -> &mut u32 { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:49:26 + --> tests/ui/mut_from_ref.rs:49:26 | LL | unsafe fn also_broken(x: &u32) -> &mut u32 { | ^^^^ diff --git a/src/tools/clippy/tests/ui/mut_key.stderr b/src/tools/clippy/tests/ui/mut_key.stderr index 48eeaff78a789..e54c3075d4f13 100644 --- a/src/tools/clippy/tests/ui/mut_key.stderr +++ b/src/tools/clippy/tests/ui/mut_key.stderr @@ -1,5 +1,5 @@ error: mutable key type - --> $DIR/mut_key.rs:31:32 + --> tests/ui/mut_key.rs:31:32 | LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> HashSet { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,97 +8,97 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash = help: to override `-D warnings` add `#[allow(clippy::mutable_key_type)]` error: mutable key type - --> $DIR/mut_key.rs:31:72 + --> tests/ui/mut_key.rs:31:72 | LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> HashSet { | ^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:35:5 + --> tests/ui/mut_key.rs:35:5 | LL | let _other: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:63:22 + --> tests/ui/mut_key.rs:63:22 | LL | fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:76:5 + --> tests/ui/mut_key.rs:76:5 | LL | let _map = HashMap::, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:78:5 + --> tests/ui/mut_key.rs:78:5 | LL | let _map = HashMap::<&mut Cell, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:80:5 + --> tests/ui/mut_key.rs:80:5 | LL | let _map = HashMap::<&mut usize, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:83:5 + --> tests/ui/mut_key.rs:83:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:85:5 + --> tests/ui/mut_key.rs:85:5 | LL | let _map = HashMap::, ()>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:87:5 + --> tests/ui/mut_key.rs:87:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:89:5 + --> tests/ui/mut_key.rs:89:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:91:5 + --> tests/ui/mut_key.rs:91:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:93:5 + --> tests/ui/mut_key.rs:93:5 | LL | let _map = HashMap::>>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:95:5 + --> tests/ui/mut_key.rs:95:5 | LL | let _map = HashMap::, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:98:5 + --> tests/ui/mut_key.rs:98:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:100:5 + --> tests/ui/mut_key.rs:100:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: mutable key type - --> $DIR/mut_key.rs:102:5 + --> tests/ui/mut_key.rs:102:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/mut_mut.stderr b/src/tools/clippy/tests/ui/mut_mut.stderr index 5ed9cd1aff99e..810c0c967437f 100644 --- a/src/tools/clippy/tests/ui/mut_mut.stderr +++ b/src/tools/clippy/tests/ui/mut_mut.stderr @@ -1,5 +1,5 @@ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:14:11 + --> tests/ui/mut_mut.rs:14:11 | LL | fn fun(x: &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | fn fun(x: &mut &mut u32) -> bool { = 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 + --> tests/ui/mut_mut.rs:31:17 | LL | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:46:25 + --> tests/ui/mut_mut.rs:46:25 | LL | let mut z = inline!(&mut $(&mut 3u32)); | ^ @@ -22,37 +22,37 @@ LL | let mut z = inline!(&mut $(&mut 3u32)); = note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: this expression mutably borrows a mutable reference. Consider reborrowing - --> $DIR/mut_mut.rs:33:21 + --> tests/ui/mut_mut.rs:33:21 | LL | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:37:32 + --> tests/ui/mut_mut.rs:37:32 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:37:16 + --> tests/ui/mut_mut.rs:37:16 | LL | let y: &mut &mut u32 = &mut &mut 2; | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:42:37 + --> tests/ui/mut_mut.rs:42:37 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:42:16 + --> tests/ui/mut_mut.rs:42:16 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:42:21 + --> tests/ui/mut_mut.rs:42:21 | LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2; | ^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/mut_mutex_lock.stderr b/src/tools/clippy/tests/ui/mut_mutex_lock.stderr index 819602882766d..a3d4905c04cb7 100644 --- a/src/tools/clippy/tests/ui/mut_mutex_lock.stderr +++ b/src/tools/clippy/tests/ui/mut_mutex_lock.stderr @@ -1,5 +1,5 @@ error: calling `&mut Mutex::lock` unnecessarily locks an exclusive (mutable) reference - --> $DIR/mut_mutex_lock.rs:10:33 + --> tests/ui/mut_mutex_lock.rs:10:33 | LL | let mut value = value_mutex.lock().unwrap(); | ^^^^ help: change this to: `get_mut` diff --git a/src/tools/clippy/tests/ui/mut_range_bound.stderr b/src/tools/clippy/tests/ui/mut_range_bound.stderr index 42f8a161f74f7..6f93b0ebe6fcc 100644 --- a/src/tools/clippy/tests/ui/mut_range_bound.stderr +++ b/src/tools/clippy/tests/ui/mut_range_bound.stderr @@ -1,5 +1,5 @@ error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:8:9 + --> tests/ui/mut_range_bound.rs:8:9 | LL | m = 5; | ^ @@ -9,7 +9,7 @@ LL | m = 5; = 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 + --> tests/ui/mut_range_bound.rs:17:9 | LL | m *= 2; | ^ @@ -17,7 +17,7 @@ LL | m *= 2; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:27:9 + --> tests/ui/mut_range_bound.rs:27:9 | LL | m = 5; | ^ @@ -25,7 +25,7 @@ LL | m = 5; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:30:9 + --> tests/ui/mut_range_bound.rs:30:9 | LL | n = 7; | ^ @@ -33,7 +33,7 @@ LL | n = 7; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:46:22 + --> tests/ui/mut_range_bound.rs:46:22 | LL | let n = &mut m; | ^ @@ -41,7 +41,7 @@ LL | let n = &mut m; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:81:9 + --> tests/ui/mut_range_bound.rs:81:9 | LL | m = 2; | ^ @@ -49,7 +49,7 @@ LL | m = 2; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> $DIR/mut_range_bound.rs:93:13 + --> tests/ui/mut_range_bound.rs:93:13 | LL | n = 1; | ^ diff --git a/src/tools/clippy/tests/ui/mut_reference.stderr b/src/tools/clippy/tests/ui/mut_reference.stderr index 87db08e2a7420..474221329c258 100644 --- a/src/tools/clippy/tests/ui/mut_reference.stderr +++ b/src/tools/clippy/tests/ui/mut_reference.stderr @@ -1,5 +1,5 @@ error: the function `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:30:34 + --> tests/ui/mut_reference.rs:30:34 | LL | takes_an_immutable_reference(&mut 42); | ^^^^^^^ @@ -8,13 +8,13 @@ LL | takes_an_immutable_reference(&mut 42); = 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:34:12 + --> tests/ui/mut_reference.rs:34:12 | LL | as_ptr(&mut 42); | ^^^^^^^ error: the method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:39:44 + --> tests/ui/mut_reference.rs:39:44 | LL | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/mutex_atomic.stderr b/src/tools/clippy/tests/ui/mutex_atomic.stderr index 91f73d30b5386..683a7b939db3a 100644 --- a/src/tools/clippy/tests/ui/mutex_atomic.stderr +++ b/src/tools/clippy/tests/ui/mutex_atomic.stderr @@ -1,5 +1,5 @@ error: consider using an `AtomicBool` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:8:5 + --> tests/ui/mutex_atomic.rs:8:5 | LL | Mutex::new(true); | ^^^^^^^^^^^^^^^^ @@ -8,31 +8,31 @@ LL | Mutex::new(true); = 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 + --> tests/ui/mutex_atomic.rs:11:5 | LL | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ 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:13:5 + --> tests/ui/mutex_atomic.rs:13:5 | LL | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:16:5 + --> tests/ui/mutex_atomic.rs:16:5 | LL | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:18:5 + --> tests/ui/mutex_atomic.rs:18:5 | LL | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicU32` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:20:5 + --> tests/ui/mutex_atomic.rs:20:5 | LL | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ @@ -41,31 +41,31 @@ LL | Mutex::new(0u32); = help: to override `-D warnings` add `#[allow(clippy::mutex_integer)]` error: consider using an `AtomicI32` 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 + --> tests/ui/mutex_atomic.rs:23:5 | LL | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ error: consider using an `AtomicU8` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:26:5 + --> tests/ui/mutex_atomic.rs:26:5 | LL | Mutex::new(0u8); | ^^^^^^^^^^^^^^^ error: consider using an `AtomicI16` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:28:5 + --> tests/ui/mutex_atomic.rs:28:5 | LL | Mutex::new(0i16); | ^^^^^^^^^^^^^^^^ error: consider using an `AtomicI8` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:30:25 + --> tests/ui/mutex_atomic.rs:30:25 | LL | let _x: Mutex = Mutex::new(0); | ^^^^^^^^^^^^^ error: consider using an `AtomicI64` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> $DIR/mutex_atomic.rs:33:5 + --> tests/ui/mutex_atomic.rs:33:5 | LL | Mutex::new(X); | ^^^^^^^^^^^^^ 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 fe2ac34f79f67..c653267f7525b 100644 --- a/src/tools/clippy/tests/ui/needless_arbitrary_self_type.stderr +++ b/src/tools/clippy/tests/ui/needless_arbitrary_self_type.stderr @@ -1,5 +1,5 @@ error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:10:16 + --> tests/ui/needless_arbitrary_self_type.rs:10:16 | LL | pub fn bad(self: Self) { | ^^^^^^^^^^ help: consider to change this parameter to: `self` @@ -8,31 +8,31 @@ LL | pub fn bad(self: Self) { = 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 + --> tests/ui/needless_arbitrary_self_type.rs:18:20 | LL | pub fn mut_bad(mut self: Self) { | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `mut self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:26:20 + --> tests/ui/needless_arbitrary_self_type.rs:26:20 | LL | pub fn ref_bad(self: &Self) { | ^^^^^^^^^^^ help: consider to change this parameter to: `&self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:34:38 + --> tests/ui/needless_arbitrary_self_type.rs:34:38 | LL | pub fn ref_bad_with_lifetime<'a>(self: &'a Self) { | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:42:24 + --> tests/ui/needless_arbitrary_self_type.rs:42:24 | LL | pub fn mut_ref_bad(self: &mut Self) { | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type.rs:50:42 + --> tests/ui/needless_arbitrary_self_type.rs:50:42 | LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) { | ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self` 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 e91359a3cc182..b50e005756290 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 @@ -1,5 +1,5 @@ error: the type of the `self` parameter does not need to be arbitrary - --> $DIR/needless_arbitrary_self_type_unfixable.rs:42:31 + --> tests/ui/needless_arbitrary_self_type_unfixable.rs:42:31 | LL | fn call_with_mut_self(self: &mut Self) {} | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` diff --git a/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr b/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr index b1fc1a7a95851..f29d4492540f9 100644 --- a/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr +++ b/src/tools/clippy/tests/ui/needless_bitwise_bool.stderr @@ -1,5 +1,5 @@ error: use of bitwise operator instead of lazy operator between booleans - --> $DIR/needless_bitwise_bool.rs:22:8 + --> tests/ui/needless_bitwise_bool.rs:22:8 | LL | if y & !x { | ^^^^^^ help: try: `y && !x` diff --git a/src/tools/clippy/tests/ui/needless_bool/fixable.stderr b/src/tools/clippy/tests/ui/needless_bool/fixable.stderr index 72b0670c95bae..9746e931f50f0 100644 --- a/src/tools/clippy/tests/ui/needless_bool/fixable.stderr +++ b/src/tools/clippy/tests/ui/needless_bool/fixable.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:41:5 + --> tests/ui/needless_bool/fixable.rs:41:5 | LL | / if x { LL | | true @@ -12,7 +12,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::needless_bool)]` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:46:5 + --> tests/ui/needless_bool/fixable.rs:46:5 | LL | / if x { LL | | false @@ -22,7 +22,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:51:5 + --> tests/ui/needless_bool/fixable.rs:51:5 | LL | / if x && y { LL | | false @@ -32,7 +32,7 @@ LL | | }; | |_____^ help: you can reduce it to: `!(x && y)` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:59:5 + --> tests/ui/needless_bool/fixable.rs:59:5 | LL | / if a == b { LL | | false @@ -42,7 +42,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a != b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:64:5 + --> tests/ui/needless_bool/fixable.rs:64:5 | LL | / if a != b { LL | | false @@ -52,7 +52,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a == b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:69:5 + --> tests/ui/needless_bool/fixable.rs:69:5 | LL | / if a < b { LL | | false @@ -62,7 +62,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a >= b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:74:5 + --> tests/ui/needless_bool/fixable.rs:74:5 | LL | / if a <= b { LL | | false @@ -72,7 +72,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a > b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:79:5 + --> tests/ui/needless_bool/fixable.rs:79:5 | LL | / if a > b { LL | | false @@ -82,7 +82,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a <= b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:84:5 + --> tests/ui/needless_bool/fixable.rs:84:5 | LL | / if a >= b { LL | | false @@ -92,7 +92,7 @@ LL | | }; | |_____^ help: you can reduce it to: `a < b` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:112:5 + --> tests/ui/needless_bool/fixable.rs:112:5 | LL | / if x { LL | | return true; @@ -102,7 +102,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:120:5 + --> tests/ui/needless_bool/fixable.rs:120:5 | LL | / if x { LL | | return false; @@ -112,7 +112,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:128:5 + --> tests/ui/needless_bool/fixable.rs:128:5 | LL | / if x && y { LL | | return true; @@ -122,7 +122,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:136:5 + --> tests/ui/needless_bool/fixable.rs:136:5 | LL | / if x && y { LL | | return false; @@ -132,7 +132,7 @@ LL | | }; | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/fixable.rs:144:8 + --> tests/ui/needless_bool/fixable.rs:144:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` @@ -141,25 +141,25 @@ LL | if x == true {}; = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against false can be replaced by a negation - --> $DIR/fixable.rs:148:8 + --> tests/ui/needless_bool/fixable.rs:148:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/fixable.rs:158:8 + --> tests/ui/needless_bool/fixable.rs:158:8 | LL | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/fixable.rs:159:8 + --> tests/ui/needless_bool/fixable.rs:159:8 | LL | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:168:12 + --> tests/ui/needless_bool/fixable.rs:168:12 | LL | } else if returns_bool() { | ____________^ @@ -170,7 +170,7 @@ LL | | }; | |_____^ help: you can reduce it to: `{ !returns_bool() }` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:181:5 + --> tests/ui/needless_bool/fixable.rs:181:5 | LL | / if unsafe { no(4) } & 1 != 0 { LL | | true @@ -180,13 +180,13 @@ LL | | }; | |_____^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:186:30 + --> tests/ui/needless_bool/fixable.rs:186:30 | LL | let _brackets_unneeded = if unsafe { no(4) } & 1 != 0 { true } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `unsafe { no(4) } & 1 != 0` error: this if-then-else expression returns a bool literal - --> $DIR/fixable.rs:189:9 + --> tests/ui/needless_bool/fixable.rs:189:9 | LL | if unsafe { no(4) } & 1 != 0 { true } else { false } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `(unsafe { no(4) } & 1 != 0)` diff --git a/src/tools/clippy/tests/ui/needless_bool/simple.stderr b/src/tools/clippy/tests/ui/needless_bool/simple.stderr index a44205c59b75b..bf30a56f43e7b 100644 --- a/src/tools/clippy/tests/ui/needless_bool/simple.stderr +++ b/src/tools/clippy/tests/ui/needless_bool/simple.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression will always return true - --> $DIR/simple.rs:14:5 + --> tests/ui/needless_bool/simple.rs:14:5 | LL | / if x { LL | | true @@ -12,7 +12,7 @@ LL | | }; = 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 + --> tests/ui/needless_bool/simple.rs:19:5 | LL | / if x { LL | | false @@ -22,7 +22,7 @@ LL | | }; | |_____^ error: this if-then-else expression will always return true - --> $DIR/simple.rs:34:5 + --> tests/ui/needless_bool/simple.rs:34:5 | LL | / if x { LL | | return true; @@ -32,7 +32,7 @@ LL | | }; | |_____^ error: this if-then-else expression will always return false - --> $DIR/simple.rs:42:5 + --> tests/ui/needless_bool/simple.rs:42:5 | LL | / if x { LL | | return false; diff --git a/src/tools/clippy/tests/ui/needless_bool_assign.stderr b/src/tools/clippy/tests/ui/needless_bool_assign.stderr index 244a88e6691fd..2d80dded39c31 100644 --- a/src/tools/clippy/tests/ui/needless_bool_assign.stderr +++ b/src/tools/clippy/tests/ui/needless_bool_assign.stderr @@ -1,5 +1,5 @@ error: this if-then-else expression assigns a bool literal - --> $DIR/needless_bool_assign.rs:13:5 + --> tests/ui/needless_bool_assign.rs:13:5 | LL | / if random() && random() { LL | | a.field = true; @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/needless_bool_assign.rs:18:5 | LL | / if random() && random() { LL | | a.field = false; @@ -22,7 +22,7 @@ LL | | } | |_____^ help: you can reduce it to: `a.field = !(random() && random());` error: this if-then-else expression assigns a bool literal - --> $DIR/needless_bool_assign.rs:32:5 + --> tests/ui/needless_bool_assign.rs:32:5 | LL | / if random() { LL | | a.field = true; @@ -32,7 +32,7 @@ LL | | } | |_____^ help: you can reduce it to: `random(); a.field = true;` error: this `if` has identical blocks - --> $DIR/needless_bool_assign.rs:32:17 + --> tests/ui/needless_bool_assign.rs:32:17 | LL | if random() { | _________________^ @@ -41,7 +41,7 @@ LL | | } else { | |_____^ | note: same as this - --> $DIR/needless_bool_assign.rs:34:12 + --> tests/ui/needless_bool_assign.rs:34:12 | LL | } else { | ____________^ diff --git a/src/tools/clippy/tests/ui/needless_borrow.fixed b/src/tools/clippy/tests/ui/needless_borrow.fixed index 23e8bf8a468fd..998f5430fdf05 100644 --- a/src/tools/clippy/tests/ui/needless_borrow.fixed +++ b/src/tools/clippy/tests/ui/needless_borrow.fixed @@ -1,6 +1,7 @@ #![feature(lint_reasons)] #![allow( unused, + non_local_definitions, clippy::uninlined_format_args, clippy::unnecessary_mut_passed, clippy::unnecessary_to_owned, diff --git a/src/tools/clippy/tests/ui/needless_borrow.rs b/src/tools/clippy/tests/ui/needless_borrow.rs index 27771a8f15b30..acb2c74d849a2 100644 --- a/src/tools/clippy/tests/ui/needless_borrow.rs +++ b/src/tools/clippy/tests/ui/needless_borrow.rs @@ -1,6 +1,7 @@ #![feature(lint_reasons)] #![allow( unused, + non_local_definitions, clippy::uninlined_format_args, clippy::unnecessary_mut_passed, clippy::unnecessary_to_owned, diff --git a/src/tools/clippy/tests/ui/needless_borrow.stderr b/src/tools/clippy/tests/ui/needless_borrow.stderr index a21ed8382c14e..5f02833876422 100644 --- a/src/tools/clippy/tests/ui/needless_borrow.stderr +++ b/src/tools/clippy/tests/ui/needless_borrow.stderr @@ -1,5 +1,5 @@ error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:15:15 + --> tests/ui/needless_borrow.rs:16:15 | LL | let _ = x(&&a); // warn | ^^^ help: change this to: `&a` @@ -8,157 +8,157 @@ LL | let _ = x(&&a); // warn = 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 + --> tests/ui/needless_borrow.rs:20:13 | LL | mut_ref(&mut &mut b); // warn | ^^^^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:31:13 + --> tests/ui/needless_borrow.rs:32:13 | LL | &&a | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:33:15 + --> tests/ui/needless_borrow.rs:34:15 | LL | 46 => &&a, | ^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:39:27 + --> tests/ui/needless_borrow.rs:40:27 | LL | break &ref_a; | ^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:46:15 + --> tests/ui/needless_borrow.rs:47:15 | LL | let _ = x(&&&a); | ^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:47:15 + --> tests/ui/needless_borrow.rs:48:15 | LL | let _ = x(&mut &&a); | ^^^^^^^^ help: change this to: `&a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:48:15 + --> tests/ui/needless_borrow.rs:49:15 | LL | let _ = x(&&&mut b); | ^^^^^^^^ help: change this to: `&mut b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:49:15 + --> tests/ui/needless_borrow.rs:50:15 | LL | let _ = x(&&ref_a); | ^^^^^^^ help: change this to: `ref_a` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:52:11 + --> tests/ui/needless_borrow.rs:53:11 | LL | x(&b); | ^^ help: change this to: `b` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:59:13 + --> tests/ui/needless_borrow.rs:60:13 | LL | mut_ref(&mut x); | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:60:13 + --> tests/ui/needless_borrow.rs:61:13 | LL | mut_ref(&mut &mut x); | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:61:23 + --> tests/ui/needless_borrow.rs:62:23 | LL | let y: &mut i32 = &mut x; | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:62:23 + --> tests/ui/needless_borrow.rs:63:23 | LL | let y: &mut i32 = &mut &mut x; | ^^^^^^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:71:14 + --> tests/ui/needless_borrow.rs:72:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:77:14 + --> tests/ui/needless_borrow.rs:78:14 | LL | 0 => &mut x, | ^^^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:89:13 + --> tests/ui/needless_borrow.rs:90:13 | LL | let _ = (&x).0; | ^^^^ help: change this to: `x` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:91:22 + --> tests/ui/needless_borrow.rs:92:22 | LL | let _ = unsafe { (&*x).0 }; | ^^^^^ help: change this to: `(*x)` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:101:5 + --> tests/ui/needless_borrow.rs:102:5 | LL | (&&()).foo(); | ^^^^^^ help: change this to: `(&())` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:110:5 + --> tests/ui/needless_borrow.rs:111:5 | LL | (&&5).foo(); | ^^^^^ help: change this to: `(&5)` error: this expression creates a reference which is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:136:23 + --> tests/ui/needless_borrow.rs:137:23 | LL | let x: (&str,) = (&"",); | ^^^ help: change this to: `""` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:178:13 + --> tests/ui/needless_borrow.rs:179:13 | LL | (&self.f)() | ^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:187:13 + --> tests/ui/needless_borrow.rs:188:13 | LL | (&mut self.f)() | ^^^^^^^^^^^^^ help: change this to: `(self.f)` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:224:22 + --> tests/ui/needless_borrow.rs:225:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:231:22 + --> tests/ui/needless_borrow.rs:232:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:235:22 + --> tests/ui/needless_borrow.rs:236:22 | LL | let _ = &mut (&mut x.u).x; | ^^^^^^^^^^ help: change this to: `x.u` error: this expression borrows a value the compiler would automatically borrow - --> $DIR/needless_borrow.rs:236:22 + --> tests/ui/needless_borrow.rs:237:22 | LL | let _ = &mut (&mut { x.u }).x; | ^^^^^^^^^^^^^^ help: change this to: `{ x.u }` diff --git a/src/tools/clippy/tests/ui/needless_borrow_pat.stderr b/src/tools/clippy/tests/ui/needless_borrow_pat.stderr index ce3a36e35b857..2ad6944903967 100644 --- a/src/tools/clippy/tests/ui/needless_borrow_pat.stderr +++ b/src/tools/clippy/tests/ui/needless_borrow_pat.stderr @@ -1,5 +1,5 @@ error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:59:14 + --> tests/ui/needless_borrow_pat.rs:59:14 | LL | Some(ref x) => x, | ^^^^^ help: try: `x` @@ -8,7 +8,7 @@ LL | Some(ref x) => x, = 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 + --> tests/ui/needless_borrow_pat.rs:67:14 | LL | Some(ref x) => *x, | ^^^^^ @@ -19,7 +19,7 @@ LL | Some(x) => x, | ~ ~ error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:74:14 + --> tests/ui/needless_borrow_pat.rs:74:14 | LL | Some(ref x) => { | ^^^^^ @@ -33,19 +33,19 @@ LL ~ f1(x); | error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:85:14 + --> tests/ui/needless_borrow_pat.rs:85:14 | LL | Some(ref x) => m1!(x), | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:91:15 + --> tests/ui/needless_borrow_pat.rs:91:15 | LL | let _ = |&ref x: &&String| { | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:97:10 + --> tests/ui/needless_borrow_pat.rs:97:10 | LL | let (ref y,) = (&x,); | ^^^^^ @@ -58,13 +58,13 @@ LL ~ let _: &String = y; | error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:108:14 + --> tests/ui/needless_borrow_pat.rs:108:14 | LL | Some(ref x) => x.0, | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:119:14 + --> tests/ui/needless_borrow_pat.rs:119:14 | LL | E::A(ref x) | E::B(ref x) => *x, | ^^^^^ ^^^^^ @@ -75,13 +75,13 @@ LL | E::A(x) | E::B(x) => x, | ~ ~ ~ error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:126:21 + --> tests/ui/needless_borrow_pat.rs:126:21 | LL | if let Some(ref x) = Some(&String::new()); | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:135:12 + --> tests/ui/needless_borrow_pat.rs:135:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { | ^^^^^ @@ -95,13 +95,13 @@ LL ~ x | error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:143:11 + --> tests/ui/needless_borrow_pat.rs:143:11 | LL | fn f(&ref x: &&String) { | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow_pat.rs:152:11 + --> tests/ui/needless_borrow_pat.rs:152:11 | LL | fn f(&ref x: &&String) { | ^^^^^ diff --git a/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr b/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr index 15261cfce0c35..b8181e2805c9c 100644 --- a/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr +++ b/src/tools/clippy/tests/ui/needless_borrowed_ref.stderr @@ -1,5 +1,5 @@ error: this pattern takes a reference on something that is being dereferenced - --> $DIR/needless_borrowed_ref.rs:30:34 + --> tests/ui/needless_borrowed_ref.rs:30:34 | LL | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ @@ -13,7 +13,7 @@ LL + let _ = v.iter_mut().filter(|a| a.is_empty()); | error: this pattern takes a reference on something that is being dereferenced - --> $DIR/needless_borrowed_ref.rs:34:17 + --> tests/ui/needless_borrowed_ref.rs:34:17 | LL | if let Some(&ref v) = thingy {} | ^^^^^^ @@ -25,7 +25,7 @@ LL + if let Some(v) = thingy {} | error: this pattern takes a reference on something that is being dereferenced - --> $DIR/needless_borrowed_ref.rs:36:14 + --> tests/ui/needless_borrowed_ref.rs:36:14 | LL | if let &[&ref a, ref b] = slice_of_refs {} | ^^^^^^ @@ -37,7 +37,7 @@ LL + if let &[a, ref b] = slice_of_refs {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:38:9 + --> tests/ui/needless_borrowed_ref.rs:38:9 | LL | let &[ref a, ..] = &array; | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + let [a, ..] = &array; | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:39:9 + --> tests/ui/needless_borrowed_ref.rs:39:9 | LL | let &[ref a, ref b, ..] = &array; | ^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + let [a, b, ..] = &array; | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:41:12 + --> tests/ui/needless_borrowed_ref.rs:41:12 | LL | if let &[ref a, ref b] = slice {} | ^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + if let [a, b] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:42:12 + --> tests/ui/needless_borrowed_ref.rs:42:12 | LL | if let &[ref a, ref b] = &vec[..] {} | ^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + if let [a, b] = &vec[..] {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:44:12 + --> tests/ui/needless_borrowed_ref.rs:44:12 | LL | if let &[ref a, ref b, ..] = slice {} | ^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + if let [a, b, ..] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:45:12 + --> tests/ui/needless_borrowed_ref.rs:45:12 | LL | if let &[ref a, .., ref b] = slice {} | ^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + if let [a, .., b] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:46:12 + --> tests/ui/needless_borrowed_ref.rs:46:12 | LL | if let &[.., ref a, ref b] = slice {} | ^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + if let [.., a, b] = slice {} | error: dereferencing a slice pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:48:12 + --> tests/ui/needless_borrowed_ref.rs:48:12 | LL | if let &[ref a, _] = slice {} | ^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + if let [a, _] = slice {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:50:12 + --> tests/ui/needless_borrowed_ref.rs:50:12 | LL | if let &(ref a, ref b, ref c) = &tuple {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + if let (a, b, c) = &tuple {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:51:12 + --> tests/ui/needless_borrowed_ref.rs:51:12 | LL | if let &(ref a, _, ref c) = &tuple {} | ^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + if let (a, _, c) = &tuple {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:52:12 + --> tests/ui/needless_borrowed_ref.rs:52:12 | LL | if let &(ref a, ..) = &tuple {} | ^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL + if let (a, ..) = &tuple {} | error: dereferencing a tuple pattern where every element takes a reference - --> $DIR/needless_borrowed_ref.rs:54:12 + --> tests/ui/needless_borrowed_ref.rs:54:12 | LL | if let &TupleStruct(ref a, ..) = &tuple_struct {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + if let TupleStruct(a, ..) = &tuple_struct {} | error: dereferencing a struct pattern where every field's pattern takes a reference - --> $DIR/needless_borrowed_ref.rs:56:12 + --> tests/ui/needless_borrowed_ref.rs:56:12 | LL | if let &Struct { | ____________^ @@ -200,7 +200,7 @@ LL ~ c: renamed, | error: dereferencing a struct pattern where every field's pattern takes a reference - --> $DIR/needless_borrowed_ref.rs:63:12 + --> tests/ui/needless_borrowed_ref.rs:63:12 | LL | if let &Struct { ref a, b: _, .. } = &s {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/needless_borrows_for_generic_args.stderr b/src/tools/clippy/tests/ui/needless_borrows_for_generic_args.stderr index e2cde2c59a6e0..83c076f8d863a 100644 --- a/src/tools/clippy/tests/ui/needless_borrows_for_generic_args.stderr +++ b/src/tools/clippy/tests/ui/needless_borrows_for_generic_args.stderr @@ -1,5 +1,5 @@ error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:16:37 + --> tests/ui/needless_borrows_for_generic_args.rs:16:37 | LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` @@ -8,67 +8,67 @@ LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::needless_borrows_for_generic_args)]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:17:33 + --> tests/ui/needless_borrows_for_generic_args.rs:17:33 | LL | let _ = Path::new(".").join(&&"."); | ^^^^^ help: change this to: `"."` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:21:33 + --> tests/ui/needless_borrows_for_generic_args.rs:21:33 | LL | let _ = std::fs::write("x", &"".to_string()); | ^^^^^^^^^^^^^^^ help: change this to: `"".to_string()` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:36:27 + --> tests/ui/needless_borrows_for_generic_args.rs:36:27 | LL | deref_target_is_x(&X); | ^^ help: change this to: `X` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:49:30 + --> tests/ui/needless_borrows_for_generic_args.rs:49:30 | LL | multiple_constraints(&[[""]]); | ^^^^^^^ help: change this to: `[[""]]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:69:49 + --> tests/ui/needless_borrows_for_generic_args.rs:69:49 | LL | multiple_constraints_normalizes_to_same(&X, X); | ^^ help: change this to: `X` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:127:24 + --> tests/ui/needless_borrows_for_generic_args.rs:127:24 | LL | takes_iter(&mut x) | ^^^^^^ help: change this to: `x` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:136:41 + --> tests/ui/needless_borrows_for_generic_args.rs:136:41 | LL | let _ = Command::new("ls").args(&["-a", "-l"]).status().unwrap(); | ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:144:41 + --> tests/ui/needless_borrows_for_generic_args.rs:144:41 | LL | let _ = std::fs::write("x", &arg); | ^^^^ help: change this to: `arg` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:145:41 + --> tests/ui/needless_borrows_for_generic_args.rs:145:41 | LL | let _ = std::fs::write("x", &loc); | ^^^^ help: change this to: `loc` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:167:11 + --> tests/ui/needless_borrows_for_generic_args.rs:167:11 | LL | f(&x); | ^^ help: change this to: `x` error: the borrowed expression implements the required traits - --> $DIR/needless_borrows_for_generic_args.rs:247:13 + --> tests/ui/needless_borrows_for_generic_args.rs:247:13 | LL | foo(&a); | ^^ help: change this to: `a` diff --git a/src/tools/clippy/tests/ui/needless_collect.stderr b/src/tools/clippy/tests/ui/needless_collect.stderr index 2c21fc5965d56..ea317896d3684 100644 --- a/src/tools/clippy/tests/ui/needless_collect.stderr +++ b/src/tools/clippy/tests/ui/needless_collect.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:9:29 + --> tests/ui/needless_collect.rs:9:29 | LL | let len = sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` @@ -8,109 +8,109 @@ LL | let len = sample.iter().collect::>().len(); = help: to override `-D warnings` add `#[allow(clippy::needless_collect)]` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:10:22 + --> tests/ui/needless_collect.rs:10:22 | LL | if sample.iter().collect::>().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:13:28 + --> tests/ui/needless_collect.rs:13:28 | LL | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == 1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:18:35 + --> tests/ui/needless_collect.rs:18:35 | LL | sample.iter().map(|x| (x, x)).collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:19:35 + --> tests/ui/needless_collect.rs:19:35 | LL | sample.iter().map(|x| (x, x)).collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:26:19 + --> tests/ui/needless_collect.rs:26:19 | LL | sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:27:19 + --> tests/ui/needless_collect.rs:27:19 | LL | sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:28:28 + --> tests/ui/needless_collect.rs:28:28 | LL | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == 1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:29:19 + --> tests/ui/needless_collect.rs:29:19 | LL | sample.iter().collect::>().contains(&&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:32:19 + --> tests/ui/needless_collect.rs:32:19 | LL | sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `count()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:33:19 + --> tests/ui/needless_collect.rs:33:19 | LL | sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:38:27 + --> tests/ui/needless_collect.rs:38:27 | LL | let _ = sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:39:27 + --> tests/ui/needless_collect.rs:39:27 | LL | let _ = sample.iter().collect::>().contains(&&0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &0)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:61:27 + --> tests/ui/needless_collect.rs:61:27 | LL | let _ = sample.iter().collect::>().is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:62:27 + --> tests/ui/needless_collect.rs:62:27 | LL | let _ = sample.iter().collect::>().contains(&&0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `any(|x| x == &0)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:66:40 + --> tests/ui/needless_collect.rs:66:40 | LL | Vec::::new().extend((0..10).collect::>()); | ^^^^^^^^^^^^^^^^^^^^ help: remove this call error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:67:20 + --> tests/ui/needless_collect.rs:67:20 | LL | foo((0..10).collect::>()); | ^^^^^^^^^^^^^^^^^^^^ help: remove this call error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:68:49 + --> tests/ui/needless_collect.rs:68:49 | LL | bar((0..10).collect::>(), (0..10).collect::>()); | ^^^^^^^^^^^^^^^^^^^^ help: remove this call error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:69:37 + --> tests/ui/needless_collect.rs:69:37 | LL | baz((0..10), (), ('a'..='z').collect::>()) | ^^^^^^^^^^^^^^^^^^^^ help: remove this call diff --git a/src/tools/clippy/tests/ui/needless_collect_indirect.stderr b/src/tools/clippy/tests/ui/needless_collect_indirect.stderr index 3d1ad2a1cfa55..0cce718a1ac7a 100644 --- a/src/tools/clippy/tests/ui/needless_collect_indirect.stderr +++ b/src/tools/clippy/tests/ui/needless_collect_indirect.stderr @@ -1,5 +1,5 @@ error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:9:39 + --> tests/ui/needless_collect_indirect.rs:9:39 | LL | let indirect_iter = sample.iter().collect::>(); | ^^^^^^^ @@ -18,7 +18,7 @@ LL ~ sample.iter().map(|x| (x, x + 1)).collect::>(); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:13:38 + --> tests/ui/needless_collect_indirect.rs:13:38 | LL | let indirect_len = sample.iter().collect::>(); | ^^^^^^^ @@ -34,7 +34,7 @@ LL ~ sample.iter().count(); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:16:40 + --> tests/ui/needless_collect_indirect.rs:16:40 | LL | let indirect_empty = sample.iter().collect::>(); | ^^^^^^^ @@ -50,7 +50,7 @@ LL ~ sample.iter().next().is_none(); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:19:43 + --> tests/ui/needless_collect_indirect.rs:19:43 | LL | let indirect_contains = sample.iter().collect::>(); | ^^^^^^^ @@ -66,7 +66,7 @@ LL ~ sample.iter().any(|x| x == &5); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:32:48 + --> tests/ui/needless_collect_indirect.rs:32:48 | LL | let non_copy_contains = sample.into_iter().collect::>(); | ^^^^^^^ @@ -82,7 +82,7 @@ LL ~ sample.into_iter().any(|x| x == a); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:62:51 + --> tests/ui/needless_collect_indirect.rs:62:51 | LL | let buffer: Vec<&str> = string.split('/').collect(); | ^^^^^^^ @@ -98,7 +98,7 @@ LL ~ string.split('/').count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:68:55 + --> tests/ui/needless_collect_indirect.rs:68:55 | LL | let indirect_len: VecDeque<_> = sample.iter().collect(); | ^^^^^^^ @@ -114,7 +114,7 @@ LL ~ sample.iter().count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:74:57 + --> tests/ui/needless_collect_indirect.rs:74:57 | LL | let indirect_len: LinkedList<_> = sample.iter().collect(); | ^^^^^^^ @@ -130,7 +130,7 @@ LL ~ sample.iter().count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:80:57 + --> tests/ui/needless_collect_indirect.rs:80:57 | LL | let indirect_len: BinaryHeap<_> = sample.iter().collect(); | ^^^^^^^ @@ -146,7 +146,7 @@ LL ~ sample.iter().count() | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:141:59 + --> tests/ui/needless_collect_indirect.rs:141:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -164,7 +164,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == i); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:167:59 + --> tests/ui/needless_collect_indirect.rs:167:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -182,7 +182,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:197:63 + --> tests/ui/needless_collect_indirect.rs:197:63 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -200,7 +200,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:234:59 + --> tests/ui/needless_collect_indirect.rs:234:59 | LL | let y: Vec = vec.iter().map(|k| k * k).collect(); | ^^^^^^^ @@ -218,7 +218,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n); | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:260:26 + --> tests/ui/needless_collect_indirect.rs:260:26 | LL | let w = v.iter().collect::>(); | ^^^^^^^ @@ -235,7 +235,7 @@ LL ~ for _ in 0..v.iter().count() { | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:283:30 + --> tests/ui/needless_collect_indirect.rs:283:30 | LL | let mut w = v.iter().collect::>(); | ^^^^^^^ @@ -252,7 +252,7 @@ LL ~ while 1 == v.iter().count() { | error: avoid using `collect()` when not needed - --> $DIR/needless_collect_indirect.rs:306:30 + --> tests/ui/needless_collect_indirect.rs:306:30 | LL | let mut w = v.iter().collect::>(); | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/needless_continue.stderr b/src/tools/clippy/tests/ui/needless_continue.stderr index 31b5dc2808da1..ec7c9ba39a72a 100644 --- a/src/tools/clippy/tests/ui/needless_continue.stderr +++ b/src/tools/clippy/tests/ui/needless_continue.stderr @@ -1,5 +1,5 @@ error: this `else` block is redundant - --> $DIR/needless_continue.rs:30:16 + --> tests/ui/needless_continue.rs:30:16 | LL | } else { | ________________^ @@ -38,7 +38,7 @@ LL | | } = 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 + --> tests/ui/needless_continue.rs:46:9 | LL | / if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { LL | | @@ -60,7 +60,7 @@ LL | | } } error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:60:9 + --> tests/ui/needless_continue.rs:60:9 | LL | continue; | ^^^^^^^^^ @@ -68,7 +68,7 @@ LL | continue; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:68:9 + --> tests/ui/needless_continue.rs:68:9 | LL | continue; | ^^^^^^^^^ @@ -76,7 +76,7 @@ LL | continue; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:76:9 + --> tests/ui/needless_continue.rs:76:9 | LL | continue | ^^^^^^^^ @@ -84,7 +84,7 @@ LL | continue = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> $DIR/needless_continue.rs:85:9 + --> tests/ui/needless_continue.rs:85:9 | LL | continue | ^^^^^^^^ @@ -92,7 +92,7 @@ LL | continue = help: consider dropping the `continue` expression error: this `else` block is redundant - --> $DIR/needless_continue.rs:136:24 + --> tests/ui/needless_continue.rs:136:24 | LL | } else { | ________________________^ @@ -117,7 +117,7 @@ LL | | } } error: there is no need for an explicit `else` block for this `if` expression - --> $DIR/needless_continue.rs:143:17 + --> tests/ui/needless_continue.rs:143:17 | LL | / if condition() { LL | | diff --git a/src/tools/clippy/tests/ui/needless_doc_main.stderr b/src/tools/clippy/tests/ui/needless_doc_main.stderr index 84256548671d1..7e362cf377ce4 100644 --- a/src/tools/clippy/tests/ui/needless_doc_main.stderr +++ b/src/tools/clippy/tests/ui/needless_doc_main.stderr @@ -1,5 +1,5 @@ error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:7:5 + --> tests/ui/needless_doc_main.rs:7:5 | LL | /// fn main() { | _____^ @@ -13,7 +13,7 @@ LL | | /// } = help: to override `-D warnings` add `#[allow(clippy::needless_doctest_main)]` error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:16:5 + --> tests/ui/needless_doc_main.rs:16:5 | LL | /// fn main() -> () { | _____^ @@ -23,7 +23,7 @@ LL | | /// } | |_____^ error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:24:5 + --> tests/ui/needless_doc_main.rs:24:5 | LL | /// fn main() { | _____^ @@ -33,7 +33,7 @@ LL | | /// } | |_____^ error: needless `fn main` in doctest - --> $DIR/needless_doc_main.rs:32:5 + --> tests/ui/needless_doc_main.rs:32:5 | LL | /// // the fn is not always the first line | _____^ diff --git a/src/tools/clippy/tests/ui/needless_else.stderr b/src/tools/clippy/tests/ui/needless_else.stderr index 66552109c48e1..77ead31b31cc9 100644 --- a/src/tools/clippy/tests/ui/needless_else.stderr +++ b/src/tools/clippy/tests/ui/needless_else.stderr @@ -1,5 +1,5 @@ error: this `else` branch is empty - --> $DIR/needless_else.rs:23:7 + --> tests/ui/needless_else.rs:23:7 | LL | } else { | _______^ 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 3b5163b0171a9..21342d0525618 100644 --- a/src/tools/clippy/tests/ui/needless_for_each_fixable.stderr +++ b/src/tools/clippy/tests/ui/needless_for_each_fixable.stderr @@ -1,5 +1,5 @@ error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:15:5 + --> tests/ui/needless_for_each_fixable.rs:15:5 | LL | / v.iter().for_each(|elem| { LL | | acc += elem; @@ -16,7 +16,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:18:5 + --> tests/ui/needless_for_each_fixable.rs:18:5 | LL | / v.into_iter().for_each(|elem| { LL | | acc += elem; @@ -31,7 +31,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:22:5 + --> tests/ui/needless_for_each_fixable.rs:22:5 | LL | / [1, 2, 3].iter().for_each(|elem| { LL | | acc += elem; @@ -46,7 +46,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:27:5 + --> tests/ui/needless_for_each_fixable.rs:27:5 | LL | / hash_map.iter().for_each(|(k, v)| { LL | | acc += k + v; @@ -61,7 +61,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:30:5 + --> tests/ui/needless_for_each_fixable.rs:30:5 | LL | / hash_map.iter_mut().for_each(|(k, v)| { LL | | acc += *k + *v; @@ -76,7 +76,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:33:5 + --> tests/ui/needless_for_each_fixable.rs:33:5 | LL | / hash_map.keys().for_each(|k| { LL | | acc += k; @@ -91,7 +91,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:36:5 + --> tests/ui/needless_for_each_fixable.rs:36:5 | LL | / hash_map.values().for_each(|v| { LL | | acc += v; @@ -106,7 +106,7 @@ LL + } | error: needless use of `for_each` - --> $DIR/needless_for_each_fixable.rs:43:5 + --> tests/ui/needless_for_each_fixable.rs:43:5 | LL | / my_vec().iter().for_each(|elem| { LL | | acc += elem; 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 24a22e232485b..9d3f639efbf27 100644 --- a/src/tools/clippy/tests/ui/needless_for_each_unfixable.stderr +++ b/src/tools/clippy/tests/ui/needless_for_each_unfixable.stderr @@ -1,5 +1,5 @@ error: needless use of `for_each` - --> $DIR/needless_for_each_unfixable.rs:8:5 + --> tests/ui/needless_for_each_unfixable.rs:8:5 | LL | / v.iter().for_each(|v| { LL | | diff --git a/src/tools/clippy/tests/ui/needless_if.stderr b/src/tools/clippy/tests/ui/needless_if.stderr index 9a911b4dbaccc..9beae596ee39d 100644 --- a/src/tools/clippy/tests/ui/needless_if.stderr +++ b/src/tools/clippy/tests/ui/needless_if.stderr @@ -1,5 +1,5 @@ error: this `if` branch is empty - --> $DIR/needless_if.rs:27:5 + --> tests/ui/needless_if.rs:27:5 | LL | if (true) {} | ^^^^^^^^^^^^ help: you can remove it @@ -8,13 +8,13 @@ LL | if (true) {} = help: to override `-D warnings` add `#[allow(clippy::needless_if)]` error: this `if` branch is empty - --> $DIR/needless_if.rs:29:5 + --> tests/ui/needless_if.rs:29:5 | LL | if maybe_side_effect() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `maybe_side_effect();` error: this `if` branch is empty - --> $DIR/needless_if.rs:34:5 + --> tests/ui/needless_if.rs:34:5 | LL | / if { LL | | return; @@ -29,7 +29,7 @@ LL + }); | error: this `if` branch is empty - --> $DIR/needless_if.rs:50:5 + --> tests/ui/needless_if.rs:50:5 | LL | / if { LL | | if let true = true @@ -54,19 +54,19 @@ LL + } && true); | error: this `if` branch is empty - --> $DIR/needless_if.rs:94:5 + --> tests/ui/needless_if.rs:94:5 | LL | if { maybe_side_effect() } {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() });` error: this `if` branch is empty - --> $DIR/needless_if.rs:96:5 + --> tests/ui/needless_if.rs:96:5 | LL | if { maybe_side_effect() } && true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() } && true);` error: this `if` branch is empty - --> $DIR/needless_if.rs:100:5 + --> tests/ui/needless_if.rs:100:5 | LL | if true {} | ^^^^^^^^^^ help: you can remove it: `true;` diff --git a/src/tools/clippy/tests/ui/needless_late_init.stderr b/src/tools/clippy/tests/ui/needless_late_init.stderr index 602b1a683e51d..1695784030d02 100644 --- a/src/tools/clippy/tests/ui/needless_late_init.stderr +++ b/src/tools/clippy/tests/ui/needless_late_init.stderr @@ -1,5 +1,5 @@ error: unneeded late initialization - --> $DIR/needless_late_init.rs:27:5 + --> tests/ui/needless_late_init.rs:27:5 | LL | let a; | ^^^^^^ created here @@ -14,7 +14,7 @@ LL | let a = "zero"; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:30:5 + --> tests/ui/needless_late_init.rs:30:5 | LL | let b; | ^^^^^^ created here @@ -28,7 +28,7 @@ LL | let b = 1; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:31:5 + --> tests/ui/needless_late_init.rs:31:5 | LL | let c; | ^^^^^^ created here @@ -42,7 +42,7 @@ LL | let c = 2; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:35:5 + --> tests/ui/needless_late_init.rs:35:5 | LL | let d: usize; | ^^^^^^^^^^^^^ created here @@ -55,7 +55,7 @@ LL | let d: usize = 1; | ~~~~~~~~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:38:5 + --> tests/ui/needless_late_init.rs:38:5 | LL | let e; | ^^^^^^ created here @@ -68,7 +68,7 @@ LL | let e = format!("{}", d); | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:43:5 + --> tests/ui/needless_late_init.rs:43:5 | LL | let a; | ^^^^^^ @@ -89,7 +89,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:52:5 + --> tests/ui/needless_late_init.rs:52:5 | LL | let b; | ^^^^^^ @@ -110,7 +110,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:59:5 + --> tests/ui/needless_late_init.rs:59:5 | LL | let d; | ^^^^^^ @@ -131,7 +131,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:67:5 + --> tests/ui/needless_late_init.rs:67:5 | LL | let e; | ^^^^^^ @@ -152,7 +152,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:74:5 + --> tests/ui/needless_late_init.rs:74:5 | LL | let f; | ^^^^^^ @@ -168,7 +168,7 @@ LL + 1 => "three", | error: unneeded late initialization - --> $DIR/needless_late_init.rs:80:5 + --> tests/ui/needless_late_init.rs:80:5 | LL | let g: usize; | ^^^^^^^^^^^^^ @@ -188,7 +188,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:88:5 + --> tests/ui/needless_late_init.rs:88:5 | LL | let x; | ^^^^^^ created here @@ -202,7 +202,7 @@ LL | let x = 1; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:92:5 + --> tests/ui/needless_late_init.rs:92:5 | LL | let x; | ^^^^^^ created here @@ -216,7 +216,7 @@ LL | let x = SignificantDrop; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:96:5 + --> tests/ui/needless_late_init.rs:96:5 | LL | let x; | ^^^^^^ created here @@ -230,7 +230,7 @@ LL | let x = SignificantDrop; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:115:5 + --> tests/ui/needless_late_init.rs:115:5 | LL | let a; | ^^^^^^ @@ -251,7 +251,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:132:5 + --> tests/ui/needless_late_init.rs:132:5 | LL | let a; | ^^^^^^ diff --git a/src/tools/clippy/tests/ui/needless_lifetimes.stderr b/src/tools/clippy/tests/ui/needless_lifetimes.stderr index 7051a2604b917..f325d27b8c753 100644 --- a/src/tools/clippy/tests/ui/needless_lifetimes.stderr +++ b/src/tools/clippy/tests/ui/needless_lifetimes.stderr @@ -1,5 +1,5 @@ error: the following explicit lifetimes could be elided: 'a, 'b - --> $DIR/needless_lifetimes.rs:17:23 + --> tests/ui/needless_lifetimes.rs:17:23 | LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} | ^^ ^^ ^^ ^^ @@ -13,7 +13,7 @@ LL + fn distinct_lifetimes(_x: &u8, _y: &u8, _z: u8) {} | error: the following explicit lifetimes could be elided: 'a, 'b - --> $DIR/needless_lifetimes.rs:19:24 + --> tests/ui/needless_lifetimes.rs:19:24 | LL | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} | ^^ ^^ ^^ ^^ @@ -25,7 +25,7 @@ LL + fn distinct_and_static(_x: &u8, _y: &u8, _z: &'static u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:29:15 + --> tests/ui/needless_lifetimes.rs:29:15 | LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { | ^^ ^^ ^^ @@ -37,7 +37,7 @@ LL + fn in_and_out(x: &u8, _y: u8) -> &u8 { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:41:31 + --> tests/ui/needless_lifetimes.rs:41:31 | LL | fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { | ^^ ^^ @@ -49,7 +49,7 @@ LL + fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:48:27 + --> tests/ui/needless_lifetimes.rs:48:27 | LL | fn multiple_in_and_out_2b<'a, 'b>(_x: &'a u8, y: &'b u8) -> &'b u8 { | ^^ ^^ @@ -61,7 +61,7 @@ LL + fn multiple_in_and_out_2b<'b>(_x: &u8, y: &'b u8) -> &'b u8 { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:65:26 + --> tests/ui/needless_lifetimes.rs:65:26 | LL | fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { | ^^ ^^ @@ -73,7 +73,7 @@ LL + fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:72:22 + --> tests/ui/needless_lifetimes.rs:72:22 | LL | fn deep_reference_1b<'a, 'b>(_x: &'a u8, y: &'b u8) -> Result<&'b u8, ()> { | ^^ ^^ @@ -85,7 +85,7 @@ LL + fn deep_reference_1b<'b>(_x: &u8, y: &'b u8) -> Result<&'b u8, ()> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:81:21 + --> tests/ui/needless_lifetimes.rs:81:21 | LL | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { | ^^ ^^ ^^ @@ -97,7 +97,7 @@ LL + fn deep_reference_3(x: &u8, _y: u8) -> Result<&u8, ()> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:86:28 + --> tests/ui/needless_lifetimes.rs:86:28 | LL | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> | ^^ ^^ ^^ @@ -109,7 +109,7 @@ LL + fn where_clause_without_lt(x: &u8, _y: u8) -> Result<&u8, ()> | error: the following explicit lifetimes could be elided: 'a, 'b - --> $DIR/needless_lifetimes.rs:98:21 + --> tests/ui/needless_lifetimes.rs:98:21 | LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} | ^^ ^^ ^^ ^^ @@ -121,7 +121,7 @@ LL + fn lifetime_param_2(_x: Ref<'_>, _y: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:122:15 + --> tests/ui/needless_lifetimes.rs:122:15 | LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> | ^^ ^^ ^^ @@ -133,7 +133,7 @@ LL + fn fn_bound_2(_m: Lt<'_, I>, _f: F) -> Lt<'_, I> | error: the following explicit lifetimes could be elided: 's - --> $DIR/needless_lifetimes.rs:152:21 + --> tests/ui/needless_lifetimes.rs:152:21 | LL | fn self_and_out<'s>(&'s self) -> &'s u8 { | ^^ ^^ ^^ @@ -145,7 +145,7 @@ LL + fn self_and_out(&self) -> &u8 { | error: the following explicit lifetimes could be elided: 't - --> $DIR/needless_lifetimes.rs:159:30 + --> tests/ui/needless_lifetimes.rs:159:30 | LL | fn self_and_in_out_1<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { | ^^ ^^ @@ -157,7 +157,7 @@ LL + fn self_and_in_out_1<'s>(&'s self, _x: &u8) -> &'s u8 { | error: the following explicit lifetimes could be elided: 's - --> $DIR/needless_lifetimes.rs:166:26 + --> tests/ui/needless_lifetimes.rs:166:26 | LL | fn self_and_in_out_2<'s, 't>(&'s self, x: &'t u8) -> &'t u8 { | ^^ ^^ @@ -169,7 +169,7 @@ LL + fn self_and_in_out_2<'t>(&self, x: &'t u8) -> &'t u8 { | error: the following explicit lifetimes could be elided: 's, 't - --> $DIR/needless_lifetimes.rs:170:29 + --> tests/ui/needless_lifetimes.rs:170:29 | LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} | ^^ ^^ ^^ ^^ @@ -181,7 +181,7 @@ LL + fn distinct_self_and_in(&self, _x: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:189:19 + --> tests/ui/needless_lifetimes.rs:189:19 | LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { | ^^ ^^ ^^ @@ -193,7 +193,7 @@ LL + fn struct_with_lt(_foo: Foo<'_>) -> &str { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:207:25 + --> tests/ui/needless_lifetimes.rs:207:25 | LL | fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str { | ^^ ^^ @@ -205,7 +205,7 @@ LL + fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:215:21 + --> tests/ui/needless_lifetimes.rs:215:21 | LL | fn struct_with_lt4b<'a, 'b>(_foo: &'a Foo<'b>) -> &'b str { | ^^ ^^ @@ -217,7 +217,7 @@ LL + fn struct_with_lt4b<'b>(_foo: &Foo<'b>) -> &'b str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:230:22 + --> tests/ui/needless_lifetimes.rs:230:22 | LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str { | ^^ ^^ ^^ @@ -229,7 +229,7 @@ LL + fn trait_obj_elided2(_arg: &dyn Drop) -> &str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:236:18 + --> tests/ui/needless_lifetimes.rs:236:18 | LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { | ^^ ^^ ^^ @@ -241,7 +241,7 @@ LL + fn alias_with_lt(_foo: FooAlias<'_>) -> &str { | error: the following explicit lifetimes could be elided: 'b - --> $DIR/needless_lifetimes.rs:254:24 + --> tests/ui/needless_lifetimes.rs:254:24 | LL | fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str { | ^^ ^^ @@ -253,7 +253,7 @@ LL + fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:262:20 + --> tests/ui/needless_lifetimes.rs:262:20 | LL | fn alias_with_lt4b<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'b str { | ^^ ^^ @@ -265,7 +265,7 @@ LL + fn alias_with_lt4b<'b>(_foo: &FooAlias<'b>) -> &'b str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:266:30 + --> tests/ui/needless_lifetimes.rs:266:30 | LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { | ^^ ^^ ^ @@ -277,7 +277,7 @@ LL + fn named_input_elided_output(_arg: &str) -> &str { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:274:19 + --> tests/ui/needless_lifetimes.rs:274:19 | LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { | ^^ ^^ @@ -289,7 +289,7 @@ LL + fn trait_bound_ok>(_: &u8, _: T) { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:310:24 + --> tests/ui/needless_lifetimes.rs:310:24 | LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { | ^^ ^^ ^^ @@ -301,7 +301,7 @@ LL + fn out_return_type_lts(e: &str) -> Cow<'_> { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:317:24 + --> tests/ui/needless_lifetimes.rs:317:24 | LL | fn needless_lt<'a>(x: &'a u8) {} | ^^ ^^ @@ -313,7 +313,7 @@ LL + fn needless_lt(x: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:321:24 + --> tests/ui/needless_lifetimes.rs:321:24 | LL | fn needless_lt<'a>(_x: &'a u8) {} | ^^ ^^ @@ -325,7 +325,7 @@ LL + fn needless_lt(_x: &u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:334:16 + --> tests/ui/needless_lifetimes.rs:334:16 | LL | fn baz<'a>(&'a self) -> impl Foo + 'a { | ^^ ^^ ^^ @@ -337,7 +337,7 @@ LL + fn baz(&self) -> impl Foo + '_ { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:366:55 + --> tests/ui/needless_lifetimes.rs:366:55 | LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 { | ^^ ^^ ^^ @@ -349,7 +349,7 @@ LL + fn impl_trait_elidable_nested_anonymous_lifetimes(i: &i32, f: impl Fn(& | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:375:26 + --> tests/ui/needless_lifetimes.rs:375:26 | LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 { | ^^ ^^ ^^ @@ -361,7 +361,7 @@ LL + fn generics_elidable &i32>(i: &i32, f: T) -> &i32 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:387:32 + --> tests/ui/needless_lifetimes.rs:387:32 | LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32 | ^^ ^^ ^^ @@ -373,7 +373,7 @@ LL + fn where_clause_elidadable(i: &i32, f: T) -> &i32 | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:402:28 + --> tests/ui/needless_lifetimes.rs:402:28 | LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 { | ^^ ^^ ^^ @@ -385,7 +385,7 @@ LL + fn pointer_fn_elidable(i: &i32, f: fn(&i32) -> &i32) -> &i32 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:415:28 + --> tests/ui/needless_lifetimes.rs:415:28 | LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 { | ^^ ^^ @@ -397,7 +397,7 @@ LL + fn nested_fn_pointer_3(_: &i32) -> fn(fn(&i32) -> &i32) -> i32 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:418:28 + --> tests/ui/needless_lifetimes.rs:418:28 | LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) { | ^^ ^^ @@ -409,7 +409,7 @@ LL + fn nested_fn_pointer_4(_: &i32) -> impl Fn(fn(&i32)) { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:440:21 + --> tests/ui/needless_lifetimes.rs:440:21 | LL | fn implicit<'a>(&'a self) -> &'a () { | ^^ ^^ ^^ @@ -421,7 +421,7 @@ LL + fn implicit(&self) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:443:25 + --> tests/ui/needless_lifetimes.rs:443:25 | LL | fn implicit_mut<'a>(&'a mut self) -> &'a () { | ^^ ^^ ^^ @@ -433,7 +433,7 @@ LL + fn implicit_mut(&mut self) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:454:31 + --> tests/ui/needless_lifetimes.rs:454:31 | LL | fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a () { | ^^ ^^ ^^ @@ -445,7 +445,7 @@ LL + fn lifetime_elsewhere(self: Box, here: &()) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:460:21 + --> tests/ui/needless_lifetimes.rs:460:21 | LL | fn implicit<'a>(&'a self) -> &'a (); | ^^ ^^ ^^ @@ -457,7 +457,7 @@ LL + fn implicit(&self) -> &(); | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:461:30 + --> tests/ui/needless_lifetimes.rs:461:30 | LL | fn implicit_provided<'a>(&'a self) -> &'a () { | ^^ ^^ ^^ @@ -469,7 +469,7 @@ LL + fn implicit_provided(&self) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:470:31 + --> tests/ui/needless_lifetimes.rs:470:31 | LL | fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a (); | ^^ ^^ ^^ @@ -481,7 +481,7 @@ LL + fn lifetime_elsewhere(self: Box, here: &()) -> &(); | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:471:40 + --> tests/ui/needless_lifetimes.rs:471:40 | LL | fn lifetime_elsewhere_provided<'a>(self: Box, here: &'a ()) -> &'a () { | ^^ ^^ ^^ @@ -493,7 +493,7 @@ LL + fn lifetime_elsewhere_provided(self: Box, here: &()) -> &() { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:480:12 + --> tests/ui/needless_lifetimes.rs:480:12 | LL | fn foo<'a>(x: &'a u8, y: &'_ u8) {} | ^^ ^^ @@ -505,7 +505,7 @@ LL + fn foo(x: &u8, y: &'_ u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:482:12 + --> tests/ui/needless_lifetimes.rs:482:12 | LL | fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {} | ^^ ^^ @@ -517,7 +517,7 @@ LL + fn bar(x: &u8, y: &'_ u8, z: &'_ u8) {} | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:489:18 + --> tests/ui/needless_lifetimes.rs:489:18 | LL | fn one_input<'a>(x: &'a u8) -> &'a u8 { | ^^ ^^ ^^ @@ -529,7 +529,7 @@ LL + fn one_input(x: &u8) -> &u8 { | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:494:42 + --> tests/ui/needless_lifetimes.rs:494:42 | LL | fn multiple_inputs_output_not_elided<'a, 'b>(x: &'a u8, y: &'b u8, z: &'b u8) -> &'b u8 { | ^^ ^^ @@ -541,7 +541,7 @@ LL + fn multiple_inputs_output_not_elided<'b>(x: &u8, y: &'b u8, z: &'b u8) | error: the following explicit lifetimes could be elided: 'a - --> $DIR/needless_lifetimes.rs:510:22 + --> tests/ui/needless_lifetimes.rs:510:22 | LL | fn one_input<'a>(x: &'a u8) -> &'a u8 { | ^^ ^^ ^^ diff --git a/src/tools/clippy/tests/ui/needless_match.stderr b/src/tools/clippy/tests/ui/needless_match.stderr index 736926b4415bc..5bcab467aeae3 100644 --- a/src/tools/clippy/tests/ui/needless_match.stderr +++ b/src/tools/clippy/tests/ui/needless_match.stderr @@ -1,5 +1,5 @@ error: this match expression is unnecessary - --> $DIR/needless_match.rs:15:18 + --> tests/ui/needless_match.rs:15:18 | LL | let _: i32 = match i { | __________________^ @@ -14,7 +14,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::needless_match)]` error: this match expression is unnecessary - --> $DIR/needless_match.rs:22:19 + --> tests/ui/needless_match.rs:22:19 | LL | let _: &str = match s { | ___________________^ @@ -25,7 +25,7 @@ LL | | }; | |_____^ help: replace it with: `s` error: this match expression is unnecessary - --> $DIR/needless_match.rs:31:21 + --> tests/ui/needless_match.rs:31:21 | LL | let _: Simple = match se { | _____________________^ @@ -37,7 +37,7 @@ LL | | }; | |_____^ help: replace it with: `se` error: this match expression is unnecessary - --> $DIR/needless_match.rs:53:26 + --> tests/ui/needless_match.rs:53:26 | LL | let _: Option = match x { | __________________________^ @@ -47,7 +47,7 @@ LL | | }; | |_____^ help: replace it with: `x` error: this match expression is unnecessary - --> $DIR/needless_match.rs:69:31 + --> tests/ui/needless_match.rs:69:31 | LL | let _: Result = match Ok(1) { | _______________________________^ @@ -57,7 +57,7 @@ LL | | }; | |_____^ help: replace it with: `Ok(1)` error: this match expression is unnecessary - --> $DIR/needless_match.rs:73:31 + --> tests/ui/needless_match.rs:73:31 | LL | let _: Result = match func_ret_err(0_i32) { | _______________________________^ @@ -67,25 +67,25 @@ LL | | }; | |_____^ help: replace it with: `func_ret_err(0_i32)` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:86:13 + --> tests/ui/needless_match.rs:86:13 | LL | let _ = if let Some(a) = Some(1) { Some(a) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `Some(1)` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:121:31 + --> tests/ui/needless_match.rs:121:31 | LL | let _: Result = if let Err(e) = x { Err(e) } else { x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:122:31 + --> tests/ui/needless_match.rs:122:31 | LL | let _: Result = if let Ok(val) = x { Ok(val) } else { x }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x` error: this if-let expression is unnecessary - --> $DIR/needless_match.rs:129:21 + --> tests/ui/needless_match.rs:129:21 | LL | let _: Simple = if let Simple::A = x { | _____________________^ @@ -98,7 +98,7 @@ LL | | }; | |_____^ help: replace it with: `x` error: this match expression is unnecessary - --> $DIR/needless_match.rs:168:26 + --> tests/ui/needless_match.rs:168:26 | LL | let _: Complex = match ce { | __________________________^ @@ -111,7 +111,7 @@ LL | | }; | |_________^ help: replace it with: `ce` error: this match expression is unnecessary - --> $DIR/needless_match.rs:252:17 + --> tests/ui/needless_match.rs:252:17 | LL | let _ = match e { | _________________^ @@ -121,7 +121,7 @@ LL | | }; | |_________^ help: replace it with: `e` error: this match expression is unnecessary - --> $DIR/needless_match.rs:258:17 + --> tests/ui/needless_match.rs:258:17 | LL | let _ = match e { | _________________^ 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 024d30c1717c2..a05d0aa9276ac 100644 --- a/src/tools/clippy/tests/ui/needless_option_as_deref.stderr +++ b/src/tools/clippy/tests/ui/needless_option_as_deref.stderr @@ -1,5 +1,5 @@ error: derefed type is same as origin - --> $DIR/needless_option_as_deref.rs:7:29 + --> tests/ui/needless_option_as_deref.rs:7:29 | LL | let _: Option<&usize> = Some(&1).as_deref(); | ^^^^^^^^^^^^^^^^^^^ help: try: `Some(&1)` @@ -8,13 +8,13 @@ LL | let _: Option<&usize> = Some(&1).as_deref(); = 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 + --> tests/ui/needless_option_as_deref.rs:8:33 | LL | let _: Option<&mut usize> = Some(&mut 1).as_deref_mut(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(&mut 1)` error: derefed type is same as origin - --> $DIR/needless_option_as_deref.rs:12:13 + --> tests/ui/needless_option_as_deref.rs:12:13 | LL | let _ = x.as_deref_mut(); | ^^^^^^^^^^^^^^^^ help: try: `x` diff --git a/src/tools/clippy/tests/ui/needless_option_take.stderr b/src/tools/clippy/tests/ui/needless_option_take.stderr index bf43a18e7115c..4a73ccb86d081 100644 --- a/src/tools/clippy/tests/ui/needless_option_take.stderr +++ b/src/tools/clippy/tests/ui/needless_option_take.stderr @@ -1,5 +1,5 @@ error: called `Option::take()` on a temporary value - --> $DIR/needless_option_take.rs:12:5 + --> tests/ui/needless_option_take.rs:12:5 | LL | x.as_ref().take(); | ^^^^^^^^^^^^^^^^^ help: try: `x.as_ref()` 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 c73564e210c06..d293ecce69fbd 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 @@ -1,5 +1,5 @@ error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:7:13 + --> tests/ui/needless_parens_on_range_literals.rs:7:13 | LL | let _ = ('a')..=('z'); | ^^^^^ help: try: `'a'` @@ -8,31 +8,31 @@ LL | let _ = ('a')..=('z'); = 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 + --> tests/ui/needless_parens_on_range_literals.rs:7:21 | LL | let _ = ('a')..=('z'); | ^^^^^ help: try: `'z'` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:8:18 + --> tests/ui/needless_parens_on_range_literals.rs:8:18 | LL | let _ = 'a'..('z'); | ^^^^^ help: try: `'z'` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:10:19 + --> tests/ui/needless_parens_on_range_literals.rs:10:19 | LL | let _ = (1.)..(2.); | ^^^^ help: try: `2.` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:11:13 + --> tests/ui/needless_parens_on_range_literals.rs:11:13 | LL | let _ = ('a')..; | ^^^^^ help: try: `'a'` error: needless parenthesis on range literals can be removed - --> $DIR/needless_parens_on_range_literals.rs:12:15 + --> tests/ui/needless_parens_on_range_literals.rs:12:15 | LL | let _ = ..('z'); | ^^^^^ help: try: `'z'` 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 5d1e9515de125..89dad3e60b143 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 @@ -1,5 +1,5 @@ error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:12:11 + --> tests/ui/needless_pass_by_ref_mut.rs:12:11 | LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` @@ -8,79 +8,79 @@ LL | fn foo(s: &mut Vec, b: &u32, x: &mut u32) { = 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:37:12 + --> tests/ui/needless_pass_by_ref_mut.rs:37:12 | LL | fn foo6(s: &mut Vec) { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:50:29 + --> tests/ui/needless_pass_by_ref_mut.rs:50:29 | LL | fn mushroom(&self, vec: &mut Vec) -> usize { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:55:31 + --> tests/ui/needless_pass_by_ref_mut.rs:55:31 | LL | fn badger(&mut self, vec: &mut Vec) -> usize { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:132:16 + --> tests/ui/needless_pass_by_ref_mut.rs:132:16 | LL | async fn a1(x: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:136:16 + --> tests/ui/needless_pass_by_ref_mut.rs:136:16 | LL | async fn a2(x: &mut i32, y: String) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:140:16 + --> tests/ui/needless_pass_by_ref_mut.rs:140:16 | LL | async fn a3(x: &mut i32, y: String, z: String) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:144:16 + --> tests/ui/needless_pass_by_ref_mut.rs:144:16 | LL | async fn a4(x: &mut i32, y: i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:148:24 + --> tests/ui/needless_pass_by_ref_mut.rs:148:24 | LL | async fn a5(x: i32, y: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:152:24 + --> tests/ui/needless_pass_by_ref_mut.rs:152:24 | LL | async fn a6(x: i32, y: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:156:32 + --> tests/ui/needless_pass_by_ref_mut.rs:156:32 | LL | async fn a7(x: i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:160:24 + --> tests/ui/needless_pass_by_ref_mut.rs:160:24 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:160:45 + --> tests/ui/needless_pass_by_ref_mut.rs:160:45 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:194:16 + --> tests/ui/needless_pass_by_ref_mut.rs:194:16 | LL | fn cfg_warn(s: &mut u32) {} | ^^^^^^^^ help: consider changing to: `&u32` @@ -88,7 +88,7 @@ LL | fn cfg_warn(s: &mut u32) {} = note: this is cfg-gated and may require further changes error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:200:20 + --> tests/ui/needless_pass_by_ref_mut.rs:200:20 | LL | fn cfg_warn(s: &mut u32) {} | ^^^^^^^^ help: consider changing to: `&u32` @@ -96,19 +96,19 @@ LL | fn cfg_warn(s: &mut u32) {} = note: this is cfg-gated and may require further changes error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:214:39 + --> tests/ui/needless_pass_by_ref_mut.rs:214:39 | LL | async fn inner_async2(x: &mut i32, y: &mut u32) { | ^^^^^^^^ help: consider changing to: `&u32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:222:26 + --> tests/ui/needless_pass_by_ref_mut.rs:222:26 | LL | async fn inner_async3(x: &mut i32, y: &mut u32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:241:34 + --> tests/ui/needless_pass_by_ref_mut.rs:241:34 | LL | pub async fn call_in_closure1(n: &mut str) { | ^^^^^^^^ help: consider changing to: `&str` @@ -116,7 +116,7 @@ LL | pub async fn call_in_closure1(n: &mut str) { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:253:25 + --> tests/ui/needless_pass_by_ref_mut.rs:253:25 | LL | pub async fn closure(n: &mut usize) -> impl '_ + FnMut() { | ^^^^^^^^^^ help: consider changing to: `&usize` @@ -124,7 +124,7 @@ LL | pub async fn closure(n: &mut usize) -> impl '_ + FnMut() { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:260:20 + --> tests/ui/needless_pass_by_ref_mut.rs:260:20 | LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { | ^^^^^^^^^^ help: consider changing to: `&usize` @@ -132,7 +132,7 @@ LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:271:26 + --> tests/ui/needless_pass_by_ref_mut.rs:271:26 | LL | pub async fn closure4(n: &mut usize) { | ^^^^^^^^^^ help: consider changing to: `&usize` @@ -140,61 +140,61 @@ LL | pub async fn closure4(n: &mut usize) { = warning: changing this function will impact semver compatibility error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:311:18 + --> tests/ui/needless_pass_by_ref_mut.rs:311:18 | LL | fn _empty_tup(x: &mut (())) {} | ^^^^^^^^^ help: consider changing to: `&()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:312:19 + --> tests/ui/needless_pass_by_ref_mut.rs:312:19 | LL | fn _single_tup(x: &mut ((i32,))) {} | ^^^^^^^^^^^^^ help: consider changing to: `&(i32,)` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:313:18 + --> tests/ui/needless_pass_by_ref_mut.rs:313:18 | LL | fn _multi_tup(x: &mut ((i32, u32))) {} | ^^^^^^^^^^^^^^^^^ help: consider changing to: `&(i32, u32)` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:314:11 + --> tests/ui/needless_pass_by_ref_mut.rs:314:11 | LL | fn _fn(x: &mut (fn())) {} | ^^^^^^^^^^^ help: consider changing to: `&fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:316:23 + --> tests/ui/needless_pass_by_ref_mut.rs:316:23 | LL | fn _extern_rust_fn(x: &mut extern "Rust" fn()) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "Rust" fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:317:20 + --> tests/ui/needless_pass_by_ref_mut.rs:317:20 | LL | fn _extern_c_fn(x: &mut extern "C" fn()) {} | ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "C" fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:318:18 + --> tests/ui/needless_pass_by_ref_mut.rs:318:18 | LL | fn _unsafe_fn(x: &mut unsafe fn()) {} | ^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:319:25 + --> tests/ui/needless_pass_by_ref_mut.rs:319:25 | LL | fn _unsafe_extern_fn(x: &mut unsafe extern "C" fn()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn()` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:320:20 + --> tests/ui/needless_pass_by_ref_mut.rs:320:20 | LL | fn _fn_with_arg(x: &mut unsafe extern "C" fn(i32)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn(i32)` error: this argument is a mutable reference, but not used mutably - --> $DIR/needless_pass_by_ref_mut.rs:321:20 + --> tests/ui/needless_pass_by_ref_mut.rs:321:20 | LL | fn _fn_with_ret(x: &mut unsafe extern "C" fn() -> (i32)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn() -> (i32)` 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 1c3a63d661f68..827a200ba6819 100644 --- a/src/tools/clippy/tests/ui/needless_pass_by_value.stderr +++ b/src/tools/clippy/tests/ui/needless_pass_by_value.stderr @@ -1,5 +1,5 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:18:23 + --> tests/ui/needless_pass_by_value.rs:18:23 | LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` @@ -8,55 +8,55 @@ LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec $DIR/needless_pass_by_value.rs:34:11 + --> tests/ui/needless_pass_by_value.rs:34:11 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:34:22 + --> tests/ui/needless_pass_by_value.rs:34:22 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:42:71 + --> tests/ui/needless_pass_by_value.rs:42:71 | LL | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:55:18 + --> tests/ui/needless_pass_by_value.rs:55:18 | LL | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option>` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:69:24 + --> tests/ui/needless_pass_by_value.rs:69:24 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:69:36 + --> tests/ui/needless_pass_by_value.rs:69:36 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:87:49 + --> tests/ui/needless_pass_by_value.rs:87:49 | LL | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:18 + --> tests/ui/needless_pass_by_value.rs:90:18 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:29 + --> tests/ui/needless_pass_by_value.rs:90:29 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ @@ -71,13 +71,13 @@ LL | let _ = t.to_string(); | ~~~~~~~~~~~~~ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:40 + --> tests/ui/needless_pass_by_value.rs:90:40 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:90:53 + --> tests/ui/needless_pass_by_value.rs:90:53 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ @@ -92,85 +92,85 @@ LL | let _ = v.to_owned(); | ~~~~~~~~~~~~ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:107:12 + --> tests/ui/needless_pass_by_value.rs:107:12 | LL | s: String, | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:109:12 + --> tests/ui/needless_pass_by_value.rs:109:12 | LL | t: String, | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:119:23 + --> tests/ui/needless_pass_by_value.rs:119:23 | LL | fn baz(&self, _u: U, _s: Self) {} | ^ help: consider taking a reference instead: `&U` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:119:30 + --> tests/ui/needless_pass_by_value.rs:119:30 | LL | fn baz(&self, _u: U, _s: Self) {} | ^^^^ help: consider taking a reference instead: `&Self` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:143:24 + --> tests/ui/needless_pass_by_value.rs:143:24 | LL | fn bar_copy(x: u32, y: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:150:29 + --> tests/ui/needless_pass_by_value.rs:150:29 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:150:45 + --> tests/ui/needless_pass_by_value.rs:150:45 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:150:61 + --> tests/ui/needless_pass_by_value.rs:150:61 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: consider marking this type as `Copy` - --> $DIR/needless_pass_by_value.rs:141:1 + --> tests/ui/needless_pass_by_value.rs:141:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:165:40 + --> tests/ui/needless_pass_by_value.rs:165:40 | LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {} | ^ help: consider taking a reference instead: `&S` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:171:20 + --> tests/ui/needless_pass_by_value.rs:171:20 | LL | fn more_fun(_item: impl Club<'static, i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` diff --git a/src/tools/clippy/tests/ui/needless_pub_self.stderr b/src/tools/clippy/tests/ui/needless_pub_self.stderr index c1f6b908b53d4..0bff2e4b8b71b 100644 --- a/src/tools/clippy/tests/ui/needless_pub_self.stderr +++ b/src/tools/clippy/tests/ui/needless_pub_self.stderr @@ -1,5 +1,5 @@ error: unnecessary `pub(self)` - --> $DIR/needless_pub_self.rs:13:1 + --> tests/ui/needless_pub_self.rs:13:1 | LL | pub(self) fn a() {} | ^^^^^^^^^ help: remove it @@ -8,13 +8,13 @@ LL | pub(self) fn a() {} = help: to override `-D warnings` add `#[allow(clippy::needless_pub_self)]` error: unnecessary `pub(in self)` - --> $DIR/needless_pub_self.rs:14:1 + --> tests/ui/needless_pub_self.rs:14:1 | LL | pub(in self) fn b() {} | ^^^^^^^^^^^^ help: remove it error: unnecessary `pub(self)` - --> $DIR/needless_pub_self.rs:20:5 + --> tests/ui/needless_pub_self.rs:20:5 | LL | pub(self) fn f() {} | ^^^^^^^^^ help: remove it diff --git a/src/tools/clippy/tests/ui/needless_question_mark.stderr b/src/tools/clippy/tests/ui/needless_question_mark.stderr index bf090302ef7eb..0a1cb59797086 100644 --- a/src/tools/clippy/tests/ui/needless_question_mark.stderr +++ b/src/tools/clippy/tests/ui/needless_question_mark.stderr @@ -1,5 +1,5 @@ error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:20:12 + --> tests/ui/needless_question_mark.rs:20:12 | LL | return Some(to.magic?); | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` @@ -8,67 +8,67 @@ LL | return Some(to.magic?); = 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 + --> tests/ui/needless_question_mark.rs:28:12 | LL | return Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:33:5 + --> tests/ui/needless_question_mark.rs:33:5 | LL | Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:38:21 + --> tests/ui/needless_question_mark.rs:38:21 | LL | to.and_then(|t| Some(t.magic?)) | ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:47:9 + --> tests/ui/needless_question_mark.rs:47:9 | LL | Some(t.magic?) | ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:52:12 + --> tests/ui/needless_question_mark.rs:52:12 | LL | return Ok(tr.magic?); | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:59:12 + --> tests/ui/needless_question_mark.rs:59:12 | LL | return Ok(tr.magic?) | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:63:5 + --> tests/ui/needless_question_mark.rs:63:5 | LL | Ok(tr.magic?) | ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:67:21 + --> tests/ui/needless_question_mark.rs:67:21 | LL | tr.and_then(|t| Ok(t.magic?)) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:75:9 + --> tests/ui/needless_question_mark.rs:75:9 | LL | Ok(t.magic?) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:82:16 + --> tests/ui/needless_question_mark.rs:82:16 | LL | return Ok(t.magic?); | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:117:27 + --> tests/ui/needless_question_mark.rs:117:27 | LL | || -> Option<_> { Some(Some($expr)?) }() | ^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `Some($expr)` @@ -79,19 +79,19 @@ LL | let _x = some_and_qmark_in_macro!(x?); = note: this error originates in the macro `some_and_qmark_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:128:5 + --> tests/ui/needless_question_mark.rs:128:5 | LL | Some(to.magic?) | ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:136:5 + --> tests/ui/needless_question_mark.rs:136:5 | LL | Ok(s.magic?) | ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `s.magic` error: question mark operator is useless here - --> $DIR/needless_question_mark.rs:140:7 + --> tests/ui/needless_question_mark.rs:140:7 | LL | { Some(a?) } | ^^^^^^^^ help: try removing question mark and `Some()`: `a` diff --git a/src/tools/clippy/tests/ui/needless_range_loop.stderr b/src/tools/clippy/tests/ui/needless_range_loop.stderr index 0d8893c261961..dc2cf437e02ea 100644 --- a/src/tools/clippy/tests/ui/needless_range_loop.stderr +++ b/src/tools/clippy/tests/ui/needless_range_loop.stderr @@ -1,5 +1,5 @@ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:15:14 + --> tests/ui/needless_range_loop.rs:15:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -12,7 +12,7 @@ LL | for in &vec { | ~~~~~~ ~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:26:14 + --> tests/ui/needless_range_loop.rs:26:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | for in &vec { | ~~~~~~ ~~~~ error: the loop variable `j` is only used to index `STATIC` - --> $DIR/needless_range_loop.rs:32:14 + --> tests/ui/needless_range_loop.rs:32:14 | LL | for j in 0..4 { | ^^^^ @@ -34,7 +34,7 @@ LL | for in &STATIC { | ~~~~~~ ~~~~~~~ error: the loop variable `j` is only used to index `CONST` - --> $DIR/needless_range_loop.rs:37:14 + --> tests/ui/needless_range_loop.rs:37:14 | LL | for j in 0..4 { | ^^^^ @@ -45,7 +45,7 @@ LL | for in &CONST { | ~~~~~~ ~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:42:14 + --> tests/ui/needless_range_loop.rs:42:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for (i, ) in vec.iter().enumerate() { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec2` - --> $DIR/needless_range_loop.rs:51:14 + --> tests/ui/needless_range_loop.rs:51:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | for in vec2.iter().take(vec.len()) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:56:14 + --> tests/ui/needless_range_loop.rs:56:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | for in vec.iter().skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:61:14 + --> tests/ui/needless_range_loop.rs:61:14 | LL | for i in 0..MAX_LEN { | ^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | for in vec.iter().take(MAX_LEN) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:66:14 + --> tests/ui/needless_range_loop.rs:66:14 | LL | for i in 0..=MAX_LEN { | ^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | for in vec.iter().take(MAX_LEN + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:71:14 + --> tests/ui/needless_range_loop.rs:71:14 | LL | for i in 5..10 { | ^^^^^ @@ -111,7 +111,7 @@ LL | for in vec.iter().take(10).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop.rs:76:14 + --> tests/ui/needless_range_loop.rs:76:14 | LL | for i in 5..=10 { | ^^^^^^ @@ -122,7 +122,7 @@ LL | for in vec.iter().take(10 + 1).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:81:14 + --> tests/ui/needless_range_loop.rs:81:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | for (i, ) in vec.iter().enumerate().skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:86:14 + --> tests/ui/needless_range_loop.rs:86:14 | LL | for i in 5..10 { | ^^^^^ @@ -144,7 +144,7 @@ LL | for (i, ) in vec.iter().enumerate().take(10).skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> $DIR/needless_range_loop.rs:92:14 + --> tests/ui/needless_range_loop.rs:92:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/needless_range_loop2.stderr b/src/tools/clippy/tests/ui/needless_range_loop2.stderr index 3d1d9e1bff432..353f30b1b26dc 100644 --- a/src/tools/clippy/tests/ui/needless_range_loop2.stderr +++ b/src/tools/clippy/tests/ui/needless_range_loop2.stderr @@ -1,5 +1,5 @@ error: the loop variable `i` is only used to index `ns` - --> $DIR/needless_range_loop2.rs:11:14 + --> tests/ui/needless_range_loop2.rs:11:14 | LL | for i in 3..10 { | ^^^^^ @@ -12,7 +12,7 @@ LL | for in ns.iter().take(10).skip(3) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `ms` - --> $DIR/needless_range_loop2.rs:34:14 + --> tests/ui/needless_range_loop2.rs:34:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | for in &mut ms { | ~~~~~~ ~~~~~~~ error: the loop variable `i` is only used to index `ms` - --> $DIR/needless_range_loop2.rs:41:14 + --> tests/ui/needless_range_loop2.rs:41:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | for in &mut ms { | ~~~~~~ ~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop2.rs:66:14 + --> tests/ui/needless_range_loop2.rs:66:14 | LL | for i in x..x + 4 { | ^^^^^^^^ @@ -45,7 +45,7 @@ LL | for in vec.iter_mut().skip(x).take(4) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> $DIR/needless_range_loop2.rs:74:14 + --> tests/ui/needless_range_loop2.rs:74:14 | LL | for i in x..=x + 4 { | ^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for in vec.iter_mut().skip(x).take(4 + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `arr` - --> $DIR/needless_range_loop2.rs:81:14 + --> tests/ui/needless_range_loop2.rs:81:14 | LL | for i in 0..3 { | ^^^^ @@ -67,7 +67,7 @@ LL | for in &arr { | ~~~~~~ ~~~~ error: the loop variable `i` is only used to index `arr` - --> $DIR/needless_range_loop2.rs:86:14 + --> tests/ui/needless_range_loop2.rs:86:14 | LL | for i in 0..2 { | ^^^^ @@ -78,7 +78,7 @@ LL | for in arr.iter().take(2) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `arr` - --> $DIR/needless_range_loop2.rs:91:14 + --> tests/ui/needless_range_loop2.rs:91:14 | LL | for i in 1..3 { | ^^^^ diff --git a/src/tools/clippy/tests/ui/needless_raw_string.stderr b/src/tools/clippy/tests/ui/needless_raw_string.stderr index b2188698564f9..7d3451a03c75c 100644 --- a/src/tools/clippy/tests/ui/needless_raw_string.stderr +++ b/src/tools/clippy/tests/ui/needless_raw_string.stderr @@ -1,5 +1,5 @@ error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:5:5 + --> tests/ui/needless_raw_string.rs:5:5 | LL | r#"aaa"#; | ^^^^^^^^ @@ -13,7 +13,7 @@ LL + "aaa"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:8:5 + --> tests/ui/needless_raw_string.rs:8:5 | LL | br#"aaa"#; | ^^^^^^^^^ @@ -25,7 +25,7 @@ LL + b"aaa"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:11:5 + --> tests/ui/needless_raw_string.rs:11:5 | LL | cr#"aaa"#; | ^^^^^^^^^ @@ -37,7 +37,7 @@ LL + c"aaa"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:15:5 + --> tests/ui/needless_raw_string.rs:15:5 | LL | / r#" LL | | a @@ -56,7 +56,7 @@ LL ~ "; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:21:5 + --> tests/ui/needless_raw_string.rs:21:5 | LL | r"no hashes"; | ^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL + "no hashes"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:22:5 + --> tests/ui/needless_raw_string.rs:22:5 | LL | br"no hashes"; | ^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ LL + b"no hashes"; | error: unnecessary raw string literal - --> $DIR/needless_raw_string.rs:23:5 + --> tests/ui/needless_raw_string.rs:23:5 | LL | cr"no hashes"; | ^^^^^^^^^^^^^ 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 c74eff8161e94..96864f612c098 100644 --- a/src/tools/clippy/tests/ui/needless_raw_string_hashes.stderr +++ b/src/tools/clippy/tests/ui/needless_raw_string_hashes.stderr @@ -1,5 +1,5 @@ error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:5:5 + --> tests/ui/needless_raw_string_hashes.rs:5:5 | LL | r#"\aaa"#; | ^^^^^^^^^ @@ -13,7 +13,7 @@ LL + r"\aaa"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:6:5 + --> tests/ui/needless_raw_string_hashes.rs:6:5 | LL | r##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + r#"Hello "world"!"#; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:7:5 + --> tests/ui/needless_raw_string_hashes.rs:7:5 | LL | r######" "### "## "# "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + r####" "### "## "# "####; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:8:5 + --> tests/ui/needless_raw_string_hashes.rs:8:5 | LL | r######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + r###" "aa" "# "## "###; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:9:5 + --> tests/ui/needless_raw_string_hashes.rs:9:5 | LL | br#"\aaa"#; | ^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + br"\aaa"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:10:5 + --> tests/ui/needless_raw_string_hashes.rs:10:5 | LL | br##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + br#"Hello "world"!"#; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:11:5 + --> tests/ui/needless_raw_string_hashes.rs:11:5 | LL | br######" "### "## "# "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + br####" "### "## "# "####; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:12:5 + --> tests/ui/needless_raw_string_hashes.rs:12:5 | LL | br######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + br###" "aa" "# "## "###; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:13:5 + --> tests/ui/needless_raw_string_hashes.rs:13:5 | LL | cr#"\aaa"#; | ^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + cr"\aaa"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:14:5 + --> tests/ui/needless_raw_string_hashes.rs:14:5 | LL | cr##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + cr#"Hello "world"!"#; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:15:5 + --> tests/ui/needless_raw_string_hashes.rs:15:5 | LL | cr######" "### "## "# "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + cr####" "### "## "# "####; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:16:5 + --> tests/ui/needless_raw_string_hashes.rs:16:5 | LL | cr######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + cr###" "aa" "# "## "###; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:18:5 + --> tests/ui/needless_raw_string_hashes.rs:18:5 | LL | / r#" LL | | \a @@ -164,7 +164,7 @@ LL ~ "; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:24:5 + --> tests/ui/needless_raw_string_hashes.rs:24:5 | LL | r###"rust"###; | ^^^^^^^^^^^^^ @@ -176,7 +176,7 @@ LL + r"rust"; | error: unnecessary hashes around raw string literal - --> $DIR/needless_raw_string_hashes.rs:25:5 + --> tests/ui/needless_raw_string_hashes.rs:25:5 | LL | r#"hello world"#; | ^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/needless_return.stderr b/src/tools/clippy/tests/ui/needless_return.stderr index cc48831115d9f..758ff6d985cd8 100644 --- a/src/tools/clippy/tests/ui/needless_return.stderr +++ b/src/tools/clippy/tests/ui/needless_return.stderr @@ -1,5 +1,5 @@ error: unneeded `return` statement - --> $DIR/needless_return.rs:26:5 + --> tests/ui/needless_return.rs:26:5 | LL | return true; | ^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:30:5 + --> tests/ui/needless_return.rs:30:5 | LL | return true; | ^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:35:5 + --> tests/ui/needless_return.rs:35:5 | LL | return true;;; | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:40:5 + --> tests/ui/needless_return.rs:40:5 | LL | return true;; ; ; | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:45:9 + --> tests/ui/needless_return.rs:45:9 | LL | return true; | ^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:47:9 + --> tests/ui/needless_return.rs:47:9 | LL | return false; | ^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + false | error: unneeded `return` statement - --> $DIR/needless_return.rs:53:17 + --> tests/ui/needless_return.rs:53:17 | LL | true => return false, | ^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | true => false, | ~~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:55:13 + --> tests/ui/needless_return.rs:55:13 | LL | return true; | ^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:62:9 + --> tests/ui/needless_return.rs:62:9 | LL | return true; | ^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:64:16 + --> tests/ui/needless_return.rs:64:16 | LL | let _ = || return true; | ^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | let _ = || true; | ~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:68:5 + --> tests/ui/needless_return.rs:68:5 | LL | return the_answer!(); | ^^^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL + the_answer!() | error: unneeded `return` statement - --> $DIR/needless_return.rs:71:21 + --> tests/ui/needless_return.rs:71:21 | LL | fn test_void_fun() { | _____________________^ @@ -146,7 +146,7 @@ LL + fn test_void_fun() { | error: unneeded `return` statement - --> $DIR/needless_return.rs:76:11 + --> tests/ui/needless_return.rs:76:11 | LL | if b { | ___________^ @@ -161,7 +161,7 @@ LL + if b { | error: unneeded `return` statement - --> $DIR/needless_return.rs:78:13 + --> tests/ui/needless_return.rs:78:13 | LL | } else { | _____________^ @@ -176,7 +176,7 @@ LL + } else { | error: unneeded `return` statement - --> $DIR/needless_return.rs:86:14 + --> tests/ui/needless_return.rs:86:14 | LL | _ => return, | ^^^^^^ @@ -187,7 +187,7 @@ LL | _ => (), | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:94:24 + --> tests/ui/needless_return.rs:94:24 | LL | let _ = 42; | ________________________^ @@ -202,7 +202,7 @@ LL + let _ = 42; | error: unneeded `return` statement - --> $DIR/needless_return.rs:97:14 + --> tests/ui/needless_return.rs:97:14 | LL | _ => return, | ^^^^^^ @@ -213,7 +213,7 @@ LL | _ => (), | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:110:9 + --> tests/ui/needless_return.rs:110:9 | LL | return String::from("test"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL + String::from("test") | error: unneeded `return` statement - --> $DIR/needless_return.rs:112:9 + --> tests/ui/needless_return.rs:112:9 | LL | return String::new(); | ^^^^^^^^^^^^^^^^^^^^ @@ -237,7 +237,7 @@ LL + String::new() | error: unneeded `return` statement - --> $DIR/needless_return.rs:134:32 + --> tests/ui/needless_return.rs:134:32 | LL | bar.unwrap_or_else(|_| return) | ^^^^^^ @@ -248,7 +248,7 @@ LL | bar.unwrap_or_else(|_| {}) | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:138:21 + --> tests/ui/needless_return.rs:138:21 | LL | let _ = || { | _____________________^ @@ -263,7 +263,7 @@ LL + let _ = || { | error: unneeded `return` statement - --> $DIR/needless_return.rs:141:20 + --> tests/ui/needless_return.rs:141:20 | LL | let _ = || return; | ^^^^^^ @@ -274,7 +274,7 @@ LL | let _ = || {}; | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:147:32 + --> tests/ui/needless_return.rs:147:32 | LL | res.unwrap_or_else(|_| return Foo) | ^^^^^^^^^^ @@ -285,7 +285,7 @@ LL | res.unwrap_or_else(|_| Foo) | ~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:156:5 + --> tests/ui/needless_return.rs:156:5 | LL | return true; | ^^^^^^^^^^^ @@ -297,7 +297,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:160:5 + --> tests/ui/needless_return.rs:160:5 | LL | return true; | ^^^^^^^^^^^ @@ -309,7 +309,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:165:9 + --> tests/ui/needless_return.rs:165:9 | LL | return true; | ^^^^^^^^^^^ @@ -321,7 +321,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:167:9 + --> tests/ui/needless_return.rs:167:9 | LL | return false; | ^^^^^^^^^^^^ @@ -333,7 +333,7 @@ LL + false | error: unneeded `return` statement - --> $DIR/needless_return.rs:173:17 + --> tests/ui/needless_return.rs:173:17 | LL | true => return false, | ^^^^^^^^^^^^ @@ -344,7 +344,7 @@ LL | true => false, | ~~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:175:13 + --> tests/ui/needless_return.rs:175:13 | LL | return true; | ^^^^^^^^^^^ @@ -356,7 +356,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:182:9 + --> tests/ui/needless_return.rs:182:9 | LL | return true; | ^^^^^^^^^^^ @@ -368,7 +368,7 @@ LL + true | error: unneeded `return` statement - --> $DIR/needless_return.rs:184:16 + --> tests/ui/needless_return.rs:184:16 | LL | let _ = || return true; | ^^^^^^^^^^^ @@ -379,7 +379,7 @@ LL | let _ = || true; | ~~~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:188:5 + --> tests/ui/needless_return.rs:188:5 | LL | return the_answer!(); | ^^^^^^^^^^^^^^^^^^^^ @@ -391,7 +391,7 @@ LL + the_answer!() | error: unneeded `return` statement - --> $DIR/needless_return.rs:191:33 + --> tests/ui/needless_return.rs:191:33 | LL | async fn async_test_void_fun() { | _________________________________^ @@ -406,7 +406,7 @@ LL + async fn async_test_void_fun() { | error: unneeded `return` statement - --> $DIR/needless_return.rs:196:11 + --> tests/ui/needless_return.rs:196:11 | LL | if b { | ___________^ @@ -421,7 +421,7 @@ LL + if b { | error: unneeded `return` statement - --> $DIR/needless_return.rs:198:13 + --> tests/ui/needless_return.rs:198:13 | LL | } else { | _____________^ @@ -436,7 +436,7 @@ LL + } else { | error: unneeded `return` statement - --> $DIR/needless_return.rs:206:14 + --> tests/ui/needless_return.rs:206:14 | LL | _ => return, | ^^^^^^ @@ -447,7 +447,7 @@ LL | _ => (), | ~~ error: unneeded `return` statement - --> $DIR/needless_return.rs:219:9 + --> tests/ui/needless_return.rs:219:9 | LL | return String::from("test"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -459,7 +459,7 @@ LL + String::from("test") | error: unneeded `return` statement - --> $DIR/needless_return.rs:221:9 + --> tests/ui/needless_return.rs:221:9 | LL | return String::new(); | ^^^^^^^^^^^^^^^^^^^^ @@ -471,7 +471,7 @@ LL + String::new() | error: unneeded `return` statement - --> $DIR/needless_return.rs:237:5 + --> tests/ui/needless_return.rs:237:5 | LL | return format!("Hello {}", "world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -483,7 +483,7 @@ LL + format!("Hello {}", "world!") | error: unneeded `return` statement - --> $DIR/needless_return.rs:249:9 + --> tests/ui/needless_return.rs:249:9 | LL | return true; | ^^^^^^^^^^^ @@ -497,7 +497,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:251:9 + --> tests/ui/needless_return.rs:251:9 | LL | return false; | ^^^^^^^^^^^^ @@ -509,7 +509,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:258:13 + --> tests/ui/needless_return.rs:258:13 | LL | return 10; | ^^^^^^^^^ @@ -524,7 +524,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:261:13 + --> tests/ui/needless_return.rs:261:13 | LL | return 100; | ^^^^^^^^^^ @@ -537,7 +537,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:269:9 + --> tests/ui/needless_return.rs:269:9 | LL | return 0; | ^^^^^^^^ @@ -549,7 +549,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:276:13 + --> tests/ui/needless_return.rs:276:13 | LL | return *(x as *const isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -564,7 +564,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:278:13 + --> tests/ui/needless_return.rs:278:13 | LL | return !*(x as *const isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -577,7 +577,7 @@ LL ~ } | error: unneeded `return` statement - --> $DIR/needless_return.rs:285:20 + --> tests/ui/needless_return.rs:285:20 | LL | let _ = 42; | ____________________^ @@ -594,7 +594,7 @@ LL + let _ = 42; | error: unneeded `return` statement - --> $DIR/needless_return.rs:292:20 + --> tests/ui/needless_return.rs:292:20 | LL | let _ = 42; return; | ^^^^^^^ @@ -606,7 +606,7 @@ LL + let _ = 42; | error: unneeded `return` statement - --> $DIR/needless_return.rs:304:9 + --> tests/ui/needless_return.rs:304:9 | LL | return Ok(format!("ok!")); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -618,7 +618,7 @@ LL + Ok(format!("ok!")) | error: unneeded `return` statement - --> $DIR/needless_return.rs:306:9 + --> tests/ui/needless_return.rs:306:9 | LL | return Err(format!("err!")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -630,7 +630,7 @@ LL + Err(format!("err!")) | error: unneeded `return` statement - --> $DIR/needless_return.rs:312:9 + --> tests/ui/needless_return.rs:312:9 | LL | return if true { 1 } else { 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -642,7 +642,7 @@ LL + if true { 1 } else { 2 } | error: unneeded `return` statement - --> $DIR/needless_return.rs:316:9 + --> tests/ui/needless_return.rs:316:9 | LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 17aa212ae8d7a..76dd5f953bc67 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 @@ -1,5 +1,5 @@ error: unneeded `return` statement with `?` operator - --> $DIR/needless_return_with_question_mark.rs:29:5 + --> tests/ui/needless_return_with_question_mark.rs:29:5 | LL | return Err(())?; | ^^^^^^^ help: remove it @@ -8,7 +8,7 @@ LL | return Err(())?; = help: to override `-D warnings` add `#[allow(clippy::needless_return_with_question_mark)]` error: unneeded `return` statement with `?` operator - --> $DIR/needless_return_with_question_mark.rs:69:9 + --> tests/ui/needless_return_with_question_mark.rs:69:9 | LL | return Err(())?; | ^^^^^^^ help: remove it diff --git a/src/tools/clippy/tests/ui/needless_splitn.stderr b/src/tools/clippy/tests/ui/needless_splitn.stderr index f347ca760dbe2..ffd82c3fcb13a 100644 --- a/src/tools/clippy/tests/ui/needless_splitn.stderr +++ b/src/tools/clippy/tests/ui/needless_splitn.stderr @@ -1,5 +1,5 @@ error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:13:13 + --> tests/ui/needless_splitn.rs:13:13 | LL | let _ = str.splitn(2, '=').next(); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` @@ -8,73 +8,73 @@ LL | let _ = str.splitn(2, '=').next(); = help: to override `-D warnings` add `#[allow(clippy::needless_splitn)]` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:14:13 + --> tests/ui/needless_splitn.rs:14:13 | LL | let _ = str.splitn(2, '=').nth(0); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:17:18 + --> tests/ui/needless_splitn.rs:17:18 | LL | let (_, _) = str.splitn(3, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:20:13 + --> tests/ui/needless_splitn.rs:20:13 | LL | let _ = str.rsplitn(2, '=').next(); | ^^^^^^^^^^^^^^^^^^^ help: try: `str.rsplit('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:21:13 + --> tests/ui/needless_splitn.rs:21:13 | LL | let _ = str.rsplitn(2, '=').nth(0); | ^^^^^^^^^^^^^^^^^^^ help: try: `str.rsplit('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:24:18 + --> tests/ui/needless_splitn.rs:24:18 | LL | let (_, _) = str.rsplitn(3, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^ help: try: `str.rsplit('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:26:13 + --> tests/ui/needless_splitn.rs:26:13 | LL | let _ = str.splitn(5, '=').next(); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:27:13 + --> tests/ui/needless_splitn.rs:27:13 | LL | let _ = str.splitn(5, '=').nth(3); | ^^^^^^^^^^^^^^^^^^ help: try: `str.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:33:13 + --> tests/ui/needless_splitn.rs:33:13 | LL | let _ = s.splitn(2, '=').next()?; | ^^^^^^^^^^^^^^^^ help: try: `s.split('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:34:13 + --> tests/ui/needless_splitn.rs:34:13 | LL | let _ = s.splitn(2, '=').nth(0)?; | ^^^^^^^^^^^^^^^^ help: try: `s.split('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:35:13 + --> tests/ui/needless_splitn.rs:35:13 | LL | let _ = s.rsplitn(2, '=').next()?; | ^^^^^^^^^^^^^^^^^ help: try: `s.rsplit('=')` error: unnecessary use of `rsplitn` - --> $DIR/needless_splitn.rs:36:13 + --> tests/ui/needless_splitn.rs:36:13 | LL | let _ = s.rsplitn(2, '=').nth(0)?; | ^^^^^^^^^^^^^^^^^ help: try: `s.rsplit('=')` error: unnecessary use of `splitn` - --> $DIR/needless_splitn.rs:44:13 + --> tests/ui/needless_splitn.rs:44:13 | LL | let _ = "key=value".splitn(2, '=').nth(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split('=')` diff --git a/src/tools/clippy/tests/ui/needless_update.stderr b/src/tools/clippy/tests/ui/needless_update.stderr index 60aeb04938702..1f482f09e4143 100644 --- a/src/tools/clippy/tests/ui/needless_update.stderr +++ b/src/tools/clippy/tests/ui/needless_update.stderr @@ -1,5 +1,5 @@ error: struct update has no effect, all the fields in the struct have already been specified - --> $DIR/needless_update.rs:19:23 + --> tests/ui/needless_update.rs:19:23 | LL | S { a: 1, b: 1, ..base }; | ^^^^ 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 c64d96b4b2032..d4f7f14f59a39 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 @@ -1,5 +1,5 @@ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> $DIR/neg_cmp_op_on_partial_ord.rs:16:21 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:16:21 | LL | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | let _not_less = !(a_value < another_value); = 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 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:21:30 | LL | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> $DIR/neg_cmp_op_on_partial_ord.rs:25:24 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:25:24 | LL | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> $DIR/neg_cmp_op_on_partial_ord.rs:29:33 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:29:33 | LL | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/neg_multiply.stderr b/src/tools/clippy/tests/ui/neg_multiply.stderr index abfc94f97701f..13226c7c37b3f 100644 --- a/src/tools/clippy/tests/ui/neg_multiply.stderr +++ b/src/tools/clippy/tests/ui/neg_multiply.stderr @@ -1,5 +1,5 @@ error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:28:5 + --> tests/ui/neg_multiply.rs:28:5 | LL | x * -1; | ^^^^^^ help: consider using: `-x` @@ -8,43 +8,43 @@ LL | x * -1; = 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 + --> tests/ui/neg_multiply.rs:30:5 | LL | -1 * x; | ^^^^^^ help: consider using: `-x` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:32:11 + --> tests/ui/neg_multiply.rs:32:11 | LL | 100 + x * -1; | ^^^^^^ help: consider using: `-x` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:34:5 + --> tests/ui/neg_multiply.rs:34:5 | LL | (100 + x) * -1; | ^^^^^^^^^^^^^^ help: consider using: `-(100 + x)` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:36:5 + --> tests/ui/neg_multiply.rs:36:5 | LL | -1 * 17; | ^^^^^^^ help: consider using: `-17` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:38:14 + --> tests/ui/neg_multiply.rs:38:14 | LL | 0xcafe | 0xff00 * -1; | ^^^^^^^^^^^ help: consider using: `-0xff00` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:40:5 + --> tests/ui/neg_multiply.rs:40:5 | LL | 3_usize as i32 * -1; | ^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)` error: this multiplication by -1 can be written more succinctly - --> $DIR/neg_multiply.rs:41:5 + --> tests/ui/neg_multiply.rs:41:5 | LL | (3_usize as i32) * -1; | ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `-(3_usize as i32)` diff --git a/src/tools/clippy/tests/ui/never_loop.stderr b/src/tools/clippy/tests/ui/never_loop.stderr index 3982f36cea9f8..440a2b5aabaae 100644 --- a/src/tools/clippy/tests/ui/never_loop.stderr +++ b/src/tools/clippy/tests/ui/never_loop.stderr @@ -1,5 +1,5 @@ error: this loop never actually loops - --> $DIR/never_loop.rs:12:5 + --> tests/ui/never_loop.rs:12:5 | LL | / loop { LL | | @@ -13,7 +13,7 @@ LL | | } = note: `#[deny(clippy::never_loop)]` on by default error: this loop never actually loops - --> $DIR/never_loop.rs:36:5 + --> tests/ui/never_loop.rs:36:5 | LL | / loop { LL | | @@ -24,7 +24,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:57:5 + --> tests/ui/never_loop.rs:57:5 | LL | / loop { LL | | @@ -36,7 +36,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:60:9 + --> tests/ui/never_loop.rs:60:9 | LL | / while i == 0 { LL | | @@ -46,7 +46,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:73:9 + --> tests/ui/never_loop.rs:73:9 | LL | / loop { LL | | @@ -58,7 +58,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:110:5 + --> tests/ui/never_loop.rs:110:5 | LL | / while let Some(y) = x { LL | | @@ -68,7 +68,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:118:5 + --> tests/ui/never_loop.rs:118:5 | LL | / for x in 0..10 { LL | | @@ -85,7 +85,7 @@ LL | if let Some(x) = (0..10).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: this loop never actually loops - --> $DIR/never_loop.rs:167:5 + --> tests/ui/never_loop.rs:167:5 | LL | / 'outer: while a { LL | | @@ -97,7 +97,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:183:9 + --> tests/ui/never_loop.rs:183:9 | LL | / while false { LL | | @@ -106,7 +106,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:235:13 + --> tests/ui/never_loop.rs:235:13 | LL | let _ = loop { | _____________^ @@ -119,7 +119,7 @@ LL | | }; | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:257:5 + --> tests/ui/never_loop.rs:257:5 | LL | / 'a: loop { LL | | @@ -131,7 +131,7 @@ LL | | } | |_____^ error: sub-expression diverges - --> $DIR/never_loop.rs:261:17 + --> tests/ui/never_loop.rs:261:17 | LL | break 'a; | ^^^^^^^^ @@ -140,7 +140,7 @@ LL | break 'a; = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: this loop never actually loops - --> $DIR/never_loop.rs:294:13 + --> tests/ui/never_loop.rs:294:13 | LL | / for _ in 0..20 { LL | | @@ -154,7 +154,7 @@ LL | if let Some(_) = (0..20).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: this loop never actually loops - --> $DIR/never_loop.rs:378:13 + --> tests/ui/never_loop.rs:378:13 | LL | / 'c: loop { LL | | @@ -163,7 +163,7 @@ LL | | } | |_____________^ error: this loop never actually loops - --> $DIR/never_loop.rs:389:5 + --> tests/ui/never_loop.rs:389:5 | LL | / loop { LL | | @@ -172,7 +172,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:393:5 + --> tests/ui/never_loop.rs:393:5 | LL | / loop { LL | | 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 8436e101ff97f..d440a9f45fcdb 100644 --- a/src/tools/clippy/tests/ui/new_ret_no_self.stderr +++ b/src/tools/clippy/tests/ui/new_ret_no_self.stderr @@ -1,5 +1,5 @@ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:50:5 + --> tests/ui/new_ret_no_self.rs:50:5 | LL | / pub fn new(_: String) -> impl R { LL | | @@ -12,7 +12,7 @@ LL | | } = 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 + --> tests/ui/new_ret_no_self.rs:84:5 | LL | / pub fn new() -> u32 { LL | | @@ -21,7 +21,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:94:5 + --> tests/ui/new_ret_no_self.rs:94:5 | LL | / pub fn new(_: String) -> u32 { LL | | @@ -30,7 +30,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:131:5 + --> tests/ui/new_ret_no_self.rs:131:5 | LL | / pub fn new() -> (u32, u32) { LL | | @@ -39,7 +39,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:159:5 + --> tests/ui/new_ret_no_self.rs:159:5 | LL | / pub fn new() -> *mut V { LL | | @@ -48,7 +48,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:178:5 + --> tests/ui/new_ret_no_self.rs:178:5 | LL | / pub fn new() -> Option { LL | | @@ -57,19 +57,19 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:232:9 + --> tests/ui/new_ret_no_self.rs:232:9 | LL | fn new() -> String; | ^^^^^^^^^^^^^^^^^^^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:245:9 + --> tests/ui/new_ret_no_self.rs:245:9 | LL | fn new(_: String) -> String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:281:9 + --> tests/ui/new_ret_no_self.rs:281:9 | LL | / fn new() -> (u32, u32) { LL | | @@ -78,7 +78,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:309:9 + --> tests/ui/new_ret_no_self.rs:309:9 | LL | / fn new() -> *mut V { LL | | @@ -87,7 +87,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:380:9 + --> tests/ui/new_ret_no_self.rs:380:9 | LL | / fn new(t: T) -> impl Into { LL | | @@ -96,7 +96,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:402:9 + --> tests/ui/new_ret_no_self.rs:402:9 | LL | / fn new(t: T) -> impl Trait2<(), i32> { LL | | diff --git a/src/tools/clippy/tests/ui/new_ret_no_self_overflow.stderr b/src/tools/clippy/tests/ui/new_ret_no_self_overflow.stderr index c0d6a74a51dee..77c1b64ebc8e3 100644 --- a/src/tools/clippy/tests/ui/new_ret_no_self_overflow.stderr +++ b/src/tools/clippy/tests/ui/new_ret_no_self_overflow.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow evaluating the requirement `::Output == issue10041::X` - --> $DIR/new_ret_no_self_overflow.rs:20:25 + --> tests/ui/new_ret_no_self_overflow.rs:20:25 | LL | pub fn new() -> X { | ^ diff --git a/src/tools/clippy/tests/ui/new_without_default.fixed b/src/tools/clippy/tests/ui/new_without_default.fixed index 1c7ba1a48c90d..85408c4e17f45 100644 --- a/src/tools/clippy/tests/ui/new_without_default.fixed +++ b/src/tools/clippy/tests/ui/new_without_default.fixed @@ -132,12 +132,18 @@ impl PrivateItem { } // We don't lint private items on public structs } -struct Const; +pub struct Const; + +impl Default for Const { + fn default() -> Self { + Self::new() + } +} impl Const { pub const fn new() -> Const { Const - } // const fns can't be implemented via Default + } // While Default is not const, it can still call const functions, so we should lint this } pub struct IgnoreGenericNew; diff --git a/src/tools/clippy/tests/ui/new_without_default.rs b/src/tools/clippy/tests/ui/new_without_default.rs index 964aa0f63da8e..3ac7292c2362f 100644 --- a/src/tools/clippy/tests/ui/new_without_default.rs +++ b/src/tools/clippy/tests/ui/new_without_default.rs @@ -114,12 +114,12 @@ impl PrivateItem { } // We don't lint private items on public structs } -struct Const; +pub struct Const; impl Const { pub const fn new() -> Const { Const - } // const fns can't be implemented via Default + } // While Default is not const, it can still call const functions, so we should lint this } pub struct IgnoreGenericNew; diff --git a/src/tools/clippy/tests/ui/new_without_default.stderr b/src/tools/clippy/tests/ui/new_without_default.stderr index acba5b0d7bd5d..a30830ae7b2e9 100644 --- a/src/tools/clippy/tests/ui/new_without_default.stderr +++ b/src/tools/clippy/tests/ui/new_without_default.stderr @@ -1,5 +1,5 @@ error: you should consider adding a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:12:5 + --> tests/ui/new_without_default.rs:12:5 | LL | / pub fn new() -> Foo { LL | | @@ -20,7 +20,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Bar` - --> $DIR/new_without_default.rs:22:5 + --> tests/ui/new_without_default.rs:22:5 | LL | / pub fn new() -> Self { LL | | @@ -38,7 +38,7 @@ LL + } | error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> $DIR/new_without_default.rs:87:5 + --> tests/ui/new_without_default.rs:87:5 | LL | / pub fn new() -> LtKo<'c> { LL | | @@ -55,8 +55,25 @@ LL + } LL + } | +error: you should consider adding a `Default` implementation for `Const` + --> tests/ui/new_without_default.rs:120:5 + | +LL | / pub const fn new() -> Const { +LL | | Const +LL | | } // While Default is not const, it can still call const functions, so we should lint this + | |_____^ + | +help: try adding this + | +LL + impl Default for Const { +LL + fn default() -> Self { +LL + Self::new() +LL + } +LL + } + | + error: you should consider adding a `Default` implementation for `NewNotEqualToDerive` - --> $DIR/new_without_default.rs:180:5 + --> tests/ui/new_without_default.rs:180:5 | LL | / pub fn new() -> Self { LL | | @@ -74,7 +91,7 @@ LL + } | error: you should consider adding a `Default` implementation for `FooGenerics` - --> $DIR/new_without_default.rs:189:5 + --> tests/ui/new_without_default.rs:189:5 | LL | / pub fn new() -> Self { LL | | @@ -92,7 +109,7 @@ LL + } | error: you should consider adding a `Default` implementation for `BarGenerics` - --> $DIR/new_without_default.rs:197:5 + --> tests/ui/new_without_default.rs:197:5 | LL | / pub fn new() -> Self { LL | | @@ -110,7 +127,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:209:9 + --> tests/ui/new_without_default.rs:209:9 | LL | / pub fn new() -> Self { LL | | @@ -130,7 +147,7 @@ LL ~ impl Foo { | error: you should consider adding a `Default` implementation for `MyStruct` - --> $DIR/new_without_default.rs:255:5 + --> tests/ui/new_without_default.rs:255:5 | LL | / pub fn new() -> Self { LL | | Self { _kv: None } @@ -149,5 +166,5 @@ LL + } LL + } | -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors diff --git a/src/tools/clippy/tests/ui/no_effect.stderr b/src/tools/clippy/tests/ui/no_effect.stderr index 8140ba1feee9c..c7c8eecd054bc 100644 --- a/src/tools/clippy/tests/ui/no_effect.stderr +++ b/src/tools/clippy/tests/ui/no_effect.stderr @@ -1,5 +1,5 @@ error: statement with no effect - --> $DIR/no_effect.rs:122:5 + --> tests/ui/no_effect.rs:122:5 | LL | 0; | ^^ @@ -8,151 +8,151 @@ LL | 0; = help: to override `-D warnings` add `#[allow(clippy::no_effect)]` error: statement with no effect - --> $DIR/no_effect.rs:125:5 + --> tests/ui/no_effect.rs:125:5 | LL | s2; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:127:5 + --> tests/ui/no_effect.rs:127:5 | LL | Unit; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:129:5 + --> tests/ui/no_effect.rs:129:5 | LL | Tuple(0); | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:131:5 + --> tests/ui/no_effect.rs:131:5 | LL | Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:133:5 + --> tests/ui/no_effect.rs:133:5 | LL | Struct { ..s }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:135:5 + --> tests/ui/no_effect.rs:135:5 | LL | Union { a: 0 }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:137:5 + --> tests/ui/no_effect.rs:137:5 | LL | Enum::Tuple(0); | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:139:5 + --> tests/ui/no_effect.rs:139:5 | LL | Enum::Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:141:5 + --> tests/ui/no_effect.rs:141:5 | LL | 5 + 6; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:143:5 + --> tests/ui/no_effect.rs:143:5 | LL | *&42; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:145:5 + --> tests/ui/no_effect.rs:145:5 | LL | &6; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:147:5 + --> tests/ui/no_effect.rs:147:5 | LL | (5, 6, 7); | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:149:5 + --> tests/ui/no_effect.rs:149:5 | LL | ..; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:151:5 + --> tests/ui/no_effect.rs:151:5 | LL | 5..; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:153:5 + --> tests/ui/no_effect.rs:153:5 | LL | ..5; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:155:5 + --> tests/ui/no_effect.rs:155:5 | LL | 5..6; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:157:5 + --> tests/ui/no_effect.rs:157:5 | LL | 5..=6; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:159:5 + --> tests/ui/no_effect.rs:159:5 | LL | [42, 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:161:5 + --> tests/ui/no_effect.rs:161:5 | LL | [42, 55][1]; | ^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:163:5 + --> tests/ui/no_effect.rs:163:5 | LL | (42, 55).1; | ^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:165:5 + --> tests/ui/no_effect.rs:165:5 | LL | [42; 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:167:5 + --> tests/ui/no_effect.rs:167:5 | LL | [42; 55][13]; | ^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:170:5 + --> tests/ui/no_effect.rs:170:5 | LL | || x += 5; | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:173:5 + --> tests/ui/no_effect.rs:173:5 | LL | FooString { s: s }; | ^^^^^^^^^^^^^^^^^^^ error: binding to `_` prefixed variable with no side-effect - --> $DIR/no_effect.rs:175:9 + --> tests/ui/no_effect.rs:175:9 | LL | let _unused = 1; | ^^^^^^^ @@ -161,19 +161,19 @@ LL | let _unused = 1; = 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:178:9 + --> tests/ui/no_effect.rs:178:9 | LL | let _penguin = || println!("Some helpful closure"); | ^^^^^^^^ error: binding to `_` prefixed variable with no side-effect - --> $DIR/no_effect.rs:180:9 + --> tests/ui/no_effect.rs:180:9 | LL | let _duck = Struct { field: 0 }; | ^^^^^ error: binding to `_` prefixed variable with no side-effect - --> $DIR/no_effect.rs:182:9 + --> tests/ui/no_effect.rs:182:9 | LL | let _cat = [2, 4, 6, 8][2]; | ^^^^ diff --git a/src/tools/clippy/tests/ui/no_effect_async_fn.rs b/src/tools/clippy/tests/ui/no_effect_async_fn.rs new file mode 100644 index 0000000000000..ef0f3d1df1acc --- /dev/null +++ b/src/tools/clippy/tests/ui/no_effect_async_fn.rs @@ -0,0 +1,50 @@ +#![warn(clippy::no_effect_underscore_binding)] +#![no_main] + +trait AsyncTrait { + async fn bar(i: u64); +} + +struct Bar; + +impl AsyncTrait for Bar { + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + async fn bar(_i: u64) { + let _a = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _b = num(); + + let _ = async { + let _c = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _d = num(); + } + .await; + } +} + +// Shouldn't lint `binding to `_` prefixed variable with no side-effect` +async fn foo(_i: u64) { + let _a = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _b = num(); + + let _ = async { + let _c = 0; + //~^ ERROR: binding to `_` prefixed variable with no side-effect + + // Shouldn't lint `binding to `_` prefixed variable with no side-effect` + let _d = num(); + } + .await; +} + +fn num() -> usize { + 0 +} diff --git a/src/tools/clippy/tests/ui/no_effect_async_fn.stderr b/src/tools/clippy/tests/ui/no_effect_async_fn.stderr new file mode 100644 index 0000000000000..2325eb9aae592 --- /dev/null +++ b/src/tools/clippy/tests/ui/no_effect_async_fn.stderr @@ -0,0 +1,29 @@ +error: binding to `_` prefixed variable with no side-effect + --> tests/ui/no_effect_async_fn.rs:20:17 + | +LL | let _c = 0; + | ^^ + | + = 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 + --> tests/ui/no_effect_async_fn.rs:13:13 + | +LL | let _a = 0; + | ^^ + +error: binding to `_` prefixed variable with no side-effect + --> tests/ui/no_effect_async_fn.rs:39:13 + | +LL | let _c = 0; + | ^^ + +error: binding to `_` prefixed variable with no side-effect + --> tests/ui/no_effect_async_fn.rs:32:9 + | +LL | let _a = 0; + | ^^ + +error: aborting due to 4 previous errors + diff --git a/src/tools/clippy/tests/ui/no_effect_replace.stderr b/src/tools/clippy/tests/ui/no_effect_replace.stderr index e1162f04f8571..ded86c5c5b8d2 100644 --- a/src/tools/clippy/tests/ui/no_effect_replace.stderr +++ b/src/tools/clippy/tests/ui/no_effect_replace.stderr @@ -1,5 +1,5 @@ error: replacing text with itself - --> $DIR/no_effect_replace.rs:4:13 + --> tests/ui/no_effect_replace.rs:4:13 | LL | let _ = "12345".replace('1', "1"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,43 +8,43 @@ LL | let _ = "12345".replace('1', "1"); = help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]` error: replacing text with itself - --> $DIR/no_effect_replace.rs:7:13 + --> tests/ui/no_effect_replace.rs:7:13 | LL | let _ = "12345".replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:9:13 + --> tests/ui/no_effect_replace.rs:9:13 | LL | let _ = String::new().replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:12:13 + --> tests/ui/no_effect_replace.rs:12:13 | LL | let _ = "12345".replacen('1', "1", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:14:13 + --> tests/ui/no_effect_replace.rs:14:13 | LL | let _ = "12345".replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:16:13 + --> tests/ui/no_effect_replace.rs:16:13 | LL | let _ = String::new().replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:23:13 + --> tests/ui/no_effect_replace.rs:23:13 | LL | let _ = "hello".replace(&x.f(), &x.f()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> $DIR/no_effect_replace.rs:27:13 + --> tests/ui/no_effect_replace.rs:27:13 | LL | let _ = "hello".replace(&y(), &y()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/no_effect_return.stderr b/src/tools/clippy/tests/ui/no_effect_return.stderr index aed079f09b986..3cfe375d034ad 100644 --- a/src/tools/clippy/tests/ui/no_effect_return.stderr +++ b/src/tools/clippy/tests/ui/no_effect_return.stderr @@ -1,5 +1,5 @@ error: statement with no effect - --> $DIR/no_effect_return.rs:9:9 + --> tests/ui/no_effect_return.rs:9:9 | LL | 0u32; | -^^^^ @@ -10,7 +10,7 @@ LL | 0u32; = help: to override `-D warnings` add `#[allow(clippy::no_effect)]` error: statement with no effect - --> $DIR/no_effect_return.rs:18:9 + --> tests/ui/no_effect_return.rs:18:9 | LL | 0u32; | -^^^^ @@ -18,7 +18,7 @@ LL | 0u32; | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:27:9 + --> tests/ui/no_effect_return.rs:27:9 | LL | 0i32 as C; | -^^^^^^^^^ @@ -26,19 +26,19 @@ LL | 0i32 as C; | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:36:9 + --> tests/ui/no_effect_return.rs:36:9 | LL | 0u128; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect_return.rs:46:9 + --> tests/ui/no_effect_return.rs:46:9 | LL | 0u16; | ^^^^^ error: statement with no effect - --> $DIR/no_effect_return.rs:54:9 + --> tests/ui/no_effect_return.rs:54:9 | LL | [1u16]; | -^^^^^^ @@ -46,7 +46,7 @@ LL | [1u16]; | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:62:9 + --> tests/ui/no_effect_return.rs:62:9 | LL | ControlFlow::Break::<()>(()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | ControlFlow::Break::<()>(()); | help: did you mean to return it?: `return` error: statement with no effect - --> $DIR/no_effect_return.rs:80:9 + --> tests/ui/no_effect_return.rs:80:9 | LL | (); | ^^^ error: statement with no effect - --> $DIR/no_effect_return.rs:89:9 + --> tests/ui/no_effect_return.rs:89:9 | LL | (); | ^^^ 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 62d53c8395fd9..27b8b39a21a22 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 @@ -1,5 +1,5 @@ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:6:1 + --> tests/ui/no_mangle_with_rust_abi.rs:6:1 | LL | fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | extern "Rust" fn rust_abi_fn_one(arg_one: u32, arg_two: usize) {} | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:11:1 + --> tests/ui/no_mangle_with_rust_abi.rs:11:1 | LL | pub fn rust_abi_fn_two(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | pub extern "Rust" fn rust_abi_fn_two(arg_one: u32, arg_two: usize) {} | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:17:1 + --> tests/ui/no_mangle_with_rust_abi.rs:17:1 | LL | pub unsafe fn rust_abi_fn_three(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | pub unsafe extern "Rust" fn rust_abi_fn_three(arg_one: u32, arg_two: usize) | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:23:1 + --> tests/ui/no_mangle_with_rust_abi.rs:23:1 | LL | unsafe fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | unsafe extern "Rust" fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {} | +++++++++++++ error: `#[no_mangle]` set on a function with the default (`Rust`) ABI - --> $DIR/no_mangle_with_rust_abi.rs:27:1 + --> tests/ui/no_mangle_with_rust_abi.rs:27:1 | LL | / fn rust_abi_multiline_function_really_long_name_to_overflow_args_to_multiple_lines( LL | | diff --git a/src/tools/clippy/tests/ui/non_canonical_clone_impl.stderr b/src/tools/clippy/tests/ui/non_canonical_clone_impl.stderr index 44196751b053b..8eff322fa2d74 100644 --- a/src/tools/clippy/tests/ui/non_canonical_clone_impl.stderr +++ b/src/tools/clippy/tests/ui/non_canonical_clone_impl.stderr @@ -1,5 +1,5 @@ error: non-canonical implementation of `clone` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:9:29 + --> tests/ui/non_canonical_clone_impl.rs:9:29 | LL | fn clone(&self) -> Self { | _____________________________^ @@ -11,7 +11,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::non_canonical_clone_impl)]` error: unnecessary implementation of `clone_from` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:13:5 + --> tests/ui/non_canonical_clone_impl.rs:13:5 | LL | / fn clone_from(&mut self, source: &Self) { LL | | source.clone(); @@ -20,7 +20,7 @@ LL | | } | |_____^ help: remove it error: non-canonical implementation of `clone` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:80:29 + --> tests/ui/non_canonical_clone_impl.rs:80:29 | LL | fn clone(&self) -> Self { | _____________________________^ @@ -29,7 +29,7 @@ LL | | } | |_____^ help: change this to: `{ *self }` error: unnecessary implementation of `clone_from` on a `Copy` type - --> $DIR/non_canonical_clone_impl.rs:84:5 + --> tests/ui/non_canonical_clone_impl.rs:84:5 | LL | / fn clone_from(&mut self, source: &Self) { LL | | source.clone(); diff --git a/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl.stderr b/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl.stderr index 05cc717b9ba1d..a15379c5b1a5e 100644 --- a/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl.stderr +++ b/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl.stderr @@ -1,5 +1,5 @@ error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl.rs:16:1 + --> tests/ui/non_canonical_partial_ord_impl.rs:16:1 | LL | / impl PartialOrd for A { LL | | fn partial_cmp(&self, other: &Self) -> Option { @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::non_canonical_partial_ord_impl)]` error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl.rs:50:1 + --> tests/ui/non_canonical_partial_ord_impl.rs:50:1 | LL | / impl PartialOrd for C { LL | | fn partial_cmp(&self, _: &Self) -> Option { diff --git a/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr b/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr index 4978d7a873960..8dd7face6ef4e 100644 --- a/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr +++ b/src/tools/clippy/tests/ui/non_canonical_partial_ord_impl_fully_qual.stderr @@ -1,5 +1,5 @@ error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl_fully_qual.rs:23:1 + --> tests/ui/non_canonical_partial_ord_impl_fully_qual.rs:23:1 | LL | / impl PartialOrd for A { LL | | fn partial_cmp(&self, other: &Self) -> Option { @@ -16,7 +16,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::non_canonical_partial_ord_impl)]` error: non-canonical implementation of `partial_cmp` on an `Ord` type - --> $DIR/non_canonical_partial_ord_impl_fully_qual.rs:46:1 + --> tests/ui/non_canonical_partial_ord_impl_fully_qual.rs:46:1 | LL | / impl PartialOrd for B { LL | | fn partial_cmp(&self, other: &Self) -> Option { diff --git a/src/tools/clippy/tests/ui/non_expressive_names.stderr b/src/tools/clippy/tests/ui/non_expressive_names.stderr index 1b78124a90318..d9c745f466b7b 100644 --- a/src/tools/clippy/tests/ui/non_expressive_names.stderr +++ b/src/tools/clippy/tests/ui/non_expressive_names.stderr @@ -1,5 +1,5 @@ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:28:9 + --> tests/ui/non_expressive_names.rs:28:9 | LL | let _1 = 1; | ^^ @@ -8,31 +8,31 @@ LL | let _1 = 1; = 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 + --> tests/ui/non_expressive_names.rs:29:9 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:30:9 + --> tests/ui/non_expressive_names.rs:30:9 | LL | let __1___2 = 12; | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:51:13 + --> tests/ui/non_expressive_names.rs:51:13 | LL | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:52:13 + --> tests/ui/non_expressive_names.rs:52:13 | LL | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:53:13 + --> tests/ui/non_expressive_names.rs:53:13 | LL | let __1___2 = 12; | ^^^^^^^ diff --git a/src/tools/clippy/tests/ui/non_minimal_cfg.stderr b/src/tools/clippy/tests/ui/non_minimal_cfg.stderr index c33c35ed8df94..707ff51d430c9 100644 --- a/src/tools/clippy/tests/ui/non_minimal_cfg.stderr +++ b/src/tools/clippy/tests/ui/non_minimal_cfg.stderr @@ -1,5 +1,5 @@ error: unneeded sub `cfg` when there is only one condition - --> $DIR/non_minimal_cfg.rs:3:7 + --> tests/ui/non_minimal_cfg.rs:3:7 | LL | #[cfg(all(windows))] | ^^^^^^^^^^^^ help: try: `windows` @@ -8,19 +8,19 @@ LL | #[cfg(all(windows))] = 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 + --> tests/ui/non_minimal_cfg.rs:6:7 | LL | #[cfg(any(windows))] | ^^^^^^^^^^^^ help: try: `windows` error: unneeded sub `cfg` when there is only one condition - --> $DIR/non_minimal_cfg.rs:9:11 + --> tests/ui/non_minimal_cfg.rs:9:11 | LL | #[cfg(all(any(unix), all(not(windows))))] | ^^^^^^^^^ help: try: `unix` error: unneeded sub `cfg` when there is only one condition - --> $DIR/non_minimal_cfg.rs:9:22 + --> tests/ui/non_minimal_cfg.rs:9:22 | LL | #[cfg(all(any(unix), all(not(windows))))] | ^^^^^^^^^^^^^^^^^ help: try: `not(windows)` diff --git a/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr b/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr index 036d38c22f48d..6d86e931edce9 100644 --- a/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr +++ b/src/tools/clippy/tests/ui/non_minimal_cfg2.stderr @@ -1,5 +1,5 @@ error: unneeded sub `cfg` when there is no condition - --> $DIR/non_minimal_cfg2.rs:3:7 + --> tests/ui/non_minimal_cfg2.rs:3:7 | LL | #[cfg(all())] | ^^^^^ 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 83688c1b4517c..890b308a1dc56 100644 --- a/src/tools/clippy/tests/ui/non_octal_unix_permissions.stderr +++ b/src/tools/clippy/tests/ui/non_octal_unix_permissions.stderr @@ -1,5 +1,5 @@ error: using a non-octal value to set unix file permissions - --> $DIR/non_octal_unix_permissions.rs:12:18 + --> tests/ui/non_octal_unix_permissions.rs:12:18 | LL | options.mode(440); | ^^^ help: consider using an octal literal instead: `0o440` @@ -8,19 +8,19 @@ LL | options.mode(440); = 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 + --> tests/ui/non_octal_unix_permissions.rs:17:47 | LL | let _permissions = Permissions::from_mode(647); | ^^^ help: consider using an octal literal instead: `0o647` error: using a non-octal value to set unix file permissions - --> $DIR/non_octal_unix_permissions.rs:26:26 + --> tests/ui/non_octal_unix_permissions.rs:26:26 | LL | permissions.set_mode(644); | ^^^ help: consider using an octal literal instead: `0o644` error: using a non-octal value to set unix file permissions - --> $DIR/non_octal_unix_permissions.rs:33:18 + --> tests/ui/non_octal_unix_permissions.rs:33:18 | LL | builder.mode(755); | ^^^ help: consider using an octal literal instead: `0o755` 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 99fd4ea60b608..f415add0a94e2 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 @@ -1,11 +1,11 @@ error: some fields in `RingBuffer` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:16:1 + --> tests/ui/non_send_fields_in_send_ty.rs:16:1 | LL | unsafe impl Send for RingBuffer {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `data` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:11:5 + --> tests/ui/non_send_fields_in_send_ty.rs:11:5 | LL | data: Vec>, | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,155 +14,155 @@ LL | data: Vec>, = 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:25:1 + --> tests/ui/non_send_fields_in_send_ty.rs:25:1 | LL | unsafe impl Send for MvccRwLock {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `lock` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:22:5 + --> tests/ui/non_send_fields_in_send_ty.rs:22:5 | LL | lock: Mutex>, | ^^^^^^^^^^^^^^^^^^^ = help: add bounds on type parameter `T` that satisfy `Mutex>: Send` error: some fields in `ArcGuard` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:34:1 + --> tests/ui/non_send_fields_in_send_ty.rs:34:1 | LL | unsafe impl Send for ArcGuard {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `head` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:31:5 + --> tests/ui/non_send_fields_in_send_ty.rs:31:5 | LL | head: Arc, | ^^^^^^^^^^^^^ = help: add bounds on type parameter `RC` that satisfy `Arc: Send` error: some fields in `DeviceHandle` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:51:1 + --> tests/ui/non_send_fields_in_send_ty.rs:51:1 | LL | unsafe impl Send for DeviceHandle {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `context` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:47:5 + --> tests/ui/non_send_fields_in_send_ty.rs:47:5 | LL | context: T, | ^^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `NoGeneric` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:59:1 + --> tests/ui/non_send_fields_in_send_ty.rs:59:1 | LL | unsafe impl Send for NoGeneric {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `rc_is_not_send` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:56:5 + --> tests/ui/non_send_fields_in_send_ty.rs:56:5 | LL | rc_is_not_send: Rc, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: some fields in `MultiField` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:68:1 + --> tests/ui/non_send_fields_in_send_ty.rs:68:1 | LL | unsafe impl Send for MultiField {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field1` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:63:5 + --> tests/ui/non_send_fields_in_send_ty.rs:63:5 | LL | field1: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field2` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:64:5 + --> tests/ui/non_send_fields_in_send_ty.rs:64:5 | LL | field2: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl note: it is not safe to send field `field3` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:65:5 + --> tests/ui/non_send_fields_in_send_ty.rs:65:5 | LL | field3: T, | ^^^^^^^^^ = help: add `T: Send` bound in `Send` impl error: some fields in `MyOption` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:76:1 + --> tests/ui/non_send_fields_in_send_ty.rs:76:1 | LL | unsafe impl Send for MyOption {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:72:12 + --> tests/ui/non_send_fields_in_send_ty.rs:72:12 | LL | MySome(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `MultiParam` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:89:1 + --> tests/ui/non_send_fields_in_send_ty.rs:89:1 | LL | unsafe impl Send for MultiParam {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `vec` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:86:5 + --> tests/ui/non_send_fields_in_send_ty.rs:86:5 | LL | vec: Vec<(A, B)>, | ^^^^^^^^^^^^^^^^ = help: add bounds on type parameters `A, B` that satisfy `Vec<(A, B)>: Send` error: some fields in `HeuristicTest` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:108:1 + --> tests/ui/non_send_fields_in_send_ty.rs:108:1 | LL | unsafe impl Send for HeuristicTest {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `field4` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:103:5 + --> tests/ui/non_send_fields_in_send_ty.rs:103:5 | LL | field4: (*const NonSend, Rc), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use a thread-safe type that implements `Send` error: some fields in `AttrTest3` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:128:1 + --> tests/ui/non_send_fields_in_send_ty.rs:128:1 | LL | unsafe impl Send for AttrTest3 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: it is not safe to send field `0` to another thread - --> $DIR/non_send_fields_in_send_ty.rs:123:11 + --> tests/ui/non_send_fields_in_send_ty.rs:123:11 | LL | Enum2(T), | ^ = help: add `T: Send` bound in `Send` impl error: some fields in `Complex` are not safe to be sent to another thread - --> $DIR/non_send_fields_in_send_ty.rs:137:1 + --> tests/ui/non_send_fields_in_send_ty.rs:137:1 | LL | unsafe impl