Don't expand macros in the same expansion tree after overflow

This commit is contained in:
Ryo Yoshida 2023-02-08 20:11:54 +09:00
parent 8011029d3a
commit ae7e62c50f
No known key found for this signature in database
GPG key ID: E25698A930586171
4 changed files with 114 additions and 49 deletions

View file

@ -55,6 +55,7 @@ pub type ExpandResult<T> = ValueResult<T, ExpandError>;
pub enum ExpandError {
UnresolvedProcMacro(CrateId),
Mbe(mbe::ExpandError),
RecursionOverflowPosioned,
Other(Box<str>),
}
@ -69,6 +70,9 @@ impl fmt::Display for ExpandError {
match self {
ExpandError::UnresolvedProcMacro(_) => f.write_str("unresolved proc-macro"),
ExpandError::Mbe(it) => it.fmt(f),
ExpandError::RecursionOverflowPosioned => {
f.write_str("overflow expanding the original macro")
}
ExpandError::Other(it) => f.write_str(it),
}
}