Commit Graph

53340 Commits

Author SHA1 Message Date
Niko Matsakis
41a652e094 WIP factor out RudimentaryEmitter 2016-05-02 11:49:24 -04:00
Niko Matsakis
489a6c95bf replace fileline_{help,note} with {help,note}
The extra filename and line was mainly there to keep the indentation
relative to the main snippet; now that this doesn't include
filename/line-number as a prefix, it is distracted.
2016-05-02 11:49:23 -04:00
Niko Matsakis
1ff1887cc9 thread tighter span for closures around
Track the span corresponding to the `|...|` part of the closure.
2016-05-02 11:47:10 -04:00
Niko Matsakis
e416518e68 update test cases to reflect new messages 2016-05-02 11:47:10 -04:00
Niko Matsakis
d9a947ce8f use new note_expected_found API
This API pulls the "expected type foo, found type bar" out after the
main snippet. There are some other places where it makes sense, but this
is a start.
2016-05-02 11:47:10 -04:00
Niko Matsakis
11dc974a38 refactor to use new snippet code and model
Major changes:
- Remove old snippet rendering code and use the new stuff.
- Introduce `span_label` method to add a label
- Remove EndSpan mode and replace with a fn to get the last
  character of a span.
- Stop using `Option<MultiSpan>` and just use an empty `MultiSpan`
- and probably a bunch of other stuff :)
2016-05-02 11:47:10 -04:00
Niko Matsakis
5b150cf0ca add borrowck info inline in main snippet
This uses the new `span_label` APIs
2016-05-02 11:47:10 -04:00
Niko Matsakis
e7c7a18d94 adapt JSON to new model
Each Span now carries a `is_primary` boolean along with an optional
label. If there are multiple labels for a span, it will appear multiple
times.
2016-05-02 11:47:10 -04:00
Niko Matsakis
a20ee76b56 revamp MultiSpan and introduce new snippet code
MultiSpan model is now:

- set of primary spans
- set of span+label pairs

Primary spans render with `^^^`, secondary spans with `---`.

Labels are placed next to the `^^^` or `---` marker as appropriate.
2016-05-02 11:47:09 -04:00
Ryman
9fe3c065b0 libstd: correct the link to functions in io module documentation
Currently the link refers to it's own section of the documentation rather than the list of functions generated by rustdoc.
2016-05-02 15:54:54 +01:00
Georg Brandl
6fed0132f3 middle: reset loop labels while visiting closure
This should fix #31754 and follow-up #25343.  Before the latter, the
closure was visited twice in the context of the enclosing fn, which
made even a single closure with a loop label emit a warning.

With this change, the closure is still visited within the context
of the main fn (which is intended, since it is not a separate item)
but resets the found loop labels while being visited.

Fixes: #31754
2016-05-02 16:48:36 +02:00
Oliver Schneider
ce6ea47d43 refactor infer function
There was no span available in the cast function, but we need to infer the `x` in `x as char` to `u8`.
The spans are now removed from all functions using `infer` and instead added in `eval_const_expr_partial`
2016-05-02 16:40:40 +02:00
Oliver Schneider
f080b13c6b tests 2016-05-02 16:38:49 +02:00
Oliver Schneider
10737a5a45 * as char assumes * to be of type u8 2016-05-02 16:38:33 +02:00
bors
0eb575c702 Auto merge of #33303 - Aatch:mir-coercion-cast, r=arielb1
[MIR] Handle coercion casts properly when building the MIR

Coercion casts (`expr as T` where the type of `expr` can be coerced to
`T`) are essentially no-ops, as the actual work is done by a coercion.
Previously a check for type equality was used to avoid emitting the
redundant cast in the MIR, but this failed for coercion casts of
function items that had lifetime parameters. The MIR trans code doesn't
handle `FnPtr -> FnPtr` casts and produced an error.

Also fixes a bug with type ascription expressions not having any
adjustments applied.

Fixes #33295

/cc @eddyb
2016-05-02 06:58:11 -07:00
Georg Brandl
98d991fac5 parser: change warning into an error on T<A=B, C>
Fixes: #32214
2016-05-02 15:10:28 +02:00
bors
e1a575cb07 Auto merge of #33289 - birkenfeld:chain-find, r=bluss
Implement find() on Chain iterators

This results in a roughly 2x speedup compared to the default impl
"inherited" from Iterator.

Benchmark: https://gist.github.com/birkenfeld/aa9b92cb7d55666dd4821207527eaf5b
2016-05-02 04:46:58 -07:00
Georg Brandl
b75f81c9b3 parser: do not try to continue with unsafe on foreign fns
The changed line makes it look like `unsafe` is allowed, but the
first statement of `parse_item_foreign_fn` is:

`self.expect_keyword(keywords::Fn)?;`

So we get the strange "expected one of `fn`, `pub`, `static`, or
`unsafe`, found `unsafe`".

Fixes: #27361
2016-05-02 12:49:31 +02:00
bors
d3c2c71988 Auto merge of #33284 - nagisa:mir-fix-constfn-pats, r=alexcrichton
Fix patterns of the constants that are const methods
2016-05-02 02:33:33 -07:00
Oliver Schneider
bf51eafbef check for wrong const_err warnings 2016-05-02 11:26:29 +02:00
Oliver Schneider
12c4a1951e remove unused constant error variants 2016-05-02 11:02:44 +02:00
Taylor Cramer
38c8836051 docs: Changed docs for size_of to describe size as a stride offset
Current description of `std::mem::size_of` is ambiguous, and the
`std::intrinsics::size_of` description incorrectly defines size
as the number of bytes necessary to exactly overwrite a value,
not including the padding between elements necessary in a vector
or structure.
2016-05-01 23:38:01 -07:00
Georg Brandl
9e2300015b lexer: do not display char confusingly in error message
Current code leads to messages like "... use a \xHH escape: \u{e4}"
which is confusing.

The printed span already points to the offending character, which
should be enough to identify the non-ASCII problem.

Fixes: #29088
2016-05-02 07:45:57 +02:00
Tomoki Aonuma
ee7a68d48b Fix minor typo in E0038 2016-05-02 14:20:51 +09:00
Georg Brandl
eba43fb5c3 std::thread docs: spawn() returns not a Thread anymore
Also move the "Thread type" section down a bit, since it is
not so important anymore.

Fixes: #33321
2016-05-02 06:17:51 +02:00
Georg Brandl
d20b4067fd diagnostics for E0432: imports are relative to crate root
This is curiously missing from both the short message and this
long diagnostic.

Refs #31573 (not sure if it should be considered "fixed" as the
short message still only refers to extern crates).
2016-05-02 06:14:09 +02:00
Georg Brandl
0e89f55982 E0269: add suggestion to check for trailing semicolons
In situations where the value of the last expression must be inferred,
rustc will not emit the "you might need to remove the semicolon" warning,
so at least note this in the extended description.

Fixes: #30497
2016-05-02 06:10:10 +02:00
Michael Woerister
42303536c2 debuginfo: Fix regression in namespace handling for struct types. 2016-05-01 23:45:33 -04:00
bors
700d3e2374 Auto merge of #33190 - jseyfried:improve_diagnostics, r=nrc
resolve: improve diagnostics and lay groundwork for resolving before ast->hir

This PR improves diagnostics in `resolve` and lays some groundwork for resolving before ast->hir.

More specifically,
 - It removes an API in `resolve` intended for external refactoring tools (see #27493) that appears not to be in active use. The API is incompatible with resolving before ast->hir, but could be rewritten in a more compatible and less intrusive way.
 - It improves the diagnostics for pattern bindings that conflict with `const`s.
 - It improves the diagnostics for modules used as expressions (fixes #33186).
 - It refactors away some uses of the hir map, which is unavavailable before ast->hir lowering.

r? @eddyb
2016-05-01 20:39:33 -07:00
bors
855fb61922 Auto merge of #33296 - jseyfried:non_idempotent_lowering, r=nrc
Remove the requirement that ast->hir lowering be reproducible

This PR changes the ast->hir lowerer to be non-reproducible, and it removes the lowering context's id cache.

If the `hir` of an `ast` node needs to be reproduced, we can use the hir map instead of the lowerer -- for example, `tcx.map.expect_expr(expr.id)` instead of `lower_expr(lcx, expr)`.

r? @nrc
2016-05-01 18:28:24 -07:00
Jeffrey Seyfried
ef69ef81e3 Remove outdated comment 2016-05-02 00:43:02 +00:00
Jeffrey Seyfried
522b6ed8a7 Avoid keeping MTWT tables for save-analysis 2016-05-02 00:19:22 +00:00
Jeffrey Seyfried
298a1c056f Cleanup formatting 2016-05-02 00:19:19 +00:00
Jeffrey Seyfried
b8dc2a7c76 Remove the lowering context's id caching system 2016-05-01 23:49:12 +00:00
Jeffrey Seyfried
ca88c44a90 Avoid using the lowering context in librustc_save_analysis 2016-05-01 23:30:18 +00:00
Jeffrey Seyfried
02df9f32b1 Remove idempotent lowering test 2016-05-01 23:30:14 +00:00
bors
adda14a033 Auto merge of #33298 - drbo:patch-1, r=alexcrichton
Note that later versions of G++ are okay

G++ 4.7 is the minimum requirement, but later versions are also okay.
2016-05-01 16:17:29 -07:00
Georg Brandl
ffba7b7254 typeck: remove confusing suggestion for calling a fn type
* It is not clear what a "base function" is.
* The suggestion just adds parens, so suggests calling without args.

The second point could be fixed with e.g. `(...)` instead of `()`,
but the preceding "note: X is a function, perhaps you wish to call it"
should already be clear enough.

Fixes: #31341
2016-05-01 22:24:39 +02:00
bors
a4b0481d1c Auto merge of #33317 - michaelwoerister:fix-partitioning-tests-race, r=alexcrichton
Fix a race condition caused by concurrently executed codegen unit tests.

This hopefully fixes issue #33315.

This short-term solution just makes sure that every test uses its own directory so they can't get into conflict with each other.

As a more long-term solution, I'd probably prefer to make the partitioning scheme specifiable via `-Ccodegen-units` (e.g. like `-Ccodegen-units=per-module`) so that we don't have to rely on `-Zincremental` in these test cases.

r? @alexcrichton
2016-05-01 12:59:25 -07:00
Georg Brandl
b51698ad60 match check: note "catchall" patterns in unreachable error
Caught as catchall patterns are:

* unconditional name bindings
* references to them
* tuple bindings with catchall elements

Fixes #31221.
2016-05-01 21:58:46 +02:00
Stephen Mather
018c595574 doc/book/getting-started.md: Removed references to creating a new executable from 'Converting to Cargo'. 2016-05-01 19:45:38 +01:00
Timothy McRoy
3f49920495 Add error explanation for E0501 2016-05-01 13:41:11 -05:00
Stephen Mather
538098c7a4 doc/book/getting-started.md: Corrected spelling of 'Internet'. 2016-05-01 19:15:33 +01:00
Michael Woerister
a4128e5950 Fix a race condition caused by concurrently executed codegen unit tests. 2016-05-01 13:53:39 -04:00
Georg Brandl
e3f13129b4 dep_graph: avoid panicking in thread when channel closed
On my system, when the processor is already loaded, and I try to
run the test suite, e.g. compile-fail/dep-graph-assoc-type-trans.rs
fails because of undecodable JSON.

Running the compiler manually, I can see that the dep graph thread
panics (and puts non-JSON on stderr) while `send`ing on `swap_out`,
presumably because the other end has already quit.  I think that in
this case, we can just gracefully exit the thread.
2016-05-01 19:33:58 +02:00
Georg Brandl
a36fb461ad parser: fix suppression of syntax errors in range RHS
Invalid expressions on the RHS were just swallowed without generating
an error.  The new code more closely mirrors the code for parsing
`..x` in the `parse_prefix_range_expr` method, where no cancel is done
either.

Fixes #33262.
2016-05-01 19:01:06 +02:00
Guillaume Gomez
47d9f49ebf Remove rust flags from doc block 2016-05-01 18:13:36 +02:00
Oliver Middleton
e8cbcef86e Fix alloc_jemalloc on windows gnu targets
jemalloc prefixes the symbols by default on Windows so we need to account
for that to avoid link errors such as: `undefined reference to `mallocx'`
when using alloc_jemalloc.
2016-05-01 13:16:06 +01:00
Georg Brandl
41861691eb libsyntax/pp: replace manual ring buffer with a VecDeque 2016-05-01 12:26:34 +02:00
Georg Brandl
3eef0831cb libsyntax/pp: minor modernizations
* implement Display on Token instead of custom tok_str() fn
* use expression returns
* remove redundant parens in asserts
* remove "/* bad */" comments that appear to be related to early
  changes in memory management
* and a few individual idiomatic changes
2016-05-01 12:26:34 +02:00