Commit Graph

2644 Commits

Author SHA1 Message Date
bors 9337ad5bae Auto merge of #42103 - jorendorff:master, r=estebank
trace_macro: Show both the macro call and its expansion. #42072.

See #42072 for the initial motivation behind this.

The change is not the minimal fix, but I want this behavior almost every time I use `trace_macros`.
2017-05-27 17:38:11 +00:00
Jeffrey Seyfried 7fdc1fb2e4 Hygienize lifetimes. 2017-05-25 05:52:09 +00:00
Jeffrey Seyfried 1f175fa35d Hygienize librustc_resolve. 2017-05-25 05:51:50 +00:00
Jeffrey Seyfried 2a1d2edb82 Declarative macros 2.0 without hygiene. 2017-05-25 05:51:06 +00:00
Jeffrey Seyfried 9c6430b325 Refactor out ast::MacroDef. 2017-05-25 05:47:25 +00:00
Mark Simulacrum 43d81a8c95 Rollup merge of #42071 - nrc:parse-mods, r=nikomatsakis
Add an option to the parser to avoid parsing out of line modules

This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
2017-05-24 19:50:00 -06:00
Mark Simulacrum 8b93680d28 Rollup merge of #42006 - jseyfried:fix_include_regression, r=nrc
Fix ICE on `include!(line!())` (regression)

Fixes #41776.
r? @nrc
2017-05-19 14:16:15 -06:00
Jason Orendorff f8b66a001d trace_macro: Show both the macro call and its expansion. #42072. 2017-05-19 13:43:06 -05:00
Nick Cameron a2566301e1 Add an option to the parser to avoid parsing out of line modules
This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
2017-05-18 11:03:07 +12:00
bors 208d23a996 Auto merge of #41961 - kennytm:fix-35829, r=petrochenkov
Fix #35829 (`quote!()` does not handle `br#"…"#`)

Fix issue #35829 (syntax extension's `quote_expr!()` does not handle `b"…"` and proc_macro's `quote!()` does not handle `r#"…"#`)

* Handles `b"…"`, `br#"…"#` and `...` for `quote_expr!()`.
* Refactored the match statement to allow it to complain loudly on any unhandled token.
* Similarly, proc_macro's `quote!()` did not handle `br#"…"#` or `r#"…"#`, so this PR fixes it too.
2017-05-17 08:14:55 +00:00
bors d8215fc238 Auto merge of #42049 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 5 pull requests

- Successful merges: #41937, #41957, #42017, #42039, #42046
- Failed merges:
2017-05-17 01:57:45 +00:00
Mark Simulacrum 4066c8ec71 Rollup merge of #41957 - llogiq:clippy-libsyntax, r=petrochenkov
Fix some clippy warnings in libsyntax

This is mostly removing stray ampersands, needless returns and lifetimes. Basically a lot of small changes.
2017-05-16 17:31:50 -06:00
bors 86319e473e Auto merge of #41907 - est31:macro_unused, r=jseyfried
Add lint for unused macros

Addresses parts of #34938, to add a lint for unused macros.

We now output warnings by default when we encounter a macro that we didn't use for expansion.

Issues to be resolved before this PR is ready for merge:

- [x] fix the NodeId issue described above
- [x] remove all unused macros from rustc and the libraries or set `#[allow(unused_macros)]` next to them if they should be kept for some reason. This is needed for successful boostrap and bors to accept the PR. -> #41934
- [x] ~~implement the full extent of #34938, that means the macro match arm checking as well.~~ *let's not do this for now*
2017-05-16 23:27:36 +00:00
Mark Simulacrum 6b4f3a73d2 Rollup merge of #42005 - jseyfried:fix_macro_regression, r=nrc
Fix regression in `macro_rules!` name matching

Fixes #41803.
r? @nrc
2017-05-16 08:18:34 -06:00
Andre Bogus 958c67d9c8 adressed comments by @kennytm and @petrochenkov 2017-05-15 23:56:09 +02:00
Jeffrey Seyfried 4f2f27014d Fix regression on include!(line!()). 2017-05-15 09:41:05 +00:00
Jeffrey Seyfried 9f4e1e10a4 Fix regression in macro_rules! name matching. 2017-05-15 09:26:26 +00:00
est31 25b7f10c78 Address review comments 2017-05-15 07:38:39 +02:00
est31 d14d194f61 Support #[allow] etc logic on a per macro level
This commit extends the current unused macro linter
to support directives like #[allow(unused_macros)]
or #[deny(unused_macros)] directly next to the macro
definition, or in one of the modules the macro is
inside. Before, we only supported such directives
at a per crate level, due to the crate's NodeId
being passed to session.add_lint.

We also had to implement handling of the macro's
NodeId in the lint visitor.
2017-05-13 16:02:29 +02:00
est31 df188b8f97 Add lint for unused macros 2017-05-13 16:02:29 +02:00
kennytm 115854e19c Fix #35829 (syntax extension's quote_expr!() does not handle b"…")
* Handles `b"…"`, `br#"…"#` and `...` for `quote_expr!()`.
* Refactored the match statement to allow it to complain loudly on any
  unhandled token.
* Similarly, proc_macro's `quote!()` did not handle `br#"…"#` or `r#"…"#`,
  so this commit fixes it too.
2017-05-13 21:41:25 +08:00
Andre Bogus a9c163ebe9 Fix some clippy warnings in libsyntax
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-05-12 20:05:39 +02:00
Corey Farwell 1940c31c92 Rollup merge of #41520 - estebank:trace-macro, r=nikomatsakis
Use diagnostics for trace_macro instead of println

When using `trace_macro`, use `span_label`s instead of `println`:

```rust
note: trace_macro
  --> $DIR/trace-macro.rs:14:5
   |
14 |     println!("Hello, World!");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expands to `println! { "Hello, World!" }`
   = note: expands to `print! { concat ! ( "Hello, World!" , "\n" ) }`
```

Fix #22597.
2017-05-08 22:34:47 -04:00
bors 0c2f34dd02 Auto merge of #41676 - sirideain:expand-macro-recursion-limit, r=jseyfried
Increase macro recursion limit to 1024

Fixes #22552
2017-05-07 03:01:31 +00:00
Esteban Küber 8c9ad8d72c Group "macro expansion" notes per call span 2017-05-06 00:55:42 -07:00
Esteban Küber 56411443f2 Use diagnostics for trace_macro instead of println 2017-05-05 15:51:48 -07:00
est31 d290849a23 Removal pass for anonymous parameters
Removes occurences of anonymous parameters from the
rustc codebase, as they are to be deprecated.

See issue #41686 and RFC 1685.
2017-05-02 05:55:20 +02:00
Charlie Sheridan 3008f53c95 Increase macro recursion limit to 1024 Fixes #22552 2017-05-01 19:23:11 -04:00
Michael Woerister 39ffea31df Implement a file-path remapping feature in support of debuginfo and reproducible builds. 2017-04-26 15:44:02 +02:00
Austin Bonander 910532ea45 Don't panic if an attribute macro fails to resolve at crate root
Adds temporary regression test; this ideally should work as-is (#41430)

Closes #41211
2017-04-20 16:13:13 -07:00
bors 235fe8313f Auto merge of #41282 - arielb1:missing-impl-item, r=petrochenkov
libsyntax/parse: fix missing kind error reporting

Fixes #41161.
Fixes #41239.
2017-04-17 22:22:56 +00:00
Ariel Ben-Yehuda d648c10e5b libsyntax/parse: improve associated item error reporting
Fixes #41161.
Fixes #41239.
2017-04-17 21:25:35 +03:00
Alex Burka e0cd76674d feature gate :vis matcher 2017-04-15 19:06:58 +00:00
Alex Burka 37459e13fc widen :vis follow set 2017-04-15 19:06:19 +00:00
Alex Burka 16010c2f50 parse interpolated visibility tokens 2017-04-15 19:06:19 +00:00
Alex Burka d53e413e04 update :vis implementation to current rust 2017-04-15 19:06:19 +00:00
Daniel Keep a2489495d9 Implementation of the vis macro matcher. 2017-04-15 19:06:19 +00:00
A.J. Gardner 768e902941 First attempt at global_asm! macro 2017-04-12 19:12:49 -05:00
Jeffrey Seyfried 6a9448b523 Fix bug parsing #[derive] macro invocations. 2017-04-03 23:02:49 +00:00
Jeffrey Seyfried 8fde04b4a2 Improve Path spans. 2017-03-30 05:44:56 +00:00
Jeffrey Seyfried f08d5ad4c5 Refactor how spans are combined in the parser. 2017-03-29 11:17:59 +00:00
Jeffrey Seyfried ec7c0aece1 Merge ExpnId and SyntaxContext. 2017-03-29 00:41:10 +00:00
Jeffrey Seyfried 1979f96549 Move syntax::ext::hygiene to syntax_pos::hygiene. 2017-03-29 00:41:08 +00:00
Alex Crichton 1fe2dfca81 Rollup merge of #40813 - jseyfried:fix_expansion_regression, r=nrc
macros: fix ICE on some nested macro definitions

Fixes #40770.
r? @nrc
2017-03-27 15:56:24 -07:00
Oliver Schneider eb447f4ef4 Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
Jeffrey Seyfried 29a052d2d8 Fix ICE with nested macros in certain situations. 2017-03-25 04:04:13 +00:00
Michael Woerister bc259ee844 Introduce HirId, a replacement for NodeId after lowering to HIR.
HirId has a more stable representation than NodeId, meaning that
modifications to one item don't influence (part of) the IDs within
other items. The other part is a DefIndex for which there already
is a way of stable hashing and persistence.

This commit introduces the HirId type and generates a HirId for
every NodeId during HIR lowering, but the resulting values are
not yet used anywhere, except in consistency checks.
2017-03-22 17:02:07 +01:00
Vadim Petrochenkov b5e889791a Refactor parsing of trait object types 2017-03-21 23:01:53 +03:00
bors 9c15de4fd5 Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrc
`TokenStream`-based attributes, paths in attribute and derive macro invocations

This PR
 - refactors `Attribute` to use  `Path` and `TokenStream` instead of `MetaItem`.
 - supports macro invocation paths for attribute procedural macros.
   - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;`
 - supports macro invocation paths for derive procedural macros.
   - e.g. `#[derive(foo::Bar, super::Baz)] struct S;`
 - supports arbitrary tokens as arguments to attribute procedural macros.
   - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;`
 - supports using arbitrary tokens in "inert attributes" with derive procedural macros.
   - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);`
where `#[proc_macro_derive(Foo, attributes(inert))]`

r? @nrc
2017-03-19 10:56:08 +00:00
Jeffrey Seyfried 839c2860cc Liberalize attributes. 2017-03-14 04:39:21 +00:00