Commit Graph

1786 Commits

Author SHA1 Message Date
bors
507a46a4aa Auto merge of #47917 - davidtwco:issue-47703, r=nikomatsakis
Fixes NLL: error from URL crate

Fixes #47703.

r? @nikomatsakis
2018-02-17 05:53:55 +00:00
Federico Poli
fe0260fbf8 mir: Gather move at SwitchInt, Assert terminators
Previously, "_1" was not marked as "definitely uninitialized" after a "switchInt(move _1)" terminator.

Related discussion: https://internals.rust-lang.org/t/why-is-2-definitely-initialized-after-switchint-move-2/6760
2018-02-15 15:18:14 +01:00
David Wood
98904c2ecc
Normalizing associated types when checking borrows in drops. 2018-02-14 20:12:28 +00:00
Niko Matsakis
552024a52e
check that types "need drop" before we access them
Also, add some comments and remove extra deref.
2018-02-14 18:17:54 +00:00
David Wood
5fd64dde21
Simplified logic and corrected shallow to deep. 2018-02-14 18:17:53 +00:00
David Wood
e7f328ea57
Handle recursive case of dropping structs with field accesses when struct has no dtor. 2018-02-14 18:17:52 +00:00
David Wood
6493ab6f2a
Fixed incorrect reporting of errors when checking borrows in drops. 2018-02-14 18:16:53 +00:00
kennytm
5a193668db
Rollup merge of #48133 - matthiaskrgr:endianess_to_endianness, r=oli-obk
typo: correct endianess to endianness (this also changes function names!)
2018-02-14 18:25:18 +08:00
bors
16362c737f Auto merge of #47843 - estebank:teach, r=nikomatsakis
Add `-Zteach` documentation

Add extra inline documentation to E0019, E0016, E0013, E0396, E0017,
E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027.

Follow up to #47652.
2018-02-12 09:38:40 +00:00
bors
7f2baba121 Auto merge of #48092 - eddyb:discriminate-the-void, r=nikomatsakis
rustc_mir: insert a dummy access to places being matched on, when building MIR.

Fixes #47412 by adding a `_dummy = Discriminant(place)` before each `match place {...}`.

r? @nikomatsakis
2018-02-11 02:42:19 +00:00
Matthias Krüger
161e8ffda7 typo: correct endianess to endianness (this also changes function names!) 2018-02-11 00:56:24 +01:00
kennytm
1e10ca0b03
Rollup merge of #48078 - alexcrichton:fix-required-const-and-proc-macro, r=eddyb
Disallow function pointers to #[rustc_args_required_const]

This commit disallows acquiring a function pointer to functions tagged as
`#[rustc_args_required_const]`. This is intended to be used as future-proofing
for the stdsimd crate to avoid taking a function pointer to any intrinsic which
has a hard requirement that one of the arguments is a constant value.

Note that the first commit here isn't related specifically to this feature, but was necessary to get this working in stdsimd!
2018-02-10 14:24:04 +08:00
Eduard-Mihai Burtescu
8af134e031 rustc_mir: insert a dummy access to places being matched on, when building MIR. 2018-02-09 23:25:10 +02:00
bors
3bcda48a30 Auto merge of #47802 - bobtwinkles:loop_false_edge, r=nikomatsakis
[NLL] Add false edges out of infinite loops

Resolves #46036 by adding a `cleanup` member to the `FalseEdges` terminator kind. There's also a small doc fix to one of the other comments in `into.rs` which I can pull out in to another PR if desired =)

This PR should pass CI but the test suite has been relatively unstable on my system so I'm not 100% sure.

r? @nikomatsakis
2018-02-09 13:04:17 +00:00
bors
afa8acce25 Auto merge of #47489 - pnkfelix:limit-2pb-issue-46747, r=nikomatsakis
NLL: Limit two-phase borrows to autoref-introduced borrows

This imposes a restriction on two-phase borrows so that it only applies to autoref-introduced borrows.

The goal is to ensure that our initial deployment of two-phase borrows is very conservative. We want it to still cover the `v.push(v.len());` example, but we do not want it to cover cases like `let imm = &v; let mu = &mut v; mu.push(imm.len());`

(Why do we want it to be conservative? Because when you are not conservative, then the results you get, at least with the current analysis, are tightly coupled to details of the MIR construction that we would rather remain invisible to the end user.)

Fix #46747

I decided, for this PR, to add a debug-flag `-Z two-phase-beyond-autoref`, to re-enable the more general approach. But my intention here is *not* that we would eventually turn on that debugflag by default; the main reason I added it was that I thought it was useful for writing tests to be able to write source that looks like desugared MIR.
2018-02-09 02:26:43 +00:00
Alex Crichton
7a20fc14ef Disallow function pointers to #[rustc_args_required_const]
This commit disallows acquiring a function pointer to functions tagged as
`#[rustc_args_required_const]`. This is intended to be used as future-proofing
for the stdsimd crate to avoid taking a function pointer to any intrinsic which
has a hard requirement that one of the arguments is a constant value.
2018-02-08 14:46:27 -08:00
Mikhail Modin
31253d5557 add transform for uniform array move out 2018-02-08 14:27:55 +03:00
Felix S. Klock II
c8041dd8ac Add AutoBorrowMutability; its like hir::Mutability but w/ two-phase borrow info too.
Namely, the mutable borrows also carries a flag indicating whether
they should support two-phase borrows.

This allows us to thread down, from the point of the borrow's
introduction, whether the particular adjustment that created it is one
that yields two-phase mutable borrows.
2018-02-08 12:16:30 +01:00
Felix S. Klock II
1855ab7424 Restrict two-phase borrows to solely borrows introduced via autoref.
Added `-Z two-phase-beyond-autoref` to bring back old behavior (mainly
to allow demonstration of desugared examples).

Updated tests to use aforementioned flag when necessary. (But in each
case where I added the flag, I made sure to also include a revision
without the flag so that one can readily see what the actual behavior
we expect is for the initial deployment of NLL.)
2018-02-08 12:16:30 +01:00
Felix S. Klock II
c00266b7ac Encode (in MIR) whether borrows are explicit in source or arise due to autoref.
This is foundation for issue 46747 (limit two-phase borrows to method-call autorefs).
2018-02-08 12:16:25 +01:00
Esteban Küber
e87e0bcc0e Add -Zteach documentation
Add extra inline documentation to E0019, E0016, E0013, E0396, E0017,
E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027.
2018-02-07 19:41:33 -08:00
bobtwinkles
8e0c3f5c46 [ci skip] Generate false edges from loop_block
As opposed to using weirdness involving pretending the body block
is the loop block. This does not pass tests

This commit is [ci skip] because I know it doesn't pass tests yet.
Somehow this commit introduces nondeterminism into the handling of
loops.
2018-02-07 14:25:08 -05:00
bors
29c8276cee Auto merge of #48053 - Manishearth:rollup, r=Manishearth
Rollup of 10 pull requests

- Successful merges: #47613, #47631, #47810, #47883, #47922, #47944, #48014, #48018, #48020, #48028
- Failed merges:
2018-02-07 17:51:52 +00:00
Manish Goregaokar
993322e886
Rollup merge of #48018 - alexcrichton:require-const-arg, r=eddyb
rustc: Add `#[rustc_args_required_const]`

This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the `constify_*` macros just yet. Hopefully soon though!
2018-02-07 08:30:56 -08:00
bors
fee39ba8bd Auto merge of #47957 - bobtwinkles:fix_mir_consts, r=nikomatsakis
[NLL] Improve DefiningTy::Const

Fixes #47590 by fixing the way DefiningTy represents constants. Previously, constants were represented using just the type of the variable. However, this will fail to capture early-bound regions as NLL inference vars, resulting in an ICE when we try to compute region VIDs a little bit later in the universal
region resolution process. (ref #47590)
2018-02-07 14:54:15 +00:00
bobtwinkles
5de094e579 mir: Fix DefiningTy::Const
Fixes #47590 by fixing the way DefiningTy represents constants. Previously,
constants were represented using just the type of the variable. However, this
will fail to capture early-bound regions as NLL inference vars, resulting in an
ICE when we try to compute region VIDs a little bit later in the universal
region resolution process.
2018-02-06 23:42:05 -05:00
bors
4f93357d3b Auto merge of #47607 - davidtwco:issue-45697, r=nikomatsakis
MIR-borrowck: augmented assignment causes duplicate errors

Fixes #45697. This PR resolves the error duplication. I attempted to replace the existing sets since there were quite a few but only managed to replace two of them.

r? @nikomatsakis
2018-02-07 02:20:23 +00:00
David Wood
5cd4b4fd95
Swapped order of left/right visits to ensure consistency in read/write pass ordering when -O is passed. 2018-02-05 22:31:56 +00:00
bobtwinkles
ed6a2ebcd6 mir: Add false edge cleanup out of infinite loops
Fixes #46036
2018-02-05 15:00:40 -05:00
bobtwinkles
bdc37aa057 mir: Add TerminatorKind::FalseUnwind
Sometimes a simple goto misses the cleanup/unwind edges. Specifically, in the
case of infinite loops such as those introduced by a loop statement without any
other out edges. Analogous to TerminatorKind::FalseEdges; this new terminator
kind is used when we want borrowck to consider an unwind path, but real control
flow should never actually take it.
2018-02-05 15:00:40 -05:00
bobtwinkles
5ca88ae6ae Fix comment in ExprKind::LogicalOp
The comment previously implied that the true branch would result in the false
block. Fortunately the implementation is correct.
2018-02-05 15:00:40 -05:00
Alex Crichton
27a4e73ca5 rustc: Add #[rustc_args_required_const]
This commit adds a new unstable attribute to the compiler which requires that
arguments to a function are always provided as constants. The primary use case
for this is SIMD intrinsics where arguments are defined by vendors to be
constant and in LLVM they indeed must be constant as well.

For now this is mostly just a semantic guarantee in rustc that an argument is a
constant when invoked, phases like trans don't actually take advantage of it
yet. This means that we'll be able to use this in stdsimd but we won't be able
to remove the `constify_*` macros just yet. Hopefully soon though!
2018-02-05 10:58:13 -08:00
bors
b0a396bb0a Auto merge of #47920 - Aaron1011:nll-overflow, r=pnkfelix
Fix overflow when performing drop check calculations in NLL

Clearing out the infcx's region constraints after processing each type
ends up interacting badly with normalizing associated types. This commit
keeps all region constraints intact until the end of
TypeLivenessGenerator.add_drop_live_constraint, ensuring that normalized
types are able to re-use existing inference variables.

Fixes #47589
2018-02-05 09:17:00 +00:00
bors
07ea260407 Auto merge of #47873 - Aaron1011:final-ref-coerce, r=nikomatsakis
Fix ref-to-ptr coercions not working with NLL in certain cases

Implicit coercions from references to pointers were lowered to slightly
different Mir than explicit casts (e.g. 'foo as *mut T'). This resulted
in certain uses of self-referential structs compiling correctly when an
explicit cast was used, but not when the implicit coercion was used.

To fix this, this commit adds an outer 'Use' expr when applying a
raw-ptr-borrow adjustment. This makes the lowered Mir for coercions
identical to that of explicit coercions, allowing the original code to
compile regardless of how the raw ptr cast occurs.

Fixes #47722
2018-02-05 04:32:06 +00:00
bors
dd29d3dd76 Auto merge of #47865 - Manishearth:cleanup-shim, r=nikomatsakis
Cleanup the shim code

 - We now write directly to `RETURN_PLACE` instead of creating intermediates
 - `tuple_like_shim` takes an iterator (used by #47867)
 - `tuple_like_shim` no longer relies on it being the first thing to create blocks, and uses relative block indexing in a cleaner way (necessary for #47867)
 - All the shim builders take `dest, src` arguments instead of hardcoding RETURN_PLACE

r? @eddyb
2018-02-05 01:45:46 +00:00
kennytm
e17ebdf344
Rollup merge of #47892 - Badel2:const_type_id_of, r=oli-obk
Turn `type_id` into a constant intrinsic

https://github.com/rust-lang/rust/issues/27745

The method `get_type_id` in `Any` is intended to support reflection. It's currently unstable in favor of using an associated constant instead. This PR makes the `type_id` intrinsic a constant intrinsic, the same as `size_of` and `align_of`, allowing `TypeId::of` to be a `const fn`, which will allow using an associated constant in `Any`.
2018-02-05 01:27:36 +08:00
kennytm
f3dc75602f
Rollup merge of #47877 - spastorino:lifetime-bounds-in-copy, r=nikomatsakis
Do not ignore lifetime bounds in Copy impls

cc #29149

r? @nikomatsakis
2018-02-04 23:28:54 +08:00
bors
9af374abf9 Auto merge of #47915 - eddyb:layout-of, r=nikomatsakis
rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf.

This PR provides `tcx.layout_of(param_env.and(ty))` as the idiomatic replacement for the existing `(tcx, param_env).layout_of(ty)` and removes fragile (coherence-wise) layout-related tuple impls.

r? @nikomatsakis
2018-02-04 03:33:44 +00:00
bors
3d292b793a Auto merge of #47845 - Zoxc:gen-fixes, r=nikomatsakis
Generator bugfixes

r? @nikomatsakis
2018-02-03 17:28:08 +00:00
Aaron Hill
a7646df923
Remove commented-out code 2018-02-02 14:59:27 -05:00
kennytm
2e3a8f5159
Rollup merge of #47898 - Aaron1011:static-ref-nll, r=nikomatsakis Fix ICE when assigning references to a static mut with NLL is_unsafe_place only filters out statics in the rhs, not the lhs. Since it's possible to reach that 'Place::Static', we handle statics the same way as we do locals. Fixes #47789 2018-02-02 22:48:45 +08:00
Badel2
196fad0d00 Turn type_id into a constant intrinsic
Add rustc_const_unstable attribute for `any::TypeId::of`

Add test for `const fn TypeId::of`
2018-02-01 23:03:19 +01:00
Aaron Hill
0fd4f37944
Fix overflow when performing drop check calculations in NLL
Clearing out the infcx's region constraints after processing each type
ends up interacting badly with normalizing associated types. This commit
keeps all region constraints intact until the end of
TypeLivenessGenerator.add_drop_live_constraint, ensuring that normalized
types are able to re-use existing inference variables.

Fixes #47589
2018-01-31 22:11:50 -05:00
Manish Goregaokar
8a8f91b89e Generalize tuple_like_shim's code to be useful for enums 2018-02-01 08:05:37 +05:30
Manish Goregaokar
dfd244d952 Eliminate ret_field and ret intermediates in array clone shim 2018-02-01 08:05:37 +05:30
Manish Goregaokar
f97629160f Correctly subst the fn_sig so that we get the correct types
Otherwise we get random TySelfs there, which means operations on
RETURN_PLACE end up breaking down badly.
2018-02-01 08:05:37 +05:30
Eduard-Mihai Burtescu
9c3dc7e872 rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. 2018-02-01 00:01:08 +02:00
kennytm
fde67b6ae3 Rollup merge of #47889 - alexcrichton:wasm-hidden-by-default, r=cramertj
rustc: Add an option to default hidden visibility

This commit adds a new option to target specifictions to specify that symbols
should be "hidden" visibility by default in LLVM. While there are no existing
targets that take advantage of this the `wasm32-unknown-unknown` target will
soon start to use this visibility. The LLD linker currently interprets `hidden`
as "don't export this from the wasm module" which is what we want for 90% of our
functions. While the LLD linker does have a "export this symbol" argument which
is what we use for other linkers, it was also somewhat easier to do this change
instead which'll involve less arguments flying around. Additionally there's no
need for non-`hidden` visibility for most of our symbols!

This change should not immediately impact the wasm targets as-is, but rather
this is laying the foundations for soon integrating LLD as a linker for wasm
code.
2018-01-31 16:36:15 +08:00
Aaron Hill
bc8e11b975
Fix ICE when assigning references to a static mut with NLL
is_unsafe_place only filters out statics in the rhs, not the lhs. Since
it's possible to reach that 'Place::Static', we handle statics the same
way as we do locals.

Fixes #47789
2018-01-30 21:44:35 -05:00
Alex Crichton
a2cc5d68a7 rustc: Add an option to default hidden visibility
This commit adds a new option to target specifictions to specify that symbols
should be "hidden" visibility by default in LLVM. While there are no existing
targets that take advantage of this the `wasm32-unknown-unknown` target will
soon start to use this visibility. The LLD linker currently interprets `hidden`
as "don't export this from the wasm module" which is what we want for 90% of our
functions. While the LLD linker does have a "export this symbol" argument which
is what we use for other linkers, it was also somewhat easier to do this change
instead which'll involve less arguments flying around. Additionally there's no
need for non-`hidden` visibility for most of our symbols!

This change should not immediately impact the wasm targets as-is, but rather
this is laying the foundations for soon integrating LLD as a linker for wasm
code.
2018-01-30 13:41:20 -08:00
Santiago Pastorino
b9f756416a Do not ignore lifetime bounds in Copy impls
Closes #29149
2018-01-30 14:00:27 -03:00
Manish Goregaokar
ef4f4864f1 Use dest,src ordering for make_clone_call 2018-01-30 21:09:19 +05:30
Manish Goregaokar
c6140970f5 Remove AggregateKind argument from tuple_like_shim 2018-01-30 21:09:18 +05:30
Manish Goregaokar
7fd3c27345 Write directly to the RETURN_PLACE in tuple_like_shim 2018-01-30 21:09:18 +05:30
Manish Goregaokar
e07aecde48 Make make_clone_call take a Place argument 2018-01-30 21:09:18 +05:30
John Kåre Alsaker
56473562c5 Force locals to be live after they are borrowed for immovable generators. Fixes #47736 2018-01-30 12:50:42 +01:00
John Kåre Alsaker
4325c6375e Allow access of the state field before the generator transform. Fixes #47482, #46476 2018-01-30 11:40:39 +01:00
Aaron Hill
b5f8cd5c20
Fix ref-to-ptr coercions not working with NLL in certain cases
Implicit coercions from references to pointers were lowered to slightly
different Mir than explicit casts (e.g. 'foo as *mut T'). This resulted
in certain uses of self-referential structs compiling correctly when an
explicit cast was used, but not when the implicit coercion was used.

To fix this, this commit adds an outer 'Use' expr when applying a
raw-ptr-borrow adjustment. This makes the lowered Mir for coercions
identical to that of explicit coercions, allowing the original code to
compile regardless of how the raw ptr cast occurs.

Fixes #47722
2018-01-29 23:25:54 -05: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
bors
70f7d5842f Auto merge of #47766 - spastorino:inference-dirty-list, r=nikomatsakis
Make region inference use a dirty list

r? @nikomatsakis
2018-01-29 10:51:07 +00:00
Eduard-Mihai Burtescu
bba81c975d rustc_borrowck: replace "lvalue" terminology with "place" in docs. 2018-01-29 11:48:17 +02:00
John Kåre Alsaker
7a6f68c872 Make error reporting work on generator upvars. Fixes #47793, #47805 2018-01-29 10:02:03 +01:00
Eduard-Mihai Burtescu
46a9bdda78 rustc: replace "lvalue" terminology with "place" in the code. 2018-01-29 01:49:29 +02:00
Eduard-Mihai Burtescu
800166cf96 rustc: remove LvaluePreference argument from Ty::builtin_deref. 2018-01-29 00:42:51 +02: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
David Wood
970fb1a77f
Added logging for error suppression. 2018-01-27 17:16:13 +00:00
David Wood
f92d679b78
Encompassed error deduplication of some existing sets in the ctxt. 2018-01-27 13:33:10 +00:00
David Wood
3daa4d255f
Introduced a new set to stop duplicate errors from MIR passes on one place/span. 2018-01-27 13:33:10 +00:00
David Wood
c71cec8834
end_point handling multibyte characters correctly. 2018-01-27 11:46:27 +00:00
David Wood
c6e6428d1a
Moved overflow check into end_point function. 2018-01-27 11:46:26 +00:00
David Wood
f6fee2a479
Fixed off-by-one spans in MIR borrowck errors. 2018-01-27 11:46:26 +00:00
Niko Matsakis
205eba83e2
pacify the mercilous tidy 2018-01-26 20:51:40 -05:00
Niko Matsakis
b57ca9d97f
change from dirty_bit_vec to clean_bit_vec
Otherwise the vector is initially out of sync
2018-01-26 20:13:51 -05:00
Niko Matsakis
44b666816b
Adjust comment spacing
I suspect the lines would be long for tidy.
2018-01-26 19:58:54 -05:00
Santiago Pastorino
da545cee60 Make region inference use a dirty list
Fixes #47602
2018-01-26 21:56:49 -03:00
varkor
adcb37e275 Add clarifying comment regarding the trailing type of a block 2018-01-26 15:39:19 +00:00
Alex Crichton
31f1aa5706 Rollup merge of #47529 - nikomatsakis:impl-trait-issue-38064, r=cramertj
track recursion limit when expanding existential impl trait

r? @cramertj
2018-01-25 12:48:51 -06:00
Alex Crichton
3b2403306f Rollup merge of #47415 - varkor:cgu-partition-heuristic, r=michaelwoerister
Add CGU size heuristic for partitioning

This addresses the concern of #47316 by estimating CGU size based on
the size of its MIR. Looking at the size estimate differences for a
small selection of crates, this heuristic produces different orderings,
which should more accurately reflect optimisation time. (Fixes #47316.)

r? @michaelwoerister
2018-01-25 12:48:44 -06:00
varkor
6461532afa Fix never-type rvalue ICE 2018-01-25 18:03:48 +00: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
John Kåre Alsaker
55c6c88782 Port borrows across yield check to MIR borrowck 2018-01-23 05:10:39 +01:00
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
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
bc072ed0ca Auto merge of #47144 - estebank:moved-closure-arg, r=nikomatsakis
Custom error when moving arg outside of its closure

When given the following code:

```rust
fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) {
    f(&());
}

fn main() {
    let mut x = None;
    give_any(|y| x = Some(y));
}
```

provide a custom error:

```
error: borrowed data cannot be moved outside of its closure
 --> file.rs:7:27
  |
6 |     let mut x = None;
  |         ----- borrowed data cannot be moved into here...
7 |     give_any(|y| x = Some(y));
  |              ---          ^ cannot be moved outside of its closure
  |              |
  |              ...because it cannot outlive this closure
```

instead of the generic lifetime error:

```
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
 --> file.rs:7:27
  |
7 |     give_any(|y| x = Some(y));
  |                           ^
  |
note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:14...
 --> file.rs:7:14
  |
7 |     give_any(|y| x = Some(y));
  |              ^^^^^^^^^^^^^^^
note: ...so that expression is assignable (expected &(), found &())
 --> file.rs:7:27
  |
7 |     give_any(|y| x = Some(y));
  |                           ^
note: but, the lifetime must be valid for the block suffix following statement 0 at 6:5...
 --> file.rs:6:5
  |
6 | /     let mut x = None;
7 | |     give_any(|y| x = Some(y));
8 | | }
  | |_^
note: ...so that variable is valid at time of its declaration
 --> file.rs:6:9
  |
6 |     let mut x = None;
  |         ^^^^^
```

Fix #45983.
2018-01-22 05:30:37 +00:00
bors
9368a1e3e2 Auto merge of #45684 - bjorn3:runtime_choose_trans2, r=eddyb
Allow runtime switching between trans backends

The driver callback after_llvm has been removed as it doesnt work with multiple backends.

r? @eddyb
2018-01-21 09:17:26 +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
bors
15a1e2844d Auto merge of #46980 - zackmdavis:and_the_case_of_the_needlessly_parenthesized_arguments, r=petrochenkov
in which the unused-parens lint comes to cover function and method args

Resolves #46137.
2018-01-20 15:06:41 +00:00
Santiago Pastorino
fcb9e928b7 Integrate generators to universal region setup 2018-01-19 21:32:43 -05:00
Niko Matsakis
5d259b23a4 change MIR dump format to include yield type 2018-01-19 21:31:35 -05:00
bjorn3
74c92c5562 Allow runtime switching between trans backends 2018-01-19 20:27:10 +01:00
bors
5965b79014 Auto merge of #47503 - arielb1:check-size, r=eddyb
avoid double-unsizing arrays in bytestring match lowering

The match lowering code, when lowering matches against bytestrings,
works by coercing both the scrutinee and the pattern to `&[u8]` and
then comparing them using `<[u8] as Eq>::eq`.

If the scrutinee is already of type `&[u8]`, then unsizing it is both
unneccessary and a trait error caught by the new and updated MIR typeck,
so this PR changes lowering to avoid doing that (match lowering tried to
avoid that before, but that attempt was quite broken).

Fixes #46920.

r? @eddyb
2018-01-19 10:18:52 +00:00
varkor
c8e9da44a9 Update comments about the partitioning inefficiency 2018-01-19 00:42:14 +00:00
varkor
e60b0f802b Refactor CodegenUnit size estimates 2018-01-19 00:41:50 +00:00
varkor
8447f4fc0f Add CGU size heuristic for partitioning
This addresses the concern of #47316 by estimating CGU size based on
the size of its MIR. Looking at the size estimate differences for a
small selection of crates, this heuristic produces different orderings,
which should more accurately reflect optimisation time.

Fixes #47316.
2018-01-19 00:41:21 +00:00
Zack M. Davis
14982db2d6 in which the unused-parens lint comes to cover function and method args
Resolves #46137.
2018-01-18 08:33:58 -08:00
Niko Matsakis
072c3daa4c track recursion limit when expanding existential impl trait 2018-01-17 18:01:17 -05:00
kennytm
be916ce584 Rollup merge of #47467 - arielb1:cleanup-shims, r=eddyb
remove noop landing pads in cleanup shims

No-op landing pads are already removed in the normal optimization pipeline - so also removing them on the shim pipeline should slightly improve codegen performance, as these cleanup blocks are known to hurt LLVM.

This un-regresses and is therefore a fix for #47442. However, the reporter of that issue should try using `-C panic=abort` instead of carefully avoiding panics.

r? @eddyb
2018-01-18 01:57:23 +08:00
kennytm
01749e1b34 Rollup merge of #47426 - varkor:default-mir-dump-dir, r=nikomatsakis
Add a default directory for -Zmir-dump-dir

The current behaviour of dumping in the current directory is rarely
desirable: a sensible default directory for dumping is much more
convenient. This makes sets the default value for `-Zmir-dump-dir`
to `mir_dump/`.

r? @eddyb
2018-01-18 01:57:17 +08:00
Seiichi Uchida
604a54f3d9 Simplify irrefutable slice patterns
Closes #47096.
2018-01-17 12:22:17 +09:00
Ariel Ben-Yehuda
06e32d044d avoid double-unsizing arrays in bytestring match lowering
The match lowering code, when lowering matches against bytestrings,
works by coercing both the scrutinee and the pattern to `&[u8]` and
then comparing them using `<[u8] as Eq>::eq`.

If the scrutinee is already of type `&[u8]`, then unsizing it is both
unneccessary and a trait error caught by the new and updated MIR typeck,
so this PR changes lowering to avoid doing that (match lowering tried to
avoid that before, but that attempt was quite broken).

Fixes #46920.
2018-01-16 23:23:11 +02:00
Niko Matsakis
3b390e5420 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.
2018-01-16 12:45:39 -05:00
Ariel Ben-Yehuda
dc44d41b98 remove noop landing pads in cleanup shims
These are already removed in the normal optimization pipeline - so this
should slightly improve codegen performance, as these cleanup blocks are
known to hurt LLVM.

This un-regresses and is therefore a fix for #47442. However, the
reporter of that issue should try using `-C panic=abort` instead of
carefully avoiding panics.
2018-01-16 00:07:06 +02:00
Esteban Küber
1820da5211 Move diagnostic logic to its own module
- Move specialized borrow checker diagnostic for bindings escaping its
  closure to its own module.
- Move affected tests to `ui`.
2018-01-15 11:12:25 -08:00
varkor
2ccc82e27e Make dump_mir_dir non-optional 2018-01-14 20:02:07 +00:00
bors
adc9d86363 Auto merge of #47322 - nikomatsakis:nll-ice, r=pnkfelix
resolve type and region variables in "NLL dropck"

Fixes #47022.

r? @pnkfelix
2018-01-14 14:11:59 +00:00
bors
fd0f29237c Auto merge of #47261 - estebank:immutable-arg, r=petrochenkov
Assignment to immutable argument: diagnostic tweak

Re #46659.
2018-01-14 06:09:14 +00:00
leonardo.yvens
f93183adb4 Remove impl Foo for .. in favor of auto trait Foo
No longer parse it.
Remove AutoTrait variant from AST and HIR.
Remove backwards compatibility lint.
Remove coherence checks, they make no sense for the new syntax.
Remove from rustdoc.
2018-01-13 18:48:00 +03:00
Eduard-Mihai Burtescu
121499a119 Don't promote to 'static the result of dereferences. 2018-01-13 11:10:07 +02:00
kennytm
7ffdabd401 Rollup merge of #47328 - mbrubeck:fs_read, r=sfackler
Use the new fs_read_write functions in rustc internals

Uses `fs::read` and `fs::write` (added by #45837) where appropriate, to simplify code and dog-food these new APIs.  This also improves performance, when combined with #47324.
2018-01-13 02:26:35 +08:00
Alexander Regueiro
e2c1a9393b Don't track local_needs_drop separately in qualify_consts (fixes #47351). 2018-01-11 20:13:06 +00:00
Niko Matsakis
d201e83f71 renumber regions in the generator interior
Fixes #47189.
2018-01-11 06:05:05 -05:00
Niko Matsakis
bf02c57b16 simplify UniversalRegions::to_region_vid to just consult the map
This doesn't actually fix the bug, but seems better.
2018-01-11 06:05:05 -05:00
Matt Brubeck
3f9c057ea6 Use the new fs_read_write functions in rustc internals 2018-01-10 14:53:40 -08:00
Esteban Küber
90bc98c5d1 Modify message to match label 2018-01-10 11:41:12 -08:00
Niko Matsakis
00ce7eed7d resolve type and region variables in "NLL dropck"
Fixes #47022.
2018-01-10 10:15:08 -05:00
bors
61452e506f Auto merge of #47269 - michaelwoerister:mangled-cgu-names, r=alexcrichton
Shorten names of some compiler generated artifacts.

This PR makes the compiler mangle codegen unit names by default. The name of every codegen unit name will now be a random string of 16 characters. It also makes the file extensions of some intermediate compiler products shorter. Hopefully, these changes will reduce the pressure on tools with path length restrictions like buildbot. The change should also solve problems with case-insensitive file system.

cc #47186 and #47222

r? @alexcrichton
2018-01-09 16:04:21 +00:00
kennytm
6648dcd353
Rollup merge of #47258 - rkruppe:struct-assert, r=eddyb
rustc::ty: Rename struct_variant to non_enum_variant

r? @eddyb
2018-01-09 03:37:16 +08:00
Michael Woerister
94f3037f4b Shorten names of some compiler generated artifacts. 2018-01-08 12:30:52 +01:00
bors
795594cd8c Auto merge of #47200 - BurntPizza:query-snatp, r=nikomatsakis
Make normalize_and_test_predicates into a query

From #44891.

I'm not real solid on how `dep_graph` stuff works, but if a node is going to have a key (again, not sure how important that is), then the key needs to be `Copy`. So since `normalize_and_test_predicates` only had one out-of-module use, I changed that call site to use a new function, `substitute_normalize_and_test_predicates` which is the query and enables having the arguments be `Copy`. Hopefully this makes sense.

r? @nikomatsakis
and/or @michaelwoerister
2018-01-08 04:31:18 +00:00
Esteban Küber
18908184de Assignment to immutable argument: diagnostic tweak 2018-01-07 19:00:45 -08:00
Robin Kruppe
cf3fefe97f rustc::ty: Rename struct_variant to non_enum_variant
It is also intended for use with unions.
2018-01-08 00:28:05 +01:00
Malo Jaffré
3f073c409a Try to fix a perf regression by updating log
Upgrade `log` to `0.4` in multiple crates.
2018-01-07 16:54:05 +01:00
kennytm
c6bf11cf2b Rollup merge of #47205 - eddyb:alloc-id, r=oli-obk
miri: use AllocId instead of u64.

This makes @alexreg's miri allocation -> LLVM global translation more straight-forward.

r? @oli-obk
2018-01-07 02:36:04 +08:00
kennytm
b63f89783d Rollup merge of #47170 - eddyb:us-vs-usize, r=nikomatsakis
rustc: use {U,I}size instead of {U,I}s shorthands.

`Us`/`Is` come from a time when `us` and `is` were the literal suffixes that are now `usize` / `isize`.

r? @nikomatsakis
2018-01-07 02:36:02 +08:00
bors
72176cf96c Auto merge of #47141 - alexcrichton:bump-bootstrap, r=alexcrichton
Bump to 1.25.0

* Bump the release version to 1.25
* Bump the bootstrap compiler to the recent beta
* Allow using unstable rustdoc features on beta - this fix has been applied to
  the beta branch but needed to go to the master branch as well.
2018-01-06 14:50:14 +00:00
Eduard-Mihai Burtescu
0907494ae1 miri: use AllocId instead of u64. 2018-01-05 05:12:38 +02:00
Alex Crichton
8c9bf663d4 rustc: Don't use relative paths for extended errors
These no longer work now that Cargo changes the cwd of rustc while it's running.
Instead use an absolute path that's set by rustbuild.
2018-01-04 07:21:22 -08:00
bors
8e7a609e63 Auto merge of #46916 - michaelwoerister:generate-dead-code-plz, r=alexcrichton
Generate code for unused const- and inline-fns if -Clink-dead-code is specified.

Fixes https://github.com/rust-lang/rust/issues/46467.

r? @alexcrichton
2018-01-04 14:04:27 +00:00
Michael Woerister
238ed47d29 Generate code for const- and inline-fns if -Clink-dead-code is specified. 2018-01-04 10:12:20 +01:00
bors
78f24d86b8 Auto merge of #47124 - estebank:loan-paths, r=nikomatsakis
Reword reason for move note

On move errors, when encountering an enum variant, be more ambiguous and do not refer to the type on the cause note, to avoid referring to `(maybe as std::prelude::v1::Some).0`, and instead refer to `the value`.

Sidesteps part of the problem with #41962:

```
error[E0382]: use of partially moved value: `maybe`
 --> file.rs:5:30
  |
5 |         if let Some(thing) = maybe {
  |                     -----    ^^^^^ value used here after move
  |                     |
  |                     value moved here
  = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0`
 --> file.rs:5:21
  |
5 |         if let Some(thing) = maybe {
  |                     ^^^^^ value moved here in previous iteration of loop
  = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait

error: aborting due to 2 previous errors
```

Previous discussion: #44360

r? @arielb1
2018-01-04 05:52:39 +00:00
Eduard-Mihai Burtescu
210ac01792 rustc: use {U,I}size instead of {U,I}s shorthands. 2018-01-04 03:12:04 +02:00
Esteban Küber
a4d46b3d87 Tweak to mir borrow in a loop diagnostic 2018-01-03 14:13:32 -08:00
bors
0a3761e63e Auto merge of #46984 - arielb1:pre-statement-effect, r=nikomatsakis
NLL fixes

First, introduce pre-statement effects to dataflow to fix #46875. Edge dataflow effects might make that redundant, but I'm not sure of the best way to integrate them with liveness etc., and if this is a hack, this is one of the cleanest hacks I've seen.

And I want a small fix to avoid the torrent of bug reports.

Second, fix linking of projections to fix #46974

r? @pnkfelix
2018-01-03 21:06:21 +00:00
Malo Jaffré
cbb32a9418 Fix docs for future pulldown migration 2018-01-01 14:44:12 +01:00
bors
5f7aeaf6e2 Auto merge of #47013 - topecongiro:issue-46655, r=petrochenkov
Do not expand a derive invocation when derive is not allowed

Closes #46655.

The first commit is what actually closes #46655. The second one is just a refactoring I have done while waiting on a test.
2017-12-28 06:45:31 +00:00
Seiichi Uchida
d882691046 Prefer to use attr::contains_name() and attr::find_by_name() 2017-12-28 12:32:24 +09:00
BurntPizza
766465f0e5 Make normalize_and_test_predicates into a query 2017-12-27 12:32:44 -05:00
bors
bfbb1f5ce1 Auto merge of #46479 - bkchr:termination_trait, r=arielb1
Implements RFC 1937: `?` in `main`

This is the first part of the RFC 1937 that supports new
`Termination` trait in the rust `main` function.

Thanks @nikomatsakis, @arielb1 and all other people in the gitter channel for all your help!

The support for doctest and `#[test]` is still missing, bu as @nikomatsakis said, smaller pull requests are better :)
2017-12-27 15:41:51 +00:00
Alex Crichton
2cdd1c4df3 rustc: Switch start_fn to hidden visibility
This'll avoid exporting a symbol from binaries unnecessarily and should help the
linker clean things up if it can.
2017-12-26 14:26:03 -08:00
bors
cddc4a62d8 Auto merge of #46975 - matthewjasper:mir-moveck-asm, r=arielb1
[MIR Borrowck] Moveck inline asm statements

Closes #45695

New behavior:
* Input operands to `asm!` are moved, direct output operands are initialized.
* Direct, non-read-write outputs match the assignment changes in #46752 (Shallow writes, end borrows).
2017-12-26 20:47:31 +00:00
Bastian Köcher
c2f22f01a9 Adds whitespace 2017-12-26 12:26:39 +01:00
Bastian Köcher
99a108c036 Fixes compilation errors and adds proposed improvements 2017-12-26 12:26:39 +01:00
Bastian Köcher
011c9eac35 Fixes compile bug caused by upstream changes 2017-12-26 12:26:39 +01:00
Bastian Köcher
d7918fb2e8 Implements RFC 1937: ? in main
This is the first part of the RFC 1937 that supports new
`Termination` trait in the rust `main` function.
2017-12-26 12:26:39 +01:00
bors
b159eeb6b9 Auto merge of #46949 - davidtwco:issue-46631, r=arielb1
MIR borrowck: no "move occurs because `X` is not Copy` error

Fixes #46631.

r? @arielb1
2017-12-25 10:07:28 +00:00
bors
000fbbc9b8 Auto merge of #46896 - arielb1:shadow-scope, r=eddyb
fix debuginfo scoping of let-statements

r? @eddyb
2017-12-24 15:26:17 +00:00
Ariel Ben-Yehuda
bd1bd76cd8 fix linking of place projections
projections other than dereferences of `&mut` used to do no linking. Fix
that.

Fixes #46974.
2017-12-24 14:56:52 +02:00
Ariel Ben-Yehuda
17d4e9be2a Make killing of out-of-scope borrows a pre-statement effect
Fixes #46875.
Fixes #46917.
Fixes #46935.
2017-12-24 14:56:52 +02:00
Ariel Ben-Yehuda
063b998950 add pre-statement-effect to dataflow 2017-12-24 14:56:52 +02:00
bors
51b47dc4a1 Auto merge of #46833 - diwic:7c-abort-ffi, r=arielb1
Prevent unwinding past FFI boundaries

Second attempt to write a patch to solve this.

r? @nikomatsakis

~~So, my biggest issue with this patch is the way the patch determines *what* functions should have an abort landing pad (in `construct_fn`). I would ideally have this code match [src/librustc_trans/callee.rs::get_fn](https://github.com/rust-lang/rust/blob/master/src/librustc_trans/callee.rs#L107-L115) but couldn't find an id that returns true for `is_foreign_item`. Also tried `tcx.has_attr("unwind")` with no luck.~~ FIXED

Other issues:

 * llvm.trap is an SIGILL on amd64. Ideally we could use panic-abort's version of aborting which is nicer but we don't want to depend on that library...

 * ~~Mir inlining is a stub currently.~~ FIXED (no-op)

Also, when reviewing please take into account that I'm new to the code and only partially know what I'm doing... and that I've mostly made made matches on `TerminatorKind::Abort` match either `TerminatorKind::Resume` or `TerminatorKind::Unreachable` based on what looked best.
2017-12-24 02:42:15 +00:00
Matthew Jasper
1a308ba90a Give MIR borrowck a better understanding of inline asm 2017-12-23 23:45:07 +00:00
David Wood
3dfe256b5f
Added 'move occurs because X is not Copy' note. 2017-12-22 15:01:47 +00:00
bors
264af16757 Auto merge of #46752 - Yoric:nll, r=arielb1
Issue #46589 - Kill borrows on a local variable whenever we assign ov…

…er this variable

This is a first patch for the issue, handling the simple case while I figure out the data structures involved in the more complex cases.
2017-12-22 09:54:21 +00:00
bors
ba2741594b Auto merge of #46922 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

- Successful merges: #46636, #46780, #46784, #46809, #46814, #46820, #46839, #46847, #46858, #46878, #46884, #46890, #46898, #46918
- Failed merges:
2017-12-21 23:01:27 +00:00
kennytm
0787ad9261
Rollup merge of #46918 - alexcrichton:fix-ordering, r=michaelwoerister
rustc: Sort CGUs before merging

This commit fixes some nondeterminism in compilation when using multiple codegen
units. The algorithm for splitting codegen units currently takes the
otherwise-would-be-for-incremental partitioning and then continuously merges the
two smallest codegen units until the desired number of codegen units are
reached.

We want to be sure to merge the same codegen units each time a compilation is
run but there's some subtle reorderings amongst all the items which was causing
this step to be slightly buggy. Notably this step involves sorting codegen units
by size, but if two codegen units had the same size they would appear in
different locations in the list each time.

This commit fixes this issue by sorting codegen units by name before doing the
loop to merge the two smallest. This means that we've got a deterministic
order going in and since we're using a stable sort this should mean that we're
always now getting a deterministic merging of codegen units.

Closes #46846
2017-12-22 05:00:41 +08:00
bors
250b492052 Auto merge of #45930 - jplatte:generics_refactoring, r=eddyb
Generics refactoring (groundwork for const generics)

These changes were suggested by @eddyb.

After this change, the `Generics` contain one `Vec` of an enum for the generic parameters, rather than two separate `Vec`s for lifetime and type parameters. Type params and const params will need to be in a shared `Vec` to preserve their ordering, and moving lifetimes into the same `Vec` should simplify the code that processes `Generics`.
2017-12-21 20:12:13 +00:00
David Henningsson
4910ed2b1e Mir: fixup nits in previous commit (f536143)
As suggested by arielb1.

Closes rust-lang/rust#18510

Signed-off-by: David Henningsson <diwic@ubuntu.com>
2017-12-21 19:36:53 +01:00
David Teller
fcb10908b0 Issue #46589 - Kill borrows on a local variable whenever we assign over this variable 2017-12-21 18:35:59 +01:00
Alex Crichton
427e6308bc rustc: Sort CGUs before merging
This commit fixes some nondeterminism in compilation when using multiple codegen
units. The algorithm for splitting codegen units currently takes the
otherwise-would-be-for-incremental partitioning and then continuously merges the
two smallest codegen units until the desired number of codegen units are
reached.

We want to be sure to merge the same codegen units each time a compilation is
run but there's some subtle reorderings amongst all the items which was causing
this step to be slightly buggy. Notably this step involves sorting codegen units
by size, but if two codegen units had the same size they would appear in
different locations in the list each time.

This commit fixes this issue by sorting codegen units by name before doing the
loop to merge the two smallest. This means that we've got a deterministic
order going in and since we're using a stable sort this should mean that we're
always now getting a deterministic merging of codegen units.

Closes #46846
2017-12-21 09:06:52 -08:00
bors
b7b52cc8bf Auto merge of #46877 - Deewiant:gh46843, r=eddyb
MIR: terminate unreachable blocks in construct_const

Fixes #46843.

#45821 added unreachable blocks in matches, which were terminated in
construct_fn but not in construct_const, causing a panic due to "no
terminator on block" when constants involved matching on enums.

The "unimplemented expression type" error may go away in the future, the
key is that we see the E0015 about using a non-const function and then
don't ICE.
2017-12-21 16:15:16 +00:00
Jonas Platte
78493ed21a Add GenericParam, refactor Generics in ast, hir, rustdoc
The Generics now contain one Vec of an enum for the generic parameters,
rather than two separate Vec's for lifetime and type parameters.

Additionally, places that previously used Vec<LifetimeDef> now use
Vec<GenericParam> instead.
2017-12-21 13:38:10 +01:00
Ariel Ben-Yehuda
9be593032d fix debuginfo scoping of let-statements 2017-12-21 14:25:17 +02:00
Guillaume Gomez
bdd3f5b240 Rollup merge of #46887 - pnkfelix:ensure-activations-are-from-assignments-to-locals, r=arielb1
Ensure separate activations only occur for assignments to locals

Ensure separate activations only occur for assignments to locals, not projections.

Fix #46746.

(I didn't make a regression test because we do not really have a good way to directly express the case that we are trying to catch, because we cannot write MIR directly.)
2017-12-21 13:18:21 +01:00
David Henningsson
f536143ab6 Mir: Abort on nounwind ABIs
Generate Abort instead of Resume terminators on nounwind ABIs.

https://github.com/rust-lang/rust/issues/18510

Signed-off-by: David Henningsson <diwic@ubuntu.com>
2017-12-21 04:43:35 +01:00
David Henningsson
dd6127e4af Mir: Add Terminatorkind::Abort
The Abort Terminatorkind will cause an llvm.trap function call to be
emitted.

Signed-off-by: David Henningsson <diwic@ubuntu.com>
2017-12-21 04:43:27 +01:00
Niko Matsakis
d925f4d1dd fix truncated comment 2017-12-20 16:51:33 -05:00
Niko Matsakis
cfa4ffa374 document and tweak the nll, use_mir, etc helpers
In particular, -Znll might as well imply -Zborrowck=mir by default,
just like `#![feature(nll)]` does.

Also, if NLL is in use, no reason to emit end regions. The NLL pass
just strips them out anyway.
2017-12-20 14:38:13 -05:00
Santiago Pastorino
e980fb8bef feature nll implies borrowck=mir 2017-12-20 14:38:13 -05:00
Santiago Pastorino
2019d69f61 feature nll implies two-phase-borrows 2017-12-20 14:38:13 -05:00
Santiago Pastorino
0b2db1e616 Add nll feature and make nll imply nll_dump_cause 2017-12-20 14:38:12 -05:00
Santiago Pastorino
95b6148e31 Add nll_dump_cause helper to Session 2017-12-20 14:38:12 -05:00
Niko Matsakis
508a831dca use report_generic_bound_failure when we can in the compiler 2017-12-20 14:38:12 -05:00
Niko Matsakis
6b39781df6 connect NLL machinery to the NiceRegionError code 2017-12-20 14:38:12 -05:00
Niko Matsakis
e28d03f38b only dump causes if we have nothing better 2017-12-20 14:38:11 -05:00
Santiago Pastorino
3a185a510d Add three point error handling to borrowck
Closes #45988
2017-12-20 14:38:10 -05:00
Niko Matsakis
6d2987ca03 Move categorize logic out of visit_local function 2017-12-20 14:38:10 -05:00
Santiago Pastorino
58b0506d65 Move MirVisitable to visit.rs 2017-12-20 14:38:10 -05:00
Niko Matsakis
93afb1affc connect NLL type checker to the impl trait code
We now add the suitable `impl Trait` constraints.
2017-12-20 14:04:52 -05:00
Niko Matsakis
da63aaa7ab extract input_output code into its own module
No functional change.
2017-12-20 14:04:52 -05:00
Niko Matsakis
a66c6512aa pass UniversalRegions to MIR type-checker instead of fields
No functional change.
2017-12-20 14:04:52 -05:00
Niko Matsakis
4a967c9df7 propagate region_bound_pairs into MIR type-check 2017-12-20 14:04:51 -05:00
Niko Matsakis
fe89f4ba86 get the DefiningTy from the body_owner_kind not type
The type isn't a good idea because we want to treat constants
uniformly, regardless of what type of value they produce.
2017-12-20 14:04:51 -05:00
Niko Matsakis
0e64a756f8 integrate -Znll-dump-cause into borrowck 2017-12-20 14:04:51 -05:00
Niko Matsakis
741ef41e41 use Rc to store nonlexical_regioncx in Borrows 2017-12-20 14:04:51 -05:00
Niko Matsakis
594c386549 dump out causal information for "free region" errors
The result is not especially illuminating, but that's ok.
2017-12-20 14:04:51 -05:00
Niko Matsakis
39b0e49ebd rustfmt: borrow_check/mod.rs 2017-12-20 14:04:51 -05:00
Paul Daniel Faria
e447b54bc3 Add tracking of causes for nll 2017-12-20 14:04:50 -05:00
Niko Matsakis
f6741d0a7a region_infer/values.rs: rustfmt 2017-12-20 14:04:50 -05:00
Felix S. Klock II
a0e1d509ab Ensure separate activations only occur for assignments to locals, not projections.
Fix #46746.
2017-12-20 18:15:33 +01:00
Matti Niemenmaa
8dfc47a4c9 MIR: terminate unreachable blocks in construct_const
Fixes #46843.

#45821 added unreachable blocks in matches, which were terminated in
construct_fn but not in construct_const, causing a panic due to "no
terminator on block" when constants involved matching on enums.

The "unimplemented expression type" error may go away in the future, the
key is that we see the E0015 about using a non-const function and then
don't ICE.
2017-12-20 15:37:17 +02:00
kennytm
5efa045bbe Rollup merge of #46852 - scottmcm:asm-placecontext, r=arielb1
Split PlaceContext::Store into Store & AsmOutput

Outputs in InlineAsm can be read-write, so splitting it out is useful for things like Store-Store folding, as that's unsound for a Store-AsmOutput.

This PR is intended to make no changes, just be the mechanical split of the enum.  Future changes can use the split, like a MIR pass I'm working on and perhaps two-phase borrows (see this FIXME: https://github.com/rust-lang/rust/pull/46852/files#diff-74dcd7740ab2104cd2b9a3b68dd4f208R543)
2017-12-20 21:22:03 +08:00
bors
588f7db8ef Auto merge of #46733 - nikomatsakis:nll-master-to-rust-master-5, r=arielb1
nll part 5

Next round of changes from the nll-master branch.

Extensions:

- we now propagate ty-region-outlives constraints out of closures and into their creator when necessary
- we fix a few ICEs that can occur by doing liveness analysis (and the resulting normalization) during type-checking
- we handle the implicit region bound that assumes that each type `T` outlives the fn body
- we handle normalization of inputs/outputs in fn signatures

Not included in this PR (will come next):

- handling `impl Trait`
- tracking causal information
- extended errors

r? @arielb1
2017-12-20 03:58:15 +00:00
Scott McMurray
fb245e0540 Split PlaceContext::Store into Store & AsmOutput
Outputs in InlineAsm can be read-write, so splitting it out is useful for things like Store-Store folding, as it cannot be done for a Store-AsmOutput.

This PR is intended to make no changes, just be the mechanical split of the enum.  Future changes can use the split, like a MIR pass I'm working on and perhaps two-phase borrows.
2017-12-19 17:05:14 -05:00
Niko Matsakis
1816ede386 be specific about what kind of normalization we mean 2017-12-19 04:28:45 -05:00
Niko Matsakis
3d826e5681 remove dead is_foo_free_region helpers
Only `is_local_free_region` is used.
2017-12-19 04:26:56 -05:00
Niko Matsakis
3c56c3610e fix comment on check_type_tests 2017-12-19 04:21:57 -05:00
Niko Matsakis
03bfb0f316 tweak comment on TypeTest to be more accurate 2017-12-19 04:18:15 -05:00
bors
c8b94c6aa1 Auto merge of #46829 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 11 pull requests

- Successful merges: #46700, #46786, #46790, #46800, #46801, #46802, #46804, #46805, #46812, #46824, #46825
- Failed merges:
2017-12-19 04:21:05 +00:00
Esteban Küber
e1dc7ac33c Tweak "unecessary unsafe block" error spans 2017-12-18 11:11:35 -08:00
Maik Klein
c847cf3f5e Fix incorrect rebase in collector::find_vtable_types 2017-12-18 19:10:01 +02:00
Ariel Ben-Yehuda
f6fcfa3915 normalize the results of tcx.type_of after substituting
Also remove `def_ty`, which was a footgun because it did not do the
above.
2017-12-18 17:08:50 +02:00
Maik Klein
b48ba026fe Rename more functions from trans to monomorphize 2017-12-18 17:08:49 +02:00
Maik Klein
d4b372d6e2 Rename trans to monomorphize in comments 2017-12-18 17:08:49 +02:00
Maik Klein
45f8a3b30c Move partitioning.rs to rustc_mir 2017-12-18 17:08:49 +02:00
Maik Klein
6e94a7a91e Remove branch with has_metadata 2017-12-18 17:08:49 +02:00
Maik Klein
7996f63ce4 Move meta_data into TyS 2017-12-18 17:08:49 +02:00
Maik Klein
dfbb6e8640 Move instance related methods from TyCtxt to Instance 2017-12-18 17:08:49 +02:00
Maik Klein
d3c4142880 Fix some comments to refer to MonoItem 2017-12-18 17:08:49 +02:00
Maik Klein
c06e3aa446 Refactor paths to middle::trans to mir::mono 2017-12-18 17:08:49 +02:00
Maik Klein
09ad6ebd0b Rename mono_item.rs to item.rs 2017-12-18 17:08:49 +02:00
Maik Klein
28f7d223f4 Rename as_trans_item to as_mono_item 2017-12-18 17:08:49 +02:00
Maik Klein
17bfd74955 Rename more functions from trans to mono 2017-12-18 17:08:48 +02:00
Maik Klein
b9ab487a7a Rename TransItemExt to MonoItemExt 2017-12-18 17:08:48 +02:00
Maik Klein
531c27d805 Move common.rs functionality into TyCtxt 2017-12-18 17:08:48 +02:00
Maik Klein
98b9eba316 Rename TransItemCollectionMode to MonoItemCollectionMode 2017-12-18 17:08:48 +02:00
Maik Klein
1181f45813 Rename TransItem to MonoItem 2017-12-18 17:08:48 +02:00
Maik Klein
e579b067db Move trans_item and monomorphize to rustc_mir 2017-12-18 17:08:48 +02:00
Maik Klein
094c021218 Move collector to monomorphize 2017-12-18 17:08:48 +02:00
Eduard-Mihai Burtescu
7dc79cc49b miri: pass pointer alignments directly instead of contextually. 2017-12-17 16:34:54 +02:00
Eduard-Mihai Burtescu
08646c6c2c miri: use separate Pointer and Align instead of PtrAndAlign. 2017-12-17 16:34:54 +02:00
Eduard-Mihai Burtescu
ff080d389d miri: track the Align instead of packedness in PtrAndAlign. 2017-12-17 16:34:54 +02:00
Eduard-Mihai Burtescu
7c6f242ca8 rustc: don't track whether layouts are "packed". 2017-12-17 16:34:54 +02:00
bors
4f2ef415ba Auto merge of #46743 - oli-obk:miri, r=eddyb
Some miri cleanups

r? @eddyb
2017-12-16 16:16:16 +00:00
bors
00fbfcce96 Auto merge of #46719 - estebank:issue-39268, r=pnkfelix
Point at var in short lived borrows instead of drop location

For RLS' sake, point at the borrow location as primary span for short lived borrows, instead of the borrow drop location.

Fix #39268.
2017-12-16 06:31:35 +00:00
Niko Matsakis
4f43c5b1e7 stop dumping DefPath into "failed type test" errors
The prior messages were not stable across platforms.
2017-12-15 17:04:48 -05:00
Esteban Küber
b562565b09 Same change to point at borrow for mir errors 2017-12-15 13:52:05 -08:00
Oliver Schneider
2d161f10e5
Allow easily creating cheap eval context instances 2017-12-15 16:56:58 +01:00
Niko Matsakis
0f8ef0ca1a more concise debug output when dumping the value of a region 2017-12-15 10:27:54 -05:00
Niko Matsakis
0d6bd42abb make blame_span deterministic 2017-12-15 10:27:54 -05:00
Niko Matsakis
e9824c50ed impose inputs/ouputs on MIR after the fact
The input/output types found in `UniversalRegions` are not normalized.
The old code used to assign them directly into the MIR, which would
lead to errors when there was a projection in a argument or return
type. This also led to some special cases in the `renumber` code.

We now renumber uniformly but then pass the input/output types into
the MIR type-checker, which equates them with the types found in MIR.
This allows us to normalize at the same time.
2017-12-15 10:27:53 -05:00
Niko Matsakis
3fcb13ae45 handle projections with regions 2017-12-15 10:27:52 -05:00
Niko Matsakis
3a5842afe1 add a new RegionKind variant: ReClosureBound
This is needed to allow the `ClosureRegionRequirements` to capture
types that include regions.
2017-12-15 10:27:52 -05:00
Niko Matsakis
85e1d4749e propagate type tests from closure to closure creators
Currently, we only propagate type tests that exclude all regions from
the type.
2017-12-15 10:27:51 -05:00
Niko Matsakis
5804637a81 permit ClosureOutlivesRequirement to constrain regions or types 2017-12-15 10:27:51 -05:00
Niko Matsakis
c7cfa2367b thread through an implicit region body of the fn body 2017-12-15 10:27:50 -05:00
Niko Matsakis
02e65250e4 mild refactors of the control flow (no functional changes)
In the future, `check_type_tests` will also potentially propagate
constriants to its caller.
2017-12-15 10:27:49 -05:00
Niko Matsakis
47c1921b9a move some parts of liveness to happen during type checking
This allows us to re-use the `normalize` method on `TypeCheck`, which
is important since normalization may create fresh region
variables. This is not an ideal solution, though, since the current
representation of "liveness constraints" (a vector of (region, point)
pairs) is rather inefficient. Could do somewhat better by converting
to indices, but it'd still be less good than the older code. Unclear
how important this is.
2017-12-15 10:27:49 -05:00
Niko Matsakis
4a940b3215 move flow_in_progress into dataflow and document it 2017-12-15 10:27:46 -05:00
Niko Matsakis
ebd086b67f move LivenessResults from nll into liveness analysis 2017-12-15 10:10:57 -05:00
Niko Matsakis
1c57468840 move type_check out of transform and into the nll module 2017-12-15 10:10:57 -05:00
Niko Matsakis
fad3d1d7fd dfs.rs: rustfmt 2017-12-15 10:10:56 -05:00
Niko Matsakis
6193c5cc2a translate Verifys into TypeTests and check them 2017-12-15 10:10:56 -05:00
Niko Matsakis
cd564d20ff only propagate ClosureRegionRequirements if non-trivial
Before, we would always have a `Some` ClosureRegionRequirements if we
were inferring values for a closure. Now we only do is it has a
non-empty set of outlives requirements.
2017-12-15 10:10:56 -05:00
Niko Matsakis
a0f0392a6d rename copy to dfs and make it customizable 2017-12-15 10:10:55 -05:00
Niko Matsakis
86334c7116 remove unnecessary intermediate vector from copy 2017-12-15 10:10:55 -05:00
bors
84feab34e4 Auto merge of #46537 - pnkfelix:two-phase-borrows, r=arielb1
[MIR-borrowck] Two phase borrows

This adds limited support for two-phase borrows as described in
  http://smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/

The support is off by default; you opt into it via the flag `-Z two-phase-borrows`

I have written "*limited* support" above because there are simple variants of the simple `v.push(v.len())` example that one would think should work but currently do not, such as the one documented in the test compile-fail/borrowck/two-phase-reservation-sharing-interference-2.rs

(To be clear, that test is not describing something that is unsound. It is just providing an explicit example of a limitation in the implementation given in this PR. I have ideas on how to fix, but I want to land the work that is in this PR first, so that I can stop repeatedly rebasing this branch.)
2017-12-15 05:40:12 +00:00
Felix S. Klock II
159037e053 Address review feedback: don't treat "first" activation special.
Instead, filter out (non-)conflicts of activiations with themselves in
the same manner that we filter out non-conflict between an activation
and its reservation.
2017-12-14 17:34:16 -06:00
Felix S. Klock II
b0421fa7de Address review feedback: don't bother skipping reservations paired with activations. 2017-12-14 16:28:26 -06:00
bors
2974104276 Auto merge of #45002 - oli-obk:miri, r=eddyb
Validate miri against the HIR const evaluator

r? @eddyb

cc @alexcrichton @arielb1 @RalfJung

The interesting parts are the last few functions in `librustc_const_eval/eval.rs`

* We warn if miri produces an error while HIR const eval does not.
* We warn if miri produces a value that does not match the value produced by HIR const eval
* if miri succeeds and HIR const eval fails, nothing is emitted, but we still return the HIR error
* if both error, nothing is emitted and the HIR const eval error is returned

So there are no actual changes, except that miri is forced to produce the same values as the old const eval.

* This does **not** touch the const evaluator in trans at all. That will come in a future PR.
* This does **not** cause any code to compile that didn't compile before. That will also come in the future

It would be great if someone could start a crater run if travis passes
2017-12-14 15:37:39 +00:00