Skip to content
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

ICE: trying to compare incompatible ctors while building rustfmt #78549

Closed
matthiaskrgr opened this issue Oct 30, 2020 · 7 comments · Fixed by #78553
Closed

ICE: trying to compare incompatible ctors while building rustfmt #78549

matthiaskrgr opened this issue Oct 30, 2020 · 7 comments · Fixed by #78553
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Repro

git clone https://github.com/rust-lang/rustfmt
cd rustfmt
git checkout 2d6a968d52b13b75fc3799f50020a34efd480a28
CFG_RELEASE=nightly CFG_RELEASE_CHANNEL=nightly cargo +master check 

Meta

rustc --version --verbose:
rustc is @ 6bdae9e

rustc 1.49.0-nightly (6bdae9edd 2020-10-29)
binary: rustc
commit-hash: 6bdae9edd0cc099daa6038bca469dc09b6fc078a
commit-date: 2020-10-29
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

    Checking rustc-ap-rustc_ast_passes v686.0.0
    Checking rustc-ap-rustc_expand v686.0.0
error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/_match.rs:934:18: trying to compare incompatible constructors Single and Str(Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [109, 97, 120, 95, 119, 105, 100, 116, 104], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [511], len: Size { raw: 9 } }, size: Size { raw: 9 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 9 }) })

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0-nightly (6bdae9edd 2020-10-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_match] match-checking `config::ConfigSetter::<'a>::max_width`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `rustfmt-nightly`

To learn more, run the command again with --verbose.
Backtrace

error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/_match.rs:934:18: trying to compare incompatible constructors Single and Str(Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [109, 97, 120, 95, 119, 105, 100, 116, 104], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [511], len: Size { raw: 9 } }, size: Size { raw: 9 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 9 }) })

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
   0:     0x7f440e94a5f0 - std::backtrace_rs::backtrace::libunwind::trace::h448c56741b6011d3
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
   1:     0x7f440e94a5f0 - std::backtrace_rs::backtrace::trace_unsynchronized::h881b9d30a8a89a0c
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f440e94a5f0 - std::sys_common::backtrace::_print_fmt::h720a2f61f75b9f58
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f440e94a5f0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8d62bbfda6d5c836
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f440e9ba52c - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f440e93c252 - std::io::Write::write_fmt::h16a9fe7680ac245c
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/io/mod.rs:1518:15
   6:     0x7f440e94f5a5 - std::sys_common::backtrace::_print::h9ba51a6db618de7d
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f440e94f5a5 - std::sys_common::backtrace::print::h5f20e41c85e91716
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f440e94f5a5 - std::panicking::default_hook::{{closure}}::h8d48653392f3b04c
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/panicking.rs:208:50
   9:     0x7f440e94f248 - std::panicking::default_hook::hb3948d1f74b6ff4c
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/panicking.rs:227:9
  10:     0x7f440f218988 - rustc_driver::report_ice::h1ddbc5609a6e1f37
  11:     0x7f43ffdb18d6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd2c74aab54599340
                               at /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1321:9
  12:     0x7f43ffdcff6b - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h364b0f4905eb955d
                               at /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7f440e94fea6 - std::panicking::rust_panic_with_hook::h55d23fef0ad751bc
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/panicking.rs:597:17
  14:     0x7f441221414d - std::panicking::begin_panic::{{closure}}::h4b123e1d8e3ae463
  15:     0x7f4412214086 - std::sys_common::backtrace::__rust_end_short_backtrace::ha21fec08f03d728b
  16:     0x7f441221411f - std::panicking::begin_panic::hc0c81fab1e0acd00
  17:     0x7f4412226080 - rustc_errors::HandlerInner::bug::h26f9bc1a7147687e
  18:     0x7f4412224bd0 - rustc_errors::Handler::bug::h2149bffe74600666
  19:     0x7f4411c826d4 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::hb4ddd0d3902006f3
  20:     0x7f4411c7c1fb - rustc_middle::ty::context::tls::with_opt::{{closure}}::ha7f81bc36cab3c9f
  21:     0x7f4411c7bbb2 - rustc_middle::ty::context::tls::with_opt::hf0c2c2aff96e53ba
  22:     0x7f4411c825f9 - rustc_middle::util::bug::opt_span_bug_fmt::hc7cbb029c2646db9
  23:     0x7f4411c8256e - rustc_middle::util::bug::bug_fmt::hb51c412c48cda8bb
  24:     0x7f4410445238 - rustc_mir_build::thir::pattern::_match::Matrix::specialize_constructor::h36673621382da348
  25:     0x7f441040d98a - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold::h8ec38e56f7f75922
  26:     0x7f441044aded - rustc_mir_build::thir::pattern::_match::is_useful::hf8efd6153416cf2d
  27:     0x7f44103df5f8 - <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h865c9f6d42685550
  28:     0x7f44103df27c - <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h865c9f6d42685550
  29:     0x7f44103e83fb - rustc_hir::intravisit::walk_expr::hd0093ab50ae5a8d4
  30:     0x7f44103df27c - <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h865c9f6d42685550
  31:     0x7f44103df27c - <rustc_mir_build::thir::pattern::check_match::MatchVisitor as rustc_hir::intravisit::Visitor>::visit_expr::h865c9f6d42685550
  32:     0x7f44103defa3 - rustc_mir_build::thir::pattern::check_match::check_match::h2d5b60d42651dc41
  33:     0x7f440f46b9c9 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_match>::compute::h3dd4584521cdb95e
  34:     0x7f440f40b1da - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h95dd3718ab01c33b
  35:     0x7f440f3d0bc9 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h0352e09bc9ab8a0b
  36:     0x7f440f436ce4 - rustc_data_structures::stack::ensure_sufficient_stack::h3626f02a47d49f69
  37:     0x7f440f3c74b8 - rustc_query_system::query::plumbing::get_query_impl::hfaed35f7e6414273
  38:     0x7f440f3c8832 - rustc_query_system::query::plumbing::ensure_query_impl::ha7327a13b80a3079
  39:     0x7f440f467a79 - rustc_interface::passes::analysis::h78326215bfd650a0
  40:     0x7f440f25791b - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::hf8d4bc54d08537f3
  41:     0x7f440f19d838 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hcb29c3d8995d5298
  42:     0x7f440f237f24 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h6d03accb53ed1239
  43:     0x7f440f23419f - rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}::h947bb326d17d8606
  44:     0x7f440f1c1308 - rustc_query_system::query::plumbing::get_query_impl::h448d10ab90370983
  45:     0x7f440f25a9df - rustc_interface::passes::QueryContext::enter::hbf7a36e966e91449
  46:     0x7f440f235826 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h25b522245624a405
  47:     0x7f440f1f8eff - rustc_span::with_source_map::h7455fffe3cd153a4
  48:     0x7f440f2309c1 - scoped_tls::ScopedKey<T>::set::h8ae8151712a551fd
  49:     0x7f440f23b0f5 - std::sys_common::backtrace::__rust_begin_short_backtrace::h26de371bc27662fc
  50:     0x7f440f1a2b18 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h80d1a8eb7971174b
  51:     0x7f440e95eeaa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9e7afb7a0a438236
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/alloc/src/boxed.rs:1307:9
  52:     0x7f440e95eeaa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70c646c4271337a1
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/alloc/src/boxed.rs:1307:9
  53:     0x7f440e95eeaa - std::sys::unix::thread::Thread::new::thread_start::h35d2b8d36f210d02
                               at /rustc/6bdae9edd0cc099daa6038bca469dc09b6fc078a/library/std/src/sys/unix/thread.rs:89:17
  54:     0x7f440e85a3e9 - start_thread
  55:     0x7f440e777293 - __GI___clone
  56:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0-nightly (6bdae9edd 2020-10-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_match] match-checking `config::ConfigSetter::<'a>::max_width`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `rustfmt-nightly`

To learn more, run the command again with --verbose.

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 30, 2020
@camelid camelid added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Oct 30, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 30, 2020

Might be related to #78072 or #78430, cc @Nadrieril

@jyn514 jyn514 added the A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns label Oct 30, 2020
@Nadrieril
Copy link
Member

Ouch, this is indeed my fault. Reproducer:

fn main() {
    match "foo" {
        "foo" => {},
        &_ => {},
    }
}

@Nadrieril
Copy link
Member

Easy fix: replace &_ with _.
I know what's happening and how to fix it, but I'm investigating whether I might have missed other similar cases.

@camelid camelid added I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Oct 30, 2020
@camelid
Copy link
Member

camelid commented Oct 30, 2020

searched nightlies: from nightly-2020-10-28 to nightly-2020-10-30
regressed nightly: nightly-2020-10-30
searched commits: from 31ee872 to 6bdae9e
regressed commit: f9187ad

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-apple-darwin
Reproduce with:

cargo bisect-rustc --preserve --regress=ice --start=2020-10-28 

It was #78430.

@anp
Copy link
Member

anp commented Oct 30, 2020

I'm seeing a similar error when building [email protected] with rustc commit 388ef34:

 ../../prebuilt/third_party/rust/linux-x64/bin/rustc --color=always --crate-name trust_dns_proto ../../third_party/rust_crates/vendor/trust-dns-proto/src/lib.rs --crate-type rlib --emit=dep-info=obj/t...
error: internal compiler error: compiler/rustc_mir_build/src/thir/pattern/_match.rs:934:18: trying to compare incompatible constructors Single and Str(Const { ty: &str, val: Value(Slice { data: Alloca...

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0-nightly (388ef3490 2020-10-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dep-info-omit-d-target -Z allow-features= -Z panic_abort_tests -C linker=/b/s/w/ir/k/fuchsia/prebuilt/third_party/clang/linux-x64/bin/lld -C link-arg=--sysroot=gen/build/confi...

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_match] match-checking `<rr::rdata::caa::Property as std::convert::From<std::string::String>>::from`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@JohnTitor
Copy link
Member

Assigning P-critical as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@JohnTitor JohnTitor removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 31, 2020
@JohnTitor JohnTitor added the P-critical Critical priority label Oct 31, 2020
@Nadrieril
Copy link
Member

Nadrieril commented Nov 1, 2020

@JohnTitor The PR that fixes this is ready to be merged #78553

bors added a commit to rust-lang-ci/rust that referenced this issue Nov 1, 2020
Fix rust-lang#78549

Before rust-lang#78430, this worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. That PR however handles `&str` as a special case, and I did not anticipate patterns for the `&str` type other than string literals.
I am not very confident there are not other similar oversights left, but hopefully only `&str` was different enough to break my assumptions.

Fixes rust-lang#78549
@bors bors closed this as completed in 4cd3019 Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants