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: type parameter impl .. out of range when substituting #121063

Closed
matthiaskrgr opened this issue Feb 14, 2024 · 4 comments · Fixed by #128171
Closed

ICE: type parameter impl .. out of range when substituting #121063

matthiaskrgr opened this issue Feb 14, 2024 · 4 comments · Fixed by #128171
Labels
-Zpolymorphize Unstable option: Polymorphization. A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

It appears that generic crash exprs are not even required 🤯

snippet:

use std::{
    fmt, ops,
    path::{Component, Path, PathBuf},
};

pub struct AbsPathBuf(PathBuf);

impl TryFrom<PathBuf> for AbsPathBuf {
    type Error = PathBuf;
    fn try_from(path: impl AsRef<Path>) -> Result<AbsPathBuf, PathBuf> {}
}

impl TryFrom<&str> for AbsPathBuf {
    fn try_from(path: &str) -> Result<AbsPathBuf, PathBuf> {
        AbsPathBuf::try_from(PathBuf::from(path))
    }
}

Version information

rustc 1.78.0-nightly (a84bb95a1 2024-02-13)
binary: rustc
commit-hash: a84bb95a1f65bfe25038f188763a18e096a86ab2
commit-date: 2024-02-13
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zpolymorphize=on --edition=2021 -Zinline-mir=yes

Program output

warning: unused imports: `Component`, `fmt`, `ops`
 --> /tmp/icemaker_global_tempdir.38EKKhyo0coV/rustc_testrunner_tmpdir_reporting.kSeYxCUoRCLn/mvce.rs:2:5
  |
2 |     fmt, ops,
  |     ^^^  ^^^
3 |     path::{Component, Path, PathBuf},
  |            ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

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

error[E0049]: method `try_from` has 1 type parameter but its trait declaration has 0 type parameters
   --> /tmp/icemaker_global_tempdir.38EKKhyo0coV/rustc_testrunner_tmpdir_reporting.kSeYxCUoRCLn/mvce.rs:10:23
    |
10  |     fn try_from(path: impl AsRef<Path>) -> Result<AbsPathBuf, PathBuf> {}
    |                       ^^^^^^^^^^^^^^^^
    |                       |
    |                       found 1 type parameter
    |                       `impl Trait` introduces an implicit type parameter
    |
   ::: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/convert/mod.rs:686:5
    |
686 |     fn try_from(value: T) -> Result<Self, Self::Error>;
    |     --------------------------------------------------- expected 0 type parameters

error[E0046]: not all trait items implemented, missing: `Error`
  --> /tmp/icemaker_global_tempdir.38EKKhyo0coV/rustc_testrunner_tmpdir_reporting.kSeYxCUoRCLn/mvce.rs:13:1
   |
13 | impl TryFrom<&str> for AbsPathBuf {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation
   |
   = help: implement the missing item: `type Error = /* Type */;`

error[E0308]: mismatched types
  --> /tmp/icemaker_global_tempdir.38EKKhyo0coV/rustc_testrunner_tmpdir_reporting.kSeYxCUoRCLn/mvce.rs:10:44
   |
10 |     fn try_from(path: impl AsRef<Path>) -> Result<AbsPathBuf, PathBuf> {}
   |        --------                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<AbsPathBuf, PathBuf>`, found `()`
   |        |
   |        implicitly returns `()` as its body has no tail or `return` expression
   |
   = note:   expected enum `Result<AbsPathBuf, PathBuf>`
           found unit type `()`

error: internal compiler error: compiler/rustc_middle/src/ty/generic_args.rs:928:9: type parameter `impl AsRef<Path>/#0` (impl AsRef<Path>/#0/0) out of range when instantiating, args=[]

thread 'rustc' panicked at compiler/rustc_middle/src/util/bug.rs:35:44:
Box<dyn Any>
stack backtrace:
   0:     0x7f13b8b8d086 - std::backtrace_rs::backtrace::libunwind::trace::h350c9bbd0d629e5a
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f13b8b8d086 - std::backtrace_rs::backtrace::trace_unsynchronized::hb5ce80cf0732c5cf
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f13b8b8d086 - std::sys_common::backtrace::_print_fmt::he116d0f55fe00810
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f13b8b8d086 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h71fa05f97c99f332
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f13b8bdd51c - core::fmt::rt::Argument::fmt::hfafe0bdb999ad9e2
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/core/src/fmt/rt.rs:142:9
   5:     0x7f13b8bdd51c - core::fmt::write::h6115470fc2d68b0c
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f13b8b80abf - std::io::Write::write_fmt::hdc66f4e88b29f74f
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/io/mod.rs:1854:15
   7:     0x7f13b8b8ce34 - std::sys_common::backtrace::_print::hcb29a46764838669
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f13b8b8ce34 - std::sys_common::backtrace::print::h05e4e1c5c9b1d560
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f13b8b8fb7b - std::panicking::default_hook::{{closure}}::h8d5ead34896ab42d
  10:     0x7f13b8b8f8c9 - std::panicking::default_hook::h78047fe2f192a868
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/panicking.rs:292:9
  11:     0x7f13bb9463bc - std[466eff1cc2ed908f]::panicking::update_hook::<alloc[4ead1f6995f5264c]::boxed::Box<rustc_driver_impl[c431125988ed1f11]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f13b8b902e0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hcfe839bef410f29b
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/alloc/src/boxed.rs:2030:9
  13:     0x7f13b8b902e0 - std::panicking::rust_panic_with_hook::h1e5f7f410afd2444
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/panicking.rs:785:13
  14:     0x7f13bb973d24 - std[466eff1cc2ed908f]::panicking::begin_panic::<rustc_errors[1de830c8c65656ce]::ExplicitBug>::{closure#0}
  15:     0x7f13bb970c36 - std[466eff1cc2ed908f]::sys_common::backtrace::__rust_end_short_backtrace::<std[466eff1cc2ed908f]::panicking::begin_panic<rustc_errors[1de830c8c65656ce]::ExplicitBug>::{closure#0}, !>
  16:     0x7f13bb970636 - std[466eff1cc2ed908f]::panicking::begin_panic::<rustc_errors[1de830c8c65656ce]::ExplicitBug>
  17:     0x7f13bb97f671 - <rustc_errors[1de830c8c65656ce]::diagnostic_builder::BugAbort as rustc_errors[1de830c8c65656ce]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f13bbd38b6e - <rustc_errors[1de830c8c65656ce]::DiagCtxt>::bug::<alloc[4ead1f6995f5264c]::string::String>
  19:     0x7f13bbdd265b - rustc_middle[80ff7a15503a7fbe]::util::bug::opt_span_bug_fmt::<rustc_span[f008fc136599d052]::span_encoding::Span>::{closure#0}
  20:     0x7f13bbdb9ffa - rustc_middle[80ff7a15503a7fbe]::ty::context::tls::with_opt::<rustc_middle[80ff7a15503a7fbe]::util::bug::opt_span_bug_fmt<rustc_span[f008fc136599d052]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f13bbdb9e98 - rustc_middle[80ff7a15503a7fbe]::ty::context::tls::with_context_opt::<rustc_middle[80ff7a15503a7fbe]::ty::context::tls::with_opt<rustc_middle[80ff7a15503a7fbe]::util::bug::opt_span_bug_fmt<rustc_span[f008fc136599d052]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f13ba2a9470 - rustc_middle[80ff7a15503a7fbe]::util::bug::bug_fmt
  23:     0x7f13bbdc7c46 - <rustc_middle[80ff7a15503a7fbe]::ty::generic_args::ArgFolder>::type_param_out_of_range
  24:     0x7f13bcc0819b - <rustc_middle[80ff7a15503a7fbe]::ty::generic_args::ArgFolder as rustc_type_ir[ebc5bf0fdfdb0d04]::fold::TypeFolder<rustc_middle[80ff7a15503a7fbe]::ty::context::TyCtxt>>::fold_ty
  25:     0x7f13bd690e76 - <rustc_middle[80ff7a15503a7fbe]::mir::Body as rustc_type_ir[ebc5bf0fdfdb0d04]::fold::TypeFoldable<rustc_middle[80ff7a15503a7fbe]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[80ff7a15503a7fbe]::ty::generic_args::ArgFolder>
  26:     0x7f13bd75646b - <rustc_mir_transform[5aabfb6384135eb6]::inline::Inliner>::try_inlining
  27:     0x7f13bd754753 - <rustc_mir_transform[5aabfb6384135eb6]::inline::Inliner>::process_blocks
  28:     0x7f13bcd3f447 - <rustc_mir_transform[5aabfb6384135eb6]::inline::Inline as rustc_middle[80ff7a15503a7fbe]::mir::MirPass>::run_pass
  29:     0x7f13bcc33b0f - rustc_mir_transform[5aabfb6384135eb6]::pass_manager::run_passes_inner
  30:     0x7f13bcf68efd - rustc_mir_transform[5aabfb6384135eb6]::optimized_mir
  31:     0x7f13bcc820f5 - rustc_query_impl[56a5a1cad20ac6aa]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[56a5a1cad20ac6aa]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[80ff7a15503a7fbe]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7f13bcc827a0 - rustc_query_system[790ca29724b87fee]::query::plumbing::try_execute_query::<rustc_query_impl[56a5a1cad20ac6aa]::DynamicConfig<rustc_query_system[790ca29724b87fee]::query::caches::DefIdCache<rustc_middle[80ff7a15503a7fbe]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[56a5a1cad20ac6aa]::plumbing::QueryCtxt, false>
  33:     0x7f13bcc81f1e - rustc_query_impl[56a5a1cad20ac6aa]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f13bd503918 - rustc_middle[80ff7a15503a7fbe]::query::plumbing::query_get_at::<rustc_query_system[790ca29724b87fee]::query::caches::DefIdCache<rustc_middle[80ff7a15503a7fbe]::query::erase::Erased<[u8; 8usize]>>>
  35:     0x7f13bd5ee1b0 - rustc_query_impl[56a5a1cad20ac6aa]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[56a5a1cad20ac6aa]::query_impl::unused_generic_params::dynamic_query::{closure#2}::{closure#0}, rustc_middle[80ff7a15503a7fbe]::query::erase::Erased<[u8; 4usize]>>
  36:     0x7f13bd5ed999 - rustc_query_system[790ca29724b87fee]::query::plumbing::try_execute_query::<rustc_query_impl[56a5a1cad20ac6aa]::DynamicConfig<rustc_query_system[790ca29724b87fee]::query::caches::DefaultCache<rustc_middle[80ff7a15503a7fbe]::ty::instance::InstanceDef, rustc_middle[80ff7a15503a7fbe]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[56a5a1cad20ac6aa]::plumbing::QueryCtxt, false>
  37:     0x7f13bd5ed6aa - rustc_query_impl[56a5a1cad20ac6aa]::query_impl::unused_generic_params::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7f13bd5e926f - rustc_interface[b495b14b2a666c1a]::passes::analysis
  39:     0x7f13bd5e8869 - rustc_query_impl[56a5a1cad20ac6aa]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[56a5a1cad20ac6aa]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[80ff7a15503a7fbe]::query::erase::Erased<[u8; 1usize]>>
  40:     0x7f13bd6af3a5 - rustc_query_system[790ca29724b87fee]::query::plumbing::try_execute_query::<rustc_query_impl[56a5a1cad20ac6aa]::DynamicConfig<rustc_query_system[790ca29724b87fee]::query::caches::SingleCache<rustc_middle[80ff7a15503a7fbe]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[56a5a1cad20ac6aa]::plumbing::QueryCtxt, false>
  41:     0x7f13bd6af109 - rustc_query_impl[56a5a1cad20ac6aa]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7f13bd8ea77b - rustc_interface[b495b14b2a666c1a]::interface::run_compiler::<core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>, rustc_driver_impl[c431125988ed1f11]::run_compiler::{closure#0}>::{closure#0}
  43:     0x7f13bdb7e854 - std[466eff1cc2ed908f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b495b14b2a666c1a]::util::run_in_thread_with_globals<rustc_interface[b495b14b2a666c1a]::util::run_in_thread_pool_with_globals<rustc_interface[b495b14b2a666c1a]::interface::run_compiler<core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>, rustc_driver_impl[c431125988ed1f11]::run_compiler::{closure#0}>::{closure#0}, core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>>::{closure#0}, core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>>
  44:     0x7f13bdb7e680 - <<std[466eff1cc2ed908f]::thread::Builder>::spawn_unchecked_<rustc_interface[b495b14b2a666c1a]::util::run_in_thread_with_globals<rustc_interface[b495b14b2a666c1a]::util::run_in_thread_pool_with_globals<rustc_interface[b495b14b2a666c1a]::interface::run_compiler<core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>, rustc_driver_impl[c431125988ed1f11]::run_compiler::{closure#0}>::{closure#0}, core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>>::{closure#0}, core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[16c6da236be526b4]::result::Result<(), rustc_span[f008fc136599d052]::ErrorGuaranteed>>::{closure#1} as core[16c6da236be526b4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7f13b8b99425 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf2f3f78227db386b
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/alloc/src/boxed.rs:2016:9
  46:     0x7f13b8b99425 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfde7215efc7d46f6
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/alloc/src/boxed.rs:2016:9
  47:     0x7f13b8b99425 - std::sys::pal::unix::thread::Thread::new::thread_start::hca4f71b4c325cea0
                               at /rustc/a84bb95a1f65bfe25038f188763a18e096a86ab2/library/std/src/sys/pal/unix/thread.rs:108:17
  48:     0x7f13b894b9eb - <unknown>
  49:     0x7f13b89cf7cc - <unknown>
  50:                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.78.0-nightly (a84bb95a1 2024-02-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z polymorphize=on -Z inline-mir=yes -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at /tmp/icemaker_global_tempdir.38EKKhyo0coV/rustc_testrunner_tmpdir_reporting.kSeYxCUoRCLn/mvce.rs:13:1: 13:34>::try_from`
#1 [unused_generic_params] determining which generic parameters are unused by `<impl at /tmp/icemaker_global_tempdir.38EKKhyo0coV/rustc_testrunner_tmpdir_reporting.kSeYxCUoRCLn/mvce.rs:13:1: 13:34>::try_from`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted

Some errors have detailed explanations: E0046, E0049, E0308, E0601.
For more information about an error, try `rustc --explain E0046`.

@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. A-mir-opt Area: MIR optimizations labels Feb 14, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 14, 2024
@matthiaskrgr
Copy link
Member Author

#120550 cc @oli-obk

@fmease
Copy link
Member

fmease commented Feb 14, 2024

generic crash exprs

sassy :P lol

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 14, 2024
@matthiaskrgr
Copy link
Member Author

probably the same issue:

use std::fmt;

pub enum TokenTree<S> {
    Leaf(Leaf<S>),
    Subtree(Subtree<S>),
}

pub enum Leaf<S> {
    Literal(Literal<S>),

    Ident(Ident<S>),
}

pub struct Subtree<S> {}

impl<S> fmt::Display for TokenTree<S> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            TokenTree::Leaf(it) => fmt::Display::fmt(it, f),
            TokenTree::Subtree(it) => fmt::Display::fmt(it, f),
        }
    }
}

impl<S> fmt::Display for Subtree<S> {
    fn fmt(text: impl Into<SmolStr>, span: S) -> fmt::Result {
        Ok(())
    }
}

impl<S> fmt::Display for Leaf<S> {}

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 18, 2024
@fmease fmease added the -Zpolymorphize Unstable option: Polymorphization. label Apr 20, 2024
@cushionbadak
Copy link

cushionbadak commented May 30, 2024

Backtrace update

rustc 1.80.0-nightly (debd22d 2024-05-29)

Backtrace

thread 'rustc' panicked at /rustc/debd22da66cfa97c74040ebf68e420672ac8560e/compiler/rustc_type_ir/src/binder.rs:708:9:
type parameter `impl AsRef<Path>/#0` (impl AsRef<Path>/#0/0) out of range when instantiating, args=[]
stack backtrace:
   0:        0x101383927 - std::backtrace::Backtrace::create::h2e80e68eee17e2f6
   1:        0x101383875 - std::backtrace::Backtrace::force_capture::h4fb5e71c673bb1ba
   2:        0x10a13406f - std[ecf23cfec152f35b]::panicking::update_hook::<alloc[9131486120985ab6]::boxed::Box<rustc_driver_impl[577e6c4a715b42f9]::install_ice_hook::{closure#0}>>::{closure#0}
   3:        0x10139da23 - std::panicking::rust_panic_with_hook::h48ac9d8bf680e17f
   4:        0x10139d362 - std::panicking::begin_panic_handler::{{closure}}::h260f1f7c11905560
   5:        0x10139a829 - std::sys_common::backtrace::__rust_end_short_backtrace::h9728cfd6bb3616f6
   6:        0x10139d096 - _rust_begin_unwind
   7:        0x101403672 - core::panicking::panic_fmt::h4f5b98d2bbfda4bd
   8:        0x10ea26015 - <rustc_type_ir[bbfc3483c8bf5bc2]::binder::ArgFolder<rustc_middle[34d74280616b98b2]::ty::context::TyCtxt>>::type_param_out_of_range
   9:        0x10af84d9b - <rustc_type_ir[bbfc3483c8bf5bc2]::binder::ArgFolder<rustc_middle[34d74280616b98b2]::ty::context::TyCtxt> as rustc_type_ir[bbfc3483c8bf5bc2]::fold::TypeFolder<rustc_middle[34d74280616b98b2]::ty::context::TyCtxt>>::fold_ty
  10:        0x10aefc92b - <rustc_middle[34d74280616b98b2]::mir::Body as rustc_type_ir[bbfc3483c8bf5bc2]::fold::TypeFoldable<rustc_middle[34d74280616b98b2]::ty::context::TyCtxt>>::try_fold_with::<rustc_type_ir[bbfc3483c8bf5bc2]::binder::ArgFolder<rustc_middle[34d74280616b98b2]::ty::context::TyCtxt>>
  11:        0x10aed209a - <rustc_middle[34d74280616b98b2]::ty::context::TyCtxt>::try_instantiate_and_normalize_erasing_regions::<rustc_middle[34d74280616b98b2]::mir::Body>
  12:        0x10afe1808 - <rustc_mir_transform[cc0cc57cf028ec00]::inline::Inliner>::try_inlining
  13:        0x10afe09f1 - <rustc_mir_transform[cc0cc57cf028ec00]::inline::Inliner>::process_blocks
  14:        0x10afe02be - <rustc_mir_transform[cc0cc57cf028ec00]::inline::Inline as rustc_middle[34d74280616b98b2]::mir::MirPass>::run_pass
  15:        0x10af8ecac - rustc_mir_transform[cc0cc57cf028ec00]::pass_manager::run_passes_inner
  16:        0x10b040fc4 - rustc_mir_transform[cc0cc57cf028ec00]::optimized_mir
  17:        0x10b5ff616 - rustc_query_impl[8bd67b4e4020215c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8bd67b4e4020215c]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[34d74280616b98b2]::query::erase::Erased<[u8; 8usize]>>
  18:        0x10b3d9273 - rustc_query_system[9b103579d163accf]::query::plumbing::try_execute_query::<rustc_query_impl[8bd67b4e4020215c]::DynamicConfig<rustc_query_system[9b103579d163accf]::query::caches::DefIdCache<rustc_middle[34d74280616b98b2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8bd67b4e4020215c]::plumbing::QueryCtxt, false>
  19:        0x10b6160c9 - rustc_query_impl[8bd67b4e4020215c]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  20:        0x10b0756cf - rustc_middle[34d74280616b98b2]::query::plumbing::query_get_at::<rustc_query_system[9b103579d163accf]::query::caches::DefIdCache<rustc_middle[34d74280616b98b2]::query::erase::Erased<[u8; 8usize]>>>
  21:        0x10b0aab8a - rustc_monomorphize[f43281e99d02b7b1]::polymorphize::unused_generic_params
  22:        0x10b601dc1 - rustc_query_impl[8bd67b4e4020215c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8bd67b4e4020215c]::query_impl::unused_generic_params::dynamic_query::{closure#2}::{closure#0}, rustc_middle[34d74280616b98b2]::query::erase::Erased<[u8; 4usize]>>
  23:        0x10b5b848f - <rustc_query_impl[8bd67b4e4020215c]::query_impl::unused_generic_params::dynamic_query::{closure#2} as core[cbba63e96e1eed3f]::ops::function::FnOnce<(rustc_middle[34d74280616b98b2]::ty::context::TyCtxt, rustc_middle[34d74280616b98b2]::ty::instance::InstanceDef)>>::call_once
  24:        0x10b43cde4 - rustc_query_system[9b103579d163accf]::query::plumbing::try_execute_query::<rustc_query_impl[8bd67b4e4020215c]::DynamicConfig<rustc_query_system[9b103579d163accf]::query::caches::DefaultCache<rustc_middle[34d74280616b98b2]::ty::instance::InstanceDef, rustc_middle[34d74280616b98b2]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[8bd67b4e4020215c]::plumbing::QueryCtxt, false>
  25:        0x10b659fa6 - rustc_query_impl[8bd67b4e4020215c]::query_impl::unused_generic_params::get_query_non_incr::__rust_end_short_backtrace
  26:        0x10a918c34 - rustc_interface[fcb9adb4e2b1ecf1]::passes::run_required_analyses
  27:        0x10a91ace3 - rustc_interface[fcb9adb4e2b1ecf1]::passes::analysis
  28:        0x10b6039ca - rustc_query_impl[8bd67b4e4020215c]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8bd67b4e4020215c]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[34d74280616b98b2]::query::erase::Erased<[u8; 1usize]>>
  29:        0x10b3e451e - rustc_query_system[9b103579d163accf]::query::plumbing::try_execute_query::<rustc_query_impl[8bd67b4e4020215c]::DynamicConfig<rustc_query_system[9b103579d163accf]::query::caches::SingleCache<rustc_middle[34d74280616b98b2]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8bd67b4e4020215c]::plumbing::QueryCtxt, false>
  30:        0x10b60db87 - rustc_query_impl[8bd67b4e4020215c]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:        0x10a0e3697 - <rustc_interface[fcb9adb4e2b1ecf1]::queries::QueryResult<&rustc_middle[34d74280616b98b2]::ty::context::GlobalCtxt>>::enter::<core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>, rustc_driver_impl[577e6c4a715b42f9]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  32:        0x10a13b09b - rustc_interface[fcb9adb4e2b1ecf1]::interface::run_compiler::<core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>, rustc_driver_impl[577e6c4a715b42f9]::run_compiler::{closure#0}>::{closure#1}
  33:        0x10a12dea1 - std[ecf23cfec152f35b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[fcb9adb4e2b1ecf1]::util::run_in_thread_with_globals<rustc_interface[fcb9adb4e2b1ecf1]::util::run_in_thread_pool_with_globals<rustc_interface[fcb9adb4e2b1ecf1]::interface::run_compiler<core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>, rustc_driver_impl[577e6c4a715b42f9]::run_compiler::{closure#0}>::{closure#1}, core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>>::{closure#0}, core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>>
  34:        0x10a142166 - <<std[ecf23cfec152f35b]::thread::Builder>::spawn_unchecked_<rustc_interface[fcb9adb4e2b1ecf1]::util::run_in_thread_with_globals<rustc_interface[fcb9adb4e2b1ecf1]::util::run_in_thread_pool_with_globals<rustc_interface[fcb9adb4e2b1ecf1]::interface::run_compiler<core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>, rustc_driver_impl[577e6c4a715b42f9]::run_compiler::{closure#0}>::{closure#1}, core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>>::{closure#0}, core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cbba63e96e1eed3f]::result::Result<(), rustc_span[eec1b011043f462a]::ErrorGuaranteed>>::{closure#2} as core[cbba63e96e1eed3f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:        0x1013a724b - std::sys::pal::unix::thread::Thread::new::thread_start::h8b147acd9fafa716
  36:     0x7ff802c1c18b - __pthread_start


rustc version: 1.80.0-nightly (debd22da6 2024-05-29)
platform: x86_64-apple-darwin

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at 121063.rs:13:1: 13:34>::try_from`
#1 [unused_generic_params] determining which generic parameters are unused by `<impl at 121063.rs:13:1: 13:34>::try_from`
#2 [analysis] running analysis passes on this crate
end of query stack

@bors bors closed this as completed in 5a853d0 Jul 25, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2024
Rollup merge of rust-lang#128171 - compiler-errors:arg-compat, r=oli-obk

Make sure that args are compatible in `resolve_associated_item`

Implements a similar check to the one that we have in projection for GATs (rust-lang#102488, rust-lang#123240), where we check that the args of an impl item are compatible before returning it. This is done in `resolve_assoc_item`, which is backing `Instance::resolve`, so this is conceptually generalizing the check from GATs to methods/assoc consts. This is important to make sure that the inliner will only visit and substitute MIR bodies that are compatible w/ their trait definitions.

This shouldn't happen in codegen, but there are a few ways to get the inliner to be invoked (via calls to `optimized_mir`) before codegen, namely polymorphization and CTFE.

Fixes rust-lang#121957
Fixes rust-lang#120792
Fixes rust-lang#120793
Fixes rust-lang#121063
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zpolymorphize Unstable option: Polymorphization. A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants