Formally implement let chains
## Let chains
My longest and hardest contribution since #64010.
Thanks to `@Centril` for creating the RFC and special thanks to `@matthewjasper` for helping me since the beginning of this journey. In fact, `@matthewjasper` did much of the complicated MIR stuff so it's true to say that this feature wouldn't be possible without him. Thanks again `@matthewjasper!`
With the changes proposed in this PR, it will be possible to chain let expressions along side local variable declarations or ordinary conditional expressions. In other words, do much of what the `if_chain` crate already does.
## Other considerations
* `if let guard` and `let ... else` features need special care and should be handled in a following PR.
* Irrefutable patterns are allowed within a let chain context
* ~~Three Clippy lints were already converted to start dogfooding and help detect possible corner cases~~
cc #53667
Before, the trait's associated item would be used. Now, the impl's
associated item is used. The only exception is for impls that use
default values for associated items set by the trait. In that case,
the trait's associated item is still used.
As an example of the old and new behavior, take this code:
trait MyTrait {
type AssocTy;
}
impl MyTrait for String {
type AssocTy = u8;
}
Before, when resolving a link to `String::AssocTy`,
`resolve_associated_trait_item` would return the associated item for
`MyTrait::AssocTy`. Now, it would return the associated item for
`<String as MyTrait>::AssocTy`, as it claims in its docs.
Rollup of 9 pull requests
Successful merges:
- #90782 (Implement raw-dylib support for windows-gnu)
- #91150 (Let qpath contain NtTy: `<$:ty as $:ty>::…`)
- #92425 (Improve SIMD casts)
- #92692 (Simplify and unify rustdoc sidebar styles)
- #92780 (Directly use ConstValue for single literals in blocks)
- #92924 (Delete pretty printer tracing)
- #93018 (Remove some unused `Ord` derives based on `Span`)
- #93026 (fix typo in `max` description for f32/f64)
- #93035 (Fix stdarch submodule pointing to commit outside tree)
Failed merges:
- #92861 (Rustdoc mobile: put out-of-band info on its own line)
r? `@ghost`
`@rustbot` modify labels: rollup
We previously weren't tracking partial re-inits while being too
aggressive around partial drops. With this change, we simply ignore
partial drops, which is the safer, more conservative choice.
The previous commit made the non_sync_with_method_call case pass due to
the await being unreachable. Unfortunately, this isn't actually the
behavior the test was verifying. This change lifts the panic into a
helper function so that the generator analysis still thinks the await
is reachable, and therefore we preserve the same testing behavior.
This changes drop range analysis to handle uninhabited return types such
as `!`. Since these calls to these functions do not return, we model
them as ending in an infinite loop.
This reduces the amount of work done, especially in later iterations,
by only processing nodes whose predecessors changed in the previous
iteration, or earlier in the current iteration. This also has the side
effect of completely ignoring all unreachable nodes.
The refactoring mainly keeps the separation between the modules clearer.
For example, process_deferred_edges function moved to cfg_build.rs since
that is really part of building the CFG, not finding the fixpoint.
Also, we use PostOrderId instead of usize in a lot more places now.
Splits drop_ranges into drop_ranges::record_consumed_borrow,
drop_ranges::cfg_build, and drop_ranges::cfg_propagate. The top level
drop_ranges module has an entry point that does all the coordination of
the other three phases, using code original in generator_interior.
All tests pass now! The issue was that we weren't handling all edges
correctly, but now they are handled consistently.
This includes code to dump a graphviz file for the CFG we built for drop
tracking.
Also removes old DropRanges tests.