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 on nightly 1.56.0 (2021-07-29) when missing semicolon or function body in impl block #87635

Closed
dataphract opened this issue Jul 30, 2021 · 3 comments · Fixed by #87646
Closed
Assignees
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dataphract
Copy link

Playground with repro here. Not present in latest stable or beta.

Code

struct Foo {}

impl Foo {
    pub fn bar()
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (492723897 2021-07-29)
binary: rustc
commit-hash: 492723897e9b4db6701b3a75b72618d08a7d5319
commit-date: 2021-07-29
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Error output

   Compiling ice v0.1.0 ([redacted])
error: expected `;`, found `}`
 --> src/main.rs:4:17
  |
4 |     pub fn bar()
  |                 ^ help: add `;` here
5 | }
  | - unexpected token

thread 'rustc' panicked at 'internal error: entered unreachable code', compiler/rustc_parse/src/parser/item.rs:1723:17
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.56.0-nightly (492723897 2021-07-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
end of query stack
error: could not compile `ice` due to previous error
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/492723897e9b4db6701b3a75b72618d08a7d5319/library/std/src/panicking.rs:516:5
   1: core::panicking::panic_fmt
             at /rustc/492723897e9b4db6701b3a75b72618d08a7d5319/library/core/src/panicking.rs:93:14
   2: core::panicking::panic
             at /rustc/492723897e9b4db6701b3a75b72618d08a7d5319/library/core/src/panicking.rs:50:5
   3: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_fn
   4: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_kind
   5: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_common
   6: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_assoc_item
   7: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_impl
   8: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_kind
   9: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_common
  10: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_mod
  11: rustc_parse::parse_crate_from_file
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::parse
  14: rustc_interface::queries::Queries::parse
  15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  16: rustc_span::with_source_map
  17: rustc_interface::interface::create_compiler_and_run
  18: scoped_tls::ScopedKey<T>::set

@dataphract dataphract 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 Jul 30, 2021
@JohnTitor JohnTitor added A-parser Area: The parsing of Rust source code to an AST regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jul 30, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 30, 2021
@JohnTitor
Copy link
Member

Regressed since #87480, I think #87436 is the cause.

@apiraino
Copy link
Contributor

right, this issue can be probably be closed as duplicate of #87647

@steffahn
Copy link
Member

@apiraino

I would suggest not closing this issue as long as #87647 literally starts with the statement

This also ICEs, but that's a separate issue: #87635

referencing back to this issue. Furthermore, this issue is older, so if they’d be duplicates, #87647 would be closed.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 3, 2021
Fix a parser ICE on invalid `fn` body

Fixes rust-lang#87635
A better fix would add a check for `fn` body on `expected_one_of_not_found` but I haven't come up with a graceful way. Any idea?
r? `@oli-obk` `@estebank`
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 3, 2021
Fix a parser ICE on invalid `fn` body

Fixes rust-lang#87635
A better fix would add a check for `fn` body on `expected_one_of_not_found` but I haven't come up with a graceful way. Any idea?
r? ``@oli-obk`` ``@estebank``
@bors bors closed this as completed in f69daa2 Aug 3, 2021
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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