about summary refs log tree commit diff
path: root/src/librustc_borrowck
AgeCommit message (Collapse)AuthorLines
2016-11-29Split nested_visit_mode function off from nested_visit_mapFlorian Diebold-6/+6
... and make the latter mandatory to implement.
2016-11-29Save bodies of functions for inlining into other cratesFlorian Diebold-6/+10
This is quite hacky and I hope to refactor it a bit, but at least it seems to work.
2016-11-29rustc_borrowck: fix compilationFlorian Diebold-23/+31
2016-11-29rustc: replace body exprs by their idsFlorian Diebold-1/+1
2016-11-28Adds TyCtxt::require_lang_item(LangItem) to simplify lang item requires.Mark-Simulacrum-2/+1
Replaces instances of tcx.lang_items.require(..) with fatal unwrap with this method.
2016-11-29add hint to fix error for immutable ref in argMikhail Modin-46/+83
2016-11-28rustc: embed path resolutions into the HIR instead of keeping DefMap.Eduard-Mihai Burtescu-1/+1
2016-11-21Cleanup `InternedString`.Jeffrey Seyfried-1/+1
2016-11-20Refactor `P<ast::MetaItem>` -> `ast::MetaItem`.Jeffrey Seyfried-2/+1
2016-11-16refactor Visitor into ItemLikeVisitor and intravisit::VisitorNiko Matsakis-1/+1
There are now three patterns (shallow, deep, and nested visit). These are described in detail on the docs in `itemlikevisit::ItemLikeVisitor`.
2016-11-14Auto merge of #37278 - matklad:lone-lifetime, r=jseyfriedbors-1/+1
Fix syntax error in the compiler Currently `rustc` accepts the following code: `fn f<'a>() where 'a {}`. This should be a syntax error, shouldn't it? Not sure if my changes actually compile, waiting for the LLVM to build.
2016-11-14Fix where clauses parsingAleksey Kladov-1/+1
Don't allow lifetimes without any bounds at all
2016-11-12Auto merge of #37675 - arielb1:trans-closure, r=eddybbors-3/+5
Translate closures through the collector Now that old trans is gone, there is no need for the hack of translating closures when they are instantiated. We can translate them like regular items. r? @eddyb
2016-11-12rustc: move closure upvar types to the closure substsAriel Ben-Yehuda-3/+5
This moves closures to the (DefId, Substs) scheme like all other items, and saves a word from the size of TyS now that Substs is 2 words.
2016-11-12Auto merge of #37531 - estebank:fix-ref-mut-mut, r=jonathandturnerbors-8/+15
Fix invalid "ref mut mut" sugestion Change output from: ```nocode error: cannot borrow immutable local variable `x` as mutable --> <anon>:12:23 | 11 | TestEnum::Item(ref mut x) => { | --------- use `ref mut mut x` here to make mutable 12 | test(&mut x); | ^ cannot borrow mutably ``` to ```nocode error: cannot borrow immutable local variable `x` as mutable --> <anon>:12:23 | 12 | test(&mut x); | ^ | | | cannot reborrow mutably | try removing `&mut` here ``` Fixes #37139, #34337, #34126
2016-11-12Auto merge of #37554 - mikhail-m1:dnlle, r=jonathandturnerbors-13/+12
Improve "Doesn't live long enough" error case with temporary variable issue #36279 part of #35233 r? @jonathandturner
2016-11-10rustc: clean up lookup_item_type and remove TypeScheme.Eduard Burtescu-1/+1
2016-11-10rustc: use an Expr instead of a Block for function bodies.Eduard Burtescu-11/+9
2016-11-09Rollup merge of #37229 - nnethercote:FxHasher, r=nikomatsakisEduard-Mihai Burtescu-9/+9
Replace FNV with a faster hash function. Hash table lookups are very hot in rustc profiles and the time taken within `FnvHash` itself is a big part of that. Although FNV is a simple hash, it processes its input one byte at a time. In contrast, Firefox has a homespun hash function that is also simple but works on multiple bytes at a time. So I tried it out and the results are compelling: ``` futures-rs-test 4.326s vs 4.212s --> 1.027x faster (variance: 1.001x, 1.007x) helloworld 0.233s vs 0.232s --> 1.004x faster (variance: 1.037x, 1.016x) html5ever-2016- 5.397s vs 5.210s --> 1.036x faster (variance: 1.009x, 1.006x) hyper.0.5.0 5.018s vs 4.905s --> 1.023x faster (variance: 1.007x, 1.006x) inflate-0.1.0 4.889s vs 4.872s --> 1.004x faster (variance: 1.012x, 1.007x) issue-32062-equ 0.347s vs 0.335s --> 1.035x faster (variance: 1.033x, 1.019x) issue-32278-big 1.717s vs 1.622s --> 1.059x faster (variance: 1.027x, 1.028x) jld-day15-parse 1.537s vs 1.459s --> 1.054x faster (variance: 1.005x, 1.003x) piston-image-0. 11.863s vs 11.482s --> 1.033x faster (variance: 1.060x, 1.002x) regex.0.1.30 2.517s vs 2.453s --> 1.026x faster (variance: 1.011x, 1.013x) rust-encoding-0 2.080s vs 2.047s --> 1.016x faster (variance: 1.005x, 1.005x) syntex-0.42.2 32.268s vs 31.275s --> 1.032x faster (variance: 1.014x, 1.022x) syntex-0.42.2-i 17.629s vs 16.559s --> 1.065x faster (variance: 1.013x, 1.021x) ``` (That's a stage1 compiler doing debug builds. Results for a stage2 compiler are similar.) The attached commit is not in a state suitable for landing because I changed the implementation of FnvHasher without changing its name (because that would have required touching many lines in the compiler). Nonetheless, it is a good place to start discussions. Profiles show very clearly that this new hash function is a lot faster to compute than FNV. The quality of the new hash function is less clear -- it seems to do better in some cases and worse in others (judging by the number of instructions executed in `Hash{Map,Set}::get`). CC @brson, @arthurprs
2016-11-09Improve "Doesn't live long enough" errorMikhail Modin-13/+12
case with temporary variable
2016-11-08Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakisbors-1/+1
Stabilize `..` in tuple (struct) patterns I'd like to nominate `..` in tuple and tuple struct patterns for stabilization. This feature is a relatively small extension to existing stable functionality and doesn't have known blockers. The feature first appeared in Rust 1.10 6 months ago. An example of use: https://github.com/rust-lang/rust/pull/36203 Closes https://github.com/rust-lang/rust/issues/33627 r? @nikomatsakis
2016-11-08Replace FnvHasher use with FxHasher.Nicholas Nethercote-9/+9
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-04Rollup merge of #37408 - eddyb:lazy-5, r=nikomatsakisAlex Crichton-1/+1
[5/n] rustc: record the target type of every adjustment. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37404) | [next](https://github.com/rust-lang/rust/pull/37412)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well. If any motivation is unclear, please ask for additional PR description clarifications or code comments._ <hr> The first commit rearranges `tcx.tables` so that all users go through `tcx.tables()`. This in preparation for per-body `Tables` where they will be requested for a specific `DefId`. Included to minimize churn. The rest of the changes focus on adjustments, there are some renamings, but the main addition is the target type, always available in all cases (as opposed to just for unsizing where it was previously needed). Possibly the most significant effect of this change is that figuring out the final type of an expression is now _always_ just one successful `HashMap` lookup (either the adjustment or, if that doesn't exist, the node type).
2016-11-03Fix invalid "ref mut mut" sugestionEsteban Küber-8/+15
2016-11-03Stabilize `..` in tuple (struct) patternsVadim Petrochenkov-1/+1
2016-11-02Rollup merge of #37498 - sanxiyn:unused-type-alias, r=eddybJonathan Turner-6/+2
Remove unused type aliases Found by extending the dead code lint. The lint itself is work in progress because of false positives. cc #37455.
2016-11-02rustc: make all read access to tcx.tables go through a method.Eduard Burtescu-1/+1
2016-11-01Improve "Doesn't live long enough" errorMikhail Modin-0/+13
case with different lifetime with spans
2016-10-31Changed most vec! invocations to use square bracesiirelu-2/+2
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-31Remove unused type aliasesSeo Sanghyeon-6/+2
2016-10-28rustc: move the MIR map into TyCtxt.Eduard Burtescu-26/+15
2016-10-28rustc: move mir::repr::* to mir.Eduard Burtescu-90/+83
2016-10-26Auto merge of #37270 - Mark-Simulacrum:smallvec-optimized-arenas, r=eddybbors-1/+1
Add ArrayVec and AccumulateVec to reduce heap allocations during interning of slices Updates `mk_tup`, `mk_type_list`, and `mk_substs` to allow interning directly from iterators. The previous PR, #37220, changed some of the calls to pass a borrowed slice from `Vec` instead of directly passing the iterator, and these changes further optimize that to avoid the allocation entirely. This change yields 50% less malloc calls in [some cases](https://pastebin.mozilla.org/8921686). It also yields decent, though not amazing, performance improvements: ``` futures-rs-test 4.091s vs 4.021s --> 1.017x faster (variance: 1.004x, 1.004x) helloworld 0.219s vs 0.220s --> 0.993x faster (variance: 1.010x, 1.018x) html5ever-2016- 3.805s vs 3.736s --> 1.018x faster (variance: 1.003x, 1.009x) hyper.0.5.0 4.609s vs 4.571s --> 1.008x faster (variance: 1.015x, 1.017x) inflate-0.1.0 3.864s vs 3.883s --> 0.995x faster (variance: 1.232x, 1.005x) issue-32062-equ 0.309s vs 0.299s --> 1.033x faster (variance: 1.014x, 1.003x) issue-32278-big 1.614s vs 1.594s --> 1.013x faster (variance: 1.007x, 1.004x) jld-day15-parse 1.390s vs 1.326s --> 1.049x faster (variance: 1.006x, 1.009x) piston-image-0. 10.930s vs 10.675s --> 1.024x faster (variance: 1.006x, 1.010x) reddit-stress 2.302s vs 2.261s --> 1.019x faster (variance: 1.010x, 1.026x) regex.0.1.30 2.250s vs 2.240s --> 1.005x faster (variance: 1.087x, 1.011x) rust-encoding-0 1.895s vs 1.887s --> 1.005x faster (variance: 1.005x, 1.018x) syntex-0.42.2 29.045s vs 28.663s --> 1.013x faster (variance: 1.004x, 1.006x) syntex-0.42.2-i 13.925s vs 13.868s --> 1.004x faster (variance: 1.022x, 1.007x) ``` We implement a small-size optimized vector, intended to be used primarily for collection of presumed to be short iterators. This vector cannot be "upsized/reallocated" into a heap-allocated vector, since that would require (slow) branching logic, but during the initial collection from an iterator heap-allocation is possible. We make the new `AccumulateVec` and `ArrayVec` generic over implementors of the `Array` trait, of which there is currently one, `[T; 8]`. In the future, this is likely to expand to other values of N. Huge thanks to @nnethercote for collecting the performance and other statistics mentioned above.
2016-10-25Utilize AccumulateVec to avoid heap allocations in mk_{substs, type_list, ↵Mark-Simulacrum-1/+1
tup} calls.
2016-10-20improve "Doesn't live long enough" errorMikhail Modin-7/+23
2016-10-17prefer `if let` to match with `None => { }` arm in some placesZack M. Davis-61/+51
In #34268 (8531d581), we replaced matches of None to the unit value `()` with `if let`s in places where it was deemed that this made the code unambiguously clearer and more idiomatic. In #34638 (d37edef9), we did the same for matches of None to the empty block `{}`. A casual observer, upon seeing these commits fly by, might suppose that the matter was then settled, that no further pull requests on this utterly trivial point of style could or would be made. Unless ... It turns out that sometimes people write the empty block with a space in between the braces. Who knew?
2016-10-12Rollup merge of #36995 - nrc:stable, r=@nikomatsakisAlex Crichton-1/+1
stabilise ?, attributes on stmts, deprecate Reflect r? @nikomatsakis
2016-10-12Stabilise `?`Nick Cameron-1/+1
cc [`?` tracking issue](https://github.com/rust-lang/rust/issues/31436)
2016-10-10Move IdxSetBuf and BitSlice to rustc_data_structuresWesley Wiser-314/+8
Resolves a FIXME
2016-09-27Ignore local kind in MIR dataflowJonas Schievink-10/+3
2016-09-26Rename MIR local iterators to match conventionJonas Schievink-1/+1
2016-09-26[WIP] Move MIR towards a single kind of localJonas Schievink-59/+38
2016-09-19librustc: Implement def-use chains and trivial copy propagation on MIR.Patrick Walton-0/+1
This only supports trivial cases in which there is exactly one def and one use.
2016-09-19librustc: Add a new nop statement to the MIR.Patrick Walton-3/+6
This is useful when passes want to remove statements without affecting `Location`s.
2016-09-16fix dynamic drop for unionsAriel Ben-Yehuda-22/+36
Moving out of a union is now treated like moving out of its parent type. Fixes #36246
2016-09-16forbid moves out of slicesAriel Ben-Yehuda-12/+15
The wording of RFC #495 enables moves out of slices. Unfortuantely, non-zeroing moves out of slices introduce a very annoying complication: as slices can vary in their length, indexes from the start and end may or may not overlap depending on the slice's exact length, which prevents assigning a particular drop flag for each individual element. For example, in the code ```Rust fn foo<T>(a: Box<[Box<[T]>]>, c: bool) -> T { match (a, c) { (box [box [t, ..], ..], true) => t, (box [.., box [.., t]], false) => t, _ => panic!() } } ``` If the condition is false, we have to drop the first element of `a`, unless `a` has size 1 in which case we drop all the elements of it but the last. If someone comes with a nice way of handling it, we can always re-allow moves out of slices. This is a [breaking-change], but it is behind the `slice_patterns` feature gate and was not allowed until recently.
2016-09-16groundwork refactoring of `gather_moves`Ariel Ben-Yehuda-703/+474
2016-09-08Refactor `TyStruct`/`TyEnum`/`TyUnion` into `TyAdt`Vadim Petrochenkov-91/+90
2016-09-04Replace `_, _` with `..`Vadim Petrochenkov-30/+30
2016-09-04Replace `_, _, _` with `..`Vadim Petrochenkov-3/+4