mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Fix remaining test failure
This commit is contained in:
parent
0660dd10d2
commit
f3c6a2e3db
2 changed files with 11 additions and 9 deletions
|
@ -21,9 +21,7 @@ fn expand_rules(rules: &[crate::Rule], input: &tt::Subtree) -> ExpandResult<tt::
|
|||
let (new_match, bindings_err) = matcher::match_(&rule.lhs, input);
|
||||
if bindings_err.is_none() {
|
||||
// if we find a rule that applies without errors, we're done
|
||||
eprintln!("match without errors: {:?}", new_match);
|
||||
let (res, transcribe_err) = transcriber::transcribe(&rule.rhs, &new_match.bindings);
|
||||
eprintln!("transcribe_err = {:?}", transcribe_err);
|
||||
if transcribe_err.is_none() {
|
||||
return (res, None);
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ impl<'a> TtIter<'a> {
|
|||
pub(crate) fn expect_fragment(
|
||||
&mut self,
|
||||
fragment_kind: ra_parser::FragmentKind,
|
||||
) -> ExpandResult<tt::TokenTree> {
|
||||
) -> ExpandResult<Option<tt::TokenTree>> {
|
||||
pub(crate) struct OffsetTokenSink<'a> {
|
||||
pub(crate) cursor: Cursor<'a>,
|
||||
pub(crate) error: bool,
|
||||
|
@ -297,12 +297,16 @@ impl<'a> TtIter<'a> {
|
|||
}
|
||||
}
|
||||
self.inner = self.inner.as_slice()[res.len()..].iter();
|
||||
if res.len() == 0 && err.is_none() {
|
||||
err = Some(err!("no tokens consumed"));
|
||||
}
|
||||
let res = match res.len() {
|
||||
1 => res[0].clone(),
|
||||
_ => tt::TokenTree::Subtree(tt::Subtree {
|
||||
1 => Some(res[0].clone()),
|
||||
0 => None,
|
||||
_ => Some(tt::TokenTree::Subtree(tt::Subtree {
|
||||
delimiter: None,
|
||||
token_trees: res.into_iter().cloned().collect(),
|
||||
}),
|
||||
})),
|
||||
};
|
||||
(res, err)
|
||||
}
|
||||
|
@ -312,7 +316,7 @@ impl<'a> TtIter<'a> {
|
|||
match fork.expect_fragment(Visibility) {
|
||||
(tt, None) => {
|
||||
*self = fork;
|
||||
Some(tt)
|
||||
tt
|
||||
}
|
||||
(_, Some(_)) => None,
|
||||
}
|
||||
|
@ -419,8 +423,8 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
|
|||
}
|
||||
};
|
||||
let (tt, err) = input.expect_fragment(fragment);
|
||||
let fragment = if kind == "expr" { Fragment::Ast(tt) } else { Fragment::Tokens(tt) };
|
||||
(Some(fragment), err)
|
||||
let fragment = if kind == "expr" { tt.map(Fragment::Ast) } else { tt.map(Fragment::Tokens) };
|
||||
(fragment, err)
|
||||
}
|
||||
|
||||
fn collect_vars(buf: &mut Vec<SmolStr>, pattern: &tt::Subtree) -> Result<(), ExpandError> {
|
||||
|
|
Loading…
Reference in a new issue