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

Support ignoring lints in editable playground blocks #2527

Open
djmitche opened this issue Jan 19, 2025 · 3 comments
Open

Support ignoring lints in editable playground blocks #2527

djmitche opened this issue Jan 19, 2025 · 3 comments
Labels
C-enhancement Category: Enhancement or feature request

Comments

@djmitche
Copy link

Problem

In a short Rust snippet, it's common to include code which has warnings like dead-code or unused-variables.

In a non-editable snippet, these can be hidden with the hidelines support. However, in a runnable snippet, they always appear.

Proposed Solution

Add a new config:

[output.html.playground]
prefix = "#![allow(unused)]"

and inject this string as a prefix to every playground run.

Notes

No response

@djmitche djmitche added the C-enhancement Category: Enhancement or feature request label Jan 19, 2025
@djmitche
Copy link
Author

(This should probably be disabled by a class on the code block, e.g., noprefix)

@max-heller
Copy link
Contributor

Would it make sense for mdbook to mirror rustdoc and automatically allow a set of lints?

djmitche added a commit to google/comprehensive-rust that referenced this issue Jan 20, 2025
These sort of warnings can be distracting when commenting out a few
lines of code or demonstrating some other concept. They can be
re-enabled for a code block with `warnunused`.

I filed rust-lang/mdBook#2527 to get behavior
like this upstream.
@djmitche
Copy link
Author

That's not a bad idea, as long as it's customizable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

2 participants