Commit Graph

56979 Commits

Author SHA1 Message Date
Vanja Cosic
172d321f9f Updated "Getting started". Trying to fix #34523
- Updated paragraphs and wording for clarity.
- Renamed `helloworld.rs` to `myprogram.rs` to make it clearer that it's an unrelated example.
2016-09-18 14:16:42 +02:00
bors
f39039e6e5 Auto merge of #36527 - nnethercote:last_token_kind, r=jseyfried
Optimize the parser's last token handling.

The parser currently makes a heap copy of the last token in four cases:
identifiers, paths, doc comments, and commas. The identifier and
interpolation cases are unused, and for doc comments and commas we only
need to record their presence, not their value.

This commit consolidates the last token handling and avoids the
unnecessary copies by replacing `last_token`, `last_token_eof`, and
`last_token_interpolated` with a new field `last_token_kind`. This
simplifies the parser slightly and speeds up parsing on some files by
3--4%.
2016-09-18 00:48:51 -07:00
bors
0b03ba1f55 Auto merge of #36502 - TimNN:correct-cancel, r=jseyfried
correctly cancel some errors

Fixes #36499.

I also (proactively) changed all other calls in `parser.rs` to use `Handler::cancel`.
2016-09-17 20:57:05 -07:00
bors
d37e54b419 Auto merge of #36504 - pcwalton:and-star, r=eddyb
librustc_mir: Remove `&*x` when `x` has a reference type.

This introduces a new `InstCombine` pass for us to place such peephole
optimizations.

r? @eddyb
2016-09-17 17:30:22 -07:00
bors
32571c05c8 Auto merge of #36508 - nagisa:llvm-backport, r=eddyb
Up the LLVM

Fixes #36474

The relevant patch to rust-llvm is at https://github.com/rust-lang/llvm/pull/51

r? @alexcrichton
2016-09-17 12:02:34 -07:00
Simonas Kazlauskas
d104e5bfb7 Up the LLVM
Fixes #36474
2016-09-17 18:40:40 +03:00
bors
fb62f4d544 Auto merge of #36490 - bluss:zip-slightly-despecialized-edition, r=alexcrichton
Remove data structure specialization for .zip() iterator

Go back on half the specialization, the part that changed the Zip
struct's fields themselves depending on the types of the iterators.

Previous PR: #33090

This means that the Zip iterator will always carry two usize fields,
which are sometimes unused. If a whole for loop using a .zip() iterator is
inlined, these are simply removed and have no effect.

The same improvement for Zip of for example slice iterators remain, and
they still optimize well. However, like when the specialization of zip
was merged, the compiler is still very sensistive to the exact context.

For example this code only autovectorizes if the function is used, not
if the code in zip_sum_i32 is inserted inline where it was called:

```rust
fn zip_sum_i32(xs: &[i32], ys: &[i32]) -> i32 {
    let mut s = 0;
    for (&x, &y) in xs.iter().zip(ys) {
        s += x * y;
    }
    s
}

fn zipdot_i32_default_zip(b: &mut test::Bencher)
{
    let xs = vec![1; 1024];
    let ys = vec![1; 1024];

    b.iter(|| {
        zip_sum_i32(&xs, &ys)
    })
}
```

Include a test that checks that `Zip<T, U>` is covariant w.r.t. T and U.

Fixes #35727
2016-09-17 08:23:44 -07:00
bors
cde61ba7f7 Auto merge of #36485 - nnethercote:char_lit-2, r=nagisa
Overhaul char_lit()

This commit does the following.

- Removes parsing support for '\X12', '\u123456' and '\U12345678' char
  literals. These are no longer valid Rust and rejected by the lexer.
  (This strange-sounding situation occurs because the parser rescans
  char literals to compute their value.)

- Rearranges the function so that all the escaped values are handled in
  a single `match`. The error-handling strategy is based on the one used
  by byte_lit().
2016-09-17 02:51:13 -07:00
bors
141012dd52 Auto merge of #36482 - jseyfried:dont_load_unconfigured_noninline_modules, r=nrc
Avoid loading and parsing unconfigured non-inline modules.

For example, `#[cfg(any())] mod foo;` will always compile after this PR, even if `foo.rs` and `foo/mod.rs` do not exist or do not contain valid Rust.

Fixes #36478 and fixes #27873.

r? @nrc
2016-09-16 23:29:15 -07:00
bors
9dc9f340cc Auto merge of #36468 - michaelwoerister:collect-vtable-drop-glue, r=eddyb
trans: Let the collector find drop-glue for all vtables, not just VTableImpl.

This fixes #36260. So far, the collector has only recorded drop-glue for insertion into a vtable if the vtable was for an impl. But there's actually no reason why it shouldn't do just the same for closure vtables, afaict.

r? @eddyb
cc @rust-lang/compiler
2016-09-16 19:52:53 -07:00
bors
d4037fc476 Auto merge of #36444 - jseyfried:macro_rules_ext, r=nrc
Remove variant `MacroRulesTT` of `SyntaxExtension`

r? @nrc
2016-09-16 14:15:13 -07:00
bors
55a61a1175 Auto merge of #36536 - jonathandturner:rollup, r=jonathandturner
Rollup of 8 pull requests

- Successful merges: #36383, #36424, #36480, #36484, #36505, #36509, #36519, #36521
- Failed merges:
2016-09-16 10:45:35 -07:00
Patrick Walton
e8a44d29b6 librustc_mir: Remove &*x when x has a reference type.
This introduces a new `InstCombine` pass for us to place such peephole
optimizations.
2016-09-16 09:30:51 -07:00
Jonathan Turner
ab7425dcd4 Rollup merge of #36521 - Mark-Simulacrum:documentation-fix, r=apasel422
Fix language in documentation comment.
2016-09-16 09:29:49 -07:00
Jonathan Turner
919cbc0168 Rollup merge of #36519 - Mark-Simulacrum:example-asmut, r=GuillaumeGomez
Add example in AsMut trait documentation

Let me know of any changes I should make.

r? @GuillaumeGomez
2016-09-16 09:29:49 -07:00
Jonathan Turner
c6f1db6f60 Rollup merge of #36509 - nagisa:rustbuild-py3, r=alexcrichton
Try to support py3 with rustbuild better

Annoying to have it fail when you run with `python` only to have to rerun later with `python2`.

r? @alexcrichton
2016-09-16 09:29:49 -07:00
Jonathan Turner
390e8bd15d Rollup merge of #36505 - nagisa:temp-stack-size, r=eddyb
Default RUST_MIN_STACK to 16MiB for now

Temporary(?) workaround to https://github.com/rust-lang/rust/issues/35408.

cc @nikomatsakis if you want to veto the idea.

r? @eddyb
2016-09-16 09:29:48 -07:00
Jonathan Turner
ff224e7d8d Rollup merge of #36484 - frewsxcv:patch-33, r=eddyb
Don't ignore a doc code-block we can compile.
2016-09-16 09:29:48 -07:00
Jonathan Turner
77c7ff5b46 Rollup merge of #36480 - tshepang:stronger-pause, r=steveklabnik
doc: make that sound better
2016-09-16 09:29:48 -07:00
Jonathan Turner
d48f17b21e Rollup merge of #36424 - kmcallister:gh-29361-marker-docs, r=GuillaumeGomez
Tweak std::marker docs

Fixes #29361.

r? @GuillaumeGomez
2016-09-16 09:29:48 -07:00
Jonathan Turner
9eac7bdd09 Rollup merge of #36383 - GuillaumeGomez:e0049, r=jonathandturner
Update E0049 to new error format

Fixes #35210.
Part of #35233.

r? @jonathandturner
2016-09-16 09:29:48 -07:00
bors
c6673db58d Auto merge of #36353 - arielb1:union-drops, r=pnkfelix
a few move-checker improvements

This fixes moves out of unions and prohibits moves out of slices (see the individual commits).

r? @pnkfelix
2016-09-16 07:23:18 -07:00
Ariel Ben-Yehuda
5c5f75223c fix test fallout 2016-09-16 16:02:43 +03:00
Ariel Ben-Yehuda
eeedc144be fix dynamic drop for unions
Moving out of a union is now treated like moving out of its parent type.

Fixes #36246
2016-09-16 15:08:32 +03:00
Ariel Ben-Yehuda
7b25e88602 forbid moves out of slices
The wording of RFC #495 enables moves out of slices. Unfortuantely, non-zeroing
moves out of slices introduce a very annoying complication: as slices can
vary in their length, indexes from the start and end may or may not overlap
depending on the slice's exact length, which prevents assigning a particular
drop flag for each individual element.

For example, in the code

```Rust
fn foo<T>(a: Box<[Box<[T]>]>, c: bool) -> T {
    match (a, c) {
        (box [box [t, ..], ..], true) => t,
        (box [.., box [.., t]], false) => t,
        _ => panic!()
    }
}
```

If the condition is false, we have to drop the first element
of `a`, unless `a` has size 1 in which case we drop all the elements
of it but the last.

If someone comes with a nice way of handling it, we can always re-allow
moves out of slices.

This is a [breaking-change], but it is behind the `slice_patterns` feature
gate and was not allowed until recently.
2016-09-16 15:08:32 +03:00
Ariel Ben-Yehuda
eb19cd6575 groundwork refactoring of gather_moves 2016-09-16 15:08:32 +03:00
bors
8394685b83 Auto merge of #36441 - alexcrichton:rustbuild-target, r=brson
rustbuild: Fix cross-compiles to MinGW on Linux

Closes #36290
Closes #36291
2016-09-16 04:01:01 -07:00
bors
89500e9341 Auto merge of #36338 - estebank:primitive-shadow, r=jseyfried
Be more specific when type parameter shadows primitive type

When a type parameter shadows a primitive type, the error message
was non obvious. For example, given the file `file.rs`:

```rust
trait Parser<T> {
    fn parse(text: &str) -> Option<T>;
}

impl<bool> Parser<bool> for bool {
    fn parse(text: &str) -> Option<bool> {
        Some(true)
    }
}

fn main() {
    println!("{}", bool::parse("ok").unwrap_or(false));
}
```

The output was:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool a
  |
  = note: expected type `bool`
  = note:    found type `bool`

error: aborting due to previous error
```

We now show extra information about the type:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool a
  |
  = note: expected type `bool` (type parameter)
  = note:    found type `bool` (bool)

error: aborting due to previous error
```

Fixes #35030
2016-09-16 00:39:27 -07:00
Nicholas Nethercote
8075d54606 Optimize the parser's last token handling.
The parser currently makes a heap copy of the last token in four cases:
identifiers, paths, doc comments, and commas. The identifier and
interpolation cases are unused, and for doc comments and commas we only
need to record their presence, not their value.

This commit consolidates the last token handling and avoids the
unnecessary copies by replacing `last_token`, `last_token_eof`, and
`last_token_interpolated` with a new field `last_token_kind`. This
simplifies the parser slightly and speeds up parsing on some files by
3--4%.
2016-09-16 15:46:40 +10:00
bors
a36e069288 Auto merge of #36213 - josephDunne:dist_version, r=brson
Add rustc version info (git hash + date) to dist tarball

a fix for #32444
2016-09-15 20:48:58 -07:00
Esteban Küber
68e8624d05 Specify when type parameter shadows primitive type
When a type parameter shadows a primitive type, the error message
was non obvious. For example, given the file `file.rs`:

```rust
trait Parser<T> {
    fn parse(text: &str) -> Option<T>;
}

impl<bool> Parser<bool> for bool {
    fn parse(text: &str) -> Option<bool> {
        Some(true)
    }
}

fn main() {
    println!("{}", bool::parse("ok").unwrap_or(false));
}
```

The output was:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool
  |
  = note: expected type `bool`
  = note:    found type `bool`

error: aborting due to previous error
```

We now show extra information about the type:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool
  |
  = note: expected type `bool` (type parameter)
  = note:    found type `bool` (bool)

error: aborting due to previous error
```

Fixes #35030
2016-09-15 20:06:29 -07:00
Mark-Simulacrum
102ee5e70a Add example in AsMut trait documentation 2016-09-15 19:47:04 -06:00
bors
5511a93c8a Auto merge of #36439 - alexcrichton:fix-rustbuild, r=japaric
rustbuild: Fix dependency tracking with new Cargo

The recent Cargo update changed filenames, which broke a lot of incremental
rustbuild builds. What it thought were the output files were indeed no longer
the output files! (wreaking havoc).

This commit updates this to stop guessing filenames of Cargo and just manage
stamp files instead.
2016-09-15 17:19:09 -07:00
Nicholas Nethercote
63ded0518a Overhaul char_lit().
This commit does the following.

- Removes parsing support for '\X12', '\u123456' and '\U12345678' char
  literals. These are no longer valid Rust and rejected by the lexer.
  (This strange-sounding situation occurs because the parser rescans
  char literals to compute their value.)

- Rearranges the function so that all the escaped values are handled in
  a single `match`, and changes the error-handling to use vanilla
  assert!() and unwrap().
2016-09-16 09:13:43 +10:00
Simonas Kazlauskas
3f79310174 Try to support py3 with rustbuild better 2016-09-16 01:52:26 +03:00
Jeffrey Seyfried
f9a08cc982 Remove irrelevant test. 2016-09-15 21:17:21 +00:00
Jeffrey Seyfried
2abdc8805c Remove MacroRulesTT. 2016-09-15 21:16:51 +00:00
Jeffrey Seyfried
0ddb66c4c7 Allow IdentMacroExpander::expand to access the ident macro invocation's attributes. 2016-09-15 20:57:54 +00:00
Jeffrey Seyfried
21ba8160f2 Move fields single_step and keep_macs from MacroExpander to ExpansionConfig. 2016-09-15 20:57:38 +00:00
Simonas Kazlauskas
ffaebadc99 Default RUST_MIN_STACK to 16MiB for now 2016-09-15 23:40:48 +03:00
bors
1265cbf4e0 Auto merge of #36393 - petrochenkov:ancient, r=eddyb
Remove some obsolete code from the compiler
2016-09-15 13:34:11 -07:00
Tim Neumann
9f4e908360 correctly cancel some errors 2016-09-15 22:12:22 +02:00
Keegan McAllister
b735c1bc78 Tweak std::marker docs
Fixes #29361.
2016-09-15 12:31:17 -07:00
bors
d1acabeaa2 Auto merge of #35992 - SimonSapin:rc-arc-ptr-eq, r=alexcrichton
Add `pub fn ptr_eq(this: &Self, other: &Self) -> bool` to Rc and Arc

Servo and Kuchiki have had helper functions doing this for some time.
2016-09-15 09:58:26 -07:00
Simon Sapin
5ce9feeb8c Add std::ptr::eq, for referential equality of &T references.
Fixes https://github.com/rust-lang/rfcs/issues/1155
2016-09-15 18:48:16 +02:00
Simon Sapin
eba2270a9c Add pub fn ptr_eq(this: &Self, other: &Self) -> bool to Rc and Arc.
Servo and Kuchiki have had helper functions doing this for some time.
2016-09-15 18:48:16 +02:00
bors
dc75933aba Auto merge of #36491 - Manishearth:rollup, r=Manishearth
Rollup of 9 pull requests

- Successful merges: #36384, #36405, #36425, #36429, #36438, #36454, #36459, #36461, #36463
- Failed merges: #36444
2016-09-15 06:14:26 -07:00
Manish Goregaokar
ec08128882 Rollup merge of #36463 - eugene-bulkin:duration-checked-ops, r=alexcrichton
Add checked operation methods to Duration

Addresses #35774.
2016-09-15 18:16:22 +05:30
Manish Goregaokar
0c9dc539df Rollup merge of #36461 - nikomatsakis:issue-36053, r=arielb1
clear obligations-added flag with nested fulfillcx

This flag is a debugging measure designed to detect cases where we start
a snapshot, create type variables, register obligations involving those
type variables in the fulfillment cx, and then have to unroll the
snapshot, leaving "dangling type variables" behind.  HOWEVER, in some
cases the flag is wrong. In particular, we sometimes create a
"mini-fulfilment-cx" in which we enroll obligations. As long as this
fulfillment cx is fully drained before we return, this is not a problem,
as there won't be any escaping obligations in the main cx. So we add a
fn to save/restore the flag.

Fixes #36053.

r? @arielb1
2016-09-15 18:16:22 +05:30
Manish Goregaokar
959f764f8b Rollup merge of #36459 - nikomatsakis:issue-35546, r=eddyb
invoke drop glue with a ptr to (data, meta)

This is done by creating a little space on the stack. Hokey, but it's the simplest fix I can see, and I am in "kill regressions" mode right now.

Fixes #35546

r? @eddyb
2016-09-15 18:16:21 +05:30