rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.87k stars 12.67k forks source link

ICE: `encountered type variable` #131758

Open matthiaskrgr opened 6 days ago

matthiaskrgr commented 6 days ago

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

matthiaskrgr commented 6 days ago

bisects to #124902