diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-07-12 11:55:29 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2019-07-15 18:41:23 +0300 |
| commit | dfbf4646f74a120fe736599faa81643a78aaf029 (patch) | |
| tree | 56c2d21a01fe7dd21453ee6fb9ef6617d8ccd187 /src/librustc/ty | |
| parent | 8c050fc805e601783765d0a58b2dbe3d948b6cd6 (diff) | |
| download | rust-dfbf4646f74a120fe736599faa81643a78aaf029.tar.gz rust-dfbf4646f74a120fe736599faa81643a78aaf029.zip | |
rustc_target: move abi::Niche from rustc::ty::layout.
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/layout.rs | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index bf48b9ead05..a60842f5681 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2222,57 +2222,6 @@ where } } -struct Niche { - offset: Size, - scalar: Scalar, -} - -impl Niche { - fn available<C: HasDataLayout>(&self, cx: &C) -> u128 { - let Scalar { value, valid_range: ref v } = self.scalar; - let bits = value.size(cx).bits(); - assert!(bits <= 128); - let max_value = !0u128 >> (128 - bits); - - // Find out how many values are outside the valid range. - let niche = v.end().wrapping_add(1)..*v.start(); - niche.end.wrapping_sub(niche.start) & max_value - } - - fn reserve<C: HasDataLayout>(&self, cx: &C, count: u128) -> Option<(u128, Scalar)> { - assert!(count > 0); - - let Scalar { value, valid_range: ref v } = self.scalar; - let bits = value.size(cx).bits(); - assert!(bits <= 128); - let max_value = !0u128 >> (128 - bits); - - if count > max_value { - return None; - } - - // Compute the range of invalid values being reserved. - let start = v.end().wrapping_add(1) & max_value; - let end = v.end().wrapping_add(count) & max_value; - - // If the `end` of our range is inside the valid range, - // then we ran out of invalid values. - // FIXME(eddyb) abstract this with a wraparound range type. - let valid_range_contains = |x| { - if v.start() <= v.end() { - *v.start() <= x && x <= *v.end() - } else { - *v.start() <= x || x <= *v.end() - } - }; - if valid_range_contains(end) { - return None; - } - - Some((start, Scalar { value, valid_range: *v.start()..=end })) - } -} - impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { /// Find the offset of a niche leaf field, starting from /// the given type and recursing through aggregates. |
