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

Broke rustc while refactoring method args in async yolo code #97484

Closed
gilescope opened this issue May 28, 2022 · 1 comment · Fixed by #97542 or #97557
Closed

Broke rustc while refactoring method args in async yolo code #97484

gilescope opened this issue May 28, 2022 · 1 comment · Fixed by #97542 or #97557
Assignees
Labels
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gilescope
Copy link
Contributor

This happens with the latest nightly 2022-05-27 and 2022-05-14

Code

https://github.com/gilescope/dotsamatown/tree/broke-rustc

fn process_extrisic had 6 args and I was de-yoloing the code to have only 4 args when rustc got the right hump.

src/datasource.rs line 810, if I change that call to process_extrinsic to have the right number (and type) of arguments then rustc gets happy again:

                                let entity = process_extrisic(&relay_id,
                                      ex_slice,&extrinsic, DotUrl{ extrinsic: Some(i as u32), ..block_doturl.clone()}).await;

Sorry my yolo code broke rustc! I suspect it's pretty obvious what's broken. I don't think this is a subtle thing though I guess it probably is the fact that it's an async fn that helps brake it.

Error output

    Checking bevy_app v0.1.0 (/home/gilescope/git/bevy_webgl_template)
warning: unused import: `FlyCam`
  --> src/movement.rs:16:19
   |
16 | use bevy_flycam::{FlyCam, MovementSettings};
   |                   ^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `subxt::ClientBuilder`
  --> src/main.rs:30:5
   |
30 | use subxt::ClientBuilder;
   |     ^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_typeck/src/check/fn_ctxt/checks.rs:433:78
stack backtrace:
   0: rust_begin_unwind
             at /rustc/490324f7b29d5f1a1e063a563045d790091ed639/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/490324f7b29d5f1a1e063a563045d790091ed639/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/490324f7b29d5f1a1e063a563045d790091ed639/library/core/src/panicking.rs:48:5
   3: <alloc::vec::drain_filter::DrainFilter<rustc_typeck::check::fn_ctxt::arg_matrix::Error, <rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types::{closure#4}> as core::ops::drop::Drop>::drop
   4: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
   5: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
   6: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
   7: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
   8: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
   9: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  10: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  11: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_match
  12: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  13: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  14: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  15: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  16: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  17: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  18: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  19: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  20: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  21: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  22: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  23: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_match
  24: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  25: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  26: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  27: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  28: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  29: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  30: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_match
  31: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  32: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  33: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  34: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  35: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  36: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  37: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  38: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  39: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  40: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  41: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  42: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  43: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  44: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  45: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  46: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  47: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  48: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  49: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  50: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  51: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  52: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  53: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  54: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  55: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  56: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  57: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  58: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  59: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  60: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  61: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  62: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  63: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  64: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  65: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  66: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  67: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  68: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
  69: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  70: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  71: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  72: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  73: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  74: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  75: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  76: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  77: rustc_typeck::check::check::check_fn
  78: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_closure
  79: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  80: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_argument_types
  81: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  82: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  83: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  84: rustc_typeck::check::check::check_fn
  85: <rustc_infer::infer::InferCtxtBuilder>::enter::<&rustc_middle::ty::context::TypeckResults, <rustc_typeck::check::inherited::InheritedBuilder>::enter<rustc_typeck::check::typeck_with_fallback<rustc_typeck::check::typeck::{closure#0}>::{closure#1}, &rustc_middle::ty::context::TypeckResults>::{closure#0}>
  86: rustc_typeck::check::typeck
  87: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>
  88: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>
  89: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.63.0-nightly (490324f7b 2022-05-26) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C opt-level=1 -C embed-bitcode=no -C debuginfo=1 -C debug-assertions=on -C linker=clang -C incremental -Z share-generics=y

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

query stack during panic:
#0 [typeck] type-checking `datasource::watch_blocks`
#1 [mir_built] building MIR for `datasource::watch_blocks`
#2 [unsafety_check_result] unsafety-checking `datasource::watch_blocks`
#3 [mir_const] processing MIR for `datasource::watch_blocks`
#4 [mir_promoted] processing `datasource::watch_blocks`
#5 [mir_borrowck] borrow-checking `datasource::watch_blocks`
#6 [type_of] computing type of `datasource::watch_blocks::{opaque#0}`
#7 [check_mod_item_types] checking item types in module `datasource`
#8 [analysis] running analysis passes on this crate
end of query stack

@gilescope gilescope 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 28, 2022
@jackh726 jackh726 added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label May 28, 2022
@compiler-errors compiler-errors self-assigned this May 28, 2022
@compiler-errors
Copy link
Member

Minimized:

struct A;
struct B;
struct C;
struct D;
struct E;
struct F;
struct G;

fn foo(a: &A, d: D, e: &E, g: G) {}

fn main() {
    foo(&&A, B, C, D, E, F, G);
}

@compiler-errors compiler-errors removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label May 28, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 29, 2022
@bors bors closed this as completed in 1922f0b Jun 9, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 29, 2022
…kh726

Use typed indices in argument mismatch algorithm

I kinda went overboard with the renames, but in general, "arg" is renamed to "expected", and "input" is renamed to "provided", and we use new typed indices to make sure we're indexing into the right sized array.

Other drive-by changes:
1. Factor this logic into a new function, so we don't need to `break 'label` to escape it.
1. Factored out dependence on `final_arg_types`, which is never populated for arguments greater than the number of expected args. Instead, we just grab the final coerced expression type from `in_progress_typeck_results`.
1. Adjust the criteria we use to print (provided) type names, before we didn't suggest anything that had infer vars, but now we suggest thing that have infer vars but aren't `_`.

~Also, sorry in advance, I kinda want to backport this but I know I have folded in a lot of unnecessary drive-by changes that might discourage that. I would be open to brainstorming how to get some of these changes on beta at least.~ edit: Minimized the ICE-fixing changes to rust-lang#97557

cc `@jackh726` as author of rust-lang#92364, and `@estebank` as reviewer of the PR.
fixes rust-lang#97484
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. glacier ICE tracked in rust-lang/glacier. 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
4 participants