Skip to content

Commit f5d8749

Browse files
committed
Remove contains_zero, respect the compiler
1 parent 021c334 commit f5d8749

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
468468
bx.range_metadata(load, &scalar.valid_range);
469469
}
470470
}
471-
abi::Pointer if !scalar.valid_range.contains_zero() => {
471+
abi::Pointer if !scalar.valid_range.contains(0) => {
472472
bx.nonnull_metadata(load);
473473
}
474474
_ => {}

compiler/rustc_middle/src/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2921,7 +2921,7 @@ where
29212921
return;
29222922
}
29232923

2924-
if !scalar.valid_range.contains_zero() {
2924+
if !scalar.valid_range.contains(0) {
29252925
attrs.set(ArgAttribute::NonNull);
29262926
}
29272927

compiler/rustc_target/src/abi/mod.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,6 @@ impl WrappingRange {
759759
}
760760
}
761761

762-
/// Returns `true` if zero is contained in the range.
763-
/// Equal to `range.contains(0)` but should be faster.
764-
#[inline(always)]
765-
pub fn contains_zero(&self) -> bool {
766-
self.start > self.end || self.start == 0
767-
}
768-
769762
/// Returns `self` with replaced `start`
770763
#[inline(always)]
771764
pub fn with_start(mut self, start: u128) -> Self {
@@ -1266,7 +1259,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
12661259
let scalar_allows_raw_init = move |s: &Scalar| -> bool {
12671260
if zero {
12681261
// The range must contain 0.
1269-
s.valid_range.contains_zero()
1262+
s.valid_range.contains(0)
12701263
} else {
12711264
// The range must include all values.
12721265
s.is_always_valid_for(cx)

0 commit comments

Comments
 (0)