rust/clippy_utils/src
llogiq cc7b2f57e0
Properly check that an expression might be the one returned (#15115)
The `TyCtxt::hir_get_fn_id_for_return_block()` function was too broad,
as it will return positively even when given part of an expression that
can be used as a return value. A new
`potential_return_of_enclosing_body()` utility function has been made to
represent the fact that an expression might be directly returned from
its enclosing body.

changelog: [`return_and_then`]: prevent false positives in case of a
partially used expression

Fixes rust-lang/rust-clippy#15111
Fixes rust-lang/rust-clippy#14927

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

-
[Beta-nomination](https://github.com/rust-lang/rust-clippy/pull/15115#issuecomment-2996222332)
by [samueltardieu](https://github.com/samueltardieu)

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-07-06 15:24:46 +00:00
..
ast_utils Rollup merge of #141570 - chenyukang:yukang-fix-eq_unspanned, r=workingjubilee 2025-06-04 16:24:07 +02:00
mir Merge commit '0621446356' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
ty Merge remote-tracking branch 'upstream/master' into rustup 2025-06-26 19:29:33 +02:00
attrs.rs Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
check_proc_macro.rs Reorder fields in hir::ItemKind variants. 2025-05-30 02:23:20 +10:00
comparisons.rs Merge commit 'd9c24d1b1e' into clippyup 2023-07-17 10:22:32 +02:00
consts.rs Add integer_const() and is_zero_integer_const() utility functions 2025-06-20 09:42:27 +02:00
diagnostics.rs docs: add link to span_lint in diagnostics.rs. 2025-06-16 17:36:02 -04:00
eager_or_lazy.rs Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
higher.rs Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
hir_utils.rs fix closure and refactor tooling code 2025-06-25 20:32:22 -04:00
lib.rs Properly check that an expression might be the one returned (#15115) 2025-07-06 15:24:46 +00:00
macros.rs Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
msrvs.rs zero_ptr: lint in const context as well 2025-06-26 23:09:37 +02:00
numeric_literal.rs Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
paths.rs clippy: replace path uses by diagnostic items 2025-06-20 17:53:09 +02:00
ptr.rs Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
qualify_min_const_fn.rs Merge remote-tracking branch 'upstream/master' into rustup 2025-06-26 19:29:33 +02:00
source.rs Merge commit 'cadf98bb7d' into clippy-subtree-update 2025-05-21 15:15:38 +02:00
str_utils.rs Merge commit '0621446356' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
sugg.rs Sugg: do not parenthesize a double unary operator 2025-06-05 23:27:35 +02:00
sym.rs Merge remote-tracking branch 'upstream/master' into rustup 2025-06-26 19:29:33 +02:00
usage.rs Merge commit '0621446356' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
visitors.rs fix closure and refactor tooling code 2025-06-25 20:32:22 -04:00