Skip to content

Thread 'rustc' panicked at 'Stack should be empty: final_buf=FrameData...' #81920

Closed
@ZhangZhuoSJTU

Description

@ZhangZhuoSJTU

When I am studying the related in #81886, I found another ICE. Although I haven't figured out the root cause, I suspect they can be fixed together.

Code

#[a]

fn e() {
    #![r=#[l"")""

playground

Meta

It can be reproduced by nightly and beta versions.

rustc --version --verbose:

rustc 1.52.0-nightly (0fc6756b4 2021-02-08)
binary: rustc
commit-hash: 0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a
commit-date: 2021-02-08
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

rustc 1.50.0-beta.9 (2efd07024 2021-02-06)
binary: rustc
commit-hash: 2efd07024a6d1dc0d4ea0a538ddbcec7cc3a4eeb
commit-date: 2021-02-06
host: x86_64-unknown-linux-gnu
release: 1.50.0-beta.9

Error output

➜  playground rustc poc.rs
error: this file contains an unclosed delimiter
 --> poc.rs:4:19
  |
3 | fn e() {
  |        - unclosed delimiter
4 |     #![r=#[l"")""
  |       -           ^
  |       |
  |       unclosed delimiter

error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `""`
 --> poc.rs:4:13
  |
4 |     #![r=#[l"")""
  |           - -^
  |           | |
  |           | help: `]` may belong here
  |           unclosed delimiter

error: expected one of `.`, `;`, `?`, `}`, or an operator, found `]`
 --> poc.rs:4:19
  |
3 | fn e() {
  |        - unclosed delimiter
4 |     #![r=#[l"")""
  |                  -^ expected one of `.`, `;`, `?`, `}`, or an operator
  |                  |
  |                  help: `}` may belong here

error[E0658]: attributes on expressions are experimental
 --> poc.rs:4:10
  |
4 |     #![r=#[l"")""
  |          ^^^
  |
  = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
  = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable

error: cannot find attribute `a` in this scope
 --> poc.rs:1:3
  |
1 | #[a]
  |   ^

error: cannot find attribute `r` in this scope
 --> poc.rs:4:8
  |
4 |     #![r=#[l"")""
  |        ^

error: cannot find attribute `l` in this scope
 --> poc.rs:4:12
  |
4 |     #![r=#[l"")""
  |            ^

thread 'rustc' panicked at 'Stack should be empty: final_buf=FrameData { open: poc.rs:4:11: 4:12 (#0), inner: [(Token(Token { kind: Ident("l", false), span: poc.rs:4:12: 4:13 (#0) }), Alone)] } stack=[FrameData { open: poc.rs:1:1: 1:1 (#0), inner: [(Token(Token { kind: Pound, span: poc.rs:4:10: 4:11 (#0) }), Alone)] }]', compiler/rustc_parse/src/parser/mod.rs:1409:5
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.52.0-nightly (0fc6756b4 2021-02-08) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0658`.
Backtrace

thread 'rustc' panicked at 'Stack should be empty: final_buf=FrameData { open: poc.rs:4:11: 4:12 (#0), inner: [(Token(Token { kind: Ident("l", false), span: poc.rs:4:12: 4:13 (#0) }), Alone)] } stack=[FrameData { open: poc.rs:1:1: 1:1 (#0), inner: [(Token(Token { kind: Pound, span: poc.rs:4:10: 4:11 (#0) }), Alone)] }]', compiler/rustc_parse/src/parser/mod.rs:1409:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a/library/std/src/panicking.rs:435:5
   2: <rustc_parse::parser::Parser::collect_tokens_trailing_token::LazyTokenStreamImpl as rustc_ast::tokenstream::CreateTokenStream>::create_token_stream
   3: rustc_parse::prepend_attrs
   4: rustc_parse::nt_to_tokenstream
   5: rustc_ast_lowering::TokenStreamLowering::lower_token
   6: rustc_ast_lowering::LoweringContext::lower_mac_args
   7: rustc_ast_lowering::LoweringContext::lower_attr
   8: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   9: rustc_ast_lowering::LoweringContext::lower_attrs
  10: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_item
  11: rustc_ast_lowering::LoweringContext::with_hir_id_owner
  12: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  13: rustc_ast_lowering::lower_crate
  14: rustc_interface::passes::BoxedResolver::access::{{closure}}
  15: rustc_interface::passes::configure_and_expand::{{closure}}
  16: rustc_interface::passes::BoxedResolver::access
  17: rustc_interface::queries::Queries::lower_to_hir
  18: rustc_interface::queries::Queries::global_ctxt
  19: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  20: rustc_span::with_source_map
  21: rustc_interface::interface::create_compiler_and_run
  22: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions