Added --format to rustc#7324
Closed
MaikKlein wants to merge 6 commits into
Closed
Conversation
Contributor
Author
|
Thanks cmr I will do this.Also I received some feedback that "rust format file1.rs file2.rs .." would probably be better and I agree. |
Closed
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Jun 17, 2021
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Jun 17, 2021
Fix false positive on `semicolon_if_nothing_returned` Currently the [`semicolon_if_nothing_returned`](https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned) lint fires in unwanted situations where a block only spans one line. An example of this was given in rust-lang#7324. This code: ```rust use std::mem::MaybeUninit; use std::ptr; fn main() { let mut s = MaybeUninit::<String>::uninit(); let _d = || unsafe { ptr::drop_in_place(s.as_mut_ptr()) }; } ``` yields the following clippy error: ``` error: consider adding a `;` to the last statement for consistent formatting --> src/main.rs:6:26 | 6 | let _d = || unsafe { ptr::drop_in_place(s.as_mut_ptr()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());` | = note: `-D clippy::semicolon-if-nothing-returned` implied by `-D clippy::pedantic` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned ``` I updated the lint to check if the statement is inside an `unsafe` block, a closure or a normal block and if the block only spans one line, in that case the lint is not emitted. This closes rust-lang#7324. changelog: enhanced semicolon if nothing returned according to rust-lang#7324.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Usage: rustc filename.rs --format
It formats the the specified file with --pretty normal.
There are two problems with this PR.
1.) I am using "process_output" instead of hooking me up in pretty_print directly. I didn't want to step on someones toes.
2.) Pretty print doesn't do a partial format. This mean that the source file doesn't get formated if the source code contains syntax errors.
I am currently using this with sublime. Every time I press ctrl+s it automatically saves and formats my current file.