Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ICE failed while formatting fluent string parse_help_set_edition_standalone #122130

Closed
matthiaskrgr opened this issue Mar 7, 2024 · 5 comments · Fixed by #122160
Closed

ICE failed while formatting fluent string parse_help_set_edition_standalone #122130

matthiaskrgr opened this issue Mar 7, 2024 · 5 comments · Fixed by #122160
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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):

`
enum will {
 so error so.
#[in_expr = c"owned_box"]so error
}


original:

`#[repr(align(8))]
enum will {
 so #[derive(Copy,< Clone)]error so.
#[in_expr = c"owned_box"]so error
}

fn nE0225() {
}

Version information

rustc 1.78.0-nightly (aa029ce4d 2024-03-07)
binary: rustc
commit-hash: aa029ce4d8f5048dafd44b6af794542ee19f7c37
commit-date: 2024-03-07
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: unknown start of token: `
 --> /tmp/icemaker_global_tempdir.hMnGGiie2zo3/rustc_testrunner_tmpdir_reporting.biPnAJzziyvK/mvce.rs:1:1
  |
1 | `
  | ^
  |
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
  |
1 | '
  |

error: expected one of `(`, `,`, `=`, `{`, or `}`, found `error`
 --> /tmp/icemaker_global_tempdir.hMnGGiie2zo3/rustc_testrunner_tmpdir_reporting.biPnAJzziyvK/mvce.rs:3:5
  |
3 |  so error so.
  |    -^^^^^ expected one of `(`, `,`, `=`, `{`, or `}`
  |    |
  |    help: missing `,`

error: expected one of `(`, `,`, `=`, `{`, or `}`, found `so`
 --> /tmp/icemaker_global_tempdir.hMnGGiie2zo3/rustc_testrunner_tmpdir_reporting.biPnAJzziyvK/mvce.rs:3:11
  |
3 |  so error so.
  |          -^^ expected one of `(`, `,`, `=`, `{`, or `}`
  |          |
  |          help: missing `,`

error: expected one of `(`, `,`, `=`, `{`, or `}`, found `.`
 --> /tmp/icemaker_global_tempdir.hMnGGiie2zo3/rustc_testrunner_tmpdir_reporting.biPnAJzziyvK/mvce.rs:3:13
  |
3 |  so error so.
  |             ^ expected one of `(`, `,`, `=`, `{`, or `}`
  |
  = note: you may be trying to write a c-string literal
  = note: c-string literals require Rust 2021 or later
thread 'rustc' panicked at compiler/rustc_errors/src/emitter.rs:1255:80:
called `Result::unwrap()` on an `Err` value: failed while formatting fluent string `parse_help_set_edition_standalone`: 
the fluent string has an argument `edition` that was not found.
help: no arguments are available

stack backtrace:
   0:     0x7f2317fbf744 - std::backtrace_rs::backtrace::libunwind::trace::hbcc4ff1e55c0c501
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f2317fbf744 - std::backtrace_rs::backtrace::trace_unsynchronized::h244e2800f31b8681
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2317fbf744 - std::sys_common::backtrace::_print_fmt::h828b9db0be6187a8
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f2317fbf744 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h243be6cd2d738d3c
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f2318010a7c - core::fmt::rt::Argument::fmt::hd45a8a4455368ade
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/core/src/fmt/rt.rs:142:9
   5:     0x7f2318010a7c - core::fmt::write_internal::hfb0b5663bbad0387
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/core/src/fmt/mod.rs:1143:17
   6:     0x7f2317fb4047 - core::fmt::write::h7be64e76d49b7e8a
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/core/src/fmt/mod.rs:1125:67
   7:     0x7f2317fb4047 - std::io::Write::write_fmt::h965f02b503bc577f
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/io/mod.rs:1846:15
   8:     0x7f2317fbf4f4 - std::sys_common::backtrace::_print::h15133f077154ef6b
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/sys_common/backtrace.rs:47:5
   9:     0x7f2317fbf4f4 - std::sys_common::backtrace::print::hd8612a43eb5c3c7f
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/sys_common/backtrace.rs:34:9
  10:     0x7f2317fc20fb - std::panicking::default_hook::{{closure}}::h569474e03da8ecce
  11:     0x7f2317fc1e57 - std::panicking::default_hook::hfd09221dda053b32
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/panicking.rs:292:9
  12:     0x7f2314c6b6bc - std[58148fe030350034]::panicking::update_hook::<alloc[e3f315c417df7fbb]::boxed::Box<rustc_driver_impl[a095b7c95f7403ba]::install_ice_hook::{closure#0}>>::{closure#0}
  13:     0x7f2317fc2812 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbb48d6b867a2ba6e
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/alloc/src/boxed.rs:2030:9
  14:     0x7f2317fc2812 - std::panicking::rust_panic_with_hook::ha68c2fa485ff9c30
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/panicking.rs:783:13
  15:     0x7f2317fc25d2 - std::panicking::begin_panic_handler::{{closure}}::h49d326f776e0946a
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/panicking.rs:657:13
  16:     0x7f2317fbfc16 - std::sys_common::backtrace::__rust_end_short_backtrace::hb3d460f6d0c4a367
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/sys_common/backtrace.rs:171:18
  17:     0x7f2317fc22d4 - rust_begin_unwind
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/panicking.rs:645:5
  18:     0x7f231800ccd5 - core::panicking::panic_fmt::h5069377c83c7fdb5
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/core/src/panicking.rs:72:14
  19:     0x7f231800d383 - core::result::unwrap_failed::h37661f0385038cab
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/core/src/result.rs:1654:5
  20:     0x7f2316d5b698 - <rustc_errors[4e3786a71f43e379]::emitter::HumanEmitter>::msgs_to_buffer
  21:     0x7f2316d61715 - <rustc_errors[4e3786a71f43e379]::emitter::HumanEmitter>::emit_messages_default_inner::{closure#0}
  22:     0x7f2316d575e8 - <rustc_errors[4e3786a71f43e379]::emitter::HumanEmitter>::emit_messages_default
  23:     0x7f2316d46b0f - <rustc_errors[4e3786a71f43e379]::emitter::HumanEmitter as rustc_errors[4e3786a71f43e379]::emitter::Emitter>::emit_diagnostic
  24:     0x7f2316d45783 - <rustc_errors[4e3786a71f43e379]::DiagCtxtInner>::emit_diagnostic::{closure#2}
  25:     0x7f2316d43c5a - rustc_interface[153d4fca0aaf0544]::callbacks::track_diagnostic
  26:     0x7f2316d426a8 - <rustc_errors[4e3786a71f43e379]::DiagCtxtInner>::emit_diagnostic
  27:     0x7f2316d42555 - <rustc_errors[4e3786a71f43e379]::DiagCtxt>::emit_diagnostic
  28:     0x7f23170cbc94 - <rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed as rustc_errors[4e3786a71f43e379]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  29:     0x7f23166b4c83 - <rustc_parse[5b3cc82c4b7abd38]::parser::Parser>::parse_item_enum
  30:     0x7f231694c5e0 - <rustc_parse[5b3cc82c4b7abd38]::parser::Parser>::parse_item_kind
  31:     0x7f231648188d - <rustc_parse[5b3cc82c4b7abd38]::parser::Parser>::parse_item_common
  32:     0x7f231647f2e3 - <rustc_parse[5b3cc82c4b7abd38]::parser::Parser>::parse_mod
  33:     0x7f2316c2a318 - rustc_interface[153d4fca0aaf0544]::passes::parse
  34:     0x7f2316c2a113 - <rustc_interface[153d4fca0aaf0544]::queries::Queries>::parse
  35:     0x7f2316d3aa99 - rustc_interface[153d4fca0aaf0544]::interface::run_compiler::<core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>, rustc_driver_impl[a095b7c95f7403ba]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7f2316fce90f - std[58148fe030350034]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[153d4fca0aaf0544]::util::run_in_thread_with_globals<rustc_interface[153d4fca0aaf0544]::util::run_in_thread_pool_with_globals<rustc_interface[153d4fca0aaf0544]::interface::run_compiler<core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>, rustc_driver_impl[a095b7c95f7403ba]::run_compiler::{closure#0}>::{closure#0}, core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>>::{closure#0}, core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>>
  37:     0x7f2316fce73c - <<std[58148fe030350034]::thread::Builder>::spawn_unchecked_<rustc_interface[153d4fca0aaf0544]::util::run_in_thread_with_globals<rustc_interface[153d4fca0aaf0544]::util::run_in_thread_pool_with_globals<rustc_interface[153d4fca0aaf0544]::interface::run_compiler<core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>, rustc_driver_impl[a095b7c95f7403ba]::run_compiler::{closure#0}>::{closure#0}, core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>>::{closure#0}, core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b4ced4ae5bd6c925]::result::Result<(), rustc_span[23f9fdf8aac2fd91]::ErrorGuaranteed>>::{closure#1} as core[b4ced4ae5bd6c925]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f2317fcbf75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4b22e8e21b559643
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/alloc/src/boxed.rs:2016:9
  39:     0x7f2317fcbf75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h218224bbab018518
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/alloc/src/boxed.rs:2016:9
  40:     0x7f2317fcbf75 - std::sys::pal::unix::thread::Thread::new::thread_start::ha7d24c05a9440d85
                               at /rustc/aa029ce4d8f5048dafd44b6af794542ee19f7c37/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x7f2311c7355a - <unknown>
  42:     0x7f2311cf0a3c - <unknown>
  43:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.78.0-nightly (aa029ce4d 2024-03-07) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 4 previous errors


@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Mar 7, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 7, 2024
@jieyouxu jieyouxu added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Mar 7, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Mar 7, 2024

Slightly smaller:

enum will {
    s#[c"owned_box"]
}

@matthiaskrgr
Copy link
Member Author

#118691 cc @chfogelman

@jieyouxu
Copy link
Member

jieyouxu commented Mar 7, 2024

#118691 cc @chfogelman

HelpUseLatestEdition::new().add_to_diagnostic(&mut err);

Somehow this subdiag enum

#[derive(Subdiagnostic)]
pub enum HelpUseLatestEdition {
    #[help(parse_help_set_edition_cargo)]
    #[note(parse_note_edition_guide)]
    Cargo { edition: Edition },
    #[help(parse_help_set_edition_standalone)]
    #[note(parse_note_edition_guide)]
    Standalone { edition: Edition },
}

impl HelpUseLatestEdition {
    pub fn new() -> Self {
        let edition = LATEST_STABLE_EDITION;
        if rustc_session::utils::was_invoked_from_cargo() {
            Self::Cargo { edition }
        } else {
            Self::Standalone { edition }
        }
    }
}

being added to a diagnostic causes

the fluent string has an argument `edition` that was not found.
help: no arguments are available

but the #[derive(Subdiagnostic)] looks okay to me...?

@jieyouxu
Copy link
Member

jieyouxu commented Mar 7, 2024

Also suspicious:

compiler/rustc_parse/src/parser/expr.rs
3453:            errors::HelpUseLatestEdition::new().add_to_diagnostic(e);

compiler/rustc_hir_typeck/src/expr.rs
2603:            HelpUseLatestEdition::new().add_to_diagnostic(&mut err);

@jieyouxu
Copy link
Member

jieyouxu commented Mar 7, 2024

Seems like for the subdiag HelpUseLatestEdition whose fluent messages contain a variable, they need to be eagerly translated via diag.subdiagnostics(dcx, subdiag) instead of using subdiag.add_to_diagnostic(diag). However I'm not very familiar with this distinction.

jhpratt added a commit to jhpratt/rust that referenced this issue Mar 9, 2024
…latest-edition, r=cjgillot

Eagerly translate `HelpUseLatestEdition` in parser diagnostics

Fixes rust-lang#122130.

This makes me suspicious of these other two usage of  `add_to_diagnostic()`. Would they *also* crash? I haven't attempted to construct test cases for them.

```
compiler/rustc_parse/src/parser/expr.rs
3453:            errors::HelpUseLatestEdition::new().add_to_diagnostic(e);

compiler/rustc_hir_typeck/src/expr.rs
2603:            HelpUseLatestEdition::new().add_to_diagnostic(&mut err);
```

This also seems like a footgun?
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 9, 2024
…latest-edition, r=cjgillot

Eagerly translate `HelpUseLatestEdition` in parser diagnostics

Fixes rust-lang#122130.

This makes me suspicious of these other two usage of  `add_to_diagnostic()`. Would they *also* crash? I haven't attempted to construct test cases for them.

```
compiler/rustc_parse/src/parser/expr.rs
3453:            errors::HelpUseLatestEdition::new().add_to_diagnostic(e);

compiler/rustc_hir_typeck/src/expr.rs
2603:            HelpUseLatestEdition::new().add_to_diagnostic(&mut err);
```

This also seems like a footgun?
@bors bors closed this as completed in 985befe Mar 9, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 9, 2024
Rollup merge of rust-lang#122160 - jieyouxu:eager-translate-help-use-latest-edition, r=cjgillot

Eagerly translate `HelpUseLatestEdition` in parser diagnostics

Fixes rust-lang#122130.

This makes me suspicious of these other two usage of  `add_to_diagnostic()`. Would they *also* crash? I haven't attempted to construct test cases for them.

```
compiler/rustc_parse/src/parser/expr.rs
3453:            errors::HelpUseLatestEdition::new().add_to_diagnostic(e);

compiler/rustc_hir_typeck/src/expr.rs
2603:            HelpUseLatestEdition::new().add_to_diagnostic(&mut err);
```

This also seems like a footgun?
@jieyouxu jieyouxu added A-diagnostics Area: Messages for errors, warnings, and lints and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants