Skip to content

ICE when using serde derives with an invalid inner doc comment #86781

Closed
@solarretrace

Description

@solarretrace

I'm hitting an ICE when using serde derives with an invalid inner doc comment. This occurs on the playground on both stable and nightly.

Code

use serde::Serialize;

//! Pc
#[derive(Serialize)]
pub struct Pc;

Meta

This is the version on my machine:

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-apple-darwin
release: 1.53.0
LLVM version: 12.0.1

Error output

   Compiling playground v0.0.1 (/playground)
error[E0753]: expected outer doc comment
 --> src/lib.rs:4:1
  |
4 | //! Pc
  | ^^^^^^
  |
  = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items

thread 'rustc' panicked at 'Failed to find trailing delimited group in: [(Token(Token { kind: Ident("pub", false), span: src/lib.rs:6:1: 6:4 (#0) }), Alone), (Token(Token { kind: Ident("struct", false), span: src/lib.rs:6:5: 6:11 (#0) }), Alone), (Token(Token { kind: Ident("Pc", false), span: src/lib.rs:6:12: 6:14 (#0) }), Joint), (Token(Token { kind: Semi, span: src/lib.rs:6:14: 6:15 (#0) }), Alone)]', compiler/rustc_ast/src/tokenstream.rs:276:25
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.55.0-nightly (868c702d0 2021-06-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

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

For more information about this error, try `rustc --explain E0753`.
error: could not compile `playground`

To learn more, run the command again with --verbose.
Backtrace

stack backtrace:
   0: _rust_begin_unwind
   1: std::panicking::begin_panic_fmt
   2: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
   3: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   5: rustc_ast::tokenstream::AttrAnnotatedTokenStream::to_tokenstream
   6: rustc_parse::prepend_attrs
   7: rustc_parse::nt_to_tokenstream
   8: <rustc_expand::proc_macro::ProcMacroDerive as rustc_expand::base::MultiItemModifier>::expand
   9: rustc_expand::expand::MacroExpander::fully_expand_fragment
  10: rustc_expand::expand::MacroExpander::expand_crate
  11: rustc_session::utils::<impl rustc_session::session::Session>::time
  12: rustc_interface::passes::configure_and_expand_inner
  13: rustc_interface::passes::configure_and_expand::{{closure}}
  14: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  15: rustc_interface::passes::configure_and_expand
  16: rustc_interface::queries::Queries::expansion
  17: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  18: rustc_span::with_source_map
  19: rustc_interface::interface::create_compiler_and_run
  20: scoped_tls::ScopedKey<T>::set

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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