summary refs log tree commit diff
path: root/src/librustc_const_eval
AgeCommit message (Collapse)AuthorLines
2016-12-02Auto merge of #38053 - eddyb:lazy-9, r=nikomatsakisbors-24/+12
[9/n] rustc: move type information out of AdtDef and TraitDef. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37688) | [next]()) 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> Both `AdtDef` and `TraitDef` contained type information (field types, generics and predicates) which was required to create them, preventing their use before that type information exists, or in the case of field types, *mutation* was required, leading to a variance-magicking implementation of `ivar`s. This PR takes that information out and the resulting cleaner setup could even eventually end up merged with HIR, because, just like `AssociatedItem` before it, there's no dependency on types anymore. (With one exception, variant discriminants should probably be moved into their own map later.)
2016-11-30Update the bootstrap compilerAlex Crichton-2/+0
Now that we've got a beta build, let's use it!
2016-11-29rustc: simplify AdtDef by removing the field types and ty::ivar.Eduard-Mihai Burtescu-24/+12
2016-11-29revamp `Visitor` with a single method for controlling nested visitsNiko Matsakis-5/+9
2016-11-29Fix rebase breakageFlorian Diebold-3/+6
2016-11-29Split nested_visit_mode function off from nested_visit_mapFlorian Diebold-3/+7
... and make the latter mandatory to implement.
2016-11-29Refactor inlined items some moreFlorian Diebold-19/+28
They don't implement FnLikeNode anymore, instead are handled differently further up in the call tree. Also, keep less information (just def ids for the args).
2016-11-29Add make tidy fixesFlorian Diebold-8/+11
2016-11-29Fix cross-crate associated constant evaluationFlorian Diebold-12/+30
2016-11-29Give function bodies their own dep graph nodeFlorian Diebold-1/+0
2016-11-29Save bodies of functions for inlining into other cratesFlorian Diebold-42/+9
This is quite hacky and I hope to refactor it a bit, but at least it seems to work.
2016-11-29rustc_const_eval: fix compilationFlorian Diebold-13/+18
2016-11-28rustc: embed path resolutions into the HIR instead of keeping DefMap.Eduard-Mihai Burtescu-83/+84
2016-11-28rustc: desugar UFCS as much as possible during HIR lowering.Eduard Burtescu-28/+29
2016-11-22Make is_uninhabited respect privacyAndrew Cann-1/+1
2016-11-22Change HirVec<P<T>> to HirVec<T> in Expr.Nicholas Nethercote-1/+1
This changes structures like this: ``` [ ExprArray | 8 | P ] | v [ P | P | P | P | P | P | P | P ] | v [ ExprTup | 2 | P ] | v [ P | P ] | v [ Expr ] ``` to this: ``` [ ExprArray | 8 | P ] | v [ [ ExprTup | 2 | P ] | ... ] | v [ Expr | Expr ] ```
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-5/+5
places.
2016-11-17Auto merge of #37660 - nikomatsakis:incremental-36349, r=eddybbors-1/+2
Separate impl items from the parent impl This change separates impl item bodies out of the impl itself. This gives incremental more resolution. In so doing, it refactors how the visitors work, and cleans up a bit of the collect/check logic (mostly by moving things out of collect that didn't really belong there, because they were just checking conditions). However, this is not as effective as I expected, for a kind of frustrating reason. In particular, when invoking `foo.bar()` you still wind up with dependencies on private items. The problem is that the method resolution code scans that list for methods with the name `bar` -- and this winds up touching *all* the methods, even private ones. I can imagine two obvious ways to fix this: - separating fn bodies from fn sigs (#35078, currently being pursued by @flodiebold) - a more aggressive model of incremental that @michaelwoerister has been advocating, in which we hash the intermediate results (e.g., the outputs of collect) so that we can see that the intermediate result hasn't changed, even if a particular impl item has changed. So all in all I'm not quite sure whether to land this or not. =) It still seems like it has to be a win in some cases, but not with the test cases we have just now. I can try to gin up some test cases, but I'm not sure if they will be totally realistic. On the other hand, some of the early refactorings to the visitor trait seem worthwhile to me regardless. cc #36349 -- well, this is basically a fix for that issue, I guess r? @michaelwoerister NB: Based atop of @eddyb's PR https://github.com/rust-lang/rust/pull/37402; don't land until that lands.
2016-11-16refactor Visitor into ItemLikeVisitor and intravisit::VisitorNiko Matsakis-1/+2
There are now three patterns (shallow, deep, and nested visit). These are described in detail on the docs in `itemlikevisit::ItemLikeVisitor`.
2016-11-14Uncomment some long error explanationGuillaume Gomez-4/+6
2016-11-10Work around a borrow surviving too long (fixes #37686)Anthony Ramine-1/+2
2016-11-09Auto merge of #37678 - eddyb:rollup, r=eddybbors-11/+5
Rollup of 5 pull requests - Successful merges: #37402, #37412, #37661, #37664, #37667 - Failed merges:
2016-11-10Rollup merge of #37412 - eddyb:lazy-6, r=nikomatsakisEduard-Mihai Burtescu-4/+3
[6/n] rustc: transition HIR function bodies from Block to Expr. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37408) | [next](https://github.com/rust-lang/rust/pull/37676)) 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 main change here is that functions and closures both use `Expr` instead of `Block` for their bodies. For closures this actually allows a honest representation of brace-less closure bodies, e.g. `|x| x + 1` is now distinguishable from `|x| { x + 1 }`, therefore this PR is `[syntax-breaking]` (cc @Manishearth). Using `Expr` allows more logic to be shared between constant bodies and function bodies, with some small such changes already part of this PR, and eventually easing #35078 and per-body type tables. Incidentally, there used to be some corners cut here and there and as such I had to (re)write divergence tracking for type-checking so that it is capable of understanding basic structured control-flow: ``` rust fn a(x: bool) -> i32 { // match also works (as long as all arms diverge) if x { panic!("true") } else { return 1; } 0 // "unreachable expression" after this PR } ``` And since liveness' "not all control paths return a value" moved to type-checking we can have nice things: ``` rust // before & after: fn b() -> i32 { 0; } // help: consider removing this semicolon // only after this PR fn c() -> i32 { { 0; } } // help: consider removing this semicolon fn d() { let x: i32 = { 0; }; } // help: consider removing this semicolon fn e() { f({ 0; }); } // help: consider removing this semicolon ```
2016-11-10rustc: unify and simplify managing associated items.Eduard Burtescu-7/+2
2016-11-10rustc: use an Expr instead of a Block for function bodies.Eduard Burtescu-4/+3
2016-11-09Auto merge of #37603 - arielb1:max-slice-length, r=nikomatsakisbors-8/+97
_match: correct max_slice_length logic The logic used to be wildly wrong, but before the HAIR patch its wrongness was in most cases hidden by another bug. Fixes #37598. r? @nikomatsakis
2016-11-09Rollup merge of #37229 - nnethercote:FxHasher, r=nikomatsakisEduard-Mihai Burtescu-3/+3
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-08add more commentAriel Ben-Yehuda-14/+61
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-3/+3
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-05Rollup merge of #37577 - nnethercote:shrink-Expr-slightly, r=eddybAlex Crichton-1/+1
Shrink `hir::Expr` slightly r? @eddyb
2016-11-05Rollup merge of #37557 - TimNN:fix-36954, r=eddybAlex Crichton-7/+6
Use DefId's in const eval for cross-crate const fn's Fixes #36954. r? @eddyb cc @raphaelcohn
2016-11-05_match: correct max_slice_length logicAriel Ben-Yehuda-8/+50
The logic used to be wildly wrong, but before the HAIR patch its wrongness was hidden by another bug. Fixes #37598.
2016-11-04Shrink `Expr_::ExprStruct`.Nicholas Nethercote-1/+1
On 64-bit platforms this reduces the size of `Expr_` from 64 bytes to 56 bytes, and reduces the size of `Expr` from 88 bytes to 80 bytes.
2016-11-03use DefId's in const eval for cross-crate const fn'sTim Neumann-7/+6
2016-11-03Stabilize `..` in tuple (struct) patternsVadim Petrochenkov-1/+1
2016-11-02rustc: make all read access to tcx.tables go through a method.Eduard Burtescu-17/+20
2016-10-31Changed most vec! invocations to use square bracesiirelu-3/+3
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-28rustc: move mir::repr::* to mir.Eduard Burtescu-1/+1
2016-10-27Address comments + Fix rebaseVadim Petrochenkov-1/+1
2016-10-27Make sufficiently old or low-impact compatibility lints deny-by-defaultVadim Petrochenkov-2/+0
2016-10-26flatten nested slice patterns in HAIR constructionAriel Ben-Yehuda-10/+43
nested slice patterns have the same functionality as non-nested ones, so flatten them in HAIR construction. Fixes #26158.
2016-10-26handle mixed byte literal and byte array patternsAriel Ben-Yehuda-50/+145
Convert byte literal pattern to byte array patterns when they are both used together. so matching them is properly handled. I could've done the conversion eagerly, but that could have caused a bad worst-case for massive byte-array matches. Fixes #18027. Fixes #25051. Fixes #26510.
2016-10-26remove StaticInliner and NaN checkingAriel Ben-Yehuda-231/+183
NaN checking was a lint for a deprecated feature. It can go away.
2016-10-26stop using MatchCheckCtxt to hold the param-env for check_matchAriel Ben-Yehuda-135/+161
2016-10-26change match checking to use HAIRAriel Ben-Yehuda-254/+376
no intended functional changes
2016-10-26un-break the `construct_witness` logicAriel Ben-Yehuda-150/+187
Fixes #35609.
2016-10-26split the exhaustiveness-checking logic to its own moduleAriel Ben-Yehuda-682/+726
`check_match` is now left with its grab bag of random checks.
2016-10-26refactor the `pat_is_catchall` logicAriel Ben-Yehuda-20/+20
2016-10-26move hair::cx::pattern to const_evalAriel Ben-Yehuda-0/+380