Skip to content

ICE: internal compiler error: coercion error but no error emitted #134355

Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

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

original:

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

Program output

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

Activity

  1. added
    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.
    on Dec 15, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Dec 15, 2024
  3. matthiaskrgr commented on Dec 15, 2024

    @matthiaskrgr
    MemberAuthor

    bisects to nightly-2023-06-04

    commit[0] 2023-06-02: Auto merge of #112162 - nnethercote:clarify-mono-item-usage, r=wesleywiser
    commit[1] 2023-06-02: Auto merge of #112228 - compiler-errors:rollup-97i0pli, r=compiler-errors
    commit[2] 2023-06-03: Auto merge of #112217 - arlosi:update-vuln-deps, r=Mark-Simulacrum
    commit[3] 2023-06-03: Auto merge of #111350 - chenyukang:yukang-remove-type-asc, r=Nilstrieb
    commit[4] 2023-06-03: Auto merge of #111516 - compiler-errors:issue-111500, r=jackh726
    commit[5] 2023-06-03: Auto merge of #109432 - flba-eb:108594_forkspawn_exponential_backoff, r=workingjubilee
    commit[6] 2023-06-03: Auto merge of #112032 - sladyn98:migrate-item-primitive, r=GuillaumeGomez
    commit[7] 2023-06-03: Auto merge of #112253 - matthiaskrgr:rollup-c37jpm5, r=matthiaskrgr

    probably related to #112215

  4. matthiaskrgr commented on Dec 15, 2024

    @matthiaskrgr
    MemberAuthor

    kinda wild that we don't emit an error here? 😅
    a nightly before, this would emit

    error[E0308]: mismatched types
     --> /tmp/crash.rs:2:14
      |
    2 |     return { i32::MIN };
      |              ^^^^^^^^ expected `str`, found `i32`
    
    error: aborting due to previous error; 1 warning emitted
    
  5. added
    A-coercionsArea: implicit and explicit `expr as Type` coercions
    on Dec 20, 2024
  6. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 3, 2025
  7. added
    S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.
    on Jan 5, 2025
  8. reddevilmidzy commented on Oct 17, 2025

    @reddevilmidzy
    Member

    @rustbot claim

  9. lqd commented on Oct 18, 2025

    @lqd
    Member

    Note: the ICE was fixed by #136274

  10. added 2 commits that reference this issue on Oct 18, 2025
    c721e50
    54c6939
  11. added a commit that references this issue on Oct 19, 2025
    918f434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-coercionsArea: implicit and explicit `expr as Type` coercionsC-bugCategory: This is a bug.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