Repository: rust
Issue: ICE: `internal compiler error: coercion error but no error emitted`
Labels: I-ICE,T-compiler,C-bug,A-coercions,S-bug-has-test

<!--
[31mICE[0m: Rustc ./a.rs '--crate-type=lib -ooutputfile -Zdump-mir-dir=dir' 'error: internal compiler error[E0277]: the size for values of type `str` cannot be known at compilation time', 'error: internal compiler error[E0277]: the size for values of type `str` cannot be known at compilation time'
File: /tmp/im/a.rs
-->

auto-reduced (treereduce-rust):
````rust
//@compile-flags: --crate-type=lib
fn digit() -> str {
    return { i32::MIN };
}

````

original:
````rust
fn digit() -> str {
    return {i32::MIN};
}

````

Version information
````
rustc 1.85.0-nightly (d18506299 2024-12-15)
binary: rustc
commit-hash: d18506299bfb20488aba466a69641a2bab6f7a4a
commit-date: 2024-12-15
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5

````



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

<details><summary><strong>Program output</strong></summary>
<p>

```
warning: unnecessary braces around `return` value
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:2:12
  |
2 |     return { i32::MIN };
  |            ^^        ^^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
2 -     return { i32::MIN };
2 +     return i32::MIN;
  |

warning: function `digit` is never used
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:1:4
  |
1 | fn digit() -> str {
  |    ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 2 warnings 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: coercion error but no error emitted
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:2:14
  |
2 |     return { i32::MIN };
  |              ^^^^^^^^
  |
note: delayed at compiler/rustc_hir_typeck/src/coercion.rs:1666:31 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:2:14
  |
2 |     return { i32::MIN };
  |              ^^^^^^^^

error: internal compiler error[E0308]: mismatched types
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:2:14
  |
1 | fn digit() -> str {
  |               --- expected `str` because of return type
2 |     return { i32::MIN };
  |              ^^^^^^^^ expected `str`, found `i32`
  |
note: delayed at compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs:2038:35 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:2:14
  |
2 |     return { i32::MIN };
  |              ^^^^^^^^

error: internal compiler error[E0277]: the size for values of type `str` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:1:15
  |
1 | fn digit() -> str {
  |               ^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `str`
  = note: the return type of a function must have a statically known size
note: delayed at compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:259:39 - disabled backtrace
 --> /tmp/icemaker_global_tempdir.QVsadqybRl15/rustc_testrunner_tmpdir_reporting.Ov3ZSIZ9UPa5/mvce.rs:1:15
  |
1 | fn digit() -> str {
  |               ^^^

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.85.0-nightly (d18506299 2024-12-15) 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

```

</p>
</details>

<!--
query stack:

-->