Commit Graph

61 Commits

Author SHA1 Message Date
bors
d21ec9b4ef Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1
Fixed mutable vars being marked used when they weren't

#### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue.

Fixes #43526, Fixes #30280, Fixes #25049

### Issue
Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings
```
fn do_thing<T>(mut arg : &mut T) {
    ... // don't touch arg - just deref it to access the T
}
```

### Fix
Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables.
#### Why not on things other than local variables?
  * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted.
  * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-10 08:53:22 +00:00
Michael Woerister
b2c3a413b9 incr.comp.: Properly incorporate symbol linkage and visibility into CGU hash. 2017-08-02 11:56:23 +02:00
Isaac van Bakel
400075d9d9 Fixed all unnecessary muts in language core 2017-08-01 23:01:24 +01:00
Bruce Mitchener
539df8121b Fix some doc/comment typos. 2017-07-23 22:48:01 +07:00
Michael Woerister
226bc92b64 partitioning: Fix visibility of internalized symbols. 2017-07-17 15:59:22 +02:00
Michael Woerister
678d37700d Address some nits in trans-collector and partitioner. 2017-07-13 17:45:40 +02:00
Michael Woerister
2f07eb3261 trans: Internalize symbols at the trans-item level, without relying on LLVM. 2017-07-13 13:28:16 +02:00
Michael Woerister
ca0a40396c incr.comp.: Improve debug output for work products. 2017-07-10 12:20:56 +02:00
Michael Woerister
3607174909 incr.comp.: Uniformly represent DepNodes as (Kind, StableHash) pairs. 2017-06-09 15:03:34 +02:00
Michael Woerister
12e5b699a4 incr.comp.: Make WorkProductId opaque so we don't accidentally rely on being able to reconstruct obj-file names from one. 2017-06-06 15:09:21 +02:00
Robin Kruppe
6fec17ee15 Remove trans-internal re-exports of rustc modules
The previous commit removed them from the public API, this rewrites the use statements to get rid of the non-standard re-exports.
2017-05-27 21:09:29 +02:00
Ariel Ben-Yehuda
a517343566 cache symbol names in ty::maps
this fixes a performance regression introduced in commit
39a58c38a0.
2017-04-26 17:45:02 +03:00
Niko Matsakis
c446cb086b just take tcx where we can
The more we can things dependent on just tcx, the easier it will
be to make queries etc later on.
2017-04-21 17:26:53 -04:00
Niko Matsakis
39a58c38a0 introduce the rather simpler symbol-cache in place of symbol-map
The symbol map is not good for incremental: it has inputs from every fn
in existence, and it will change if anything changes. One could imagine
cheating with the symbol-map and exempting it from the usual dependency
tracking, since the results are fully deterministic. Instead, I opted to
just add a per-CGU cache, on the premise that recomputing some symbol
names is not going to be so very expensive.
2017-04-21 17:26:53 -04:00
A.J. Gardner
70fcff6318 Add new TransItem for global_asm trans 2017-04-12 19:12:49 -05: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
aac5ba5dab resolve instances to ty::Instance directly
This removes the duplication between collector, callee, and (eventually)
MIRI.
2017-03-18 02:53:07 +02:00
Ariel Ben-Yehuda
ffee9566bb move Instance to rustc and use it in the collector 2017-03-18 02:53:04 +02:00
Ariel Ben-Yehuda
ca8708273b more through normalization in typeck & trans
Fixes #27901.
Fixes #28828.
Fixes #38135.
Fixes #39363.
2017-03-01 16:56:08 +02:00
Eduard-Mihai Burtescu
45c8c5678a rustc: rename TyCtxt's map field to hir. 2017-01-26 13:41:28 +02:00
Michael Woerister
622730ca10 Remove some out-dated comments from CGU partitioning docs. 2017-01-09 10:06:58 -05:00
Michael Woerister
5f90947c2c trans: Treat generics like regular functions, not like #[inline] functions during CGU partitioning. 2017-01-09 10:06:58 -05:00
Michael Woerister
4a494ed8df incr.comp.: Take symbol visibility into account for CGU hashes. 2016-12-09 17:47:56 -05:00
Jeffrey Seyfried
36c8f6b0d3 Cleanup InternedString. 2016-11-21 09:00:56 +00:00
Jeffrey Seyfried
e85a0d70b8 Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Jeffrey Seyfried
d2f8fb0a0a Move syntax::util::interner -> syntax::symbol, cleanup. 2016-11-20 23:40:20 +00:00
Eduard Burtescu
3f9eba1c7c rustc: clean up lookup_item_type and remove TypeScheme. 2016-11-10 16:49:53 +02:00
Nicholas Nethercote
00e48affde Replace FnvHasher use with FxHasher.
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-08 15:14:59 +11:00
Jonathan Turner
1a7aa75332 Rollup merge of #36960 - michaelwoerister:linker-regression, r=eddyb
Linker regression

This should fix the symbol conflicts reported in #36852.
The PR also makes some debug output a bit more informative.

r? @eddyb
2016-10-06 08:35:42 -07:00
Michael Woerister
457019967b Add symbol hash to trans::partitioning debug output. 2016-10-04 12:02:19 -04:00
Alex Crichton
10c3134da0 std: Stabilize and deprecate APIs for 1.13
This commit is intended to be backported to the 1.13 branch, and works with the
following APIs:

Stabilized

* `i32::checked_abs`
* `i32::wrapping_abs`
* `i32::overflowing_abs`
* `RefCell::try_borrow`
* `RefCell::try_borrow_mut`
* `DefaultHasher`
* `DefaultHasher::new`
* `DefaultHasher::default`

Deprecated

* `BinaryHeap::push_pop`
* `BinaryHeap::replace`
* `SipHash13`
* `SipHash24`
* `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map`
  module

Closes #28147
Closes #34767
Closes #35057
Closes #35070
2016-10-03 10:34:34 -07:00
Michael Woerister
bfa6fdc72c trans: Allow base::internalize_symbols() to internalize #[no_mangle] symbols 2016-09-15 20:39:58 -04:00
Michael Woerister
c10176ef66 trans: Only translate #[inline] functions if they are used somewhere. 2016-09-15 11:40:16 -04:00
Niko Matsakis
72694d5829 give apply_param_substs a SharedCrateContext
I plan to put a cache on the shared context, for now at least.
2016-08-31 17:05:53 -04:00
Eduard Burtescu
5222fa58a1 rustc: use accessors for Substs::{types,regions}. 2016-08-27 00:25:04 +03:00
Eduard Burtescu
9453d9b8ad rustc: remove ParamSpace from Substs. 2016-08-17 06:32:00 +03:00
Eduard Burtescu
c1cfd58cbd rustc: remove SelfSpace from ParamSpace. 2016-08-17 05:50:57 +03:00
Eduard Burtescu
4158673ad7 rustc: reduce Substs and Generics to a simple immutable API. 2016-08-17 05:50:57 +03:00
Niko Matsakis
2f9fff2191 Keep multiple files per work-product
In the older version, a `.o` and ` .bc` file were separate
work-products.  This newer version keeps, for each codegen-unit, a set
of files of different kinds. We assume that if any kinds are available
then all the kinds we need are available, since the precise set of
switches will depend on attributes and command-line switches.

Should probably test this: the effect of changing attributes in
particular might not be successfully tracked?
2016-07-28 12:05:45 -04:00
Niko Matsakis
ceeb158e0a Address mw nits 2016-07-28 12:05:45 -04:00
Niko Matsakis
58d4b8edd3 Modify trans to skip generating .o files
This checks the `previous_work_products` data from the dep-graph and
tries to simply copy a `.o` file if possible.  We also add new
work-products into the dep-graph, and create edges to/from the dep-node
for a work-product.
2016-07-28 12:05:45 -04:00
Michael Woerister
1c03bfe3b4 trans: Adjust linkage assignment so that we don't need weak linkage. 2016-07-08 10:42:48 -04:00
Michael Woerister
4c27a3c6d5 trans: Enable falling back to on-demand instantiation for drop-glue and monomorphizations.
See issue #34151 for more information.
2016-07-08 10:42:48 -04:00
Michael Woerister
ab80f74670 collector-driven-trans: Take care of nits. 2016-07-08 10:42:47 -04:00
Michael Woerister
3a47103f1d Fix codegen tests by make sure items are translated in AST order. 2016-07-08 10:42:47 -04:00
Michael Woerister
37a10ecbe8 Make item translation order deterministic by sorting by symbol name. 2016-07-08 10:42:47 -04:00
Michael Woerister
87c1c87dd7 Make drop-glue translation collector-driven. 2016-07-08 10:42:47 -04:00
Michael Woerister
6c8c94b848 Improve linkage assignment in trans::partitioning. 2016-07-08 10:42:47 -04:00
Michael Woerister
65e8a13441 Adapt backend to trans::partitioning dictating the codegen-unit setup. 2016-07-08 10:42:46 -04:00
Niko Matsakis
be7b576cc5 correct typo in comment 2016-05-24 15:08:07 -04:00