rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.77k stars 12.76k forks source link

ICE: `attempted to subtract with overflow` with No-Break Space and small terminal #132918

Open matthiaskrgr opened 1 week ago

matthiaskrgr commented 1 week ago

Code

                                         (                                        )

This mix of spaces and "no-break-spaces" https://www.compart.com/en/unicode/U+00A0 seems to cause a problem with small terminals when the terminal is too small to show the entire code as diagnostic. I guess rustc has problems while splitting the no-break-spaces?

Meta

rustc --version --verbose:

de27914e8e6c5f8a02698a8ed9b318df17f2f621

Error output

output with sufficient screen space:

error: unknown start of token: \u{a0}
 --> a.rs:1:1
  |
1 | ...                   (                                        )
^ |
  |
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
  |
1 |                                          (                                        )
  | +

error: expected item, found `(`
 --> a.rs:1:42
  |
1 | ...                   (                                        )
  |                       ^ expected item
  |
  = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>

error: aborting due to 2 previous errors

output when terminal is node wide enough ( may require std overflow checks )

Backtrace

``` thread 'rustc' panicked at compiler/rustc_errors/src/emitter.rs:142:16: attempt to subtract with overflow stack backtrace: 0: 0x7ba058cfda15 - std::backtrace_rs::backtrace::libunwind::trace::hce40cf0e2aac7ed5 at /home/matthias/vcs/github/rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x7ba058cfda15 - std::backtrace_rs::backtrace::trace_unsynchronized::h880b379da68f72c2 at /home/matthias/vcs/github/rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7ba058cfda15 - std::sys::backtrace::_print_fmt::h1a354c4aa782d172 at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:66:9 3: 0x7ba058cfda15 - ::fmt::h0d7ca387cd41cee9 at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:39:26 4: 0x7ba058d60733 - core::fmt::rt::Argument::fmt::he92dc2df83bef3f2 at /home/matthias/vcs/github/rust/library/core/src/fmt/rt.rs:177:76 5: 0x7ba058d60733 - core::fmt::write::h591c6167c085ca3e at /home/matthias/vcs/github/rust/library/core/src/fmt/mod.rs:1189:21 6: 0x7ba058cf6b99 - std::io::Write::write_fmt::h21924ac1c814d024 at /home/matthias/vcs/github/rust/library/std/src/io/mod.rs:1839:15 7: 0x7ba058cfd8b3 - std::sys::backtrace::BacktraceLock::print::hc19afe4d9960b9cf at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:42:9 8: 0x7ba058cce4a7 - std::panicking::default_hook::{{closure}}::h062ece2733a4f22b at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:268:22 9: 0x7ba058cce264 - std::panicking::default_hook::hb8b1f712abe85c4d at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:295:9 10: 0x7ba054bfac08 - rustc_driver_impl[9029c07c6277fcfe]::install_ice_hook::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_driver_impl/src/lib.rs:1421:17 11: 0x7ba054bfac08 - as core[8de79deff3db24ef]::ops::function::Fn<(&dyn for<'a, 'b> core[8de79deff3db24ef]::ops::function::Fn<(&'a std[9f27a9e79a3d8fec]::panic::PanicHookInfo<'b>,), Output = ()> + core[8de79deff3db24ef]::marker::Send + core[8de79deff3db24ef]::marker::Sync, &std[9f27a9e79a3d8fec]::panic::PanicHookInfo)>>::call at /home/matthias/vcs/github/rust/library/alloc/src/boxed.rs:1982:9 12: 0x7ba058ccea9d - std::panicking::rust_panic_with_hook::hf5e74db3e2ab088b at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:809:13 13: 0x7ba058cfdfd8 - std::panicking::begin_panic_handler::{{closure}}::he05440ad0bcf0762 at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:667:13 14: 0x7ba058cfdc49 - std::sys::backtrace::__rust_end_short_backtrace::h9c5bf8d13149dc49 at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:170:18 15: 0x7ba058cce54e - rust_begin_unwind at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:665:5 16: 0x7ba054b9ca80 - core::panicking::panic_fmt::hb3d38ae66b53032c at /home/matthias/vcs/github/rust/library/core/src/panicking.rs:76:14 17: 0x7ba054b9d590 - core::panicking::panic_const::panic_const_sub_overflow::h7e9d53069202d422 at /home/matthias/vcs/github/rust/library/core/src/panicking.rs:182:21 18: 0x7ba05880f5e9 - ::compute 19: 0x7ba05880f5e9 - ::new at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:105:9 20: 0x7ba05880f5e9 - ::emit_messages_default_inner::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:1771:30 21: 0x7ba058807fd0 - ::emit_messages_default_inner at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:1386:5 22: 0x7ba0587fb509 - ::emit_messages_default at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:2331:15 23: 0x7ba0587fb509 - ::emit_diagnostic at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/emitter.rs:516:9 24: 0x7ba05883070b - ::emit_diagnostic::{closure#3} at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1572:17 25: 0x7ba054f69cf2 - rustc_interface[37f1de6f39eeba1d]::callbacks::track_diagnostic::>::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/callbacks.rs:53:13 26: 0x7ba054f69cf2 - rustc_middle[b0f7bee8c2110bb2]::ty::context::tls::with_context_opt::>::{closure#0}, core[8de79deff3db24ef]::option::Option> at /home/matthias/vcs/github/rust/compiler/rustc_middle/src/ty/context/tls.rs:95:9 27: 0x7ba054f69cf2 - rustc_interface[37f1de6f39eeba1d]::callbacks::track_diagnostic::> at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/callbacks.rs:42:5 28: 0x7ba05882fa61 - ::emit_diagnostic at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1527:9 29: 0x7ba05882e5c8 - ::emit_diagnostic at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1057:9 30: 0x7ba058881e45 - ::emit_producing_error_guaranteed at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/diagnostic.rs:1324:20 31: 0x7ba0582408fe - ::emit at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/diagnostic.rs:1331:9 32: 0x7ba0582408fe - ::emit_err:: at /home/matthias/vcs/github/rust/compiler/rustc_errors/src/lib.rs:1262:30 33: 0x7ba0582408fe - ::next_token at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/mod.rs:390:32 34: 0x7ba05822fc5c - ::bump at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/tokentrees.rs:223:66 35: 0x7ba05822fc5c - ::lex_token_trees at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/tokentrees.rs:41:33 36: 0x7ba05822fa9d - ::lex_all_token_trees at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/tokentrees.rs:30:44 37: 0x7ba05823fa6e - rustc_parse[a0515389a56242fe]::lexer::lex_token_trees at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lexer/mod.rs:70:9 38: 0x7ba058223698 - rustc_parse[a0515389a56242fe]::source_file_to_stream at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lib.rs:125:5 39: 0x7ba05822349f - rustc_parse[a0515389a56242fe]::new_parser_from_source_file at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lib.rs:93:18 40: 0x7ba058223116 - rustc_parse[a0515389a56242fe]::new_parser_from_file at /home/matthias/vcs/github/rust/compiler/rustc_parse/src/lib.rs:83:5 41: 0x7ba054f42893 - rustc_interface[37f1de6f39eeba1d]::passes::parse::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/passes.rs:48:38 42: 0x7ba054f42893 - ::run::, rustc_interface[37f1de6f39eeba1d]::passes::parse::{closure#0}> at /home/matthias/vcs/github/rust/compiler/rustc_data_structures/src/profiling.rs:753:9 43: 0x7ba054f42893 - ::time::, rustc_interface[37f1de6f39eeba1d]::passes::parse::{closure#0}> at /home/matthias/vcs/github/rust/compiler/rustc_session/src/utils.rs:16:9 44: 0x7ba054ecdbff - rustc_interface[37f1de6f39eeba1d]::passes::parse at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/passes.rs:45:17 45: 0x7ba054f6b0b4 - ::parse::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:98:31 46: 0x7ba054f6b0b4 - >::compute::<::parse::{closure#0}>::{closure#0}::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:39:41 47: 0x7ba054f6b0b4 - , rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>>::get_or_insert_with::<>::compute<::parse::{closure#0}>::{closure#0}::{closure#0}> at /home/matthias/vcs/github/rust/library/core/src/option.rs:1690:26 48: 0x7ba054f6b0b4 - >::compute::<::parse::{closure#0}>::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:39:17 49: 0x7ba054f6b0b4 - , rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>>>::filter_map::, >::compute<::parse::{closure#0}>::{closure#0}> at /home/matthias/vcs/github/rust/library/core/src/cell.rs:1713:15 50: 0x7ba054f6b0b4 - >::compute::<::parse::{closure#0}> at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:36:9 51: 0x7ba054f6b0b4 - ::parse at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:98:9 52: 0x7ba054c30fb1 - rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}::{closure#1} at /home/matthias/vcs/github/rust/compiler/rustc_driver_impl/src/lib.rs:398:13 53: 0x7ba054c30fb1 - ::enter::, rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>> at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/queries.rs:210:19 54: 0x7ba054c4c5f1 - rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_driver_impl/src/lib.rs:393:22 55: 0x7ba054c4c5f1 - rustc_interface[37f1de6f39eeba1d]::interface::run_compiler::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/interface.rs:505:27 56: 0x7ba054c4c5f1 - rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_pool_with_globals::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/util.rs:157:13 57: 0x7ba054c4c5f1 - rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/util.rs:107:21 58: 0x7ba054c4c5f1 - >::set::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>> at /home/matthias/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9 59: 0x7ba054c4c5f1 - rustc_span[e1ef1ea18f9f3be]::create_session_globals_then::, rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}> at /home/matthias/vcs/github/rust/compiler/rustc_span/src/lib.rs:137:5 60: 0x7ba054bb43f1 - rustc_interface[37f1de6f39eeba1d]::util::run_in_thread_with_globals::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0} at /home/matthias/vcs/github/rust/compiler/rustc_interface/src/util.rs:106:17 61: 0x7ba054bb43f1 - std[9f27a9e79a3d8fec]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>> at /home/matthias/vcs/github/rust/library/std/src/sys/backtrace.rs:154:18 62: 0x7ba054bb5977 - ::spawn_unchecked_::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0} at /home/matthias/vcs/github/rust/library/std/src/thread/mod.rs:541:17 63: 0x7ba054bb5977 - ::spawn_unchecked_, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}> as core[8de79deff3db24ef]::ops::function::FnOnce<()>>::call_once at /home/matthias/vcs/github/rust/library/core/src/panic/unwind_safe.rs:272:9 64: 0x7ba054bb5977 - std[9f27a9e79a3d8fec]::panicking::try::do_call::::spawn_unchecked_, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>> at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:557:40 65: 0x7ba054bb5977 - std[9f27a9e79a3d8fec]::panicking::try::, core[8de79deff3db24ef]::panic::unwind_safe::AssertUnwindSafe<::spawn_unchecked_, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}>> at /home/matthias/vcs/github/rust/library/std/src/panicking.rs:520:19 66: 0x7ba054bb5977 - std[9f27a9e79a3d8fec]::panic::catch_unwind::::spawn_unchecked_, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>> at /home/matthias/vcs/github/rust/library/std/src/panic.rs:358:14 67: 0x7ba054bb5977 - ::spawn_unchecked_::, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1} at /home/matthias/vcs/github/rust/library/std/src/thread/mod.rs:540:30 68: 0x7ba054bb5977 - <::spawn_unchecked_, rustc_driver_impl[9029c07c6277fcfe]::run_compiler::{closure#0}>::{closure#1}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8de79deff3db24ef]::result::Result<(), rustc_span[e1ef1ea18f9f3be]::ErrorGuaranteed>>::{closure#1} as core[8de79deff3db24ef]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} at /home/matthias/vcs/github/rust/library/core/src/ops/function.rs:250:5 69: 0x7ba058ce1643 - as core::ops::function::FnOnce>::call_once::h3425f4d14c8f80b0 at /home/matthias/vcs/github/rust/library/alloc/src/boxed.rs:1968:9 70: 0x7ba058ce1643 - as core::ops::function::FnOnce>::call_once::hb4c2e9fcaaea9e84 at /home/matthias/vcs/github/rust/library/alloc/src/boxed.rs:1968:9 71: 0x7ba058ce1643 - std::sys::pal::unix::thread::Thread::new::thread_start::hbf5605cef6cbee26 at /home/matthias/vcs/github/rust/library/std/src/sys/pal/unix/thread.rs:105:17 72: 0x7ba053ea339d - 73: 0x7ba053f2849c - 74: 0x0 - 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: please attach the file at `/tmp/im/rustc-ice-2024-11-11T20_55_45-1497449.txt` to your bug report query stack during panic: end of query stack error: aborting due to 1 previous error ```

matthiaskrgr commented 1 week ago

a.rs.txt