Commit Graph

5097 Commits

Author SHA1 Message Date
Florian Hahn
2bc8f4ff80 Add interpolated_or_expr_span macro and pass lo to newly added parse_dot_suffix 2016-01-26 11:51:24 +01:00
Florian Hahn
1bde18d60c Use interpolated token span when building spans for bigger expressions 2016-01-26 10:32:58 +01:00
Florian Hahn
20edb366e7 Set span for interpolated tokens correctly 2016-01-26 10:32:58 +01:00
Florian Hahn
b285ebc48e Update expression span when transcribing macro args
closes #29084
closes #28308
closes #25385
closes #28288
closes #31011
closes #26480
closes #26093
closes #26094
closes #25386
closes #26237
closes #25793
2016-01-26 10:31:54 +01:00
bors
faf6d1e873 Auto merge of #31065 - nrc:ident-correct, r=pnkfelix
This PR adds some minor error correction to the parser - if there is a missing ident, we recover and carry on. It also makes compilation more robust so that non-fatal errors (which is still most of them, unfortunately) in parsing do not cause us to abort compilation. The effect is that a program with a missing or incorrect ident can get all the way to type checking.
2016-01-26 00:42:08 +00:00
Daniel Campbell
616bfb6f15 Extended save-analysis to support generated code, alterned some spans in format_args! and derive to maintain compatability 2016-01-22 19:12:51 +13:00
Nick Cameron
0ac8915875 The war on abort_if_errors 2016-01-22 08:19:27 +13:00
Nick Cameron
b1b6b33c6d Some basic error correction in the parser after a dot 2016-01-22 08:19:27 +13:00
Erick Tryzelaar
1dc7eb8853 syntax: Fix encoding and decoding spans
The protocol for `serialize::{En,De}code` doesn't allow for two
integers to be serialized next to each other. This switches the
protocol to serializing `Span`s as a struct. rbml structs don't
have any overhead, so the metadata shouldn't increase in size,
but it allows the json format to be properly generated, albeit
slightly more heavy than when it was just serializing a span as
a u64.

Closes #31025.

s
2016-01-20 10:04:31 -08:00
bors
077f4eeb84 Auto merge of #30567 - steffengy:master, r=alexcrichton
Add support to use functions exported using vectorcall.
This essentially only allows to pass a new LLVM calling convention
from rust to LLVM.

```rust
extern "vectorcall" fn abc(param: c_void);
```

references
----
http://llvm.org/docs/doxygen/html/CallingConv_8h_source.html
https://msdn.microsoft.com/en-us/library/dn375768.aspx
2016-01-16 23:30:30 +00:00
Manish Goregaokar
56cae9f507 Rollup merge of #30787 - nikomatsakis:future-incompatible-lint, r=brson
There is now more structure to the report, so that you can specify e.g. an RFC/PR/issue number and other explanatory details.

Example message:

```
type-parameter-invalid-lint.rs:14:8: 14:9 error: defaults for type parameters are only allowed on type definitions, like `struct` or `enum`
type-parameter-invalid-lint.rs:14 fn avg<T=i32>(_: T) {}
                                         ^
type-parameter-invalid-lint.rs:14:8: 14:9 warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
type-parameter-invalid-lint.rs:14:8: 14:9 note: for more information, see PR 30742 <https://github.com/rust-lang/rust/pull/30724>
type-parameter-invalid-lint.rs:11:9: 11:28 note: lint level defined here
type-parameter-invalid-lint.rs:11 #![deny(future_incompatible)]
                                          ^~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
```

r? @brson

I would really like feedback also on the specific messages!

Fixes #30746
2016-01-15 17:28:28 +05:30
bors
a70a60a02b Auto merge of #30763 - gchp:issue/30033, r=nagisa
This is achieved by adding the scan_back method. This method looks back
through the source_text of the StringReader until it finds the target
char, returning it's offset in the source. We use this method to find
the offset of the opening single quote, and use that offset as the start
of the error.

Given this code:

```rust
fn main() {
    let _ = 'abcd';
}
```

The compiler would give a message like:

```
error: character literal may only contain one codepoint: ';
let _ = 'abcd';
             ^~
```
With this change, the message now displays:

```
error: character literal may only contain one codepoint: 'abcd';
let _ = 'abcd';
        ^~~~~~~
```

Fixes #30033
2016-01-15 06:38:26 +00:00
Nick Cameron
11dcb48c6a Add a test
And fix bustage in make check
2016-01-15 10:24:12 +13:00
Nick Cameron
b976d9e666 Implement JSON error emission
[breaking-change]

syntax::errors::Handler::new has been renamed to with_tty_emitter

Many functions which used to take a syntax::errors::ColorConfig, now take a rustc::session::config::ErrorOutputType. If you previously used ColorConfig::Auto as a default, you should now use ErrorOutputType::default().
2016-01-15 10:24:12 +13:00
Nick Cameron
fd46c78f8f Add an --output option for specifying an error emitter 2016-01-15 10:24:12 +13:00
Nick Cameron
acfccc515b Add a JSON error emitter 2016-01-15 10:20:30 +13:00
Greg Chapple
acc9428c6a Display better snippet for invalid char literal
Given this code:

    fn main() {
        let _ = 'abcd';
    }

The compiler would give a message like:

    error: character literal may only contain one codepoint: ';
    let _ = 'abcd';
                 ^~

With this change, the message now displays:

    error: character literal may only contain one codepoint: 'abcd'
    let _ = 'abcd'
            ^~~~~~

Fixes #30033
2016-01-14 17:34:42 +00:00
bors
6089ebaddb Auto merge of #30813 - fhahn:fix-ice-semicolon-in-lifetime, r=nrc
This PR fixes an ICE due to an DiagnosticsBuilder not being canceld or emitted.

Ideally it would use `Handler::cancel`, but I did not manage to get a `&mut` reference to the diagnostics handler.
2016-01-13 20:38:12 +00:00
bors
d3c83fef24 Auto merge of #30684 - tshepang:rustfmt-lexer-part2, r=nrc 2016-01-13 12:22:51 +00:00
Niko Matsakis
0254f69d74 use fileline_ and not full span_ for the followon messages 2016-01-12 19:38:12 -05:00
Tshepang Lekhonkhobe
aa3b4c668e re-instate comment that was mysteriously disappeared 2016-01-12 21:00:09 +02:00
Niko Matsakis
259379426c Revamp the "future incompatible" section to clarify the situation
better
2016-01-12 12:53:55 -05:00
Steffen
8cdad627ae add feature gate "abi_vectorcall" for the vectorcall calling convention 2016-01-11 23:45:33 +01:00
Simonas Kazlauskas
6d6e831c33 Rollup merge of #30694 - pnkfelix:issue-25658-real-first-follow, r=nrc
Proper first and follow sets for macro_rules future proofing

implements first stage of RFC amendment 1384; see #30450
2016-01-11 21:17:52 +02:00
Oliver Schneider
bac3eec67c [breaking-change] remove negate_unsigned feature gate 2016-01-11 12:31:46 +01:00
Florian Hahn
e61d21fe3d Cancel parse_ty error in Parser::parse_generic_values_after_lt 2016-01-10 22:59:23 +01:00
Felix S. Klock II
3703ef5820 extending FOLLOW(NT) as specified in amendment.
See RFC amendment 1384:

  https://github.com/rust-lang/rfcs/pull/1384
2016-01-07 20:53:33 +01:00
Felix S. Klock II
076e64475a macro_rules: proper FIRST/FOLLOW computations for checking macro_rules validity.
See RFC amendment 1384 and tracking issue 30450:
  https://github.com/rust-lang/rfcs/pull/1384
  https://github.com/rust-lang/rust/issues/30450

Moved old check_matcher code into check_matcher_old

combined the two checks to enable a warning cycle (where we will
continue to error if the two checks agree to reject, accept if the new
check says accept, and warn if the old check accepts but the new check
rejects).
2016-01-07 20:53:33 +01:00
bors
440671751e Auto merge of #30723 - nrc:macro-err-bug, r=Manishearth
Fixes #30715
2016-01-07 04:44:14 +00:00
Steve Klabnik
d91518b9c4 Rollup merge of #30729 - huonw:delete-bad-comment, r=sanxiyn
The fundamental problem of duplication was fixed in https://github.com/rust-lang/rust/pull/10891, but the comment was preserved. Closes https://github.com/rust-lang/rust/issues/9762.
2016-01-06 18:31:58 -05:00
bors
5daa75373d Auto merge of #30654 - nrc:panictry, r=brson
The motivation (other than removing boilerplate) is that this is a baby step towards a parser with error recovery.

[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2016-01-06 20:30:55 +00:00
bors
e8c337b5ca Auto merge of #30532 - nikomatsakis:cross-item-dependencies, r=mw
This is roughly the same as my previous PR that created a dependency graph, but that:

1. The dependency graph is only optionally constructed, though this doesn't seem to make much of a difference in terms of overhead (see measurements below).
2. The dependency graph is simpler (I combined a lot of nodes).
3. The dependency graph debugging facilities are much better: you can now use `RUST_DEP_GRAPH_FILTER` to filter the dep graph to just the nodes you are interested in, which is super help.
4. The tests are somewhat more elaborate, including a few known bugs I need to fix in a second pass.

This is potentially a `[breaking-change]` for plugin authors. If you are poking about in tcx state or something like that, you probably want to add `let _ignore = tcx.dep_graph.in_ignore();`, which will cause your reads/writes to be ignored and not affect the dep-graph.

After this, or perhaps as an add-on to this PR in some cases, what I would like to do is the following:

- [x] Write-up a little guide to how to use this system, the debugging options available, and what the possible failure modes are.
- [ ] Introduce read-only and perhaps the `Meta` node
- [x] Replace "memoization tasks" with node from the map itself
- [ ] Fix the shortcomings, obviously! Notably, the HIR map needs to register reads, and there is some state that is not yet tracked. (Maybe as a separate PR.)
- [x] Refactor the dep-graph code so that the actual maintenance of the dep-graph occurs in a parallel thread, and the main thread simply throws things into a shared channel (probably a fixed-size channel). There is no reason for dep-graph construction to be on the main thread. (Maybe as a separate PR.)

Regarding performance: adding this tracking does add some overhead, approximately 2% in my measurements (I was comparing the build times for rustdoc). Interestingly, enabling or disabling tracking doesn't seem to do very much. I want to poke at this some more and gather a bit more data -- in some tests I've seen that 2% go away, but on others it comes back. It's not entirely clear to me if that 2% is truly due to constructing the dep-graph at all.

The next big step after this is write some code to dump the dep-graph to disk and reload it.

r? @michaelwoerister
2016-01-06 18:37:57 +00:00
Niko Matsakis
8b22ed8651 Add assert-dep-graph testing mechanism and tests 2016-01-05 21:05:51 -05:00
Huon Wilson
4ea84fc184 Remove irrelevant comment
The fundamental problem of duplication was fixed in https://github.com/rust-lang/rust/pull/10891, but the comment was preserved. Closes https://github.com/rust-lang/rust/issues/9762.
2016-01-06 12:28:34 +11:00
Nick Cameron
535282bcf5 Cancel an error before it panics
Fixes #30715
2016-01-06 09:56:32 +13:00
Tshepang Lekhonkhobe
249b5c0b4a address review comment 2016-01-04 21:35:06 +02:00
Guillaume Gomez
6e68cdfcc2 Add test for "malformed macro lhs" and change back span_bug to span_fatal 2016-01-04 01:13:57 +01:00
Tshepang Lekhonkhobe
4a1062873e fix "make tidy" failure 2016-01-03 11:20:06 +02:00
Tshepang Lekhonkhobe
f20a139981 run rustfmt on syntax::parse::lexer 2016-01-03 11:14:09 +02:00
James Mantooth
877d55c1e0 Grammar fixes 2016-01-02 01:26:22 -06:00
Simonas Kazlauskas
23d24ff667 Rollup merge of #30565 - michaelwoerister:opaque_encoder, r=brson
This PR changes the `emit_opaque` and `read_opaque` methods in the RBML library to use a space-efficient binary encoder that does not emit any tags and uses the LEB128 variable-length integer format for all numbers it emits.

The space savings are nice, albeit a bit underwhelming, especially for dynamic libraries where metadata is already compressed.

| RLIBs        |  NEW   |   OLD     |
|--------------|--------|-----------|
|libstd        | 8.8 MB |  10.5 MB  |
|libcore       |15.6 MB |   19.7 MB |
|libcollections| 3.7 MB |    4.8 MB |
|librustc      |34.0 MB |   37.8 MB |
|libsyntax     |28.3 MB |   32.1 MB |

| SOs           |     NEW   |    OLD |
|---------------|-----------|--------|
| libstd        |  4.8 MB   | 5.1 MB |
| librustc      |  8.6 MB   | 9.2 MB |
| libsyntax     |  7.8 MB   | 8.4 MB |

At least this should make up for the size increase caused recently by also storing MIR in crate metadata.

Can this be a breaking change for anyone?
cc @rust-lang/compiler
2015-12-31 18:52:20 +02:00
bors
f73c0a82ec Auto merge of #30598 - est31:macro_export_help_note, r=Manishearth
The current help message is too much about "normal" macros to be used
as general message. Keep it for normal macros, and add custom help and
error messages for macro definitions.
2015-12-31 06:16:12 +00:00
Nick Cameron
9023c659af Cut out a bunch of Result and panictry! boilerplate from libsyntax.
[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2015-12-31 14:29:02 +13:00
bors
2370d461a6 Auto merge of #30375 - aaronkeen:issue_28777, r=eddyb
RESTRICTION_STMT_EXPR restriction to allow subsequent expressions to
contain braces.

https://github.com/rust-lang/rust/issues/28777
2015-12-30 23:20:12 +00:00
est31
40a9481f87 Limit line length to below 100 chars 2015-12-30 16:27:55 +01:00
est31
f4eb44e4df whitespace after colon, not before 2015-12-30 16:23:49 +01:00
est31
66a12f504f Custom help message for people trying to make macro public
The current help message is too much about "normal" macros to be used
as general message. Keep it for normal macros, and add custom help and
error messages for macro definitions.
2015-12-30 16:23:49 +01:00
bors
85fb3b6fc0 Auto merge of #30526 - Ms2ger:PathParameters, r=brson 2015-12-30 14:19:08 +00:00
Nick Cameron
04d972906d Rebasing and review comments 2015-12-30 14:54:36 +13:00
Nick Cameron
aaa02b3ff9 Refactoring 2015-12-30 14:27:59 +13:00