mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Details about macro NestingState hit and at_end fields
This commit is contained in:
parent
6d84dee4e7
commit
c670a15345
1 changed files with 10 additions and 7 deletions
|
@ -18,16 +18,16 @@ impl Bindings {
|
||||||
let mut b = self.inner.get(name).ok_or_else(|| {
|
let mut b = self.inner.get(name).ok_or_else(|| {
|
||||||
ExpandError::BindingError(format!("could not find binding `{}`", name))
|
ExpandError::BindingError(format!("could not find binding `{}`", name))
|
||||||
})?;
|
})?;
|
||||||
for s in nesting.iter_mut() {
|
for nesting_state in nesting.iter_mut() {
|
||||||
s.hit = true;
|
nesting_state.hit = true;
|
||||||
b = match b {
|
b = match b {
|
||||||
Binding::Fragment(_) => break,
|
Binding::Fragment(_) => break,
|
||||||
Binding::Nested(bs) => bs.get(s.idx).ok_or_else(|| {
|
Binding::Nested(bs) => bs.get(nesting_state.idx).ok_or_else(|| {
|
||||||
s.at_end = true;
|
nesting_state.at_end = true;
|
||||||
ExpandError::BindingError(format!("could not find nested binding `{}`", name))
|
ExpandError::BindingError(format!("could not find nested binding `{}`", name))
|
||||||
})?,
|
})?,
|
||||||
Binding::Empty => {
|
Binding::Empty => {
|
||||||
s.at_end = true;
|
nesting_state.at_end = true;
|
||||||
return Err(ExpandError::BindingError(format!(
|
return Err(ExpandError::BindingError(format!(
|
||||||
"could not find empty binding `{}`",
|
"could not find empty binding `{}`",
|
||||||
name
|
name
|
||||||
|
@ -61,7 +61,11 @@ pub(super) fn transcribe(
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct NestingState {
|
struct NestingState {
|
||||||
idx: usize,
|
idx: usize,
|
||||||
|
/// `hit` is currently necessary to tell `expand_repeat` if it should stop
|
||||||
|
/// because there is no variable in use by the current repetition
|
||||||
hit: bool,
|
hit: bool,
|
||||||
|
/// `at_end` is currently necessary to tell `expand_repeat` if it should stop
|
||||||
|
/// because there is no more value avaible for the current repetition
|
||||||
at_end: bool,
|
at_end: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,8 +134,7 @@ fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr) -> Result<Fragment, ExpandError>
|
||||||
.into();
|
.into();
|
||||||
Fragment::Tokens(tt)
|
Fragment::Tokens(tt)
|
||||||
} else {
|
} else {
|
||||||
let fragment = ctx.bindings.get(&v, &mut ctx.nesting)?.clone();
|
ctx.bindings.get(&v, &mut ctx.nesting)?.clone()
|
||||||
fragment
|
|
||||||
};
|
};
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue