mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +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);
|
let (new_match, bindings_err) = matcher::match_(&rule.lhs, input);
|
||||||
if bindings_err.is_none() {
|
if bindings_err.is_none() {
|
||||||
// if we find a rule that applies without errors, we're done
|
// 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);
|
let (res, transcribe_err) = transcriber::transcribe(&rule.rhs, &new_match.bindings);
|
||||||
eprintln!("transcribe_err = {:?}", transcribe_err);
|
|
||||||
if transcribe_err.is_none() {
|
if transcribe_err.is_none() {
|
||||||
return (res, None);
|
return (res, None);
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ impl<'a> TtIter<'a> {
|
||||||
pub(crate) fn expect_fragment(
|
pub(crate) fn expect_fragment(
|
||||||
&mut self,
|
&mut self,
|
||||||
fragment_kind: ra_parser::FragmentKind,
|
fragment_kind: ra_parser::FragmentKind,
|
||||||
) -> ExpandResult<tt::TokenTree> {
|
) -> ExpandResult<Option<tt::TokenTree>> {
|
||||||
pub(crate) struct OffsetTokenSink<'a> {
|
pub(crate) struct OffsetTokenSink<'a> {
|
||||||
pub(crate) cursor: Cursor<'a>,
|
pub(crate) cursor: Cursor<'a>,
|
||||||
pub(crate) error: bool,
|
pub(crate) error: bool,
|
||||||
|
@ -297,12 +297,16 @@ impl<'a> TtIter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.inner = self.inner.as_slice()[res.len()..].iter();
|
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() {
|
let res = match res.len() {
|
||||||
1 => res[0].clone(),
|
1 => Some(res[0].clone()),
|
||||||
_ => tt::TokenTree::Subtree(tt::Subtree {
|
0 => None,
|
||||||
|
_ => Some(tt::TokenTree::Subtree(tt::Subtree {
|
||||||
delimiter: None,
|
delimiter: None,
|
||||||
token_trees: res.into_iter().cloned().collect(),
|
token_trees: res.into_iter().cloned().collect(),
|
||||||
}),
|
})),
|
||||||
};
|
};
|
||||||
(res, err)
|
(res, err)
|
||||||
}
|
}
|
||||||
|
@ -312,7 +316,7 @@ impl<'a> TtIter<'a> {
|
||||||
match fork.expect_fragment(Visibility) {
|
match fork.expect_fragment(Visibility) {
|
||||||
(tt, None) => {
|
(tt, None) => {
|
||||||
*self = fork;
|
*self = fork;
|
||||||
Some(tt)
|
tt
|
||||||
}
|
}
|
||||||
(_, Some(_)) => None,
|
(_, 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 (tt, err) = input.expect_fragment(fragment);
|
||||||
let fragment = if kind == "expr" { Fragment::Ast(tt) } else { Fragment::Tokens(tt) };
|
let fragment = if kind == "expr" { tt.map(Fragment::Ast) } else { tt.map(Fragment::Tokens) };
|
||||||
(Some(fragment), err)
|
(fragment, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_vars(buf: &mut Vec<SmolStr>, pattern: &tt::Subtree) -> Result<(), ExpandError> {
|
fn collect_vars(buf: &mut Vec<SmolStr>, pattern: &tt::Subtree) -> Result<(), ExpandError> {
|
||||||
|
|
Loading…
Reference in a new issue