Commit graph

994 commits

Author SHA1 Message Date
Urgau
249d399caa Don't lint on interior mutable const item coming from derefs
(cherry picked from commit 2581c2571c)
2026-01-08 16:09:05 -08:00
Urgau
0aa11b5dd2 Add regression test for const_item_interior_mutations deref FP
(cherry picked from commit 0bc29cec45)
2026-01-08 16:09:05 -08:00
Matthias Krüger
5c9a4eed87
Rollup merge of #149544 - reddevilmidzy:where, r=fmease
Only apply `no_mangle_const_items`'s suggestion to plain const items

resolve: rust-lang/rust#149511
2025-12-04 09:22:11 +01:00
reddevilmidzy
2951d72219 Simplify and robustly compute suggestion span using
`vis_span.to(ident.span.shrink_to_lo())`
2025-12-04 11:01:40 +09:00
reddevilmidzy
6ce0f0ff91 Only apply no_mangle_const_items's suggestion to plain const items 2025-12-04 11:01:10 +09:00
Matthias Krüger
a2aa4f08da
Rollup merge of #149541 - WaffleLapkin:never-test, r=lcnr
Various never type test improvements

I want to make sure that the never type ui tests are actually sensible, and to do so I'm trying to clean them up. This mainly adds comments explaining test purposes and removes outdated stuff.

I imagine best reviewed commit-by-commit, I tried to write useful descriptions and group things into small commits.

cc `@lcnr` (I removed `fallback`/`nofallback` terminology in b5f82d4716d0d978b89034c902f88e2d449da636)
2025-12-03 13:05:15 +01:00
Matthias Krüger
02434fe718
Rollup merge of #148678 - xonx4l:EO412_replacement_with_EO425, r=Kivooeo
Merge E0412 into E0425

This PR merge E0412 into E0425  as both mean the same thing to users.

This fixes https://github.com/rust-lang/rust/issues/148558.
2025-12-02 22:02:30 +01:00
xonx4l
4b000cfacd Merge E0412 into E0425 2025-12-02 18:25:13 +00:00
Waffle Lapkin
98430c4d9d
remove unused features from some tests 2025-12-02 11:07:42 +01:00
Scott Schafer
b2b059c20b
chore: Update annotate-snippets to 0.12.10 2025-12-01 18:12:35 -07:00
bors
e6edf3ae53 Auto merge of #147498 - ferrocene:pvdrz/edition-range-gating, r=jieyouxu,fmease
Gate tests with the right edition

This PR guarantees that `./x test --test-args="--edition XXXX" ui` runs correctly with the 2015, 2018 and 2021 editions.

I don't expect this PR to hold up over time but it helps to submit further updates to the `//@ edition` directives of tests where we can use the new range syntax to have a more robust testing across different editions

r? `@fmease`

---

try-job: aarch64-gnu
try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
try-job: test-various
try-job: armhf-gnu
2025-11-27 22:37:05 +00:00
Christian Poveda
7ae2823bc6
Gate 2018 UI tests 2025-11-27 14:13:58 -05:00
Christian Poveda
b2ab7cf980
Gate 2015 UI tests 2025-11-27 11:19:00 -05:00
Sasha Pourcelot
2ab2090937 Port the #![windows_subsystem] attribute to the new attribute system 2025-11-27 00:17:48 +01:00
Ben Kimock
bef49a02ef Don't lint on derefs of null pointers to ZSTs 2025-11-24 21:45:28 -05:00
Ben Kimock
c0097978aa Make deref_nullptr deny by default instead of warn 2025-11-24 21:45:28 -05:00
bors
122cbd0438 Auto merge of #147804 - tmiasko:move-copy, r=cjgillot,saethlin
Turn moves into copies after copy propagation

Previously copy propagation presumed that there is further unspecified distinction between move operands and copy operands in assignments and propagated moves from assignments into terminators. This is inconsistent with current operational semantics.

Turn moves into copies after copy propagation to preserve existing behavior.

Fixes https://github.com/rust-lang/rust/issues/137936.
Fixes https://github.com/rust-lang/rust/issues/146423.

r? `@cjgillot`
2025-11-23 13:56:14 +00:00
bors
e0e204f3e9 Auto merge of #149096 - chenyukang:yukang-fix-unused-vars-148373, r=oli-obk
Skip unused variables warning for unreachable code

Fixes rust-lang/rust#148373

These warnings are not reported on stable branch, but are now reported on the beta.

I tried another solution to record whether a `local` is reachable in `find_dead_assignments`, but the code in this PR seems simpler.

r? `@cjgillot`
2025-11-23 04:14:38 +00:00
Matthias Krüger
cef578b3a9
Rollup merge of #149072 - chenyukang:yukang-fix-unused-148960, r=davidtwco
Fix the issue of unused assignment from MIR liveness checking

Fixes rust-lang/rust#148960
Fixes rust-lang/rust#148418

r? ``@davidtwco``

cc ``@cjgillot``

My first try on MIR related code, so it may not be the best fix.
2025-11-22 18:41:21 +01:00
Urgau
dc2a61eccd Add const_item_interior_mutations lint 2025-11-22 14:48:40 +01:00
yukang
2c6b1d3430 Skip unused variables warning for unreachable code 2025-11-21 08:48:45 +08:00
Tomasz Miąsko
6bd1a031ab Turn moves into copies after copy propagation
Previously copy propagation presumed that there is further unspecified
distinction between move operands and copy operands in assignments and
propagated moves from assignments into terminators. This is inconsistent
with current operational semantics.

Turn moves into copies after copy propagation to preserve existing behavior.

Fixes https://github.com/rust-lang/rust/issues/137936.
Fixes https://github.com/rust-lang/rust/issues/146423.
2025-11-20 19:23:10 +01:00
yukang
00f3155794 fix unused assigment issue for variable with drop, issue 148418 2025-11-20 20:00:54 +08:00
yukang
4930d3e612 Fix the issue of unused assignment from MIR liveness checking 2025-11-19 13:29:43 +08:00
Guillaume Gomez
d05f297164 Add more test for function_cast_as_integer lint 2025-11-10 16:38:28 +01:00
Guillaume Gomez
0a2c473ae7 Convert function_cast_as_integer lint suggestion to plain *const () cast 2025-11-10 16:38:28 +01:00
Guillaume Gomez
2ac32ae7a0 Add ui test for function_casts_as_integer lint 2025-11-10 16:38:28 +01:00
Guillaume Gomez
725f4ad24b Allow function_casts_as_integer in non-related ui tests 2025-11-10 16:38:28 +01:00
Stuart Cook
b0c4434a7f
Rollup merge of #148601 - GrigorenkoPV:invalid_atomic_ordering, r=Kivooeo
`invalid_atomic_ordering`: also lint `update` & `try_update`

Split from rust-lang/rust#148590

Tracking issue for `update` and `try_update`: rust-lang/rust#135894
2025-11-09 13:22:30 +11:00
21aslade
566a86b02f show packed alignment in mir_transform_unaligned_packed_ref 2025-11-07 13:57:37 -07:00
Pavel Grigorenko
bd23d55f29 invalid_atomic_ordering: also lint update & try_update 2025-11-07 16:17:10 +03:00
Marijn Schouten
0bd6a03edf dangling ptr lint cleanup 2025-11-01 15:15:05 +00:00
Jonathan Brouwer
a09c4fc862
Fix types being marked as dead when they are inferred generic arguments
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-30 08:31:07 +01:00
Stuart Cook
ef8003bbb9
Rollup merge of #147185 - RalfJung:repr-c-not-zst, r=petrochenkov
repr(transparent): do not consider repr(C) types to be 1-ZST

Context: https://github.com/rust-lang/unsafe-code-guidelines/issues/552

This experiments with a [suggestion](https://github.com/rust-lang/rfcs/pull/3845#discussion_r2388463698) by ```@RustyYato``` to stop considering repr(C) types as 1-ZST for the purpose of repr(transparent). If we go with https://github.com/rust-lang/rfcs/pull/3845 (or another approach for fixing repr(C)), they will anyway not be ZST on all targets any more, so this removes a portability hazard. Furthermore, zero-sized repr(C) structs [may have to be treated](https://github.com/rust-lang/unsafe-code-guidelines/issues/552#issuecomment-3250657813) as non-ZST for the win64 ABI (at least that's what gcc/clang do), so allowing them to be ignored in repr(transparent) types is not entirely coherent.

Turns out we already have an FCW for repr(transparent), namely https://github.com/rust-lang/rust/issues/78586. This extends that lint to also check for repr(C).
2025-10-28 20:39:32 +11:00
Ralf Jung
b9b29c4379 repr(transparent): do not consider repr(C) types to be 1-ZST 2025-10-27 19:25:14 +01:00
Scott Schafer
5aedef17f9
chore: Remove unneeded ansi escape resets from output 2025-10-20 12:13:26 -06:00
Scott Schafer
a484119046
refactor: Use plain ansi colors for output 2025-10-20 12:13:26 -06:00
Stuart Cook
061f854d07
Rollup merge of #147382 - joshtriplett:unused-must-use-ignore-result-unit-uninhabited, r=fmease
unused_must_use: Don't warn on `Result<(), Uninhabited>` or `ControlFlow<Uninhabited, ()>`

This suppresses warnings on things like `Result<(), !>`, which helps simplify code using the common pattern of having an `Error` associated type: code will only have to check the error if there is a possibility of error.

This will, for instance, help with future refactorings of `write!` in the standard library.

As this is a user-visible change to lint behavior, it'll require a lang FCP.

---

My proposal, here, is that we handle this simple case to make common patterns more usable. This does not rule out the possibility of adding more cases in the future, including general trait-based cases. However, I don't think we should make this common case wait on the more general cases. In particular, this solution does not close any doors on replacing this special case with a general case.

This would unblock some planned work in the standard library to make `write!` more usable for infallible cases (e.g. writing into a `Vec` or `String`).
2025-10-20 16:12:54 +11:00
Jonathan Brouwer
66b8a9db1f
Update uitests with new unused_attributes warnings
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-18 21:17:48 +02:00
Stuart Cook
a49246a614
Rollup merge of #147546 - chenyukang:yukang-fix-break-label-147542, r=jackh726
Suppress unused_parens for labeled break

Fixes rust-lang/rust#147542
2025-10-14 16:30:59 +11:00
yukang
d658bcfdfe Suppress unused_parens for labeled break 2025-10-14 12:32:51 +08:00
Camille Gillot
c653430714 Suggest unit struct and constants. 2025-10-11 20:50:21 +00:00
Camille GILLOT
ca0379d6cd Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
Camille GILLOT
5620c82e53 Report uninhabited call return types on MIR. 2025-10-11 20:50:20 +00:00
niacdoial
2d95dfd5a9 unused_must_use: Add extra test for types that are still generic 2025-10-10 13:09:49 -07:00
Josh Triplett
339caa11c7 unused_must_use: Rename test functions to reflect what they test
This makes it easier to review without cross-referencing each test
function with its invocation.
2025-10-10 13:09:49 -07:00
Josh Triplett
39f59bf6a2 unused_must_use: Suppress warnings for ControlFlow<Uninhabited, ()> too 2025-10-10 13:09:49 -07:00
Josh Triplett
efd76c910e unused_must_use: Add test for a method using an associated error type 2025-10-10 13:09:49 -07:00
Josh Triplett
6f89cecf37 unused_must_use: Don't warn on Result<(), Uninhabited>
This suppresses warnings on things like `Result<(), !>`, which helps
simplify code using the common pattern of having an `Error` associated
type: code will only have to check the error if there is a possibility
of error.
2025-10-10 13:09:46 -07:00
Jana Dönszelmann
1dbe831e47
sort attribute targets for more consistent error messages 2025-10-08 08:32:03 +02:00