Commit Graph

1786 Commits

Author SHA1 Message Date
Santiago Pastorino
ec761903ec
Remove nll-dump-cause flag and always track causes 2018-03-06 10:34:46 -03:00
kennytm
57cfbeaf64
Rollup merge of #48727 - leodasvacas:refactor-contrived-match, r=rkruppe
Refactor contrived match.
2018-03-06 20:52:29 +08:00
Michael Woerister
e5ee01143b Rename exported_symbol_ids query to something more explicit and document what it is doing. 2018-03-06 09:47:43 +01:00
varkor
f69a0999e7 Remove IdxSet::elems 2018-03-06 01:14:38 +00:00
varkor
89d12478ac Remove IdxSet::each_bit 2018-03-06 01:14:36 +00:00
varkor
6701d9020f Remove IdxSet::reset_to_empty 2018-03-06 00:58:01 +00:00
Michael Woerister
542bc75dea Turn features() into a query. 2018-03-05 11:05:01 +01:00
bors
259e4a6784 Auto merge of #48592 - spastorino:borrowed_value_error, r=nikomatsakis
[NLL] Avoid borrowed value must be valid for lifetime '_#2r..." in errors

Closes #48428

- [x] If NLL is enabled, [do not invoke `note_and_explain_region`](https://github.com/rust-lang/rust/issues/48428#issuecomment-367691123)
- [x] Modify `-Zdump-nll-cause` to not print [the overwhelming debug output here](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/nll/region_infer/mod.rs#L1288-L1299). This way we should I believe at least get nice-ish output for [our original example](https://github.com/rust-lang/rust/issues/48428#issue-299364536).
- [x] Extend `explain_why_borrow_contains_point` to also work for "universal lifetimes" like the `'a` in [the example at the end of this comment](https://github.com/rust-lang/rust/issues/48428#issuecomment-367691123).
- [ ] Figure out how to enable causal information all the time (but that is https://github.com/rust-lang/rust/issues/46590).
2018-03-04 18:16:43 +00:00
Pramod Bisht
6fdf6377cc Fixed #48425 2018-03-04 20:27:55 +05:30
leonardo.yvens
0b0e1b71d5 Refactor contrived match. 2018-03-04 08:31:09 -03:00
Manish Goregaokar
40f218f703 Remove allow(bare_trait_object) from librustc_mir 2018-03-02 21:02:37 -08:00
Manish Goregaokar
3c95814294 Perform manual fixups 2018-03-02 21:02:37 -08:00
Manish Goregaokar
8d730ed527 Run Rustfix on librustc_mir 2018-03-02 21:02:37 -08:00
John Kåre Alsaker
b74e97cf42 Replace Rc with Lrc for shared data 2018-03-02 10:48:52 +01:00
Santiago Pastorino
99c42dccfa
rustfmt over error_reporting, explain_borrow and region_infer mods 2018-03-01 16:43:03 -03:00
Santiago Pastorino
ff7dca50a4
Make explain borrow work for Universal lifetimes 2018-03-01 16:42:44 -03:00
Manish Goregaokar
f57835b7f4
Rollup merge of #48461 - Manishearth:epoch-dyn-trait, r=nmatsakis
Fixes #47311.
r? @nrc
2018-02-28 15:09:29 -08:00
Manish Goregaokar
12515608cb
Rollup merge of #48380 - nikomatsakis:issue-48251-master, r=acrichto
Fixes #47311.
r? @nrc
2018-02-28 15:09:26 -08:00
Manish Goregaokar
f59ab8e96a
Rollup merge of #48355 - mikhail-m1:subslice_pattern_array_drop2, r=nikomatsakis
Fixes #47311.
r? @nrc
2018-02-28 15:09:22 -08:00
Santiago Pastorino
7580826a1f
Avoid printing overwhelming info on -Znll-dump-cause 2018-02-28 12:31:38 -03:00
Santiago Pastorino
a17a2e3f83
Do not report _#nr lifetimes names in errors 2018-02-28 12:31:27 -03:00
varkor
2466644389 Ensure main() always has external linkage
This ensures that the entry function is never elided due to inlining, even with `inline(always)`. Fixes #47783.

There were a couple of possible ways of addressing this issue; I simply picked the one that seemed most direct. A warning could be appropriate, but considering using inlining hints in other places it doesn't apply also throws no warnings, and it seems like an edge case anyway, I haven't added one for now.
2018-02-25 23:05:06 +00:00
Mikhail Modin
12c7e27330 restore Subslice move out from array after elaborate drops and borrowck 2018-02-25 18:59:16 +03:00
Manish Goregaokar
2dba874d57
Rollup merge of #48452 - varkor:unpacked-kind, r=eddyb
Introduce UnpackedKind

This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker will be able to catch more potential issues.

r? @eddyb
cc @yodaldevoid
2018-02-24 15:52:15 -08:00
Manish Goregaokar
182f8820c4 Rollup merge of #48061 - nikomatsakis:nll-do-not-run-mir-typeck-twice, r=eddyb
Fixes #47311.
r? @nrc
2018-02-24 12:48:03 -08:00
Manish Goregaokar
2483d842fb Rollup merge of #48353 - michaelwoerister:monoitem-static-defid, r=eddyb
Allow for instantiating statics from upstream crates

This PR makes the infrastructure around translating statics a bit more flexible so that it can also instantiate statics from upstream crates if the need arises. This is preparatory work for a MIR-only RLIBs prototype, where the instantiation of a `static` may be deferred until a leaf crate.

r? @eddyb (feel free to assign to someone else if you're busy)
2018-02-24 12:48:01 -08:00
Manish Goregaokar
a1a1409647 Rollup merge of #48317 - ExpHP:unused-unsafe-is-no-fn, r=estebank
unused_unsafe: don't label irrelevant fns

Fixes #48131

Diagnostic bugfix to remove an errant note.  Stops the search for an enclosing unsafe scope at the first safe fn encountered.

```rust
pub unsafe fn outer() {
    fn inner() {
        unsafe { /* unnecessary */ }
    }

    inner()
}
```

**Before:**

```
warning: unnecessary `unsafe` block
 --> src/main.rs:3:9
  |
1 | pub unsafe fn outer() {
  | --------------------- because it's nested under this `unsafe` fn
2 |     fn inner() {
3 |         unsafe { /* unnecessary */ }
  |         ^^^^^^ unnecessary `unsafe` block
  |
  = note: #[warn(unused_unsafe)] on by default
```

**After:**

```
warning: unnecessary `unsafe` block
 --> src/main.rs:3:9
  |
3 |         unsafe { /* unnecessary */ }
  |         ^^^^^^ unnecessary `unsafe` block
  |
  = note: #[warn(unused_unsafe)] on by default
```
2018-02-24 12:48:01 -08:00
Manish Goregaokar
8fdad6f2ef Rollup merge of #48232 - fpoli:master, r=pnkfelix
mir: Gather move at SwitchInt, Assert terminators

Previously, `_1` was not marked as "definitely uninitialized" after a `switchInt(move _1)` terminator.

I think the same goes for the `assert` terminator.

Related discussion: https://internals.rust-lang.org/t/why-is-2-definitely-initialized-after-switchint-move-2/6760
2018-02-24 12:47:59 -08:00
Manish Goregaokar
74f6794193
Rollup merge of #48245 - spastorino:sparse_bitsets, r=nikomatsakis
Use sparse bitsets instead of dense ones for NLL results

This is for https://github.com/rust-lang/rust/issues/48170.

r? @nikomatsakis
2018-02-23 10:24:53 -08:00
Manish Goregaokar
63168f7275 Lint bare traits 2018-02-23 08:24:49 -08:00
Niko Matsakis
bcd996857e explain why we don't need to run type-checker when NLL is enabled 2018-02-23 10:42:12 -05:00
Niko Matsakis
380e388a86 do not run MIR type checker twice 2018-02-23 10:36:56 -05:00
bors
928435305a Auto merge of #48052 - eddyb:deggregate, r=nikomatsakis
rustc_mir: handle all aggregate kinds in, and always run, the deaggregator.

This helps with removing`Rvalue::Aggregate` from the MIR, and with enabling more optimizations.
r? @nikomatsakis
2018-02-23 02:21:06 +00:00
varkor
8b2037c6fe Introduce UnpackedKind
This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker should catch more potential issues.
2018-02-23 01:13:54 +00:00
Santiago Pastorino
6a74615fe3
Run rustfmt over bitvec.rs and region_infer/values.rs 2018-02-22 21:27:52 -03:00
Santiago Pastorino
ff9eb56c6e
Use Sparse bitsets instead of dense ones for NLL results
Fixes #48170
2018-02-22 21:27:26 -03:00
Niko Matsakis
a47fd3df89 make #[unwind] attribute specify expectations more clearly
You can now choose between the following:

- `#[unwind(allowed)]`
- `#[unwind(aborts)]`

Per rust-lang/rust#48251, the default is `#[unwind(allowed)]`, though
I think we should change this eventually.
2018-02-20 19:12:52 -05:00
Mark Simulacrum
33f5ceee1f stage0 cfg cleanup 2018-02-20 08:52:33 -07:00
Eduard-Mihai Burtescu
c9fcedeb4c rustc_mir: optimize the deaggregator's expansion of statements. 2018-02-20 02:50:26 +02:00
Eduard-Mihai Burtescu
d773d95880 rustc_mir: don't run the deaggregator on arrays for now. 2018-02-20 02:50:26 +02:00
Eduard-Mihai Burtescu
6e5dacbd5e rustc_mir: always run the deaggregator. 2018-02-20 02:50:26 +02:00
Eduard-Mihai Burtescu
e598bdfaa0 rustc_mir: do not remove dead user variables if debuginfo needs them. 2018-02-20 02:50:26 +02:00
Eduard-Mihai Burtescu
b88180f74c rustc_mir: handle all aggregate kinds in the deaggregator. 2018-02-20 02:50:26 +02:00
Eduard-Mihai Burtescu
3922dd72fe rustc_mir: use the "idiomatic" optimization gating in the deaggregator. 2018-02-20 02:50:26 +02:00
Michael Woerister
15ff0adcde Use DefId instead of NodeId in MonoItem::Static. 2018-02-19 13:29:22 +01:00
Guillaume Gomez
af140ecdbc
Rollup merge of #48275 - matthiaskrgr:codespell, r=kennytm,varkor
fix more typos found by codespell.
2018-02-18 13:21:01 +01:00
Michael Lamparski
42df8c56cc unused_unsafe: don't label irrelevant fns 2018-02-17 22:31:14 -05:00
bors
5313e8728f Auto merge of #47408 - eddyb:deref-danger, r=nikomatsakis
Don't promote to 'static the result of dereferences.

This is a **breaking change**, removing copies out of dereferences from rvalue-to-`'static` promotion.

With miri we won't easily know whether the dereference itself would see the same value at runtime as miri (e.g. after mutating a `static`) or even if it can be interpreted (e.g. integer pointers).
One alternative to this ban is defining at least *some* of those situations as UB, i.e. you shouldn't have a reference in the first place, and you should work through raw pointers instead, to avoid promotion.

**EDIT**: The other *may seem* to be to add some analysis which whitelists references-to-constant-values and assume any values produced by arbitrary computation to not be safe to promote dereferences thereof - but that means producing a reference from an associated constant or `const fn` would necessarily obscure it, and in the former case, this could still impact code that runs on stable today. What we do today to track "references to statics" only works because we restrict taking a reference to a `static` at all to other `static`s (which, again, are currently limited in that they can't be read at compile-time) and to runtime-only `fn`s (*not* `const fn`s).

I'm primarily opening this PR with a conservative first approximation (e.g. `&(*r).a` is not allowed, only reborrows are, and in the old borrow only implicit ones from adjustments, at that) for cratering.

r? @nikomatsakis
2018-02-17 19:32:25 +00:00
Matthias Krüger
4452446292 fix more typos found by codespell. 2018-02-17 17:38:49 +01:00
bors
b85bd51c94 Auto merge of #47926 - mikhail-m1:subslice_pattern_array_drop2, r=nikomatsakis
add transform for uniform array move out

reworked second step for fix #34708
previous try #46686
r? @nikomatsakis
2018-02-17 08:44:41 +00:00
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