chore: fix src formatting
This commit is contained in:
parent
9b0ed57af6
commit
bea7209d0a
4 changed files with 19 additions and 28 deletions
|
|
@ -1186,7 +1186,10 @@ fn next_space(tok: &TokenKind) -> SpaceState {
|
|||
/// Tries to convert a macro use into a short hand try expression. Returns `None`
|
||||
/// when the macro is not an instance of `try!` (or parsing the inner expression
|
||||
/// failed).
|
||||
pub(crate) fn convert_try_mac(mac: &ast::MacCall, context: &RewriteContext<'_>) -> Option<ast::Expr> {
|
||||
pub(crate) fn convert_try_mac(
|
||||
mac: &ast::MacCall,
|
||||
context: &RewriteContext<'_>,
|
||||
) -> Option<ast::Expr> {
|
||||
let path = &pprust::path_to_string(&mac.path);
|
||||
if path == "try" || path == "r#try" {
|
||||
let ts = mac.args.inner_tokens();
|
||||
|
|
|
|||
|
|
@ -251,11 +251,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
|||
if self.parse_sess.is_file_parsed(&path) {
|
||||
return Ok(None);
|
||||
}
|
||||
return match Parser::parse_file_as_module(
|
||||
self.parse_sess,
|
||||
&path,
|
||||
sub_mod.inner,
|
||||
) {
|
||||
return match Parser::parse_file_as_module(self.parse_sess, &path, sub_mod.inner) {
|
||||
Some(m) => Ok(Some(SubModKind::External(
|
||||
path,
|
||||
DirectoryOwnership::Owned { relative: None },
|
||||
|
|
@ -293,16 +289,10 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
|||
return Ok(Some(SubModKind::MultiExternal(mods_outside_ast)));
|
||||
}
|
||||
}
|
||||
match Parser::parse_file_as_module(
|
||||
self.parse_sess,
|
||||
&path,
|
||||
sub_mod.inner,
|
||||
) {
|
||||
Some(m) if outside_mods_empty => Ok(Some(SubModKind::External(
|
||||
path,
|
||||
ownership,
|
||||
Cow::Owned(m),
|
||||
))),
|
||||
match Parser::parse_file_as_module(self.parse_sess, &path, sub_mod.inner) {
|
||||
Some(m) if outside_mods_empty => {
|
||||
Ok(Some(SubModKind::External(path, ownership, Cow::Owned(m))))
|
||||
}
|
||||
Some(m) => {
|
||||
mods_outside_ast.push((path.clone(), ownership, Cow::Owned(m)));
|
||||
if should_insert {
|
||||
|
|
@ -319,7 +309,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
|||
mods_outside_ast.push((path, ownership, sub_mod.clone()));
|
||||
}
|
||||
Ok(Some(SubModKind::MultiExternal(mods_outside_ast)))
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(mut e) if !mods_outside_ast.is_empty() => {
|
||||
|
|
@ -385,11 +375,8 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
|
|||
));
|
||||
continue;
|
||||
}
|
||||
let m = match Parser::parse_file_as_module(
|
||||
self.parse_sess,
|
||||
&actual_path,
|
||||
sub_mod.inner,
|
||||
) {
|
||||
let m = match Parser::parse_file_as_module(self.parse_sess, &actual_path, sub_mod.inner)
|
||||
{
|
||||
Some(m) => m,
|
||||
None => continue,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -231,7 +231,9 @@ impl Rewrite for Pat {
|
|||
PatKind::Struct(ref path, ref fields, ellipsis) => {
|
||||
rewrite_struct_pat(path, fields, ellipsis, self.span, context, shape)
|
||||
}
|
||||
PatKind::MacCall(ref mac) => rewrite_macro(mac, None, context, shape, MacroPosition::Pat),
|
||||
PatKind::MacCall(ref mac) => {
|
||||
rewrite_macro(mac, None, context, shape, MacroPosition::Pat)
|
||||
}
|
||||
PatKind::Paren(ref pat) => pat
|
||||
.rewrite(context, shape.offset_left(1)?.sub_width(1)?)
|
||||
.map(|inner_pat| format!("({})", inner_pat)),
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ impl<'a> Parser<'a> {
|
|||
path: &Path,
|
||||
span: Span,
|
||||
) -> Option<ast::Mod> {
|
||||
let result = catch_unwind(AssertUnwindSafe(|| {
|
||||
let result = catch_unwind(AssertUnwindSafe(|| {
|
||||
let mut parser = new_parser_from_file(sess.inner(), &path, Some(span));
|
||||
|
||||
let lo = parser.token.span;
|
||||
|
|
@ -241,9 +241,7 @@ impl<'a> Parser<'a> {
|
|||
sess: &'a ParseSess,
|
||||
mac: &'a ast::MacCall,
|
||||
) -> Result<Vec<ast::Item>, &'static str> {
|
||||
match catch_unwind(AssertUnwindSafe(|| {
|
||||
Parser::parse_cfg_if_inner(sess, mac)
|
||||
})) {
|
||||
match catch_unwind(AssertUnwindSafe(|| Parser::parse_cfg_if_inner(sess, mac))) {
|
||||
Ok(Ok(items)) => Ok(items),
|
||||
Ok(err @ Err(_)) => err,
|
||||
Err(..) => Err("failed to parse cfg_if!"),
|
||||
|
|
@ -255,7 +253,8 @@ impl<'a> Parser<'a> {
|
|||
mac: &'a ast::MacCall,
|
||||
) -> Result<Vec<ast::Item>, &'static str> {
|
||||
let token_stream = mac.args.inner_tokens();
|
||||
let mut parser = rustc_parse::stream_to_parser(sess.inner(),token_stream.clone(),Some(""));
|
||||
let mut parser =
|
||||
rustc_parse::stream_to_parser(sess.inner(), token_stream.clone(), Some(""));
|
||||
|
||||
let mut items = vec![];
|
||||
let mut process_if_cfg = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue