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: compiler/rustc_typeck/src/check/upvar.rs:1701:13: Drop location span error: need to handle more #96258

Closed
jaskij opened this issue Apr 20, 2022 · 6 comments · Fixed by #98644
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

@jaskij
Copy link

jaskij commented Apr 20, 2022

Code

Works even with calling just rustc - no need for a project, and does not need gpio_cdev as a dependency in Cargo.toml.

#![warn(rust_2021_incompatible_closure_captures)]

use std::time::Duration;

use gpio_cdev::{Line, LineRequestFlags};

fn main() {}

pub(crate) struct Numberer {
    line: Line,
    interval: Duration,
    step: u32,
}

impl Numberer {
    pub(crate) async fn new(
        line: Line,
        interval: Duration,
        step: u32,
    ) -> Result<Numberer, gpio_cdev::Error> {
        line.request(
            LineRequestFlags::INPUT,
            0,
            crate::build_info::BUILD_INFO.package_name,
        )?;
        Ok(Numberer {
            line,
            interval,
            step,
        })
    }
}

Meta

Bug exists on 1.59, 1.60, beta and nightly.

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.59.0 (9d1b2106e 2022-02-23)
binary: rustc
commit-hash: 9d1b2106e23b1abd32fce1f17267604a5102f57a
commit-date: 2022-02-23
host: x86_64-unknown-linux-gnu
release: 1.59.0
LLVM version: 13.0.0

Error output

$ cargo check
    Checking ice-repro v0.1.0 (/home/jaskij/projects/rust/ice-repro)
error[E0432]: unresolved import `gpio_cdev`
 --> src/main.rs:5:5
  |
5 | use gpio_cdev::{Line, LineRequestFlags};
  |     ^^^^^^^^^ use of undeclared crate or module `gpio_cdev`

error[E0433]: failed to resolve: use of undeclared crate or module `gpio_cdev`
  --> src/main.rs:20:27
   |
20 |     ) -> Result<Numberer, gpio_cdev::Error> {
   |                           ^^^^^^^^^ use of undeclared crate or module `gpio_cdev`

error[E0433]: failed to resolve: could not find `build_info` in the crate root
  --> src/main.rs:24:20
   |
24 |             crate::build_info::BUILD_INFO.package_name,
   |                    ^^^^^^^^^^ could not find `build_info` in the crate root

error: internal compiler error: compiler/rustc_typeck/src/check/upvar.rs:1701:13: Drop location span error: need to handle more Node ImplItem(ImplItem { ident: new#0, def_id: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), vis: Spanned { node: Crate(PubCrate), span: src/main.rs:16:5: 16:15 (#0) }, defaultness: Final, generics: Generics { params: [], where_clause: WhereClause { predicates: [], span: src/main.rs:20:44: 20:44 (#0) }, span: src/main.rs:16:28: 16:28 (#0) }, kind: Fn(FnSig { header: FnHeader { unsafety: Normal, constness: NotConst, asyncness: Async, abi: Rust }, decl: FnDecl { inputs: [Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 74 }, kind: Path(Resolved(None, Path { span: src/main.rs:17:15: 17:19 (#0), res: Err, segments: [PathSegment { ident: Line#0, hir_id: Some(HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 75 }), res: Some(Err), args: None, infer_args: false }] })), span: src/main.rs:17:15: 17:19 (#0) }, Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 76 }, kind: Path(Resolved(None, Path { span: src/main.rs:18:19: 18:27 (#0), res: Def(Struct, DefId(2:47686 ~ core[4b8c]::time::Duration)), segments: [PathSegment { ident: Duration#0, hir_id: Some(HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 77 }), res: Some(Err), args: None, infer_args: false }] })), span: src/main.rs:18:19: 18:27 (#0) }, Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 78 }, kind: Path(Resolved(None, Path { span: src/main.rs:19:15: 19:18 (#0), res: PrimTy(Uint(U32)), segments: [PathSegment { ident: u32#0, hir_id: Some(HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 79 }), res: Some(Err), args: None, infer_args: false }] })), span: src/main.rs:19:15: 19:18 (#0) }], output: Return(Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 80 }, kind: OpaqueDef(ItemId { def_id: DefId(0:20 ~ ice_repro[15e6]::{impl#0}::new::{opaque#0}) }, []), span: src/main.rs:20:10: 20:44 (#86) }), c_variadic: false, implicit_self: None }, span: src/main.rs:16:5: 20:44 (#0) }, BodyId { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 73 } }), span: src/main.rs:16:5: 31:6 (#0) })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.59.0 (9d1b2106e 2022-02-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [typeck] type-checking `<impl at src/main.rs:15:1: 32:2>::new`
#1 [mir_built] building MIR for `<impl at src/main.rs:15:1: 32:2>::new`
end of query stack
Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `ice-repro` due to 3 previous error
Backtrace

$ RUST_BACKTRACE=full cargo check
    Checking ice-repro v0.1.0 (/home/jaskij/projects/rust/ice-repro)
error[E0432]: unresolved import `gpio_cdev`
 --> src/main.rs:5:5
  |
5 | use gpio_cdev::{Line, LineRequestFlags};
  |     ^^^^^^^^^ use of undeclared crate or module `gpio_cdev`

error[E0433]: failed to resolve: use of undeclared crate or module `gpio_cdev`
  --> src/main.rs:20:27
   |
20 |     ) -> Result<Numberer, gpio_cdev::Error> {
   |                           ^^^^^^^^^ use of undeclared crate or module `gpio_cdev`

error[E0433]: failed to resolve: could not find `build_info` in the crate root
  --> src/main.rs:24:20
   |
24 |             crate::build_info::BUILD_INFO.package_name,
   |                    ^^^^^^^^^^ could not find `build_info` in the crate root

error: internal compiler error: compiler/rustc_typeck/src/check/upvar.rs:1701:13: Drop location span error: need to handle more Node ImplItem(ImplItem { ident: new#0, def_id: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), vis: Spanned { node: Crate(PubCrate), span: src/main.rs:16:5: 16:15 (#0) }, defaultness: Final, generics: Generics { params: [], where_clause: WhereClause { predicates: [], span: src/main.rs:20:44: 20:44 (#0) }, span: src/main.rs:16:28: 16:28 (#0) }, kind: Fn(FnSig { header: FnHeader { unsafety: Normal, constness: NotConst, asyncness: Async, abi: Rust }, decl: FnDecl { inputs: [Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 74 }, kind: Path(Resolved(None, Path { span: src/main.rs:17:15: 17:19 (#0), res: Err, segments: [PathSegment { ident: Line#0, hir_id: Some(HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 75 }), res: Some(Err), args: None, infer_args: false }] })), span: src/main.rs:17:15: 17:19 (#0) }, Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 76 }, kind: Path(Resolved(None, Path { span: src/main.rs:18:19: 18:27 (#0), res: Def(Struct, DefId(2:47686 ~ core[4b8c]::time::Duration)), segments: [PathSegment { ident: Duration#0, hir_id: Some(HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 77 }), res: Some(Err), args: None, infer_args: false }] })), span: src/main.rs:18:19: 18:27 (#0) }, Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 78 }, kind: Path(Resolved(None, Path { span: src/main.rs:19:15: 19:18 (#0), res: PrimTy(Uint(U32)), segments: [PathSegment { ident: u32#0, hir_id: Some(HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 79 }), res: Some(Err), args: None, infer_args: false }] })), span: src/main.rs:19:15: 19:18 (#0) }], output: Return(Ty { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 80 }, kind: OpaqueDef(ItemId { def_id: DefId(0:20 ~ ice_repro[15e6]::{impl#0}::new::{opaque#0}) }, []), span: src/main.rs:20:10: 20:44 (#86) }), c_variadic: false, implicit_self: None }, span: src/main.rs:16:5: 20:44 (#0) }, BodyId { hir_id: HirId { owner: DefId(0:19 ~ ice_repro[15e6]::{impl#0}::new), local_id: 73 } }), span: src/main.rs:16:5: 31:6 (#0) })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
stack backtrace:
   0:     0x7fdde2496b9c - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fdde2496b9c - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fdde2496b9c - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fdde2496b9c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fdde24f7a2c - core::fmt::write::h753c7571fa063ecb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:     0x7fdde2485ea3 - std::io::Write::write_fmt::h2815c0519c99ba09
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:     0x7fdde249aca2 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fdde249aca2 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fdde249aca2 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:     0x7fdde249a885 - std::panicking::default_hook::hda898f8d3ad1a5ae
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:     0x7fdde2d1a761 - rustc_driver[68791c760b496cb9]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fdde249b455 - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:610:17
  12:     0x7fdde3f4319b - std[c2a6a440a415d498]::panicking::begin_panic::<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>::{closure#0}
  13:     0x7fdde3f43116 - std[c2a6a440a415d498]::sys_common::backtrace::__rust_end_short_backtrace::<std[c2a6a440a415d498]::panicking::begin_panic<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>::{closure#0}, !>
  14:     0x7fdde3f46f7f - std[c2a6a440a415d498]::panicking::begin_panic::<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>
  15:     0x7fdde3f51d0d - std[c2a6a440a415d498]::panic::panic_any::<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>
  16:     0x7fdde3f50f97 - <rustc_errors[a7f9c61e2940d55a]::HandlerInner>::bug
  17:     0x7fdde3f509a0 - <rustc_errors[a7f9c61e2940d55a]::Handler>::bug
  18:     0x7fdde3dd0579 - rustc_middle[918e6c9f11b9cfc2]::ty::context::tls::with_opt::<rustc_middle[918e6c9f11b9cfc2]::util::bug::opt_span_bug_fmt<rustc_span[eb9d2b35b06e162f]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7fdde3dd09e0 - rustc_middle[918e6c9f11b9cfc2]::util::bug::opt_span_bug_fmt::<rustc_span[eb9d2b35b06e162f]::span_encoding::Span>
  20:     0x7fdde3dd0956 - rustc_middle[918e6c9f11b9cfc2]::util::bug::bug_fmt
  21:     0x7fdde30b4f71 - rustc_typeck[e51d086a7d7ce975]::check::upvar::drop_location_span
  22:     0x7fdde30d774f - <<rustc_typeck[e51d086a7d7ce975]::check::fn_ctxt::FnCtxt>::perform_2229_migration_anaysis::{closure#0} as core[4b8c045e35bf0313]::ops::function::FnOnce<(rustc_middle[918e6c9f11b9cfc2]::lint::LintDiagnosticBuilder,)>>::call_once::{shim:vtable#0}
  23:     0x7fdde4a65ad6 - rustc_middle[918e6c9f11b9cfc2]::lint::struct_lint_level::struct_lint_level_impl
  24:     0x7fdde30dcd6c - rustc_middle[918e6c9f11b9cfc2]::lint::struct_lint_level::<<rustc_typeck[e51d086a7d7ce975]::check::fn_ctxt::FnCtxt>::perform_2229_migration_anaysis::{closure#0}>
  25:     0x7fdde3073b1c - <rustc_middle[918e6c9f11b9cfc2]::ty::context::TyCtxt>::struct_span_lint_hir::<rustc_span[eb9d2b35b06e162f]::span_encoding::Span, <rustc_typeck[e51d086a7d7ce975]::check::fn_ctxt::FnCtxt>::perform_2229_migration_anaysis::{closure#0}>
  26:     0x7fdde4dc439b - <rustc_typeck[e51d086a7d7ce975]::check::fn_ctxt::FnCtxt>::analyze_closure
  27:     0x7fdde42b5602 - <rustc_typeck[e51d086a7d7ce975]::check::upvar::InferBorrowKindVisitor as rustc_hir[bbd43c30a9e25620]::intravisit::Visitor>::visit_expr
  28:     0x7fdde4260f2a - rustc_hir[bbd43c30a9e25620]::intravisit::walk_expr::<rustc_typeck[e51d086a7d7ce975]::check::upvar::InferBorrowKindVisitor>
  29:     0x7fdde425ce71 - rustc_hir[bbd43c30a9e25620]::intravisit::walk_body::<rustc_typeck[e51d086a7d7ce975]::check::upvar::InferBorrowKindVisitor>
  30:     0x7fdde42756e5 - <rustc_infer[78a58de0f2f222a5]::infer::InferCtxtBuilder>::enter::<&rustc_middle[918e6c9f11b9cfc2]::ty::context::TypeckResults, <rustc_typeck[e51d086a7d7ce975]::check::inherited::InheritedBuilder>::enter<rustc_typeck[e51d086a7d7ce975]::check::typeck_with_fallback<rustc_typeck[e51d086a7d7ce975]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[918e6c9f11b9cfc2]::ty::context::TypeckResults>::{closure#0}>
  31:     0x7fdde42405ef - rustc_typeck[e51d086a7d7ce975]::check::typeck
  32:     0x7fdde469309c - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId, &rustc_middle[918e6c9f11b9cfc2]::ty::context::TypeckResults>>
  33:     0x7fdde46f16d8 - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::typeck
  34:     0x7fdde4a4c812 - <rustc_middle[918e6c9f11b9cfc2]::ty::context::TyCtxt>::typeck_opt_const_arg
  35:     0x7fdde43fc253 - rustc_mir_build[15bd22390fb06210]::build::mir_built
  36:     0x7fdde4686d4c - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_middle[918e6c9f11b9cfc2]::ty::WithOptConstParam<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId>, &rustc_data_structures[496dc1ea3fa24648]::steal::Steal<rustc_middle[918e6c9f11b9cfc2]::mir::Body>>>
  37:     0x7fdde46ebbd0 - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::mir_built
  38:     0x7fdde418c582 - rustc_mir_transform[6b60019107120a72]::check_unsafety::unsafety_check_result
  39:     0x7fdde418a223 - <rustc_mir_transform[6b60019107120a72]::check_unsafety::provide::{closure#0} as core[4b8c045e35bf0313]::ops::function::FnOnce<(rustc_middle[918e6c9f11b9cfc2]::ty::context::TyCtxt, rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId)>>::call_once
  40:     0x7fdde4694dfc - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId, &rustc_middle[918e6c9f11b9cfc2]::mir::query::UnsafetyCheckResult>>
  41:     0x7fdde46f12b8 - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::unsafety_check_result
  42:     0x7fdde41849b1 - rustc_mir_transform[6b60019107120a72]::mir_const
  43:     0x7fdde4686d4c - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_middle[918e6c9f11b9cfc2]::ty::WithOptConstParam<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId>, &rustc_data_structures[496dc1ea3fa24648]::steal::Steal<rustc_middle[918e6c9f11b9cfc2]::mir::Body>>>
  44:     0x7fdde46ebd17 - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::mir_const
  45:     0x7fdde4185a67 - rustc_mir_transform[6b60019107120a72]::mir_promoted
  46:     0x7fdde4687f96 - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_middle[918e6c9f11b9cfc2]::ty::WithOptConstParam<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId>, (&rustc_data_structures[496dc1ea3fa24648]::steal::Steal<rustc_middle[918e6c9f11b9cfc2]::mir::Body>, &rustc_data_structures[496dc1ea3fa24648]::steal::Steal<rustc_index[69ea34c38b914ba2]::vec::IndexVec<rustc_middle[918e6c9f11b9cfc2]::mir::Promoted, rustc_middle[918e6c9f11b9cfc2]::mir::Body>>)>>
  47:     0x7fdde46ec15f - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::mir_promoted
  48:     0x7fdde4532014 - rustc_borrowck[8b7f6be767d7c201]::mir_borrowck
  49:     0x7fdde452c271 - <rustc_borrowck[8b7f6be767d7c201]::provide::{closure#0} as core[4b8c045e35bf0313]::ops::function::FnOnce<(rustc_middle[918e6c9f11b9cfc2]::ty::context::TyCtxt, rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId)>>::call_once
  50:     0x7fdde4693f4c - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId, &rustc_middle[918e6c9f11b9cfc2]::mir::query::BorrowCheckResult>>
  51:     0x7fdde46f196b - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::mir_borrowck
  52:     0x7fdde42bb2fc - rustc_typeck[e51d086a7d7ce975]::collect::type_of::type_of
  53:     0x7fdde46e71bf - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::type_of
  54:     0x7fdde42cf3fb - rustc_typeck[e51d086a7d7ce975]::check::check::check_item_type
  55:     0x7fdde42c1eb5 - <rustc_middle[918e6c9f11b9cfc2]::hir::map::Map>::visit_item_likes_in_module::<rustc_typeck[e51d086a7d7ce975]::check::CheckItemTypesVisitor>
  56:     0x7fdde4e4641c - rustc_typeck[e51d086a7d7ce975]::check::check::check_mod_item_types
  57:     0x7fdde4695c9f - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId, ()>>
  58:     0x7fdde503e8c3 - rustc_query_system[f23fa726dd903306]::query::plumbing::get_query::<rustc_query_impl[7556885dd75c8dd5]::queries::check_mod_item_types, rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt>
  59:     0x7fdde4e3cea2 - <rustc_middle[918e6c9f11b9cfc2]::hir::map::Map>::for_each_module::<rustc_typeck[e51d086a7d7ce975]::check_crate::{closure#6}::{closure#0}>
  60:     0x7fdde4df5560 - <rustc_session[4ee117c394fa64a2]::session::Session>::time::<(), rustc_typeck[e51d086a7d7ce975]::check_crate::{closure#6}>
  61:     0x7fdde4de6503 - rustc_typeck[e51d086a7d7ce975]::check_crate
  62:     0x7fdde4b87297 - rustc_interface[f4c999472ca453d]::passes::analysis
  63:     0x7fdde502c2e5 - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<(), core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>>
  64:     0x7fdde504e995 - rustc_query_system[f23fa726dd903306]::query::plumbing::get_query::<rustc_query_impl[7556885dd75c8dd5]::queries::analysis, rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt>
  65:     0x7fdde4b68912 - <rustc_interface[f4c999472ca453d]::interface::Compiler>::enter::<rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}::{closure#2}, core[4b8c045e35bf0313]::result::Result<core[4b8c045e35bf0313]::option::Option<rustc_interface[f4c999472ca453d]::queries::Linker>, rustc_errors[a7f9c61e2940d55a]::ErrorReported>>
  66:     0x7fdde4b4b97c - rustc_span[eb9d2b35b06e162f]::with_source_map::<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_interface[f4c999472ca453d]::interface::create_compiler_and_run<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#1}>
  67:     0x7fdde4b67cfe - rustc_interface[f4c999472ca453d]::interface::create_compiler_and_run::<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>
  68:     0x7fdde4b4cedb - <scoped_tls[7dc407bead1f97c0]::ScopedKey<rustc_span[eb9d2b35b06e162f]::SessionGlobals>>::set::<rustc_interface[f4c999472ca453d]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f4c999472ca453d]::interface::run_compiler<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#0}::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>
  69:     0x7fdde4b4ccd5 - std[c2a6a440a415d498]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f4c999472ca453d]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f4c999472ca453d]::interface::run_compiler<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>
  70:     0x7fdde4b78499 - <<std[c2a6a440a415d498]::thread::Builder>::spawn_unchecked<rustc_interface[f4c999472ca453d]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f4c999472ca453d]::interface::run_compiler<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#1} as core[4b8c045e35bf0313]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  71:     0x7fdde24a7073 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49b6c7c5155a2296
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1854:9
  72:     0x7fdde24a7073 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha8b5234bfeb15105
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1854:9
  73:     0x7fdde24a7073 - std::sys::unix::thread::Thread::new::thread_start::h6f207dd842d64859
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys/unix/thread.rs:108:17
  74:     0x7fdde22835c2 - start_thread
  75:     0x7fdde2308584 - __clone
  76:                0x0 - <unknown>

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.59.0 (9d1b2106e 2022-02-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [typeck] type-checking `<impl at src/main.rs:15:1: 32:2>::new`
#1 [mir_built] building MIR for `<impl at src/main.rs:15:1: 32:2>::new`
#2 [unsafety_check_result] unsafety-checking `<impl at src/main.rs:15:1: 32:2>::new`
#3 [mir_const] processing MIR for `<impl at src/main.rs:15:1: 32:2>::new`
#4 [mir_promoted] processing `<impl at src/main.rs:15:1: 32:2>::new`
#5 [mir_borrowck] borrow-checking `<impl at src/main.rs:15:1: 32:2>::new`
#6 [type_of] computing type of `<impl at src/main.rs:15:1: 32:2>::new::{opaque#0}`
#7 [check_mod_item_types] checking item types in top-level module
#8 [analysis] running analysis passes on this crate
end of query stack
Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `ice-repro` due to 3 previous errors

@jaskij jaskij 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 Apr 20, 2022
@compiler-errors
Copy link
Member

@jaskij:

I unfortunately do not have the time to minimize the code.

Do you have a codebase that can be shared instead? Unfortunately, it's kinda difficult to investigate this without seeing what triggered the ICE.

@matthiaskrgr
Copy link
Member

might be a duplicate of #93117

@jaskij
Copy link
Author

jaskij commented Apr 20, 2022

@compiler-errors I tried my hands at minimizing this, and it turned out way easier than I thought. Updated the original comment with reproduction code.

@compiler-errors compiler-errors self-assigned this Apr 20, 2022
@rvantonder
Copy link

I subscribed to this thread for curiosity about ICEs on rustc. Here's a smaller crashing program using comby-reducer 😄

#![warn(rust_2021_incompatible_closure_captures)]
impl Numberer {
    pub(crate) async fn new(
        interval: Duration,

@jaskij
Copy link
Author

jaskij commented Apr 20, 2022

Managed to minimize it more:

#![warn(rust_2021_incompatible_closure_captures)]

fn main() {}

pub(crate) struct Numberer {}

impl Numberer {
    pub(crate) async fn new(
        interval: Duration,
    ) -> Numberer {
        Numberer {}
    }
}
$ rustc --edition=2021 main.rs 
error[E0412]: cannot find type `Duration` in this scope
 --> main.rs:9:19
  |
9 |         interval: Duration,
  |                   ^^^^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
3 | use core::time::Duration;
  |
3 | use std::time::Duration;
  |

error: internal compiler error: compiler/rustc_typeck/src/check/upvar.rs:1701:13: Drop location span error: need to handle more Node ImplItem(ImplItem { ident: new#0, def_id: DefId(0:6 ~ main[a756]::{impl#0}::new), vis: Spanned { node: Crate(PubCrate), span: main.rs:8:5: 8:15 (#0) }, defaultness: Final, generics: Generics { params: [], where_clause: WhereClause { predicates: [], span: main.rs:10:18: 10:18 (#0) }, span: main.rs:8:28: 8:28 (#0) }, kind: Fn(FnSig { header: FnHeader { unsafety: Normal, constness: NotConst, asyncness: Async, abi: Rust }, decl: FnDecl { inputs: [Ty { hir_id: HirId { owner: DefId(0:6 ~ main[a756]::{impl#0}::new), local_id: 20 }, kind: Path(Resolved(None, Path { span: main.rs:9:19: 9:27 (#0), res: Err, segments: [PathSegment { ident: Duration#0, hir_id: Some(HirId { owner: DefId(0:6 ~ main[a756]::{impl#0}::new), local_id: 21 }), res: Some(Err), args: None, infer_args: false }] })), span: main.rs:9:19: 9:27 (#0) }], output: Return(Ty { hir_id: HirId { owner: DefId(0:6 ~ main[a756]::{impl#0}::new), local_id: 22 }, kind: OpaqueDef(ItemId { def_id: DefId(0:7 ~ main[a756]::{impl#0}::new::{opaque#0}) }, []), span: main.rs:10:10: 10:18 (#82) }), c_variadic: false, implicit_self: None }, span: main.rs:8:5: 10:18 (#0) }, BodyId { hir_id: HirId { owner: DefId(0:6 ~ main[a756]::{impl#0}::new), local_id: 19 } }), span: main.rs:8:5: 12:6 (#0) })

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.59.0 (9d1b2106e 2022-02-23) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `<impl at main.rs:7:1: 13:2>::new`
#1 [mir_built] building MIR for `<impl at main.rs:7:1: 13:2>::new`
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.

@jaskij
Copy link
Author

jaskij commented Apr 20, 2022

might be a duplicate of #93117

@matthiaskrgr you might be right, especially after I narrowed down the reproduction code.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 23, 2022
@compiler-errors compiler-errors removed their assignment May 31, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 1, 2022
…_inc_clos_cap, r=lcnr

fix ICE with -Wrust-2021-incompatible-closure-captures

Fixes rust-lang#93117
Fixes rust-lang#96258
@bors bors closed this as completed in 7dc0489 Jul 1, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 25, 2023
Fix test for rust-lang#96258

rust-lang#98644 did not properly test enabling the problematic lint as a warning due to improper use of `compile-flags:` (missing `:`). This makes it use `#![warn]` instead, like in the reproducer.

cc rust-lang#96258
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 25, 2023
…llaumeGomez

Rollup of 4 pull requests

Successful merges:

 - rust-lang#112918 (display PID of process holding lock)
 - rust-lang#112990 (Add a regression test for rust-lang#96699)
 - rust-lang#113011 (Add enum for `can_access_statics` boolean)
 - rust-lang#113018 (Fix test for rust-lang#96258)

r? `@ghost`
`@rustbot` modify labels: rollup
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

Successfully merging a pull request may close this issue.

5 participants