Skip to content

Format code #4284

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

Merged
merged 1 commit into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clippy_lints/src/double_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl<'a, 'tcx> DoubleComparisons {
);
}};
}
#[rustfmt::skip]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a rustfmt bug:
it formats the match arm to drop the {} and with that the line exceeds the maximum length.

match (op, lkind, rkind) {
(BinOpKind::Or, BinOpKind::Eq, BinOpKind::Lt) | (BinOpKind::Or, BinOpKind::Lt, BinOpKind::Eq) => {
lint_double_comparison!(<=)
Expand Down
10 changes: 7 additions & 3 deletions mini-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
#![deny(rust_2018_idioms)]
extern crate proc_macro;

use proc_macro::{TokenStream, quote};
use proc_macro::{quote, TokenStream};

#[proc_macro_derive(ClippyMiniMacroTest)]
pub fn mini_macro(_: TokenStream) -> TokenStream {
quote!(
#[allow(unused)] fn needless_take_by_value(s: String) { println!("{}", s.len()); }
#[allow(unused)] fn needless_loop(items: &[u8]) {
#[allow(unused)]
fn needless_take_by_value(s: String) {
println!("{}", s.len());
}
#[allow(unused)]
fn needless_loop(items: &[u8]) {
for i in 0..items.len() {
println!("{}", items[i]);
}
Expand Down