Skip to content

Commit 99f05e8

Browse files
committedSep 19, 2018
Improve handling of type bounds in bit_set.rs.
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.

File tree

6 files changed

+210
-202
lines changed

6 files changed

+210
-202
lines changed
 

‎src/librustc/traits/select.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use ty::relate::TypeRelation;
4444
use middle::lang_items;
4545
use mir::interpret::{GlobalId};
4646

47-
use rustc_data_structures::bit_set::BitSet;
47+
use rustc_data_structures::bit_set::GrowableBitSet;
4848
use rustc_data_structures::sync::Lock;
4949
use std::iter;
5050
use std::cmp;
@@ -3069,7 +3069,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
30693069
} else {
30703070
return Err(Unimplemented);
30713071
};
3072-
let mut ty_params = BitSet::new_empty(substs_a.types().count());
3072+
let mut ty_params = GrowableBitSet::new_empty();
30733073
let mut found = false;
30743074
for ty in field.walk() {
30753075
if let ty::Param(p) = ty.sty {

0 commit comments

Comments
 (0)
Please sign in to comment.