Repository navigation
rustfmt wanted features & bugfixes #398
Copy link
Copy link
Open
Labels
metaMeta issue.Meta issue.• toolchainRelated to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...Related to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...
Description
Note: see as well:
- Adding
rustfmtas a "transpiler" (not as a formatting action, which is already available) to Compiler Explorer: [COMPILER REQUEST]:rustfmtfor Rust compiler-explorer/compiler-explorer#4553.
Features that we would like to see
Required (we almost certainly want them)
- Stabilize the style
rustfmtgenerates when using a trailing empty comment, but without having to use the comment.- Tracking Issue: Keep
used items on individual lines when requested rust-lang/rustfmt#6829. - Docs: https://docs.kernel.org/rust/coding-guidelines.html#imports.
- Lore: https://lore.kernel.org/rust-for-linux/20251010174351.948650-2-ojeda@kernel.org/.
- Related issue (
imports_layout): [unstable option] imports_layout rust-lang/rustfmt#3361. - Related issue (
imports_granularity): [unstable option]imports_granularityrust-lang/rustfmt#4991.
- Tracking Issue: Keep
Nice to have (not critical, we could workaround if needed, etc.)
-
Stabilize
wrap_comments.- Tracking Issue: [unstable option] wrap_comments rust-lang/rustfmt#3347.
- Related:
wrap_doc_comments(even just that would already be quite nice to have). - Related PR: Format markdown files and rust code blocks in markdown files rust-lang/rustfmt#5909.
- Cc: @tgross35.
-
Stabilize
format_code_in_doc_comments.- Tracking Issue: [unstable option] format_code_in_doc_comments rust-lang/rustfmt#3348.
- Related:
doc_comment_code_block_width.
-
Support
RUSTC_BOOTSTRAP.- Issue (closed as WONTFIX): Support
RUSTC_BOOTSTRAPrust-lang/rustfmt#4884. - Without it, we cannot easily test it nor ask kernel developers to run it from time to time to e.g. format the code in doc comments.
- Old PR: RUSTFMT_BOOTSTRAP=1 allows the compiler's stage0 toolchain to be used upstream rust-lang/rustfmt#3900.
- Issue (closed as WONTFIX): Support
-
Stabilize
reorder_impl_items.- Tracking Issue: [unstable option] reorder_impl_items rust-lang/rustfmt#3363.
-
Stabilize
comment_width.- Tracking Issue: [unstable option] comment_width rust-lang/rustfmt#3349.
-
Stabilize
normalize_comments.- Tracking Issue: [unstable option] normalize_comments rust-lang/rustfmt#3350.
-
Stabilize
hex_literal_case. -
Support
skip_macro_invocations, i.e. skipping the formatting of some macro invocations by the macro name.- Tracking Issue: [unstable option]
skip_macro_invocationsrust-lang/rustfmt#5346. - It could potentially useful in some cases (possibly e.g.
module!) -- no concrete one yet though. - Lore: https://lore.kernel.org/rust-for-linux/CANiq72n=gFWrv9yFmzntaeR+RH5=qeD_uOs6NiW4dHkdaopKKw@mail.gmail.com/.
- Tracking Issue: [unstable option]
Low priority (we will likely not use them in the end)
Done (stabilized, fixed, not needed anymore, etc.)
Bugs that we would like to see fixed
Required (we almost certainly want them)
Nice to have (probably not critical, we could workaround if needed, etc.)
Low priority (we will likely not use them in the end)
Done (stabilized, fixed, or not needed anymore, etc.)
-
#[no_mangle]functions should not haveextern "Rust"removed.- Issue (to avoid removing it in all cases): Stripping
extern "Rust"from functions rust-lang/rustfmt#5701. - PR (to avoid removing it in all cases): refactor ABI formatting rust-lang/rustfmt#5845 (1.73?).
- Issue (to avoid removing it in all cases): Stripping
-
rustfmtICEs (apparently on purpose) on certain expanded-Zunpretty=expanded(i.e..rsi) constructs (e.g.offset_of!).- Status:
rustfmtwants us to report the ICEs and they are also happy to use small snippets like the one we reported as test cases. - From: https://rust-for-linux.zulipchat.com/#narrow/stream/291565-Help/topic/Using.20the.20.2Ersi.20target/near/423973701.
- Issue:
rustfmtICE with expanded code rust-lang/rustfmt#6105. - Issue (outside a
const): ICE: unreachablesrc/tools/rustfmt/src/expr.rs:407:13rust-lang/rustfmt#5885. - PR: Fix: ICE with expanded code #6105 rust-lang/rustfmt#6112 (1.81).
- Status:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
metaMeta issue.Meta issue.• toolchainRelated to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...Related to `rustc`, `bindgen`, `rustdoc`, LLVM, Clippy...
Activity
bjorn3 commentedon Jun 29, 2021
Which unstable rustfmt features are actually used that necessitate
RUSTC_BOOTSTRAP?ojeda commentedon Jun 29, 2021
format_code_in_doc_commentsis the one we are currently using.bjorn3 commentedon Jun 29, 2021
That one sounds useful. https://github.com/rust-lang/rustfmt/issues?q=format_code_in_doc_comments+is%3Aopen lists a couple of issues with it. Once those are fixed it would make sense to push for stabilization IMHO.
ojeda commentedon Jun 29, 2021
Indeed! We also have a few others in the
.rustfmt.tomlfile that were not currently enabled. I have put them in the list above :-)tgross35 commentedon Aug 23, 2024
hex_literal_caseseems useful, and potentially pretty easy to get over the stabilization line. Thinking about this because I noticed a patch that had a mix of upper- and lowercase hex, grepping through the kernel it seems like lowercase is much more common (and used by all in-tree Rust code so far)Context: https://lore.kernel.org/rust-for-linux/CALNs47u6+EFYkvpyHZD5zLcjQeb2CuZNTOjPuZ4MKewoKZYPMg@mail.gmail.com/
ojeda commentedon Aug 24, 2024
Thanks Trevor! I agree, that one would be useful -- added above.