Skip to content

ICE: Special char (like RTL(U+202E)) in comment for value in vec! would cause ICE if not add #[allow(text_direction_codepoint_in_literal)] #140281

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

Open
wychlw opened this issue Apr 25, 2025 · 1 comment · May be fixed by #141004
Assignees
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ L-text_direction_codepoint_in_literal Lint: text_direction_codepoint_in_literal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wychlw
Copy link

wychlw commented Apr 25, 2025

Code

// #[allow(text_direction_codepoint_in_literal)]
fn main() {
    let t = vec![
        /// ‮test⁦ RTL in doc in vec!
        //  ICE (Sadly)
        1
    ];
}

Note: the string comment is: \u+202e test \u+2066 RTL in doc in vec!

And actually if you ADD the #[allow(text_direction_codepoint_in_literal)], ICE would disappear.
However, I think with out it should get a error just like other situation has a special character, instead of an ICE directly?

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (d7ea436a0 2025-04-24)
binary: rustc
commit-hash: d7ea436a02d5de4033fcf7fd4eb8ed965d0f574c
commit-date: 2025-04-24
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Error output

thread 'rustc' panicked at compiler/rustc_span/src/lib.rs:2252:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
...
query stack during panic:
#0 [early_lint_checks] perform lints prior to AST lowering
#1 [hir_crate] getting the crate HIR
#2 [opt_hir_owner_nodes] getting HIR owner items in ``
#3 [hir_crate_items] getting HIR crate items
#4 [proc_macro_decls_static] looking up the proc macro declarations for a crate
#5 [analysis] running analysis passes on this crate
end of query stack
Backtrace

warning: unused doc comment
 --> results/3.rs:4:9
  |
4 |         /// �test� RTL in doc in vec!
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 |         //  ICE (Sadly)
6 |         1
  |         - rustdoc does not generate documentation for expressions
  |
  = help: use `//` for a plain comment
  = note: `#[warn(unused_doc_comments)]` on by default


thread 'rustc' panicked at compiler/rustc_span/src/lib.rs:2252:17:
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32
stack backtrace:
   0:     0x74e8bf700af3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h904445fd43971ac2
   1:     0x74e8bfe05ac7 - core::fmt::write::haf953ebbe9ae3b8f
   2:     0x74e8c11ed151 - std::io::Write::write_fmt::hf56a31f7c729c1eb
   3:     0x74e8bf700952 - std::sys::backtrace::BacktraceLock::print::ha4c7301f21e048e8
   4:     0x74e8bf7042ca - std::panicking::default_hook::{{closure}}::hdf738965590aed1b
   5:     0x74e8bf703e4f - std::panicking::default_hook::ha27c43c4ffc1fe90
   6:     0x74e8be774973 - std[da27df0714dc5aa6]::panicking::update_hook::<alloc[4e641192740d77f8]::boxed::Box<rustc_driver_impl[aa060002af73b10]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x74e8bf704b43 - std::panicking::rust_panic_with_hook::h0b6c03f2b60724f5
   8:     0x74e8bf704806 - std::panicking::begin_panic_handler::{{closure}}::hbce440c8d6435cba
   9:     0x74e8bf700fb9 - std::sys::backtrace::__rust_end_short_backtrace::h6024a3502da9a7e6
  10:     0x74e8bf7044fd - __rustc[b94488cf790a175f]::rust_begin_unwind
  11:     0x74e8bc08c7d0 - core::panicking::panic_fmt::hcfb4f56b51bd6104
  12:     0x74e8bc0913ac - core::panicking::panic::h806b26c9718f2945
  13:     0x74e8c074db65 - <rustc_span[697d8df8862c8d77]::source_map::SourceMap>::lookup_char_pos
  14:     0x74e8c074a50f - <rustc_errors[cee55832778cbb75]::emitter::HumanEmitter>::get_multispan_max_line_num
  15:     0x74e8c0752f82 - <rustc_errors[cee55832778cbb75]::emitter::HumanEmitter as rustc_errors[cee55832778cbb75]::emitter::Emitter>::emit_diagnostic
  16:     0x74e8c0dea668 - <rustc_errors[cee55832778cbb75]::DiagCtxtInner>::emit_diagnostic::{closure#3}
  17:     0x74e8c0decf5d - rustc_interface[1c505902b33a67ab]::callbacks::track_diagnostic::<core[3597e8473f983ff]::option::Option<rustc_span[697d8df8862c8d77]::ErrorGuaranteed>>
  18:     0x74e8c0debba6 - <rustc_errors[cee55832778cbb75]::DiagCtxtInner>::emit_diagnostic
  19:     0x74e8c0deba79 - <rustc_errors[cee55832778cbb75]::DiagCtxtHandle>::emit_diagnostic
  20:     0x74e8c0deb915 - <() as rustc_errors[cee55832778cbb75]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  21:     0x74e8c038fbc4 - rustc_middle[79325ec0783d6836]::lint::lint_level::lint_level_impl
  22:     0x74e8becd2069 - <rustc_lint[e0647b199692e64d]::hidden_unicode_codepoints::HiddenUnicodeCodepoints>::lint_text_direction_codepoint
  23:     0x74e8bc38c45b - <rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass as rustc_lint[e0647b199692e64d]::passes::EarlyLintPass>::check_expr
  24:     0x74e8bfea6903 - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass>>::with_lint_attrs::<<rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_expr::{closure#0}>
  25:     0x74e8bfea7750 - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass>>::with_lint_attrs::<<rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_expr::{closure#0}>
  26:     0x74e8bfea6d05 - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass>>::with_lint_attrs::<<rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_expr::{closure#0}>
  27:     0x74e8bfea6a49 - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass>>::with_lint_attrs::<<rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_expr::{closure#0}>
  28:     0x74e8bfea6a49 - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass>>::with_lint_attrs::<<rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_expr::{closure#0}>
  29:     0x74e8bfea8914 - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_block
  30:     0x74e8bfeac111 - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_fn
  31:     0x74e8bfeafc22 - rustc_ast[c70a88a4ab5e43d5]::visit::walk_item_ctxt::<rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass>, rustc_ast[c70a88a4ab5e43d5]::ast::ItemKind>
  32:     0x74e8bfeaf4af - <rustc_lint[e0647b199692e64d]::early::EarlyContextAndPass<rustc_lint[e0647b199692e64d]::BuiltinCombinedEarlyLintPass> as rustc_ast[c70a88a4ab5e43d5]::visit::Visitor>::visit_item
  33:     0x74e8c05268a8 - rustc_interface[1c505902b33a67ab]::passes::early_lint_checks
  34:     0x74e8c052610d - rustc_query_impl[20a6bea039ee1f44]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a6bea039ee1f44]::query_impl::early_lint_checks::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 0usize]>>
  35:     0x74e8c0d5bd7d - rustc_query_system[ec6c378d7b3d9aa4]::query::plumbing::try_execute_query::<rustc_query_impl[20a6bea039ee1f44]::DynamicConfig<rustc_query_system[ec6c378d7b3d9aa4]::query::caches::SingleCache<rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[20a6bea039ee1f44]::plumbing::QueryCtxt, false>
  36:     0x74e8c0d5bafa - rustc_query_impl[20a6bea039ee1f44]::query_impl::early_lint_checks::get_query_non_incr::__rust_end_short_backtrace
  37:     0x74e8c036a2d2 - rustc_ast_lowering[ca3ab2546c6ae290]::lower_to_hir
  38:     0x74e8c0d5b2e4 - rustc_query_impl[20a6bea039ee1f44]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a6bea039ee1f44]::query_impl::hir_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 8usize]>>
  39:     0x74e8c0d5db04 - rustc_query_system[ec6c378d7b3d9aa4]::query::plumbing::try_execute_query::<rustc_query_impl[20a6bea039ee1f44]::DynamicConfig<rustc_query_system[ec6c378d7b3d9aa4]::query::caches::SingleCache<rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[20a6bea039ee1f44]::plumbing::QueryCtxt, false>
  40:     0x74e8c0d5d8df - rustc_query_impl[20a6bea039ee1f44]::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
  41:     0x74e8c01879f6 - rustc_query_impl[20a6bea039ee1f44]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a6bea039ee1f44]::query_impl::opt_hir_owner_nodes::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 8usize]>>
  42:     0x74e8c0186aac - rustc_query_system[ec6c378d7b3d9aa4]::query::plumbing::try_execute_query::<rustc_query_impl[20a6bea039ee1f44]::DynamicConfig<rustc_data_structures[8818201305a26393]::vec_cache::VecCache<rustc_span[697d8df8862c8d77]::def_id::LocalDefId, rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[ec6c378d7b3d9aa4]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[20a6bea039ee1f44]::plumbing::QueryCtxt, false>
  43:     0x74e8c018674d - rustc_query_impl[20a6bea039ee1f44]::query_impl::opt_hir_owner_nodes::get_query_non_incr::__rust_end_short_backtrace
  44:     0x74e8c09152ae - <rustc_middle[79325ec0783d6836]::ty::context::TyCtxt>::expect_hir_owner_nodes
  45:     0x74e8c018d07c - rustc_middle[79325ec0783d6836]::hir::map::hir_crate_items
  46:     0x74e8c0c4845d - rustc_query_impl[20a6bea039ee1f44]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a6bea039ee1f44]::query_impl::hir_crate_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 8usize]>>
  47:     0x74e8c0d5db04 - rustc_query_system[ec6c378d7b3d9aa4]::query::plumbing::try_execute_query::<rustc_query_impl[20a6bea039ee1f44]::DynamicConfig<rustc_query_system[ec6c378d7b3d9aa4]::query::caches::SingleCache<rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[20a6bea039ee1f44]::plumbing::QueryCtxt, false>
  48:     0x74e8c0d5d41f - rustc_query_impl[20a6bea039ee1f44]::query_impl::hir_crate_items::get_query_non_incr::__rust_end_short_backtrace
  49:     0x74e8c03968cb - rustc_interface[1c505902b33a67ab]::proc_macro_decls::proc_macro_decls_static
  50:     0x74e8c10863b5 - rustc_query_impl[20a6bea039ee1f44]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a6bea039ee1f44]::query_impl::proc_macro_decls_static::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 4usize]>>
  51:     0x74e8c1085f84 - rustc_query_system[ec6c378d7b3d9aa4]::query::plumbing::try_execute_query::<rustc_query_impl[20a6bea039ee1f44]::DynamicConfig<rustc_query_system[ec6c378d7b3d9aa4]::query::caches::SingleCache<rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[20a6bea039ee1f44]::plumbing::QueryCtxt, false>
  52:     0x74e8c1085d74 - rustc_query_impl[20a6bea039ee1f44]::query_impl::proc_macro_decls_static::get_query_non_incr::__rust_end_short_backtrace
  53:     0x74e8c0909b90 - rustc_interface[1c505902b33a67ab]::passes::run_required_analyses
  54:     0x74e8c0a6aede - rustc_interface[1c505902b33a67ab]::passes::analysis
  55:     0x74e8c0a6aeb3 - rustc_query_impl[20a6bea039ee1f44]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[20a6bea039ee1f44]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 0usize]>>
  56:     0x74e8c0d5bd7d - rustc_query_system[ec6c378d7b3d9aa4]::query::plumbing::try_execute_query::<rustc_query_impl[20a6bea039ee1f44]::DynamicConfig<rustc_query_system[ec6c378d7b3d9aa4]::query::caches::SingleCache<rustc_middle[79325ec0783d6836]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[20a6bea039ee1f44]::plumbing::QueryCtxt, false>
  57:     0x74e8c0d5ba78 - rustc_query_impl[20a6bea039ee1f44]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  58:     0x74e8c109a3c0 - rustc_interface[1c505902b33a67ab]::passes::create_and_enter_global_ctxt::<core[3597e8473f983ff]::option::Option<rustc_interface[1c505902b33a67ab]::queries::Linker>, rustc_driver_impl[aa060002af73b10]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  59:     0x74e8c0ecc604 - rustc_interface[1c505902b33a67ab]::interface::run_compiler::<(), rustc_driver_impl[aa060002af73b10]::run_compiler::{closure#0}>::{closure#1}
  60:     0x74e8c0eacdf4 - std[da27df0714dc5aa6]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1c505902b33a67ab]::util::run_in_thread_with_globals<rustc_interface[1c505902b33a67ab]::util::run_in_thread_pool_with_globals<rustc_interface[1c505902b33a67ab]::interface::run_compiler<(), rustc_driver_impl[aa060002af73b10]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  61:     0x74e8c0ead234 - <<std[da27df0714dc5aa6]::thread::Builder>::spawn_unchecked_<rustc_interface[1c505902b33a67ab]::util::run_in_thread_with_globals<rustc_interface[1c505902b33a67ab]::util::run_in_thread_pool_with_globals<rustc_interface[1c505902b33a67ab]::interface::run_compiler<(), rustc_driver_impl[aa060002af73b10]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3597e8473f983ff]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  62:     0x74e8c0eae62b - std::sys::pal::unix::thread::Thread::new::thread_start::h7c46323428199a20
  63:     0x74e8baca3708 - <unknown>
  64:     0x74e8bad27aac - <unknown>
  65:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.88.0-nightly (d7ea436a0 2025-04-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -Z no-codegen -Z mir-opt-level=4 -Z validate-mir --crate-type lib

query stack during panic:
#0 [early_lint_checks] perform lints prior to AST lowering
#1 [hir_crate] getting the crate HIR
#2 [opt_hir_owner_nodes] getting HIR owner items in ``
#3 [hir_crate_items] getting HIR crate items
#4 [proc_macro_decls_static] looking up the proc macro declarations for a crate
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

@wychlw wychlw 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 Apr 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 25, 2025
@wychlw wychlw changed the title ICE: Special char (like RTL(U+202E)) in doc comment for value in vec! would cause ICE if not add #[allow(text_direction_codepoint_in_literal)] ICE: Special char (like RTL(U+202E)) in comment for value in vec! would cause ICE if not add #[allow(text_direction_codepoint_in_literal)] Apr 25, 2025
@theemathas
Copy link
Contributor

ICE also occurs with user-defined macro_rules:

macro_rules! foo {
    ($x:expr) => { $x }
}

fn main() {
    foo!(
        /// ‮test⁦ RTL in doc in macro
        1
    );
}

@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. L-text_direction_codepoint_in_literal Lint: text_direction_codepoint_in_literal A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 25, 2025
@matthewjasper matthewjasper self-assigned this Apr 25, 2025
matthewjasper added a commit to matthewjasper/rust that referenced this issue May 14, 2025
- The lint is now reported in code that gets removed/modified/duplicated
  by macro expansion.
- Spans are more accurate
- Fixes rust-lang#140281
matthewjasper added a commit to matthewjasper/rust that referenced this issue May 14, 2025
- The lint is now reported in code that gets removed/modified/duplicated
  by macro expansion.
- Spans are more accurate
- Fixes rust-lang#140281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ L-text_direction_codepoint_in_literal Lint: text_direction_codepoint_in_literal 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.

5 participants