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 tuple struct pattern #60635

Closed
hellow554 opened this issue May 8, 2019 · 3 comments · Fixed by #60641
Closed

ICE on tuple struct pattern #60635

hellow554 opened this issue May 8, 2019 · 3 comments · Fixed by #60641
Assignees
Labels
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.

Comments

@hellow554
Copy link
Contributor

hellow554 commented May 8, 2019

use std::ffi::OsStr;
use std::path::Component;

pub fn panic_with_msgbox<'a, I: Iterator<Item = Component<'a>>>(a: I) -> bool {
    a.any(|c| match c {
        Component::Normal(OsStr::new("src")) => true,
//        Component::Normal(&OsStr::new("src")) => true,
        _ => false,
    })
}
error: internal compiler error: src/librustc/middle/mem_categorization.rs:1298: tuple struct pattern didn't resolve to variant or struct Method(DefId(1/0:1293 ~ std[9302]::ffi[0]::os_str[0]::{{impl}}[17]::new[0]))
  --> src/lib.rs:14:45
   |
14 |     a.any(|c| matches!(c, Component::Normal(OsStr::new("src"))))
   |                                             ^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:571:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_
  15: rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_
  16: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
  17: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
  18: rustc_typeck::check::upvar::<impl rustc_typeck::check::FnCtxt>::analyze_closure
  19: rustc::hir::intravisit::walk_expr
  20: rustc_typeck::check::upvar::<impl rustc_typeck::check::FnCtxt>::closure_analyze
  21: rustc::ty::context::GlobalCtxt::enter_local
  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 for rustc::ty::query::queries::typeck_tables_of>::compute
  25: rustc::dep_graph::graph::DepGraph::with_task_impl
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  27: rustc::ty::query::__query_compute::typeck_tables_of
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  32: rustc_typeck::check::typeck_item_bodies
  33: rustc::ty::query::__query_compute::typeck_item_bodies
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_item_bodies>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: rustc::util::common::time
  38: rustc_typeck::check_crate
  39: rustc_interface::passes::analysis
  40: rustc::ty::query::__query_compute::analysis
  41: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  42: rustc::dep_graph::graph::DepGraph::with_task_impl
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  44: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  45: rustc_interface::passes::create_global_ctxt::{{closure}}
  46: rustc_interface::passes::BoxedGlobalCtxt::enter
  47: rustc_interface::interface::run_compiler_in_existing_thread_pool
  48: std::thread::local::LocalKey<T>::with
  49: scoped_tls::ScopedKey<T>::set
  50: syntax::with_globals
query stack during panic:
#0 [typeck_tables_of] processing `panic_with_msgbox`
#1 [typeck_tables_of] processing `panic_with_msgbox::{{closure}}#0`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

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

note: rustc 1.36.0-nightly (e305df184 2019-04-24) running on x86_64-unknown-linux-gnu

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

This one is very interesting IMHO.
The "original" ICE was introduced between 056f589...4b9b70c, but if I prepend the & before OsStr (the outcommented line), there's a second ICE that is there forever (at least since Rust 1.11).

@rustbot modify labels: I-ICE C-bug

@hellow554
Copy link
Contributor Author

hellow554 commented May 8, 2019

@rustbot modify labels: I-ICE C-bug T-compiler

(seems that I cannot ping rustbot from the thread start itself)

@rustbot rustbot 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 May 8, 2019
@Centril
Copy link
Contributor

Centril commented May 8, 2019

Reduced:

struct A {}

impl A {
    fn new() {}
}

fn hof<F>(_: F) where F: FnMut(()) {}

fn ice() {
    hof(|c| match c {
        A::new() => (),
        _ => ()
    })
}

@Centril
Copy link
Contributor

Centril commented May 8, 2019

This issue exists all the way back to at least 1.7.0.

@estebank estebank self-assigned this May 8, 2019
Centril added a commit to Centril/rust that referenced this issue May 8, 2019
Instead of ICEing on incorrect pattern, use delay_span_bug

Fix rust-lang#60635.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants