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: unexpected non-type Node::GenericParam #129205

Closed
matthiaskrgr opened this issue Aug 17, 2024 · 3 comments · Fixed by #129250
Closed

ICE: unexpected non-type Node::GenericParam #129205

matthiaskrgr opened this issue Aug 17, 2024 · 3 comments · Fixed by #129250
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

fn test_generic<T: Copy>(val: T) -> T {
    let _ = T::try_from(val).unwrap();
}
original code

original:

#![deny(clippy::useless_conversion)]
#![allow(
    clippy::needless_if,
    clippy::unnecessary_fallible_conversions,
    clippy::manual_unwrap_or_default
)]

fn test_generic<T: Copy>(val: T) -> T {
    let _ = T::try_from(val).unwrap();
    //~^ ERROR: useless conversion to the same type: `T`
    val.try_into().unwrap()
    //~^ ERROR: useless conversion to the same type: `T`
}

fn test_generic2<T: Copy + Into<i32> + Into<U>, U: From<T>>(val: T) {
    // ok
    let _: i32 = val.try_into().unwrap();
    let _: U = val.try_into().unwrap();
    let _ = U::try_from(val).unwrap();
}

fn main() {
    test_generic(10i32);
    test_generic2::<i32, i32>(10i32);

    let _: String = "foo".try_into().unwrap();
    let _: String = TryFrom::try_from("foo").unwrap();
    let _ = String::try_from("foo").unwrap();
    #[allow(clippy::useless_conversion)]
    {
        let _ = String::try_from("foo").unwrap();
        let _: String = "foo".try_into().unwrap();
    }
    let _: String = "foo".to_string().try_into().unwrap();
    //~^ ERROR: useless conversion to the same type: `std::string::String`
    let _: String = TryFrom::try_from("foo".to_string()).unwrap();
    //~^ ERROR: useless conversion to the same type: `std::string::String`
    let _ = String::try_from("foo".to_string()).unwrap();
    //~^ ERROR: useless conversion to the same type: `std::string::String`
    let _ = String::try_from(format!("A: {:04}", 123)).unwrap();
    //~^ ERROR: useless conversion to the same type: `std::string::String`
    let _: String = format!("Hello {}", "world").try_into().unwrap();
    //~^ ERROR: useless conversion to the same type: `std::string::String`
    let _: String = String::new().try_into().unwrap();
    //~^ ERROR: useless conversion to the same type: `std::string::String`
    let _: String = match String::from("_").try_into() {
        //~^ ERROR: useless conversion to the same type: `std::string::String`
        Ok(a) => a,
        Err(_) => String::new(),
    };
    // FIXME this is a false negative
    #[allow(clippy::cmp_owned)]
    if String::from("a") == TryInto::<String>::try_into(String::from("a")).unwrap() {}
}

Version information

rustc 1.82.0-nightly (9b318d2e9 2024-08-17)
binary: rustc
commit-hash: 9b318d2e93ce35e7ba32d8cfa96a1dbe63a7bed1
commit-date: 2024-08-17
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.sXqwjI7Mv8KU/rustc_testrunner_tmpdir_reporting.B11rGugxJB7Z/mvce.rs:3:2
  |
3 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.sXqwjI7Mv8KU/rustc_testrunner_tmpdir_reporting.B11rGugxJB7Z/mvce.rs`

error: internal compiler error: compiler/rustc_hir_analysis/src/collect/type_of.rs:582:18: unexpected non-type Node::GenericParam: Type { default: None, synthetic: false }

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/type_of.rs:582:18:
Box<dyn Any>
stack backtrace:
   0:     0x73887d5b28dd - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hbc01d7b608be4cd7
   1:     0x73887de05157 - core::fmt::write::hb357ae00ad9c5259
   2:     0x73887edbda51 - std::io::Write::write_fmt::h13a24ddc9a1fdb00
   3:     0x73887d5b4fbb - std::panicking::default_hook::{{closure}}::he90538c5db987e04
   4:     0x73887d5b4c2e - std::panicking::default_hook::ha1a531e9b99fa317
   5:     0x73887c747ba9 - std[6cb574a7e0954fac]::panicking::update_hook::<alloc[df4cc1a01d5b065d]::boxed::Box<rustc_driver_impl[8771d5e726c45cf8]::install_ice_hook::{closure#0}>>::{closure#0}
   6:     0x73887d5b58d7 - std::panicking::rust_panic_with_hook::h13cac42622f97635
   7:     0x73887c781f11 - std[6cb574a7e0954fac]::panicking::begin_panic::<rustc_errors[fd70399d2354dc26]::ExplicitBug>::{closure#0}
   8:     0x73887c774f56 - std[6cb574a7e0954fac]::sys::backtrace::__rust_end_short_backtrace::<std[6cb574a7e0954fac]::panicking::begin_panic<rustc_errors[fd70399d2354dc26]::ExplicitBug>::{closure#0}, !>
   9:     0x73887c770336 - std[6cb574a7e0954fac]::panicking::begin_panic::<rustc_errors[fd70399d2354dc26]::ExplicitBug>
  10:     0x73887c78aef1 - <rustc_errors[fd70399d2354dc26]::diagnostic::BugAbort as rustc_errors[fd70399d2354dc26]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x73887cd4e994 - rustc_middle[c3682ad5e92f3c6c]::util::bug::opt_span_bug_fmt::<rustc_span[5d62fad87722a712]::span_encoding::Span>::{closure#0}
  12:     0x73887cd345aa - rustc_middle[c3682ad5e92f3c6c]::ty::context::tls::with_opt::<rustc_middle[c3682ad5e92f3c6c]::util::bug::opt_span_bug_fmt<rustc_span[5d62fad87722a712]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x73887cd3445b - rustc_middle[c3682ad5e92f3c6c]::ty::context::tls::with_context_opt::<rustc_middle[c3682ad5e92f3c6c]::ty::context::tls::with_opt<rustc_middle[c3682ad5e92f3c6c]::util::bug::opt_span_bug_fmt<rustc_span[5d62fad87722a712]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x73887a823c10 - rustc_middle[c3682ad5e92f3c6c]::util::bug::bug_fmt
  15:     0x73887b2a73e4 - rustc_hir_analysis[25b7da8f6fe9ad06]::collect::type_of::type_of
  16:     0x73887de37530 - rustc_query_impl[f86d883d92ecf329]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f86d883d92ecf329]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c3682ad5e92f3c6c]::query::erase::Erased<[u8; 8usize]>>
  17:     0x73887de361e7 - rustc_query_system[bd3380b77d0fd58]::query::plumbing::try_execute_query::<rustc_query_impl[f86d883d92ecf329]::DynamicConfig<rustc_query_system[bd3380b77d0fd58]::query::caches::DefIdCache<rustc_middle[c3682ad5e92f3c6c]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f86d883d92ecf329]::plumbing::QueryCtxt, false>
  18:     0x73887de35da7 - rustc_query_impl[f86d883d92ecf329]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  19:     0x73887e2cab11 - rustc_middle[c3682ad5e92f3c6c]::query::plumbing::query_get_at::<rustc_query_system[bd3380b77d0fd58]::query::caches::DefIdCache<rustc_middle[c3682ad5e92f3c6c]::query::erase::Erased<[u8; 8usize]>>>
  20:     0x73887ca8d083 - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::suggest_traits_to_import
  21:     0x73887ca7a19a - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::report_no_match_method_error
  22:     0x73887caae2ba - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::report_method_error
  23:     0x73887e848e90 - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::check_expr_path
  24:     0x73887e7db898 - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x73887e7dcfcd - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x73887e7ddaea - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27:     0x73887e7da304 - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::check_decl
  28:     0x73887e7d7581 - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::check_block_with_expected
  29:     0x73887e7dda88 - <rustc_hir_typeck[12bf866448a1086e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x73887e03a521 - rustc_hir_typeck[12bf866448a1086e]::check::check_fn
  31:     0x73887e16b41f - rustc_hir_typeck[12bf866448a1086e]::typeck
  32:     0x73887e16ae73 - rustc_query_impl[f86d883d92ecf329]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f86d883d92ecf329]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c3682ad5e92f3c6c]::query::erase::Erased<[u8; 8usize]>>
  33:     0x73887e0cb039 - rustc_query_system[bd3380b77d0fd58]::query::plumbing::try_execute_query::<rustc_query_impl[f86d883d92ecf329]::DynamicConfig<rustc_query_system[bd3380b77d0fd58]::query::caches::VecCache<rustc_span[5d62fad87722a712]::def_id::LocalDefId, rustc_middle[c3682ad5e92f3c6c]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[f86d883d92ecf329]::plumbing::QueryCtxt, false>
  34:     0x73887e0ca255 - rustc_query_impl[f86d883d92ecf329]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  35:     0x73887e0c9edb - <rustc_middle[c3682ad5e92f3c6c]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[25b7da8f6fe9ad06]::check_crate::{closure#4}>::{closure#0}
  36:     0x73887e0c7c24 - rustc_hir_analysis[25b7da8f6fe9ad06]::check_crate
  37:     0x73887e9279ff - rustc_interface[63d22841a2327cf2]::passes::run_required_analyses
  38:     0x73887e95dc9e - rustc_interface[63d22841a2327cf2]::passes::analysis
  39:     0x73887e95dc71 - rustc_query_impl[f86d883d92ecf329]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f86d883d92ecf329]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c3682ad5e92f3c6c]::query::erase::Erased<[u8; 1usize]>>
  40:     0x73887ed873ae - rustc_query_system[bd3380b77d0fd58]::query::plumbing::try_execute_query::<rustc_query_impl[f86d883d92ecf329]::DynamicConfig<rustc_query_system[bd3380b77d0fd58]::query::caches::SingleCache<rustc_middle[c3682ad5e92f3c6c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f86d883d92ecf329]::plumbing::QueryCtxt, false>
  41:     0x73887ed8710f - rustc_query_impl[f86d883d92ecf329]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  42:     0x73887ebfa56a - rustc_interface[63d22841a2327cf2]::interface::run_compiler::<core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>, rustc_driver_impl[8771d5e726c45cf8]::run_compiler::{closure#0}>::{closure#1}
  43:     0x73887eb13690 - std[6cb574a7e0954fac]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[63d22841a2327cf2]::util::run_in_thread_with_globals<rustc_interface[63d22841a2327cf2]::util::run_in_thread_pool_with_globals<rustc_interface[63d22841a2327cf2]::interface::run_compiler<core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>, rustc_driver_impl[8771d5e726c45cf8]::run_compiler::{closure#0}>::{closure#1}, core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>>::{closure#0}, core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>>
  44:     0x73887eb13cfa - <<std[6cb574a7e0954fac]::thread::Builder>::spawn_unchecked_<rustc_interface[63d22841a2327cf2]::util::run_in_thread_with_globals<rustc_interface[63d22841a2327cf2]::util::run_in_thread_pool_with_globals<rustc_interface[63d22841a2327cf2]::interface::run_compiler<core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>, rustc_driver_impl[8771d5e726c45cf8]::run_compiler::{closure#0}>::{closure#1}, core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>>::{closure#0}, core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7c75989f65d16f38]::result::Result<(), rustc_span[5d62fad87722a712]::ErrorGuaranteed>>::{closure#1} as core[7c75989f65d16f38]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x73887eb1406b - std::sys::pal::unix::thread::Thread::new::thread_start::h683ced0bc52e6b8c
  46:     0x73888028c39d - <unknown>
  47:     0x73888031149c - <unknown>
  48:                0x0 - <unknown>

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: rustc 1.82.0-nightly (9b318d2e9 2024-08-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [type_of] computing type of `test_generic::T`
#1 [typeck] type-checking `test_generic`
end of query stack
error: aborting due to 2 previous errors

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Aug 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 17, 2024
@matthiaskrgr
Copy link
Member Author

mvce:

fn x<T: Copy>() {
    T::try_from();
}

@matthiaskrgr
Copy link
Member Author

#128786 🤔 cc @estebank

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 17, 2024
@matthiaskrgr matthiaskrgr added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 17, 2024
@estebank
Copy link
Contributor

estebank added a commit to estebank/rust that referenced this issue Aug 18, 2024
When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786. Fix rust-lang#129205.
estebank added a commit to estebank/rust that referenced this issue Aug 21, 2024
When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786. Fix rust-lang#129205.
tgross35 added a commit to tgross35/rust that referenced this issue Aug 21, 2024
…errors

Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786. Fix rust-lang#129205.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 26, 2024
…errors

Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786.
Fixes rust-lang#129205
Fixes rust-lang#129216
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 26, 2024
…errors

Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786.
Fixes rust-lang#129205
Fixes rust-lang#129216
@bors bors closed this as completed in 00c435d Aug 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 27, 2024
Rollup merge of rust-lang#129250 - estebank:issue-129205, r=compiler-errors

Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786.
Fixes rust-lang#129205
Fixes rust-lang#129216
bvanjoi pushed a commit to bvanjoi/rust that referenced this issue Aug 28, 2024
When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786. Fix rust-lang#129205.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants