Handle generic reborrow in expression-use adjustment walking#156795
Conversation
|
rustbot has assigned @nikomatsakis. Use Why was this reviewer chosen?The reviewer was selected based on:
|
53084cc to
90709a5
Compare
|
Does this fix #156339 ? |
Yes, this should fix #156339. I tested the repro from that issue on this branch: the The reduced repro can still produce ordinary diagnostics unrelated to this PR, including the trait-method and async-block type errors from the issue, but the ICE from #156339 is the same expression-use |
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
* Handle generic reborrow in expression-use adjustment walking * Require generic reborrow to be terminal in adjustment walks
|
🔨 2 commits were squashed into a5e4dc9. |
4b11926 to
a5e4dc9
Compare
…-visitor, r=dingxiangfei2009 Handle generic reborrow in expression-use adjustment walking Fixes an ICE in expression-use adjustment walking where `Adjust::GenericReborrow` could reach a match arm that assumed generic reborrow was unreachable. `GenericReborrow` is already emitted by typeck and classified as rvalue-producing elsewhere in `expr_use_visitor.rs`, so the adjustment walker must handle it explicitly instead of panicking. This PR models `GenericReborrow` as a borrow-like use of the source expression: - `Mutability::Mut` is treated like an exclusive/mutable reborrow use. - `Mutability::Not` is treated like a shared/coerce-shared borrow-like use. - The source is not moved or treated as a mere copy. cc @aapoalas @rustbot label F-reborrow Fixes rust-lang#156339 Tracking: rust-lang#145612
…-visitor, r=dingxiangfei2009 Handle generic reborrow in expression-use adjustment walking Fixes an ICE in expression-use adjustment walking where `Adjust::GenericReborrow` could reach a match arm that assumed generic reborrow was unreachable. `GenericReborrow` is already emitted by typeck and classified as rvalue-producing elsewhere in `expr_use_visitor.rs`, so the adjustment walker must handle it explicitly instead of panicking. This PR models `GenericReborrow` as a borrow-like use of the source expression: - `Mutability::Mut` is treated like an exclusive/mutable reborrow use. - `Mutability::Not` is treated like a shared/coerce-shared borrow-like use. - The source is not moved or treated as a mere copy. cc @aapoalas @rustbot label F-reborrow Fixes rust-lang#156339 Tracking: rust-lang#145612
…uwer Rollup of 6 pull requests Successful merges: - #158026 (`RegionValues`: disable unnecessary range check) - #156795 (Handle generic reborrow in expression-use adjustment walking) - #157694 (Enhance documentation on wake call memory ordering) - #158034 (Fix reborrow source expression visits) - #158074 (Document transient connection errors from TcpListener::accept) - #158086 (renovate: Loosen dashboard approval and adopt recommended config)
…-visitor, r=dingxiangfei2009 Handle generic reborrow in expression-use adjustment walking Fixes an ICE in expression-use adjustment walking where `Adjust::GenericReborrow` could reach a match arm that assumed generic reborrow was unreachable. `GenericReborrow` is already emitted by typeck and classified as rvalue-producing elsewhere in `expr_use_visitor.rs`, so the adjustment walker must handle it explicitly instead of panicking. This PR models `GenericReborrow` as a borrow-like use of the source expression: - `Mutability::Mut` is treated like an exclusive/mutable reborrow use. - `Mutability::Not` is treated like a shared/coerce-shared borrow-like use. - The source is not moved or treated as a mere copy. cc @aapoalas @rustbot label F-reborrow Fixes rust-lang#156339 Tracking: rust-lang#145612
…uwer Rollup of 10 pull requests Successful merges: - #158026 (`RegionValues`: disable unnecessary range check) - #156795 (Handle generic reborrow in expression-use adjustment walking) - #157694 (Enhance documentation on wake call memory ordering) - #157935 (Make `proc_macro::ConversionErrorKind` non exhaustive) - #158002 (Replace `unwrap` with `expect` in `get_module_children`) - #158034 (Fix reborrow source expression visits) - #158072 (Bump thin-vec to 0.2.18 to address RUSTSEC-2026-0103) - #158074 (Document transient connection errors from TcpListener::accept) - #158077 (rustdoc-json-types: Replace bincode dev-dependency with postcard) - #158086 (renovate: Loosen dashboard approval and adopt recommended config)
…uwer Rollup of 10 pull requests Successful merges: - #158026 (`RegionValues`: disable unnecessary range check) - #156795 (Handle generic reborrow in expression-use adjustment walking) - #157694 (Enhance documentation on wake call memory ordering) - #157935 (Make `proc_macro::ConversionErrorKind` non exhaustive) - #158002 (Replace `unwrap` with `expect` in `get_module_children`) - #158034 (Fix reborrow source expression visits) - #158072 (Bump thin-vec to 0.2.18 to address RUSTSEC-2026-0103) - #158074 (Document transient connection errors from TcpListener::accept) - #158077 (rustdoc-json-types: Replace bincode dev-dependency with postcard) - #158086 (renovate: Loosen dashboard approval and adopt recommended config)
Rollup of 12 pull requests Successful merges: - #156795 (Handle generic reborrow in expression-use adjustment walking) - #157694 (Enhance documentation on wake call memory ordering) - #157935 (Make `proc_macro::ConversionErrorKind` non exhaustive) - #158002 (Replace `unwrap` with `expect` in `get_module_children`) - #158009 (Reject `impl const Trait` since the right syntax is `const impl Trait` now) - #158034 (Fix reborrow source expression visits) - #158072 (Bump thin-vec to 0.2.18 to address RUSTSEC-2026-0103) - #158074 (Document transient connection errors from TcpListener::accept) - #158077 (rustdoc-json-types: Replace bincode dev-dependency with postcard) - #158086 (renovate: Loosen dashboard approval and adopt recommended config) - #158088 (codegen_ssa: no dbginfo for scalable vec local w/ `-O0`) - #158089 (Fix invalid "jump-to-def" doc link generation when an item has a `derive` proc-macro)
Rollup merge of #156795 - P8L1:fix-generic-reborrow-expr-use-visitor, r=dingxiangfei2009 Handle generic reborrow in expression-use adjustment walking Fixes an ICE in expression-use adjustment walking where `Adjust::GenericReborrow` could reach a match arm that assumed generic reborrow was unreachable. `GenericReborrow` is already emitted by typeck and classified as rvalue-producing elsewhere in `expr_use_visitor.rs`, so the adjustment walker must handle it explicitly instead of panicking. This PR models `GenericReborrow` as a borrow-like use of the source expression: - `Mutability::Mut` is treated like an exclusive/mutable reborrow use. - `Mutability::Not` is treated like a shared/coerce-shared borrow-like use. - The source is not moved or treated as a mere copy. cc @aapoalas @rustbot label F-reborrow Fixes #156339 Tracking: #145612
Rollup of 12 pull requests Successful merges: - rust-lang/rust#156795 (Handle generic reborrow in expression-use adjustment walking) - rust-lang/rust#157694 (Enhance documentation on wake call memory ordering) - rust-lang/rust#157935 (Make `proc_macro::ConversionErrorKind` non exhaustive) - rust-lang/rust#158002 (Replace `unwrap` with `expect` in `get_module_children`) - rust-lang/rust#158009 (Reject `impl const Trait` since the right syntax is `const impl Trait` now) - rust-lang/rust#158034 (Fix reborrow source expression visits) - rust-lang/rust#158072 (Bump thin-vec to 0.2.18 to address RUSTSEC-2026-0103) - rust-lang/rust#158074 (Document transient connection errors from TcpListener::accept) - rust-lang/rust#158077 (rustdoc-json-types: Replace bincode dev-dependency with postcard) - rust-lang/rust#158086 (renovate: Loosen dashboard approval and adopt recommended config) - rust-lang/rust#158088 (codegen_ssa: no dbginfo for scalable vec local w/ `-O0`) - rust-lang/rust#158089 (Fix invalid "jump-to-def" doc link generation when an item has a `derive` proc-macro)
Fixes an ICE in expression-use adjustment walking where
Adjust::GenericReborrowcould reach a match arm that assumed generic reborrow was unreachable.GenericReborrowis already emitted by typeck and classified as rvalue-producing elsewhere inexpr_use_visitor.rs, so the adjustment walker must handle it explicitly instead of panicking.This PR models
GenericReborrowas a borrow-like use of the source expression:Mutability::Mutis treated like an exclusive/mutable reborrow use.Mutability::Notis treated like a shared/coerce-shared borrow-like use.cc @aapoalas
@rustbot label F-reborrow
Fixes #156339
Tracking: #145612