mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 13:23:25 +00:00
cargo fmt
This commit is contained in:
parent
87f837cec7
commit
7535bb4661
571 changed files with 2210 additions and 2458 deletions
|
|
@ -5,18 +5,19 @@ use rustc_hash::FxHashMap;
|
|||
use span::{Edition, Span};
|
||||
use stdx::itertools::Itertools;
|
||||
use syntax::{
|
||||
ast::{self, HasName},
|
||||
AstNode,
|
||||
ast::{self, HasName},
|
||||
};
|
||||
use syntax_bridge::{
|
||||
dummy_test_span_utils::{DummyTestSpanMap, DUMMY},
|
||||
syntax_node_to_token_tree, DocCommentDesugarMode,
|
||||
DocCommentDesugarMode,
|
||||
dummy_test_span_utils::{DUMMY, DummyTestSpanMap},
|
||||
syntax_node_to_token_tree,
|
||||
};
|
||||
use test_utils::{bench, bench_fixture, skip_slow_tests};
|
||||
|
||||
use crate::{
|
||||
parser::{MetaVarKind, Op, RepeatKind, Separator},
|
||||
DeclarativeMacro,
|
||||
parser::{MetaVarKind, Op, RepeatKind, Separator},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
@ -53,7 +54,7 @@ fn benchmark_expand_macro_rules() {
|
|||
.map(|(id, tt)| {
|
||||
let res = rules[&id].expand(&tt, |_| (), DUMMY, Edition::CURRENT);
|
||||
assert!(res.err.is_none());
|
||||
res.value.0 .0.len()
|
||||
res.value.0.0.len()
|
||||
})
|
||||
.sum()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use intern::Symbol;
|
|||
use rustc_hash::FxHashMap;
|
||||
use span::{Edition, Span};
|
||||
|
||||
use crate::{parser::MetaVarKind, ExpandError, ExpandErrorKind, ExpandResult, MatchedArmIndex};
|
||||
use crate::{ExpandError, ExpandErrorKind, ExpandResult, MatchedArmIndex, parser::MetaVarKind};
|
||||
|
||||
pub(crate) fn expand_rules(
|
||||
rules: &[crate::Rule],
|
||||
|
|
|
|||
|
|
@ -61,19 +61,19 @@
|
|||
|
||||
use std::{rc::Rc, sync::Arc};
|
||||
|
||||
use intern::{sym, Symbol};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use intern::{Symbol, sym};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use span::{Edition, Span};
|
||||
use tt::{
|
||||
iter::{TtElement, TtIter},
|
||||
DelimSpan,
|
||||
iter::{TtElement, TtIter},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
ExpandError, ExpandErrorKind, MetaTemplate, ValueResult,
|
||||
expander::{Binding, Bindings, ExpandResult, Fragment},
|
||||
expect_fragment,
|
||||
parser::{ExprKind, MetaVarKind, Op, RepeatKind, Separator},
|
||||
ExpandError, ExpandErrorKind, MetaTemplate, ValueResult,
|
||||
};
|
||||
|
||||
impl<'a> Bindings<'a> {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
//! Transcriber takes a template, like `fn $ident() {}`, a set of bindings like
|
||||
//! `$ident => foo`, interpolates variables in the template, to get `fn foo() {}`
|
||||
|
||||
use intern::{sym, Symbol};
|
||||
use intern::{Symbol, sym};
|
||||
use span::{Edition, Span};
|
||||
use tt::{iter::TtElement, Delimiter, TopSubtreeBuilder};
|
||||
use tt::{Delimiter, TopSubtreeBuilder, iter::TtElement};
|
||||
|
||||
use crate::{
|
||||
ExpandError, ExpandErrorKind, ExpandResult, MetaTemplate,
|
||||
expander::{Binding, Bindings, Fragment},
|
||||
parser::{ConcatMetaVarExprElem, MetaVarKind, Op, RepeatKind, Separator},
|
||||
ExpandError, ExpandErrorKind, ExpandResult, MetaTemplate,
|
||||
};
|
||||
|
||||
impl<'t> Bindings<'t> {
|
||||
|
|
@ -331,7 +331,10 @@ fn expand_subtree(
|
|||
}
|
||||
_ => {
|
||||
if err.is_none() {
|
||||
err = Some(ExpandError::binding_error(var.span, "metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`"))
|
||||
err = Some(ExpandError::binding_error(
|
||||
var.span,
|
||||
"metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`",
|
||||
))
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ mod tests;
|
|||
|
||||
use span::{Edition, Span, SyntaxContext};
|
||||
use syntax_bridge::to_parser_input;
|
||||
use tt::iter::TtIter;
|
||||
use tt::DelimSpan;
|
||||
use tt::iter::TtIter;
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use intern::{sym, Symbol};
|
||||
use intern::{Symbol, sym};
|
||||
use span::{Edition, Span, SyntaxContext};
|
||||
use tt::iter::{TtElement, TtIter};
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ fn next_op(
|
|||
let mut res = ArrayVec::new();
|
||||
res.push(*p);
|
||||
Box::new(res)
|
||||
}))
|
||||
}));
|
||||
}
|
||||
Some(it) => it,
|
||||
};
|
||||
|
|
@ -212,13 +212,13 @@ fn next_op(
|
|||
Mode::Pattern => {
|
||||
return Err(ParseError::unexpected(
|
||||
"`${}` metavariable expressions are not allowed in matchers",
|
||||
))
|
||||
));
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
return Err(ParseError::expected(
|
||||
"expected `$()` repetition or `${}` expression",
|
||||
))
|
||||
));
|
||||
}
|
||||
},
|
||||
TtElement::Leaf(leaf) => match leaf {
|
||||
|
|
@ -246,7 +246,7 @@ fn next_op(
|
|||
Mode::Pattern => {
|
||||
return Err(ParseError::unexpected(
|
||||
"`$$` is not allowed on the pattern side",
|
||||
))
|
||||
));
|
||||
}
|
||||
Mode::Template => Op::Punct({
|
||||
let mut res = ArrayVec::new();
|
||||
|
|
@ -255,7 +255,7 @@ fn next_op(
|
|||
}),
|
||||
},
|
||||
tt::Leaf::Punct(_) | tt::Leaf::Literal(_) => {
|
||||
return Err(ParseError::expected("expected ident"))
|
||||
return Err(ParseError::expected("expected ident"));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -348,7 +348,7 @@ fn parse_repeat(src: &mut TtIter<'_, Span>) -> Result<(Option<Separator>, Repeat
|
|||
};
|
||||
match tt {
|
||||
tt::Leaf::Ident(_) | tt::Leaf::Literal(_) if has_sep => {
|
||||
return Err(ParseError::InvalidRepeat)
|
||||
return Err(ParseError::InvalidRepeat);
|
||||
}
|
||||
tt::Leaf::Ident(ident) => separator = Separator::Ident(ident.clone()),
|
||||
tt::Leaf::Literal(lit) => separator = Separator::Literal(lit.clone()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue