tamer: asg::air: InvalidExpansionContext in place of TODO
There are no such invalid expansion contexts yet, but this gets rid of the final remaining TODO from introducing the stack. With the existing feature set, at least. DEV-13708main
parent
e3d60750a9
commit
6d35e8776c
|
@ -250,12 +250,21 @@ impl ParseState for AirTplAggregate {
|
|||
}
|
||||
|
||||
(Toplevel(tpl), AirTpl(TplEndRef(span))) => {
|
||||
let oi_target = ctx.expansion_oi().expect("TODO");
|
||||
tpl.oi().expand_into(ctx.asg_mut(), oi_target);
|
||||
// Note that we utilize lookahead in either case,
|
||||
// but in the case of an error,
|
||||
// we are effectively discarding the ref and translating
|
||||
// into a `TplEnd`.
|
||||
match ctx.expansion_oi() {
|
||||
Some(oi_target) => {
|
||||
tpl.oi().expand_into(ctx.asg_mut(), oi_target);
|
||||
|
||||
Transition(Toplevel(tpl.anonymous_reachable()))
|
||||
.incomplete()
|
||||
.with_lookahead(AirTpl(TplEnd(span)))
|
||||
Transition(Toplevel(tpl.anonymous_reachable()))
|
||||
.incomplete()
|
||||
}
|
||||
None => Transition(Toplevel(tpl))
|
||||
.err(AsgError::InvalidExpansionContext(span)),
|
||||
}
|
||||
.with_lookahead(AirTpl(TplEnd(span)))
|
||||
}
|
||||
|
||||
(
|
||||
|
|
|
@ -114,6 +114,10 @@ pub enum AsgError {
|
|||
///
|
||||
/// Ideally this situation is syntactically invalid in a source IR.
|
||||
InvalidRefContext(SPair),
|
||||
|
||||
/// Attempted to expand a template into a context that does not support
|
||||
/// expansion.
|
||||
InvalidExpansionContext(Span),
|
||||
}
|
||||
|
||||
impl Display for AsgError {
|
||||
|
@ -150,6 +154,9 @@ impl Display for AsgError {
|
|||
TtQuote::wrap(ident)
|
||||
)
|
||||
}
|
||||
InvalidExpansionContext(_) => {
|
||||
write!(f, "invalid template expansion context",)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,6 +264,9 @@ impl Diagnostic for AsgError {
|
|||
"cannot reference the value of an expression from outside \
|
||||
of an expression context",
|
||||
)],
|
||||
InvalidExpansionContext(span) => {
|
||||
vec![span.error("cannot expand a template here")]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue