Skip to content

Crash when pass some invalid format string by proc-macro #80224

Closed
@Riey

Description

@Riey

Code

use thiserror::Error;

#[derive(Debug, Error)]
pub enum LexicalError {
    #[error("{0.what}ㅇ")]
    InvalidCode(i32),
}

Meta

rustc 1.48.0 (7eac88a 2020-11-16)
binary: rustc
commit-hash: 7eac88a
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0

it also occured in nightly-2020-11-25

Error output

Compiling ice-example v0.1.0 (/home/riey/repos/ice-example)
thread 'rustc' panicked at 'assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32', compiler/rustc_span/src/source_map.rs:950:17
Backtrace

stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_span::source_map::SourceMap::bytepos_to_file_charpos
   2: rustc_span::source_map::SourceMap::lookup_char_pos
   3: rustc_errors::emitter::EmitterWriter::get_multispan_max_line_num
   4: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   5: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
   6: rustc_errors::HandlerInner::emit_diagnostic
   7: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
   8: rustc_builtin_macros::format::expand_preparsed_format_args
   9: rustc_builtin_macros::format::expand_format_args_impl
  10: rustc_expand::expand::MacroExpander::fully_expand_fragment
  11: rustc_expand::expand::MacroExpander::expand_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::configure_and_expand_inner
  14: rustc_interface::passes::configure_and_expand::{{closure}}
  15: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  16: rustc_interface::passes::configure_and_expand
  17: rustc_interface::queries::Queries::expansion
  18: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  19: rustc_span::with_source_map
  20: 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.48.0 (7eac88abb 2020-11-16) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
error: could not compile `ice-example`

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosC-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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions