-
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
use PatKind::Error
when an ADT const value has violation
#116522
Conversation
This is confusing -- I expect this to be a hard error. Also, why is this being considered an |
I've been trying to use godbolt on my phone for the last 5 mins and failing, so I can't check what the behaviour used to be. But I also expect it to have gone from an error to an ICE. If that is so, we should figure out how to get the error back |
@oli is correct, this was an error on 1.69:
And then it became a different error in 1.70 -- we should find out why:
And then it became an ICE in 1.72 |
Did |
Some changes might have occurred in exhaustiveness checking cc @Nadrieril |
According to my understanding,
I've implemented a special handling for |
ci is green. @rustbot ready |
why is this just for |
#[derive(PartialEq, Eq)]
pub enum Foo {
FooA(()),
FooB(Vec<()>),
}
impl Foo {
const A1: Foo = Foo::FooA(());
}
fn main() {
let foo = Foo::FooA(());
match foo {
Foo::A1 => {},
_ => {},
}
} Although |
PatKind::wild
when an ADT const value has violation
That makes sense, thanks! Please add that as an explanation for why we only care about |
@bors r+ rollup |
use `PatKind::wild` when an ADT const value has violation Fixes rust-lang#115599 Since the [to_pat](https://github.com/rust-lang/rust/pull/111913/files#diff-6d8d99538aca600d633270051580c7a9e40b35824ea2863d9dda2c85a733b5d9R126-R155) behavior has been changed in the rust-lang#111913 update, the kind of `inlined_const_ast_pat` has transformed from `PatKind::Leaf { pattern: Pat { kind: Wild, ..} } ` to `PatKind::Constant`. This caused a scenario where there are no matched candidates, leading to a testing of the candidates. This process ultimately attempts to test the string const, triggering the `bug!` invocation finally. r? `@oli-obk`
☔ The latest upstream changes (presumably #115937) made this pull request unmergeable. Please resolve the merge conflicts. |
This is starting to feel like we need |
If we have to handle error Constants and types anyway, is it worth a PatKind::Error? I guess we don't know without an impl 😅 |
I had another case where returning an error through |
I attempted it and it indeed entered into the
I don't quite understand this advice. Did you mean to say: if let Some(non_sm_ty) = structural {
let ty = Ty::new_error(tcx, e);
PatKind::Constant { value: mir::Const::Ty(ty::Const::new_error(tcx, e, ty)) }
} |
basically my hope is that if every site in this module uses
giving an entirely new panic, not the If so, let's just land your PR as it is and we'll figure out more refactorings later |
It's not a new panic, merely the bug! that I am aiming to fix. |
I will try it, @rustbot author |
#116715 got merged! Could you try |
PatKind::wild
when an ADT const value has violationPatKind::Error
when an ADT const value has violation
I've utilized @rustbot ready |
@bors r+ rollup Thanks! |
use `PatKind::Error` when an ADT const value has violation Fixes rust-lang#115599 Since the [to_pat](https://github.com/rust-lang/rust/pull/111913/files#diff-6d8d99538aca600d633270051580c7a9e40b35824ea2863d9dda2c85a733b5d9R126-R155) behavior has been changed in the rust-lang#111913 update, the kind of `inlined_const_ast_pat` has transformed from `PatKind::Leaf { pattern: Pat { kind: Wild, ..} } ` to `PatKind::Constant`. This caused a scenario where there are no matched candidates, leading to a testing of the candidates. This process ultimately attempts to test the string const, triggering the `bug!` invocation finally. r? `@oli-obk`
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#115955 (Stabilize `{IpAddr, Ipv6Addr}::to_canonical`) - rust-lang#116033 (report `unused_import` for empty reexports even it is pub) - rust-lang#116172 (Broaden the consequences of recursive TLS initialization) - rust-lang#116341 (Implement sys::args for UEFI) - rust-lang#116522 (use `PatKind::Error` when an ADT const value has violation) - rust-lang#116732 (Make x capable of resolving symlinks) - rust-lang#116755 (Remove me from libcore review rotation) - rust-lang#116760 (Remove trivial cast in `guaranteed_eq`) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#116172 (Broaden the consequences of recursive TLS initialization) - rust-lang#116341 (Implement sys::args for UEFI) - rust-lang#116522 (use `PatKind::Error` when an ADT const value has violation) - rust-lang#116732 (Make x capable of resolving symlinks) - rust-lang#116755 (Remove me from libcore review rotation) - rust-lang#116760 (Remove trivial cast in `guaranteed_eq`) - rust-lang#116771 (Ignore let-chains formatting) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#116522 - bvanjoi:fix-115599, r=oli-obk use `PatKind::Error` when an ADT const value has violation Fixes rust-lang#115599 Since the [to_pat](https://github.com/rust-lang/rust/pull/111913/files#diff-6d8d99538aca600d633270051580c7a9e40b35824ea2863d9dda2c85a733b5d9R126-R155) behavior has been changed in the rust-lang#111913 update, the kind of `inlined_const_ast_pat` has transformed from `PatKind::Leaf { pattern: Pat { kind: Wild, ..} } ` to `PatKind::Constant`. This caused a scenario where there are no matched candidates, leading to a testing of the candidates. This process ultimately attempts to test the string const, triggering the `bug!` invocation finally. r? ``@oli-obk``
54: Pull upstream master 2023 10 17 r=pietroalbini a=Veykril * rust-lang/rust#116196 * rust-lang/rust#116824 * rust-lang/rust#116822 * rust-lang/rust#116477 * rust-lang/rust#116826 * rust-lang/rust#116820 * rust-lang/rust#116811 * rust-lang/rust#116808 * rust-lang/rust#116805 * rust-lang/rust#116800 * rust-lang/rust#116798 * rust-lang/rust#116754 * rust-lang/rust#114370 * rust-lang/rust#116804 * rust-lang/rust#116802 * rust-lang/rust#116790 * rust-lang/rust#116786 * rust-lang/rust#116709 * rust-lang/rust#116430 * rust-lang/rust#116257 * rust-lang/rust#114157 * rust-lang/rust#116731 * rust-lang/rust#116550 * rust-lang/rust#114330 * rust-lang/rust#116724 * rust-lang/rust#116782 * rust-lang/rust#116776 * rust-lang/rust#115955 * rust-lang/rust#115196 * rust-lang/rust#116775 * rust-lang/rust#114589 * rust-lang/rust#113747 * rust-lang/rust#116772 * rust-lang/rust#116771 * rust-lang/rust#116760 * rust-lang/rust#116755 * rust-lang/rust#116732 * rust-lang/rust#116522 * rust-lang/rust#116341 * rust-lang/rust#116172 * rust-lang/rust#110604 * rust-lang/rust#110729 * rust-lang/rust#116527 * rust-lang/rust#116688 * rust-lang/rust#116757 * rust-lang/rust#116753 * rust-lang/rust#116748 * rust-lang/rust#116741 * rust-lang/rust#116594 * rust-lang/rust#116691 * rust-lang/rust#116643 * rust-lang/rust#116683 * rust-lang/rust#116635 * rust-lang/rust#115515 * rust-lang/rust#116742 * rust-lang/rust#116661 * rust-lang/rust#116576 * rust-lang/rust#116540 * rust-lang/rust#116352 * rust-lang/rust#116737 * rust-lang/rust#116730 * rust-lang/rust#116723 * rust-lang/rust#116715 * rust-lang/rust#116603 * rust-lang/rust#116591 * rust-lang/rust#115439 * rust-lang/rust#116264 * rust-lang/rust#116727 * rust-lang/rust#116704 * rust-lang/rust#116696 * rust-lang/rust#116695 * rust-lang/rust#116644 * rust-lang/rust#116630 * rust-lang/rust#116728 * rust-lang/rust#116689 * rust-lang/rust#116679 * rust-lang/rust#116618 * rust-lang/rust#116577 * rust-lang/rust#115653 * rust-lang/rust#116702 * rust-lang/rust#116015 * rust-lang/rust#115822 * rust-lang/rust#116407 * rust-lang/rust#115719 * rust-lang/rust#115524 * rust-lang/rust#116705 * rust-lang/rust#116645 * rust-lang/rust#116233 * rust-lang/rust#115108 * rust-lang/rust#116670 * rust-lang/rust#116676 * rust-lang/rust#116666 Co-authored-by: Benoît du Garreau <bdgdlm@outlook.com> Co-authored-by: Colin Finck <colin@reactos.org> Co-authored-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com> Co-authored-by: León Orell Valerian Liehr <me@fmease.dev> Co-authored-by: Trevor Gross <tmgross@umich.edu> Co-authored-by: Evan Merlock <evan@merlock.dev> Co-authored-by: joboet <jonasboettiger@icloud.com> Co-authored-by: Ralf Jung <post@ralfj.de> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com> Co-authored-by: onur-ozkan <work@onurozkan.dev> Co-authored-by: Nicholas Nethercote <n.nethercote@gmail.com> Co-authored-by: The 8472 <git@infinite-source.de> Co-authored-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Co-authored-by: reez12g <reez12g@gmail.com> Co-authored-by: Jakub Beránek <berykubik@gmail.com>
Fixes #115599
Since the to_pat behavior has been changed in the #111913 update, the kind of
inlined_const_ast_pat
has transformed fromPatKind::Leaf { pattern: Pat { kind: Wild, ..} }
toPatKind::Constant
. This caused a scenario where there are no matched candidates, leading to a testing of the candidates. This process ultimately attempts to test the string const, triggering thebug!
invocation finally.r? @oli-obk