| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Define built-in macros through libcore
This PR defines built-in macros through libcore using a scheme similar to lang items (attribute `#[rustc_builtin_macro]`).
All the macro properties (stability, visibility, etc.) are taken from the source code in libcore, with exception of the expander function transforming input tokens/AST into output tokens/AST, which is still provided by the compiler.
The macros are made available to user code through the standard library prelude (`{core,std}::prelude::v1`), so they are still always in scope.
As a result **built-in macros now have stable absolute addresses in the library**, like `core::prelude::v1::line!()`, this is an insta-stable change.
Right now `prelude::v1` is the only publicly available absolute address for these macros, but eventually they can be moved into more appropriate locations with library team approval (e.g. `Clone` derive -> `core::clone::Clone`).
Now when built-in macros have canonical definitions they can be imported or reexported without issues (https://github.com/rust-lang/rust/issues/61687).
Other changes:
- You can now define a derive macro with a name matching one of the built-in derives (https://github.com/rust-lang/rust/issues/52269). This was an artificial restriction that could be worked around with import renaming anyway.
Known regressions:
- Empty library crate with a crate-level `#![test]` attribute no longer compiles without `--test`. Previously it didn't compile *with* `--test` or with the bin crate type.
Fixes https://github.com/rust-lang/rust/issues/61687
Fixes https://github.com/rust-lang/rust/issues/61804
r? @eddyb
|
|
|
|
When 2 or more sequences share the same span, we can't use the precomputed map
for their first set. So we compute it recursively.
Fixes #62831.
|
|
Handle more cases of typos misinterpreted as type ascription
Fix #60933, #54516.
CC #47666, #34255, #48016.
|
|
Specific error for positional args after named args in `format!()`
When writing positional arguments after named arguments in the
`format!()` and `println!()` macros, provide a targeted diagnostic.
Follow up to https://github.com/rust-lang/rust/pull/57522/files#r247278885
|
|
|
|
|
|
resolve: Improve candidate search for unresolved macro suggestions
Use same scope visiting machinery for both collecting suggestion candidates and actually resolving the names.
The PR is better read in per-commit fashion with whitespace changes ignored (the first commit in particular moves some code around).
This should be the last pre-requisite for https://github.com/rust-lang/rust/pull/62086.
r? @davidtwco
|
|
|
|
Normally `#![feature(...)]` shouldn't change behavior, but custom attributes in particular are in the process of retirement, and we should not produce a message telling to enable them.
It also helps with unifying diagnostics for unresolved macros.
|
|
https://github.com/rust-lang/rust/issues/60532
|
|
When writing positional arguments after named arguments in the
`format!()` and `println!()` macros, provide a targeted diagnostic.
|
|
Fix some remaining cases of bad formatting
Update some failing tests
|
|
|
|
|
|
Add a test for the issue resolved by removing `resolve_macro_path`
Add a test making sure that extern prelude entries introduced from an opaque macro are not visible anywhere, even it that macro
Fix test output after rebase
|
|
It's more convenient to have all this highly related stuff together on one screen (for future refactorings).
The `expand_invoc` function is compact enough now, after all the previous refactorings.
|
|
Remove a bunch of `Option`s that assumed that dummy fragment creation could fail.
The test output changed due to not performing the expansion in `fn expand_invoc` in case of the recursion limit hit.
|
|
Also move macro stability checking closer to other checks performed on obtained resolutions.
Tighten the stability spans as well, it is an error to *refer* to and unstable entity in any way, not only "call" it.
|
|
This way we are processing all of them in a single point, rather than separately for each syntax extension kind.
Also, the standard expected/found wording is used.
|
|
It either returns the indeterminacy error, or valid (but perhaps dummy) `SyntaxExtension`.
With this change enum `Determinacy` is no longer used in libsyntax and can be moved to resolve.
The regressions in diagnosics are fixed in the next commits.
|
|
https://github.com/rust-lang/rust/issues/60532
|
|
|
|
|
|
|
|
|
|
|
|
|
|
It's a less powerful duplicate of `SyntaxExtension::NormalTT`
|
|
|
|
|
|
|
|
syntax: Remove `Deref` impl from `Token`
Follow up to https://github.com/rust-lang/rust/pull/61541
r? @oli-obk
|
|
Unlike other built-in attributes, this attribute accepts any input
|
|
|
|
- Add detail on origin of current parser when reaching EOF and stop
saying "found <eof>" and point at the end of macro calls
- Handle empty `cfg_attr` attribute
- Reword empty `derive` attribute error
|
|
|
|
Remove some dead code
|
|
Make assert! ensure the macro is parsed completely
Fixes https://github.com/rust-lang/rust/issues/60024
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Make duplicate matcher bindings a hard error
r? @Centril
Closes #57742
|
|
Tweak unstable diagnostic output
|
|
|
|
|