rust-lang / rust

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

Compilation bug while using Diesel framework #125549

Closed Capunix309 closed 5 months ago

Capunix309 commented 5 months ago

rustc-ice-2024-05-25T18_02_18-25659.txt

I'm developing a website using actix-web and diesel. I needed to modify a variable in my up.sql file and to redo my migration. After doing that, the compiler refused to compile. Please tell me what to do, I never reported before and I'm not a native English speaker (please forgive me for the potential errors in my explanation).

Edit : I just tried to use the stable version and it perfectly work in case you're wondering Update : Apparently, it was ok for just a brief moment... It's still bugged, even in stable version...

Code

Before

CREATE TABLE blocks (
    --global
    id_block TEXT PRIMARY KEY NOT NULL,
    id_user TEXT,
    id_team TEXT,
    id_blocker TEXT NOT NULL,

    --infos
    date TIMESTAMP NOT NULL,
    reason VARCHAR(500) NOT NULL,
    still_active BOOL NOT NULL DEFAULT TRUE,

    --foreign keys
    CHECK (id_user IS NOT NULL OR id_team IS NOT NULL),
    FOREIGN KEY (id_blocker) REFERENCES users(id_user) ON DELETE CASCADE,
    FOREIGN KEY (id_user) REFERENCES users(id_user) ON DELETE CASCADE,
    FOREIGN KEY (id_team) REFERENCES teams(id_team) ON DELETE CASCADE
);

After


CREATE TABLE blocks (
    --global
    id_block TEXT PRIMARY KEY NOT NULL,
    id_user TEXT,
    id_team TEXT,
    id_blocker TEXT NOT NULL,

    --infos
    date TIMESTAMP NOT NULL,
    reason VARCHAR(500) NOT NULL,
    end_date TIMESTAMP NOT NULL,

    --foreign keys
    CHECK (id_user IS NOT NULL OR id_team IS NOT NULL),
    FOREIGN KEY (id_blocker) REFERENCES users(id_user) ON DELETE CASCADE,
    FOREIGN KEY (id_user) REFERENCES users(id_user) ON DELETE CASCADE,
    FOREIGN KEY (id_team) REFERENCES teams(id_team) ON DELETE CASCADE
);

Schema.rs

diesel::table! {
    blocks (id_block) {
        id_block -> Text,
        id_user -> Nullable<Text>,
        id_team -> Nullable<Text>,
        id_blocker -> Text,
        date -> Timestamp,
        #[max_length = 500]
        reason -> Varchar,
        end_date -> Timestamp,
    }
}

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (36153f1a4 2024-05-24)
binary: rustc
commit-hash: 36153f1a4e3162f0a143c7b3e468ecb3beb0008e
commit-date: 2024-05-24
host: x86_64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.6
Backtrace

``` thread 'rustc' panicked at compiler/rustc_hir/src/definitions.rs:389:13: ("Failed to extract DefId", def_kind, PackedFingerprint(Fingerprint(1656113388420302199, 1128357605846114694))) stack backtrace: 0: 0x10c4a4283 - ::fmt::hb04141112752ea70 1: 0x10c4ef88b - core::fmt::write::hddfa7860c859e571 2: 0x10c49a3ce - std::io::Write::write_fmt::h3002ff5eaabbfa96 3: 0x10c4a4071 - std::sys_common::backtrace::print::hf8b8ac82befd31a5 4: 0x10c4a6e39 - std::panicking::default_hook::{{closure}}::headb9a59455c83cc 5: 0x10c4a6bb8 - std::panicking::default_hook::h0f278631d2fb154e 6: 0x1151d246c - std[bbe2f3e4661d22f2]::panicking::update_hook::>::{closure#0} 7: 0x10c4a7943 - std::panicking::rust_panic_with_hook::hc40a2ef99d181ed1 8: 0x10c4a7282 - std::panicking::begin_panic_handler::{{closure}}::head167c964aad049 9: 0x10c4a4759 - std::sys_common::backtrace::__rust_end_short_backtrace::h0fc564af4a20bb02 10: 0x10c4a6fb6 - _rust_begin_unwind 11: 0x10c50bfd2 - core::panicking::panic_fmt::ha7e6d9002cbc558e 12: 0x1199b55ce - ::local_def_path_hash_to_def_id::err 13: 0x115d1ecd0 - ::def_path_hash_to_def_id 14: 0x11660c59e - ::{closure#0} as core[98362835e6f1cf4d]::ops::function::FnOnce<(rustc_middle[fa5ba927ae906344]::ty::context::TyCtxt, rustc_query_system[1b610f4e21531e30]::dep_graph::dep_node::DepNode)>>::call_once 15: 0x11640451a - >::try_mark_previous_green:: 16: 0x11640457a - >::try_mark_previous_green:: 17: 0x11640457a - >::try_mark_previous_green:: 18: 0x11640457a - >::try_mark_previous_green:: 19: 0x11640457a - >::try_mark_previous_green:: 20: 0x11640457a - >::try_mark_previous_green:: 21: 0x11640457a - >::try_mark_previous_green:: 22: 0x11640457a - >::try_mark_previous_green:: 23: 0x1164042b0 - >::try_mark_green:: 24: 0x11647e9e7 - rustc_query_system[1b610f4e21531e30]::query::plumbing::try_execute_query::>, rustc_middle[fa5ba927ae906344]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt, true> 25: 0x1166e1950 - rustc_query_impl[10e03e6d76125a1d]::query_impl::evaluate_obligation::get_query_incr::__rust_end_short_backtrace 26: 0x116c98aec - ::evaluate_obligation 27: 0x116c98e6d - ::evaluate_obligation_no_overflow 28: 0x116c89d61 - ::process_trait_obligation 29: 0x116c88b3e - ::process_obligation 30: 0x116aba733 - >::process_obligations:: 31: 0x116bec685 - ::select_where_possible 32: 0x115472440 - rustc_hir_analysis[ad0ad50ab359f2b9]::check::check::check_impl_items_against_trait 33: 0x115468dbb - rustc_hir_analysis[ad0ad50ab359f2b9]::check::check::check_item_type 34: 0x11549ed01 - rustc_hir_analysis[ad0ad50ab359f2b9]::check::wfcheck::check_well_formed 35: 0x116684d2a - rustc_query_impl[10e03e6d76125a1d]::plumbing::__rust_begin_short_backtrace::> 36: 0x116513953 - rustc_query_system[1b610f4e21531e30]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt, true> 37: 0x1166013cd - ::{closure#0} as core[98362835e6f1cf4d]::ops::function::FnOnce<(rustc_middle[fa5ba927ae906344]::ty::context::TyCtxt, rustc_query_system[1b610f4e21531e30]::dep_graph::dep_node::DepNode)>>::call_once 38: 0x11640451a - >::try_mark_previous_green:: 39: 0x1164042b0 - >::try_mark_green:: 40: 0x11643aaa2 - rustc_query_system[1b610f4e21531e30]::query::plumbing::ensure_must_run::>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt> 41: 0x1166a92a6 - rustc_query_impl[10e03e6d76125a1d]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace 42: 0x115523a0c - rustc_hir_analysis[ad0ad50ab359f2b9]::check_crate 43: 0x1159acd81 - rustc_interface[879bf7e024c9790f]::passes::run_required_analyses 44: 0x1159af3c3 - rustc_interface[879bf7e024c9790f]::passes::analysis 45: 0x116687ada - rustc_query_impl[10e03e6d76125a1d]::plumbing::__rust_begin_short_backtrace::> 46: 0x116462119 - rustc_query_system[1b610f4e21531e30]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt, true> 47: 0x116691b8a - rustc_query_impl[10e03e6d76125a1d]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 48: 0x11517daf7 - >::enter::, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}::{closure#1}::{closure#3}> 49: 0x1151d0c9d - rustc_interface[879bf7e024c9790f]::interface::run_compiler::, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}>::{closure#1} 50: 0x1151c3aa1 - std[bbe2f3e4661d22f2]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}>::{closure#1}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>> 51: 0x1151db6f6 - <::spawn_unchecked_, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}>::{closure#1}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#2} as core[98362835e6f1cf4d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 52: 0x10c4b0ffb - std::sys::pal::unix::thread::Thread::new::thread_start::hefcab854b80b5673 53: 0x7ff808cf318b - __pthread_start error: 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: please make sure that you have updated to the latest nightly note: please attach the file at `/Users/_/Documents/Dev/Projets rust/site_scan/rustc-ice-2024-05-25T17_50_05-25434.txt` to your bug report note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [evaluate_obligation] evaluating trait selection obligation `diesel::query_builder::select_statement::SelectStatement>: diesel::associations::HasTable` | = note: this failure-note originates in the macro `diesel::table` (in Nightly builds, run with -Z macro-backtrace for more info) #1 [check_well_formed] checking that `schema::blocks::` is well-formed end of query stack there was a panic while trying to force a dep node try_mark_green dep node stack: #0 representability(4f30fb18c8887b86-69d9742e053ade32) #1 adt_sized_constraint(thread 'rustc' panicked at compiler/rustc_hir/src/definitions.rs:389:13: ("Failed to extract DefId", adt_sized_constraint, PackedFingerprint(Fingerprint(1656113388420302199, 1128357605846114694))) stack backtrace: 0: 0x10c4a4283 - ::fmt::hb04141112752ea70 1: 0x10c4ef88b - core::fmt::write::hddfa7860c859e571 2: 0x10c49a3ce - std::io::Write::write_fmt::h3002ff5eaabbfa96 3: 0x10c4a4071 - std::sys_common::backtrace::print::hf8b8ac82befd31a5 4: 0x10c4a6e39 - std::panicking::default_hook::{{closure}}::headb9a59455c83cc 5: 0x10c4a6bb8 - std::panicking::default_hook::h0f278631d2fb154e 6: 0x1151d246c - std[bbe2f3e4661d22f2]::panicking::update_hook::>::{closure#0} 7: 0x10c4a7943 - std::panicking::rust_panic_with_hook::hc40a2ef99d181ed1 8: 0x10c4a7282 - std::panicking::begin_panic_handler::{{closure}}::head167c964aad049 9: 0x10c4a4759 - std::sys_common::backtrace::__rust_end_short_backtrace::h0fc564af4a20bb02 10: 0x10c4a6fb6 - _rust_begin_unwind 11: 0x10c50bfd2 - core::panicking::panic_fmt::ha7e6d9002cbc558e 12: 0x1199b55ce - ::local_def_path_hash_to_def_id::err 13: 0x115d1ecd0 - ::def_path_hash_to_def_id 14: 0x11599a5fa - rustc_interface[879bf7e024c9790f]::callbacks::dep_node_debug 15: 0x11673013f - ::fmt 16: 0x10c4ef88b - core::fmt::write::hddfa7860c859e571 17: 0x10c498621 - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::hf3241710851205a6 18: 0x10c498f87 - std::io::stdio::_eprint::heedc006db6d249f8 19: 0x119b01600 - rustc_query_system[1b610f4e21531e30]::dep_graph::graph::print_markframe_trace:: 20: 0x116404609 - >::try_mark_previous_green:: 21: 0x11640457a - >::try_mark_previous_green:: 22: 0x11640457a - >::try_mark_previous_green:: 23: 0x11640457a - >::try_mark_previous_green:: 24: 0x11640457a - >::try_mark_previous_green:: 25: 0x11640457a - >::try_mark_previous_green:: 26: 0x11640457a - >::try_mark_previous_green:: 27: 0x11640457a - >::try_mark_previous_green:: 28: 0x1164042b0 - >::try_mark_green:: 29: 0x11647e9e7 - rustc_query_system[1b610f4e21531e30]::query::plumbing::try_execute_query::>, rustc_middle[fa5ba927ae906344]::query::erase::Erased<[u8; 2usize]>>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt, true> 30: 0x1166e1950 - rustc_query_impl[10e03e6d76125a1d]::query_impl::evaluate_obligation::get_query_incr::__rust_end_short_backtrace 31: 0x116c98aec - ::evaluate_obligation 32: 0x116c98e6d - ::evaluate_obligation_no_overflow 33: 0x116c89d61 - ::process_trait_obligation 34: 0x116c88b3e - ::process_obligation 35: 0x116aba733 - >::process_obligations:: 36: 0x116bec685 - ::select_where_possible 37: 0x115472440 - rustc_hir_analysis[ad0ad50ab359f2b9]::check::check::check_impl_items_against_trait 38: 0x115468dbb - rustc_hir_analysis[ad0ad50ab359f2b9]::check::check::check_item_type 39: 0x11549ed01 - rustc_hir_analysis[ad0ad50ab359f2b9]::check::wfcheck::check_well_formed 40: 0x116684d2a - rustc_query_impl[10e03e6d76125a1d]::plumbing::__rust_begin_short_backtrace::> 41: 0x116513953 - rustc_query_system[1b610f4e21531e30]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt, true> 42: 0x1166013cd - ::{closure#0} as core[98362835e6f1cf4d]::ops::function::FnOnce<(rustc_middle[fa5ba927ae906344]::ty::context::TyCtxt, rustc_query_system[1b610f4e21531e30]::dep_graph::dep_node::DepNode)>>::call_once 43: 0x11640451a - >::try_mark_previous_green:: 44: 0x1164042b0 - >::try_mark_green:: 45: 0x11643aaa2 - rustc_query_system[1b610f4e21531e30]::query::plumbing::ensure_must_run::>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt> 46: 0x1166a92a6 - rustc_query_impl[10e03e6d76125a1d]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace 47: 0x115523a0c - rustc_hir_analysis[ad0ad50ab359f2b9]::check_crate 48: 0x1159acd81 - rustc_interface[879bf7e024c9790f]::passes::run_required_analyses 49: 0x1159af3c3 - rustc_interface[879bf7e024c9790f]::passes::analysis 50: 0x116687ada - rustc_query_impl[10e03e6d76125a1d]::plumbing::__rust_begin_short_backtrace::> 51: 0x116462119 - rustc_query_system[1b610f4e21531e30]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[10e03e6d76125a1d]::plumbing::QueryCtxt, true> 52: 0x116691b8a - rustc_query_impl[10e03e6d76125a1d]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 53: 0x11517daf7 - >::enter::, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}::{closure#1}::{closure#3}> 54: 0x1151d0c9d - rustc_interface[879bf7e024c9790f]::interface::run_compiler::, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}>::{closure#1} 55: 0x1151c3aa1 - std[bbe2f3e4661d22f2]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}>::{closure#1}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>> 56: 0x1151db6f6 - <::spawn_unchecked_, rustc_driver_impl[263088e60e1843a4]::run_compiler::{closure#0}>::{closure#1}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[98362835e6f1cf4d]::result::Result<(), rustc_span[b9e4b09a24a8c018]::ErrorGuaranteed>>::{closure#2} as core[98362835e6f1cf4d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 57: 0x10c4b0ffb - std::sys::pal::unix::thread::Thread::new::thread_start::hefcab854b80b5673 58: 0x7ff808cf318b - __pthread_start error: 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: please make sure that you have updated to the latest nightly note: please attach the file at `/Users/_/Documents/Dev/Projets rust/site_scan/rustc-ice-2024-05-25T17_50_05-25434.txt` to your bug report note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED] note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [evaluate_obligation] evaluating trait selection obligation `diesel::query_builder::select_statement::SelectStatement>: diesel::associations::HasTable` | = note: this failure-note originates in the macro `diesel::table` (in Nightly builds, run with -Z macro-backtrace for more info) #1 [check_well_formed] checking that `schema::blocks::` is well-formed end of query stack there was a panic while trying to force a dep node try_mark_green dep node stack: #0 check_mod_type_wf(astralscan[16fb]::schema::blocks) end of try_mark_green dep node stack ```

Noratrieb commented 5 months ago

thank you for the report, but without a reproduction, there is sadly not much we can do.

Capunix309 commented 5 months ago

How can I give you this ?

Noratrieb commented 5 months ago

Ideally you could just post your project somewhere public like with a GitHub repo. If your project is not public though, then you can't easily do it, you'd need to attempt to minimize the bug to something small enough to share.

Also, just a project isn't enough in this case, we'd really need to know the exact edit you did that triggered the crash (for example with a git patch).

As a workaround, you can disable incremental compilation by setting [build] incremental = false in .cargo/config.toml.

Capunix309 commented 5 months ago

Thank you for the reply, but my project isn't public and couldn't be... The bug is disappearing when I re-install rust, and it currently isn't here. I don't understand what the problem is, since it seems being too deep for me. I'm just a junior developper you see. So thank you for your help, but I don't think I can't help you more with this.

KayneWang commented 5 months ago

@Capunix309 Delete your target directory (perhaps created by rust-analyzer) which is in your project root directory. Then try building again; it will be resolved.

Capunix309 commented 5 months ago

Thank you, I already found this solution.