Skip to content

ICE: encountered type variable #131758

Open
Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(unboxed_closures)]
trait Foo {}

impl<T: Fn<(i32,)>> Foo for T {}

fn baz<T: Foo>(_: T) {}

fn main() {
    baz(|x| ());
}

original:

trait Foo {}

impl<T: Fn<(i32,)>> Foo for T {}

fn baz<T: Foo>(_: T) {}

fn main() {
    baz(|_| ());
    //~^ ERROR implementation of `FnOnce` is not general enough
    //~| ERROR implementation of `Fn` is not general enough
    baz(|x| ());
    //~^ ERROR implementation of `FnOnce` is not general enough
    //~| ERROR implementation of `Fn` is not general enough
}

Version information

rustc 1.84.0-nightly (a0c2aba29 2024-10-15)
binary: rustc
commit-hash: a0c2aba29aa9ea50a7c45c3391dd446f856bef7b
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(unboxed_closures)

Program output

warning: unused variable: `x`
 --> /tmp/icemaker_global_tempdir.qRMnYYI19Q4z/rustc_testrunner_tmpdir_reporting.nQT3i3c5eog1/mvce.rs:8:10
  |
8 |     baz(|x| ());
  |          ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` 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: encountered type variable
 --> /tmp/icemaker_global_tempdir.qRMnYYI19Q4z/rustc_testrunner_tmpdir_reporting.nQT3i3c5eog1/mvce.rs:8:10
  |
8 |     baz(|x| ());
  |          ^
  |
note: delayed at compiler/rustc_hir_typeck/src/expr_use_visitor.rs:174:20 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.qRMnYYI19Q4z/rustc_testrunner_tmpdir_reporting.nQT3i3c5eog1/mvce.rs:8:10
  |
8 |     baz(|x| ());
  |          ^

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.84.0-nightly (a0c2aba29 2024-10-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(unboxed_closures) -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@rustbot label +F-unboxed_closures

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-closuresArea: Closures (`|…| { … }`)C-bugCategory: This is a bug.F-unboxed_closures`#![feature(unboxed_closures)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.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