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 on Beta when matching on not a tuple variant or struct #56235

Closed
moxian opened this issue Nov 26, 2018 · 8 comments
Closed

ICE on Beta when matching on not a tuple variant or struct #56235

moxian opened this issue Nov 26, 2018 · 8 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@moxian
Copy link
Contributor

moxian commented Nov 26, 2018

The following code on latest beta (rustc 1.31.0-beta.17 (1a4f1f3 2018-11-25))

use std::ffi::OsStr;

fn foo() {
    match Some(OsStr::new("1")) {
        Some(OsStr::new("2")) => (),
    }
}

results in ICE

backtrace
thread 'main' panicked at 'expected fn type', libcore\option.rs:1008:5
stack backtrace:
   0: <std::sync::mpsc::select::Select as core::fmt::Debug>::fmt
   1: <std::path::Iter<'a> as core::convert::AsRef<std::path::Path>>::as_ref
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty
::ToPredicate<'tcx>>::to_predicate
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::option::expect_failed
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <rustc_typeck::outlives::implicit_infer::IgnoreSelfTy as core::fmt::Debug>
::fmt
  15: <rustc_typeck::check::method::suggest::TraitInfo as core::cmp::PartialOrd>
::partial_cmp
  16: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::Ast
Conv<'gcx, 'tcx>>::record_ty
  17: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::Ast
Conv<'gcx, 'tcx>>::record_ty
  18: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::Ast
Conv<'gcx, 'tcx>>::record_ty
  19: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::Ast
Conv<'gcx, 'tcx>>::record_ty
  20: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::Ast
Conv<'gcx, 'tcx>>::record_ty
  21: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::Ast
Conv<'gcx, 'tcx>>::record_ty
  22: <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::i
ntravisit::Visitor<'gcx>>::visit_pat
  23: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fm
t::Debug>::fmt
  24: <rustc_typeck::check::method::probe::ProbeScope as core::fmt::Debug>::fmt
  25: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::iteml
ikevisit::ItemLikeVisitor<'tcx>>::visit_item
  26: <rustc::traits::query::outlives_bounds::OutlivesBound<'a> as rustc::ty::co
ntext::Lift<'tcx>>::lift_to_tcx
  27: <rustc::traits::query::outlives_bounds::OutlivesBound<'a> as rustc::ty::co
ntext::Lift<'tcx>>::lift_to_tcx
  28: rustc::ty::context::tls::track_diagnostic
  29: rustc::dep_graph::graph::DepGraph::assert_ignored
  30: rustc::ty::adjustment::<impl core::convert::From<rustc::ty::adjustment::Au
toBorrowMutability> for rustc::hir::Mutability>::from
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tc
x>>::try_print_query_stack
  32: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tc
x>>::try_print_query_stack
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tc
x>>::try_print_query_stack
  34: <rustc_typeck::check::PathSeg as core::fmt::Debug>::fmt
  35: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::iteml
ikevisit::ItemLikeVisitor<'tcx>>::visit_item
  36: <rustc::traits::query::outlives_bounds::OutlivesBound<'a> as rustc::ty::co
ntext::Lift<'tcx>>::lift_to_tcx
  37: rustc::ty::context::tls::track_diagnostic
  38: rustc::dep_graph::graph::DepGraph::assert_ignored
  39: rustc::ty::adjustment::<impl core::convert::From<rustc::ty::adjustment::Au
toBorrowMutability> for rustc::hir::Mutability>::from
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tc
x>>::try_print_query_stack
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tc
x>>::try_print_query_stack
  42: rustc_typeck::check_crate
  43: <rustc_driver::pretty::IdentifiedAnnotation<'hir> as rustc_driver::pretty:
:HirPrinterSupport<'hir>>::sess
  44: <rustc_driver::pretty::IdentifiedAnnotation<'hir> as rustc_driver::pretty:
:HirPrinterSupport<'hir>>::sess
  45: <rustc_driver::pretty::IdentifiedAnnotation<'hir> as rustc_driver::pretty:
:HirPrinterSupport<'hir>>::sess
  46: rustc_driver::driver::compile_input
  47: rustc_driver::run_compiler
  48: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  49: rustc_driver::run_compiler
  50: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  51: _rust_maybe_catch_panic
  52: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  53: rustc_driver::main
  54: <unknown>
  55: std::panicking::update_panic_count
  56: _rust_maybe_catch_panic
  57: std::rt::lang_start_internal
  58: <unknown>
  59: <unknown>
  60: BaseThreadInitThunk
  61: RtlUserThreadStart
query stack during panic:
#0 [typeck_tables_of] processing `foo`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack

error: internal compiler error: unexpected panic

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

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

note: rustc 1.31.0-beta.17 (1a4f1f398 2018-11-25) running on x86_64-pc-windows-m
svc

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

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

error: Could not compile `osstring`.

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

Latest nightly (rustc 1.32.0-nightly (6acbb5b 2018-11-25)) does not result in ICE.

error[E0164]: expected tuple struct/variant, found method `<OsStr>::new`
 --> src\lib.rs:5:14
  |
5 |         Some(OsStr::new("2")) => (),
  |              ^^^^^^^^^^^^^^^ not a tuple variant or struct

error: aborting due to previous error

For more information about this error, try `rustc --explain E0164`.
error: Could not compile `osstring`.

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

I would guess whatever fix there was in nightly should be backported to beta/stable as well.

P.s: is not a problem on 1.29.0 stable. Is a problem on 1.30.1

@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Nov 26, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2018

I'm guessing #55742 needs a backport

@moxian
Copy link
Contributor Author

moxian commented Nov 26, 2018

Re:tags: This is a regression both from stable to beta and from stable to stable. IOW, the bug is present in current 1.30.1 stable (but was not in 1.29.0).

@nikomatsakis
Copy link
Contributor

@oli-obk that PR appears to have been included in #55803, no?

@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2018

Not sure I understand. #55803 is a rollup PR that merged #55742, true, but I don't see how the rollup relates to this issue.

@nikomatsakis
Copy link
Contributor

@oli-obk I'm just confused why that PR is not already backported to beta. But I agree it is not (was just checking).

@nikomatsakis
Copy link
Contributor

Oh, sorry, I was reading #55803 was "beta backport rollup", but it's just an ordinary rollup. OK.

@nikomatsakis
Copy link
Contributor

Created #56240 with a backport

@pietroalbini pietroalbini added this to the Rust 2018 Release milestone Nov 26, 2018
@petrochenkov
Copy link
Contributor

Fixed in #56240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

6 participants