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

Compiler panic when string literal contains emoji followed by a quote #44078

Closed
Alvenix opened this issue Aug 25, 2017 · 1 comment · Fixed by #44081
Closed

Compiler panic when string literal contains emoji followed by a quote #44078

Alvenix opened this issue Aug 25, 2017 · 1 comment · Fixed by #44081
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Alvenix
Copy link

Alvenix commented Aug 25, 2017

When I try to compile the following incorrect code:

fn main() {
    println!("💞"");
}

This happen:

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/blob/master/CONTRIBUTING.md#bug-reports

thread 'rustc' panicked at 'byte index 16 is not a char boundary; it is inside '💞' (bytes 14..18) of `    println!("💞"");`', src/libcore/str/mod.rs:2161
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Version information:

rustc --version --verbose
rustc 1.19.0 (0ade339 2017-07-17)
binary: rustc
commit-hash: 0ade339
commit-date: 2017-07-17
host: x86_64-apple-darwin
release: 1.19.0
LLVM version: 4.0

Backtrace:

stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::str::slice_error_fail
   9: rustc_errors::emitter::EmitterWriter::emit_message_default
  10: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit
  11: rustc_errors::Handler::emit
  12: rustc_errors::Handler::span_fatal
  13: syntax::parse::lexer::StringReader::fatal_span_
  14: syntax::parse::lexer::StringReader::next_token_inner
  15: syntax::parse::lexer::StringReader::advance_token
  16: syntax::parse::lexer::StringReader::try_next_token
  17: syntax::parse::lexer::StringReader::real_token
  18: syntax::parse::lexer::tokentrees::<impl syntax::parse::lexer::StringReader<'a>>::parse_token_tree
  19: syntax::parse::lexer::tokentrees::<impl syntax::parse::lexer::StringReader<'a>>::parse_token_tree
  20: syntax::parse::lexer::tokentrees::<impl syntax::parse::lexer::StringReader<'a>>::parse_all_token_trees
  21: syntax::parse::filemap_to_stream
  22: syntax::parse::filemap_to_parser
  23: syntax::parse::parse_crate_from_file
  24: rustc_driver::driver::phase_1_parse_input::{{closure}}
  25: rustc_driver::driver::phase_1_parse_input
  26: rustc_driver::driver::compile_input
  27: rustc_driver::run_compiler
@est31
Copy link
Member

est31 commented Aug 25, 2017

Hmm this has unconvered a more fundamental bug with the error emission machinery: #44080

Fixing this ICE is very easy, but fixing that bug is not as easy.

est31 added a commit to est31/rust that referenced this issue Aug 25, 2017
Fixes rust-lang#44078. Fixes rust-lang#44023.

The start_col member is given in chars,
while the code previously assumed it was given in bytes.

The more basic issue rust-lang#44080 doesn't get fixed.
@shepmaster shepmaster added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 25, 2017
alexcrichton added a commit to alexcrichton/rust that referenced this issue Aug 26, 2017
Fix a byte/char confusion issue in the error emitter

Fixes rust-lang#44078. Fixes rust-lang#44023.

The start_col member is given in chars, while the code previously assumed it was given in bytes.

The more basic issue rust-lang#44080 doesn't get fixed.
bors added a commit that referenced this issue Aug 26, 2017
Fix a byte/char confusion issue in the error emitter

Fixes #44078. Fixes #44023.

The start_col member is given in chars, while the code previously assumed it was given in bytes.

The more basic issue #44080 doesn't get fixed.
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. 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