Vadim Petrochenkov
106b30e869
macro_rules: NtLifetime
cannot start with an identifier
2020-04-04 16:23:43 +03:00
Matthias Krüger
9bba047c2e
Use if let instead of match when only matching a single variant (clippy::single_match)
...
Makes code more compact and reduces nestig.
2020-03-30 10:52:29 +02:00
bors
b9d5ee5676
Auto merge of #70261 - Centril:angle-args-partition, r=varkor
...
Move arg/constraint partition check to validation & improve recovery
- In the first commit, we move the check rejecting e.g., `<'a, Item = u8, String>` from the parser into AST validation.
- We then use this to improve the code for parsing generic arguments.
- And we add recovery for e.g., `<Item = >` (missing), `<Item = 42>` (constant), and `<Item = 'a>` (lifetime).
This is also preparatory work for supporting https://github.com/rust-lang/rust/issues/70256 .
r? @varkor
2020-03-28 11:13:09 +00:00
Mazdak Farrokhzad
91194f795c
parse: move constraint/arg restriction to ast_validation.
2020-03-27 07:39:14 +01:00
Mazdak Farrokhzad
6c643a070c
suggest semi on expr mac!() good as stmt mac!().
2020-03-27 07:02:50 +01:00
Esteban Küber
f18a6dcec0
Rename def_span
to guess_head_span
2020-03-25 16:45:12 -07:00
Mazdak Farrokhzad
d8080d828c
expand: address review comments
2020-03-24 06:28:56 +01:00
Mazdak Farrokhzad
21944b3a10
expand: add recovery for parse_nt
2020-03-24 06:28:56 +01:00
Mazdak Farrokhzad
2868045a28
expand: nix unused method
2020-03-24 06:28:56 +01:00
Mazdak Farrokhzad
1bfa2483d5
defatalize compile_declarative_macro
2020-03-24 06:28:56 +01:00
Mazdak Farrokhzad
df9cec2df4
mbe::transcribe: defatalize errors.
2020-03-24 06:28:56 +01:00
Mazdak Farrokhzad
ad26401dc1
remove ExtCxt::struct_span_warn
2020-03-24 06:28:56 +01:00
Mazdak Farrokhzad
c1ef1b3bca
defatalize ProcMacroDerive::expand
...
Also remove ExtCtxt::struct_span_fatal.
2020-03-24 06:28:56 +01:00
Mazdak Farrokhzad
ce8880d1d8
defatalize AttrProcMacro::expand
2020-03-24 06:28:55 +01:00
Mazdak Farrokhzad
35cca74212
defatalize BangProcMacro::expand
2020-03-24 06:28:55 +01:00
Mazdak Farrokhzad
b0537e2081
generic_extension: defatalize Error case
2020-03-24 06:28:55 +01:00
Mazdak Farrokhzad
b7909b22b5
nix remaining rustc_expand::panictry! uses.
2020-03-24 06:28:55 +01:00
Mazdak Farrokhzad
0a8db690a4
nix panictry! in ParserAnyMacro::make
2020-03-24 06:28:10 +01:00
Mazdak Farrokhzad
0f2d9686cc
rustc_expand::base: nix panictry! uses
2020-03-24 06:28:10 +01:00
Mazdak Farrokhzad
eaa0ae503f
parse: nix new_sub_parser_from_file
2020-03-22 00:35:20 +01:00
Mazdak Farrokhzad
d18ed205c9
parse: nix unused root_module_name
.
2020-03-21 22:51:03 +01:00
Dylan DPC
a6596f2a4d
Rollup merge of #69497 - Zoxc:ast-fragment-error, r=petrochenkov
...
Don't unwind when hitting the macro expansion recursion limit
This removes one use of `FatalError.raise()`.
r? @petrochenkov
2020-03-21 13:06:33 +01:00
Mazdak Farrokhzad
9b9a22cd2e
can_begin_literal_maybe_minus: true
on "-"? lit
NTs.
2020-03-20 16:42:53 +01:00
John Kåre Alsaker
82920f36c4
Don't unwind when hitting the macro expansion recursion limit
2020-03-19 14:59:14 +01:00
Mazdak Farrokhzad
5ee4f6f660
fix pre-expansion linting infra
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
fe71342091
tweak outline module parsing spans
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
7d0e5bbb67
parser/expand: minor cleanup
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
31ee8e0a43
{rustc_parse -> rustc_expand}::config
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
3796faefb1
{rustc_parse::parser -> rustc_expand}::module
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
ddcc8ec89d
move Directory -> parser::module
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
83a757a9ca
outline modules: parse -> expand.
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
b9e1b26611
expand: use push_directory
2020-03-18 15:08:25 +01:00
Mazdak Farrokhzad
8cf9e9efca
Rollup merge of #68746 - matthewjasper:metahygiene, r=petrochenkov
...
Make macro metavars respect (non-)hygiene
This makes them more consistent with other name resolution while not breaking any code on crater.
2020-03-17 12:16:10 +01:00
Mazdak Farrokhzad
9fc5c2d00d
Rollup merge of #69870 - petrochenkov:cfgacc, r=matthewjasper
...
expand: Implement something similar to `#[cfg(accessible(path))]`
cc https://github.com/rust-lang/rust/issues/64797
The feature is implemented as a `#[cfg_accessible(path)]` attribute macro rather than as `#[cfg(accessible(path))]` because it needs to wait until `path` becomes resolvable, and `cfg` cannot wait, but macros can wait.
Later we can think about desugaring or not desugaring `#[cfg(accessible(path))]` into `#[cfg_accessible(path)]`.
This implementation is also incomplete in the sense that it never returns "false" from `cfg_accessible(path)`, it requires some tweaks to resolve, which is not quite ready to answer queries like this during early resolution.
However, the most important part of this PR is not `cfg_accessible` itself, but expansion infrastructure for retrying expansions.
Before this PR we could say "we cannot resolve this macro path, let's try it later", with this PR we can say "we cannot expand this macro, let's try it later" as well.
This is a pre-requisite for
- turning `#[derive(...)]` into a regular attribute macro,
- properly supporting eager expansion for macros that cannot yet be resolved like
```
fn main() {
println!(not_available_yet!());
}
macro_rules! make_available {
() => { #[macro_export] macro_rules! not_available_yet { () => { "Hello world!" } }}
}
make_available!();
```
2020-03-17 03:05:12 +01:00
Matthew Jasper
ec862703fd
Make macro metavars respect (non-)hygiene
2020-03-16 17:13:48 +00:00
Vadim Petrochenkov
8c9a38f679
Other legacy
-> macro_rules
2020-03-16 00:29:42 +03:00
Vadim Petrochenkov
65bf4831d2
ast/hir: MacroDef::legacy
-> MacroDef::macro_rules
2020-03-16 00:29:03 +03:00
Vadim Petrochenkov
e809e0214e
ast: Mac
/Macro
-> MacCall
2020-03-12 22:26:52 +03:00
Mazdak Farrokhzad
fd302f46dc
Store TokenStream
in rmeta::MacroDef
.
...
This removes a hack from `load_macro_untracked` in which parsing is used.
2020-03-10 07:26:27 +01:00
Vadim Petrochenkov
2e6528961c
builtin_macros: Add attribute macro #[cfg_accessible(path)]
2020-03-10 01:02:13 +03:00
Vadim Petrochenkov
552a8875bd
expand: Implement support for retrying macro expansions
2020-03-10 00:56:09 +03:00
Vadim Petrochenkov
eafeb9a267
expand/builtin_macros: Minor cleanup
2020-03-09 20:50:48 +03:00
Vadim Petrochenkov
7a30bb1676
Address review comments
2020-03-09 13:07:21 +03:00
Vadim Petrochenkov
925e9a2188
rustc_parse: Use Token::ident
where possible
2020-03-09 12:42:41 +03:00
Mazdak Farrokhzad
10f999b72d
Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkov
...
fix various typos
2020-03-07 17:27:32 +01:00
Matthias Krüger
4c2b0f1631
bless tests
2020-03-06 19:37:22 +01:00
Vadim Petrochenkov
2d0c5b4337
rustc_expand: Factor out Annotatable::into_tokens
to a separate method
2020-03-06 20:34:01 +03:00
Matthias Krüger
136ad015b6
fix various typos
2020-03-06 15:19:31 +01:00
bors
4a1b69d53a
Auto merge of #69586 - petrochenkov:unmerge, r=Centril
...
ast: Unmerge structures for associated items and foreign items
Follow-up to https://github.com/rust-lang/rust/pull/69194 .
r? @Centril
2020-03-06 02:22:49 +00:00
Matthias Krüger
10183851fb
Improve weird formatting by moving comment inside else-code block.
2020-03-03 01:01:21 +01:00