67140 Commits

Author SHA1 Message Date
Alex Crichton
069a1b3c8f rustbuild: Tweak how we cross-compile LLVM
In preparation for upgrading to LLVM 5.0 it looks like we need to tweak how we
cross compile LLVM slightly. It's using `CMAKE_SYSTEM_NAME` to infer whether to
build libFuzzer which only works on some platforms, and then once we configure
that it needs to apparently reach into the host build area to try to compile
`llvm-config` as well. Once these are both configured, though, it looks like we
can successfully cross-compile LLVM.
2017-07-28 12:20:47 -07:00
bors
126321e2e5 Auto merge of #43230 - alexcrichton:more-tokenstream, r=nrc,jseyfried
Implement tokenization for some items in proc_macro

This PR is a partial implementation of https://github.com/rust-lang/rust/issues/43081 targeted towards preserving span information in attribute-like procedural macros. Currently all attribute-like macros will lose span information with the input token stream if it's iterated over due to the inability of the compiler to losslessly tokenize an AST node. This PR takes a strategy of saving off a list of tokens in particular AST nodes to return a lossless tokenized version. There's a few limitations with this PR, however, so the old fallback remains in place.
2017-07-28 18:31:52 +00:00
Alex Crichton
4886ec8665 syntax: Capture a TokenStream when parsing items
This is then later used by `proc_macro` to generate a new
`proc_macro::TokenTree` which preserves span information. Unfortunately this
isn't a bullet-proof approach as it doesn't handle the case when there's still
other attributes on the item, especially inner attributes.

Despite this the intention here is to solve the primary use case for procedural
attributes, attached to functions as outer attributes, likely bare. In this
situation we should be able to now yield a lossless stream of tokens to preserve
span information.
2017-07-28 10:47:01 -07:00
bors
eba9d7f08c Auto merge of #43298 - gaurikholkar:lifetime_errors, r=estebank
improve case with both anonymous lifetime parameters #43269

This is a fix to #43269.

Sample output message-

```

error[E0623]: lifetime mismatch
  --> $DIR/ex3-both-anon-regions.rs:12:12
   |
11 | fn foo(x: &mut Vec<&u8>, y: &u8) {
   |                    ---      --- these references must have the same lifetime
12 |     x.push(y);
   |            ^ data from `y` flows into `x` here

error: aborting due to 2 previous errors

```
r? @nikomatsakis
2017-07-28 16:03:32 +00:00
topecongiro
6375b77ebb Add Span to ast::WhereClause 2017-07-29 00:43:35 +09:00
Alex Crichton
036300aadd Add a failing test for errors in proc macros
This test currently fails because the tokenization of an AST item during the
expansion of a procedural macro attribute rounds-trips through strings, losing
span information.
2017-07-28 07:58:20 -07:00
Alex Crichton
36f2816a1e proc_macro: Use an item's tokens if available
This partly resolves the `FIXME` located in `src/libproc_macro/lib.rs` when
interpreting interpolated tokens. All instances of `ast::Item` which have a list
of tokens attached to them now use that list of tokens to losslessly get
converted into a `TokenTree` instead of going through stringification and losing
span information.

cc #43081
2017-07-28 07:58:20 -07:00
Alex Crichton
9b2f7624ec syntax: Add tokens: Option<TokenStream> to Item
This commit adds a new field to the `Item` AST node in libsyntax to optionally
contain the original token stream that the item itself was parsed from. This is
currently `None` everywhere but is intended for use later with procedural
macros.
2017-07-28 07:58:20 -07:00
Luca Barbato
c4710203c0 Make LLVMRustHasFeature more robust
The function should accept feature strings that old LLVM might not
support.

Simplify the code using the same approach used by
LLVMRustPrintTargetFeatures.

Dummify the function for non 4.0 LLVM and update the tests accordingly.
2017-07-28 14:30:06 +00:00
John Kåre Alsaker
416096d0fd Update comment 2017-07-28 15:47:55 +02:00
Alex Crichton
ff996853fe Fix more tests with GeneratorState rename 2017-07-28 15:47:55 +02:00
John Kåre Alsaker
be0a9b8958 Fix tests 2017-07-28 15:47:55 +02:00
John Kåre Alsaker
ae1856cb9e Update rename State in docs 2017-07-28 15:47:55 +02:00
John Kåre Alsaker
93b9b1a2b1 Fix tests 2017-07-28 15:47:55 +02:00
John Kåre Alsaker
9556faca68 Fix error message string 2017-07-28 15:47:55 +02:00
John Kåre Alsaker
0f8897cc35 Fix error code 2017-07-28 15:47:55 +02:00
John Kåre Alsaker
9a6a8668ae Remove visit_body from YieldFinder 2017-07-28 15:47:14 +02:00
John Kåre Alsaker
5da9a8aa19 Rename some variables in lowering.rs and add an error number for the error 2017-07-28 15:47:14 +02:00
John Kåre Alsaker
df0496a620 Rename State to GeneratorState 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
62e210fb3c Derive traits for State. 2017-07-28 15:46:27 +02:00
Niko Matsakis
39478e8ab1 update references due to removing tabs 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
d32428bc5f Remove tabs 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
b2d931abbb Fix error message tests again 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
6106f6c5c1 Fix error message tests 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
0a8b81a568 Ignore drop check bools when testing for legal generator types 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
4628f8534f Fix error message tests 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
f5ec50358a Fix tidy errors 2017-07-28 15:46:27 +02:00
Niko Matsakis
3fdc3fa1ec change how we report err_out_of_scope borrowck errors
Also, remove the explicit code detecting borrows over a yield.  It
turns out not to be necessary -- any such borrow winds up with a
lifetime that is part of the generator type, and therefore which will
outlive the generator expression itself, which yields an
`err_out_of_scope`. So instead we intercept those errors and display
them in a nicer way.
2017-07-28 15:46:27 +02:00
Niko Matsakis
188cdf499f combine bckerr_to_diag and note_and_explain_bckerr 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
5a6e0694da Remove a FIXME and apply the same hack as closures 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
14c747678e Fix a string literal 2017-07-28 15:46:27 +02:00
John Kåre Alsaker
e4fdbcbc9f Update FIXME 2017-07-28 15:46:26 +02:00
John Kåre Alsaker
b744b1cfe3 Convert to spaces 2017-07-28 15:46:26 +02:00
John Kåre Alsaker
cbdb18650e Add some comments 2017-07-28 15:46:26 +02:00
John Kåre Alsaker
eea290d7fd Convert to spaces 2017-07-28 15:46:26 +02:00
Alex Crichton
09a5d319ab Remove support for gen arg 2017-07-28 15:46:26 +02:00
John Kåre Alsaker
93172045c8 Fix a bug with yielding subtypes of the yield type. 2017-07-28 15:46:25 +02:00
John Kåre Alsaker
dcddd80729 Remove debug code 2017-07-28 15:46:25 +02:00
John Kåre Alsaker
a602fc06bd Revert some whitespace changes 2017-07-28 15:46:25 +02:00
John Kåre Alsaker
10def9a6e0 Revert borrowck changes 2017-07-28 15:46:25 +02:00
John Kåre Alsaker
2ad0f89e86 Tweak docs 2017-07-28 15:46:25 +02:00
Niko Matsakis
d71fa9371c fix yields-in-args test and add a reverse one 2017-07-28 15:46:25 +02:00
Niko Matsakis
264c3f4952 add some tests of yielding with outstanding borrows
No doubt there are more tests one might write, but it's a start.
2017-07-28 15:46:25 +02:00
Alex Crichton
8e82b19c6b Convert tabs to spaces 2017-07-28 15:46:25 +02:00
Alex Crichton
12bbcd3c29 Add a test case for conditional drop 2017-07-28 15:46:25 +02:00
John Kåre Alsaker
77bf6e4461 Add a test 2017-07-28 15:46:25 +02:00
Alex Crichton
7eae8489fc Touch up unstable docs for generators 2017-07-28 15:46:25 +02:00
John Kåre Alsaker
6e66dccc44 Remove a FIXME 2017-07-28 15:46:24 +02:00
John Kåre Alsaker
05fcef0b3e Fix printing 2017-07-28 15:46:24 +02:00
John Kåre Alsaker
21f2d259e0 Consider StorageDead and StorageLive as gens for liveness analysis 2017-07-28 15:46:24 +02:00