Skip to content

ICE and bad string (un)escaping regression in assert macro #50471

Closed
@ollie27

Description

@ollie27

I tried this code:

assert!({false})
assert!(r"\u{41}" == "A")
assert!(r"\u{".is_empty())

I expected to see this happen:

thread 'main' panicked at 'assertion failed: { false }'
thread 'main' panicked at 'assertion failed: r"\u{41}" == "A"'
thread 'main' panicked at 'assertion failed: r"\u{".is_empty()'

Instead, this happened:

thread 'main' panicked at 'assertion failed: {{ false }}'
thread 'main' panicked at 'assertion failed: r"A" == "A"'
thread 'rustc' panicked at 'lexer should have rejected invalid escape sequences', libcore\option.rs:916:5
stack backtrace:
   0: std::rt::lang_start_internal
   1: std::sys::windows::c::TryAcquireSRWLockShared
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: rustc::ty::maps::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::maps::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::option::expect_failed
  10: syntax_ext::deriving::partial_ord::cs_partial_cmp
  11: syntax_ext::deriving::partial_ord::cs_partial_cmp
  12: syntax::ext::expand::MacroExpander::expand_crate
  13: syntax::ext::expand::MacroExpander::expand_crate
  14: syntax::ext::expand::MacroExpander::expand_crate
  15: rustc_driver::driver::build_output_filenames
  16: rustc_driver::driver::build_output_filenames
  17: rustc_driver::driver::count_nodes
  18: rustc_driver::driver::compile_input
  19: rustc_driver::run_compiler
  20: rustc_driver::target_features::add_configuration
  21: <unknown>
  22: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  23: _rust_maybe_catch_panic
  24: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  25: std::sync::mpsc::blocking::WaitToken::wait_max_until
  26: std::sys::windows::thread::Thread::new
  27: BaseThreadInitThunk
  28: RtlUserThreadStart

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

note: rustc 1.26.0-beta.18 (1f200ac2c 2018-05-03) running on x86_64-pc-windows-msvc

They all work in 1.25.0 but not in 1.26.0 beta or nightly and I think this is caused by #48813 (cc. @sinkuu).

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions