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 in 1.60.0-beta.1: thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1160:9 #94291

Closed
edmorley opened this issue Feb 23, 2022 · 5 comments
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.
Milestone

Comments

@edmorley
Copy link
Contributor

edmorley commented Feb 23, 2022

Code

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8246316eaa144bdcfc3f421aa56fd785

use std::collections::VecDeque;

pub struct BuildPlanBuilder {
    acc: VecDeque<(String, String)>,
    current_provides: String,
    current_requires: String,
}

impl BuildPlanBuilder {
    pub fn or(&mut self) -> &mut Self {
        self.acc
            .push_back(self.current_provides, self.current_requires);
        // ...
        self
    }
}

Note: In the example above, there are parens missing around the tuple being passed to .push_back(), which once added in, resolves the ICE.

Meta

rustc --version --verbose:

rustc 1.60.0-beta.1 (0a4f984a8 2022-02-22)
binary: rustc
commit-hash: 0a4f984a87c7ba6c74ec3e78442fec955a419e32
commit-date: 2022-02-22
host: x86_64-apple-darwin
release: 1.60.0-beta.1
LLVM version: 14.0.0

This also reproduces using nightly on playground:
rustc 1.61.0-nightly (68369a041 2022-02-22) running on x86_64-unknown-linux-gnu

Error output

$ cargo check
...
error: internal compiler error: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs:318:26: while adjusting Expr { hir_id: HirId { owner: DefId(0:11 ~ testcase[ccae]::{impl#0}::or), local_id: 8 }, kind: Path(Resolved(None, Path { span: src/main.rs:12:24: 12:28 (#0), res: Local(HirId { owner: DefId(0:11 ~ testcase[ccae]::{impl#0}::or), local_id: 2 }), segments: [PathSegment { ident: self#0, hir_id: Some(HirId { owner: DefId(0:11 ~ testcase[ccae]::{impl#0}::or), local_id: 7 }), res: Some(Local(HirId { owner: DefId(0:11 ~ testcase[ccae]::{impl#0}::or), local_id: 2 })), args: None, infer_args: true }] })), span: src/main.rs:12:24: 12:28 (#0) }, can't compose [Deref(None) -> BuildPlanBuilder] and [Deref(None) -> BuildPlanBuilder]

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1160:9
Backtrace

stack backtrace:
   0:        0x101ec0931 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2c6bfa9583f55670
   1:        0x101f1673b - core::fmt::write::h7b8221f61225c332
   2:        0x101eb1ade - std::io::Write::write_fmt::hc0333143931a574a
   3:        0x101ec4cb0 - std::panicking::default_hook::{{closure}}::h7dd014f3aae9b77c
   4:        0x101ec4994 - std::panicking::default_hook::ha78dd79e768f2753
   5:        0x112ce6e2a - rustc_driver[29a75661ecaf6b4c]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x101ec557c - std::panicking::rust_panic_with_hook::h0630d39009e15b1a
   7:        0x117488c47 - std[7f8020145a6ee860]::panicking::begin_panic::<rustc_errors[433cd6a44670cdf3]::ExplicitBug>::{closure#0}
   8:        0x117488bf9 - std[7f8020145a6ee860]::sys_common::backtrace::__rust_end_short_backtrace::<std[7f8020145a6ee860]::panicking::begin_panic<rustc_errors[433cd6a44670cdf3]::ExplicitBug>::{closure#0}, !>
   9:        0x1177c7531 - std[7f8020145a6ee860]::panicking::begin_panic::<rustc_errors[433cd6a44670cdf3]::ExplicitBug>
  10:        0x1174c1420 - std[7f8020145a6ee860]::panic::panic_any::<rustc_errors[433cd6a44670cdf3]::ExplicitBug>
  11:        0x1174be51f - <rustc_errors[433cd6a44670cdf3]::HandlerInner>::bug
  12:        0x1174bc651 - <rustc_errors[433cd6a44670cdf3]::Handler>::bug
  13:        0x1171a58e4 - rustc_middle[3c29833e5b151737]::ty::context::tls::with_opt::<rustc_middle[3c29833e5b151737]::util::bug::opt_span_bug_fmt<rustc_span[546498272619ff06]::span_encoding::Span>::{closure#0}, ()>
  14:        0x1171a597b - rustc_middle[3c29833e5b151737]::util::bug::opt_span_bug_fmt::<rustc_span[546498272619ff06]::span_encoding::Span>
  15:        0x1177b7206 - rustc_middle[3c29833e5b151737]::util::bug::bug_fmt
  16:        0x115887e28 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::apply_adjustments
  17:        0x115841dfa - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_field
  18:        0x11583b3b5 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:        0x11584b7c9 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_argument_types
  20:        0x11584a25c - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_method_argument_types
  21:        0x115884dd3 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_expr_kind
  22:        0x11583b3b5 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:        0x11584f30c - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_stmt
  24:        0x11584fc97 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  25:        0x11583b3b5 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:        0x11583c176 - <rustc_typeck[18c6c2d659b9fd2e]::check::fn_ctxt::FnCtxt>::check_return_expr
  27:        0x115a91d14 - rustc_typeck[18c6c2d659b9fd2e]::check::check::check_fn
  28:        0x115979cb4 - <rustc_infer[6184ae6860a61da1]::infer::InferCtxtBuilder>::enter::<&rustc_middle[3c29833e5b151737]::ty::context::TypeckResults, <rustc_typeck[18c6c2d659b9fd2e]::check::inherited::InheritedBuilder>::enter<rustc_typeck[18c6c2d659b9fd2e]::check::typeck_with_fallback<rustc_typeck[18c6c2d659b9fd2e]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[3c29833e5b151737]::ty::context::TypeckResults>::{closure#0}>
  29:        0x1159243ed - rustc_typeck[18c6c2d659b9fd2e]::check::typeck
  30:        0x1165e2839 - <rustc_query_system[2bc9e46b7784aabd]::dep_graph::graph::DepGraph<rustc_middle[3c29833e5b151737]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[3c29833e5b151737]::ty::context::TyCtxt, rustc_span[546498272619ff06]::def_id::LocalDefId, &rustc_middle[3c29833e5b151737]::ty::context::TypeckResults>
  31:        0x116766c22 - rustc_data_structures[1faf00faa2f06afe]::stack::ensure_sufficient_stack::<(&rustc_middle[3c29833e5b151737]::ty::context::TypeckResults, rustc_query_system[2bc9e46b7784aabd]::dep_graph::graph::DepNodeIndex), rustc_query_system[2bc9e46b7784aabd]::query::plumbing::execute_job<rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt, rustc_span[546498272619ff06]::def_id::LocalDefId, &rustc_middle[3c29833e5b151737]::ty::context::TypeckResults>::{closure#3}>
  32:        0x1163a18da - rustc_query_system[2bc9e46b7784aabd]::query::plumbing::try_execute_query::<rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt, rustc_query_system[2bc9e46b7784aabd]::query::caches::DefaultCache<rustc_span[546498272619ff06]::def_id::LocalDefId, &rustc_middle[3c29833e5b151737]::ty::context::TypeckResults>>
  33:        0x116490d6e - rustc_query_system[2bc9e46b7784aabd]::query::plumbing::get_query::<rustc_query_impl[7ede96447151a31d]::queries::typeck, rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt>
  34:        0x1159d8a28 - <rustc_middle[3c29833e5b151737]::hir::map::Map>::par_body_owners::<rustc_typeck[18c6c2d659b9fd2e]::check::typeck_item_bodies::{closure#0}>
  35:        0x1159290c5 - rustc_typeck[18c6c2d659b9fd2e]::check::typeck_item_bodies
  36:        0x116627208 - <rustc_query_system[2bc9e46b7784aabd]::dep_graph::graph::DepGraph<rustc_middle[3c29833e5b151737]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[3c29833e5b151737]::ty::context::TyCtxt, (), ()>
  37:        0x11676b987 - rustc_data_structures[1faf00faa2f06afe]::stack::ensure_sufficient_stack::<((), rustc_query_system[2bc9e46b7784aabd]::dep_graph::graph::DepNodeIndex), rustc_query_system[2bc9e46b7784aabd]::query::plumbing::execute_job<rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt, (), ()>::{closure#3}>
  38:        0x1163fc301 - rustc_query_system[2bc9e46b7784aabd]::query::plumbing::try_execute_query::<rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt, rustc_query_system[2bc9e46b7784aabd]::query::caches::DefaultCache<(), ()>>
  39:        0x116470b48 - rustc_query_system[2bc9e46b7784aabd]::query::plumbing::get_query::<rustc_query_impl[7ede96447151a31d]::queries::typeck_item_bodies, rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt>
  40:        0x11593c811 - <rustc_session[313880d72d209f1e]::session::Session>::time::<(), rustc_typeck[18c6c2d659b9fd2e]::check_crate::{closure#7}>
  41:        0x115918f88 - rustc_typeck[18c6c2d659b9fd2e]::check_crate
  42:        0x112df171a - rustc_interface[fc3b1e0a542d811d]::passes::analysis
  43:        0x11661a56c - <rustc_query_system[2bc9e46b7784aabd]::dep_graph::graph::DepGraph<rustc_middle[3c29833e5b151737]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[3c29833e5b151737]::ty::context::TyCtxt, (), core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>
  44:        0x11675c985 - rustc_data_structures[1faf00faa2f06afe]::stack::ensure_sufficient_stack::<(core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>, rustc_query_system[2bc9e46b7784aabd]::dep_graph::graph::DepNodeIndex), rustc_query_system[2bc9e46b7784aabd]::query::plumbing::execute_job<rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt, (), core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>::{closure#3}>
  45:        0x1163f0792 - rustc_query_system[2bc9e46b7784aabd]::query::plumbing::try_execute_query::<rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt, rustc_query_system[2bc9e46b7784aabd]::query::caches::DefaultCache<(), core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>>
  46:        0x116491165 - rustc_query_system[2bc9e46b7784aabd]::query::plumbing::get_query::<rustc_query_impl[7ede96447151a31d]::queries::analysis, rustc_query_impl[7ede96447151a31d]::plumbing::QueryCtxt>
  47:        0x112cd8ef6 - <rustc_interface[fc3b1e0a542d811d]::passes::QueryContext>::enter::<rustc_driver[29a75661ecaf6b4c]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>
  48:        0x112c86488 - rustc_interface[fc3b1e0a542d811d]::interface::create_compiler_and_run::<core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>, rustc_driver[29a75661ecaf6b4c]::run_compiler::{closure#1}>
  49:        0x112c6b1af - std[7f8020145a6ee860]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[fc3b1e0a542d811d]::util::run_in_thread_pool_with_globals<rustc_interface[fc3b1e0a542d811d]::interface::run_compiler<core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>, rustc_driver[29a75661ecaf6b4c]::run_compiler::{closure#1}>::{closure#0}, core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>::{closure#0}, core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>
  50:        0x112cf0951 - <<std[7f8020145a6ee860]::thread::Builder>::spawn_unchecked_<rustc_interface[fc3b1e0a542d811d]::util::run_in_thread_pool_with_globals<rustc_interface[fc3b1e0a542d811d]::interface::run_compiler<core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>, rustc_driver[29a75661ecaf6b4c]::run_compiler::{closure#1}>::{closure#0}, core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>::{closure#0}, core[865dbc4a436edfcf]::result::Result<(), rustc_errors[433cd6a44670cdf3]::ErrorReported>>::{closure#1} as core[865dbc4a436edfcf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:        0x101ed2ba7 - std::sys::unix::thread::Thread::new::thread_start::ha11ef5e652bceddf
  52:     0x7ff81aaa84f4 - __pthread_start

query stack during panic:
#0 [typeck] type-checking `<impl at src/main.rs:9:1: 16:2>::or`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

@edmorley edmorley 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 Feb 23, 2022
@edmorley edmorley changed the title ICE in 1.60.0-beta.1 thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1160:9 ICE in 1.60.0-beta.1: thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1160:9 Feb 23, 2022
@ouz-a
Copy link
Contributor

ouz-a commented Feb 25, 2022

@rustbot claim

@terrarier2111
Copy link
Contributor

terrarier2111 commented Feb 25, 2022

@ouz-a

Sorry, that i didn't claim this before,
I found a fix for this, should I create a pr for it, or do you wanna fix this?

@ouz-a
Copy link
Contributor

ouz-a commented Feb 25, 2022

@terrarier2111

I am just about to open my pull request

@terrarier2111
Copy link
Contributor

I am just about to open my pull request

Oh, okay

terrarier2111 added a commit to terrarier2111/rust that referenced this issue Feb 25, 2022
@Mark-Simulacrum Mark-Simulacrum added this to the 1.60.0 milestone Feb 25, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 25, 2022
Add one more case to avoid ICE

Fix for the  rust-lang#94291, added one more case to related function to avoid ICE.

Not sure if my test is in the correct place 😅
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 25, 2022
Add one more case to avoid ICE

Fix for the  rust-lang#94291, added one more case to related function to avoid ICE.

Not sure if my test is in the correct place 😅
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Feb 26, 2022
@Alexendoo
Copy link
Member

Fixed by #94355

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 1, 2022
…-once, r=davidtwco

Check method input expressions once

If the user mistakenly forgets to wrap their method args in a tuple, then the compiler tries to check that  types within the tuple match the expression args. This means we call `check_expr` once within this diagnostic code, so when we check the expr once again in `demand_compatible`, we attempt to apply expr adjustments twice, leading to ICEs.

This PR attempts to fix this by skipping the expression type check in `demand_compatible` if we have detected an method arg mismatch at all.

This does lead to a single UI test regressing slightly, due to a diagnostic disappearing, though I don't know if it is generally meaningful to even raise an type error after noting that the argument count is incorrect in a function call, since the user might be providing (in-context) meaningless expressions to the wrong method.

I can adjust this to be a bit more targeted (to just skip checking exprs in `demand_compatible` in the tuple case) if this UI test regression is a problem.

fixes rust-lang#94334
cc rust-lang#94291

Also drive-by fixup of `.node_type(expr.hir_id)` to `.expr_ty(expr)`, since that method exists.
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
Development

No branches or pull requests

6 participants