-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
resolve/metadata: Stop encoding macros as reexports #91795
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9519fe6
to
1b37371
Compare
This comment has been minimized.
This comment has been minimized.
hir: Do not introduce dummy type names for `extern` blocks in def paths Use a separate nameless `DefPathData` variant instead. Extracted from rust-lang#91795.
This comment has been minimized.
This comment has been minimized.
Remove effect of `#[no_link]` attribute on name resolution Previously it hid all non-macro names from other crates. This has no relation to linking and can change name resolution behavior in some cases (e.g. glob conflicts), in addition to just producing the "unresolved name" errors. I can kind of understand the possible reasoning behind the current behavior - if you can use names from a `no_link` crates then you can use, for example, functions too, but whether it will actually work or produce link-time errors will depend on random factors like inliner behavior. (^^^ This is not the actual reason why the current behavior exist, I've looked through git history and it's mostly accidental.) I think this risk is ok for such an obscure attribute, and we don't need to specifically prevent use of non-macro items from such crates. (I'm not actually sure why would anyone use `#[no_link]` on a crate, even if it's macro only, if you aware of any use cases, please share. IIRC, at some point it was used for crates implementing custom derives - the now removed legacy ones, not the current proc macros.) Extracted from rust-lang#91795.
1b37371
to
3776062
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8d8eb69
to
e2850ed
Compare
This comment has been minimized.
This comment has been minimized.
e2850ed
to
6f48c76
Compare
Previously macros were encoded as both items and reexports, but the item versions were ignored during decoding to avoid duplication. |
For performance it would be optimal to use two structures: // This struct is used during decoding and unifies both proper items and reexports
struct ModChild {
pub ident: Ident,
pub res: Res<!>,
pub vis: ty::Visibility,
pub span: Span,
pub macro_rules: bool,
}
// This structure is used for encoding the reexport table, `macro_rules` is always false by definition
pub struct Reexport {
pub ident: Ident,
pub res: Res<!>,
pub vis: ty::Visibility,
pub span: Span,
} , but I just didn't want to introduce more entities. |
6f48c76
to
63b50ec
Compare
Updated. |
This comment has been minimized.
This comment has been minimized.
63b50ec
to
1f8ebcc
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Sorry for the delay. |
…-in macros Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
To make the `macro_rules` flag more readily available without decoding everything else
1f8ebcc
to
b91ec30
Compare
@bors r=cjgillot |
📌 Commit b91ec30 has been approved by |
Rollup of 9 pull requests Successful merges: - rust-lang#91795 (resolve/metadata: Stop encoding macros as reexports) - rust-lang#93714 (better ObligationCause for normalization errors in `can_type_implement_copy`) - rust-lang#94175 (Improve `--check-cfg` implementation) - rust-lang#94212 (Stop manually SIMDing in `swap_nonoverlapping`) - rust-lang#94242 (properly handle fat pointers to uninhabitable types) - rust-lang#94308 (Normalize main return type during mono item collection & codegen) - rust-lang#94315 (update auto trait lint for `PhantomData`) - rust-lang#94316 (Improve string literal unescaping) - rust-lang#94327 (Avoid emitting full macro body into JSON errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
resolve: Turn the binding from `#[macro_export]` into a proper `Import` Continuation of rust-lang#91795. ```rust #[macro_export] macro_rules! m { /*...*/ } ``` is desugared to something like ```rust macro_rules! m { /*...*/ } // Non-modularized macro_rules item pub use m; // It's modularized reexport ``` This PR adjusts the internal representation to better match this model.
Supersedes #88335.
r? @cjgillot