Skip to content

thread 'main' panicked at lib.rs:376:47 because of empty code block in doc comment #4793

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

Closed
oovm opened this issue Apr 10, 2021 · 6 comments
Closed
Labels
bug Panic, non-idempotency, invalid code, etc. help wanted p-medium

Comments

@oovm
Copy link

oovm commented Apr 10, 2021

Describe the bug

$ RUST_BACKTRACE=full cargo fmt
thread 'main' panicked at 'begin <= end (12 <= 11) when slicing `fn main() {}`', src\\lib.rs:376:47
stack backtrace:
   0:     0x7ff700d0665e - <unknown>
   1:     0x7ff700d1e72b - <unknown>
   2:     0x7ff700d02d98 - <unknown>
   3:     0x7ff700d092bd - <unknown>
   4:     0x7ff700d08d89 - <unknown>
   5:     0x7ff700d09b70 - <unknown>
   6:     0x7ff700d096a1 - <unknown>
   7:     0x7ff700d06fef - <unknown>
   8:     0x7ff700d095f9 - <unknown>
   9:     0x7ff700d1bcc0 - <unknown>
  10:     0x7ff700d218d6 - <unknown>
  11:     0x7ff70086b81d - <unknown>
  12:     0x7ff700844519 - <unknown>
  13:     0x7ff700846a9f - <unknown>
  14:     0x7ff70083f7a2 - <unknown>
  15:     0x7ff70094f5f0 - <unknown>
  16:     0x7ff70085dd83 - <unknown>
  17:     0x7ff700935e77 - <unknown>
  18:     0x7ff70092bc06 - <unknown>
  19:     0x7ff7009231a4 - <unknown>
  20:     0x7ff700936705 - <unknown>
  21:     0x7ff7009374f8 - <unknown>
  22:     0x7ff70080607d - <unknown>
  23:     0x7ff700838ea7 - <unknown>
  24:     0x7ff70080b9ca - <unknown>
  25:     0x7ff700815b07 - <unknown>
  26:     0x7ff70080b246 - <unknown>
  27:     0x7ff700812071 - <unknown>
  28:     0x7ff70080f162 - <unknown>
  29:     0x7ff70080d2b6 - <unknown>
  30:     0x7ff70080d5cc - <unknown>
  31:     0x7ff700d09e47 - <unknown>
  32:     0x7ff700816aa7 - <unknown>
  33:     0x7ff700d27714 - <unknown>
  34:     0x7fff6fcc7034 - BaseThreadInitThunk
  35:     0x7fff70782651 - RtlUserThreadStart

It's very strange.

There is no fn main() {} in my project, nor 376 lines in lib.rs

To Reproduce

The project can be found here: sdl-rs/sdl-ast@fe2daf4

Expected behavior

Meta

  • rustfmt version: v1.4.36
  • From where did you install rustfmt?: rustfmt_windows-x86_64-msvc_v1.4.36
  • How do you run rustfmt:

Run RUST_BACKTRACE=full cargo fmt in MINGW64

image

@oovm oovm added the bug Panic, non-idempotency, invalid code, etc. label Apr 10, 2021
@calebcartwright
Copy link
Member

Important to note that rustup is the recommended and preferred way of getting the right components onto your system, but if you're going to download the pre-built binaries then I'd think for mingw you'd want to use rustfmt_windows-x86_64-gnu_v1.4.36.zip and not the msvc one, no?

@calebcartwright
Copy link
Member

Thanks. The panic and line info is a reference to rustfmt, not your source input, and is related to some extra processing required in cases like formatting code blocks in comments.

Could you please try to distill your input down into a smaller reproducible example? Even getting down to a single file would be a helpful starting point as opposed to an entire project. You may want to try running with --verbose to get a better idea of which file contains the problematic area.

@oovm
Copy link
Author

oovm commented Apr 10, 2021

Everything is fine after removing: sdl-ast/src/ast/loops/mod.rs

So I think

/// ```
/// 
/// ```

gives this panic

@calebcartwright
Copy link
Member

That's super helpful, thanks so much for reducing that to a minimal example!

@jplatte
Copy link

jplatte commented Sep 10, 2021

I get pretty much the same panic with some (broken) macro_rules! code, not sure whether it's the same root cause: Playground

@ytmimi ytmimi changed the title thread 'main' panicked at lib.rs:376:47 thread 'main' panicked at lib.rs:376:47 because of empty code block in doc comment Jul 27, 2022
@ytmimi
Copy link
Contributor

ytmimi commented Jul 27, 2022

going to close this in favor of #5234, as the issue is clearer in that issue

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. help wanted p-medium
Projects
None yet
Development

No branches or pull requests

4 participants