-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to expand macro in extern block causes excess memory usage #54441
Comments
Minimized: #![feature(macros_in_extern)]
macro_rules! m {
() => {
let
};
}
extern "C" {
m!();
} |
This might well be my fault, so I'll try to look at it sometime this week. |
I've been able to repro the issue but I haven't run it through an allocation profiler yet*. The latest master doesn't like to build with my local Rust install so I spent a lot of time last night trying to figure out why but it finally worked when I gave up and just let it download a snapshot for stage 0. |
So far it looks like the leak involves Simple fix is to check at the end of |
|
make `Parser::parse_foreign_item()` return a foreign item or error Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter. This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`. closes rust-lang#54441 r? @petrochenkov cc @dtolnay
rustc --version --verbose
output:While trying to implement Lua in Rust, I wanted to write a macro to make writing function signatures easier. When I tested the macro within an
extern "C"
block, and ranrustc --pretty expanded -Z unstable-options
, my computer froze due to all (8 gigs) of my RAM being used up byrustc
. An MCVE-The text was updated successfully, but these errors were encountered: