Commit Graph

49475 Commits

Author SHA1 Message Date
Niko Matsakis
a9d7e36668 Fix numerous typos, renamings, and minor nits raised by mw. 2016-01-06 09:19:19 -05:00
bors
d5ac1a1da3 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
2016-01-06 13:11:18 +00:00
Ms2ger
6f0e58fc5f Stop re-exporting MutateMode's variants. 2016-01-06 13:16:30 +01:00
Simonas Kazlauskas
36b3951c73 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.
2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
f9814242dc panic/panic_bounds_check to destructure tys
Not any more beautiful.
2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
d1c644c1e9 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.
2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
50107034c0 Add tests 2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
cef6aee369 Don’t generate landing-pads if -Z no-landing-pads 2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
20ec53a0d3 Fix ReturnPointer generation for void return types
Fixes #30480
2016-01-06 13:57:52 +02:00
Simonas Kazlauskas
924bb1e5eb Refine call terminator translation
* Implement landing pads; and
* Implement DivergingCall translation; and
* Modernise previous implementation of Call somewhat.
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
a1e13983f7 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.
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
4e86dcdb72 Remove diverge terminator
Unreachable terminator can be contained all within the trans.
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
5b34690842 Remove the Panic block terminator 2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
ecf4d0e3ad Add Resume Terminator which corresponds to resume
Diverge should eventually go away
2016-01-06 13:57:51 +02:00
Simonas Kazlauskas
6f18b559df Generate DivergingCall terminator
This simplifies CFG greatly for some cases :)
2016-01-06 13:57:47 +02:00
Simonas Kazlauskas
893a66d7a1 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.
2016-01-06 13:40:57 +02:00
jonastepe
eb30c661c0 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. 2016-01-06 12:13:47 +01:00
bors
7312e0a163 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.
2016-01-06 09:00:57 +00:00
Jeffrey Seyfried
834fb17e94 Fix bug in duplicate checking for extern crates. 2016-01-06 07:04:48 +00:00
Mike Anderson
5038d4e8ef std::cmp::max -> max 2016-01-06 00:42:19 -06:00
Lawrence Woodman
0ca33adabf Add missing semi-colon 2016-01-06 06:27:29 +00:00
Nicholas Mazzuca
14e1e2aee8 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
2016-01-05 22:16:03 -08:00
Scott Olson
b2903d87c9 Improve pretty-printing for ConstVals in MIR. 2016-01-05 23:08:16 -06:00
Niko Matsakis
11c671b59c Workaround stage0 bug 2016-01-05 21:05:51 -05:00
Niko Matsakis
8b22ed8651 Add assert-dep-graph testing mechanism and tests 2016-01-05 21:05:51 -05:00
Niko Matsakis
d48f48f61f Refactor compiler to make use of dep-tracking-maps. Also, in cases where
we were using interior mutability (RefCells, TyIvar), add some reads/writes.
2016-01-05 21:05:51 -05:00
Niko Matsakis
5d9dd7cf33 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.
2016-01-05 21:05:51 -05:00
Niko Matsakis
75c4f395ac Strip the trait-def phase from collect, which has no function. 2016-01-05 21:05:50 -05:00
Niko Matsakis
005fa14358 Annotate the compiler with information about what it is doing when. 2016-01-05 21:05:50 -05:00
Niko Matsakis
aa265869ba Add DepGraph to tcx. 2016-01-05 21:05:50 -05:00
Niko Matsakis
c77cd480cf Introduce the DepGraph and DepTracking map abstractions,
along with a README explaining how they are to be used
2016-01-05 21:05:50 -05:00
bors
dc1f442634 Auto merge of #30492 - wesleywiser:fix_extra_drops, r=pnkfelix
Fixes #28159
2016-01-06 01:55:45 +00: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
Scott Olson
c785802c0a Boring whitespace cleanup. 2016-01-05 17:26:22 -06:00
Tobias Bucher
ce6baa77fe 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.
2016-01-06 00:04:25 +01:00
Niko Matsakis
6dd3f6143e convert from hard error to future-incompatible lint 2016-01-05 16:21:53 -05:00
Niko Matsakis
27d6b9d215 improve visibility of future-incompatibilities (mildly, at least) 2016-01-05 16:21:53 -05:00
Nick Cameron
535282bcf5 Cancel an error before it panics
Fixes #30715
2016-01-06 09:56:32 +13:00
BChip
7d6d39bcd9 Clarify What LIFO Is
Declare what LIFO stands for
2016-01-05 15:32:54 -05:00
Michael Woerister
e281509dce [MIR] Add test case for translation of closure calls. 2016-01-05 12:50:54 -05:00
Michael Woerister
7d357190ff [MIR] Implement calling of closures and add missing monomorphization when translating function references. 2016-01-05 12:50:46 -05:00
Michael Woerister
04b6c4939b [MIR] Handle overloaded call expressions during HIR -> HAIR translation. 2016-01-05 12:40:35 -05:00
Steve Klabnik
011a23e8bc Update MinGW details in the README
Fixes #29649
2016-01-05 11:36:15 -05:00
Matt Kraai
cd4bf34659 Fix the spelling of "hexadecimal" 2016-01-05 07:40:40 -08:00
bors
bd58fd8438 Auto merge of #30665 - zachpanz88:new-year, r=nrc
New copyright date

Happy new year!
2016-01-05 13:54:30 +00:00
Lawrence Woodman
ca1f0c9b64 Add correct use for Error and io
This also repeated the case analysis used.
2016-01-05 11:09:39 +00:00
bors
5253294d22 Auto merge of #30702 - tshepang:derives-not-needed, r=steveklabnik
Also sneak in a missing trailing comma
2016-01-05 10:24:37 +00:00
Piotr Czarnecki
388e6afa1d Add tests for drops 2016-01-05 11:02:58 +01:00
Piotr Czarnecki
100a4698de Ran rustfmt 2016-01-05 11:02:43 +01:00
Piotr Czarnecki
72a5bb73c1 Move tests around 2016-01-05 11:02:43 +01:00