Skip to content

Trying to expand macro in extern block causes excess memory usage #54441

Closed
@WarpspeedSCP

Description

@WarpspeedSCP

rustc --version --verbose output:

rustc 1.30.0-nightly (3bc2ca7e4 2018-09-20)
binary: rustc
commit-hash: 3bc2ca7e4f8507f82a4c357ee19300166bcd8099
commit-date: 2018-09-20
host: x86_64-unknown-linux-gnu
release: 1.30.0-nightly
LLVM version: 8.0

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 ran rustc --pretty expanded -Z unstable-options, my computer froze due to all (8 gigs) of my RAM being used up by rustc . An MCVE-

#![feature(macros_in_extern)]
#![feature(concat_idents)]

macro_rules! lua_func {
    ($name: ident, $ret: ty, $var: ident, $type: ty) => {
        let fn_name = concat_idents!(lua_, $name);
        pub fn fn_name (L: *mut lua_State, $var: $type) -> $ret
    };
}

extern "C" {
    lua_func!(toboolean, bool, idx, int);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions