Skip to content

ice: no type-dependent def for method #116893

Closed

Description

@matthiaskrgr

File: /tmp/icemaker/AE153D8D5D57B27605224C96E644139B2BD809C19625E0FE2660FDA8A2906DF3.rs

auto-reduced (treereduce-rust):

struct X;
struct Y;
struct Z;

trait Foo<T> {
    type Ty;
    fn foo() -> Self::Ty;
}

impl Foo<Y> for X {
    type Ty = Z;
    fn foo() -> Self::Ty {
        unimplemented!()
    }
}

fn main() {
    let s = [(); {
        let mut n = 113383;
        while n != 0 {}
        n
    }];
    s.doit();
    X::foo();
}

original:

// check-pass

#![feature(inline_const_pat)]

const TLC: usize = 4;

trait Tr { fn doit(&self); }

impl Tr for [usize; TLC] {
    fn doit(&self) {
        println!("called 4");
    }
}

struct X;
struct Y;
struct Z;

trait Foo<T> {
    type Ty;
    fn foo() -> Self::Ty;
}

impl Foo<Y> for X {
    type Ty = Z;
    fn foo() -> Self::Ty {
        unimplemented!()
    }
}

enum E {
    A,
    B, //~ WARN variants `B` and `C` are never constructed
    C,
}

type F = E;

impl E {
    fn check(&self) -> bool {
        match self {
            Self::A => true,
            Self::B => false,
            F::C => false,
        }
    }
}

fn main() {
    let s = [(); { //~ ERROR failed to evaluate the given constant
        let mut n = 113383; // #20 in https://oeis.org/A006884
        while n != 0 {
            n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
            //~^ ERROR evaluation of constant value failed
        }
        n
    }];
    s.doit();
    X::foo();
    E::A.check();
}

Version information

rustc 1.75.0-nightly (e1de04ad4 2023-10-18)
binary: rustc
commit-hash: e1de04ad4e32afc6c82080a0b46408fee31dce88
commit-date: 2023-10-18
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3

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

Program output

warning: the feature `inline_const_pat` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker/AE153D8D5D57B27605224C96E644139B2BD809C19625E0FE2660FDA8A2906DF3.rs:3:12
  |
3 | #![feature(inline_const_pat)]
  |            ^^^^^^^^^^^^^^^^
  |
  = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: constant evaluation is taking a long time
  --> /tmp/icemaker/AE153D8D5D57B27605224C96E644139B2BD809C19625E0FE2660FDA8A2906DF3.rs:52:9
   |
52 | /         while n != 0 {
53 | |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
54 | |             //~^ ERROR evaluation of constant value failed
55 | |         }
   | |_________^
   |
   = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
           If your compilation actually takes a long time, you can safely allow the lint.
help: the constant being evaluated
  --> /tmp/icemaker/AE153D8D5D57B27605224C96E644139B2BD809C19625E0FE2660FDA8A2906DF3.rs:50:18
   |
50 |       let s = [(); { //~ ERROR failed to evaluate the given constant
   |  __________________^
51 | |         let mut n = 113383; // #20 in https://oeis.org/A006884
52 | |         while n != 0 {
53 | |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
...  |
56 | |         n
57 | |     }];
   | |_____^
   = note: `#[deny(long_running_const_eval)]` on by default

error: internal compiler error: compiler/rustc_passes/src/dead.rs:131:13: no type-dependent def for method

thread 'rustc' panicked at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/compiler/rustc_errors/src/lib.rs:1659:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f8b8816922c - std::backtrace_rs::backtrace::libunwind::trace::h78b9e962e243ca8f
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f8b8816922c - std::backtrace_rs::backtrace::trace_unsynchronized::h10b60b94f8e8e90f
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8b8816922c - std::sys_common::backtrace::_print_fmt::heabe9f83d4e1fbf2
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f8b8816922c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h81b76958dc64cc2e
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8b881cb1c0 - core::fmt::rt::Argument::fmt::h7f74343dbffe9183
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/core/src/fmt/rt.rs:142:9
   5:     0x7f8b881cb1c0 - core::fmt::write::hc2d1091c5ed1b3b7
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/core/src/fmt/mod.rs:1117:17
   6:     0x7f8b8815cf3f - std::io::Write::write_fmt::hb67a8f48bcfb1f4f
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/io/mod.rs:1762:15
   7:     0x7f8b88169014 - std::sys_common::backtrace::_print::h67add1984c5a1838
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8b88169014 - std::sys_common::backtrace::print::h404a822bd43d8000
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f8b8816bca7 - std::panicking::default_hook::{{closure}}::h4e8ae7bcfd2c52aa
  10:     0x7f8b8816ba0f - std::panicking::default_hook::h004c8707dedde48e
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/panicking.rs:292:9
  11:     0x7f8b8aca0400 - std[7217ace3ed74fbee]::panicking::update_hook::<alloc[624d8125282ac140]::boxed::Box<rustc_driver_impl[f4c3d59f9c31edf1]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f8b8816c3e8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbb7dfda09706e9c5
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/alloc/src/boxed.rs:2021:9
  13:     0x7f8b8816c3e8 - std::panicking::rust_panic_with_hook::h9ccb8adbf5a6f206
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/panicking.rs:735:13
  14:     0x7f8b8b059704 - std[7217ace3ed74fbee]::panicking::begin_panic::<rustc_errors[9290e2584ae7ad32]::ExplicitBug>::{closure#0}
  15:     0x7f8b8b051126 - std[7217ace3ed74fbee]::sys_common::backtrace::__rust_end_short_backtrace::<std[7217ace3ed74fbee]::panicking::begin_panic<rustc_errors[9290e2584ae7ad32]::ExplicitBug>::{closure#0}, !>
  16:     0x7f8b8b04b536 - std[7217ace3ed74fbee]::panicking::begin_panic::<rustc_errors[9290e2584ae7ad32]::ExplicitBug>
  17:     0x7f8b8b033f24 - <rustc_errors[9290e2584ae7ad32]::HandlerInner>::bug::<alloc[624d8125282ac140]::string::String>
  18:     0x7f8b8b033ce4 - <rustc_errors[9290e2584ae7ad32]::Handler>::bug::<alloc[624d8125282ac140]::string::String>
  19:     0x7f8b8b0d2a7d - rustc_middle[c3bb664540fd40fe]::util::bug::opt_span_bug_fmt::<rustc_span[86ba460ec05b7c05]::span_encoding::Span>::{closure#0}
  20:     0x7f8b8b0b9a2a - rustc_middle[c3bb664540fd40fe]::ty::context::tls::with_opt::<rustc_middle[c3bb664540fd40fe]::util::bug::opt_span_bug_fmt<rustc_span[86ba460ec05b7c05]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f8b8b0b98c8 - rustc_middle[c3bb664540fd40fe]::ty::context::tls::with_context_opt::<rustc_middle[c3bb664540fd40fe]::ty::context::tls::with_opt<rustc_middle[c3bb664540fd40fe]::util::bug::opt_span_bug_fmt<rustc_span[86ba460ec05b7c05]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f8b891bfe70 - rustc_middle[c3bb664540fd40fe]::util::bug::bug_fmt
  23:     0x7f8b89495d72 - <rustc_passes[fe3435d9db1f5a89]::dead::MarkSymbolVisitor as rustc_hir[d5ac411c7739f82b]::intravisit::Visitor>::visit_expr
  24:     0x7f8b8c13b4c4 - <rustc_passes[fe3435d9db1f5a89]::dead::MarkSymbolVisitor as rustc_hir[d5ac411c7739f82b]::intravisit::Visitor>::visit_block
  25:     0x7f8b8c139b6f - rustc_hir[d5ac411c7739f82b]::intravisit::walk_item::<rustc_passes[fe3435d9db1f5a89]::dead::MarkSymbolVisitor>
  26:     0x7f8b8cc8236a - rustc_passes[fe3435d9db1f5a89]::dead::live_symbols_and_ignored_derived_traits
  27:     0x7f8b8cc81856 - rustc_query_impl[1e4b497268a3bf63]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e4b497268a3bf63]::query_impl::live_symbols_and_ignored_derived_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c3bb664540fd40fe]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f8b8cb147b3 - rustc_query_system[643e04207a7d8bda]::query::plumbing::try_execute_query::<rustc_query_impl[1e4b497268a3bf63]::DynamicConfig<rustc_query_system[643e04207a7d8bda]::query::caches::SingleCache<rustc_middle[c3bb664540fd40fe]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1e4b497268a3bf63]::plumbing::QueryCtxt, false>
  29:     0x7f8b8cb13f06 - rustc_query_impl[1e4b497268a3bf63]::query_impl::live_symbols_and_ignored_derived_traits::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f8b8c5ba402 - rustc_passes[fe3435d9db1f5a89]::dead::check_mod_deathness
  31:     0x7f8b8c5ba307 - rustc_query_impl[1e4b497268a3bf63]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e4b497268a3bf63]::query_impl::check_mod_deathness::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c3bb664540fd40fe]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7f8b8c5c4234 - rustc_query_system[643e04207a7d8bda]::query::plumbing::try_execute_query::<rustc_query_impl[1e4b497268a3bf63]::DynamicConfig<rustc_query_system[643e04207a7d8bda]::query::caches::DefaultCache<rustc_span[86ba460ec05b7c05]::def_id::LocalModDefId, rustc_middle[c3bb664540fd40fe]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1e4b497268a3bf63]::plumbing::QueryCtxt, false>
  33:     0x7f8b8c5c3a8b - rustc_query_impl[1e4b497268a3bf63]::query_impl::check_mod_deathness::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f8b8c75a18f - rustc_interface[41ec36dc370840d6]::passes::analysis
  35:     0x7f8b8c759121 - rustc_query_impl[1e4b497268a3bf63]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1e4b497268a3bf63]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c3bb664540fd40fe]::query::erase::Erased<[u8; 1usize]>>
  36:     0x7f8b8c91e0a6 - rustc_query_system[643e04207a7d8bda]::query::plumbing::try_execute_query::<rustc_query_impl[1e4b497268a3bf63]::DynamicConfig<rustc_query_system[643e04207a7d8bda]::query::caches::SingleCache<rustc_middle[c3bb664540fd40fe]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1e4b497268a3bf63]::plumbing::QueryCtxt, false>
  37:     0x7f8b8c91ded5 - rustc_query_impl[1e4b497268a3bf63]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7f8b8cb2cc6a - std[7217ace3ed74fbee]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[41ec36dc370840d6]::util::run_in_thread_with_globals<rustc_interface[41ec36dc370840d6]::interface::run_compiler<core[1d18a34c428c8cbf]::result::Result<(), rustc_span[86ba460ec05b7c05]::ErrorGuaranteed>, rustc_driver_impl[f4c3d59f9c31edf1]::run_compiler::{closure#1}>::{closure#0}, core[1d18a34c428c8cbf]::result::Result<(), rustc_span[86ba460ec05b7c05]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1d18a34c428c8cbf]::result::Result<(), rustc_span[86ba460ec05b7c05]::ErrorGuaranteed>>
  39:     0x7f8b8cb2bf73 - <<std[7217ace3ed74fbee]::thread::Builder>::spawn_unchecked_<rustc_interface[41ec36dc370840d6]::util::run_in_thread_with_globals<rustc_interface[41ec36dc370840d6]::interface::run_compiler<core[1d18a34c428c8cbf]::result::Result<(), rustc_span[86ba460ec05b7c05]::ErrorGuaranteed>, rustc_driver_impl[f4c3d59f9c31edf1]::run_compiler::{closure#1}>::{closure#0}, core[1d18a34c428c8cbf]::result::Result<(), rustc_span[86ba460ec05b7c05]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1d18a34c428c8cbf]::result::Result<(), rustc_span[86ba460ec05b7c05]::ErrorGuaranteed>>::{closure#1} as core[1d18a34c428c8cbf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f8b88176f05 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2ccd842889ca1510
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/alloc/src/boxed.rs:2007:9
  41:     0x7f8b88176f05 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0b4e82b761ce431b
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/alloc/src/boxed.rs:2007:9
  42:     0x7f8b88176f05 - std::sys::unix::thread::Thread::new::thread_start::hd80c9211641b110c
                               at /rustc/e1de04ad4e32afc6c82080a0b46408fee31dce88/library/std/src/sys/unix/thread.rs:108:17
  43:     0x7f8b87f409eb - <unknown>
  44:     0x7f8b87fc47cc - <unknown>
  45:                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: rustc 1.75.0-nightly (e1de04ad4 2023-10-18) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [live_symbols_and_ignored_derived_traits] finding live symbols in crate
#1 [check_mod_deathness] checking deathness of variables in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted


Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on Oct 18, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 18, 2023
  3. matthiaskrgr commented on Oct 18, 2023

    @matthiaskrgr
    MemberAuthor

    Regression in nightly-2023-06-02
    Regression in 23f93a1
    #103877 cc @oli-obk

  4. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 22, 2023
  5. added 2 commits that reference this issue on Jan 16, 2024
    c21fcd4
    26f922f
  6. added a commit that references this issue on Jan 17, 2024
    7693297
  7. added a commit that references this issue on Jan 17, 2024
    4721d75
  8. added a commit that references this issue on Jan 17, 2024
    c297753
  9. added a commit that references this issue on Jan 17, 2024
    6ca77ff
  10. added a commit that references this issue on Jan 18, 2024
    736d752
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions