Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bea7209

Browse files
chore: fix src formatting
1 parent 9b0ed57 commit bea7209

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

src/macros.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,10 @@ fn next_space(tok: &TokenKind) -> SpaceState {
11861186
/// Tries to convert a macro use into a short hand try expression. Returns `None`
11871187
/// when the macro is not an instance of `try!` (or parsing the inner expression
11881188
/// failed).
1189-
pub(crate) fn convert_try_mac(mac: &ast::MacCall, context: &RewriteContext<'_>) -> Option<ast::Expr> {
1189+
pub(crate) fn convert_try_mac(
1190+
mac: &ast::MacCall,
1191+
context: &RewriteContext<'_>,
1192+
) -> Option<ast::Expr> {
11901193
let path = &pprust::path_to_string(&mac.path);
11911194
if path == "try" || path == "r#try" {
11921195
let ts = mac.args.inner_tokens();

src/modules.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
251251
if self.parse_sess.is_file_parsed(&path) {
252252
return Ok(None);
253253
}
254-
return match Parser::parse_file_as_module(
255-
self.parse_sess,
256-
&path,
257-
sub_mod.inner,
258-
) {
254+
return match Parser::parse_file_as_module(self.parse_sess, &path, sub_mod.inner) {
259255
Some(m) => Ok(Some(SubModKind::External(
260256
path,
261257
DirectoryOwnership::Owned { relative: None },
@@ -293,16 +289,10 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
293289
return Ok(Some(SubModKind::MultiExternal(mods_outside_ast)));
294290
}
295291
}
296-
match Parser::parse_file_as_module(
297-
self.parse_sess,
298-
&path,
299-
sub_mod.inner,
300-
) {
301-
Some(m) if outside_mods_empty => Ok(Some(SubModKind::External(
302-
path,
303-
ownership,
304-
Cow::Owned(m),
305-
))),
292+
match Parser::parse_file_as_module(self.parse_sess, &path, sub_mod.inner) {
293+
Some(m) if outside_mods_empty => {
294+
Ok(Some(SubModKind::External(path, ownership, Cow::Owned(m))))
295+
}
306296
Some(m) => {
307297
mods_outside_ast.push((path.clone(), ownership, Cow::Owned(m)));
308298
if should_insert {
@@ -319,7 +309,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
319309
mods_outside_ast.push((path, ownership, sub_mod.clone()));
320310
}
321311
Ok(Some(SubModKind::MultiExternal(mods_outside_ast)))
322-
},
312+
}
323313
}
324314
}
325315
Err(mut e) if !mods_outside_ast.is_empty() => {
@@ -385,11 +375,8 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
385375
));
386376
continue;
387377
}
388-
let m = match Parser::parse_file_as_module(
389-
self.parse_sess,
390-
&actual_path,
391-
sub_mod.inner,
392-
) {
378+
let m = match Parser::parse_file_as_module(self.parse_sess, &actual_path, sub_mod.inner)
379+
{
393380
Some(m) => m,
394381
None => continue,
395382
};

src/patterns.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ impl Rewrite for Pat {
231231
PatKind::Struct(ref path, ref fields, ellipsis) => {
232232
rewrite_struct_pat(path, fields, ellipsis, self.span, context, shape)
233233
}
234-
PatKind::MacCall(ref mac) => rewrite_macro(mac, None, context, shape, MacroPosition::Pat),
234+
PatKind::MacCall(ref mac) => {
235+
rewrite_macro(mac, None, context, shape, MacroPosition::Pat)
236+
}
235237
PatKind::Paren(ref pat) => pat
236238
.rewrite(context, shape.offset_left(1)?.sub_width(1)?)
237239
.map(|inner_pat| format!("({})", inner_pat)),

src/syntux/parser.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a> Parser<'a> {
168168
path: &Path,
169169
span: Span,
170170
) -> Option<ast::Mod> {
171-
let result = catch_unwind(AssertUnwindSafe(|| {
171+
let result = catch_unwind(AssertUnwindSafe(|| {
172172
let mut parser = new_parser_from_file(sess.inner(), &path, Some(span));
173173

174174
let lo = parser.token.span;
@@ -241,9 +241,7 @@ impl<'a> Parser<'a> {
241241
sess: &'a ParseSess,
242242
mac: &'a ast::MacCall,
243243
) -> Result<Vec<ast::Item>, &'static str> {
244-
match catch_unwind(AssertUnwindSafe(|| {
245-
Parser::parse_cfg_if_inner(sess, mac)
246-
})) {
244+
match catch_unwind(AssertUnwindSafe(|| Parser::parse_cfg_if_inner(sess, mac))) {
247245
Ok(Ok(items)) => Ok(items),
248246
Ok(err @ Err(_)) => err,
249247
Err(..) => Err("failed to parse cfg_if!"),
@@ -255,7 +253,8 @@ impl<'a> Parser<'a> {
255253
mac: &'a ast::MacCall,
256254
) -> Result<Vec<ast::Item>, &'static str> {
257255
let token_stream = mac.args.inner_tokens();
258-
let mut parser = rustc_parse::stream_to_parser(sess.inner(),token_stream.clone(),Some(""));
256+
let mut parser =
257+
rustc_parse::stream_to_parser(sess.inner(), token_stream.clone(), Some(""));
259258

260259
let mut items = vec![];
261260
let mut process_if_cfg = true;

0 commit comments

Comments
 (0)