about summary refs log tree commit diff
path: root/src/tools/clippy/tests
AgeCommit message (Collapse)AuthorLines
2025-03-30Drop `clippy::invalid_null_ptr_usage`Urgau-575/+21
2025-03-20Merge commit '1e5237f4a56ae958af7e5824343eacf737b67083' into ↵Philipp Krones-503/+3105
clippy-subtree-update
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-16/+0
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-11/+5
2025-02-28Clippy: skip check_host_compiler check in rustc testsuitePhilipp Krones-0/+5
This test only makes sense to run in the Clippy repo In the Rust repo the name of the host_compiler is dev, not nightly
2025-02-28Merge commit '9f9a822509e5ad3e560cbbe830d1013f936fca28' into ↵Philipp Krones-14004/+31921
clippy-subtree-update
2025-02-24simplify must-use lint slightlyJana Dönszelmann-29/+40
2025-02-24Fix rustdoc and clippyJana Dönszelmann-13/+15
2025-02-21Trim suggestion part before generating highlightsMichael Goulet-24/+20
2025-02-21More sophisticated span trimmingMichael Goulet-121/+80
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-4/+4
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-29/+18
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-1500/+2292
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-07add tests for spurious failure and fix typoJana Dönszelmann-21/+49
2025-02-07fix empty after lint on impl/trait itemsJonathan Dönszelmann-1/+40
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2025-02-07Update UI testsGuillaume Gomez-24/+26
2025-02-06Merge commit '3e3715c31236bff56f1c63a1de2c7bbdfcfb0923' into ↵Philipp Krones-249/+1527
clippy-subtree-update
2025-01-28Merge commit '51d49c1ae2785b24ef18a46ef233fc1d91844666' into ↵Philipp Krones-364/+4048
clippy-subtree-update
2025-01-26remove `clippy::double_neg`Kalle Wachsmuth-95/+82
2025-01-21Auto merge of #134299 - RalfJung:remove-start, r=compiler-errorsbors-185/+37
remove support for the (unstable) #[start] attribute As explained by `@Noratrieb:` `#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction. I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple: - `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail) - `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways* `#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program. So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place. Note that this feature has **not** been RFCed in the first place. *This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.* Closes https://github.com/rust-lang/rust/issues/29633 try-job: x86_64-gnu-nopt try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: test-various
2025-01-21remove support for the #[start] attributeRalf Jung-185/+37
2025-01-15Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, ↵Guillaume Gomez-31/+31
r=davidtwco deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead The `rustc_allowed_through_unstable_modules` attribute lets users call `std::mem::transmute` as `std::intrinsics::transmute`. The former is a reexport of the latter, and for a long time we didn't properly check stability for reexports, so making this a hard error now would be a breaking change for little gain. But at the same time, `std::intrinsics::transmute` is not the intended path for this function, so I think it is a good idea to show a deprecation warning when that path is used. This PR implements that, for all the functions in `std::intrinsics` that carry the attribute. I assume this will need ``@rust-lang/libs-api`` FCP.
2025-01-15Rollup merge of #132397 - m-ou-se:warn-missing-abi, r=NadrierilJacob Pratt-12/+15
Make missing_abi lint warn-by-default. This makes the missing_abi lint warn-by-default, as suggested here: https://github.com/rust-lang/rfcs/pull/3722#issuecomment-2447719047 This needs a lang FCP.
2025-01-15intrinsics: deprecate calling them via the unstable std::intrinsics pathRalf Jung-31/+31
2025-01-09Merge commit '19e305bb57a7595f2a8d81f521c0dd8bf854e739' into ↵Philipp Krones-190/+1291
clippy-subtree-update
2025-01-08Rename PatKind::Lit to ExprOli Scherer-6/+6
2025-01-08Exhaustively handle expressions in patternsOli Scherer-6/+6
2025-01-07Update tests.Mara Bos-12/+15
2025-01-03turn rustc_box into an intrinsicRalf Jung-9/+8
2024-12-26Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into ↵Philipp Krones-794/+4578
clippy-subtree-update
2024-12-15Auto merge of #134258 - bjorn3:no_public_specialization, r=petrochenkovbors-56/+1
Remove support for specializing ToString outside the standard library This is the only trait specializable outside of the standard library. Before stabilizing specialization we will probably want to remove support for this. It was originally made specializable to allow a more efficient ToString in libproc_macro back when this way the only way to get any data out of a TokenStream. We now support getting individual tokens, so proc macros no longer need to call it as often.
2024-12-14Stop handling specialization in clippy's to_string_trait_impl lintbjorn3-56/+1
ToString can no longer be specialized, so no need to account for it in to_string_trait_impl either.
2024-12-14Rollup merge of #134181 - estebank:trim-render, r=oli-obkMatthias Krüger-155/+32
Tweak multispan rendering to reduce output length Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments. We do that check not only on the first 4 lines of the multispan, but now also on the previous to last line as well.
2024-12-13Account for `///` when rendering multiline spansEsteban Küber-10/+31
Don't consider `///` and `//!` docstrings to be empty for the purposes of multiline span rendering.
2024-12-13Stabilize async closuresMichael Goulet-51/+45
2024-12-12Filter empty lines, comments and delimiters from previous to last multiline ↵Esteban Küber-69/+4
span rendering
2024-12-12Tweak multispan renderingEsteban Küber-117/+38
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
2024-12-02Drop uplifted `clippy::fn_address_comparisons`Urgau-107/+77
2024-12-01Rollup merge of #133589 - voidc:remove-array-len, r=boxyuwuJacob Pratt-2/+1
Remove `hir::ArrayLen` This refactoring removes `hir::ArrayLen`, replacing it with `hir::ConstArg`. To represent inferred array lengths (previously `hir::ArrayLen::Infer`), a new variant `ConstArgKind::Infer` is added. r? `@BoxyUwU`
2024-11-30Remove hir::ArrayLen, introduce ConstArgKind::InferDominik Stolz-2/+1
Remove Node::ArrayLenInfer
2024-11-28Merge commit 'ff4a26d442bead94a4c96fb1de967374bc4fbd8e' into ↵Philipp Krones-193/+1030
clippy-subtree-update
2024-11-14Merge commit '786fbd6d683933cd0e567fdcd25d449a69b4320c' into ↵Philipp Krones-33/+599
clippy-subtree-update
2024-11-11Auto merge of #126597 - estebank:unicode-output, r=fmeasebors-28/+28
Add Unicode block-drawing compiler output support Add nightly-only theming support to rustc output using Unicode box drawing characters instead of ASCII-art to draw the terminal UI. In order to enable, the flags `-Zunstable-options=yes --error-format=human-unicode` must be passed in. After: ``` error: foo ╭▸ test.rs:3:3 │ 3 │ X0 Y0 Z0 │ ┌───╿──│──┘ │ ┌│───│──┘ │ ┏││━━━┙ │ ┃││ 4 │ ┃││ X1 Y1 Z1 5 │ ┃││ X2 Y2 Z2 │ ┃│└────╿──│──┘ `Z` label │ ┃└─────│──┤ │ ┗━━━━━━┥ `Y` is a good letter too │ `X` is a good letter ╰╴ note: bar ╭▸ test.rs:4:3 │ 4 │ ┏ X1 Y1 Z1 5 │ ┃ X2 Y2 Z2 6 │ ┃ X3 Y3 Z3 │ ┗━━━━━━━━━━┛ ├ note: bar ╰ note: baz note: qux ╭▸ test.rs:4:3 │ 4 │ X1 Y1 Z1 ╰╴ ━━━━━━━━ ``` Before: ``` error: foo --> test.rs:3:3 | 3 | X0 Y0 Z0 | ___^__-__- | |___|__| | ||___| | ||| 4 | ||| X1 Y1 Z1 5 | ||| X2 Y2 Z2 | |||____^__-__- `Z` label | ||_____|__| | |______| `Y` is a good letter too | `X` is a good letter | note: bar --> test.rs:4:3 | 4 | / X1 Y1 Z1 5 | | X2 Y2 Z2 6 | | X3 Y3 Z3 | |__________^ = note: bar = note: baz note: qux --> test.rs:4:3 | 4 | X1 Y1 Z1 | ^^^^^^^^ ``` After: ![rustc output with unicode box drawing characters](https://github.com/rust-lang/rust/assets/1606434/d210b79a-6579-4407-9706-ba8edc6e9f25) Before: ![current rustc output with ASCII art](https://github.com/rust-lang/rust/assets/1606434/5aecccf8-a6ee-4469-8b39-72fb0d979a9f)
2024-11-10Add Unicode block-drawing compiler output supportEsteban Küber-28/+28
Add nightly-only theming support to rustc output using Unicode box drawing characters instead of ASCII-art to draw the terminal UI: After: ``` error: foo ╭▸ test.rs:3:3 │ 3 │ X0 Y0 Z0 │ ┌───╿──│──┘ │ ┌│───│──┘ │ ┏││━━━┙ │ ┃││ 4 │ ┃││ X1 Y1 Z1 5 │ ┃││ X2 Y2 Z2 │ ┃│└────╿──│──┘ `Z` label │ ┃└─────│──┤ │ ┗━━━━━━┥ `Y` is a good letter too │ `X` is a good letter ╰╴ note: bar ╭▸ test.rs:4:3 │ 4 │ ┏ X1 Y1 Z1 5 │ ┃ X2 Y2 Z2 6 │ ┃ X3 Y3 Z3 │ ┗━━━━━━━━━━┛ ├ note: bar ╰ note: baz note: qux ╭▸ test.rs:4:3 │ 4 │ X1 Y1 Z1 ╰╴ ━━━━━━━━ ``` Before: ``` error: foo --> test.rs:3:3 | 3 | X0 Y0 Z0 | ___^__-__- | |___|__| | ||___| | ||| 4 | ||| X1 Y1 Z1 5 | ||| X2 Y2 Z2 | |||____^__-__- `Z` label | ||_____|__| | |______| `Y` is a good letter too | `X` is a good letter | note: bar --> test.rs:4:3 | 4 | / X1 Y1 Z1 5 | | X2 Y2 Z2 6 | | X3 Y3 Z3 | |__________^ = note: bar = note: baz note: qux --> test.rs:4:3 | 4 | X1 Y1 Z1 | ^^^^^^^^ ```
2024-11-07Merge commit 'f712eb5cdccd121d0569af12f20e6a0fabe4364d' into ↵Philipp Krones-245/+2773
clippy-subtree-update
2024-11-04Move two attribute lints to be early pass (post expansion)Jonathan Dönszelmann-35/+18
2024-11-03Rename the FIXMEs, remove a few that dont matter anymoreMichael Goulet-4/+4
2024-10-30Remap impl-trait lifetimes on HIR instead of AST lowering.Camille GILLOT-1/+1
2024-10-29Auto merge of #128985 - GrigorenkoPV:instantly-dangling-pointer, r=Urgaubors-8/+14
Lint against getting pointers from immediately dropped temporaries Fixes #123613 ## Changes: 1. New lint: `dangling_pointers_from_temporaries`. Is a generalization of `temporary_cstring_as_ptr` for more types and more ways to get a temporary. 2. `temporary_cstring_as_ptr` is removed and marked as renamed to `dangling_pointers_from_temporaries`. 3. `clippy::temporary_cstring_as_ptr` is marked as renamed to `dangling_pointers_from_temporaries`. 4. Fixed a false positive[^fp] for when the pointer is not actually dangling because of lifetime extension for function/method call arguments. 5. `core::cell::Cell` is now `rustc_diagnostic_item = "Cell"` ## Questions: - [ ] Instead of manually checking for a list of known methods and diagnostic items, maybe add some sort of annotation to those methods in library and check for the presence of that annotation? https://github.com/rust-lang/rust/pull/128985#issuecomment-2318714312 ## Known limitations: ### False negatives[^fn]: See the comments in `compiler/rustc_lint/src/dangling.rs` 1. Method calls that are not checked for: - `temporary_unsafe_cell.get()` - `temporary_sync_unsafe_cell.get()` 2. Ways to get a temporary that are not recognized: - `owning_temporary.field` - `owning_temporary[index]` 3. No checks for ref-to-ptr conversions: - `&raw [mut] temporary` - `&temporary as *(const|mut) _` - `ptr::from_ref(&temporary)` and friends [^fn]: lint **should** be emitted, but **is not** [^fp]: lint **should not** be emitted, but **is**
2024-10-28New lint: `dangling_pointers_from_temporaries`Pavel Grigorenko-8/+14