| Age | Commit message (Collapse) | Author | Lines |
|
`syntax_expand` -> `rustc_expand`
`syntax_pos` -> `rustc_span`
`syntax_ext` -> `rustc_builtin_macros`
|
|
Fix outdated comment
Logics in `libsyntax/ext/expand.rs:MacroExpander::expand()` have been moved to `libsyntax_expand/expand.rs:MacroExpander::fully_expand_fragment()`
This pull request fixs the dangling file path.
#### Old
https://github.com/rust-lang/rust/blob/35176867f62f76b9bc27267878f2d74d9c776221/src/libsyntax/ext/expand.rs#L285-L301
#### New
https://github.com/rust-lang/rust/blob/9ff30a7810c586819a78188c173a7b74adbb9730/src/libsyntax_expand/expand.rs#L421-L439
https://github.com/rust-lang/rust/blob/9ff30a7810c586819a78188c173a7b74adbb9730/src/libsyntax_expand/base.rs#L224-L234
|
|
|
|
Logics in libsyntax/ext/expand.rs:MacroExpander::expand() have moved to libsyntax_expand/expand.rs:MacroExpander::fully_expand_fragment()
|
|
Merge `ast::Mutability` and `mir::Mutability`
r? @oli-obk
|
|
|
|
2. mir::Mutability -> ast::Mutability.
|
|
|
|
|
|
|
|
|
|
Also remove a couple of redundant `visit_mac` asserts
|
|
|
|
|
|
|
|
|
|
This is done by moving some data definitions to syntax::expand.
|
|
|
|
|
|
|
|
|
|
The dummy Span pointed to the beginning of the source file instead to
where the `#[derive]` is located. Later, it tripped the
`in_derive_expansion(span)` check at `src/librustc/middle/stability.rs`,
causing a span-less deprecation warning to be emitted.
Fixes #56195, #55417.
|
|
|
|
|
|
|
|
|
|
It was never used
|
|
|
|
|
|
Arm, Field, FieldPat, GenericParam, Param, StructField and Variant
|
|
|
|
|
|
Replace them with equivalents of `Span::{def_site,call_site}` from proc macro API.
The new API is much less error prone and doesn't rely on macros having default transparency.
|
|
Also make them generally more hygienic with name resolution.
|
|
For naming consistency with everything else in this area
|
|
|
|
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
|
|
|
|
Merge Variant and Variant_
Extracted from #63468.
|
|
|
|
|
|
Move special treatment of `derive(Copy, PartialEq, Eq)` from expansion infrastructure to elsewhere
As described in https://github.com/rust-lang/rust/pull/62086#issuecomment-515195477.
Reminder:
- `derive(PartialEq, Eq)` makes the type it applied to a "structural match" type, so constants of this type can be used in patterns (and const generics in the future).
- `derive(Copy)` notifies other derives that the type it applied to implements `Copy`, so `derive(Clone)` can generate optimized code and other derives can generate code working with `packed` types and types with `rustc_layout_scalar_valid_range` attributes.
First, the special behavior is now enabled after properly resolving the derives, rather than after textually comparing them with `"Copy"`, `"PartialEq"` and `"Eq"` in `fn add_derived_markers`.
The markers are no longer kept as attributes in AST since derives cannot modify items and previously did it through hacks in the expansion infra.
Instead, the markers are now kept in a "global context" available from all the necessary places, namely - resolver.
For `derive(PartialEq, Eq)` the markers are created by the derive macros themselves and then consumed during HIR lowering to add the `#[structural_match]` attribute in HIR.
This is still a hack, but now it's a hack local to two specific macros rather than affecting the whole expansion infra.
Ideally we should find the way to put `#[structural_match]` on the impls rather than on the original item, and then consume it in `rustc_mir`, then no hacks in expansion and lowering will be required.
(I'll make an issue about this for someone else to solve, after this PR lands.)
The marker for `derive(Copy)` cannot be emitted by the `Copy` macro itself because we need to know it *before* the `Copy` macro is expanded for expanding other macros.
So we have to do it in resolve and block expansion of any derives in a `derive(...)` container until we know for sure whether this container has `Copy` in it or not.
Nasty stuff.
r? @eddyb or @matthewjasper
|
|
|
|
infrastructure to elsewhere
|
|
|
|
MetaItem.span was always equivalent
|
|
|
|
|
|
|
|
Also give them a span in the HIR
|