Commit Graph

572 Commits

Author SHA1 Message Date
bors
ba377982a3 Auto merge of #41153 - petrochenkov:umove, r=pnkfelix
Fix move checking for nested union fields

Fixes https://github.com/rust-lang/rust/issues/41126
r? @arielb1
2017-04-14 16:28:14 +00:00
Tim Neumann
1dd9801fa5 Rollup merge of #41232 - arielb1:mir-rvalues, r=eddyb
move rvalue checking to MIR
2017-04-12 14:45:47 +02:00
Tim Neumann
49082ae9f2 Rollup merge of #41063 - nikomatsakis:issue-40746-always-exec-loops, r=eddyb
remove unnecessary tasks

Remove various unnecessary tasks. All of these are "always execute" tasks that don't do any writes to tracked state (or else an assert would trigger, anyhow). In some cases, they issue lints or errors, but we''ll deal with that -- and anyway side-effects outside of a task don't cause problems for anything that I can see.

The one non-trivial refactoring here is the borrowck conversion, which adds the requirement to go from a `DefId` to a `BodyId`. I tried to make a useful helper here.

r? @eddyb

cc #40746
cc @cramertj @michaelwoerister
2017-04-12 14:45:40 +02:00
Niko Matsakis
2e327a668e fix nit 2017-04-12 05:42:02 -04:00
Ariel Ben-Yehuda
384ec80d2b store Spans for all MIR locals 2017-04-11 23:52:51 +03:00
bors
666e7148d1 Auto merge of #41148 - arielb1:dead-unwind, r=nagisa
borrowck::mir::dataflow: ignore unwind edges of empty drops

This avoids creating drop flags in many unnecessary situations.

Fixes #41110.

r? @nagisa

beta-nominating because regression. However, that is merely a small perf regression and codegen changes are always risky, so we might let this slide for 1.17.
2017-04-08 19:47:31 +00:00
Ariel Ben-Yehuda
6979798687 borrowck::mir::dataflow: ignore unwind edges of empty drops
This avoids creating drop flags in many unnecessary situations.

Fixes #41110.
2017-04-08 22:46:50 +03:00
Vadim Petrochenkov
ad58d37c56 Fix move checking for nested union fields 2017-04-08 11:52:37 +03:00
Corey Farwell
d860b1c003 Rollup merge of #40797 - GAJaloyan:patch-1, r=arielb1
Correcting mistakes in the README.md

Correcting the two mistakes in the README.md (issue #40793)
2017-04-07 09:20:03 -04:00
Niko Matsakis
a4d7c1fec3 push borrowck into its own task 2017-04-04 12:06:35 -04:00
Corey Farwell
a63b1dfa34 Rollup merge of #40841 - arielb1:immutable-blame, r=pnkfelix
borrowck: consolidate `mut` suggestions

This converts all of borrowck's `mut` suggestions to a new
`mc::ImmutabilityBlame` API instead of the current mix of various hacks.

Fixes #35937.
Fixes #40823.
Fixes #40859.

cc @estebank
r? @pnkfelix
2017-03-29 08:57:06 -04:00
GAJaloyan
c80868e3b3 correcting another mistake in an example
copy_pointer -> copy_borrowed_ptr
2017-03-27 16:17:08 +02:00
Oliver Schneider
eb447f4ef4
Fix various useless derefs and slicings 2017-03-27 08:58:00 +02:00
Ariel Ben-Yehuda
39011f8590 fix handling of self 2017-03-27 01:37:46 +03:00
Ariel Ben-Yehuda
50728e5245 borrowck: consolidate mut suggestions
This converts all of borrowck's `mut` suggestions to a new
`mc::ImmutabilityBlame` API instead of the current mix of various hacks.

Fixes #35937.
Fixes #40823.
2017-03-27 01:37:42 +03:00
GAJaloyan
03949f5b5c issue #40793
Correcting the two mistakes in the README.md
2017-03-24 17:47:23 +01:00
Alex Crichton
e341d603fe Remove internal liblog
This commit deletes the internal liblog in favor of the implementation that
lives on crates.io. Similarly it's also setting a convention for adding crates
to the compiler. The main restriction right now is that we want compiler
implementation details to be unreachable from normal Rust code (e.g. requires a
feature), and by default everything in the sysroot is reachable via `extern
crate`.

The proposal here is to require that crates pulled in have these lines in their
`src/lib.rs`:

    #![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
    #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]

This'll mean that by default they're not using these attributes but when
compiled as part of the compiler they do a few things:

* Mark themselves as entirely unstable via the `staged_api` feature and the
  `#![unstable]` attribute.
* Allow usage of other unstable crates via `feature(rustc_private)` which is
  required if the crate relies on any other crates to compile (other than std).
2017-03-23 11:28:00 -07:00
bors
134c4a0f08 Auto merge of #39628 - arielb1:shimmir, r=eddyb
Translate shims using MIR

This removes one large remaining part of old trans.
2017-03-20 15:58:10 +00:00
Corey Farwell
9032ceae97 Rollup merge of #40445 - estebank:issue-18150, r=jonathandturner
Point to let when modifying field of immutable variable

Point at the immutable local variable when trying to modify one of its
fields.

Given a file:

```rust
struct Foo {
    pub v: Vec<String>
}

fn main() {
    let f = Foo { v: Vec::new() };
    f.v.push("cat".to_string());
}
```

present the following output:

```
error: cannot borrow immutable field `f.v` as mutable
 --> file.rs:7:13
  |
6 |    let f = Foo { v: Vec::new() };
  |        - this should be `mut`
7 |    f.v.push("cat".to_string());
  |    ^^^

error: aborting due to previous error
```

Fix #27593.
2017-03-19 10:18:13 -04:00
Ariel Ben-Yehuda
f2c7917402 translate drop glue using MIR
Drop of arrays is now translated in trans::block in an ugly way that I
should clean up in a later PR, and does not handle panics in the middle
of an array drop, but this commit & PR are growing too big.
2017-03-18 02:53:08 +02:00
Ariel Ben-Yehuda
2b9fea1300 move the drop expansion code to rustc_mir 2017-03-18 02:53:07 +02:00
Esteban Küber
9ac628d5e8 Add label to primary span for mutable access of immutable struct error 2017-03-13 19:22:48 -07:00
Esteban Küber
38b5b29c57 Change label to "consider changing this to mut f"
Change the wording of mutable borrow on immutable binding from "this
should be `mut`" to "consider changing this to `mut f`".
2017-03-12 16:38:53 -07:00
Esteban Küber
6ba494b68b Point to let when modifying field of immutable variable
Point at the immutable local variable when trying to modify one of its
fields.

Given a file:

```rust
struct Foo {
    pub v: Vec<String>
}

fn main() {
    let f = Foo { v: Vec::new() };
    f.v.push("cat".to_string());
}
```

present the following output:

```
error: cannot borrow immutable field `f.v` as mutable
 --> file.rs:7:13
  |
6 |    let f = Foo { v: Vec::new() };
  |        - this should be `mut`
7 |    f.v.push("cat".to_string());
  |    ^^^

error: aborting due to previous error
```
2017-03-11 14:28:29 -08:00
Niko Matsakis
4b6b544d65 isolate dep-graph tasks
A task function is now given as a `fn` pointer to ensure that it carries
no state. Each fn can take two arguments, because that worked out to be
convenient -- these two arguments must be of some type that is
`DepGraphSafe`, a new trait that is intended to prevent "leaking"
information into the task that was derived from tracked state.

This intentionally leaves `DepGraph::in_task()`, the more common form,
alone. Eventually all uses of `DepGraph::in_task()` should be ported
to `with_task()`, but I wanted to start with a smaller subset.

Originally I wanted to use closures bound by an auto trait, but that
approach has some limitations:

- the trait cannot have a `read()` method; since the current method
  is unused, that may not be a problem.
- more importantly, we would want the auto trait to be "undefined" for all types
  *by default* -- that is, this use case doesn't really fit the typical
  auto trait scenario. For example, imagine that there is a `u32` loaded
  out of a `hir::Node` -- we don't really want to be passing that
  `u32` into the task!
2017-03-10 08:15:13 -08:00
bors
f0b514524f Auto merge of #40133 - arielb1:operand-lifetimes, r=eddyb
[MIR] improve operand lifetimes

r? @eddyb
2017-03-03 13:12:08 +00:00
Ariel Ben-Yehuda
6755fb8ba2 schedule drops on bindings only after initializing them
This reduces the number of dynamic drops in libstd from 1141 to 899.
However, without this change, the next patch would have created much
more dynamic drops.

A basic merge unswitching hack reduced the number of dynamic drops to
644, with no effect on stack usage. I should be writing a more dedicated
drop unswitching pass.

No performance measurements.
2017-03-02 22:38:21 +02:00
Niko Matsakis
2b5c0267b4 kill the code path for E0388
This was specific to the old special-case handling of statics in
borrowck.
2017-02-28 08:43:47 -05:00
Niko Matsakis
3e9bddad7b remove Option from the tables field 2017-02-28 08:43:47 -05:00
Niko Matsakis
cc2e4cd7e3 use visit_all_bodies_in_krate for borrowck instead of item-likes 2017-02-28 08:43:47 -05:00
Niko Matsakis
085d71c3ef remove special-case code for statics and just use borrowck_fn
Fixes #38520
2017-02-28 08:43:47 -05:00
Niko Matsakis
a9ec8841ef make borrowck_fn and friends create bccx 2017-02-28 08:43:47 -05:00
Niko Matsakis
530b92cfdd remove the borrowck stats 2017-02-28 08:43:47 -05:00
Niko Matsakis
03e8b26f35 rewrite borrowck_fn to only use the body-id 2017-02-28 08:43:47 -05:00
Niko Matsakis
b3a482ca9b move the FreeRegionMap into TypeckTables 2017-02-28 08:43:47 -05:00
Eduard-Mihai Burtescu
c832e6f327 rustc_typeck: rework coherence to be almost completely on-demand. 2017-02-25 18:35:26 +02:00
Eduard-Mihai Burtescu
ba11640179 rustc_typeck: hook up collect and item/body check to on-demand. 2017-02-25 18:35:25 +02:00
Eduard-Mihai Burtescu
91374f8fe4 rustc: combine BareFnTy and ClosureTy into FnSig. 2017-02-25 17:47:15 +02:00
Eduard-Mihai Burtescu
e96a171453 rustc: move the actual values of enum discriminants into a map. 2017-02-25 17:07:59 +02:00
Simonas Kazlauskas
4a3c66ad2f [MIR] Make InlineAsm a Statement
Previously InlineAsm was an Rvalue, but its semantics doesn’t really match the semantics of an
Rvalue – rather it behaves more like a Statement.
2017-02-15 21:21:36 +02:00
Simonas Kazlauskas
7d1f36a482 Inline open_drop_for_variant & clean matches::test 2017-02-10 19:47:09 +02:00
Simonas Kazlauskas
eb727a8faa Add TerminatorKind::if_ convenience constructor
Constructs a TerminatorKind::SwitchInt for an equivalent conditional true-false branch.
2017-02-10 19:45:55 +02:00
Simonas Kazlauskas
8e00d28ff4 Prefer switching on false for boolean switches
This ends up not really mattering because we generate a plain conditional branch in LLVM either
way.
2017-02-10 19:44:00 +02:00
Simonas Kazlauskas
4be18488a7 Fix SwitchInt building in ElaborateDrops pass
Previously it used to build a switch in a way that didn’t preserve the invariat of SwitchInt. Now
it builds it in an optimal way too, where otherwise branch becomes all the branches which did not
have partial variant drops.
2017-02-10 19:44:00 +02:00
Simonas Kazlauskas
c9939863ca Fix the IntTypeExt::to_ty() lifetime bounds 2017-02-10 19:43:57 +02:00
Simonas Kazlauskas
a00a0adc79 Only SwitchInt over integers, not all consts
Also use a Cow to avoid full Vec for all SwitchInts
2017-02-10 19:42:41 +02:00
Simonas Kazlauskas
aac82d9b13 SwitchInt over Switch
This removes another special case of Switch by replacing it with the more general SwitchInt. While
this is more clunky currently, there’s no reason we can’t make it nice (and efficient) to use.
2017-02-10 19:42:41 +02:00
Simonas Kazlauskas
98d1db7fe3 If is now always a SwitchInt in MIR 2017-02-10 19:31:37 +02:00
Simonas Kazlauskas
779c6b6cb8 Add Rvalue::Discriminant to retrieve discriminant 2017-02-10 19:31:37 +02:00
Andrew Cann
2cc84df44c Add warning for () to ! switch 2017-02-03 18:48:15 +08:00