rust/tests/ui/lint/unused
Jacob Pratt c9a7f8afa9
Rollup merge of #152103 - eggyal:caught-divergence-not-unused, r=cjgillot
Consider captures to be used by closures that unwind

Assignments to a captured variable within a diverging closure should not be considered unused if the divergence is caught.

This patch considers such assignments/captures to be used by diverging closures irrespective of whether the divergence is caught, but better a false negative unused lint than a false positive one (the latter having caused a stable-to-stable regression).

Fixes rust-lang/rust#152079
r? compiler
2026-02-16 04:28:57 -05:00
..
auxiliary Fix suppression of unused_assignment in binding of unused_variable 2026-01-23 22:20:52 +00:00
unused_parens Supress unused_parens lint for guard patterns 2026-01-09 16:15:39 +00:00
assoc-types.assoc_ty.stderr Enforce must_use on associated types and RPITITs 2023-11-30 02:24:52 +00:00
assoc-types.rpitit.stderr Enforce must_use on associated types and RPITITs 2023-11-30 02:24:52 +00:00
assoc-types.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
break-label-with-parens-147542.rs Suppress unused_parens for labeled break 2025-10-14 12:32:51 +08:00
closure-body-issue-136741.fixed Remove uncessary parens in closure body with unused lint 2025-07-10 09:25:56 +08:00
closure-body-issue-136741.rs Remove uncessary parens in closure body with unused lint 2025-07-10 09:25:56 +08:00
closure-body-issue-136741.stderr chore: Update annotate-snippets to 0.12.10 2025-12-01 18:12:35 -07:00
concat-in-crate-deprecated-issue-137687.rs fix ICE on stable related to attrs on macros 2025-08-24 09:20:57 +02:00
concat-in-crate-name-issue-137687.rs Use attribute name in message for "outer attr used as inner attr" errors 2025-08-25 21:31:04 +02:00
concat-in-crate-name-issue-137687.stderr Update uitests 2026-01-18 22:41:00 +01:00
const-local-var.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
diverging-path.rs Consider captures to be used by closures that unwind 2026-02-04 12:35:34 +00:00
import_remove_line.fixed If suggestion would leave an empty line, delete it 2024-03-01 13:48:20 +00:00
import_remove_line.rs If suggestion would leave an empty line, delete it 2024-03-01 13:48:20 +00:00
import_remove_line.stderr Make early lints translatable 2024-05-21 20:16:39 +00:00
issue-30730.rs
issue-30730.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-46576.rs
issue-46576.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-47390-unused-variable-in-struct-pattern.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-47390-unused-variable-in-struct-pattern.stderr Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
issue-54180-unused-ref-field.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-54180-unused-ref-field.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-54180-unused-ref-field.stderr Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
issue-54538-unused-parens-lint.fixed Gate 2018 UI tests 2025-11-27 14:13:58 -05:00
issue-54538-unused-parens-lint.rs Gate 2018 UI tests 2025-11-27 14:13:58 -05:00
issue-54538-unused-parens-lint.stderr Gate 2018 UI tests 2025-11-27 14:13:58 -05:00
issue-59896.rs Introduce REDUNDANT_IMPORTS lint 2024-07-31 00:07:42 -04:00
issue-59896.stderr Introduce REDUNDANT_IMPORTS lint 2024-07-31 00:07:42 -04:00
issue-67691-unused-field-in-or-pattern.rs
issue-67691-unused-field-in-or-pattern.stderr Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
issue-70041.rs replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
issue-70041.stderr bless tests with new lint messages 2025-08-19 21:27:10 +02:00
issue-71290-unused-paren-binop.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-74883-unused-paren-baren-yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
issue-74883-unused-paren-baren-yield.stderr
issue-81314-unused-span-ident.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-81314-unused-span-ident.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-81314-unused-span-ident.stderr
issue-85913.rs
issue-85913.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-88519-unused-paren.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-90807-unused-paren-error.rs
issue-90807-unused-paren-error.stderr
issue-90807-unused-paren.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-92751.rs
issue-92751.stderr
issue-96606.rs Emit warnings on unused parens/braces in index expressions 2023-02-02 12:46:31 -07:00
issue-96606.stderr Emit warnings on unused parens/braces in index expressions 2023-02-02 12:46:31 -07:00
issue-103320-must-use-ops.rs remove unused features from some tests 2025-12-02 11:07:42 +01:00
issue-103320-must-use-ops.stderr remove unused features from some tests 2025-12-02 11:07:42 +01:00
issue-104397.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-105061-array-lint.rs add test case for issue 105601 2023-01-14 17:11:05 +08:00
issue-105061-array-lint.stderr add test case for issue 105601 2023-01-14 17:11:05 +08:00
issue-105061-should-lint.rs Detect more cases of unused_parens around types 2025-07-01 08:56:20 +02:00
issue-105061-should-lint.stderr Detect more cases of unused_parens around types 2025-07-01 08:56:20 +02:00
issue-105061.rs Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
issue-105061.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-117142-invalid-remove-parens.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-117284-arg-in-macro.rs Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
issue-117284-arg-in-macro.stderr Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
issue-119383-if-let-guard.rs Rename test 2023-12-29 13:49:23 +01:00
issue-119383-if-let-guard.stderr Rename test 2023-12-29 13:49:23 +01:00
lint-unsed-in-macro-issue-151269.rs Fix unused lint error in macro 2026-01-29 23:10:46 +08:00
lint-unsed-in-macro-issue-151269.stderr Fix unused lint error in macro 2026-01-29 23:10:46 +08:00
lint-unused-extern-crate.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lint-unused-extern-crate.stderr Use cfg_attr AST placeholder AST cfg_attr_trace for diagnostics 2025-05-29 10:24:23 +00:00
lint-unused-imports-self-single.fixed Fix autofix for self and self as … in unused_imports lint 2025-03-24 13:01:47 +01:00
lint-unused-imports-self-single.rs Fix autofix for self and self as … in unused_imports lint 2025-03-24 13:01:47 +01:00
lint-unused-imports-self-single.stderr Fix autofix for self and self as … in unused_imports lint 2025-03-24 13:01:47 +01:00
lint-unused-imports.rs Use non-2015 edition paths in tests that do not test for their resolution 2025-06-03 13:35:31 +02:00
lint-unused-imports.stderr Use non-2015 edition paths in tests that do not test for their resolution 2025-06-03 13:35:31 +02:00
lint-unused-mut-self.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lint-unused-mut-self.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
lint-unused-mut-self.stderr
lint-unused-mut-variables.rs Stabilize async closures 2024-12-13 00:04:56 +00:00
lint-unused-mut-variables.stderr Stabilize async closures 2024-12-13 00:04:56 +00:00
lint-unused-variables.rs Stabilize async closures 2024-12-13 00:04:56 +00:00
lint-unused-variables.stderr Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
match_with_guard.rs Fix missing unused_variables lint when using a match guard 2026-02-02 10:57:54 +00:00
match_with_guard.stderr Fix missing unused_variables lint when using a match guard 2026-02-02 10:57:54 +00:00
must-use-block-expr.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
must-use-block-expr.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
must-use-block-expr.stderr Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
must-use-box-from-raw.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
must-use-box-from-raw.stderr error-msg: expand suggestion for unused lint 2023-03-15 23:30:12 +13:00
must-use-foreign.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
must-use-macros.fixed Fix suggestion spans inside macros for the unused_must_use lint 2025-06-25 23:03:18 +02:00
must-use-macros.rs Fix suggestion spans inside macros for the unused_must_use lint 2025-06-25 23:03:18 +02:00
must-use-macros.stderr Fix suggestion spans inside macros for the unused_must_use lint 2025-06-25 23:03:18 +02:00
must-use-ops.rs tests: fix some typos in comment 2025-03-07 10:50:31 +08:00
must-use-ops.stderr
must_use-array.rs
must_use-array.stderr
must_use-in-stdlib-traits.rs
must_use-in-stdlib-traits.stderr
must_use-pin.rs add test for pinned must_use pointers 2023-11-18 21:01:02 -08:00
must_use-pin.stderr add test for pinned must_use pointers 2023-11-18 21:01:02 -08:00
must_use-result-unit-uninhabited.rs unused_must_use: Add extra test for types that are still generic 2025-10-10 13:09:49 -07:00
must_use-result-unit-uninhabited.stderr unused_must_use: Add extra test for types that are still generic 2025-10-10 13:09:49 -07:00
must_use-trait.rs
must_use-trait.stderr
must_use-tuple.rs
must_use-tuple.stderr
must_use-unit.rs UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
must_use-unit.stderr error-msg: expand suggestion for unused lint 2023-03-15 23:30:12 +13:00
mut-used-despite-borrowck-error.rs Suppress unused_mut lint if mutation fails due to borrowck error 2026-02-03 11:52:00 +00:00
mut-used-despite-borrowck-error.stderr Suppress unused_mut lint if mutation fails due to borrowck error 2026-02-03 11:52:00 +00:00
no-unused-parens-return-block.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
trait-alias-supertrait.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
underscore-capture-issue-149889.rs Underscore-prefixed bindings are explicitly allowed to be unused 2026-01-11 16:32:19 +08:00
unused-allocation-box-ref-issue-151846.rs Skip unused_allocation lint when method takes &Box<Self> 2026-01-30 09:14:03 +00:00
unused-allocation.rs turn rustc_box into an intrinsic 2025-01-03 12:01:31 +01:00
unused-allocation.stderr turn rustc_box into an intrinsic 2025-01-03 12:01:31 +01:00
unused-assign-148960.rs fix unused assigment issue for variable with drop, issue 148418 2025-11-20 20:00:54 +08:00
unused-assign-148960.stderr fix unused assigment issue for variable with drop, issue 148418 2025-11-20 20:00:54 +08:00
unused-associated-item.rs Split item bounds and item super predicates 2024-03-20 13:00:34 -04:00
unused-async.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unused-async.stderr Dont check must_use on nested impl Future from fn 2023-05-12 02:08:43 +00:00
unused-attr-duplicate.rs Port crate name to the new attribute system 2025-08-24 09:20:57 +02:00
unused-attr-duplicate.stderr Port #![no_builtins] to the attribute parser. 2026-01-21 21:08:28 +00:00
unused-attr-macro-rules.rs Update uitests 2025-08-14 18:18:42 +02:00
unused-attr-macro-rules.stderr Update uitests 2026-01-18 22:41:00 +01:00
unused-attr-repr-packed-c-order.rs cleaned up some tests 2025-12-13 00:54:20 +09:00
unused-braces-attrs-issue-141549.fixed Fix unused_braces lint suggestion when encountering attributes 2025-05-25 18:17:43 +02:00
unused-braces-attrs-issue-141549.rs Fix unused_braces lint suggestion when encountering attributes 2025-05-25 18:17:43 +02:00
unused-braces-attrs-issue-141549.stderr Fix unused_braces lint suggestion when encountering attributes 2025-05-25 18:17:43 +02:00
unused-closure.rs Stabilize async closures 2024-12-13 00:04:56 +00:00
unused-closure.stderr Stabilize async closures 2024-12-13 00:04:56 +00:00
unused-doc-comments-edge-cases.rs Revert "Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, r=davidtwco" 2024-06-06 20:39:54 +00:00
unused-doc-comments-edge-cases.stderr Detail expectation on non-() block tail in if then condition with no else 2025-12-22 13:55:49 +00:00
unused-doc-comments-for-macros.rs
unused-doc-comments-for-macros.stderr
unused-field-in-pat-field.rs Visit PatField when collecting lint levels 2025-03-13 00:22:30 +00:00
unused-macro-rules-compile-error.rs Remove ordinalize. 2024-05-10 16:42:09 +10:00
unused-macro-rules-compile-error.stderr Stop relying on hashmap iteration for unused macro rules arms 2024-10-20 00:12:52 -07:00
unused-macro-rules-decl.rs Remove ordinalize. 2024-05-10 16:42:09 +10:00
unused-macro-rules-decl.stderr Stop relying on hashmap iteration for unused macro rules arms 2024-10-20 00:12:52 -07:00
unused-macro-rules-malformed-rule.rs
unused-macro-rules-malformed-rule.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
unused-macro-rules.rs Remove ordinalize. 2024-05-10 16:42:09 +10:00
unused-macro-rules.stderr Stop relying on hashmap iteration for unused macro rules arms 2024-10-20 00:12:52 -07:00
unused-macro-with-bad-frag-spec.rs
unused-macro-with-bad-frag-spec.stderr Stabilize expr_2021 fragment in all editions 2024-10-01 07:51:58 +00:00
unused-macro-with-follow-violation.rs
unused-macro-with-follow-violation.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
unused-macros-decl.rs
unused-macros-decl.stderr
unused-macros-malformed-rule.rs
unused-macros-malformed-rule.stderr
unused-macros.rs
unused-macros.stderr resolve: Replace Macros20NormalizedIdent with IdentKey 2026-01-27 18:11:52 +03:00
unused-mut-warning-captured-var.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unused-mut-warning-captured-var.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unused-mut-warning-captured-var.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
unused-parens-assign-expr-in-ret-issue-131989.fixed Adding BreakValue to UnusedDelimsCtx to make UnusedParens and UnusedBraces checking break 2024-11-14 09:08:56 +08:00
unused-parens-assign-expr-in-ret-issue-131989.rs Adding BreakValue to UnusedDelimsCtx to make UnusedParens and UnusedBraces checking break 2024-11-14 09:08:56 +08:00
unused-parens-assign-expr-in-ret-issue-131989.stderr Adding BreakValue to UnusedDelimsCtx to make UnusedParens and UnusedBraces checking break 2024-11-14 09:08:56 +08:00
unused-parens-false-positive-issue-143653.fixed Add test case for single bound 2025-07-24 20:44:10 +02:00
unused-parens-false-positive-issue-143653.rs Add test case for single bound 2025-07-24 20:44:10 +02:00
unused-parens-false-positive-issue-143653.stderr Add test case for single bound 2025-07-24 20:44:10 +02:00
unused-parens-for-stmt-expr-attributes-issue-129833.fixed Make unused_parens's suggestion considering expr's attributes 2024-10-12 09:32:25 +08:00
unused-parens-for-stmt-expr-attributes-issue-129833.rs Make unused_parens's suggestion considering expr's attributes 2024-10-12 09:32:25 +08:00
unused-parens-for-stmt-expr-attributes-issue-129833.stderr Make unused_parens's suggestion considering expr's attributes 2024-10-12 09:32:25 +08:00
unused-parens-issue-106413.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unused-parens-issue-106413.stderr diagnostics: avoid wrong unused_parens on x as (T) < y 2023-08-31 20:14:49 -07:00
unused-parens-trait-obj.edition2018.fixed Detect more cases of unused_parens around types 2025-07-01 08:56:20 +02:00
unused-parens-trait-obj.edition2018.stderr Detect more cases of unused_parens around types 2025-07-01 08:56:20 +02:00
unused-parens-trait-obj.rs Detect more cases of unused_parens around types 2025-07-01 08:56:20 +02:00
unused-result.rs
unused-result.stderr error-msg: expand suggestion for unused lint 2023-03-15 23:30:12 +13:00
unused-supertrait.rs
unused-supertrait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
unused-trait-fn.rs add metadata and bless moved tests 2026-01-18 06:23:47 +01:00
unused-trait-fn.stderr add metadata and bless moved tests 2026-01-18 06:23:47 +01:00
unused-var-in-match-arm.rs add metadata and bless moved tests 2026-01-18 06:23:47 +01:00
unused-var-in-match-arm.stderr add metadata and bless moved tests 2026-01-18 06:23:47 +01:00
unused-var-in-unreachable-code.rs Skip unused variables warning for unreachable code 2025-11-21 08:48:45 +08:00
unused-var-in-unreachable-code.stderr Skip unused variables warning for unreachable code 2025-11-21 08:48:45 +08:00
unused_assignment.rs Fix suppression of unused_assignment in binding of unused_variable 2026-01-23 22:20:52 +00:00
unused_assignment.stderr Fix suppression of unused_assignment in binding of unused_variable 2026-01-23 22:20:52 +00:00
unused_assignments_across_match_guards.rs add lint test 2026-01-19 08:59:44 +09:00
unused_attributes-must_use.fixed Regression test for attributes on macro calls 2025-08-24 14:54:15 +02:00
unused_attributes-must_use.rs Regression test for attributes on macro calls 2025-08-24 14:54:15 +02:00
unused_attributes-must_use.stderr Treat unions as 'data types' in attr parsing diagnostics 2026-01-29 15:51:43 +00:00
useless-comment.rs For now, ignore target checking for doc attributes in attr_parsing 2025-12-10 20:18:42 +01:00
useless-comment.stderr For now, ignore target checking for doc attributes in attr_parsing 2025-12-10 20:18:42 +01:00