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

Backslash at the end of line followed by \n on the next line in a print! or println! macro crashes rustc #83708

Closed
devins2518 opened this issue Mar 31, 2021 · 3 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@devins2518
Copy link

Code

This fails to compile using both println!() and print():

fn main() {
    println!(
        "  {}\
        \n {}
        \n {} ╭",
        "hello", "hello",
    );
}

This does not panic the compiler but correctly gives an error that the number of arguments are incorrect:

fn main() {
    println!(
        "  {}
        \n {}
        \n {} ╭",
        "hello", "hello",
    );
}

Meta

Stable, nightly, and beta fail with the same error.

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

Error output

    Running `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=8603d8e21acbe81f -C extra-filename=-8603d8e21acbe81f --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps`
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1512:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: 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.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `t`

Caused by:
  process didn't exit successfully: `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=8603d8e21acbe81f -C extra-filename=-8603d8e21acbe81f --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps` (exit code: 101)
Stable Backtrace

   Compiling t v0.1.0 (/home/devin/Repos/t)
     Running `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=8603d8e21acbe81f -C extra-filename=-8603d8e21acbe81f --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps`
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1512:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:50:5
   3: rustc_span::SourceFile::lookup_file_pos
   4: rustc_span::SourceFile::lookup_file_pos_with_col_display
   5: rustc_span::source_map::SourceMap::lookup_char_pos
   6: rustc_errors::emitter::EmitterWriter::get_multispan_max_line_num
   7: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   8: rustc_errors::json::Diagnostic::from_errors_diagnostic
   9: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  10: rustc_errors::HandlerInner::emit_diagnostic
  11: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  12: rustc_builtin_macros::format::expand_preparsed_format_args
  13: rustc_builtin_macros::format::expand_format_args_impl
  14: rustc_expand::expand::MacroExpander::fully_expand_fragment
  15: rustc_expand::expand::MacroExpander::expand_crate
  16: rustc_session::utils::<impl rustc_session::session::Session>::time
  17: rustc_interface::passes::configure_and_expand_inner
  18: rustc_interface::passes::configure_and_expand::{{closure}}
  19: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  20: rustc_interface::passes::configure_and_expand
  21: rustc_interface::queries::Queries::expansion
  22: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  23: rustc_span::with_source_map
  24: rustc_interface::interface::create_compiler_and_run
  25: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: 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.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `t`

Caused by:
  process didn't exit successfully: `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=8603d8e21acbe81f -C extra-filename=-8603d8e21acbe81f --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps` (exit code: 101)

Nightly Backtrace

   Compiling t v0.1.0 (/home/devin/Repos/t)
     Running `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=1403359c3521122d -C extra-filename=-1403359c3521122d --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps`
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1513:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/107896c32d5dda4db508968ff34997a39d286966/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/107896c32d5dda4db508968ff34997a39d286966/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/107896c32d5dda4db508968ff34997a39d286966/library/core/src/panicking.rs:50:5
   3: rustc_span::SourceFile::lookup_file_pos
   4: rustc_span::SourceFile::lookup_file_pos_with_col_display
   5: rustc_span::source_map::SourceMap::lookup_char_pos
   6: rustc_errors::emitter::EmitterWriter::get_multispan_max_line_num
   7: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   8: rustc_errors::json::Diagnostic::from_errors_diagnostic
   9: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  10: rustc_errors::HandlerInner::emit_diagnostic
  11: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  12: rustc_builtin_macros::format::expand_preparsed_format_args
  13: rustc_builtin_macros::format::expand_format_args_impl
  14: rustc_expand::expand::MacroExpander::fully_expand_fragment
  15: rustc_expand::expand::MacroExpander::expand_crate
  16: rustc_session::utils::<impl rustc_session::session::Session>::time
  17: rustc_interface::passes::configure_and_expand_inner
  18: rustc_interface::passes::configure_and_expand::{{closure}}
  19: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  20: rustc_interface::passes::configure_and_expand
  21: rustc_interface::queries::Queries::expansion
  22: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  23: rustc_span::with_source_map
  24: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: 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.52.0-nightly (107896c32 2021-03-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `t`

Caused by:
  process didn't exit successfully: `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=1403359c3521122d -C extra-filename=-1403359c3521122d --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps` (exit code: 101)

Beta Backtrace

   Compiling t v0.1.0 (/home/devin/Repos/t)
     Running `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=2bf67af2c447314e -C extra-filename=-2bf67af2c447314e --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps`
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/lib.rs:1512:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4f27db6956dbd50bb3ce92a73e344d1d02bb1a63/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/4f27db6956dbd50bb3ce92a73e344d1d02bb1a63/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/4f27db6956dbd50bb3ce92a73e344d1d02bb1a63/library/core/src/panicking.rs:50:5
   3: rustc_span::SourceFile::lookup_file_pos
   4: rustc_span::SourceFile::lookup_file_pos_with_col_display
   5: rustc_span::source_map::SourceMap::lookup_char_pos
   6: rustc_errors::emitter::EmitterWriter::get_multispan_max_line_num
   7: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   8: rustc_errors::json::Diagnostic::from_errors_diagnostic
   9: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  10: rustc_errors::HandlerInner::emit_diagnostic
  11: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  12: rustc_builtin_macros::format::expand_preparsed_format_args
  13: rustc_builtin_macros::format::expand_format_args_impl
  14: rustc_expand::expand::MacroExpander::fully_expand_fragment
  15: rustc_expand::expand::MacroExpander::expand_crate
  16: rustc_session::utils::<impl rustc_session::session::Session>::time
  17: rustc_interface::passes::configure_and_expand_inner
  18: rustc_interface::passes::configure_and_expand::{{closure}}
  19: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  20: rustc_interface::passes::configure_and_expand
  21: rustc_interface::queries::Queries::expansion
  22: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  23: rustc_span::with_source_map
  24: rustc_interface::interface::create_compiler_and_run
  25: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: 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.52.0-beta.2 (4f27db695 2021-03-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `t`

Caused by:
  process didn't exit successfully: `rustc --crate-name t --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=2bf67af2c447314e -C extra-filename=-2bf67af2c447314e --out-dir /home/devin/Repos/t/target/debug/deps -C incremental=/home/devin/Repos/t/target/debug/incremental -L dependency=/home/devin/Repos/t/target/debug/deps` (exit code: 101)

@devins2518 devins2518 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 Mar 31, 2021
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 31, 2021
@apiraino
Copy link
Contributor

apiraino commented Apr 1, 2021

Assigning priority as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 1, 2021
@klensy
Copy link
Contributor

klensy commented Apr 1, 2021

There was similar issue #83344

Checked on a5029ac, issue was fixed.

@devins2518
Copy link
Author

Ok, thanks for checking that out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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

5 participants