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

ice: entered unreachabe code #16278

Closed
matthiaskrgr opened this issue Jan 6, 2024 · 2 comments · Fixed by #16770
Closed

ice: entered unreachabe code #16278

matthiaskrgr opened this issue Jan 6, 2024 · 2 comments · Fixed by #16770
Labels
A-parser parser issues C-bug Category: bug I-panic

Comments

@matthiaskrgr
Copy link
Member

struct S(u8, (u8, u8));

fn main() {
    let s = S(0, (0, 0));
    s.1e1; //~ ERROR no field `1e1` on type `S`
}

rust-analyzer symbols < ./fixed/float-field.rs

thread 'main' panicked at crates/parser/src/shortcuts.rs:218:21:
internal error: entered unreachable code
stack backtrace:
   0:     0x7fb9307e7806 - std::backtrace_rs::backtrace::libunwind::trace::hccd39fe91d56daec
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb9307e7806 - std::backtrace_rs::backtrace::trace_unsynchronized::hb9c211c184511b77
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb9307e7806 - std::sys_common::backtrace::_print_fmt::ha68911449431f29f
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb9307e7806 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h34c6aa4d9ef2549f
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb930839f00 - core::fmt::rt::Argument::fmt::h97f0cd02ba3737ef
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb930839f00 - core::fmt::write::heb4624e14e98aea7
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb9307db15f - std::io::Write::write_fmt::h25504a918ea5c052
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/io/mod.rs:1810:15
   7:     0x7fb9307e75e4 - std::sys_common::backtrace::_print::h16efe88e7fa25a23
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb9307e75e4 - std::sys_common::backtrace::print::h4f2dda7c938219d4
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb9307ea377 - std::panicking::default_hook::{{closure}}::hdfd96bdc522bbb15
  10:     0x7fb9307ea0d9 - std::panicking::default_hook::hf1cac0ca04453e02
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:292:9
  11:     0x7fb9307ea938 - std::panicking::rust_panic_with_hook::hd39b254275236486
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:779:13
  12:     0x7fb9307ea7d9 - std::panicking::begin_panic_handler::{{closure}}::h5bbe5cb47793ee20
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:649:13
  13:     0x7fb9307e7d06 - std::sys_common::backtrace::__rust_end_short_backtrace::h464decb1e79e1351
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/sys_common/backtrace.rs:171:18
  14:     0x7fb9307ea570 - rust_begin_unwind
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:645:5
  15:     0x7fb930836605 - core::panicking::panic_fmt::h679166b76d3d88f6
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/core/src/panicking.rs:72:14
  16:     0x7fb9308366c3 - core::panicking::panic::h63af6af8832e6e11
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/core/src/panicking.rs:144:5
  17:     0x555fe99ab377 - <parser[7b20a0df5f7d490f]::lexed_str::LexedStr>::intersperse_trivia
  18:     0x555fe99389a3 - syntax[93f6c363a9c02f46]::parsing::build_tree
  19:     0x555fe997b414 - <syntax[93f6c363a9c02f46]::ast::generated::nodes::SourceFile>::parse
  20:     0x555fe990f1dd - <base_db[ccb70c7332b7862c]::ParseQuery as salsa[1f70372cff72ab3f]::plumbing::QueryFunction>::execute
  21:     0x555fe98fb277 - <salsa[1f70372cff72ab3f]::derived::slot::Slot<base_db[ccb70c7332b7862c]::ParseQuery, salsa[1f70372cff72ab3f]::derived::AlwaysMemoizeValue>>::execute
  22:     0x555fe990dac9 - <_ as base_db[ccb70c7332b7862c]::SourceDatabase>::parse::__shim
  23:     0x555fe8e5b59d - <ide[c84991b3490e4885]::Analysis>::file_structure
  24:     0x555fe8ad401a - <rust_analyzer[1d698c3afe0c2f30]::cli::flags::Symbols>::run
  25:     0x555fe8979cbe - rust_analyzer[ea83a2a0fbc63401]::main
  26:     0x555fe8908b33 - std[4bc72880d5231e4c]::sys_common::backtrace::__rust_begin_short_backtrace::<fn() -> core[25a4dcbb3cee7009]::result::Result<(), anyhow[63f90c604b8a6a8d]::Error>, core[25a4dcbb3cee7009]::result::Result<(), anyhow[63f90c604b8a6a8d]::Error>>
  27:     0x555fe89659cd - std[4bc72880d5231e4c]::rt::lang_start::<core[25a4dcbb3cee7009]::result::Result<(), anyhow[63f90c604b8a6a8d]::Error>>::{closure#0}
  28:     0x7fb9307cba01 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hc6b0dae8727a4153
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/core/src/ops/function.rs:284:13
  29:     0x7fb9307cba01 - std::panicking::try::do_call::hea61ab072ac41e8e
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:552:40
  30:     0x7fb9307cba01 - std::panicking::try::h5c21571bdf7e08ad
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:516:19
  31:     0x7fb9307cba01 - std::panic::catch_unwind::h682719196f0777aa
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panic.rs:142:14
  32:     0x7fb9307cba01 - std::rt::lang_start_internal::{{closure}}::hac3ffec90ad839c4
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/rt.rs:148:48
  33:     0x7fb9307cba01 - std::panicking::try::do_call::h1791f2ae1fcf40e6
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:552:40
  34:     0x7fb9307cba01 - std::panicking::try::h4626756b2e85d8cd
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panicking.rs:516:19
  35:     0x7fb9307cba01 - std::panic::catch_unwind::hae97474d5de51d0e
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/panic.rs:142:14
  36:     0x7fb9307cba01 - std::rt::lang_start_internal::h5018c9c91a53da4f
                               at /rustc/595bc6f00369475047538fdae1ff8cea692ac385/library/std/src/rt.rs:148:20
  37:     0x555fe897fa75 - main
  38:     0x7fb92a52ecd0 - <unknown>
  39:     0x7fb92a52ed8a - __libc_start_main
  40:     0x555fe88f88b9 - <unknown>
  41:                0x0 - <unknown>

rust-analyzer 1.77.0-nightly (595bc6f 2024-01-05)

@matthiaskrgr matthiaskrgr added the C-bug Category: bug label Jan 6, 2024
@lnicola
Copy link
Member

lnicola commented Jan 6, 2024

Better backtrace:

   0: rust_begin_unwind
             at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/0e09125c6c3c2fd70d7de961bcf0e51575235fad/library/core/src/panicking.rs:144:5
   3: parser::shortcuts::Builder::float_split
   4: parser::shortcuts::<impl parser::lexed_str::LexedStr>::intersperse_trivia
   5: syntax::parsing::build_tree
   6: syntax::parsing::parse_text
   7: syntax::<impl syntax::ast::generated::nodes::SourceFile>::parse
   8: <base_db::ParseQuery as salsa::plumbing::QueryFunction>::execute
   9: salsa::Cycle::catch
  10: salsa::derived::slot::Slot<Q,MP>::execute
  11: salsa::derived::slot::Slot<Q,MP>::read
  12: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
  13: <DB as base_db::SourceDatabase>::parse::__shim
  14: ide_diagnostics::diagnostics
  15: salsa::Cancelled::catch
  16: ide::Analysis::diagnostics
  17: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  18: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  19: rust_analyzer::diagnostics::fetch_native_diagnostics

@lnicola lnicola added the A-parser parser issues label Jan 6, 2024
@matthiaskrgr
Copy link
Member Author

smaller repro:

fn main() {
    s.1e1;
}

@lnicola lnicola added the I-panic label Jan 6, 2024
@matthiaskrgr matthiaskrgr mentioned this issue Jan 6, 2024
bors added a commit that referenced this issue Mar 6, 2024
fix: panic when using float numbers without dots in chain calls

Fix #16278.

This PR fixes the panic caused by using floating-point numbers without a dot (such as `1e2`) in chain calls.

-------------

Although this syntax is very odd 🤣, r-a should not panic.
@bors bors closed this as completed in e5889c9 Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues C-bug Category: bug I-panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants