summary refs log tree commit diff
path: root/src/librustc
AgeCommit message (Collapse)AuthorLines
2017-05-24box large variants in MIRAriel Ben-Yehuda-8/+9
Operand: 72 -> 24 B Statement: 192 -> 96 B Terminator: 256 -> 112 B librustc translation memory usage: 1795 -> 1669 MB next step would be interning lvalues, I suppose?
2017-05-23do not fetch variance for items when equatingNiko Matsakis-31/+55
Fixes #41849. Problem was that evaluating the constant expression required evaluating a trait, which would equate types, which would request variance information, which it would then discard. However, computing the variance information would require determining the type of a field, which would evaluate the constant expression. (This problem will potentially arise *later* as we move to more sophisticated constants, however, where we need to check subtyping. We can tackle that when we come to it.)
2017-05-23use equality in the coerce-unsized checkNiko Matsakis-0/+19
This seems both to be a safe, conservative choice, and it sidesteps the cycle in #41936. Fixes #41936.
2017-05-23add a WF obligation if a type variable appears in bivariant positionNiko Matsakis-18/+69
2017-05-23replace the type generalizer with one based on varianceNiko Matsakis-35/+146
2017-05-10typeck: resolve type vars before calling `try_index_step`Ariel Ben-Yehuda-2/+9
`try_index_step` does not resolve type variables by itself and would fail otherwise. Also harden the failure path in `confirm` to cause less confusing errors.
2017-04-24Fix type error.Without Boats-1/+1
2017-04-24Add compile-fail test.Without Boats-1/+1
2017-04-23Associated consts are not object safe.Without Boats-0/+9
2017-04-23Auto merge of #41486 - arielb1:select-where, r=eddybbors-1/+6
traits::select: quickly filter out predicates from other traits this improves most pre-trans passes's performance by ~1%. That missed the spring cleaning PR because I wanted to ship it. r? @eddyb
2017-04-23cache ADT dtorck resultsAriel Ben-Yehuda-23/+252
This avoids visiting the fields of all structs multiple times, improving item-bodies checking time by 10% (!).
2017-04-23traits::select: quickly filter out predicates from other traitsAriel Ben-Yehuda-1/+6
this improves most pre-trans passes's performance by ~1%.
2017-04-23clean-up adt_sized_constraint now that it uses on-demandAriel Ben-Yehuda-49/+21
2017-04-23rustc_const_eval: support all unit enum variants.Eduard-Mihai Burtescu-8/+29
2017-04-23rustc_const_eval: CallOn isn't needed, typeck/const-qualif handle those cases.Eduard-Mihai Burtescu-2/+0
2017-04-23rustc: make the const-eval cache polymorphic.Eduard-Mihai Burtescu-15/+40
2017-04-22bail out of selection when there are multiple surviving candidatesAriel Ben-Yehuda-7/+7
In some cases (e.g. <[int-var] as Add<[int-var]>>), selection can turn up a large number of candidates. Bailing out early avoids O(n^2) performance. This improves item-type checking time by quite a bit, resulting in ~2% of total time-to-typeck.
2017-04-22add a cache to impl_polarityAriel Ben-Yehuda-10/+3
this is another one of these things that looks *much* worse on valgrind.
2017-04-22weak_lang_items: check for `lang` attribute before calling `value_str`Ariel Ben-Yehuda-3/+4
improves trans performance by *another* 10%.
2017-04-22cache attributes of items from foreign cratesAriel Ben-Yehuda-10/+23
this avoids parsing item attributes on each call to `item_attrs`, which takes off 33% (!) of translation time and 50% (!) of trans-item collection time.
2017-04-22short-cut SharedCrateContext::layout_ofAriel Ben-Yehuda-28/+26
That method is *incredibly* hot, so this ends up saving 10% of trans time. BTW, we really should be doing dependency tracking there - and possibly be taking the respective perf hit (got to find a way to make DTMs fast), but `layout_cache` is a non-dep-tracking map.
2017-04-22avoid calling `mk_region` unnecessarilyAriel Ben-Yehuda-22/+54
this improves typeck & trans performance by 1%. This looked hotter on callgrind than it is on a CPU.
2017-04-22Auto merge of #41464 - frewsxcv:rollup, r=frewsxcvbors-5/+228
Rollup of 3 pull requests - Successful merges: #41077, #41355, #41450 - Failed merges:
2017-04-22Auto merge of #39999 - bitshifter:struct_align, r=eddybbors-9/+111
Implementation of repr struct alignment RFC 1358. The main changes around rustc::ty::Layout::struct: * Added abi_align field which stores abi alignment before repr align is applied * align field contains transitive repr alignment * Added padding vec which stores padding required after fields The main user of this information is rustc_trans::adt::struct_llfields which determines the LLVM fields to be used by LLVM, including padding fields. A possible future optimisation would be to put the padding Vec in an Option, since it will be unused unless you are using repr align.
2017-04-21move the uses of the trans caches into rustc::traitsNiko Matsakis-4/+143
This makes these routines more readily available for other bits of code. It also will help when refactoring.
2017-04-21move the trans trait caches into tcxNiko Matsakis-0/+77
Arguably these could become custom queries, but I chose not to do that because the relationship of queries and trait system is not yet fleshed out enough. For now it seems fine to have them be `DepTrackingMap` using the memoize pattern.
2017-04-21make `reachable_set` ref-countedNiko Matsakis-5/+6
Once it is computed, no need to deep clone the set.
2017-04-21introduce `is_foreign_item` queryNiko Matsakis-0/+6
This may seem like overkill, but it's exactly what we want/need for incremental compilation I think. In particular, while generating code for some codegen unit X, we can wind up querying about any number of external items, and we only want to be forced to rebuild X is some of those changed from a foreign item to otherwise. Factoring this into a query means we would re-run only if some `false` became `true` (or vice versa).
2017-04-21Implementation of repr struct alignment RFC 1358.Cameron Hart-9/+111
The main changes around rustc::ty::Layout::struct and rustc_trans:adt: * Added primitive_align field which stores alignment before repr align * Always emit field padding when generating the LLVM struct fields * Added methods for adjusting field indexes from the layout index to the LLVM struct field index The main user of this information is rustc_trans::adt::struct_llfields which determines the LLVM fields to be used by LLVM, including padding fields.
2017-04-20rustc: combine type_needs_drop_given_env and may_drop into needs_drop.Eduard-Mihai Burtescu-55/+60
2017-04-20rustc: replace TypeContents::needs_drop with Ty::may_drop.Eduard-Mihai Burtescu-154/+87
2017-04-20rustc: replace interior_unsafe with a Freeze trait.Eduard-Mihai Burtescu-12/+55
2017-04-20rustc: simplify TypeContents drastically.Eduard-Mihai Burtescu-148/+42
2017-04-20Rollup merge of #41377 - nikomatsakis:issue-41298-ICE-inference, r=eddybCorey Farwell-11/+24
Fix ICE building gluon_vm The problem was due to various places we were failing to propagate obligations. I think I got them mostly correct, but I didn't get around to writing test cases for each case. r? @eddyb or @arielb1
2017-04-20Rollup merge of #41214 - estebank:less-multiline, r=petrochenkovCorey Farwell-15/+13
Add a way to get shorter spans until `char` for pointing at defs ```rust error[E0072]: recursive type `X` has infinite size --> file.rs:10:1 | 10 | struct X { | ^^^^^^^^ recursive type has infinite size | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `X` representable ``` vs ```rust error[E0072]: recursive type `X` has infinite size --> file.rs:10:1 | 10 | struct X { | _^ starting here... 11 | | x: X, 12 | | } | |_^ ...ending here: recursive type has infinite size | = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `X` representable ``` Re: #35965, #38246. Follow up to #38328. r? @jonathandturner
2017-04-19propagate other obligations that were left outNiko Matsakis-7/+20
cc #32730 -- I left exactly one instance where I wasn't sure of the right behavior.
2017-04-19propagate obligations during overlap checkNiko Matsakis-4/+4
2017-04-19Auto merge of #41325 - eddyb:isolate-snapshots-for-good, r=arielb1bors-30/+30
Ban registering obligations during InferCtxt snapshots. Back in #33852, a flag was added to `InferCtxt` to prevent rolling back a snapshot if obligations were added to some `FulfillmentContext` during the snapshot, to prevent leaking fresh inference variables (created during that snapshot, so their indices would get reused) in obligations, which could ICE or worse. But that isn't enough in the long run, as type-checking ends up relying on success implying that eager side-effects are fine, and while stray obligations *do* get caught nowadays, those errors prevent, e.g. the speculative coercions from #37658, which *have to* be rolled back *even* if they succeed. We can't just allow those obligations to stay around though, because we end up, again, in ICEs or worse. Instead, this PR modifies `lookup_method_in_trait_adjusted` to return `InferOk` containing the obligations that `Autoderef::finalize_as_infer_ok` can propagate to deref coercions. As there shouldn't be *anything* left that registers obligations during snapshots, it's completely banned. r? @nikomatsakis @arielb1
2017-04-19Auto merge of #41236 - cengizIO:master, r=nikomatsakisbors-41/+86
Move E0101 and E0102 logic into new E0282 mechanism #40013 Hello there! ## What's this? Previously, me and @nikomatsakis worked on error messages of uninferred locals. (#38812) This aims to build up on that by moving certain type checks from `writeback`. With this, `E0101` and `E0102` errors are getting obsoleted and no longer thrown. They're replaced with customized versions of `E0282`s instead. ## Sample Error Messages #### `E0101` is getting converted into: ```rust error[E0282]: type annotations needed --> test.rs:2:14 | 2 | let x = |_| {}; | ^ consider giving this closure parameter a type error: aborting due to previous error ``` #### `E0102` is getting converted into: ```rust error[E0282]: type annotations needed --> test.rs:2:9 | 2 | let x = []; | ^ | | | consider giving `x` a type | cannot infer type for `[_; 0]` error: aborting due to previous error ``` ## Annoyances - I think we need to change our way of type name resolving in relevant places, because that `[_; 0]` looks horrible IMHO. - I'm not terribly happy with the note ordering of errors. So please do point to code that might help me accomplish this. ## Tests Tests of `E0101` and `E0102` are getting converted from `compile-fail` to `ui` tests. ## Documentation Please help me with documentation update. There are some confusing places that needed an update but I'm not sure if I did the right ones. Please do comment on messages, layouts and other details. ## Appreciation Huge thanks goes to @nikomatsakis for being a patient and humble mentor along this long journey. 🍻
2017-04-18change note for patternsCengiz Can-1/+1
2017-04-18comment out removed error codesCengiz Can-52/+2
2017-04-18fixes #40013Cengiz Can-41/+136
2017-04-18kill a bunch of one off tasksNiko Matsakis-33/+0
2017-04-18convert calls to `visit_all_item_likes_in_krate`Niko Matsakis-23/+2
We no longer need to track the tasks in these cases since these particular tasks have no outputs (except, potentially, errors...) and they always execute.
2017-04-18Auto merge of #41357 - frewsxcv:rollup, r=frewsxcvbors-8/+261
Rollup of 3 pull requests - Successful merges: #41262, #41310, #41344 - Failed merges:
2017-04-17Rollup merge of #41310 - eddyb:demand-const-eval, r=nikomatsakisCorey Farwell-8/+261
[on-demand] Turn monomorphic_const_eval into a proper query, not just a cache. The error definitions and reporting logic, alongside with `eval_length` were moved to `librustc`. Both local and cross-crate constant evaluation is on-demand now, but the latter is only used for `enum` discriminants, to replace the manual insertion into the cache which was done when decoding variants. r? @nikomatsakis
2017-04-17rustc: move associated_item_def_ids to an on-demand query.Eduard-Mihai Burtescu-25/+25
2017-04-16Compress ReprOptions a little bitSimonas Kazlauskas-31/+61
2017-04-16rustc: use monomorphic const_eval for cross-crate enum discriminants.Eduard-Mihai Burtescu-1/+46
2017-04-16rustc: expose monomorphic const_eval through on-demand.Eduard-Mihai Burtescu-1/+36