Skip to content

Commit 065ff89

Browse files
committed
Auto merge of #2158 - rust-lang:gesundheit, r=RalfJung
Avoid error patterns matching themselves fixes #2156 fixes #2155 this will be obsolete the moment I extract that data from json diagnostics instead of just regexing the stderr.
2 parents 5c3e4b6 + 3832227 commit 065ff89

18 files changed

+428
-20
lines changed

miri

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ test|test-debug|bless|bless-debug)
133133
;;
134134
esac
135135
# Then test, and let caller control flags.
136-
# Only in root project as `cargo-miri` has no tests.
137-
exec cargo test $CARGO_BUILD_FLAGS "$@"
136+
# Only in root project and ui_test as `cargo-miri` has no tests.
137+
cargo test $CARGO_BUILD_FLAGS "$@"
138+
cargo test $CARGO_BUILD_FLAGS --manifest-path ui_test/Cargo.toml "$@"
138139
;;
139140
run|run-debug)
140141
# Scan for "--target" to set the "MIRI_TEST_TARGET" env var so

tests/compile-fail/intrinsics/copy_unaligned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ fn main() {
99
let mut data = [0u16; 8];
1010
let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16;
1111
// Even copying 0 elements to something unaligned should error
12-
unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment ALIGN, but alignment ALIGN is required
12+
unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment 1, but alignment 2 is required
1313
}

tests/compile-fail/stacked_borrows/static_memory_modification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ static X: usize = 5;
33
#[allow(mutable_transmutes)]
44
fn main() {
55
let _x = unsafe {
6-
std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR writing to ALLOC which is read-only
6+
std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR writing to alloc1 which is read-only
77
};
88
}

tests/compile-fail/unaligned_pointers/dyn_alignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ fn main() {
1616
// Overwrite the data part of `ptr` so it points to `buf`.
1717
unsafe { (&mut ptr as *mut _ as *mut *const u8).write(&buf as *const _ as *const u8); }
1818
// Re-borrow that. This should be UB.
19-
let _ptr = &*ptr; //~ERROR alignment ALIGN is required
19+
let _ptr = &*ptr; //~ERROR alignment 256 is required
2020
}
2121
}

tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ fn main() {
1212
// Manually make sure the pointer is properly aligned.
1313
let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr+1 };
1414
let u16_ptr = base_addr_aligned as *mut u16;
15-
unsafe { *u16_ptr = 2; } //~ERROR memory with alignment ALIGN, but alignment ALIGN is required
15+
unsafe { *u16_ptr = 2; } //~ERROR memory with alignment 1, but alignment 2 is required
1616
println!("{:?}", x);
1717
}

tests/compile-fail/unaligned_pointers/reference_to_packed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ fn main() {
1616
y: 99,
1717
};
1818
let p = &foo.x;
19-
let i = *p; //~ERROR alignment ALIGN is required
19+
let i = *p; //~ERROR alignment 4 is required
2020
}
2121
}

tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ fn main() {
66
let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error.
77
let x = &x[0] as *const _ as *const u32;
88
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
9-
let _x = unsafe { *x }; //~ERROR memory with alignment ALIGN, but alignment ALIGN is required
9+
let _x = unsafe { *x }; //~ERROR memory with alignment 2, but alignment 4 is required
1010
}
1111
}

tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ fn main() {
88
let x = (x.as_ptr() as *const u8).wrapping_offset(3) as *const u32;
99
// This must fail because alignment is violated: the offset is not sufficiently aligned.
1010
// Also make the offset not a power of 2, that used to ICE.
11-
let _x = unsafe { *x }; //~ERROR memory with alignment ALIGN, but alignment ALIGN is required
11+
let _x = unsafe { *x }; //~ERROR memory with alignment 1, but alignment 4 is required
1212
}

tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ fn main() {
88
let x = &x[0] as *const _ as *const u32;
99
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
1010
// The deref is UB even if we just put the result into a raw pointer.
11-
let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment ALIGN, but alignment ALIGN is required
11+
let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required
1212
}
1313
}

tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn main() {
77
let x = i as u8;
88
let x = &x as *const _ as *const [u32; 0];
99
// This must fail because alignment is violated. Test specifically for loading ZST.
10-
let _x = unsafe { *x }; //~ERROR alignment ALIGN is required
10+
let _x = unsafe { *x }; //~ERROR alignment 4 is required
1111
}
1212
}

0 commit comments

Comments
 (0)