Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
matthiaskrgr opened this issue Dec 15, 2024 · 2 comments
Open

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

matthiaskrgr opened this issue Dec 15, 2024 · 2 comments
Labels
A-coercions Area: implicit and explicit `expr as Type` coercions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 15, 2024
@matthiaskrgr
Copy link
Member Author

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

@matthiaskrgr
Copy link
Member Author

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

@jieyouxu jieyouxu added the A-coercions Area: implicit and explicit `expr as Type` coercions label Dec 20, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 3, 2025
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jan 5, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-coercions Area: implicit and explicit `expr as Type` coercions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants