Skip to content

Commit 555d16e

Browse files
committed
Fix change of behaviour found by @dotdash
1 parent ac13722 commit 555d16e

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/librustc_trans/abi.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1056,16 +1056,16 @@ impl<'a, 'tcx> FnType<'tcx> {
10561056
_ => {}
10571057
}
10581058
if let layout::Abi::Scalar(ref scalar) = self.ret.layout.abi {
1059-
if let Some(range) = scalar.range_metadata(bx.cx) {
1060-
// If the value is a boolean, the range is 0..2 and that ultimately
1061-
// become 0..0 when the type becomes i1, which would be rejected
1062-
// by the LLVM verifier.
1063-
match scalar.value {
1064-
layout::Int(..) if !scalar.is_bool() => {
1059+
// If the value is a boolean, the range is 0..2 and that ultimately
1060+
// become 0..0 when the type becomes i1, which would be rejected
1061+
// by the LLVM verifier.
1062+
match scalar.value {
1063+
layout::Int(..) if !scalar.is_bool() => {
1064+
if let Some(range) = scalar.range_metadata(bx.cx) {
10651065
bx.range_metadata(callsite, range);
10661066
}
1067-
_ => {}
10681067
}
1068+
_ => {}
10691069
}
10701070
}
10711071
for arg in &self.args {

src/librustc_trans/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#![allow(unused_attributes)]
2626
#![feature(libc)]
2727
#![feature(quote)]
28+
#![feature(range_contains)]
2829
#![feature(rustc_diagnostic_macros)]
2930
#![feature(slice_sort_by_cached_key)]
3031
#![feature(optin_builtin_traits)]

src/librustc_trans/mir/place.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,17 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
9191
}
9292

9393
let scalar_load_metadata = |load, scalar: &layout::Scalar| {
94-
if let Some(range) = scalar.range_metadata(bx.cx) {
95-
match scalar.value {
96-
layout::Int(..) => {
94+
match scalar.value {
95+
layout::Int(..) => {
96+
if let Some(range) = scalar.range_metadata(bx.cx) {
9797
bx.range_metadata(load, range);
9898
}
99-
layout::Pointer if 0 < range.start && range.start < range.end => {
100-
bx.nonnull_metadata(load);
101-
}
102-
_ => {}
10399
}
100+
layout::Pointer
101+
if (1..scalar.valid_range.end).contains(&scalar.valid_range.start) => {
102+
bx.nonnull_metadata(load);
103+
}
104+
_ => {}
104105
}
105106
};
106107

0 commit comments

Comments
 (0)