]> git.lizzy.rs Git - rust.git/log
rust.git
8 years agoAuto merge of #30557 - sfackler:panic-propagate, r=aturon
bors [Thu, 7 Jan 2016 01:26:45 +0000 (01:26 +0000)]
Auto merge of #30557 - sfackler:panic-propagate, r=aturon

See rust-lang/rfcs#1413.

r? @alexcrichton

8 years agoAdd std::panic::propagate
Steven Fackler [Fri, 25 Dec 2015 19:00:40 +0000 (12:00 -0700)]
Add std::panic::propagate

8 years agoAuto merge of #30750 - steveklabnik:rollup, r=steveklabnik
bors [Wed, 6 Jan 2016 23:35:13 +0000 (23:35 +0000)]
Auto merge of #30750 - steveklabnik:rollup, r=steveklabnik

- Successful merges: #30683, #30698, #30699, #30700, #30716, #30720, #30727, #30729, #30735, #30749
- Failed merges:

8 years agoRollup merge of #30749 - andgra2:patch-1, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
Rollup merge of #30749 - andgra2:patch-1, r=steveklabnik

8 years agoRollup merge of #30735 - jonastepe:nomicon_vec_dealloc_pointer_type, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
Rollup merge of #30735 - jonastepe:nomicon_vec_dealloc_pointer_type, r=steveklabnik

heap::deallocate expects a *mut u8, but here a *mut T is given as the type of the argument. This would not compile. The final code is correct, however.

8 years agoRollup merge of #30729 - huonw:delete-bad-comment, r=sanxiyn
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
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.

8 years agoRollup merge of #30727 - tbu-:pr_doc_escaped_newline, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:58 +0000 (18:31 -0500)]
Rollup merge of #30727 - tbu-:pr_doc_escaped_newline, r=steveklabnik

Rust differs in that behavior from C: In C, the newline escapes are resolved
before anything else, and in Rust this depends on whether the backslash is
escaped itself.

A difference can be observed in the following two programs:

```c
int main()
{
printf("\\
n\n");
return 0;
}
```

```rust
fn main() {
println!("\\
n");
}
```

The first program prints two newlines, the second one prints a backslash, a
newline, the latin character n and a final newline.

8 years agoRollup merge of #30720 - BChip:patch-1, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30720 - BChip:patch-1, r=steveklabnik

Declare what LIFO stands for

8 years agoRollup merge of #30716 - kraai:fix-hexicdecimal, r=apasel422
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30716 - kraai:fix-hexicdecimal, r=apasel422

8 years agoRollup merge of #30700 - steveklabnik:gh28581, r=brson
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30700 - steveklabnik:gh28581, r=brson

Fixes #28581

8 years agoRollup merge of #30699 - steveklabnik:gh30254, r=apasel422
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30699 - steveklabnik:gh30254, r=apasel422

Fixes #30254

8 years agoRollup merge of #30698 - steveklabnik:gh29649, r=brson
Steve Klabnik [Wed, 6 Jan 2016 23:31:57 +0000 (18:31 -0500)]
Rollup merge of #30698 - steveklabnik:gh29649, r=brson

Fixes #29649

r? @retep998 @alexcrichton

8 years agoRollup merge of #30683 - LawrenceWoodman:patch-1, r=steveklabnik
Steve Klabnik [Wed, 6 Jan 2016 23:31:56 +0000 (18:31 -0500)]
Rollup merge of #30683 - LawrenceWoodman:patch-1, r=steveklabnik

I noticed the alignment was off in the error handling part of the book.  This was caused because two tabs had crept into the file.  I have changed these for spaces.

8 years agoFix error in example code
Anders Granlund [Wed, 6 Jan 2016 23:09:26 +0000 (00:09 +0100)]
Fix error in example code

8 years agoAuto merge of #30654 - nrc:panictry, r=brson
bors [Wed, 6 Jan 2016 20:30:55 +0000 (20:30 +0000)]
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!

8 years agoAuto merge of #30532 - nikomatsakis:cross-item-dependencies, r=mw
bors [Wed, 6 Jan 2016 18:37:57 +0000 (18:37 +0000)]
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

8 years agoFix dependency graph test cases to have correct commments and use -Z incr-comp
Niko Matsakis [Wed, 6 Jan 2016 16:29:00 +0000 (11:29 -0500)]
Fix dependency graph test cases to have correct commments and use -Z incr-comp

8 years agoFix tidy errors
Niko Matsakis [Wed, 6 Jan 2016 16:28:53 +0000 (11:28 -0500)]
Fix tidy errors

8 years agoUse `memoized` helper more often.
Niko Matsakis [Wed, 6 Jan 2016 15:16:58 +0000 (10:16 -0500)]
Use `memoized` helper more often.

8 years agoAuto merge of #30733 - ubsan:wrapping_op_assign, r=eddyb
bors [Wed, 6 Jan 2016 15:00:17 +0000 (15:00 +0000)]
Auto merge of #30733 - ubsan:wrapping_op_assign, r=eddyb

Fix a breaking change in #30523

While this does fix a breaking change, it is also, technically, a
[breaking-change] to go back to our original way

8 years agoFix numerous typos, renamings, and minor nits raised by mw.
Niko Matsakis [Wed, 6 Jan 2016 14:19:19 +0000 (09:19 -0500)]
Fix numerous typos, renamings, and minor nits raised by mw.

8 years agoAuto merge of #30481 - nagisa:mir-calls-2, r=nikomatsakis
bors [Wed, 6 Jan 2016 13:11:18 +0000 (13:11 +0000)]
Auto merge of #30481 - nagisa:mir-calls-2, r=nikomatsakis

r? @nikomatsakis

This is a pretty big PR conflating changes to a few different block terminators (Call, DivergingCall, Panic, Resume, Diverge), because they are somewhat closely related.

Each commit has a pretty good description on what is being changed in each commit. The end result is greatly simplified CFG and translation for calls (no success branch if the function is diverging, no cleanup branch if there’s nothing to cleanup etc).

Fixes https://github.com/rust-lang/rust/issues/30480
Fixes https://github.com/rust-lang/rust/issues/29767
Partialy solves https://github.com/rust-lang/rust/issues/29575
Fixes https://github.com/rust-lang/rust/issues/29573

8 years agoCreate personality slot when translating Resume
Simonas Kazlauskas [Fri, 1 Jan 2016 22:45:21 +0000 (00:45 +0200)]
Create personality slot when translating Resume

This considerably simplifies code around calling functions and translation of Resume itself. This
removes requirement that a block containing Resume terminator is always translated after something
which creates a landing pad, thus allowing us to actually translate some valid MIRs we could not
translate before.

However, an assumption is added that translator is correct (in regards to landing pad generation)
and code will never reach the Resume terminator without going through a landing pad first. Breaking
these assumptions would pass an `undef` value into the personality functions.

8 years agopanic/panic_bounds_check to destructure tys
Simonas Kazlauskas [Tue, 22 Dec 2015 16:43:05 +0000 (18:43 +0200)]
panic/panic_bounds_check to destructure tys

Not any more beautiful.

8 years agoMerge Call and DivergingCall diffs into CallKind
Simonas Kazlauskas [Mon, 21 Dec 2015 23:46:56 +0000 (01:46 +0200)]
Merge Call and DivergingCall diffs into CallKind

This merges two separate Call terminators and uses a separate CallKind sub-enum instead.

A little bit unrelatedly, copying into destination value for a certain kind of invoke, is also
implemented here. See the associated comment in code for various details that arise with this
implementation.

8 years agoAdd tests
Simonas Kazlauskas [Mon, 21 Dec 2015 16:58:18 +0000 (18:58 +0200)]
Add tests

8 years agoDon’t generate landing-pads if -Z no-landing-pads
Simonas Kazlauskas [Sun, 20 Dec 2015 13:30:09 +0000 (15:30 +0200)]
Don’t generate landing-pads if -Z no-landing-pads

8 years agoFix ReturnPointer generation for void return types
Simonas Kazlauskas [Sat, 19 Dec 2015 14:51:52 +0000 (16:51 +0200)]
Fix ReturnPointer generation for void return types

Fixes #30480

8 years agoRefine call terminator translation
Simonas Kazlauskas [Sat, 19 Dec 2015 14:48:49 +0000 (16:48 +0200)]
Refine call terminator translation

* Implement landing pads; and
* Implement DivergingCall translation; and
* Modernise previous implementation of Call somewhat.

8 years agoHave a cached unreachable block inside MIR state
Simonas Kazlauskas [Sat, 19 Dec 2015 14:47:52 +0000 (16:47 +0200)]
Have a cached unreachable block inside MIR state

It is useful for various cases where direct unreachable cannot be translated and a separate block
is necessary.

8 years agoRemove diverge terminator
Simonas Kazlauskas [Fri, 18 Dec 2015 22:44:32 +0000 (00:44 +0200)]
Remove diverge terminator

Unreachable terminator can be contained all within the trans.

8 years agoRemove the Panic block terminator
Simonas Kazlauskas [Fri, 18 Dec 2015 21:19:29 +0000 (23:19 +0200)]
Remove the Panic block terminator

8 years agoAdd Resume Terminator which corresponds to resume
Simonas Kazlauskas [Tue, 15 Dec 2015 18:46:39 +0000 (20:46 +0200)]
Add Resume Terminator which corresponds to resume

Diverge should eventually go away

8 years agoGenerate DivergingCall terminator
Simonas Kazlauskas [Tue, 15 Dec 2015 10:20:49 +0000 (12:20 +0200)]
Generate DivergingCall terminator

This simplifies CFG greatly for some cases :)

8 years agoSplit Call into Call and DivergingCall
Simonas Kazlauskas [Mon, 14 Dec 2015 21:27:58 +0000 (23:27 +0200)]
Split Call into Call and DivergingCall

DivergingCall is different enough from the regular converging Call to warrant the split. This also
inlines CallData struct and creates a new CallTargets enum in order to have a way to differentiate
between calls that do not have an associated cleanup block.

Note, that this patch still does not produce DivergingCall terminator anywhere. Look for that in
the next patches.

8 years agoheap::deallocate expects a *mut u8 but here a *mut T is given. The final code is...
jonastepe [Wed, 6 Jan 2016 11:13:47 +0000 (12:13 +0100)]
heap::deallocate expects a *mut u8 but here a *mut T is given. The final code is correct, the example here would not compile without the cast. I used *mut _ instead of *mut u8 to be consistent with the final code.

8 years agoAuto merge of #30692 - michaelwoerister:mir-overloaded-fn-calls, r=nikomatsakis
bors [Wed, 6 Jan 2016 09:00:57 +0000 (09:00 +0000)]
Auto merge of #30692 - michaelwoerister:mir-overloaded-fn-calls, r=nikomatsakis

So far, calls going through `Fn::call`, `FnMut::call_mut`, or `FnOnce::call_once` have not been translated properly into MIR:
The call `f(a, b, c)` where `f: Fn(T1, T2, T3)` would end up in MIR as:
```
call `f` with arguments  `a`, `b`, `c`
```
What we really want is:
```
call `Fn::call` with arguments  `f`, `a`, `b`, `c`
```
This PR transforms these kinds of overloaded calls during `HIR -> HAIR` translation.

What's still a bit funky is that the `Fn` traits expect arguments to be tupled but due to special handling type-checking and trans, we do not actually tuple arguments and everything still checks out fine. So, after this PR we end up with MIR containing calls where function signature and arguments seemingly don't match:
```
call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, `a`, `b`, `c`
```
instead of
```
call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, (`a`, `b`, `c`)  //  <- args tupled!
```
It would be nice if the call traits could go without special handling in MIR and later on.

8 years agoFix a breaking change in #30523
Nicholas Mazzuca [Wed, 6 Jan 2016 06:16:03 +0000 (22:16 -0800)]
Fix a breaking change in #30523

While this does fix a breaking change, it is also, technically, a
[breaking-change] to go back to our original way

8 years agoWorkaround stage0 bug
Niko Matsakis [Tue, 22 Dec 2015 22:24:26 +0000 (17:24 -0500)]
Workaround stage0 bug

8 years agoAdd assert-dep-graph testing mechanism and tests
Niko Matsakis [Tue, 22 Dec 2015 22:17:27 +0000 (17:17 -0500)]
Add assert-dep-graph testing mechanism and tests

8 years agoRefactor compiler to make use of dep-tracking-maps. Also, in cases where
Niko Matsakis [Tue, 22 Dec 2015 21:39:33 +0000 (16:39 -0500)]
Refactor compiler to make use of dep-tracking-maps. Also, in cases where
we were using interior mutability (RefCells, TyIvar), add some reads/writes.

8 years agoRefactor overlap checker so that it walks the HIR instead of poking into
Niko Matsakis [Tue, 22 Dec 2015 22:17:57 +0000 (17:17 -0500)]
Refactor overlap checker so that it walks the HIR instead of poking into
random tables. The old code was weird anyway because it would
potentially walk traits from other crates etc. The new code fits
seamlessly with the dependency tracking.

8 years agoStrip the trait-def phase from collect, which has no function.
Niko Matsakis [Tue, 22 Dec 2015 22:08:45 +0000 (17:08 -0500)]
Strip the trait-def phase from collect, which has no function.

8 years agoAnnotate the compiler with information about what it is doing when.
Niko Matsakis [Tue, 22 Dec 2015 21:35:02 +0000 (16:35 -0500)]
Annotate the compiler with information about what it is doing when.

8 years agoAdd DepGraph to tcx.
Niko Matsakis [Tue, 5 Jan 2016 18:07:45 +0000 (13:07 -0500)]
Add DepGraph to tcx.

8 years agoIntroduce the DepGraph and DepTracking map abstractions,
Niko Matsakis [Tue, 5 Jan 2016 18:02:57 +0000 (13:02 -0500)]
Introduce the DepGraph and DepTracking map abstractions,
along with a README explaining how they are to be used

8 years agoAuto merge of #30492 - wesleywiser:fix_extra_drops, r=pnkfelix
bors [Wed, 6 Jan 2016 01:55:45 +0000 (01:55 +0000)]
Auto merge of #30492 - wesleywiser:fix_extra_drops, r=pnkfelix

Fixes #28159

8 years agoRemove irrelevant comment
Huon Wilson [Wed, 6 Jan 2016 01:28:34 +0000 (12:28 +1100)]
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.

8 years agoClarify how Rust treats backslashes at end of line in string literals
Tobias Bucher [Tue, 5 Jan 2016 23:01:59 +0000 (00:01 +0100)]
Clarify how Rust treats backslashes at end of line in string literals

Rust differs in that behavior from C: In C, the newline escapes are resolved
before anything else, and in Rust this depends on whether the backslash is
escaped itself.

A difference can be observed in the following two programs:

```c
#include <stdio.h>
int main()
{
printf("\\
n\n");
return 0;
}
```

```rust
fn main() {
println!("\\
n");
}
```

The first program prints two newlines, the second one prints a backslash, a
newline, the latin character n and a final newline.

8 years agoClarify What LIFO Is
BChip [Tue, 5 Jan 2016 20:32:54 +0000 (15:32 -0500)]
Clarify What LIFO Is

Declare what LIFO stands for

8 years ago[MIR] Add test case for translation of closure calls.
Michael Woerister [Tue, 5 Jan 2016 17:32:49 +0000 (12:32 -0500)]
[MIR] Add test case for translation of closure calls.

8 years ago[MIR] Implement calling of closures and add missing monomorphization when translating...
Michael Woerister [Tue, 5 Jan 2016 17:29:50 +0000 (12:29 -0500)]
[MIR] Implement calling of closures and add missing monomorphization when translating function references.

8 years ago[MIR] Handle overloaded call expressions during HIR -> HAIR translation.
Michael Woerister [Mon, 4 Jan 2016 11:08:11 +0000 (06:08 -0500)]
[MIR] Handle overloaded call expressions during HIR -> HAIR translation.

8 years agoUpdate MinGW details in the README
Steve Klabnik [Mon, 4 Jan 2016 17:33:43 +0000 (12:33 -0500)]
Update MinGW details in the README

Fixes #29649

8 years agoFix the spelling of "hexadecimal"
Matt Kraai [Tue, 5 Jan 2016 15:40:40 +0000 (07:40 -0800)]
Fix the spelling of "hexadecimal"

8 years agoAuto merge of #30665 - zachpanz88:new-year, r=nrc
bors [Tue, 5 Jan 2016 13:54:30 +0000 (13:54 +0000)]
Auto merge of #30665 - zachpanz88:new-year, r=nrc

New copyright date

Happy new year!

8 years agoAuto merge of #30702 - tshepang:derives-not-needed, r=steveklabnik
bors [Tue, 5 Jan 2016 10:24:37 +0000 (10:24 +0000)]
Auto merge of #30702 - tshepang:derives-not-needed, r=steveklabnik

Also sneak in a missing trailing comma

8 years agoAuto merge of #30680 - wesleywiser:rustdoc_image_max_width, r=steveklabnik
bors [Tue, 5 Jan 2016 08:37:06 +0000 (08:37 +0000)]
Auto merge of #30680 - wesleywiser:rustdoc_image_max_width, r=steveklabnik

Fixes #24861

8 years agoAuto merge of #30708 - GuillaumeGomez:malformed_macro, r=sanxiyn
bors [Tue, 5 Jan 2016 05:20:27 +0000 (05:20 +0000)]
Auto merge of #30708 - GuillaumeGomez:malformed_macro, r=sanxiyn

Part of #30669

8 years agoAuto merge of #30595 - steveklabnik:remove_learn_rust, r=gankro
bors [Tue, 5 Jan 2016 03:32:12 +0000 (03:32 +0000)]
Auto merge of #30595 - steveklabnik:remove_learn_rust, r=gankro

Some history:

While getting Rust to 1.0, it was a struggle to keep the book in a
working state. I had always wanted a certain kind of TOC, but couldn't
quite get it there.

At the 11th hour, I wrote up "Rust inside other langauges" and "Dining
Philosophers" in an attempt to get the book in the direction I wanted to
go. They were fine, but not my best work. I wanted to further expand
this section, but it's just never going to end up happening. We're doing
the second draft of the book now, and these sections are basically gone
already.

Here's the issues with these two sections, and removing them just fixes
it all:

// Philosophers

There was always controversy over which ones were chosen, and why. This
is kind of a perpetual bikeshed, but it comes up every once in a while.

The implementation was originally supposed to show off channels, but
never did, due to time constraints. Months later, I still haven't
re-written it to use them.

People get different results and assume that means they're wrong, rather
than the non-determinism inherent in concurrency. Platform differences
aggrivate this, as does the exact amount of sleeping and printing.

// Rust Inside Other Languages

This section is wonderful, and shows off a strength of Rust. However,
it's not clear what qualifies a language to be in this section. And I'm
not sure how tracking a ton of other languages is gonna work, into the
future; we can't test _anything_ in this section, so it's prone to
bitrot.

By removing this section, and making the Guessing Game an initial
tutorial, we will move this version of the book closer to the future
version, and just eliminate all of these questions.

In addition, this also solves the 'split-brained'-ness of having two
paths, which has endlessly confused people in the past.

I'm sad to see these sections go, but I think it's for the best.

Fixes #30471
Fixes #30163
Fixes #30162
Fixes #25488
Fixes #30345
Fixes #29590
Fixes #28713
Fixes #28915

And probably others. This lengthy list alone is enough to show that
these should have been removed.

RIP.

8 years agoAuto merge of #30707 - tsion:mir-text, r=nikomatsakis
bors [Tue, 5 Jan 2016 01:43:07 +0000 (01:43 +0000)]
Auto merge of #30707 - tsion:mir-text, r=nikomatsakis

r? @nikomatsakis

Textual MIR can be dumped for a particular `fn` with `#![rustc_mir(pretty = "filename.mir")]`. Below is an example of the text output.

```rust
struct Point {
    x: i32,
    y: i32,
}

fn example() -> Point {
    let mut e = Point { x: 1, y: 2 };

    let num = 5;
    let plus_num = |x: i32| x + num;

    e.y = plus_num(e.x);
    e
}
```

```rust
fn() -> Point {
    let mut var0: Point; // e
    let var1: i32; // num
    let var2: [closure@test.rs:84:20: 84:36 num:&i32]; // plus_num
    let mut tmp0: ();
    let mut tmp1: &i32;
    let mut tmp2: ();
    let mut tmp3: i32;
    let mut tmp4: &[closure@test.rs:84:20: 84:36 num:&i32];
    let mut tmp5: i32;
    let mut tmp6: Point;

    bb0: {
        var0 = Point { x: 1, y: 2 };
        var1 = 5;
        tmp1 = &var1;
        var2 = [closure@test.rs:84:20: 84:36] { num: tmp1 };
        tmp4 = &var2;
        tmp5 = var0.0;
        tmp3 = tmp4(tmp5) -> [return: bb3, unwind: bb4];
    }

    bb1: {
        return;
    }

    bb2: {
        diverge;
    }

    bb3: {
        drop var0.1;
        var0.1 = tmp3;
        drop tmp2;
        drop var2;
        drop var0;
        tmp6 = var0;
        return = tmp6;
        drop tmp6;
        goto -> bb1;
    }

    bb4: {
        drop var2;
        goto -> bb5;
    }

    bb5: {
        drop var0;
        goto -> bb2;
    }
}
```

```rust
fn(arg0: &[closure@test.rs:84:20: 84:36 num:&i32], arg1: i32) -> i32 {
    let var0: i32; // x
    let mut tmp0: ();
    let mut tmp1: i32;
    let mut tmp2: i32;

    bb0: {
        var0 = arg1;
        tmp1 = var0;
        tmp2 = (*(*arg0).0);
        return = Add(tmp1, tmp2);
        goto -> bb1;
    }

    bb1: {
        return;
    }

    bb2: {
        diverge;
    }
}
```

8 years agoAuto merge of #30681 - Toby-S:master, r=bluss
bors [Mon, 4 Jan 2016 23:57:46 +0000 (23:57 +0000)]
Auto merge of #30681 - Toby-S:master, r=bluss

Make `".".parse::<f32>()` and `".".parse::<f64>()` return Err

This fixes #30344.

This is a [breaking-change], which the libs team have classified as a
bug fix.

8 years agoAdd 'mut' to MIR temp variable debug output.
Scott Olson [Sat, 2 Jan 2016 13:10:25 +0000 (07:10 -0600)]
Add 'mut' to MIR temp variable debug output.

8 years agoPretty-print ReturnPointer as 'return' in MIR.
Scott Olson [Sat, 2 Jan 2016 03:56:29 +0000 (21:56 -0600)]
Pretty-print ReturnPointer as 'return' in MIR.

8 years agoPretty-print static lvalues in MIR as just their path.
Scott Olson [Sat, 2 Jan 2016 03:01:17 +0000 (21:01 -0600)]
Pretty-print static lvalues in MIR as just their path.

8 years agoImprove pretty-printing of references in MIR.
Scott Olson [Fri, 1 Jan 2016 06:39:02 +0000 (00:39 -0600)]
Improve pretty-printing of references in MIR.

8 years agoPretty-print aggregates more prettily in MIR.
Scott Olson [Fri, 1 Jan 2016 03:38:44 +0000 (21:38 -0600)]
Pretty-print aggregates more prettily in MIR.

8 years agoUse fmt::Result instead of Result<(), Error>.
Scott Olson [Fri, 1 Jan 2016 02:11:25 +0000 (20:11 -0600)]
Use fmt::Result instead of Result<(), Error>.

8 years agoPrint BasicBlock names in lowercase.
Scott Olson [Wed, 30 Dec 2015 02:10:39 +0000 (20:10 -0600)]
Print BasicBlock names in lowercase.

8 years agoAdd a human-readable textual form for MIR.
Scott Olson [Wed, 30 Dec 2015 02:06:19 +0000 (20:06 -0600)]
Add a human-readable textual form for MIR.

This can be dumped for a particular `fn` with the attribute
`#![rustc_mir(pretty = "filename.mir"]`.

8 years agoAuto merge of #30661 - michaelwoerister:trans_fn_attrs, r=nrc
bors [Mon, 4 Jan 2016 22:09:52 +0000 (22:09 +0000)]
Auto merge of #30661 - michaelwoerister:trans_fn_attrs, r=nrc

So far `librustc::trans::base::trans_fn()` and `trans_closure()` have been passed the list of attributes on the function being translated *only* if the function was local and non-generic. For generic functions, functions inlined from other crates, functions with foreign ABI and for closures, only an empty list of attributes was ever passed to `trans_fn()`.
This led to the case that generic functions marked with `#[rustc_mir]` where not actually translated via MIR but via the legacy translation path.

This PR makes function/closure attributes always be passed to `trans_fn()` and disables the one test where this makes a difference.

If there is an actual reason why attributes were not passed along in these cases, let me know.

cc @rust-lang/compiler
cc @luqmana regarding the test case

8 years agodoc: these examples do not need Copy and Clone traits
Tshepang Lekhonkhobe [Mon, 4 Jan 2016 20:37:06 +0000 (22:37 +0200)]
doc: these examples do not need Copy and Clone traits

Also sneak in a missing trailing comma

8 years agoAuto merge of #30602 - tsion:mir-graphviz-display, r=nikomatsakis
bors [Mon, 4 Jan 2016 20:24:35 +0000 (20:24 +0000)]
Auto merge of #30602 - tsion:mir-graphviz-display, r=nikomatsakis

r? @nikomatsakis

cc @eddyb @nagisa

This PR changes most of the MIR graphviz debug output, making it smaller and more consistent. Also, it changes all fonts to monospace and adds a graph label containing the type of the `fn` the MIR is for and all the values (arguments, named bindings, and compiler temporaries).

I chose to re-write the graphviz output code instead of using the existing libgraphviz API because I found it much easier to prototype usage of various graphviz features when I had full control of the text output. It also makes the code simpler, I think.

Below are a bunch of example functions and links to their output images on the current nightly vs. this PR. File names starting with numbers (e.g. `80-factorial_fold-new.png`) are for closures. There's still a bunch of low hanging fruit to make it even better, particularly around aggregates and references.

I also imagine the textual output for MIR will be able to closely match the graphviz output. The list of statements should look identical and the terminators will be the same except that the text form will have a list of target blocks (potentially using the same edge labels as the graphviz does). I can PR a simple text output right after this PR.

This is my first large change to the compiler, so if anything should be reorganized/renamed/etc, let me know! Also, feel free to bikeshed the details of the output, though any minor changes can come in future PRs.

```rust
fn empty() {}
```

http://vps.solson.me/mir-graphviz/empty-new.png
http://vps.solson.me/mir-graphviz/empty-old.png

```rust
fn constant() -> i32 {
    42
}
```

http://vps.solson.me/mir-graphviz/constant-new.png
http://vps.solson.me/mir-graphviz/constant-old.png

```rust
fn increment(x: i32) -> i32 {
    x + 1
}
```

http://vps.solson.me/mir-graphviz/increment-new.png
http://vps.solson.me/mir-graphviz/increment-old.png

```rust
fn factorial_recursive(n: usize) -> usize {
    if n == 0 {
        1
    } else {
        n * factorial_recursive(n - 1)
    }
}
```

http://vps.solson.me/mir-graphviz/factorial_recursive-new.png
http://vps.solson.me/mir-graphviz/factorial_recursive-old.png

```rust
fn factorial_iterative(n: usize) -> usize {
    let mut prod = 1;
    for x in 1..n {
        prod *= x;
    }
    prod
}
```

http://vps.solson.me/mir-graphviz/factorial_iterative-new.png
http://vps.solson.me/mir-graphviz/factorial_iterative-old.png

```rust
fn factorial_fold(n: usize) -> usize {
    (1..n).fold(1, |prod, x| prod * x)
}
```

http://vps.solson.me/mir-graphviz/factorial_fold-new.png
http://vps.solson.me/mir-graphviz/factorial_fold-old.png
http://vps.solson.me/mir-graphviz/80-factorial_fold-new.png
http://vps.solson.me/mir-graphviz/80-factorial_fold-old.png

```rust
fn collatz(mut n: usize) {
    while n != 1 {
        if n % 2 == 0 {
            n /= 2;
        } else {
            n = 3 * n + 1;
        }
    }
}
```

http://vps.solson.me/mir-graphviz/collatz-new.png
http://vps.solson.me/mir-graphviz/collatz-old.png

```rust
fn multi_switch(n: usize) -> usize {
    match n {
        5 | 10 | 15 => 3,
        20 | 30 => 2,
        _ => 1,
    }
}
```

http://vps.solson.me/mir-graphviz/multi_switch-new.png
http://vps.solson.me/mir-graphviz/multi_switch-old.png

8 years agoMention that structs can contain &mut Ts
Steve Klabnik [Mon, 4 Jan 2016 17:44:54 +0000 (12:44 -0500)]
Mention that structs can contain &mut Ts

Fixes #30254

8 years agoAuto merge of #30523 - ubsan:wrapping_op_assign, r=eddyb
bors [Mon, 4 Jan 2016 18:37:21 +0000 (18:37 +0000)]
Auto merge of #30523 - ubsan:wrapping_op_assign, r=eddyb

Add OpAssign to Wrapping<T>, plus fix some problems in core::num::wrapping

including, but not limited to:

* Testing Wrapping<T>
* Pull out a lot of broken code that doesn't need to be there with the new stage0 compiler
* Adding Rem and RemAssign to Wrapping<T>
* Removed 3 (assumed accidental) re-exports, which is a minor [breaking-change].
* Change shl and shr to take all integer types, instead of a usize; this is a more major [breaking-change], because of values that were inferred before, but brings us in line with the integer shifts.

Fixes #30524 and #30523

8 years agoMake float parsing "." return Err
Toby Scrace [Sun, 3 Jan 2016 20:08:53 +0000 (20:08 +0000)]
Make float parsing "." return Err

This makes both of the following return Err:

    ".".parse::<f32>()
    ".".parse::<f64>()

This is a [breaking-change], which the libs team have classified as a
bug fix.

8 years agoMention that Sync/Send are automatically derived
Steve Klabnik [Mon, 4 Jan 2016 18:03:29 +0000 (13:03 -0500)]
Mention that Sync/Send are automatically derived

Fixes #28581

8 years agoAuto merge of #30553 - luqmana:mir-match-arm-guards, r=nikomatsakis
bors [Mon, 4 Jan 2016 16:54:11 +0000 (16:54 +0000)]
Auto merge of #30553 - luqmana:mir-match-arm-guards, r=nikomatsakis

Fixes #30527.

```Rust

fn main() {
    let _abc = match Some(101i8) {
        Some(xyz) if xyz > 100 => xyz,
        Some(_) => -1,
        None => -2
    };
}
```

Resulting MIR now includes the `Some(xyz)` arm, guard and all:
![match.dot](https://cloud.githubusercontent.com/assets/287063/11999413/066f7610-aa8b-11e5-927b-24215af57fc4.png)

~~Not quite sure how to write a test for this.~~ Thinking too hard, just tested the end result.

r? @nikomatsakis

8 years agoAuto merge of #30690 - LawrenceWoodman:patch-2, r=steveklabnik
bors [Mon, 4 Jan 2016 14:09:15 +0000 (14:09 +0000)]
Auto merge of #30690 - LawrenceWoodman:patch-2, r=steveklabnik

`fs::File` was being referenced without either calling via `std::fs::File` or by using `File` after having used `std::fs::File`.  Also `Path` was being referenced without first having used `std::path::Path`.

8 years agoAdd missing use statements
Lawrence Woodman [Mon, 4 Jan 2016 07:21:48 +0000 (07:21 +0000)]
Add missing use statements

fs::File was being referenced without either calling via std::fs::File or by using File after having used fs::File.  Also Path was being referenced without first having used std::path::Path.

8 years agoAuto merge of #30651 - nagisa:mir-fix-equality-checks, r=eddyb
bors [Mon, 4 Jan 2016 03:07:59 +0000 (03:07 +0000)]
Auto merge of #30651 - nagisa:mir-fix-equality-checks, r=eddyb

This is not a fix to checks themselves per se (though we still use `Eq` MIR test instead of calling `PartialEq::eq`), but rather how we handle items we encounter in pattern position.

Previously we would just call `PartialEq` with the constant and the matchee, but now we essentially inline the constant instead. E.g. these two snippets are functionally equivalent at MIR level:

```
match val { Some(42) => true, _ => false }
```
and
```
const SECRET: Option<u8> = Some(42);
match val { SECRET => true, _ => false }
```

This approach also allows for more optimizations of matches. I.e. It can now exploit `SwitchInt` to switch on number inside a `Some` regardless of whether the value being an item or not.

This is based on @tsion’s already approved PR so I could reuse the file for more tests.

r? @eddyb
cc @nikomatsakis @tsion

8 years agoAuto merge of #29732 - nathansizemore:master, r=steveklabnik
bors [Mon, 4 Jan 2016 00:27:40 +0000 (00:27 +0000)]
Auto merge of #29732 - nathansizemore:master, r=steveklabnik

8 years agoAdd test for "malformed macro lhs" and change back span_bug to span_fatal
Guillaume Gomez [Mon, 4 Jan 2016 00:11:54 +0000 (01:11 +0100)]
Add test for "malformed macro lhs" and change back span_bug to span_fatal

8 years agoAuto merge of #30677 - diwic:master, r=bluss
bors [Sun, 3 Jan 2016 21:00:46 +0000 (21:00 +0000)]
Auto merge of #30677 - diwic:master, r=bluss

Obviously we can't remove the character one past the end of the String. And we can't today either - we'll just panic at char_at() instead - but if we're going to keep that assertion, we should at least have a correct assertion.

8 years agoAuto merge of #29949 - fhahn:issue-21659-show-relevant-trait-impls, r=arielb1
bors [Sun, 3 Jan 2016 19:14:20 +0000 (19:14 +0000)]
Auto merge of #29949 - fhahn:issue-21659-show-relevant-trait-impls, r=arielb1

This PR for #21659 uses `DefId.for_each_relevant_impl()` to show other possible implementations in the "trait not implemented" message.

8 years agoCorrect formatting use of tab instead of spaces
Lawrence Woodman [Sun, 3 Jan 2016 08:15:24 +0000 (08:15 +0000)]
Correct formatting use of tab instead of spaces

8 years agoRustdoc - Specify max-image size
Wesley Wiser [Sun, 3 Jan 2016 02:38:36 +0000 (21:38 -0500)]
Rustdoc - Specify max-image size

Fixes #24861

8 years agoTake out Op<T>/OpAssign<T> for Wrapping<T>
Nicholas Mazzuca [Sat, 2 Jan 2016 23:34:55 +0000 (15:34 -0800)]
Take out Op<T>/OpAssign<T> for Wrapping<T>

8 years agoRefactor candidate selection
Florian Hahn [Sat, 2 Jan 2016 23:11:48 +0000 (00:11 +0100)]
Refactor candidate selection

8 years agoFinish test implementation
Nicholas Mazzuca [Sat, 2 Jan 2016 22:36:28 +0000 (14:36 -0800)]
Finish test implementation

8 years agoFix off-by-one in String::remove
diwic [Sat, 2 Jan 2016 21:36:50 +0000 (22:36 +0100)]
Fix off-by-one in String::remove

Obviously we can't remove the character one past the end of the String. And we can't today either - we'll just panic at char_at() instead - but if we're going to keep that assertion, we should at least have a correct assertion.

8 years agoUse for_each_impl
Florian Hahn [Mon, 28 Dec 2015 22:50:18 +0000 (23:50 +0100)]
Use for_each_impl

8 years agoManually check trait implementations
Florian Hahn [Thu, 17 Dec 2015 22:58:56 +0000 (23:58 +0100)]
Manually check trait implementations

8 years agoAdd more tests
Florian Hahn [Sat, 28 Nov 2015 10:42:25 +0000 (11:42 +0100)]
Add more tests

8 years agoLimit displaying relevant trait impls to 4
Florian Hahn [Sat, 28 Nov 2015 10:41:52 +0000 (11:41 +0100)]
Limit displaying relevant trait impls to 4

8 years agoAuto merge of #30264 - GuillaumeGomez:patch-5, r=Manishearth
bors [Sat, 2 Jan 2016 16:56:15 +0000 (16:56 +0000)]
Auto merge of #30264 - GuillaumeGomez:patch-5, r=Manishearth

r? @Manishearth

Also: should I merged both commits? Not sure if it's really useful to keep the first one.

8 years agoAuto merge of #30675 - jimmantooth:master, r=apasel422
bors [Sat, 2 Jan 2016 13:58:57 +0000 (13:58 +0000)]
Auto merge of #30675 - jimmantooth:master, r=apasel422

8 years agoAdd 'mut' to temporary vars in MIR graphviz output.
Scott Olson [Sat, 2 Jan 2016 13:12:20 +0000 (07:12 -0600)]
Add 'mut' to temporary vars in MIR graphviz output.

8 years agoGrammar fixes
James Mantooth [Sat, 2 Jan 2016 07:26:22 +0000 (01:26 -0600)]
Grammar fixes

8 years agoAdjusted heading and created dedicated section in std::io docs
Nathan [Tue, 1 Dec 2015 02:23:19 +0000 (21:23 -0500)]
Adjusted heading and created dedicated section in std::io docs