[generator_interior] Be more precise with scopes of borrowed places
Previously the generator interior type checking analysis would use the nearest temporary scope as the scope of a borrowed value. This ends up being overly broad for cases such as:
```rust
fn status(_client_status: &Client) -> i16 {
200
}
fn main() {
let client = Client;
let g = move || match status(&client) {
_status => yield,
};
assert_send(g);
}
```
In this case, the borrow `&client` could be considered in scope for the entirety of the `match` expression, meaning it would be viewed as live across the `yield`, therefore making the generator not `Send`.
In most cases, we want to use the enclosing expression as the scope for a borrowed value which will be less than or equal to the nearest temporary scope. This PR changes the analysis to use the enclosing expression as the scope for most borrows, with the exception of borrowed RValues which are true temporary values that should have the temporary scope. There's one further exception where borrows of a copy such as happens in autoref cases also should be ignored despite being RValues.
Joint work with `@nikomatsakis`
Fixes#57017
r? `@tmandry`
Don't lint `transmute_undefined_repr` when changing the type of generic params
Partially fixes#8499
changelog: Don't lint `transmute_undefined_repr` when changing the type of generic params
More `transmute_undefined_repr` fixes
fixes: #8498fixes: #8501fixes: #8503
changelog: Allow `transumte_undefined_repr` between fat pointers and `(usize, usize)`
changelog: Allow `transumte_undefined_repr` when one side is a union
changelog: Fix `transumte_undefined_repr` on tuples with one non-zero-sized type.
[`collapsible_if`] fix typo in code-block kind specifier
*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: [`collapsible_if`] fix typo in code-block kind specifier
Allow `single_component_path_imports` for all macros
Closes: https://github.com/rust-lang/rust-clippy/issues/7923
It can be useful to have `use macro_name` regardless of the visibility. This removes the visibility filter.
changelog: [`single_component_path_imports`]: no longer triggers on macros
Make `search_is_some`s suggestion `MachineApplicable`
My biggest PR to date, about 0.3 Lines have been changed!
Closes https://github.com/rust-lang/rust-clippy/issues/8062
The suggestion seems to work well, as we've received no error reports since the implementation in December. This PR therefore promotes the suggestion to `MachineApplicable`. The tests already include `.fixed` files :)
changelog: [`search_is_some`]: Make more suggestions `MachineApplicable`
new lint: `only_used_in_recursion`
changed:
- added `only_used_in_recursion`.
- fixed code that variables are only used in recursion.
- this would not lint when `unused_variable`
This fixes: #8390
-----
changelog: add lint [`only_used_in_recursion`]