Closed
Description
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