Skip to content

ICE: trait takes 1 generic argument but 0 generic arguments were supplied #128249

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait<Type> {
    type Type;

    fn method(&self) -> impl Trait<Type: '_>;
}

original:

trait Trait<Type> {
    type Type;

    fn method(&self) -> impl Trait<Type: '_>;
    // the problematic bound ------------^^
}

Version information

rustc 1.82.0-nightly (2d5a628a1 2024-07-26)
binary: rustc
commit-hash: 2d5a628a1de1d38318909a710ef37da6251e362e
commit-date: 2024-07-26
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib

Program output

warning: trait `Trait` is never used
 --> /tmp/icemaker_global_tempdir.esDLOVYEjfST/rustc_testrunner_tmpdir_reporting.Iwz5Hytr9bHo/mvce.rs:1:7
  |
1 | trait Trait<Type> {
  |       ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
 --> /tmp/icemaker_global_tempdir.esDLOVYEjfST/rustc_testrunner_tmpdir_reporting.Iwz5Hytr9bHo/mvce.rs:4:30
  |
4 |     fn method(&self) -> impl Trait<Type: '_>;
  |                              ^^^^^ expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `Type`
 --> /tmp/icemaker_global_tempdir.esDLOVYEjfST/rustc_testrunner_tmpdir_reporting.Iwz5Hytr9bHo/mvce.rs:1:7
  |
1 | trait Trait<Type> {
  |       ^^^^^ ----
note: delayed at compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs:1133:23 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.esDLOVYEjfST/rustc_testrunner_tmpdir_reporting.Iwz5Hytr9bHo/mvce.rs:4:30
  |
4 |     fn method(&self) -> impl Trait<Type: '_>;
  |                              ^^^^^
help: add missing generic argument
  |
4 |     fn method(&self) -> impl Trait<Type, Type: '_>;
  |                                    +++++

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:543:29 - disabled backtrace

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 (2d5a628a1 2024-07-26) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
end of query stack

Metadata

Metadata

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