about summary refs log tree commit diff
path: root/src/librustc_data_structures
AgeCommit message (Collapse)AuthorLines
2018-12-03data_structures: remove tuple_sliceljedrz-71/+0
2018-11-29Use raw_entry for more efficient interningJohn Kåre Alsaker-0/+70
2018-11-25Remove `OpenSnapshot` and `CommittedSnapshot` markers from `SnapshotMap`.Nicholas Nethercote-34/+25
They're not strictly necessary, and they result in the `Vec` being allocated even for the trivial (and common) case where a `start_snapshot` is immediately followed by a `commit` or `rollback_to`.
2018-11-25Introduce `in_snapshot` and `assert_open_snapshot` methods.Nicholas Nethercote-3/+7
This makes the two snapshot implementations more consistent with each other and with crate `ena`.
2018-11-25Make `commit` and `rollback_to` methods take ownership of the snapshots.Nicholas Nethercote-8/+8
Because they shouldn't be reused. This provides consistency with the `ena` crate.
2018-11-25Replace a `.truncate(0)` call with `.clear()`.Nicholas Nethercote-1/+1
2018-11-25Remove `insert_noop`.Nicholas Nethercote-10/+4
Because it's as useless as its name suggests. This commit also renames `UndoLog::Noop` as `UndoLog::Purged`, because (a) that's a more descriptive name and (b) it matches the name used in similar code in `librustc/infer/region_constraints/mod.rs`.
2018-11-25Update to `ena` 0.11.0.Nicholas Nethercote-1/+1
This version has some significant speed-ups relating to snapshotting.
2018-11-24Rollup merge of #55945 - oli-obk:static_assert_arg_type, r=michaelwoeristerkennytm-1/+2
Ensure that the argument to `static_assert` is a `bool` cc @eddyb
2018-11-21rustc: implement and use Default on more types.Eduard-Mihai Burtescu-23/+25
2018-11-21rustc: remove {FxHash,Node,DefId,HirId,ItemLocal}{Map,Set} "constructor" fns.Eduard-Mihai Burtescu-3/+1
2018-11-16Ensure that the `static_assert!` argument is a `bool`Oliver Scherer-1/+2
2018-11-16remove unused dependencyAndreas Jonson-1/+0
2018-11-15Rollup merge of #55901 - euclio:speling, r=petrochenkovPietro Albini-4/+4
fix various typos in doc comments
2018-11-13fix various typos in doc commentsAndy Russell-4/+4
2018-11-13Move `static_assert!` into librustc_data_structures.Nicholas Nethercote-0/+22
This means it can be used by more crates.
2018-11-07Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwcokennytm-2/+2
refactor: use shorthand fields refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-07Rollup merge of #55501 - nnethercote:DoCompleted, r=pnkfelixkennytm-69/+84
Make `process_obligations`' computation of `completed` optional. It's only used in tests. This reduces instruction counts on several benchmarks by 0.5--1%.
2018-11-06refactor: use shorthand fieldsteresy-2/+2
2018-10-31Bump nightly to 1.32.0Alex Crichton-1/+0
* Also update the bootstrap compiler * Update cargo to 1.32.0 * Clean out stage0 annotations
2018-10-30Make `process_obligations`' computation of `completed` optional.Nicholas Nethercote-69/+84
It's only used in tests. This reduces instruction counts on several benchmarks by 0.5--1%.
2018-10-29Use opt.take() instead of mem::replace(opt, None)ljedrz-5/+3
2018-10-23Auto merge of #54778 - scottmcm:stabilize-ihle, r=pnkfelixbors-1/+1
Stabilize impl_header_lifetime_elision in 2015 ~~This is currently blocked on https://github.com/rust-lang/rust/issues/54902; it should be good after that~~ It's already stable in 2018; this finishes the stabilization. FCP completed (https://github.com/rust-lang/rust/issues/15872#issuecomment-417953153), proposal (https://github.com/rust-lang/rust/issues/15872#issuecomment-412759783). Tracking issue: https://github.com/rust-lang/rust/issues/15872 Usage examples (from libcore): https://github.com/rust-lang/rust/pull/54687
2018-10-19Stabilize impl_header_lifetime_elision in 2015Scott McMurray-1/+1
It's already stable in 2018; this finishes the stabilization.
2018-10-19Update unit testsOliver Scherer-19/+19
2018-10-19Prefer `Default::default` over `FxHash*::default` in struct constructorsOliver Scherer-11/+17
2018-10-19Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hackOliver Scherer-21/+6
2018-10-18Rollup merge of #55127 - ljedrz:simplify_hybridbitset, r=matthewjasperkennytm-36/+14
Remove HybridBitSet::dummy This simplifies some of the `HybridBitSet` code. cc @nnethercote
2018-10-16Remove HybridBitSet::dummyljedrz-36/+14
2018-10-14Added graphviz visualization for obligation forests.Diogo Sousa-0/+105
This can be a big help when debugging the trait resolver.
2018-10-01Rollup merge of #54656 - nieksand:workqueue_doc, r=varkorkennytm-1/+1
Correct doc for WorkQueue<T>::pop(). The old function doc looks like copy-pasta from WorkQueue::insert(). WorkQueue::pop() does not enqueue nor does it return a boolean false. Doc corrected accordingly.
2018-09-30Auto merge of #53255 - orium:fix-bug-overflow-send, r=arielb1bors-25/+76
Add a per-tree error cache to the obligation forest This implements part of what @nikomatsakis mentioned in https://github.com/rust-lang/rust/pull/30533#issuecomment-170705871: > 1. If you find that a new obligation is a duplicate of one already in the tree, the proper processing is: > * if that other location is your parent, you should abort with a cycle error (or accept it, if coinductive) > * if that other location is not an ancestor, you can safely ignore the new obligation In particular it implements the "if that other location is your parent accept it, if coinductive" part. This fixes #40827. I have to say that I'm not 100% confident that this is rock solid. This is my first pull request :tada:, and I didn't know anything about the trait resolver before this. In particular I'm not totally sure that comparing predicates is enough (for instance, do we need to compare `param_env` as well?). Also, I'm not sure what @nikomatsakis mentions [here](https://github.com/rust-lang/rust/issues/30977#issue-127091096), but it might be something that affects this PR: > In particular, I am wary of getting things wrong around inference variables! We can always add things to the set in their current state, and if unifications occur then the obligation is just kind of out-of-date, but I want to be sure we don't accidentally fail to notice that something is our ancestor. I decided this was subtle enough to merit its own PR. Anyway, go ahead and review :slightly_smiling_face:. Ref #30977. # Performance We are now copying vectors around, so I decided to do some benchmarking. A simple benchmark shows that this does not seem to affect performance in a measurable way: I ran `cargo clean && cargo build` 20 times on actix-web (84b27db) and these are the results: ```text rustc master: Mean Std.Dev. Min Median Max real 66.637 2.996 57.220 67.714 69.314 user 307.293 14.741 258.093 312.209 320.702 sys 12.524 0.653 10.499 12.726 13.193 rustc fix-bug-overflow-send: Mean Std.Dev. Min Median Max real 66.297 4.310 53.532 67.516 70.348 user 306.812 22.371 236.917 314.748 326.229 sys 12.757 0.952 9.671 13.125 13.544 ``` I will do a more comprehensive benchmark (compiling rustc stage1) and post the results. r? @nikomatsakis, @nnethercote PS: It is better to review this commit-by-commit.
2018-09-30Deduplicate errors in the obligation forest.Diogo Sousa-19/+72
Fixes #40827.
2018-09-30Typos and style fixes.Diogo Sousa-8/+6
2018-09-30Correct doc for WorkQueue<T>::pop().Niek Sanders-1/+1
2018-09-27Bump to 1.31.0 and bootstrap from 1.30 betaJosh Stone-2/+1
2018-09-26make NLL handle `IfEq` bounds by using SCC normalizationNiko Matsakis-0/+7
2018-09-26Remove OneVectorljedrz-57/+0
2018-09-20Improve handling of type bounds in `bit_set.rs`.Nicholas Nethercote-196/+190
Currently, `BitSet` doesn't actually know its own domain size; it just knows how many words it contains. To improve things, this commit makes the following changes. - It changes `BitSet` and `SparseBitSet` to store their own domain size, and do more precise bounds and same-size checks with it. It also changes the signature of `BitSet::to_string()` (and puts it within `impl ToString`) now that the domain size need not be passed in from outside. - It uses `derive(RustcDecodable, RustcEncodable)` for `BitSet`. This required adding code to handle `PhantomData` in `libserialize`. - As a result, it removes the domain size from `HybridBitSet`, making a lot of that code nicer. - Both set_up_to() and clear_above() were overly general, working with arbitrary sizes when they are only needed for the domain size. The commit removes the former, degeneralizes the latter, and removes the (overly general) tests. - Changes `GrowableBitSet::grow()` to `ensure()`, fixing a bug where a (1-based) domain size was confused with a (0-based) element index. - Changes `BitMatrix` to store its row count, and do more precise bounds checks with it. - Changes `ty_params` in `select.rs` from a `BitSet` to a `GrowableBitSet` because it repeatedly failed the new, more precise bounds checks. (Changing the type was simpler than computing an accurate domain size.) - Various other minor improvements.
2018-09-18Use `HybridBitSet` for rows within `SparseBitMatrix`.Nicholas Nethercote-24/+167
This requires adding a few extra methods to `HybridBitSet`. (These are tested in a new unit test.) This commit reduces the `max-rss` for `nll-check` builds of `html5ever` by 46%, `ucd` by 45%, `clap-rs` by 23%, `inflate` by 14%. And the results for the `unic-ucd-name` crate are even more impressive: a 21% reduction in instructions, a 60% reduction in wall-time, a 96% reduction in `max-rss`, and a 97% reduction in faults! Fixes #52028.
2018-09-18Remove `array_vec.rs`.Nicholas Nethercote-322/+21
`SparseBitSet` is the only remaining user of `ArrayVec`. This commit switches it to using `SmallVec`, and removes `array_vec.rs`. Why the switch? Although `SparseBitSet` is size-limited and doesn't need the ability to spill to the heap, `SmallVec` has many more features than `ArrayVec`. In particular, it's now possible to keep `SparseBitSet`'s elements in sorted order, which gives in-order iteration, which is a requirement for the next commit.
2018-09-18Use `elem` instead of `bit` consistently for arguments.Nicholas Nethercote-22/+22
2018-09-18Some "word"-related improvements.Nicholas Nethercote-71/+66
- Rename `BitSet::data` and `BitMatrix::vector` as `words`, because that's what they are. - Remove `BitSet::words_mut()`, which is no longer necessary. - Better distinguish multiple meanins of "word", i.e. "word index" vs "word ref" vs "word" (i.e. the value itself).
2018-09-18Eliminate `BitwiseOperator`.Nicholas Nethercote-26/+9
`BitwiseOperator` is an unnecessarily low-level thing. This commit replaces it with `BitSetOperator`, which works on `BitSet`s instead of words. Within `bit_set.rs`, the commit eliminates `Intersect`, `Union`, and `Subtract` by instead passing a function to `bitwise()`.
2018-09-18Merge indexed_set.rs into bitvec.rs, and rename it bit_set.rs.Nicholas Nethercote-1157/+1063
Currently we have two files implementing bitsets (and 2D bit matrices). This commit combines them into one, taking the best features from each. This involves renaming a lot of things. The high level changes are as follows. - bitvec.rs --> bit_set.rs - indexed_set.rs --> (removed) - BitArray + IdxSet --> BitSet (merged, see below) - BitVector --> GrowableBitSet - {,Sparse,Hybrid}IdxSet --> {,Sparse,Hybrid}BitSet - BitMatrix --> BitMatrix - SparseBitMatrix --> SparseBitMatrix The changes within the bitset types themselves are as follows. ``` OLD OLD NEW BitArray<C> IdxSet<T> BitSet<T> -------- ------ ------ grow - grow new - (remove) new_empty new_empty new_empty new_filled new_filled new_filled - to_hybrid to_hybrid clear clear clear set_up_to set_up_to set_up_to clear_above - clear_above count - count contains(T) contains(&T) contains(T) contains_all - superset is_empty - is_empty insert(T) add(&T) insert(T) insert_all - insert_all() remove(T) remove(&T) remove(T) words words words words_mut words_mut words_mut - overwrite overwrite merge union union - subtract subtract - intersect intersect iter iter iter ``` In general, when choosing names I went with: - names that are more obvious (e.g. `BitSet` over `IdxSet`). - names that are more like the Rust libraries (e.g. `T` over `C`, `insert` over `add`); - names that are more set-like (e.g. `union` over `merge`, `superset` over `contains_all`, `domain_size` over `num_bits`). Also, using `T` for index arguments seems more sensible than `&T` -- even though the latter is standard in Rust collection types -- because indices are always copyable. It also results in fewer `&` and `*` sigils in practice.
2018-09-15Auto merge of #54177 - nnethercote:streamline-bit-stuff, r=Mark-Simulacrumbors-388/+261
Remove bitslice.rs As the comment in `bitslice.rs` says: > FIXME: merge with `bitvec`
2018-09-14Auto merge of #54032 - oli-obk:layout_scalar_ranges, r=eddybbors-2/+5
Add forever unstable attribute to allow specifying arbitrary scalar ranges r? @eddyb for the first commit and @nikomatsakis for the second one
2018-09-14Rollup merge of #54024 - alexcrichton:compile-to-wasm, r=petrochenkovkennytm-292/+298
Fix compiling some rustc crates to wasm I was dabbling recently seeing what it would take to compile `rustfmt` to the `wasm32-unknown-unknown` target and it turns out not much effort is needed! Currently `rustfmt` depends on a few rustc crates published to crates.io, so this commit touches up those crates to compile for wasm themselves. Notably: * The `rustc_data_structures` crate's `flock` implementation is stubbed out to unconditionally return errors on unsupported platforms. * The `rustc_errors` crate is extended to not do any locking for all non-windows platforms. In both of these cases if we port the compiler to new platforms the functionality isn't critical but will be discovered over time as it comes up, so this hopefully doesn't make it too too hard to compile to new platforms!
2018-09-14Remove `Iter` and `SparseIter` in indexed_set.rs.Nicholas Nethercote-35/+7
Because they're just thin wrappers around `BitIter` and `slice::Iter`.
2018-09-13Remove bitslice.rs.Nicholas Nethercote-317/+221
This requires the following changes. - It moves parts of bitslice.rs into bitvec.rs: `bitwise()`, `BitwiseOperator`, `bits_to_string()`. - It changes `IdxSet` to just be a wrapper around `BitArray`. - It changes `BitArray` and `BitVec` to use `usize` words instead of `u128` words. (`BitSlice` and `IdxSet` already use `usize`.) Local profiling showed `usize` was better. - It moves some operations from `IdxSet` into `BitArray`: `new_filled()`, `clear()`, `set_up_to()`, `trim_to()` (renamed `clear_above()`), `words()` and `words_mut()`, `encode()` and `decode(). The `IdxSet` operations now just call the `BitArray` operations. - It replaces `BitArray`'s iterator implementation with `IdxSet`'s, because the latter is more concise. It also removes the buggy `size_hint` function from `BitArray`'s iterator, which counted the number of *words* rather than the number of *bits*. `IdxSet`'s iterator is now just a thin wrapper around `BitArray`'s iterator. - It moves some unit tests from `indexed_set.rs` to `bitvec.rs`.