forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#88428 - petrochenkov:stmtid, r=Aaron1011
expand: Treat more macro calls as statement macro calls This PR implements the suggestion from rust-lang#87981 (comment) and treats fn-like macro calls inside `StmtKind::Item` and `StmtKind::Semi` as statement macro calls, which is consistent with treatment of attribute invocations in the same positions and with token-based macro expansion model in general. This also allows to remove a special case in `NodeId` assignment (previously tried in rust-lang#87779), and to use statement `NodeId`s for linting (`assign_id!`). r? `@Aaron1011`
- Loading branch information
Showing
5 changed files
with
108 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// check-pass | ||
|
||
macro_rules! two_items { | ||
() => { | ||
extern "C" {} | ||
extern "C" {} | ||
}; | ||
} | ||
|
||
macro_rules! single_expr_funneler { | ||
($expr:expr) => { | ||
$expr; // note the semicolon, it changes the statement kind during parsing | ||
}; | ||
} | ||
|
||
macro_rules! single_item_funneler { | ||
($item:item) => { | ||
$item | ||
}; | ||
} | ||
|
||
fn main() { | ||
single_expr_funneler! { two_items! {} } | ||
single_item_funneler! { two_items! {} } | ||
} |