Skip to content
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

Investigate if proc-macro crates can use regular crate metadata. #49271

Closed
michaelwoerister opened this issue Mar 22, 2018 · 2 comments
Closed
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-metadata Area: Crate metadata C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@michaelwoerister
Copy link
Member

Currently, proc-macro crates require a lot of special-casing like the following:

pub fn get_def(&self, index: DefIndex) -> Option<Def> {
if !self.is_proc_macro(index) {
self.entry(index).kind.to_def(self.local_def_id(index))
} else {
let kind = self.proc_macros.as_ref().unwrap()[index.to_proc_macro_index()].1.kind();
Some(Def::Macro(self.local_def_id(index), kind))
}
}

I wonder if this is really necessary. It would be preferable if proc-macro crates could be treated as regular crates.

cc @rust-lang/compiler @jseyfried

@michaelwoerister michaelwoerister added A-metadata Area: Crate metadata A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 22, 2018
alexcrichton added a commit to alexcrichton/rust that referenced this issue Mar 23, 2018
…cro-defkey, r=eddyb

Fix DefKey lookup for proc-macro crates.

Add a special case for proc-macro crates for `def_key()` in the metadata decoder (like we already have for many other methods in there). In the long run, it would be preferable to get rid of the need for special casing proc-macro crates (see rust-lang#49271).

Fixes rust-lang#48739 (though I wasn't able to come up with a regression test, unfortunately)

r? @eddyb
kennytm added a commit to kennytm/rust that referenced this issue Mar 24, 2018
…cro-defkey, r=eddyb

Fix DefKey lookup for proc-macro crates.

Add a special case for proc-macro crates for `def_key()` in the metadata decoder (like we already have for many other methods in there). In the long run, it would be preferable to get rid of the need for special casing proc-macro crates (see rust-lang#49271).

Fixes rust-lang#48739 (though I wasn't able to come up with a regression test, unfortunately)

r? @eddyb
kennytm added a commit to kennytm/rust that referenced this issue Mar 24, 2018
…cro-defkey, r=eddyb

Fix DefKey lookup for proc-macro crates.

Add a special case for proc-macro crates for `def_key()` in the metadata decoder (like we already have for many other methods in there). In the long run, it would be preferable to get rid of the need for special casing proc-macro crates (see rust-lang#49271).

Fixes rust-lang#48739 (though I wasn't able to come up with a regression test, unfortunately)

r? @eddyb
@jkordish jkordish added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jun 5, 2018
@bjorn3
Copy link
Member

bjorn3 commented May 16, 2022

I believe this has been fixed for a while.

@oli-obk
Copy link
Contributor

oli-obk commented May 16, 2022

looks like it. There's mostly special casing in the metadata encoder to just skip serializing entire kinds of items

@oli-obk oli-obk closed this as completed May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-metadata Area: Crate metadata C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants