Skip to content

Commit d312f1d

Browse files
committed
chore: remove the unstable rustfmt options and format the repo
In order to switch to a fully stable rustc, we need to remove the unstable rustmt options.
1 parent e97719b commit d312f1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+274
-317
lines changed

Diff for: harper-cli/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ enum Args {
1919
/// Whether to merely print out the number of errors encountered,
2020
/// without further details.
2121
#[arg(short, long)]
22-
count: bool
22+
count: bool,
2323
},
2424
/// Parse a provided document and print the detected symbols.
2525
Parse {
2626
/// The file you wish to parse.
27-
file: PathBuf
27+
file: PathBuf,
2828
},
2929
/// Emit decompressed, line-separated list of words in Harper's dictionary.
30-
Words
30+
Words,
3131
}
3232

3333
fn main() -> anyhow::Result<()> {
@@ -65,7 +65,7 @@ fn main() -> anyhow::Result<()> {
6565
report_builder = report_builder.with_label(
6666
Label::new((&filename, lint.span.into()))
6767
.with_message(lint.message)
68-
.with_color(primary_color)
68+
.with_color(primary_color),
6969
);
7070
}
7171

@@ -110,7 +110,7 @@ fn load_file(file: &Path) -> anyhow::Result<(Document, String)> {
110110
Box::new(
111111
CommentParser::new_from_filename(file)
112112
.map(Box::new)
113-
.ok_or(format_err!("Could not detect language ID."))?
113+
.ok_or(format_err!("Could not detect language ID."))?,
114114
)
115115
};
116116

Diff for: harper-comments/src/comment_parser.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tree_sitter::Node;
99
use crate::comment_parsers;
1010

1111
pub struct CommentParser {
12-
inner: parsers::Mask<TreeSitterMasker, Box<dyn Parser>>
12+
inner: parsers::Mask<TreeSitterMasker, Box<dyn Parser>>,
1313
}
1414

1515
impl CommentParser {
@@ -35,21 +35,21 @@ impl CommentParser {
3535
"lua" => tree_sitter_lua::language(),
3636
"sh" => tree_sitter_bash::language(),
3737
"java" => tree_sitter_java::language(),
38-
_ => return None
38+
_ => return None,
3939
};
4040

4141
let comment_parser: Box<dyn Parser> = match language_id {
4242
"javascriptreact" | "typescript" | "typescriptreact" | "javascript" => Box::new(JsDoc),
4343
"java" => Box::new(JavaDoc::default()),
4444
"go" => Box::new(Go),
45-
_ => Box::new(Unit)
45+
_ => Box::new(Unit),
4646
};
4747

4848
Some(Self {
4949
inner: parsers::Mask::new(
5050
TreeSitterMasker::new(language, Self::node_condition),
51-
comment_parser
52-
)
51+
comment_parser,
52+
),
5353
})
5454
}
5555

@@ -82,7 +82,7 @@ impl CommentParser {
8282
"sh" => "sh",
8383
"bash" => "sh",
8484
"java" => "java",
85-
_ => return None
85+
_ => return None,
8686
})
8787
}
8888

Diff for: harper-comments/src/comment_parsers/javadoc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::without_initiators;
88

99
#[derive(Default)]
1010
pub struct JavaDoc {
11-
html_parser: HtmlParser
11+
html_parser: HtmlParser,
1212
}
1313

1414
impl Parser for JavaDoc {

Diff for: harper-comments/src/comment_parsers/jsdoc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Parser for JsDoc {
1717

1818
new_tokens.push(Token::new(
1919
Span::new_with_len(line.len(), 1),
20-
harper_core::TokenKind::Newline(1)
20+
harper_core::TokenKind::Newline(1),
2121
));
2222

2323
new_tokens

Diff for: harper-comments/src/comment_parsers/unit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Parser for Unit {
3232

3333
new_tokens.push(Token::new(
3434
Span::new_with_len(line.len(), 1),
35-
harper_core::TokenKind::Newline(1)
35+
harper_core::TokenKind::Newline(1),
3636
));
3737

3838
new_tokens

Diff for: harper-core/src/char_ext.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl CharExt for char {
3131
unicode_blocks::EMOTICONS,
3232
unicode_blocks::MISCELLANEOUS_SYMBOLS,
3333
unicode_blocks::VARIATION_SELECTORS,
34-
unicode_blocks::SUPPLEMENTAL_SYMBOLS_AND_PICTOGRAPHS
34+
unicode_blocks::SUPPLEMENTAL_SYMBOLS_AND_PICTOGRAPHS,
3535
];
3636

3737
blocks.contains(&block)
@@ -66,7 +66,7 @@ impl CharExt for char {
6666
unicode_blocks::CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT,
6767
unicode_blocks::CJK_RADICALS_SUPPLEMENT,
6868
unicode_blocks::ENCLOSED_CJK_LETTERS_AND_MONTHS,
69-
unicode_blocks::HIRAGANA
69+
unicode_blocks::HIRAGANA,
7070
];
7171

7272
blocks.contains(&block)

Diff for: harper-core/src/document.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{Dictionary, FatToken, FullDictionary, Lrc, Token, TokenKind, TokenSt
1717
#[derive(Debug, Clone)]
1818
pub struct Document {
1919
source: Lrc<Vec<char>>,
20-
tokens: Vec<Token>
20+
tokens: Vec<Token>,
2121
}
2222

2323
impl Default for Document {
@@ -48,7 +48,7 @@ impl Document {
4848
pub fn new_from_vec(
4949
source: Lrc<Vec<char>>,
5050
parser: &mut impl Parser,
51-
dictionary: &impl Dictionary
51+
dictionary: &impl Dictionary,
5252
) -> Self {
5353
let tokens = parser.parse(&source);
5454

@@ -153,7 +153,7 @@ impl Document {
153153
&old[indices
154154
.last()
155155
.map(|v| v + stretch_len)
156-
.unwrap_or(indices.len())..]
156+
.unwrap_or(indices.len())..],
157157
);
158158
}
159159

@@ -304,7 +304,7 @@ impl Document {
304304
pub fn get_full_string(&self) -> String {
305305
self.get_span_content_str(Span {
306306
start: 0,
307-
end: self.source.len()
307+
end: self.source.len(),
308308
})
309309
}
310310

@@ -642,7 +642,7 @@ fn is_chunk_terminator(token: &TokenKind) -> bool {
642642
TokenKind::Punctuation(punct) => {
643643
matches!(punct, Punctuation::Comma | Punctuation::Quote { .. })
644644
}
645-
_ => false
645+
_ => false,
646646
}
647647
}
648648

@@ -651,11 +651,11 @@ fn is_sentence_terminator(token: &TokenKind) -> bool {
651651
TokenKind::Punctuation(punct) => [
652652
Punctuation::Period,
653653
Punctuation::Bang,
654-
Punctuation::Question
654+
Punctuation::Question,
655655
]
656656
.contains(punct),
657657
TokenKind::ParagraphBreak => true,
658-
_ => false
658+
_ => false,
659659
}
660660
}
661661

@@ -749,7 +749,7 @@ mod tests {
749749
assert_token_count("This is the 3rd test", 9);
750750
assert_token_count(
751751
"It works even with weird capitalization like this: 600nD",
752-
18
752+
18,
753753
);
754754
}
755755

Diff for: harper-core/src/language_detection.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn is_likely_english(doc: &Document, dict: &impl Dictionary) -> bool {
1818
}
1919
}
2020
TokenKind::Punctuation(_) => punctuation += 1,
21-
_ => ()
21+
_ => (),
2222
}
2323
}
2424

@@ -62,7 +62,7 @@ mod tests {
6262
#[test]
6363
fn detects_french() {
6464
assert_not_english(
65-
"C'est du français. Il ne devrait pas être marqué comme anglais par Harper."
65+
"C'est du français. Il ne devrait pas être marqué comme anglais par Harper.",
6666
);
6767
}
6868

@@ -100,7 +100,7 @@ def fibIter(n):
100100
for _ in range(2, n):
101101
fibPrev, fib = fib, fib + fibPrev
102102
return fib
103-
"#
103+
"#,
104104
);
105105
}
106106
}

Diff for: harper-core/src/lexing/email_address.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn lex_email_address(source: &[char]) -> Option<FoundToken> {
1818

1919
Some(FoundToken {
2020
next_index: at_loc + 1 + domain_part_len,
21-
token: TokenKind::EmailAddress
21+
token: TokenKind::EmailAddress,
2222
})
2323
}
2424

@@ -90,7 +90,7 @@ fn valid_unquoted_character(c: char) -> bool {
9090

9191
let others = [
9292
'!', '#', '$', '%', '&', '\'', '*', '+', '-', '/', '=', '?', '^', '_', '`', '{', '|', '}',
93-
'~', '.'
93+
'~', '.',
9494
];
9595

9696
if others.contains(&c) {
@@ -125,7 +125,7 @@ mod tests {
125125
r#"user-"#,
126126
r#"postmaster"#,
127127
r#"postmaster"#,
128-
r#"_test"#
128+
r#"_test"#,
129129
]
130130
.into_iter()
131131
.map(|s| s.chars().collect())

Diff for: harper-core/src/lexing/hostname.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub mod tests {
3838
r#"example.org"#,
3939
r#"strange.example.com"#,
4040
r#"example.org"#,
41-
r#"example.org"#
41+
r#"example.org"#,
4242
]
4343
.into_iter()
4444
.map(|s| s.chars().collect())

Diff for: harper-core/src/lexing/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct FoundToken {
1515
/// The index of the character __after__ the lexed token
1616
pub next_index: usize,
1717
/// Token lexed
18-
pub token: TokenKind
18+
pub token: TokenKind,
1919
}
2020

2121
pub fn lex_token(source: &[char]) -> Option<FoundToken> {
@@ -28,7 +28,7 @@ pub fn lex_token(source: &[char]) -> Option<FoundToken> {
2828
lex_url,
2929
lex_email_address,
3030
lex_word,
31-
lex_catch
31+
lex_catch,
3232
];
3333

3434
for lexer in lexers {
@@ -51,7 +51,7 @@ fn lex_word(source: &[char]) -> Option<FoundToken> {
5151
} else {
5252
Some(FoundToken {
5353
next_index: end,
54-
token: TokenKind::Word(WordMetadata::default())
54+
token: TokenKind::Word(WordMetadata::default()),
5555
})
5656
}
5757
}
@@ -77,7 +77,7 @@ pub fn lex_number(source: &[char]) -> Option<FoundToken> {
7777
if let Ok(n) = s.parse::<f64>() {
7878
return Some(FoundToken {
7979
token: TokenKind::Number(n.into(), None),
80-
next_index: end + 1
80+
next_index: end + 1,
8181
});
8282
}
8383
}
@@ -91,7 +91,7 @@ fn lex_newlines(source: &[char]) -> Option<FoundToken> {
9191
if count > 0 {
9292
Some(FoundToken {
9393
token: TokenKind::Newline(count),
94-
next_index: count
94+
next_index: count,
9595
})
9696
} else {
9797
None
@@ -104,7 +104,7 @@ fn lex_tabs(source: &[char]) -> Option<FoundToken> {
104104
if count > 0 {
105105
Some(FoundToken {
106106
token: TokenKind::Space(count * 2),
107-
next_index: count
107+
next_index: count,
108108
})
109109
} else {
110110
None
@@ -117,7 +117,7 @@ fn lex_spaces(source: &[char]) -> Option<FoundToken> {
117117
if count > 0 {
118118
Some(FoundToken {
119119
token: TokenKind::Space(count),
120-
next_index: count
120+
next_index: count,
121121
})
122122
} else {
123123
None
@@ -134,7 +134,7 @@ fn lex_punctuation(source: &[char]) -> Option<FoundToken> {
134134

135135
Some(FoundToken {
136136
next_index: 1,
137-
token: TokenKind::Punctuation(punct)
137+
token: TokenKind::Punctuation(punct),
138138
})
139139
}
140140

@@ -144,7 +144,7 @@ fn lex_quote(source: &[char]) -> Option<FoundToken> {
144144
if c == '\"' || c == '“' || c == '”' {
145145
Some(FoundToken {
146146
next_index: 1,
147-
token: TokenKind::Punctuation(Punctuation::Quote(Quote { twin_loc: None }))
147+
token: TokenKind::Punctuation(Punctuation::Quote(Quote { twin_loc: None })),
148148
})
149149
} else {
150150
None
@@ -155,7 +155,7 @@ fn lex_quote(source: &[char]) -> Option<FoundToken> {
155155
fn lex_catch(_source: &[char]) -> Option<FoundToken> {
156156
Some(FoundToken {
157157
next_index: 1,
158-
token: TokenKind::Unlintable
158+
token: TokenKind::Unlintable,
159159
})
160160
}
161161

Diff for: harper-core/src/lexing/url.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn lex_url(source: &[char]) -> Option<FoundToken> {
1414

1515
Some(FoundToken {
1616
next_index: url_end + sep + 1,
17-
token: TokenKind::Url
17+
token: TokenKind::Url,
1818
})
1919
}
2020

@@ -92,7 +92,7 @@ fn lex_hostport(source: &[char]) -> Option<usize> {
9292
c.is_ascii_digit()
9393
})
9494
.map(|(i, _)| i)
95-
.unwrap_or(source.len())
95+
.unwrap_or(source.len()),
9696
)
9797
} else {
9898
Some(hostname_end)

0 commit comments

Comments
 (0)