Skip to content

Commit

Permalink
Expand - Allow macros to be expanded in final stage (for derive)
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed Jan 29, 2024
1 parent 4b818fb commit e2e8267
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/expand/mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,6 @@ ::std::unique_ptr<TokenStream> Expand_Macro(
Span mi_span, const AST::Path& path, const RcString& input_ident, TokenTree& input_tt
)
{
if( es.mode == ExpandMode::Final ) {
ERROR(mi_span, E0000, "Unknown macro " << path);
}
auto rv = Expand_Macro_Inner(es.crate, es.modstack, mod, mi_span, path, input_ident, input_tt);
if( rv ) {
es.change = true;
Expand All @@ -359,6 +356,10 @@ ::std::unique_ptr<TokenStream> Expand_Macro(
rv->parse_state().module = &mod;
}
else {
// HACK: Allow the expansion to happen, even in final (e.g. if from derive)
if( es.mode == ExpandMode::Final ) {
ERROR(mi_span, E0000, "Unknown macro " << path);
}
DEBUG("Missing, waiting until another pass");
es.has_missing = true;
}
Expand Down

0 comments on commit e2e8267

Please sign in to comment.