Commit Graph

163 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
88c007cd04
Rollup merge of #62249 - czipperz:use-mem-take-instead-of-replace-default, r=dtolnay,Centril
Use mem::take instead of mem::replace with default
2019-07-04 01:38:46 +02:00
Jeremy Stucki
87e8613fd4
Remove needless lifetimes 2019-07-03 10:00:23 +02:00
Chris Gregory
b0c199a969 Enable mem_take feature in relevant crates 2019-07-01 20:21:53 -07:00
Chris Gregory
8a3797b736 Use mem::take instead of mem::replace with default 2019-07-01 20:21:12 -07:00
Julien Cretin
b8106b59d2 Fix meta-variable binding errors in macros
The errors are either:
- The meta-variable used in the right-hand side is not bound (or defined) in the
  left-hand side.
- The meta-variable used in the right-hand side does not repeat with the same
  kleene operator as its binder in the left-hand side. Either it does not repeat
  enough, or it uses a different operator somewhere.

This change should have no semantic impact.
2019-06-23 01:30:41 +02:00
Eduard-Mihai Burtescu
6688b03865 proc_macro: stop using LEB128 for RPC. 2019-04-09 21:05:15 +03:00
Josh Stone
0730a01c5c Use for_each to extend collections
This updates the `Extend` implementations to use `for_each` for many
collections: `BinaryHeap`, `BTreeMap`, `BTreeSet`, `LinkedList`, `Path`,
`TokenStream`, `VecDeque`, and `Wtf8Buf`.

Folding with `for_each` enables better performance than a `for`-loop for
some iterators, especially if they can just forward to internal
iterators, like `Chain` and `FlatMap` do.
2019-04-05 14:51:07 -07:00
bors
c5fb4d0d2f Auto merge of #55780 - ogoffart:span_source_text, r=petrochenkov
Introduce proc_macro::Span::source_text

A function to extract the actual source behind a Span.

Background: I would like to use `syn` in a `build.rs` script to parse the rust code, and extract part of the source code. However, `syn` only gives access to proc_macro2::Span, and i would like to get the source code behind that.
I opened an issue on proc_macro2 bug tracker for this feature https://github.com/alexcrichton/proc-macro2/issues/110  and @alexcrichton said the feature should first go upstream in proc_macro.  So there it is!

Since most of the Span API is unstable anyway, this is guarded by the same `proc_macro_span` feature as everything else.
2019-03-27 08:58:40 +00:00
Taiki Endo
871910a2c6 Use ? in some macros 2019-02-24 21:59:44 +09:00
Mazdak Farrokhzad
aa896f30bb
Rollup merge of #57856 - lzutao:fix-old-first-edition, r=steveklabnik
Convert old first edition links to current edition one

r? @steveklabnik
2019-02-14 02:41:16 +01:00
Lzu Tao
e7f8e63ed4 Convert old doc links to current edition
Use footnote style to bypass the tidy check
2019-02-13 14:39:25 +00:00
bors
b244f61b77 Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnik
Cosmetic improvements to doc comments

This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase).

r? @steveklabnik

Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-12 19:09:24 +00:00
Alexander Regueiro
b87363e763 tests: doc comments 2019-02-10 23:42:32 +00:00
Taiki Endo
2be0993c4e Revert removed #![feature(nll)] 2019-02-10 16:13:30 +09:00
Guillaume Gomez
8b886e07f5 Remove images' url to make it work even without internet connection 2019-02-07 11:06:19 +01:00
Taiki Endo
18da195bab libproc_macro => 2018 2019-02-04 03:55:40 +09:00
Alexander Regueiro
edabad64b0 Work-around for shadowing of variant names with assoc const names in libproc_macro/bridge/rpc.rs. 2018-12-26 21:40:21 +00:00
Alexander Regueiro
1b150c4043 Store Ident rather than just Name in HIR types Item and ForeignItem. 2018-12-26 21:26:37 +00:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Vadim Petrochenkov
8a8ef260be proc_macro: Validate tokens coming from the compiler again 2018-12-19 23:17:53 +03:00
Alexander Regueiro
ee89c088b0 Various minor/cosmetic improvements to code 2018-12-07 23:53:34 +00:00
Olivier Goffart
e88b0d9a94 Introduce proc_macro::Span::source_text 2018-12-01 09:02:11 +01:00
Eduard-Mihai Burtescu
188d2dafcd Statically link proc_macro into proc macros. 2018-11-30 06:15:20 +02:00
Eduard-Mihai Burtescu
8cf463bcff proc_macro: move the rustc server to syntax_ext. 2018-11-30 06:15:19 +02:00
Eduard-Mihai Burtescu
38fee305da proc_macro: remove the __internal module. 2018-11-30 06:15:19 +02:00
Eduard-Mihai Burtescu
e305994beb proc_macro: introduce a "bridge" between clients (proc macros) and servers (compiler front-ends). 2018-11-30 06:15:19 +02:00
Sergio Benitez
09e7051b7e Add unstable Literal::subspan(). 2018-11-20 21:17:20 -08:00
Andy Russell
4e35cbb22e
fix various typos in doc comments 2018-11-13 14:45:31 -05:00
Alex Crichton
526ca7ce79 All proc_macro_span APIs tracked at #54725 now 2018-10-01 12:15:35 -07:00
Alex Crichton
7662523492 Span::def_site() is now at #54724 2018-10-01 12:15:35 -07:00
Alex Crichton
3ced475360 The proc_macro_raw_ident feature is now at #54723 2018-10-01 12:15:35 -07:00
Alex Crichton
b871293cfd The proc_macro_quote feature now lives at #54722 2018-10-01 12:15:35 -07:00
Josh Stone
ce034951fb Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
Sergio Benitez
adc2c04543 Make 'proc_macro::MultiSpan' public. 2018-09-19 19:22:21 -07:00
Sergio Benitez
10bb5edb19 Add multispan support to proc-macro diagnostics.
Also updates the issue number for 'proc_macro_diagnostic'.
2018-09-13 01:19:48 -07:00
Sergio Benitez
50d869333b Add inspection and setter methods to proc_macro::Diagnostic. 2018-09-12 23:34:12 -07:00
bors
6810f5286b Auto merge of #53793 - toidiu:ak-stabalize, r=nikomatsakis
stabilize outlives requirements

https://github.com/rust-lang/rust/issues/44493

r? @nikomatsakis
2018-09-12 11:27:48 +00:00
toidiu
731f4efae5 stabalize infer outlives requirements (RFC 2093).
Co-authored-by: nikomatsakis
2018-09-11 11:40:04 -04:00
David Tolnay
7acd4b12da
Remove documentation about proc_macro being bare-bones 2018-09-09 09:56:14 -07:00
David Tolnay
a1dd39e724
Track distinct spans for open and close delimiter 2018-09-08 19:01:48 -07:00
David Tolnay
c5a561c0ab
proc_macro::Group::span_open and span_close
Before this addition, every delimited group like (...) [...] {...} has
only a single Span that covers the full source location from opening
delimiter to closing delimiter. This makes it impossible for a
procedural macro to trigger an error pointing to just the opening or
closing delimiter. The Rust compiler does not seem to have the same
limitation:

    mod m {
        type T =
    }

    error: expected type, found `}`
     --> src/main.rs:3:1
      |
    3 | }
      | ^

On that same input, a procedural macro would be forced to trigger the
error on the last token inside the block, on the entire block, or on the
next token after the block, none of which is really what you want for an
error like above.

This commit adds group.span_open() and group.span_close() which access
the Span associated with just the opening delimiter and just the closing
delimiter of the group. Relevant to Syn as we implement real error
messages for when parsing fails in a procedural macro.
2018-09-02 14:34:45 -07:00
Niko Matsakis
73fb1622b3 check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
kennytm
b5519db323
Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkor
Fix typos found by codespell.
2018-08-21 17:51:49 +08:00
Donato Sciarra
6138c82803 fix tidy errors 2018-08-19 23:01:01 +02:00
Donato Sciarra
d3fe97f3d3 mv codemap() source_map() 2018-08-19 23:01:01 +02:00
Donato Sciarra
cbd0595710 mv filemap source_file 2018-08-19 23:00:59 +02:00
Donato Sciarra
d6dcbcd4e1 mv FileMap SourceFile 2018-08-19 23:00:59 +02:00
Matthias Krüger
71120ef1e5 Fix typos found by codespell. 2018-08-19 17:41:28 +02:00
bors
b2028828db Auto merge of #53433 - kennytm:rollup, r=kennytm
Rollup of 10 pull requests

Successful merges:

 - #52946 (Documented impl From on line 367 of libserialize/json.rs)
 - #53234 (Remove Travis shutdown debug scripts, and remove CI-specific DNS settings)
 - #53313 (Two small improvements)
 - #53360 (Addressed #51602)
 - #53364 (Warn if the user tries to use GATs)
 - #53373 (Tweak unclosed delimiter parser error)
 - #53377 (std: Use target_pointer_width for BACKTRACE_ELF_SIZE)
 - #53395 (Use #[non_exhaustive] on internal enums)
 - #53399 (Tidy: ignore non-Markdown files when linting for the Unstable Book)
 - #53412 (syntax_ext: remove leftover span_err_if_not_stage0 macro.)
2018-08-16 17:53:29 +00:00
bors
b5590423e6 Auto merge of #53304 - dtolnay:extend, r=dtolnay
TokenStream::extend

Two new insta-stable impls in libproc_macro:

```rust
impl Extend<TokenTree> for TokenStream
impl Extend<TokenStream> for TokenStream
```

`proc_macro::TokenStream` already implements `FromIterator<TokenTree>` and `FromIterator<TokenStream>` so I elected to support the same input types for `Extend`.

**This commit reduces compile time of Serde derives by 60% (takes less than half as long to compile)** as measured by building our test suite:

```console
$ git clone https://github.com/serde-rs/serde
$ cd serde/test_suite
$ cargo check --tests --features proc-macro2/nightly
$ rm -f ../target/debug/deps/libtest_*.rmeta
$ time cargo check --tests --features proc-macro2/nightly
Before: 20.8 seconds
After: 8.6 seconds
```

r? @alexcrichton
2018-08-16 15:44:30 +00:00