Skip to content

Commit 9c297b9

Browse files
authored
Merge pull request #2244 from rust-lang/rustc-pull
Rustc pull update
2 parents a770388 + 41c1461 commit 9c297b9

15 files changed

+89
-30
lines changed

src/bin/miri.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use std::num::NonZero;
2929
use std::ops::Range;
3030
use std::path::PathBuf;
3131
use std::str::FromStr;
32-
use std::sync::Once;
32+
use std::sync::{Arc, Once};
3333
use std::sync::atomic::{AtomicI32, AtomicU32, Ordering};
3434

3535
use miri::{
@@ -38,7 +38,6 @@ use miri::{
3838
};
3939
use rustc_abi::ExternAbi;
4040
use rustc_data_structures::sync;
41-
use rustc_data_structures::sync::Lrc;
4241
use rustc_driver::Compilation;
4342
use rustc_hir::def_id::LOCAL_CRATE;
4443
use rustc_hir::{self as hir, Node};
@@ -134,7 +133,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
134133
// HACK: rustc will emit "crate ... required to be available in rlib format, but
135134
// was not found in this form" errors once we use `tcx.dependency_formats()` if
136135
// there's no rlib provided, so setting a dummy path here to workaround those errors.
137-
Lrc::make_mut(&mut crate_source).rlib = Some((PathBuf::new(), PathKind::All));
136+
Arc::make_mut(&mut crate_source).rlib = Some((PathBuf::new(), PathKind::All));
138137
crate_source
139138
};
140139
});

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg_attr(bootstrap, feature(trait_upcasting))]
12
#![feature(rustc_private)]
23
#![feature(cell_update)]
34
#![feature(float_gamma)]
@@ -9,7 +10,6 @@
910
#![feature(yeet_expr)]
1011
#![feature(nonzero_ops)]
1112
#![feature(let_chains)]
12-
#![feature(trait_upcasting)]
1313
#![feature(strict_overflow_ops)]
1414
#![feature(pointer_is_aligned_to)]
1515
#![feature(unqualified_local_imports)]

src/machine.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,11 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
11501150
interp_ok(ecx.tcx.sess.ub_checks())
11511151
}
11521152

1153+
#[inline(always)]
1154+
fn contract_checks(ecx: &InterpCx<'tcx, Self>) -> InterpResult<'tcx, bool> {
1155+
interp_ok(ecx.tcx.sess.contract_checks())
1156+
}
1157+
11531158
#[inline(always)]
11541159
fn thread_local_static_pointer(
11551160
ecx: &mut MiriInterpCx<'tcx>,

tests/fail/dyn-upcast-trait-mismatch.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Validation stops this too early.
22
//@compile-flags: -Zmiri-disable-validation
33

4-
#![feature(trait_upcasting)]
5-
#![allow(incomplete_features)]
6-
74
trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
85
#[allow(dead_code)]
96
fn a(&self) -> i32 {
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![feature(core_intrinsics)]
2+
fn main() {
3+
// one bit in common
4+
unsafe { std::intrinsics::disjoint_bitor(0b01101001_u8, 0b10001110) }; //~ ERROR: Undefined Behavior
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: `assume` called with `false`
2+
--> tests/fail/intrinsics/disjoint_bitor.rs:LL:CC
3+
|
4+
LL | unsafe { std::intrinsics::disjoint_bitor(0b01101001_u8, 0b10001110) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` called with `false`
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/intrinsics/disjoint_bitor.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
unsafe {
3+
(&1_u8 as *const u8).offset_from(&2_u8); //~ERROR: not both derived from the same allocation
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
2+
--> tests/fail/intrinsics/ptr_offset_from_different_allocs.rs:LL:CC
3+
|
4+
LL | (&1_u8 as *const u8).offset_from(&2_u8);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/intrinsics/ptr_offset_from_different_allocs.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

tests/fail/intrinsics/ptr_offset_from_different_ints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ fn main() {
1515
let _ = p1.byte_offset_from(p1);
1616

1717
// UB because different pointers.
18-
let _ = p1.byte_offset_from(p2); //~ERROR: no provenance
18+
let _ = p1.byte_offset_from(p2); //~ERROR: not both derived from the same allocation
1919
}
2020
}

tests/fail/intrinsics/ptr_offset_from_different_ints.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: Undefined Behavior: out-of-bounds `offset_from` origin: expected a pointer to the end of 1 byte of memory, but got 0xb[noalloc] which is a dangling pointer (it has no provenance)
1+
error: Undefined Behavior: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
22
--> tests/fail/intrinsics/ptr_offset_from_different_ints.rs:LL:CC
33
|
44
LL | let _ = p1.byte_offset_from(p2);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to the end of 1 byte of memory, but got 0xb[noalloc] which is a dangling pointer (it has no provenance)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
let mem = [0u8; 1];
3+
let ptr = mem.as_ptr();
4+
unsafe {
5+
ptr.wrapping_add(4).offset_from(ptr); //~ERROR: the memory range between them is not in-bounds of an allocation
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation
2+
--> tests/fail/intrinsics/ptr_offset_from_oob.rs:LL:CC
3+
|
4+
LL | ptr.wrapping_add(4).offset_from(ptr);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/intrinsics/ptr_offset_from_oob.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

tests/pass/binops.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
fn test_nil() {
44
assert_eq!((), ());
5-
assert!((!(() != ())));
6-
assert!((!(() < ())));
7-
assert!((() <= ()));
8-
assert!((!(() > ())));
9-
assert!((() >= ()));
5+
assert!(!(() != ()));
6+
assert!(!(() < ()));
7+
assert!(() <= ());
8+
assert!(!(() > ()));
9+
assert!(() >= ());
1010
}
1111

1212
fn test_bool() {
13-
assert!((!(true < false)));
14-
assert!((!(true <= false)));
15-
assert!((true > false));
16-
assert!((true >= false));
13+
assert!(!(true < false));
14+
assert!(!(true <= false));
15+
assert!(true > false);
16+
assert!(true >= false);
1717

18-
assert!((false < true));
19-
assert!((false <= true));
20-
assert!((!(false > true)));
21-
assert!((!(false >= true)));
18+
assert!(false < true);
19+
assert!(false <= true);
20+
assert!(!(false > true));
21+
assert!(!(false >= true));
2222

2323
// Bools support bitwise binops
2424
assert_eq!(false & false, false);
@@ -65,9 +65,9 @@ fn test_class() {
6565

6666
assert_eq!(q, r);
6767
r.y = 17;
68-
assert!((r.y != q.y));
68+
assert!(r.y != q.y);
6969
assert_eq!(r.y, 17);
70-
assert!((q != r));
70+
assert!(q != r);
7171
}
7272

7373
pub fn main() {

tests/pass/box-custom-alloc.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
3-
#![allow(incomplete_features)] // for trait upcasting
4-
#![feature(allocator_api, trait_upcasting)]
3+
#![feature(allocator_api)]
54

65
use std::alloc::{AllocError, Allocator, Layout};
76
use std::cell::Cell;

tests/pass/dyn-upcast.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(trait_upcasting)]
2-
#![allow(incomplete_features)]
3-
41
use std::fmt;
52

63
fn main() {

0 commit comments

Comments
 (0)