rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.32k stars 12.72k forks source link

ICE: compiler/rustc_typeck/src/check/upvar.rs:1701:13: Drop location span error: need to handle more #96258

Closed jaskij closed 2 years ago

jaskij commented 2 years ago

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 { | ^^^^^^^^^ 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', 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 - ::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::::{closure#0} 13: 0x7fdde3f43116 - std[c2a6a440a415d498]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 14: 0x7fdde3f46f7f - std[c2a6a440a415d498]::panicking::begin_panic:: 15: 0x7fdde3f51d0d - std[c2a6a440a415d498]::panic::panic_any:: 16: 0x7fdde3f50f97 - ::bug 17: 0x7fdde3f509a0 - ::bug 18: 0x7fdde3dd0579 - rustc_middle[918e6c9f11b9cfc2]::ty::context::tls::with_opt::::{closure#0}, ()> 19: 0x7fdde3dd09e0 - rustc_middle[918e6c9f11b9cfc2]::util::bug::opt_span_bug_fmt:: 20: 0x7fdde3dd0956 - rustc_middle[918e6c9f11b9cfc2]::util::bug::bug_fmt 21: 0x7fdde30b4f71 - rustc_typeck[e51d086a7d7ce975]::check::upvar::drop_location_span 22: 0x7fdde30d774f - <::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::<::perform_2229_migration_anaysis::{closure#0}> 25: 0x7fdde3073b1c - ::struct_span_lint_hir::::perform_2229_migration_anaysis::{closure#0}> 26: 0x7fdde4dc439b - ::analyze_closure 27: 0x7fdde42b5602 - ::visit_expr 28: 0x7fdde4260f2a - rustc_hir[bbd43c30a9e25620]::intravisit::walk_expr:: 29: 0x7fdde425ce71 - rustc_hir[bbd43c30a9e25620]::intravisit::walk_body:: 30: 0x7fdde42756e5 - ::enter::<&rustc_middle[918e6c9f11b9cfc2]::ty::context::TypeckResults, ::enter::{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::> 33: 0x7fdde46f16d8 - ::typeck 34: 0x7fdde4a4c812 - ::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_data_structures[496dc1ea3fa24648]::steal::Steal>> 37: 0x7fdde46ebbd0 - ::mir_built 38: 0x7fdde418c582 - rustc_mir_transform[6b60019107120a72]::check_unsafety::unsafety_check_result 39: 0x7fdde418a223 - >::call_once 40: 0x7fdde4694dfc - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::> 41: 0x7fdde46f12b8 - ::unsafety_check_result 42: 0x7fdde41849b1 - rustc_mir_transform[6b60019107120a72]::mir_const 43: 0x7fdde4686d4c - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::, &rustc_data_structures[496dc1ea3fa24648]::steal::Steal>> 44: 0x7fdde46ebd17 - ::mir_const 45: 0x7fdde4185a67 - rustc_mir_transform[6b60019107120a72]::mir_promoted 46: 0x7fdde4687f96 - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::, (&rustc_data_structures[496dc1ea3fa24648]::steal::Steal, &rustc_data_structures[496dc1ea3fa24648]::steal::Steal>)>> 47: 0x7fdde46ec15f - ::mir_promoted 48: 0x7fdde4532014 - rustc_borrowck[8b7f6be767d7c201]::mir_borrowck 49: 0x7fdde452c271 - >::call_once 50: 0x7fdde4693f4c - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::> 51: 0x7fdde46f196b - ::mir_borrowck 52: 0x7fdde42bb2fc - rustc_typeck[e51d086a7d7ce975]::collect::type_of::type_of 53: 0x7fdde46e71bf - ::type_of 54: 0x7fdde42cf3fb - rustc_typeck[e51d086a7d7ce975]::check::check::check_item_type 55: 0x7fdde42c1eb5 - ::visit_item_likes_in_module:: 56: 0x7fdde4e4641c - rustc_typeck[e51d086a7d7ce975]::check::check::check_mod_item_types 57: 0x7fdde4695c9f - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::> 58: 0x7fdde503e8c3 - rustc_query_system[f23fa726dd903306]::query::plumbing::get_query:: 59: 0x7fdde4e3cea2 - ::for_each_module:: 60: 0x7fdde4df5560 - ::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::>> 64: 0x7fdde504e995 - rustc_query_system[f23fa726dd903306]::query::plumbing::get_query:: 65: 0x7fdde4b68912 - ::enter::, rustc_errors[a7f9c61e2940d55a]::ErrorReported>> 66: 0x7fdde4b4b97c - rustc_span[eb9d2b35b06e162f]::with_source_map::, rustc_interface[f4c999472ca453d]::interface::create_compiler_and_run, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#1}> 67: 0x7fdde4b67cfe - rustc_interface[f4c999472ca453d]::interface::create_compiler_and_run::, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}> 68: 0x7fdde4b4cedb - >::set::, 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_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 - <::spawn_unchecked, 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 - as core::ops::function::FnOnce>::call_once::h49b6c7c5155a2296 at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1854:9 72: 0x7fdde24a7073 - as core::ops::function::FnOnce>::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 - 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 `::new` #1 [mir_built] building MIR for `::new` #2 [unsafety_check_result] unsafety-checking `::new` #3 [mir_const] processing MIR for `::new` #4 [mir_promoted] processing `::new` #5 [mir_borrowck] borrow-checking `::new` #6 [type_of] computing type of `::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 ```

compiler-errors commented 2 years ago

@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 commented 2 years ago

might be a duplicate of https://github.com/rust-lang/rust/issues/93117

jaskij commented 2 years ago

@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.

rvantonder commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

might be a duplicate of #93117

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