Skip to content

Compiler crashes on syntax error when trying to call a function from a dependency #96738

Closed
@Larodar

Description

@Larodar

Hi,
I am running rustc 1.62.0-nightly (4c60a0e 2022-05-04) on x86_64-pc-windows-msvc
(via rust-toolchain.toml)

Code

I have a binary and a library. The binary depends on the library. The directory structure looks like this:

  • somedirectory
    • binary

      • src
        • main.rs
      • Cargo.toml
      • rust-toolchain.toml
    • lib

      • src
        • lib.rs
      • Cargo.toml

The lib.rs has this one line.

pub fn get_root_dir() {}

The main.rs consumes this in the following way.

use lib::get_root_dir;

fn main() {
    test();
}

fn test() {
    let mut var = get_root_dir.to_owned();
    //                       ^ syntax error: It should be get_root_dir()
    var.push(""); // Deleting this line makes the compiler run just fine.
}

Error output

Setting RUST_BACKTRACE=1 did not make a difference.
I was not sure how to distinguish error output from the stacktrace. Thus, I left it in one piece.

thread 'rustc' panicked at 'DefId::expect_local: `DefId(16:3 ~ lib[2542]::get_root_dir)` isn't local', /rustc/4c60a0ea5b2385d7400df9db1ad04e96f2a4c154\compiler\rustc_span\src\def_id.rs:283:43
stack backtrace:
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.62.0-nightly (4c60a0ea5 2022-05-04) running on x86_64-pc-windows-msvc

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

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

query stack during panic:
#0 [typeck] type-checking `test`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: internal compiler error: no warnings or errors encountered even though `delayed_good_path_bugs` issued

error: internal compiler error: trimmed_def_paths constructed
  |
  = note: delayed at    0: std::backtrace::Backtrace::disabled
             1: std::backtrace::Backtrace::force_capture
             2: <rustc_middle::ty::subst::UserSubsts as rustc_middle::ty::context::Lift>::lift_to_tcx
             3: <rustc_middle::ty::print::pretty::TraitPredPrintModifiersAndPath as core::fmt::Debug>::fmt
             4: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
             5: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
             6: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
             7: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
             8: <rustc_middle::ty::print::pretty::FmtPrinter as rustc_middle::ty::print::Printer>::print_def_path
             9: <rustc_middle::ty::print::pretty::RegionHighlightMode>::highlighting_bound_region
            10: <rustc_middle::ty::print::pretty::FmtPrinter as rustc_middle::ty::print::Printer>::print_type
            11: <rustc_middle::ty::Ty as core::fmt::Display>::fmt
            12: <rustc_infer::infer::InferCtxt>::ty_to_string
            13: <rustc_typeck::check::fn_ctxt::FnCtxt>::report_method_error
            14: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
            15: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast
            16: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
            17: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_no_value
            18: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
            19: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast
            20: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_cast
            21: <rustc_typeck::check::cast::CastCheck>::check
            22: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap as core::fmt::Debug>::fmt
            23: rustc_typeck::check::provide
            24: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            25: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            26: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            27: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            28: <rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_item
            29: <rustc_typeck::check::CheckItemTypesVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
            30: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            31: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            32: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            33: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            34: <rustc_typeck::bounds::Bounds as core::fmt::Debug>::fmt
            35: rustc_typeck::check_crate
            36: rustc_interface::passes::analysis
            37: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            38: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            39: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            40: <alloc::vec::Vec<u8> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
            41: <rustc_driver::args::Error as core::fmt::Debug>::fmt
            42: <tracing_log::InfoCallsite as tracing_core::callsite::Callsite>::set_interest
            43: rustc_driver::pretty::print_after_hir_lowering
            44: <tracing_log::InfoCallsite as tracing_core::callsite::Callsite>::set_interest
            45: <rustc_driver::args::Error as core::fmt::Debug>::fmt
            46: <rustc_driver::args::Error as core::fmt::Debug>::fmt
            47: std::sys::windows::thread::Thread::new
            48: BaseThreadInitThunk
            49: RtlUserThreadStart


thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1358:13
stack backtrace:
   0:     0x7ff8bda1981f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7947b62570d4c5b1
   1:     0x7ff8bda548da - core::fmt::write::h70d4843ba7a897b3
   2:     0x7ff8bda0be99 - <std::io::IoSlice as core::fmt::Debug>::fmt::h5d4bb2848c520794
   3:     0x7ff8bda1d00b - std::panicking::default_hook::h3e750e6ba47e30f7
   4:     0x7ff8bda1cbfe - std::panicking::default_hook::h3e750e6ba47e30f7
   5:     0x7ff87f10d809 - <rustc_middle[54d97f71b399d5ec]::ty::SymbolName as core[7ee8ff2afd209409]::fmt::Display>::fmt
   6:     0x7ff8bda1d8ea - std::panicking::rust_panic_with_hook::h7cbf1deba360f8f8
   7:     0x7ff883a9a9f5 - <rustc_errors[eb5d71f99b1ea29a]::diagnostic_builder::DiagnosticBuilderInner as core[7ee8ff2afd209409]::ops::drop::Drop>::drop
   8:     0x7ff883a9a9a9 - <rustc_errors[eb5d71f99b1ea29a]::diagnostic_builder::DiagnosticBuilderInner as core[7ee8ff2afd209409]::ops::drop::Drop>::drop
   9:     0x7ff883dde749 - rustc_query_system[871b0f23bf45689b]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ff883a8c809 - <rustc_feature[3d48dd72efe309b8]::builtin_attrs::AttributeType as core[7ee8ff2afd209409]::fmt::Debug>::fmt
  11:     0x7ff883a90a3f - <rustc_errors[eb5d71f99b1ea29a]::HandlerInner as core[7ee8ff2afd209409]::ops::drop::Drop>::drop
  12:     0x7ff87f134784 - rustc_driver[befd72d25b210878]::pretty::print_after_hir_lowering
  13:     0x7ff87f1370fa - rustc_driver[befd72d25b210878]::pretty::print_after_hir_lowering
  14:     0x7ff87f12360d - rustc_driver[befd72d25b210878]::pretty::print_after_hir_lowering
  15:     0x7ff87f12129e - rustc_driver[befd72d25b210878]::pretty::print_after_hir_lowering
  16:     0x7ff883cd1a60 - _rust_realloc
  17:     0x7ff883cd0eb6 - _rust_realloc
  18:     0x7ff883ccd2f8 - _rust_realloc
  19:     0x7ff883cd021d - _rust_realloc
  20:     0x7ff883ccdc11 - _rust_realloc
  21:     0x7ff94027214f - _chkstk
  22:     0x7ff940200939 - RtlUnwindEx
  23:     0x7ff883ccd7c2 - _rust_realloc
  24:     0x7ff883cceec9 - _rust_realloc
  25:     0x7ff883ccf2df - _rust_realloc
  26:     0x7ff883cd0319 - _rust_realloc
  27:     0x7ff883ccdc11 - _rust_realloc
  28:     0x7ff9402720cf - _chkstk
  29:     0x7ff940221454 - RtlRaiseException
  30:     0x7ff9402211a5 - RtlRaiseException
  31:     0x7ff93de04f69 - RaiseException
  32:     0x7ff8bda7b3a8 - _umodti3
  33:     0x7ff8bda33f6e - _rust_start_panic
  34:     0x7ff8bda1dbab - rust_panic
  35:     0x7ff8bda1d90d - std::panicking::rust_panic_with_hook::h7cbf1deba360f8f8
  36:     0x7ff8bda1d63d - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h6726cbab8ed23bb0
  37:     0x7ff8bda1a317 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7947b62570d4c5b1
  38:     0x7ff8bda1d319 - rust_begin_unwind
  39:     0x7ff8bda88425 - core::panicking::panic_fmt::hcd7b4dbbeff87394
  40:     0x7ff881ca199b - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::report_method_error
  41:     0x7ff881ccf01c - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  42:     0x7ff881c6d320 - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::check_for_cast
  43:     0x7ff881c8d113 - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::check_stmt
  44:     0x7ff881c8d8fc - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::check_block_no_value
  45:     0x7ff881ccfa64 - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  46:     0x7ff881c6d320 - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::check_for_cast
  47:     0x7ff881c6e09b - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::check_for_cast
  48:     0x7ff881d26dec - <rustc_typeck[460aab01860c4d75]::check::cast::CastCheck>::check
  49:     0x7ff881d5ff82 - <rustc_typeck[460aab01860c4d75]::outlives::explicit::ExplicitPredicatesMap as core[7ee8ff2afd209409]::fmt::Debug>::fmt
  50:     0x7ff881d436f2 - rustc_typeck[460aab01860c4d75]::check::provide
  51:     0x7ff882911858 - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  52:     0x7ff882baa6d2 - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  53:     0x7ff882a2fa30 - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  54:     0x7ff882b69d18 - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  55:     0x7ff881cec621 - <rustc_typeck[460aab01860c4d75]::check::fn_ctxt::FnCtxt>::regionck_item
  56:     0x7ff881d49c93 - <rustc_typeck[460aab01860c4d75]::check::CheckItemTypesVisitor as rustc_hir[b25de3aa2715c5c6]::itemlikevisit::ItemLikeVisitor>::visit_item
  57:     0x7ff8829138ee - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  58:     0x7ff882bd22ef - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  59:     0x7ff882ac631d - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  60:     0x7ff882b3a619 - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  61:     0x7ff881c09faf - <rustc_typeck[460aab01860c4d75]::bounds::Bounds as core[7ee8ff2afd209409]::fmt::Debug>::fmt
  62:     0x7ff881bde445 - rustc_typeck[460aab01860c4d75]::check_crate
  63:     0x7ff87f22e9ef - rustc_interface[12230e7297bb182a]::passes::analysis
  64:     0x7ff88291365e - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  65:     0x7ff882bca11f - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  66:     0x7ff882ab1b64 - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  67:     0x7ff882b6a126 - <alloc[2ec833caa542c15b]::vec::Vec<u8> as rustc_serialize[5e5970f6941d1787]::serialize::Decodable<rustc_query_impl[dc14a1fb25a81ba1]::on_disk_cache::CacheDecoder>>::decode
  68:     0x7ff87f0c8b3f - <rustc_driver[befd72d25b210878]::args::Error as core[7ee8ff2afd209409]::fmt::Debug>::fmt
  69:     0x7ff87f09cc78 - <tracing_log[41e87b0bfa5e3ea7]::InfoCallsite as tracing_core[8b123e72e1908f2]::callsite::Callsite>::set_interest
  70:     0x7ff87f120a85 - rustc_driver[befd72d25b210878]::pretty::print_after_hir_lowering
  71:     0x7ff87f09dfb6 - <tracing_log[41e87b0bfa5e3ea7]::InfoCallsite as tracing_core[8b123e72e1908f2]::callsite::Callsite>::set_interest
  72:     0x7ff87f0cbb46 - <rustc_driver[befd72d25b210878]::args::Error as core[7ee8ff2afd209409]::fmt::Debug>::fmt
  73:     0x7ff87f0ccb78 - <rustc_driver[befd72d25b210878]::args::Error as core[7ee8ff2afd209409]::fmt::Debug>::fmt
  74:     0x7ff8bda2ed5c - std::sys::windows::thread::Thread::new::h1c4d5b4f08b98136
  75:     0x7ff93e457034 - BaseThreadInitThunk
  76:     0x7ff940222651 - RtlUserThreadStart

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.62.0-nightly (4c60a0ea5 2022-05-04) running on x86_64-pc-windows-msvc

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

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

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `crash`

Caused by:
  process didn't exit successfully: `rustc --crate-name crash --edition=2021 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=72243d3efb6d1b30 --out-dir C:\source\Playground\compiler-crash\crash\target\debug\deps -C incremental=C:\source\Playground\compiler-crash\crash\target\debug\incremental -L dependency=C:\source\Playground\compiler-crash\crash\target\debug\deps --extern lib=C:\source\Playground\compiler-crash\crash\target\debug\deps\liblib-2d1afb7a4f58f5c4.rlib` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

Please let me know, if you need more information or if the report is malformed. It is my first time reporting a bug here.

Thanks for your awesome work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions