rust-lang / rust-lang/rust

[ICE]: `expected lifetime parameter, but found another generic parameter: GenericParamDef ..`

Open
#151,313 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-ICE P-medium regression-from-stable-to-nightly T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
pub(crate) trait AsyncLend {
    type From<'a>
    where
        Self: 'a;
    async fn lend(from: Self::From<'_>) -> Self::From<'_>;
}

impl<T, F> AsyncLend for (T, F) {
    type From<'a> = ();

    async fn lend(from: Self::From<'_>) -> Pin {
        from
    }
}

original:

pub(crate) trait AsyncLend {
    type From<'a>
    where
        Self: 'a;
    async fn lend(from: Self::From<'_>) -> Self::From<'_>;
}

impl<T, F> AsyncLend for (T, F) {
    type From<'a> = ();

    async fn lend(from: Self::From<'_>) -> Pin<Box<dyn Future<Output = ()> + Send>> {
        from
    }
}

Version information

rustc 1.95.0-nightly (621d76794 2026-01-18)
binary: rustc
commit-hash: 621d76794c76fc21c0a6151fbc090120e0230a91
commit-date: 2026-01-18
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8

Possibly related line of code:
https://github.com/rust-lang/rust/blob/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_middle/src/ty/generics.rs#L241-L253

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:5:5
  |
5 |     async fn lend(from: Self::From<'_>) -> Self::From<'_>;
  |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2024` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0670]: `async fn` is not permitted in Rust 2015
  --> /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:11:5
   |
11 |     async fn lend(from: Self::From<'_>) -> Pin {
   |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
   |
   = help: pass `--edition 2024` to `rustc`
   = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0425]: cannot find type `Pin` in this scope
  --> /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:11:44
   |
11 |     async fn lend(from: Self::From<'_>) -> Pin {
   |                                            ^^^ not found in this scope
   |
help: consider importing this struct
   |
 1 + use std::pin::Pin;
   |

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

error[E0309]: the parameter type `T` may not live long enough
 --> /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:9:21
  |
9 |     type From<'a> = ();
  |               --    ^^ ...so that the type `(T, F)` will meet its required lifetime bounds
  |               |
  |               the parameter type `T` must be valid for the lifetime `'a` as defined here...
  |
help: consider adding an explicit lifetime bound
  |
9 |     type From<'a> = () where T: 'a;
  |                        +++++++++++

error[E0309]: the parameter type `F` may not live long enough
 --> /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:9:21
  |
9 |     type From<'a> = ();
  |               --    ^^ ...so that the type `(T, F)` will meet its required lifetime bounds
  |               |
  |               the parameter type `F` must be valid for the lifetime `'a` as defined here...
  |
help: consider adding an explicit lifetime bound
  |
9 |     type From<'a> = () where F: 'a;
  |                        +++++++++++

error[E0311]: the parameter type `T` may not live long enough
 --> /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:5:25
  |
5 |     async fn lend(from: Self::From<'_>) -> Self::From<'_>;
  |                         ^^^^^^^^^^^--^
  |                         |          |
  |                         |          the parameter type `T` must be valid for the anonymous lifetime as defined here...
  |                         ...so that the type `(T, F)` will meet its required lifetime bounds
  |
help: consider adding an explicit lifetime bound
  |
5 -     async fn lend(from: Self::From<'_>) -> Self::From<'_>;
5 +     async fn lend<'a>(from: Self::From<'a>) -> Self::From<'a> where T: 'a;
  |

error[E0311]: the parameter type `F` may not live long enough
 --> /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:5:25
  |
5 |     async fn lend(from: Self::From<'_>) -> Self::From<'_>;
  |                         ^^^^^^^^^^^--^
  |                         |          |
  |                         |          the parameter type `F` must be valid for the anonymous lifetime as defined here...
  |                         ...so that the type `(T, F)` will meet its required lifetime bounds
  |
help: consider adding an explicit lifetime bound
  |
5 -     async fn lend(from: Self::From<'_>) -> Self::From<'_>;
5 +     async fn lend<'a>(from: Self::From<'a>) -> Self::From<'a> where F: 'a;
  |

error: internal compiler error: /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_middle/src/ty/generics.rs:247:17: expected lifetime parameter, but found another generic parameter: GenericParamDef {
                                    name: "F",
                                    def_id: DefId(0:10 ~ mvce[a621]::{impl#0}::F),
                                    index: 1,
                                    pure_wrt_drop: false,
                                    kind: Type {
                                        has_default: false,
                                        synthetic: false,
                                    },
                                }


thread 'rustc' (1398377) panicked at /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_middle/src/ty/generics.rs:247:17:
Box<dyn Any>
stack backtrace:
   0:     0x7fd8ef433fd3 - <<std[287527946f71f0bc]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7477a31a1a34cc49]::fmt::Display>::fmt
   1:     0x7fd8efa0e2c8 - core[7477a31a1a34cc49]::fmt::write
   2:     0x7fd8ef44a9c6 - <std[287527946f71f0bc]::sys::stdio::unix::Stderr as std[287527946f71f0bc]::io::Write>::write_fmt
   3:     0x7fd8ef40a048 - std[287527946f71f0bc]::panicking::default_hook::{closure#0}
   4:     0x7fd8ef427703 - std[287527946f71f0bc]::panicking::default_hook
   5:     0x7fd8ee3fbb8a - std[287527946f71f0bc]::panicking::update_hook::<alloc[979041e9952e771b]::boxed::Box<rustc_driver_impl[517260a07841a630]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd8ef4279e2 - std[287527946f71f0bc]::panicking::panic_with_hook
   7:     0x7fd8ee438bc1 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}
   8:     0x7fd8ee428fe6 - std[287527946f71f0bc]::sys::backtrace::__rust_end_short_backtrace::<std[287527946f71f0bc]::panicking::begin_panic<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}, !>
   9:     0x7fd8ee4264b9 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>
  10:     0x7fd8ee456901 - <rustc_errors[26c9ea40265c581b]::diagnostic::BugAbort as rustc_errors[26c9ea40265c581b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fd8eea074f9 - rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt::<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}
  12:     0x7fd8eea07682 - rustc_middle[725063e074f29df]::ty::context::tls::with_opt::<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fd8ee9f8cab - rustc_middle[725063e074f29df]::ty::context::tls::with_context_opt::<rustc_middle[725063e074f29df]::ty::context::tls::with_opt<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fd8ebe91cc4 - rustc_middle[725063e074f29df]::util::bug::bug_fmt
  15:     0x7fd8f16d0f5a - <rustc_middle[725063e074f29df]::ty::region::Region>::opt_param_def_id.cold
  16:     0x7fd8eea25b24 - <rustc_middle[725063e074f29df]::ty::context::TyCtxt>::is_suitable_region
  17:     0x7fd8ef1f22a5 - <rustc_trait_selection[9fee51d8a10a777c]::error_reporting::TypeErrCtxt>::construct_generic_bound_failure
  18:     0x7fd8ef1ee4b0 - <rustc_trait_selection[9fee51d8a10a777c]::error_reporting::TypeErrCtxt>::report_region_errors
  19:     0x7fd8f040ce4c - <rustc_trait_selection[9fee51d8a10a777c]::traits::engine::ObligationCtxt<rustc_trait_selection[9fee51d8a10a777c]::traits::FulfillmentError>>::resolve_regions_and_report_errors::<indexmap[625b39e164a783fb]::set::IndexSet<rustc_middle[725063e074f29df]::ty::Ty, core[7477a31a1a34cc49]::hash::BuildHasherDefault<rustc_hash[fee08caa250aad94]::FxHasher>>>
  20:     0x7fd8f0428e4e - rustc_hir_analysis[1a80394817eddfdd]::check::compare_impl_item::check_type_bounds
  21:     0x7fd8f03e168c - rustc_hir_analysis[1a80394817eddfdd]::check::compare_impl_item::compare_impl_item
  22:     0x7fd8f03dea99 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::compare_impl_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>
  23:     0x7fd8f0192f78 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_data_structures[e0d8483206daafa2]::vec_cache::VecCache<rustc_span[851f35e07e3c2dd4]::def_id::LocalDefId, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[b7e73caa2c2ad9a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  24:     0x7fd8f0192a51 - rustc_query_impl[f20b8284200e680a]::query_impl::compare_impl_item::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7fd8f0195eaa - rustc_hir_analysis[1a80394817eddfdd]::check::check::check_item_type
  26:     0x7fd8f019379c - rustc_hir_analysis[1a80394817eddfdd]::check::wfcheck::check_well_formed
  27:     0x7fd8f019376b - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7fd8f01931e3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_data_structures[e0d8483206daafa2]::vec_cache::VecCache<rustc_span[851f35e07e3c2dd4]::def_id::LocalDefId, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[b7e73caa2c2ad9a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  29:     0x7fd8f0192cd6 - rustc_query_impl[f20b8284200e680a]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7fd8f0190470 - rustc_hir_analysis[1a80394817eddfdd]::check::wfcheck::check_type_wf
  31:     0x7fd8f019035d - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7fd8f0ba3e85 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  33:     0x7fd8f0ba3b36 - rustc_query_impl[f20b8284200e680a]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7fd8f053f316 - rustc_hir_analysis[1a80394817eddfdd]::check_crate
  35:     0x7fd8efb493db - rustc_interface[5c48368f5debe80d]::passes::analysis
  36:     0x7fd8efb49035 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>
  37:     0x7fd8f0ba4be3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  38:     0x7fd8f0ba49ce - rustc_query_impl[f20b8284200e680a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7fd8f0d82c11 - <rustc_interface[5c48368f5debe80d]::passes::create_and_enter_global_ctxt<core[7477a31a1a34cc49]::option::Option<rustc_interface[5c48368f5debe80d]::queries::Linker>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(&rustc_session[eb79e6d3104f29ae]::session::Session, rustc_middle[725063e074f29df]::ty::context::CurrentGcx, alloc[979041e9952e771b]::sync::Arc<rustc_data_structures[e0d8483206daafa2]::jobserver::Proxy>, &std[287527946f71f0bc]::sync::once_lock::OnceLock<rustc_middle[725063e074f29df]::ty::context::GlobalCtxt>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_middle[725063e074f29df]::arena::Arena>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_hir[7eac7792dedc1861]::Arena>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  40:     0x7fd8f0bf5d34 - rustc_interface[5c48368f5debe80d]::interface::run_compiler::<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7fd8f0b5aa3a - std[287527946f71f0bc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7fd8f0b5a7fe - <std[287527946f71f0bc]::thread::lifecycle::spawn_unchecked<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7477a31a1a34cc49]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7fd8f0b5c5c4 - <std[287527946f71f0bc]::sys::thread::unix::Thread>::new::thread_start
  44:     0x7fd8ea49698b - <unknown>
  45:     0x7fd8ea51a9cc - <unknown>
  46:                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.95.0-nightly (621d76794 2026-01-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [compare_impl_item] checking assoc item `<impl at /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:8:1: 8:32>::lend::{anon_assoc#0}` is compatible with trait definition
#1 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.N69Bvlw7oDqw/rustc_testrunner_tmpdir_reporting.Z888mcM6dQvS/mvce.rs:8:1: 8:32>` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 9 previous errors

Some errors have detailed explanations: E0309, E0311, E0425, E0601, E0670.
For more information about an error, try `rustc --explain E0309`.

@rustbot label +WG-trait-system-refactor

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reduced Rust program in the issue and reproduce it using rustc -Znext-solver=globally. Inspect compiler/rustc_middle/src/ty/generics.rs around lines 241-253 and the reported is_suitable_region path; done means the example no longer produces an internal compiler error and reports the appropriate diagnostics instead.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.