-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix ICE with unsized type in const pattern #87065
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
}; | ||
self.behind_reference.set(old); | ||
val | ||
if !pointee_ty.is_sized(tcx.at(span), param_env) { |
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.
that certainly avoids the ICE, but we could also make such patterns legal. I think we should. @rust-lang/wg-const-eval what do you think about these?
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 always does span_err
or delay_span_bug
... how does this make anything legal?
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 said "we could ...", I'm fine doing this PR, it changes an ICE to an error, but why should the code in the new test not be permitted? It seems perfectly alright to me
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 not familiar enough with pattern matching code to comment on this.
But I'd prefer we port that code to valtrees first, then I will be a lot more confident that what that code does makes sense in my mental model of rustc. :)
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.
@oli-obk What would be a good way to direct attention to this? I would find it incredibly useful to be able to use newtypes around str
as const patterns.
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.
Valtrees are being worked on right now, once we have them, this becomes trivial to do and we can ask T-lang whether they think this should br supported, too
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.
Cool thanks
@bors r+ |
📌 Commit 79f0743 has been approved by |
Rollup of 11 pull requests Successful merges: - rust-lang#86344 (Split MaybeUninit::write into new feature gate and stabilize it) - rust-lang#86811 (Remove unstable `io::Cursor::remaining`) - rust-lang#86846 (stdio_locked: add tracking issue) - rust-lang#86887 (rustdoc: remove dead code in `clean`) - rust-lang#87007 (Fix rust-analyzer install when not available.) - rust-lang#87035 (Fix implementors display) - rust-lang#87065 (Fix ICE with unsized type in const pattern) - rust-lang#87070 (Simplify future incompatible reporting.) - rust-lang#87077 (:arrow_up: rust-analyzer) - rust-lang#87078 (Rustdoc: suggest removing disambiguator if linking to field) - rust-lang#87089 (CTFE engine: small cleanups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #87046. The
deref_const()
query currently contains the following check:rust/compiler/rustc_mir/src/const_eval/mod.rs
Lines 191 to 204 in e9a387d
i.e. this will cause an ICE for every unsized type except slices. An error is reported with my changes if such a type is used as a const pattern (this should not be a breaking change, since so far, this has caused an ICE).