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 with opaquely typed constant used in pattern #71042

Closed
Centril opened this issue Apr 11, 2020 · 3 comments · Fixed by #72572
Closed

ICE with opaquely typed constant used in pattern #71042

Centril opened this issue Apr 11, 2020 · 3 comments · Fixed by #72572
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-patterns Relating to patterns and pattern matching C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Apr 11, 2020

#![feature(impl_trait_in_bindings)]

fn main() {
    const C: impl Copy = 0;
    match C {
        C | _ => {}
    }
}

ICE message:

error: internal compiler error: src/librustc_mir_build/build/matches/test.rs:417:
    non_scalar_compare called on non-reference type: impl std::marker::Copy`
Backtrace
error: internal compiler error: src/librustc_mir_build/build/matches/test.rs:417: non_scalar_compare called on non-reference type: impl std::marker::Copy

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:880:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1504
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:515
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::bug_fmt
  20: rustc_mir_build::build::matches::test::<impl rustc_mir_build::build::Builder>::non_scalar_compare
  21: rustc_mir_build::build::matches::<impl rustc_mir_build::build::Builder>::match_simplified_candidates
  22: rustc_mir_build::build::matches::<impl rustc_mir_build::build::Builder>::match_candidates
  23: rustc_mir_build::build::matches::<impl rustc_mir_build::build::Builder>::lower_match_tree
  24: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr
  25: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr
  26: rustc_mir_build::build::block::<impl rustc_mir_build::build::Builder>::ast_block_stmts
  27: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr
  28: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr
  29: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::into_expr
  30: rustc_mir_build::build::construct_fn
  31: rustc_middle::ty::context::GlobalCtxt::enter_local
  32: rustc_mir_build::build::mir_built
  33: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_built>::compute
  34: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  35: rustc_query_system::query::plumbing::get_query
  36: rustc_mir::transform::check_unsafety::unsafety_check_result
  37: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::unsafety_check_result>::compute
  38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  39: rustc_query_system::query::plumbing::get_query
  40: rustc_mir::transform::mir_const
  41: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_const>::compute
  42: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  43: rustc_query_system::query::plumbing::get_query
  44: rustc_mir::transform::mir_validated
  45: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_validated>::compute
  46: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  47: rustc_query_system::query::plumbing::get_query
  48: rustc_mir::borrow_check::mir_borrowck
  49: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  50: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  51: rustc_query_system::query::plumbing::get_query
  52: rustc_query_system::query::plumbing::ensure_query
  53: rustc_session::utils::<impl rustc_session::session::Session>::time
  54: rustc_interface::passes::analysis
  55: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  56: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  57: rustc_query_system::query::plumbing::get_query
  58: rustc_middle::ty::context::tls::enter_global
  59: rustc_interface::interface::run_compiler_in_existing_thread_pool
  60: scoped_tls::ScopedKey<T>::set
  61: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.44.0-nightly (94d346360 2020-04-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

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

query stack during panic:
#0 [mir_built] building MIR for
#1 [unsafety_check_result] unsafety-checking `main`
#2 [mir_const] processing `main`
#3 [mir_validated] processing `main`
#4 [mir_borrowck] borrow-checking `main`
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `playground`.

To learn more, run the command again with --verbose.
@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` requires-nightly This issue requires a nightly compiler in some way. A-patterns Relating to patterns and pattern matching labels Apr 11, 2020
@Centril
Copy link
Contributor Author

Centril commented Apr 11, 2020

This should be erroring in exhaustiveness checking; ty::Opaque shouldn't be allowed there.

cc @oli-obk @eddyb @pnkfelix @ecstatic-morse

@eddyb
Copy link
Member

eddyb commented Apr 11, 2020

This should be erroring in exhaustiveness checking

It should be erroring earlier, when trying to create a pattern out of the constant.
And it should also not be considered structural-match type-wise.

@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Apr 11, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 16, 2020
@JohnTitor
Copy link
Member

Triage: This is no longer ICE, seems that it's fixed by #72153, marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 26, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue May 26, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 29, 2020
@bors bors closed this as completed in 89cb4d7 May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-patterns Relating to patterns and pattern matching C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. 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.

5 participants