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

Closure type error during const-eval (array len context) #66706

Closed
DutchGhost opened this issue Nov 24, 2019 · 9 comments · Fixed by #70452
Closed

Closure type error during const-eval (array len context) #66706

DutchGhost opened this issue Nov 24, 2019 · 9 comments · Fixed by #70452
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Nov 24, 2019

The following code ICE's on stable, beta and nightly

fn bug() {
    [0; [|f @ &ref _| {} ; 0 ].len() ];
}
Backtrace:
error: expected identifier, found reserved identifier `_`
 --> src/lib.rs:3:20
  |
3 |     [0; [|f @ &ref _| {} ; 0 ].len() ];
  |                    ^ expected identifier, found reserved identifier

error: internal compiler error: src/librustc_mir/hair/cx/expr.rs:518: closure expr w/o closure type: [type error]
 --> src/lib.rs:3:10
  |
3 |     [0; [|f @ &ref _| {} ; 0 ].len() ];
  |          ^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:851:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1030
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:188
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:205
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:468
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::span_bug
  14: rustc_errors::Handler::span_bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::span_bug_fmt
  20: rustc_mir::hair::cx::expr::make_mirror_unadjusted
  21: rustc_mir::hair::cx::expr::<impl rustc_mir::hair::Mirror for &rustc::hir::Expr>::make_mirror
  22: <rustc_mir::hair::ExprRef as rustc_mir::hair::Mirror>::make_mirror
  23: rustc_mir::build::expr::as_rvalue::<impl rustc_mir::build::Builder>::expr_as_rvalue
  24: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  25: rustc_mir::build::expr::as_temp::<impl rustc_mir::build::Builder>::expr_as_temp
  26: rustc_mir::build::expr::as_place::<impl rustc_mir::build::Builder>::expr_as_place
  27: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  28: rustc_mir::build::expr::as_temp::<impl rustc_mir::build::Builder>::expr_as_temp
  29: rustc_mir::build::expr::as_operand::<impl rustc_mir::build::Builder>::expr_as_operand
  30: rustc_mir::build::expr::as_rvalue::<impl rustc_mir::build::Builder>::expr_as_rvalue
  31: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  32: rustc_mir::build::expr::as_temp::<impl rustc_mir::build::Builder>::expr_as_temp
  33: rustc_mir::build::expr::as_operand::<impl rustc_mir::build::Builder>::expr_as_operand
  34: rustc_mir::build::expr::as_operand::<impl rustc_mir::build::Builder>::expr_as_operand
  35: rustc_mir::build::expr::as_operand::<impl rustc_mir::build::Builder>::as_local_operand
  36: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  37: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  38: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  39: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  40: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  41: rustc_mir::build::construct_const
  42: rustc::ty::context::tls::with_context::{{closure}}
  43: rustc_mir::build::mir_build
  44: rustc_mir::transform::mir_built
  45: rustc::ty::query::__query_compute::mir_built
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  47: rustc_mir::transform::check_unsafety::unsafety_check_result
  48: rustc::ty::query::__query_compute::unsafety_check_result
  49: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  50: rustc_mir::transform::mir_const
  51: rustc::ty::query::__query_compute::mir_const
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  53: rustc_mir::transform::mir_const_qualif
  54: rustc::ty::query::__query_compute::mir_const_qualif
  55: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  56: rustc_mir::transform::mir_validated
  57: rustc::ty::query::__query_compute::mir_validated
  58: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  59: rustc_mir::borrow_check::mir_borrowck
  60: rustc::ty::query::__query_compute::mir_borrowck
  61: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  62: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  63: rustc_mir::transform::optimized_mir
  64: rustc::ty::query::__query_compute::optimized_mir
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  66: rustc_mir::interpret::eval_context::InterpCx<M>::load_mir
  67: rustc_mir::const_eval::const_eval_raw_provider
  68: rustc::ty::query::__query_compute::const_eval_raw
  69: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  70: rustc_mir::const_eval::const_eval_provider
  71: rustc::ty::query::__query_compute::const_eval
  72: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  73: rustc::dep_graph::graph::DepGraph::with_task_impl
  74: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  75: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  76: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  77: rustc_typeck::check::FnCtxt::check_stmt
  78: rustc_typeck::check::FnCtxt::check_block_with_expected
  79: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  80: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  81: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  82: rustc_typeck::check::check_fn
  83: rustc::ty::context::tls::with_context::{{closure}}
  84: rustc_typeck::check::typeck_tables_of
  85: rustc::ty::query::__query_compute::typeck_tables_of
  86: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  87: rustc::dep_graph::graph::DepGraph::with_task_impl
  88: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  89: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  90: rustc_typeck::check::typeck_item_bodies
  91: rustc::ty::query::__query_compute::typeck_item_bodies
  92: rustc::dep_graph::graph::DepGraph::with_task_impl
  93: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  94: rustc::util::common::time
  95: rustc_typeck::check_crate
  96: rustc_interface::passes::analysis
  97: rustc::ty::query::__query_compute::analysis
  98: rustc::dep_graph::graph::DepGraph::with_task_impl
  99: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
 100: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
 101: rustc_interface::passes::create_global_ctxt::{{closure}}
 102: rustc_interface::passes::BoxedGlobalCtxt::enter
 103: rustc_interface::interface::run_compiler_in_existing_thread_pool
 104: std::thread::local::LocalKey<T>::with
 105: scoped_tls::ScopedKey<T>::set
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.41.0-nightly (0c987c5c0 2019-11-23) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [mir_built] processing `bug::{{constant}}#0`
#1 [unsafety_check_result] processing `bug::{{constant}}#0`
#2 [mir_const] processing `bug::{{constant}}#0`
#3 [mir_const_qualif] const checking `bug::{{constant}}#0`
#4 [mir_validated] processing `bug::{{constant}}#0`
#5 [mir_borrowck] processing `bug::{{constant}}#0`
#6 [optimized_mir] processing `bug::{{constant}}#0`
#7 [const_eval_raw] const-evaluating `bug::{{constant}}#0`
#8 [const_eval] const-evaluating + checking `bug::{{constant}}#0`
#9 [typeck_tables_of] processing `bug`
#10 [typeck_item_bodies] type-checking all item bodies
#11 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

@jonas-schievink jonas-schievink added A-coroutines Area: Coroutines 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. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Nov 24, 2019
@DutchGhost
Copy link
Contributor Author

@jonas-schievink , I experimented a little further. Generators are not needed anymore, so that label can be removed :)

@jonas-schievink jonas-schievink added I-nominated and removed A-coroutines Area: Coroutines labels Nov 24, 2019
@DutchGhost
Copy link
Contributor Author

DutchGhost commented Nov 24, 2019

Another version of this is:

fn bug() {
    [0; [|&_: _ &_| {}; 0 ].len()]
}

A quick look in Godbolt gives that this ICE's since 1.24

@hellow554
Copy link
Contributor

hellow554 commented Nov 25, 2019

You can omit that last 0 here (yeah.. saved 5 more bytes 🎉) ^^

fn bug() {
    [0; [|_: _ &_| ()].len()]
}

@pnkfelix pnkfelix changed the title Closure type error Closure type error during const-eval (array len context) Nov 28, 2019
@pnkfelix pnkfelix added A-const-eval Area: Constant evaluation (MIR interpretation) P-high High priority and removed I-nominated labels Nov 28, 2019
@DutchGhost
Copy link
Contributor Author

DutchGhost commented Nov 29, 2019

Posting here, since the code looks verry similar. However, the message from the ICE is different, but I guess they have the same cause? Feel free to move it to its own place if needed :)

fn bug() {
    [0; match [|f @ &ref _| () ] {} ]
}
Backtrace:

error: expected identifier, found reserved identifier `_`
 --> src/lib.rs:2:26
  |
2 |     [0; match [|f @ &ref _| () ] {} ]
  |                          ^ expected identifier, found reserved identifier

error[E0658]: `match` is not allowed in a `const`
 --> src/lib.rs:2:9
  |
2 |     [0; match [|f @ &ref _| () ] {} ]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: for more information, see https://github.com/rust-lang/rust/issues/49146
  = help: add `#![feature(const_if_match)]` to the crate attributes to enable

error: internal compiler error: src/librustc/ty/sty.rs:1815: `sequence_element_type` called on non-sequence value: [type error]

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:892:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1024
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:190
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:207
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:470
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc::ty::sty::<impl rustc::ty::TyS>::sequence_element_type
  21: rustc_mir::build::expr::as_rvalue::<impl rustc_mir::build::Builder>::expr_as_rvalue
  22: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  23: rustc_mir::build::expr::as_temp::<impl rustc_mir::build::Builder>::expr_as_temp
  24: rustc_mir::build::expr::as_place::<impl rustc_mir::build::Builder>::expr_as_place
  25: rustc_mir::build::expr::as_place::<impl rustc_mir::build::Builder>::expr_as_place
  26: rustc_mir::build::expr::as_place::<impl rustc_mir::build::Builder>::as_place
  27: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  28: rustc_mir::build::expr::as_temp::<impl rustc_mir::build::Builder>::expr_as_temp
  29: rustc_mir::build::expr::as_operand::<impl rustc_mir::build::Builder>::expr_as_operand
  30: rustc_mir::build::expr::as_rvalue::<impl rustc_mir::build::Builder>::expr_as_rvalue
  31: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  32: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  33: rustc_mir::build::expr::into::<impl rustc_mir::build::Builder>::into_expr
  34: rustc_mir::build::construct_const
  35: rustc::ty::context::tls::with_context::{{closure}}
  36: rustc_mir::build::mir_build
  37: rustc_mir::transform::mir_built
  38: rustc::ty::query::__query_compute::mir_built
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: rustc_mir::transform::check_unsafety::unsafety_check_result
  41: rustc::ty::query::__query_compute::unsafety_check_result
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  43: rustc_mir::transform::mir_const
  44: rustc::ty::query::__query_compute::mir_const
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  46: rustc_mir::transform::mir_const_qualif
  47: rustc::ty::query::__query_compute::mir_const_qualif
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  49: rustc_mir::transform::mir_validated
  50: rustc::ty::query::__query_compute::mir_validated
  51: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  52: rustc_mir::borrow_check::mir_borrowck
  53: rustc::ty::query::__query_compute::mir_borrowck
  54: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  55: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  56: rustc_mir::transform::optimized_mir
  57: rustc::ty::query::__query_compute::optimized_mir
  58: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  59: rustc_mir::interpret::eval_context::InterpCx<M>::load_mir
  60: rustc_mir::const_eval::const_eval_raw_provider
  61: rustc::ty::query::__query_compute::const_eval_raw
  62: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  63: rustc_mir::const_eval::const_eval_provider
  64: rustc::ty::query::__query_compute::const_eval
  65: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  66: rustc::dep_graph::graph::DepGraph::with_task_impl
  67: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  68: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  69: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  70: rustc_typeck::check::FnCtxt::check_block_with_expected
  71: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  72: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  73: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  74: rustc_typeck::check::check_fn
  75: rustc::ty::context::tls::with_context::{{closure}}
  76: rustc_typeck::check::typeck_tables_of
  77: rustc::ty::query::__query_compute::typeck_tables_of
  78: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  79: rustc::dep_graph::graph::DepGraph::with_task_impl
  80: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  81: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  82: rustc_typeck::check::typeck_item_bodies
  83: rustc::ty::query::__query_compute::typeck_item_bodies
  84: rustc::dep_graph::graph::DepGraph::with_task_impl
  85: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  86: rustc_typeck::check_crate
  87: rustc_interface::passes::analysis
  88: rustc::ty::query::__query_compute::analysis
  89: rustc::dep_graph::graph::DepGraph::with_task_impl
  90: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  91: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  92: rustc_interface::passes::create_global_ctxt::{{closure}}
  93: rustc_interface::passes::BoxedGlobalCtxt::enter
  94: rustc_interface::interface::run_compiler_in_existing_thread_pool
  95: std::thread::local::LocalKey<T>::with
  96: scoped_tls::ScopedKey<T>::set
  97: syntax::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.41.0-nightly (bbb664a99 2019-11-28) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [mir_built] processing `bug::{{constant}}#0`
#1 [unsafety_check_result] processing `bug::{{constant}}#0`
#2 [mir_const] processing `bug::{{constant}}#0`
#3 [mir_const_qualif] const checking `bug::{{constant}}#0`
#4 [mir_validated] processing `bug::{{constant}}#0`
#5 [mir_borrowck] processing `bug::{{constant}}#0`
#6 [optimized_mir] processing `bug::{{constant}}#0`
#7 [const_eval_raw] const-evaluating `bug::{{constant}}#0`
#8 [const_eval] const-evaluating + checking `bug::{{constant}}#0`
#9 [typeck_tables_of] processing `bug`
#10 [typeck_item_bodies] type-checking all item bodies
#11 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `playground`.

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

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 18, 2019
@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

We shouldn't be reaching MIR building in the first place due to the [type error], but for some reason, when it happens in an AnonConst, we don't bail on type errors. cc @oli-obk @varkor

@Alexendoo
Copy link
Member

Alexendoo commented Mar 25, 2020

Things changed slightly from 342c5f3:

No longer ICEs:

fn bug() {
    [0; [|f @ &ref _| {} ; 0 ].len() ];
}
fn bug() {
    [0; [|_: _ &_| ()].len()]
}

Still ICEs:

fn bug() {
    [0; [|&_: _ &_| {}; 0 ].len()]
}
fn bug() {
    [0; match [|f @ &ref _| () ] {} ]
}

@Centril
Copy link
Contributor

Centril commented Mar 25, 2020

@Alexendoo Would you be game to add the two cases no longer ICEing as tests in a PR?

@Alexendoo
Copy link
Member

Yeah no problem, I'll get on that tomorrow

Alexendoo added a commit to Alexendoo/rust that referenced this issue Mar 26, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 27, 2020
Add regression test for rust-lang#66706

Adds the two cases that no longer ICE (rust-lang#66706 (comment))
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 27, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#69644 (Remove framework in `dataflow/mod.rs` in favor of "generic" one)
 - rust-lang#69936 (Fix cycle error when emitting suggestion for mismatched `fn` type)
 - rust-lang#70048 (Allow obtaining &mut OsStr)
 - rust-lang#70344 (Decouple `rustc_hir::print` into `rustc_hir_pretty`)
 - rust-lang#70435 (Add regression test for rust-lang#66706)

Failed merges:

r? @ghost
@eddyb
Copy link
Member

eddyb commented Mar 27, 2020

I think the reason these doesn't ICE anymore is a bug, the ICE itself wasn't fixed.
I'm saying that because I've just triggered it with the first commit of #70452, which should cover most of the WF hole around constants right now.

I'm guessing what's happening is #69981 introduced a bug, hiding the ICEs, as some of these cases no longer fail during type-checking, but with my changes, they do again.


I've just looked at the debug log and this is fascinating: I believe what's happening is, because there are inference variables, this gets hit, but the TypeckTables are not marked as tainted:

match self.infcx.fully_resolve(&t) {
Ok(t) => self.infcx.tcx.erase_regions(&t),
Err(_) => {
debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t);
self.report_error(t);
self.tcx().types.err
}
}

So we end up with ty::Error types with no indication that there were errors.
I'll try to see how targeted of a fix I can make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority 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.

8 participants