Skip to content

rustc panics on matching std::path::Path #55718

Closed
@Hakuyume

Description

@Hakuyume

Code:

use std::path::Path;

fn main() {
    let path = Path::new("foo");
    match path {
        Path::new("foo") => println!("foo"),
        Path::new("bar") => println!("bar"),
        _ => (),
    }
}

Expected result: print foo.
Actual result:

thread 'main' panicked at 'expected fn type', libcore/option.rs:1000:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

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/master/CONTRIBUTING.md#bug-reports

note: rustc 1.30.0 (da5f414c2 2018-10-24) running on x86_64-unknown-linux-gnu

Meta

rustc --version --verbose:

rustc 1.30.0 (da5f414c2 2018-10-24)
binary: rustc
commit-hash: da5f414c2c0bfe5198934493f04c676e2b23ff2e
commit-date: 2018-10-24
host: x86_64-unknown-linux-gnu
release: 1.30.0
LLVM version: 8.0

Backtrace:

thread 'main' panicked at 'expected fn type', libcore/option.rs:1000:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227                                                                                                                                                                                                      
   4: rustc::util::common::panic_hook                                                                                                                                                                                                        
   5: std::panicking::rust_panic_with_hook                                                                                                                                                                                                   
             at libstd/panicking.rs:481                                                                                                                                                                                                      
   6: std::panicking::continue_panic_fmt                                                                                                                                                                                                     
             at libstd/panicking.rs:391                                                                                                                                                                                                      
   7: rust_begin_unwind                                                                                                                                                                                                                      
             at libstd/panicking.rs:326                                                                                                                                                                                                      
   8: core::panicking::panic_fmt                                                                                                                                                                                                             
             at libcore/panicking.rs:77                                                                                                                                                                                                      
   9: core::option::expect_failed                                                                                                                                                                                                            
             at libcore/option.rs:1000                                                                                                                                                                                                       
  10: rustc_typeck::check::_match::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_pat_tuple_struct                                                                                                                                
  11: rustc_typeck::check::_match::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_pat_walk                                                                                                                                        
  12: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter                                                                                                                                                                        
  13: rustc_typeck::check::FnCtxt::check_expr_kind                                                                                                                                                                                           
  14: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs                                                                                                                                                                     
  15: rustc_typeck::check::FnCtxt::check_block_with_expected                                                                                                                                                                                 
  16: rustc_typeck::check::FnCtxt::check_expr_kind                                                                                                                                                                                           
  17: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs                                                                                                                                                                     
  18: rustc_typeck::check::FnCtxt::check_return_expr                                                                                                                                                                                         
  19: rustc_typeck::check::check_fn                                                                                                                                                                                                          
  20: rustc::ty::context::tls::with_related_context                                                                                                                                                                                          
  21: rustc::infer::InferCtxtBuilder::enter                                                                                                                                                                                                  
  22: rustc_typeck::check::typeck_tables_of                                                                                                                                                                                                  
  23: rustc::ty::query::__query_compute::typeck_tables_of                                                                                                                                                                                    
  24: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute                                                                                                 
  25: rustc::dep_graph::graph::DepGraph::with_task_impl                                                                                                                                                                                      
  26: rustc::ty::context::tls::with_related_context                                                                                                                                                                                          
  27: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job                                                                                                                                    
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query                                                                                                                                               
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query                                                                                                                                            
  30: rustc_typeck::check::typeck_item_bodies                                                                                                                                                                                                
  31: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_item_bodies<'tcx>>::compute                                                                                               
  32: rustc::dep_graph::graph::DepGraph::with_task_impl                                                                                                                                                                                      
  33: rustc::ty::context::tls::with_related_context
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  35: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  36: rustc_typeck::check_crate
  37: rustc::ty::context::tls::enter_context
  38: <std::thread::local::LocalKey<T>>::with
  39: rustc::ty::context::TyCtxt::create_and_enter
  40: rustc_driver::driver::compile_input
  41: rustc_driver::run_compiler_with_pool
  42: rustc_driver::driver::spawn_thread_pool
  43: rustc_driver::run_compiler
  44: <scoped_tls::ScopedKey<T>>::set
  45: syntax::with_globals
  46: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:103
  47: rustc_driver::run
  48: rustc_driver::main
  49: std::rt::lang_start::{{closure}}
  50: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  51: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:103
  52: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  53: main
  54: __libc_start_main
  55: <unknown>
query stack during panic:
#0 [typeck_tables_of] processing `main`
#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/master/CONTRIBUTING.md#bug-reports

note: rustc 1.30.0 (da5f414c2 2018-10-24) running on x86_64-unknown-linux-gnu

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions