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

Internal compiler error while trying to use formatdoc #51

Closed
VorfeedCanal opened this issue Nov 19, 2022 · 1 comment
Closed

Internal compiler error while trying to use formatdoc #51

VorfeedCanal opened this issue Nov 19, 2022 · 1 comment

Comments

@VorfeedCanal
Copy link

Code

use indoc::formatdoc;

fn main() {
    let 𝗍𝗋𝖺𝗂𝗍_𝗇𝖺𝗆𝖾 = "Trait";
    let 𝖿𝗇_𝗇𝖺𝗆𝖾 = "fun";
    println!("{}", formatdoc!("
                          pub trait {𝗍𝗋𝖺𝗂𝗍_𝗇𝖺𝗆𝖾};
                          fn {𝖿𝗇_𝗇𝖺𝗆𝖾};}}"));
}

Meta

Bug is reproducible with different compilers but is extremely finicky WRT to small changes to source: white space change fixes it and/or causes it to return.

rustc --version --verbose:

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: aarch64-apple-darwin
release: 1.65.0
LLVM version: 15.0.0

Error output

   Compiling hello_world v0.1.0 (/tmp/hello_world)
warning: identifier contains uncommon Unicode codepoints
 --> src/main.rs:4:9
  |
4 |     let 𝗍𝗋𝖺𝗂𝗍_𝗇𝖺𝗆𝖾 = "Trait";
  |         ^^^^^^^^^^
  |
  = note: `#[warn(uncommon_codepoints)]` on by default

warning: identifier contains uncommon Unicode codepoints
 --> src/main.rs:5:9
  |
5 |     let 𝖿𝗇_𝗇𝖺𝗆𝖾 = "fun";
  |         ^^^^^^^

thread 'rustc' panicked at 'byte index 221 is not a char boundary; it is inside '𝗍' (bytes 220..224) of `use indoc::formatdoc;

fn main() {
    let 𝗍𝗋𝖺𝗂𝗍_𝗇𝖺𝗆𝖾 = "Trait";
    let 𝖿𝗇_𝗇𝖺𝗆𝖾 = "fun";
    println!("{}", formatdoc!("
                          pub trait {𝗍𝗋𝖺𝗂𝗍_𝗇𝖺𝗆𝖾};
            `[...]', compiler/rustc_span/src/source_map.rs:921:14
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: <rustc_span::source_map::SourceMap>::find_width_of_character_at_span
   5: <rustc_span::source_map::SourceMap>::end_point
   6: <rustc_mir_build::build::Builder>::schedule_drop
   7: <rustc_mir_build::build::Builder>::as_temp_inner
   8: <rustc_mir_build::build::Builder>::as_operand
   9: <rustc_mir_build::build::Builder>::as_call_operand
  10: <core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::adapters::map::map_fold<rustc_middle::thir::ExprId, rustc_middle::mir::syntax::Operand, (), <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}, core::iter::traits::iterator::Iterator::for_each::call<rustc_middle::mir::syntax::Operand, <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_extend::SpecExtend<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::spec_extend::{closure#0}>::{closure#0}>::{closure#0}>
  11: <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::from_iter
  12: <rustc_mir_build::build::Builder>::expr_into_dest
  13: <rustc_mir_build::build::Builder>::as_temp_inner
  14: <rustc_mir_build::build::Builder>::as_operand
  15: <rustc_mir_build::build::Builder>::as_operand
  16: <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::as_rvalue::{closure#1}>>>::from_iter
  17: <rustc_mir_build::build::Builder>::as_rvalue
  18: <rustc_mir_build::build::Builder>::expr_into_dest
  19: <rustc_mir_build::build::Builder>::as_temp_inner
  20: <rustc_mir_build::build::Builder>::expr_as_place
  21: <rustc_mir_build::build::Builder>::expr_as_place
  22: <rustc_mir_build::build::Builder>::as_read_only_place
  23: <rustc_mir_build::build::Builder>::expr_into_dest
  24: <rustc_mir_build::build::Builder>::as_temp_inner
  25: <rustc_mir_build::build::Builder>::expr_as_place
  26: <rustc_mir_build::build::Builder>::expr_as_place
  27: <rustc_mir_build::build::Builder>::as_read_only_place
  28: <rustc_mir_build::build::Builder>::expr_into_dest
  29: <rustc_mir_build::build::Builder>::as_temp_inner
  30: <rustc_mir_build::build::Builder>::as_operand
  31: <rustc_mir_build::build::Builder>::as_rvalue
  32: <rustc_mir_build::build::Builder>::expr_into_dest
  33: <rustc_mir_build::build::Builder>::as_temp_inner
  34: <rustc_mir_build::build::Builder>::as_operand
  35: <rustc_mir_build::build::Builder>::as_call_operand
  36: <core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::adapters::map::map_fold<rustc_middle::thir::ExprId, rustc_middle::mir::syntax::Operand, (), <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}, core::iter::traits::iterator::Iterator::for_each::call<rustc_middle::mir::syntax::Operand, <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_extend::SpecExtend<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::spec_extend::{closure#0}>::{closure#0}>::{closure#0}>
  37: <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::from_iter
  38: <rustc_mir_build::build::Builder>::expr_into_dest
  39: <rustc_mir_build::build::Builder>::as_temp_inner
  40: <rustc_mir_build::build::Builder>::as_operand
  41: <rustc_mir_build::build::Builder>::as_call_operand
  42: <core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::adapters::map::map_fold<rustc_middle::thir::ExprId, rustc_middle::mir::syntax::Operand, (), <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}, core::iter::traits::iterator::Iterator::for_each::call<rustc_middle::mir::syntax::Operand, <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_extend::SpecExtend<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::spec_extend::{closure#0}>::{closure#0}>::{closure#0}>
  43: <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::from_iter
  44: <rustc_mir_build::build::Builder>::expr_into_dest
  45: <rustc_mir_build::build::Builder>::in_scope::<<rustc_mir_build::build::Builder>::expr_into_dest::{closure#0}::{closure#0}, ()>
  46: <rustc_mir_build::build::Builder>::expr_into_dest::{closure#0}
  47: <rustc_mir_build::build::Builder>::expr_into_dest
  48: <rustc_mir_build::build::Builder>::ast_block_stmts
  49: <rustc_mir_build::build::Builder>::expr_into_dest
  50: <rustc_mir_build::build::Builder>::as_temp_inner
  51: <rustc_mir_build::build::Builder>::expr_as_place
  52: <rustc_mir_build::build::Builder>::expr_as_place
  53: <rustc_mir_build::build::Builder>::as_read_only_place
  54: <rustc_mir_build::build::Builder>::expr_into_dest
  55: <rustc_mir_build::build::Builder>::as_temp_inner
  56: <rustc_mir_build::build::Builder>::expr_as_place
  57: <rustc_mir_build::build::Builder>::expr_as_place
  58: <rustc_mir_build::build::Builder>::as_read_only_place
  59: <rustc_mir_build::build::Builder>::expr_into_dest
  60: <rustc_mir_build::build::Builder>::as_temp_inner
  61: <rustc_mir_build::build::Builder>::as_operand
  62: <rustc_mir_build::build::Builder>::as_call_operand
  63: <core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::adapters::map::map_fold<rustc_middle::thir::ExprId, rustc_middle::mir::syntax::Operand, (), <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}, core::iter::traits::iterator::Iterator::for_each::call<rustc_middle::mir::syntax::Operand, <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_extend::SpecExtend<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::spec_extend::{closure#0}>::{closure#0}>::{closure#0}>
  64: <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::from_iter
  65: <rustc_mir_build::build::Builder>::expr_into_dest
  66: <rustc_mir_build::build::Builder>::as_temp_inner
  67: <rustc_mir_build::build::Builder>::as_operand
  68: <rustc_mir_build::build::Builder>::as_operand
  69: <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::as_rvalue::{closure#1}>>>::from_iter
  70: <rustc_mir_build::build::Builder>::as_rvalue
  71: <rustc_mir_build::build::Builder>::expr_into_dest
  72: <rustc_mir_build::build::Builder>::as_temp_inner
  73: <rustc_mir_build::build::Builder>::expr_as_place
  74: <rustc_mir_build::build::Builder>::expr_as_place
  75: <rustc_mir_build::build::Builder>::as_read_only_place
  76: <rustc_mir_build::build::Builder>::expr_into_dest
  77: <rustc_mir_build::build::Builder>::as_temp_inner
  78: <rustc_mir_build::build::Builder>::expr_as_place
  79: <rustc_mir_build::build::Builder>::expr_as_place
  80: <rustc_mir_build::build::Builder>::as_read_only_place
  81: <rustc_mir_build::build::Builder>::expr_into_dest
  82: <rustc_mir_build::build::Builder>::as_temp_inner
  83: <rustc_mir_build::build::Builder>::as_operand
  84: <rustc_mir_build::build::Builder>::as_rvalue
  85: <rustc_mir_build::build::Builder>::expr_into_dest
  86: <rustc_mir_build::build::Builder>::as_temp_inner
  87: <rustc_mir_build::build::Builder>::as_operand
  88: <rustc_mir_build::build::Builder>::as_call_operand
  89: <core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::adapters::map::map_fold<rustc_middle::thir::ExprId, rustc_middle::mir::syntax::Operand, (), <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}, core::iter::traits::iterator::Iterator::for_each::call<rustc_middle::mir::syntax::Operand, <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_extend::SpecExtend<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::spec_extend::{closure#0}>::{closure#0}>::{closure#0}>
  90: <alloc::vec::Vec<rustc_middle::mir::syntax::Operand> as alloc::vec::spec_from_iter::SpecFromIter<rustc_middle::mir::syntax::Operand, core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::thir::ExprId>>, <rustc_mir_build::build::Builder>::expr_into_dest::{closure#3}>>>::from_iter
  91: <rustc_mir_build::build::Builder>::expr_into_dest
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.65.0 (897e37553 2022-11-02) running on aarch64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [mir_built] building MIR for `main`
#1 [unsafety_check_result] unsafety-checking `main`
#2 [mir_const] processing MIR for `main`
#3 [mir_promoted] processing `main`
#4 [mir_borrowck] borrow-checking `main`
#5 [analysis] running analysis passes on this crate
end of query stack
warning: `hello_world` (bin "hello_world") generated 2 warnings
error: could not compile `hello_world`; 2 warnings emitted
[hello_world.zip](https://github.com/dtolnay/indoc/files/10047945/hello_world.zip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants