-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow destructuring opaque types in their defining scopes #98582
Conversation
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #98566) made this pull request unmergeable. Please resolve the merge conflicts. |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/mir-opt Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
d9d3674
to
9399ae1
Compare
☔ The latest upstream changes (presumably #98649) made this pull request unmergeable. Please resolve the merge conflicts. |
cc @rust-lang/wg-mir-opt this is solely a MIR building/mir-borrowck concern, any takers? |
9399ae1
to
57d011d
Compare
☔ The latest upstream changes (presumably #99101) made this pull request unmergeable. Please resolve the merge conflicts. |
57d011d
to
57e9f7a
Compare
r? rust-lang/compiler-team |
r? compiler-team |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bors r+
#[allow(unconditional_recursion)] | ||
fn foo(b: bool) -> impl Copy { | ||
let (mut x, mut y) = foo(false); | ||
x = 42; | ||
y = "foo"; | ||
if b { | ||
panic!() | ||
} else { | ||
foo(true) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a bug on the lint?
{ | ||
place = test_place_builder.into_place(self.tcx, self.typeck_results); | ||
} else { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the early return is no longer needed because of the changes in the files above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
into_place
ICEs if try_upvars_resolved
would have returned Err
. So this early return was always dead code as I could not figure out when it would ever happen and nothing in our test suite actually hit it.
// Opaque types can't get destructured/split, but the patterns can | ||
// actually hint at hidden types, so we use the patterns' types instead. | ||
if let ty::Opaque(..) = v.head().ty().kind() { | ||
if let Some(row) = rows.first() { | ||
ty = row.head().ty(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this is the meat of this change to get things working.
@bors r+ |
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#98582 (Allow destructuring opaque types in their defining scopes) - rust-lang#99213 (migrate some of `rustc_passes::check_attr`'s diagnostics and derive improvements) - rust-lang#99258 (Provide structured suggestion for dropped temp value) - rust-lang#99259 (interpret/visitor: support visiting with a PlaceTy) - rust-lang#99287 ([rustdoc-json] JSON no longer inlines) - rust-lang#99290 (Revert "Highlight conflicting param-env candidates") - rust-lang#99316 (docs: add missing word) - rust-lang#99317 (Borrow Vec<T, A> as [T]) - rust-lang#99323 (Fix flakyness of GUI tests) - rust-lang#99342 (Avoid some `Symbol` to `String` conversions) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Revert "Rollup merge of rust-lang#98582 - oli-obk:unconstrained_opaque_type, r… …=estebank" This reverts commit 6f8fb91, reversing changes made to 7210e46. r? `@ghost` rebase of rust-lang#99368
…rors Some `is_useful` cleanups rust-lang#98582 was reverted because it was a perf regression. rust-lang#99806 reintroduces the changes, but this PR picks individual ones that have no regressions.
…ed_opaque_type, r=estebank"" This reverts commit 4a742a6.
…ed_opaque_type, r=estebank"" This reverts commit 4a742a6.
…ed_opaque_type, r=estebank"" This reverts commit 4a742a6.
fixes #96572
Before this PR, the following code snippet failed with an incomprehensible error, and similar code just ICEd in mir borrowck.
The problem was that the last line created MIR projections of the form
foo.0
andfoo.1
, butfoo
's type isT
, which doesn't have fields (only its hidden type does). But the pattern supplies enough type information (a tuple of two different inference types) to bind a hidden type.