-
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
macros: improve $crate
#37213
macros: improve $crate
#37213
Conversation
cc #35896 |
to clarify - this PR doesn't actually allow any changes to the actual importing behaviour of such macros, it just lays internal groundwork to allow this in the future? |
Right, the only observable change from this PR is restricting where |
@bors: r+ |
📌 Commit 2676b25 has been approved by |
🔒 Merge conflict |
☔ The latest upstream changes (presumably #37269) made this pull request unmergeable. Please resolve the merge conflicts. |
2676b25
to
8b0c292
Compare
@bors r=nrc |
📌 Commit 8b0c292 has been approved by |
macros: improve `$crate` This PR refactors the implementation of `$crate` so that - `$crate` is only allowed at the start of a path (like `super`), - we can make `$crate` work with inter-crate re-exports (groundwork for macro modularization), and - we can support importing macros from an extern crate that is not declared at the crate root (also groundwork for macro modularization). This is a [breaking-change]. For example, the following would break: ```rust fn foo() {} macro_rules! m { () => { $crate foo $crate () $crate $crate; //^ Today, `$crate` is allowed just about anywhere in unexported macros. } } fn main() { m!(); } ``` r? @nrc
Fix regression involving custom derives on items with `$crate` The regression was introduced in #37213. I believe we cannot make the improvements from #37213 work with the current custom derive setup (c.f. #37637 (comment)) -- we'll have to wait for `TokenStream`'s API to improve. Fixes #37637. r? @nrc
This PR refactors the implementation of
$crate
so that$crate
is only allowed at the start of a path (likesuper
),$crate
work with inter-crate re-exports (groundwork for macro modularization), andThis is a [breaking-change]. For example, the following would break:
r? @nrc