Commit Graph

8439 Commits

Author SHA1 Message Date
Mark Mansi
51ef7393ef Fix typo in error message + update tests 2018-01-30 12:41:04 -06:00
Mark Mansi
711f71cfa9 Add a couple of tests 2018-01-30 12:32:41 -06:00
kennytm
b83fb0f2de Rollup merge of #47853 - rust-lang:increase-nested-groups-test-coverage, r=nikomatsakis
Increase test coverage of use_nested_groups

r? @nikomatsakis
2018-01-30 17:10:59 +08:00
kennytm
fccc85a0ad Rollup merge of #47718 - malbarbo:env-home-dir, r=nikomatsakis
Make run-pass/env-home-dir.rs test more robust

Remove the assumption that home_dir always returns Some.

This allows the test to be executed with [cross](https://github.com/japaric/cross).
2018-01-30 17:10:51 +08:00
bors
90eb44a589 Auto merge of #47837 - eddyb:going-places, r=nikomatsakis
Replace "lvalue" terminology with "place".

See #46425 for the previous PR (which only changed MIR-related code).

r? @nikomatsakis
2018-01-29 19:47:48 +00:00
Niko Matsakis
adeb0aeb4a
move comment right onto the line in question 2018-01-29 13:28:23 -05:00
Marco A L Barbosa
898fdcc3ed Make run-pass/env-home-dir.rs test more robust
Remove the assumption that home_dir always returns Some

This allows the test to be executed with
[cross](https://github.com/japaric/cross).
2018-01-29 15:40:27 -02:00
Pietro Albini
8389b66c18
Increase test coverage of use_nested_groups 2018-01-29 17:11:09 +01:00
Eduard-Mihai Burtescu
6f8d263e87 tests: replace "lvalue" terminology with "place". 2018-01-29 11:48:12 +02:00
bors
5e7fd65419 Auto merge of #47794 - etaoins:fix-ice-on-const-eval-of-union-field, r=eddyb
Fix ICE on const eval of union field

MIR's `Const::get_field()` attempts to retrieve the value for a given field in a constant. In the case of a union constant it was falling through to a generic `const_get_elt` based on the field index. As union fields don't have an index this caused an ICE in `llvm_field_index`.

Fix by simply returning the current value when accessing any field in a union. This works because all union fields start at byte offset 0.

The added test uses `const_fn` it ensure the field is extracted using MIR's const evaluation. The crash is reproducible without it, however.

Fixes #47788

r? @eddyb
2018-01-28 13:24:47 +00:00
bors
6beb06ee5e Auto merge of #47746 - varkor:never-type-ice, r=nikomatsakis
Fix never-type rvalue ICE

This fixes #43061.
r? @nikomatsakis

A small post-mortem as a follow-up to our investigations in https://github.com/rust-lang/rust/pull/47291:
The problem as I understand it is that when `NeverToAny` coercions are made, the expression/statement that is coerced may be enclosed in a block. In our case, the statement `x;` was being transformed to something like: `NeverToAny( {x;} )`. Then, `NeverToAny` is transformed into an expression:
000fbbc9b8/src/librustc_mir/build/expr/into.rs (L52-L59)
Which ends up calling `ast_block_stmts` on the block `{x;}`, which triggers this condition:
000fbbc9b8/src/librustc_mir/build/block.rs (L141-L147)
In our case, there is no return expression, so `push_assign_unit` is called. But the block has already been recorded as _diverging_, meaning the result of the block will be assigned to a location of type `!`, rather than `()`. This causes the MIR error.
I'm assuming the `NeverToAny` coercion code is doing what it's supposed to (there don't seem to be any other problems), so fixing the issue simply consists of checking that the destination for the return value actually _is_ supposed to be a unit. (If no return value is given, the only other possible type for the return value is `!`, which can just be ignored, as it will be unreachable anyway.)

I checked the other cases of `push_assign_unit`, and it didn't look like they could be affected by the divergence issue (blocks are kind of special-cased in this regard as far as I can tell), so this should be sufficient to fix the issue.
2018-01-28 00:40:10 +00:00
Ryan Cumming
ed7e4e1e27 Expand union test to include different types 2018-01-27 14:26:14 +11:00
Ryan Cumming
75c79bdb02 Fix ICE on const eval of union field
MIR's `Const::get_field()` attempts to retrieve the value for a given
field in a constant. In the case of a union constant it was falling
through to a generic `const_get_elt` based on the field index. As union
fields don't have an index this caused an ICE in `llvm_field_index`.

Fix by simply returning the current value when accessing any field in a
union. This works because all union fields start at byte offset 0.

The added test uses `const_fn` it ensure the field is extracted using
MIR's const evaluation. The crash is reproducible without it, however.

Fixes #47788
2018-01-27 12:57:01 +11:00
bors
bacb5c58df Auto merge of #47748 - alexcrichton:rollup, r=alexcrichton
Rollup of 19 pull requests

- Successful merges: #47415, #47437, #47439, #47453, #47460, #47502, #47529, #47600, #47607, #47618, #47626, #47656, #47668, #47696, #47701, #47705, #47710, #47711, #47719
- Failed merges: #47455, #47521
2018-01-26 17:41:36 +00:00
Alex Crichton
a06d333a14 Ignore a test on emscripten 2018-01-26 09:41:00 -08:00
varkor
adcb37e275 Add clarifying comment regarding the trailing type of a block 2018-01-26 15:39:19 +00:00
Alex Crichton
9bb18239de Fix a test case on Windows 2018-01-26 07:37:57 -08:00
Alex Crichton
c915e3a10a Merge branch 'mlsm' of https://github.com/dotdash/rust into rollup 2018-01-26 06:53:18 -08:00
Alex Crichton
afc977fa23 Merge branch 'android-run-pass' of https://github.com/malbarbo/rust into rollup 2018-01-26 06:52:36 -08:00
Alex Crichton
a9101095e8 Merge branch 'simd-always-mem' of https://github.com/alexcrichton/rust into rollup 2018-01-26 06:51:43 -08:00
Alex Crichton
ac774e7a5b Shorten another test path for MSVC 2018-01-26 06:48:38 -08:00
bors
a97cd17f5d Auto merge of #47252 - Zoxc:backtrace-win, r=alexcrichton
Print inlined functions on Windows

Split from https://github.com/rust-lang/rust/pull/45637

r? @alexcrichton
2018-01-26 12:18:00 +00:00
Björn Steinbrink
aca88e185a Upgrade LLVM to incorporate a fix for #47364
Fixes #47364
2018-01-26 09:57:34 +01:00
Alex Crichton
68f2e1ebf2 Ignore an i128 test on emscripten 2018-01-25 21:04:01 -08:00
John Kåre Alsaker
634f8cc06a Print inlined functions on Windows 2018-01-26 04:49:54 +01:00
Alex Crichton
e61c609320 Merge branch 'configure-lto' of https://github.com/alexcrichton/rust into rollup 2018-01-25 13:50:42 -08:00
Alex Crichton
ad8b3135e1 Rollup merge of #47719 - malbarbo:run-pass-arch-powerpc, r=alexcrichton
Add powerpc to run-pass/conditional-compile-arch.rs
2018-01-25 13:49:56 -08:00
Alex Crichton
f7706d5816 Rollup merge of #47705 - pietroalbini:fix-47673, r=petrochenkov
Fix ICE when use trees have multiple empty nested groups

The issue was caused by an oversight of mine in the original use_nested_groups PR, where different paths were resolved with the same `NodeId` in some cases (such as in `use {{}, {}};`).

Fixes #47673
r? @petrochenkov
2018-01-25 13:49:53 -08:00
Marco A L Barbosa
c199cb5370 Make 3 run-pass tests works on android (aarch64 and x86) 2018-01-25 18:55:11 -02:00
Alex Crichton
502de01ff4 rustc: SIMD types use pointers in Rust's ABI
This commit changes the ABI of SIMD types in the "Rust" ABI to unconditionally
be passed via pointers instead of being passed as immediates. This should fix a
longstanding issue, #44367, where SIMD-using programs ended up showing very odd
behavior at runtime because the ABI between functions was mismatched.

As a bit of a recap, this is sort of an LLVM bug and sort of an LLVM feature
(today's behavior). LLVM will generate code for a function solely looking at the
function it's generating, including calls to other functions. Let's then say
you've got something that looks like:

```llvm
define void @foo() { ; no target features enabled
  call void @bar(<i64 x 4> zeroinitializer)
  ret void
}

define void @bar(<i64 x 4>) #0 { ; enables the AVX feature
  ...
}
```

LLVM will codegen the call to `bar` *without* using AVX registers becauase `foo`
doesn't have access to these registers. Instead it's generated with emulation
that uses two 128-bit registers. The `bar` function, on the other hand, will
expect its argument in an AVX register (as it has AVX enabled). This means we've
got a codegen problem!

Comments on #44367 have some more contexutal information but the crux of the
issue is that if we want SIMD to work in general we'll need to ensure that
whenever a function calls another they ABI of the arguments being passed is in
agreement.

One possible solution to this would be to insert "shim functions" where whenever
a `target_feature` mismatch is detected the compiler inserts a shim function
where you pass arguments via memory to the shim and then the shim loads the
values and calls the target function (where the shim and the target have the
same target features enabled). This unfortunately is quite nontrivial to
implement in rustc today (especially when accounting for function pointers and
such).

This commit takes a different solution, *always* passing SIMD arguments through
memory instead of passing as immediates. This strategy solves the problem at the
LLVM layer because the ABI between two functions never uses SIMD registers. This
also shouldn't be a hit to performance because SIMD performance is thought to
often rely on inlining anyway, where a `call` instruction, even if using SIMD
registers, would be disastrous to performance regardless. LLVM should then be
more than capable of fixing all our memory usage to use registers instead after
enough inlining has been performed.

Note that there's a few caveats to this commit though:

* The "platform intrinsic" ABI is omitted from "always pass via memory". This
  ABI is used to define intrinsics like `simd_shuffle4` where LLVM and rustc
  need to have the arguments as an immediate.

* Additionally this commit does *not* fix the `extern` ("C") ABI. This means
  that the bug in #44367 can still happen when using non-Rust-ABI functions. My
  hope is that before stabilization we can ban and/or warn about SIMD types in
  these functions (as AFAIK there's not much motivation to belong there anyway),
  but I'll leave that for a later commit and if this is merged I'll file a
  follow-up issue.

All in all this...

Closes #44367
2018-01-25 12:05:24 -08:00
Alex Crichton
6eb1430547 Rollup merge of #47439 - eddyb:issue-45662, r=nagisa
rustc_trans: ignore trailing padding larger than 8 bytes.

Fixes #45662 by ignoring a missing second register component, as it could be entirely padding.
2018-01-25 12:48:46 -06:00
Alex Crichton
fe2fb24228 Rollup merge of #47437 - eddyb:issue-38763, r=nagisa
rustc_trans: take into account primitives larger than 8 bytes.

Fixes #38763 by marking all "eightbytes" covered by a primitive appropriately, not just the first.
2018-01-25 12:48:45 -06:00
varkor
6461532afa Fix never-type rvalue ICE 2018-01-25 18:03:48 +00:00
Guillaume Gomez
83603b8294 Rollup merge of #47609 - ritiek:test-mutating-references, r=nikomatsakis
NLL test for mutating &mut references

As mentioned in #46361.

cc @nikomatsakis?
2018-01-25 15:52:12 +01:00
bors
247835aacb Auto merge of #47374 - topecongiro:issue-47096, r=nikomatsakis
Simplify irrefutable slice patterns

Closes #47096.
2018-01-25 03:20:54 +00:00
bors
a0a9007f8d Auto merge of #47006 - bitshifter:stabilize-repr-align, r=eddyb
Stabilized `#[repr(align(x))]` attribute (RFC 1358)

Stabilzed `#[repr(align(x))]` with attr_literal syntax as proposed by @eddyb https://github.com/rust-lang/rust/issues/33626#issuecomment-348467804
2018-01-25 00:26:17 +00:00
Marco A L Barbosa
5c5d9ddf64 Add powerpc to run-pass/conditional-compile-arch.rs 2018-01-24 15:16:18 -02:00
Pietro Albini
5faba281ad
Fix ICE when use trees have multiple empty nested groups 2018-01-24 13:13:39 +01:00
bors
fdecb0564b Auto merge of #45337 - Zoxc:gen-static, r=nikomatsakis
Immovable generators

This adds support for immovable generators which allow you to borrow local values inside generator across suspension points. These are declared using a `static` keyword:
```rust
let mut generator = static || {
    let local = &Vec::new();
    yield;
    local.push(0i8);
};
generator.resume();

// ERROR moving the generator after it has resumed would invalidate the interior reference
// drop(generator);
```

Region inference is no longer affected by the types stored in generators so the regions inside should be similar to other code (and unaffected by the presence of `yield` expressions). The borrow checker is extended to pick up the slack so interior references still result in errors for movable generators. This fixes #44197, #45259 and #45093.

This PR depends on [PR #44917 (immovable types)](https://github.com/rust-lang/rust/pull/44917), I suggest potential reviewers ignore the first commit as it adds immovable types.
2018-01-23 22:50:03 +00:00
Alex Crichton
8bde2acfc7 rustc: Add -C lto=val option
This commit primarily adds the ability to control what kind of LTO happens when
rustc performs LTO, namely allowing values to be specified to the `-C lto`
option, such as `-C lto=thin` and `-C lto=fat`. (where "fat" is the previous
kind of LTO, throw everything in one giant module)

Along the way this also refactors a number of fields which store information
about whether LTO/ThinLTO are enabled to unify them all into one field through
which everything is dispatched, hopefully removing a number of special cases
throughout.

This is intended to help mitigate #47409 but will require a backport as well,
and this would unfortunately need to be an otherwise insta-stable option.
2018-01-23 14:13:47 -08:00
ritiek
06d123d4be Remove similar test that does not run the result 2018-01-23 22:45:10 +05:30
John Kåre Alsaker
c166ef9d1b Make immovable generators unsafe 2018-01-23 05:10:38 +01:00
John Kåre Alsaker
ccf0d8399e Adds support for immovable generators. Move checking of invalid borrows across suspension points to borrowck. Fixes #44197, #45259 and #45093. 2018-01-23 05:10:38 +01:00
Cameron Hart
651ea8ea44 Stabilized #[repr(align(x))] attribute (RFC 1358) 2018-01-23 08:36:13 +11:00
Santiago Pastorino
90aef18cb0 Add dynamic-drop test to nll tests also 2018-01-22 15:09:02 -03:00
bors
fdc18b3067 Auto merge of #47353 - nikomatsakis:nll-issue-47189, r=pnkfelix+nmatsakis
renumber regions in generators

This fixes #47189, but I think we still have to double check various things around how to treat generators in MIR type check + borrow check (e.g., what borrows should be invalidated by a `Suspend`? What consistency properties should type check be enforcing anyway around the "interior" type?)

Also fixes #47587 thanks to @spastorino's commit.

r? @pnkfelix
2018-01-22 11:11:47 +00:00
bors
3001ab10b9 Auto merge of #47001 - arielb1:private-match, r=nikomatsakis
check_match: fix handling of privately uninhabited types

the match-checking code used to use TyErr for signaling "unknown,
inhabited" types for a long time. It had been switched to using the
exact type in #38069, to handle uninhabited types.

However, in #39980, we discovered that we still needed the "unknown
inhabited" logic, but I used `()` instead of `TyErr` to handle that.
Revert to using `TyErr` to fix that problem.

Fixes #46964.

r? @nikomatsakis
2018-01-21 12:05:49 +00:00
bors
8d3e93beae Auto merge of #47622 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 10 pull requests

- Successful merges: #46938, #47193, #47508, #47510, #47532, #47535, #47559, #47568, #47573, #47578
- Failed merges:
2018-01-21 06:32:03 +00:00
bors
b85aefbc60 Auto merge of #47495 - nikomatsakis:nll-issue-47153, r=pnkfelix
remove bogus assertion and comments

The code (incorrectly) assumed that constants could not have generics
in scope, but it's not really a problem if they do.

Fixes #47153

r? @pnkfelix
2018-01-21 03:38:34 +00:00
Guillaume Gomez
0e270fc842 Rollup merge of #47193 - cramertj:result-opts, r=TimNN
Add transpose conversions for nested Option and Result

These impls are useful when working with combinator
methods that expect an option or a result, but you
have a `Result<Option<T>, E>` instead of an `Option<Result<T, E>>`
or vice versa.
2018-01-20 22:32:42 +01:00