repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/address-reuse.rs
src/tools/miri/tests/pass/address-reuse.rs
//! Check that we do sometimes reuse addresses. use std::collections::HashSet; fn main() { let count = 100; let mut addrs = HashSet::<usize>::new(); for _ in 0..count { // We make a `Box` with a layout that's hopefully not used by tons of things inside the // allocator itself, so that we ar...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/loop-break-value.rs
src/tools/miri/tests/pass/loop-break-value.rs
#![feature(never_type)] #![allow(unreachable_code)] #[allow(unused)] fn never_returns() { loop { break loop {}; } } fn main() { let value = 'outer: loop { if 1 == 1 { break 13; } else { let _never: ! = loop { break loop { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/drop_through_trait_object_rc.rs
src/tools/miri/tests/pass/drop_through_trait_object_rc.rs
trait Foo {} struct Bar; static mut DROP_CALLED: bool = false; impl Drop for Bar { fn drop(&mut self) { unsafe { DROP_CALLED = true; } } } impl Foo for Bar {} use std::rc::Rc; fn main() { let b: Rc<dyn Foo> = Rc::new(Bar); assert!(unsafe { !DROP_CALLED }); drop(b); ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/zst_variant_drop.rs
src/tools/miri/tests/pass/zst_variant_drop.rs
struct Foo; impl Drop for Foo { fn drop(&mut self) { unsafe { FOO = true; } } } static mut FOO: bool = false; enum Bar { A(#[allow(dead_code)] Box<i32>), B(Foo), } fn main() { assert!(unsafe { !FOO }); drop(Bar::A(Box::new(42))); assert!(unsafe { !FOO }); d...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/unsized.rs
src/tools/miri/tests/pass/unsized.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(unsized_fn_params)] #![feature(custom_mir, core_intrinsics)] fn unsized_params() { fn f0(_f: dyn FnOnce()) {} fn f1(_s: str) {} fn f2(_x: i32, _y: [i32]) {} fn f3(_p: dyn Send) {} let c: Box<dyn FnOnce()> = Box::new(||...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/tail_call.rs
src/tools/miri/tests/pass/tail_call.rs
#![allow(incomplete_features)] #![feature(explicit_tail_calls)] fn main() { assert_eq!(factorial(10), 3_628_800); assert_eq!(mutually_recursive_identity(1000), 1000); } fn factorial(n: u32) -> u32 { fn factorial_acc(n: u32, acc: u32) -> u32 { match n { 0 => acc, _ => become...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/underscore_pattern.rs
src/tools/miri/tests/pass/underscore_pattern.rs
// Various tests ensuring that underscore patterns really just construct the place, but don't check its contents. #![feature(never_type)] use std::ptr; fn main() { dangling_match(); invalid_match(); dangling_let(); invalid_let(); dangling_let_type_annotation(); invalid_let_type_annotation(); ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/union-overwrite.rs
src/tools/miri/tests/pass/union-overwrite.rs
#[repr(C)] #[derive(Clone, Copy)] struct Pair<T, U>(T, U); #[repr(C)] #[derive(Clone, Copy)] struct Triple<T>(T, T, T); #[repr(C)] union U<A: Copy, B: Copy> { a: Pair<A, A>, b: B, } #[repr(C)] union W<A: Copy, B: Copy> { a: A, b: B, } #[cfg(target_endian = "little")] unsafe fn check() { let mut u...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/products.rs
src/tools/miri/tests/pass/products.rs
fn tuple() -> (i16,) { (1,) } fn tuple_2() -> (i16, i16) { (1, 2) } fn tuple_5() -> (i16, i16, i16, i16, i16) { (1, 2, 3, 4, 5) } #[derive(Debug, PartialEq)] struct Pair { x: i8, y: i8, } fn pair() -> Pair { Pair { x: 10, y: 20 } } fn field_access() -> (i8, i8) { let mut p = Pair { x: 1...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/coroutine.rs
src/tools/miri/tests/pass/coroutine.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(coroutines, coroutine_trait, never_type, stmt_expr_attributes)] use std::fmt::Debug; use std::mem::ManuallyDrop; use std::ops::Coroutine; use std::ops::CoroutineState::{self, *}; use std::pin::Pin; use std::ptr; use std::sync::atomic::{Ato...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/last-use-in-cap-clause.rs
src/tools/miri/tests/pass/last-use-in-cap-clause.rs
// Make sure #1399 stays fixed #[allow(dead_code)] struct A { a: Box<isize>, } fn foo() -> Box<dyn FnMut() -> isize + 'static> { let k: Box<_> = Box::new(22); let _u = A { a: k.clone() }; let result = || 22; Box::new(result) } fn main() { assert_eq!(foo()(), 22); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/subslice_array.rs
src/tools/miri/tests/pass/subslice_array.rs
fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] { [a, b, b, a] } fn main() { let out = bar("baz", "foo"); let [a, xs @ .., d] = out; assert_eq!(a, "baz"); assert_eq!(xs, ["foo", "foo"]); assert_eq!(d, "baz"); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/atomic-readonly-load.rs
src/tools/miri/tests/pass/atomic-readonly-load.rs
// Stacked Borrows doesn't like this. //@compile-flags: -Zmiri-tree-borrows use std::sync::atomic::*; fn main() { // Atomic loads from read-only memory are fine if they are relaxed and small. static X: i32 = 0; let x = &X as *const i32 as *const AtomicI32; let x = unsafe { &*x }; x.load(Ordering::...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/alloc-access-tracking.rs
src/tools/miri/tests/pass/alloc-access-tracking.rs
//@compile-flags: -Zmiri-track-alloc-accesses #[path = "../utils/mod.rs"] mod utils; fn main() { unsafe { let mut b = Box::<[u8; 123]>::new_uninit(); let ptr = b.as_mut_ptr() as *mut u8; utils::miri_track_alloc(ptr); *ptr = 42; // Crucially, only a write is printed here, no read! ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/coerce_non_capture_closure_to_fn_ptr.rs
src/tools/miri/tests/pass/coerce_non_capture_closure_to_fn_ptr.rs
static FOO: fn() = || assert_ne!(42, 43); static BAR: fn(i32, i32) = |a, b| assert_ne!(a, b); // use to first make the closure FnOnce() before making it fn() fn force_once0<R, F: FnOnce() -> R>(f: F) -> F { f } fn force_once1<T, R, F: FnOnce(T) -> R>(f: F) -> F { f } fn force_mut0<R, F: FnMut() -> R>(f: F) -> ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/atomic-compare-exchange-weak-never-fail.rs
src/tools/miri/tests/pass/atomic-compare-exchange-weak-never-fail.rs
//@compile-flags: -Zmiri-compare-exchange-weak-failure-rate=0.0 use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::*; // Ensure that compare_exchange_weak never fails. fn main() { let atomic = AtomicBool::new(false); let tries = 100; for _ in 0..tries { let cur = atomic.load(Relaxe...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/move-data-across-await-point.rs
src/tools/miri/tests/pass/move-data-across-await-point.rs
use std::future::Future; use std::ptr; // This test: // - Compares addresses of non-Copy data before and after moving it // - Writes to the pointer after it has moved across the await point // // This is only meant to assert current behavior, not guarantee that this is // how it should work in the future. In fact, upc...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/async-fn.rs
src/tools/miri/tests/pass/async-fn.rs
#![feature(never_type)] use std::future::Future; // See if we can run a basic `async fn` pub async fn foo(x: &u32, y: u32) -> u32 { let y = &y; let z = 9; let z = &z; let y = async { *y + *z }.await; let a = 10; let a = &a; *x + y + *a } async fn add(x: u32, y: u32) -> u32 { let a = a...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/ptr_raw.rs
src/tools/miri/tests/pass/ptr_raw.rs
use std::mem; use std::ptr::{self, addr_of}; fn basic_raw() { let mut x = 12; let x = &mut x; assert_eq!(*x, 12); let raw = x as *mut i32; unsafe { *raw = 42; } assert_eq!(*x, 42); let raw = x as *mut i32; unsafe { *raw = 12; } *x = 23; assert_eq!(*x...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/float_nan.rs
src/tools/miri/tests/pass/float_nan.rs
// This test's runtime explodes if the GC interval is set to 1 (which we do in CI), so we // override it internally back to the default frequency. //@compile-flags: -Zmiri-provenance-gc=10000 #![feature(float_gamma, portable_simd, core_intrinsics)] use std::fmt; use std::hint::black_box; #[path = "../utils/mod.rs"] mo...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/hashmap.rs
src/tools/miri/tests/pass/hashmap.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::collections::HashMap; use std::hash::BuildHasher; // Gather all references from a mutable iterator and make sure Miri notices if // using them is dangerous. fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator<Item = &'a mut T>) { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/intptrcast.rs
src/tools/miri/tests/pass/intptrcast.rs
//@compile-flags: -Zmiri-permissive-provenance use std::mem; // This strips provenance fn transmute_ptr_to_int<T>(x: *const T) -> usize { unsafe { std::mem::transmute(x) } } fn cast() { // Some casting-to-int with arithmetic. let x = &42 as *const i32 as usize; let y = x * 2; assert_eq!(y, x + x)...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/dst-struct.rs
src/tools/miri/tests/pass/dst-struct.rs
struct Fat<T: ?Sized> { f1: isize, f2: &'static str, ptr: T, } // x is a fat pointer fn foo(x: &Fat<[isize]>) { let y = &x.ptr; assert_eq!(x.ptr.len(), 3); assert_eq!(y[0], 1); assert_eq!(x.ptr[1], 2); assert_eq!(x.f1, 5); assert_eq!(x.f2, "some str"); } fn foo2<T: ToBar>(x: &Fat<[...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/path.rs
src/tools/miri/tests/pass/path.rs
//@compile-flags: -Zmiri-disable-isolation use std::path::{Path, PathBuf, absolute}; #[path = "../utils/mod.rs"] mod utils; #[track_caller] fn assert_absolute_eq(in_: &str, out: &str) { assert_eq!( absolute(in_).unwrap().as_os_str(), Path::new(out).as_os_str(), "incorrect absolute path for...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs
src/tools/miri/tests/pass/box-custom-alloc-aliasing.rs
//! Regression test for <https://github.com/rust-lang/miri/issues/3341>: //! If `Box` has a local allocator, then it can't be `noalias` as the allocator //! may want to access allocator state based on the data pointer. //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(allocator_api)] use...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/async-closure-captures.rs
src/tools/miri/tests/pass/async-closure-captures.rs
// Same as rustc's `tests/ui/async-await/async-closures/captures.rs`, keep in sync #![feature(async_trait_bounds)] use std::future::Future; use std::pin::pin; use std::task::*; fn block_on<T>(fut: impl Future<Output = T>) -> T { let mut fut = pin!(fut); let ctx = &mut Context::from_waker(Waker::noop()); ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/wtf8.rs
src/tools/miri/tests/pass/wtf8.rs
//@only-target: windows use std::ffi::{OsStr, OsString}; use std::os::windows::ffi::{OsStrExt, OsStringExt}; fn test1() { let base = "a\té \u{7f}💩\r"; let mut base: Vec<u16> = OsStr::new(base).encode_wide().collect(); base.push(0xD800); let _res = OsString::from_wide(&base); } fn test2() { let m...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/mpsc.rs
src/tools/miri/tests/pass/mpsc.rs
use std::sync::mpsc::channel; fn main() { let (tx, rx) = channel::<Box<_>>(); tx.send(Box::new(100)).unwrap(); let v = rx.recv().unwrap(); assert_eq!(v, Box::new(100)); tx.send(Box::new(101)).unwrap(); tx.send(Box::new(102)).unwrap(); assert_eq!(rx.recv().unwrap(), Box::new(101)); asse...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/static_mut.rs
src/tools/miri/tests/pass/static_mut.rs
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] use std::ptr::addr_of; static mut FOO: i32 = 42; static BAR: Foo = Foo(addr_of!(FOO)); #[allow(dead_code)] struct Foo(*const i32); unsafe impl Sync for Foo {} fn main() { unsafe { assert_eq!(*BAR.0, 42); ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/float_extra_rounding_error.rs
src/tools/miri/tests/pass/float_extra_rounding_error.rs
//! Check that the flags to control the extra rounding error work. //@revisions: random max none //@[max]compile-flags: -Zmiri-max-extra-rounding-error //@[none]compile-flags: -Zmiri-no-extra-rounding-error #![feature(cfg_select)] use std::collections::HashSet; use std::hint::black_box; fn main() { let expected =...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/vec.rs
src/tools/miri/tests/pass/vec.rs
//@revisions: stack tree //@compile-flags: -Zmiri-strict-provenance //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(iter_advance_by, iter_next_chunk)] // Gather all references from a mutable iterator and make sure Miri notices if // using them is dangerous. fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/try-operator-custom.rs
src/tools/miri/tests/pass/try-operator-custom.rs
fn main() { assert!(Ok::<i32, String>(42) == Ok(42)); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/box.rs
src/tools/miri/tests/pass/box.rs
//@compile-flags: -Zmiri-permissive-provenance #![feature(ptr_internals)] fn main() { into_raw(); into_unique(); boxed_pair_to_vec(); } fn into_raw() { unsafe { let b = Box::new(4i32); let r = Box::into_raw(b); // "lose the tag" let r2 = ((r as usize) + 0) as *mut i32;...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/transmute_ptr.rs
src/tools/miri/tests/pass/transmute_ptr.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::mem; fn t1() { // If we are careful, we can exploit data layout... // This is a tricky case since we are transmuting a ScalarPair type to a non-ScalarPair type. let raw = unsafe { mem::transmute::<&[u8], [*const u8; 2]>(&[42]) };...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/closure-drop.rs
src/tools/miri/tests/pass/closure-drop.rs
struct Foo<'a>(&'a mut bool); impl<'a> Drop for Foo<'a> { fn drop(&mut self) { *self.0 = true; } } fn f<T: FnOnce()>(t: T) { t() } fn main() { let mut ran_drop = false; { let x = Foo(&mut ran_drop); // this closure never by val uses its captures // so it's basicall...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/no_std_miri_start.rs
src/tools/miri/tests/pass/no_std_miri_start.rs
//@compile-flags: -Cpanic=abort #![no_std] #![no_main] use core::fmt::Write; #[path = "../utils/mod.no_std.rs"] mod utils; #[no_mangle] fn miri_start(_argc: isize, _argv: *const *const u8) -> isize { writeln!(utils::MiriStdout, "hello, world!").unwrap(); 0 } #[panic_handler] fn panic_handler(_: &core::panic...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/zst_box.rs
src/tools/miri/tests/pass/zst_box.rs
fn main() { let x = Box::new(()); let y = Box::new(()); drop(y); let z = Box::new(()); drop(x); drop(z); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/align_offset_symbolic.rs
src/tools/miri/tests/pass/align_offset_symbolic.rs
//@compile-flags: -Zmiri-symbolic-alignment-check use std::mem; fn test_align_to() { const N: usize = 4; let d = Box::new([0u32; N]); // Get u8 slice covering the entire thing let s = unsafe { std::slice::from_raw_parts(d.as_ptr() as *const u8, 4 * N) }; let raw = s.as_ptr(); // Cases where w...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/union.rs
src/tools/miri/tests/pass/union.rs
fn main() { a(); b(); c(); d(); } fn a() { #[allow(dead_code)] union U { f1: u32, f2: f32, } let mut u = U { f1: 1 }; unsafe { let b1 = &mut u.f1; *b1 = 5; } assert_eq!(unsafe { u.f1 }, 5); } fn b() { #[derive(Copy, Clone)] struct S {...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/arrays.rs
src/tools/miri/tests/pass/arrays.rs
fn empty_array() -> [u16; 0] { [] } fn mini_array() -> [u16; 1] { [42] } fn big_array() -> [u16; 5] { [5, 4, 3, 2, 1] } fn array_array() -> [[u8; 2]; 3] { [[5, 4], [3, 2], [1, 0]] } fn index_unsafe() -> i32 { let a = [0, 10, 20, 30]; unsafe { *a.get_unchecked(2) } } fn index() -> i32 { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/pattern-types.rs
src/tools/miri/tests/pass/pattern-types.rs
#![feature(pattern_types, pattern_type_macro, sized_hierarchy)] #![allow(dead_code)] use std::marker::PointeeSized; use std::mem::transmute; pub struct NonNull<T: PointeeSized> { pointer: std::pat::pattern_type!(*const T is !null), } trait Trait {} impl Trait for () {} fn main() { unsafe { let _: No...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/drop_through_trait_object.rs
src/tools/miri/tests/pass/drop_through_trait_object.rs
trait Foo {} struct Bar; static mut DROP_CALLED: bool = false; impl Drop for Bar { fn drop(&mut self) { unsafe { DROP_CALLED = true; } } } impl Foo for Bar {} fn main() { let b: Box<dyn Foo> = Box::new(Bar); assert!(unsafe { !DROP_CALLED }); drop(b); assert!(unsa...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/pointers.rs
src/tools/miri/tests/pass/pointers.rs
//@compile-flags: -Zmiri-permissive-provenance #![feature(ptr_metadata, const_raw_ptr_comparison)] #![allow(ambiguous_wide_pointer_comparisons)] use std::mem::{self, transmute}; use std::ptr; fn one_line_ref() -> i16 { *&1 } fn basic_ref() -> i16 { let x = &1; *x } fn basic_ref_mut() -> i16 { let x ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/async-closure-drop.rs
src/tools/miri/tests/pass/async-closure-drop.rs
#![feature(async_fn_traits, async_trait_bounds)] use std::future::Future; use std::pin::pin; use std::task::*; fn block_on<T>(fut: impl Future<Output = T>) -> T { let mut fut = pin!(fut); let ctx = &mut Context::from_waker(Waker::noop()); loop { match fut.as_mut().poll(ctx) { Poll::Pe...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/deriving-associated-types.rs
src/tools/miri/tests/pass/deriving-associated-types.rs
pub trait DeclaredTrait { type Type; } impl DeclaredTrait for i32 { type Type = i32; } pub trait WhereTrait { type Type; } impl WhereTrait for i32 { type Type = i32; } // Make sure we don't add a bound that just shares a name with an associated // type. pub mod module { pub type Type = i32; } #...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/disjoint-array-accesses.rs
src/tools/miri/tests/pass/disjoint-array-accesses.rs
// This is a regression test for issue #135671 where a MIR refactor about arrays and their lengths // unexpectedly caused borrowck errors for disjoint borrows of array elements, for which we had no // tests. This is a collection of a few code samples from that issue. //@revisions: stack tree //@[tree]compile-flags: -Z...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/prefetch.rs
src/tools/miri/tests/pass/prefetch.rs
#![feature(core_intrinsics)] // Test that these intrinsics work. Their behavior should be a no-op. fn main() { static X: [u8; 8] = [0; 8]; ::std::intrinsics::prefetch_read_data::<_, 1>(::std::ptr::null::<u8>()); ::std::intrinsics::prefetch_read_data::<_, 2>(::std::ptr::dangling::<u8>()); ::std::intri...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/ptr_int_casts.rs
src/tools/miri/tests/pass/ptr_int_casts.rs
//@compile-flags: -Zmiri-permissive-provenance //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::{mem, ptr}; fn eq_ref<T>(x: &T, y: &T) -> bool { x as *const _ == y as *const _ } fn f() -> i32 { 42 } fn ptr_int_casts() { // int-ptr-int assert_eq!(1 as *const i32 as usize, ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/enum-nullable-const-null-with-fields.rs
src/tools/miri/tests/pass/enum-nullable-const-null-with-fields.rs
static C: Result<(), Box<isize>> = Ok(()); // This is because of yet another bad assertion (ICE) about the null side of a nullable enum. // So we won't actually compile if the bug is present, but we check the value in main anyway. fn main() { assert!(C.is_ok()); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/c_enums.rs
src/tools/miri/tests/pass/c_enums.rs
enum Foo { Bar = 42, Baz, Quux = 100, } enum Signed { Bar = -42, Baz, Quux = 100, } fn foo() -> [u8; 3] { let baz = Foo::Baz; // let-expansion changes the MIR significantly [Foo::Bar as u8, baz as u8, Foo::Quux as u8] } fn signed() -> [i8; 3] { let baz = Signed::Baz; // let-expans...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/move-arg-2-unique.rs
src/tools/miri/tests/pass/move-arg-2-unique.rs
fn test(foo: Box<Vec<isize>>) { assert_eq!((*foo)[0], 10); } fn main() { let x = Box::new(vec![10]); // Test forgetting a local by move-in test(x); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/tuple_like_struct_constructor.rs
src/tools/miri/tests/pass/tuple_like_struct_constructor.rs
fn main() { #[derive(PartialEq, Eq, Debug)] struct A(i32); assert_eq!(Some(42).map(A), Some(A(42))); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/packed_struct.rs
src/tools/miri/tests/pass/packed_struct.rs
#![feature(unsize, coerce_unsized)] use std::collections::hash_map::DefaultHasher; use std::hash::Hash; use std::ptr; fn test_basic() { #[repr(packed)] struct S { fill: u8, a: i32, b: i64, } #[repr(packed)] #[allow(dead_code)] struct Test1<'a> { x: u8, ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/thread_local-panic.rs
src/tools/miri/tests/pass/thread_local-panic.rs
thread_local! { static LOCAL: u64 = panic!(); } fn main() { let _ = std::panic::catch_unwind(|| LOCAL.with(|_| {})); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/cfg_miri.rs
src/tools/miri/tests/pass/cfg_miri.rs
fn main() { assert!(cfg!(miri)); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/associated-const.rs
src/tools/miri/tests/pass/associated-const.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows trait Foo { const ID: i32; } impl Foo for i32 { const ID: i32 = 1; } fn main() { assert_eq!(1, <i32 as Foo>::ID); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/cast_fn_ptr.rs
src/tools/miri/tests/pass/cast_fn_ptr.rs
fn main() { fn f(_: *const u8) {} let g = unsafe { std::mem::transmute::<fn(*const u8), fn(*const i32)>(f) }; g(&42 as *const _); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/box-custom-alloc.rs
src/tools/miri/tests/pass/box-custom-alloc.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(allocator_api)] use std::alloc::{AllocError, Allocator, Layout}; use std::cell::Cell; use std::mem::MaybeUninit; use std::ptr::{self, NonNull}; struct OnceAlloc<'a> { space: Cell<&'a mut [MaybeUninit<u8>]>, } unsafe impl<'shared, 'a:...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/drop_on_array_elements.rs
src/tools/miri/tests/pass/drop_on_array_elements.rs
#![allow(static_mut_refs)] struct Bar(u16); // ZSTs are tested separately static mut DROP_COUNT: usize = 0; impl Drop for Bar { fn drop(&mut self) { assert_eq!(self.0 as usize, unsafe { DROP_COUNT }); // tests whether we are called at a valid address unsafe { DROP_COUNT += 1; ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/char.rs
src/tools/miri/tests/pass/char.rs
fn main() { let c = 'x'; assert_eq!(c, 'x'); assert!('a' < 'z'); assert!('1' < '9'); assert_eq!(std::char::from_u32('x' as u32), Some('x')); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/reentrant-println.rs
src/tools/miri/tests/pass/reentrant-println.rs
use std::fmt::{Display, Error, Formatter}; // This test case exercises std::sys_common::remutex::ReentrantMutex // by calling println!() from inside fmt. struct InterruptingCow; impl Display for InterruptingCow { fn fmt(&self, _f: &mut Formatter<'_>) -> Result<(), Error> { println!("Moo"); Ok(())...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/move-uninit-primval.rs
src/tools/miri/tests/pass/move-uninit-primval.rs
#![allow(deprecated)] use std::mem; struct Foo { _inner: mem::MaybeUninit<i32>, } fn main() { unsafe { let foo = Foo { _inner: mem::uninitialized() }; let _bar = foo; } }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/extern_crate_std_in_main.rs
src/tools/miri/tests/pass/extern_crate_std_in_main.rs
#![no_std] fn main() { extern crate std; }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/static_align.rs
src/tools/miri/tests/pass/static_align.rs
#![feature(static_align)] #![deny(non_upper_case_globals)] use std::cell::Cell; // When a static uses `align(N)`, its address should be a multiple of `N`. #[rustc_align_static(256)] static FOO: u64 = 0; #[rustc_align_static(512)] static BAR: u64 = 0; struct HasDrop(*const HasDrop); impl Drop for HasDrop { fn ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/loops.rs
src/tools/miri/tests/pass/loops.rs
fn factorial_loop() -> i64 { let mut product = 1; let mut i = 1; while i <= 10 { product *= i; i += 1; } product } fn index_for_loop() -> usize { let mut sum = 0; let a = [0, 10, 20, 30]; for i in 0..a.len() { sum += a[i]; } sum } fn for_loop() -> usiz...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/tuple_like_enum_variant_constructor_pointer_opt.rs
src/tools/miri/tests/pass/tuple_like_enum_variant_constructor_pointer_opt.rs
fn main() { let x = 5; assert_eq!(Some(&x).map(Some), Some(Some(&x))); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/overflow_checks_off.rs
src/tools/miri/tests/pass/overflow_checks_off.rs
//@compile-flags: -C overflow-checks=off // Check that we correctly implement the intended behavior of these operators // when they are not being overflow-checked at runtime. // FIXME: if we call the functions in `std::ops`, we still get the panics. // Miri does not implement the codegen-time hack that backs `#[rustc...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/disable-alignment-check.rs
src/tools/miri/tests/pass/disable-alignment-check.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-disable-alignment-check -Cdebug-assertions=no fn main() { let mut x = [0u8; 20]; let x_ptr: *mut u8 = x.as_mut_ptr(); // At least one of these is definitely unaligned. unsafe { *(x_ptr as *mut u64) = 4...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/ptr_offset.rs
src/tools/miri/tests/pass/ptr_offset.rs
//@compile-flags: -Zmiri-permissive-provenance use std::{mem, ptr}; fn main() { smoke(); test_offset_from(); test_vec_into_iter(); ptr_arith_offset(); ptr_arith_offset_overflow(); ptr_offset(); } fn smoke() { // Smoke-test various offsetting operations. let ptr = &5; let ptr = ptr ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/async-drop.rs
src/tools/miri/tests/pass/async-drop.rs
//@revisions: stack tree //@compile-flags: -Zmiri-strict-provenance //@[tree]compile-flags: -Zmiri-tree-borrows // WARNING: If you would ever want to modify this test, // please consider modifying rustc's async drop test at // `tests/ui/async-await/async-drop/async-drop-initial.rs`. #![feature(async_drop, impl_trait_...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/slices.rs
src/tools/miri/tests/pass/slices.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance #![feature(slice_partition_dedup)] #![feature(layout_for_ptr)] use std::{ptr, slice}; fn slice_of_zst() { fn foo<T>(v: &[T]) -> Option<&[T]> { let mut it = v.iter(); for _ in 0..5 { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/match_slice.rs
src/tools/miri/tests/pass/match_slice.rs
fn main() { let x = "hello"; match x { "foo" => {} "bar" => {} _ => {} } }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/packed-struct-dyn-trait.rs
src/tools/miri/tests/pass/packed-struct-dyn-trait.rs
// run-pass use std::ptr::addr_of; // When the unsized tail is a `dyn Trait`, its alignments is only dynamically known. This means the // packed(2) needs to be applied at runtime: the actual alignment of the field is `min(2, // usual_alignment)`. Here we check that we do this right by comparing size, alignment, and fi...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/fat_ptr.rs
src/tools/miri/tests/pass/fat_ptr.rs
// test that ordinary fat pointer operations work. struct Wrapper<T: ?Sized>(#[allow(dead_code)] u32, T); struct FatPtrContainer<'a> { ptr: &'a [u8], } fn fat_ptr_project(a: &Wrapper<[u8]>) -> &[u8] { &a.1 } fn fat_ptr_simple(a: &[u8]) -> &[u8] { a } fn fat_ptr_via_local(a: &[u8]) -> &[u8] { let x ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/without-validation.rs
src/tools/miri/tests/pass/without-validation.rs
// When we notice something breaks only without validation, we add a test here. //@compile-flags: -Zmiri-disable-validation use std::cell::*; fn refcell_unsize() { let cell: RefCell<[i32; 3]> = RefCell::new([1, 2, 3]); { let mut cellref: RefMut<'_, [i32; 3]> = cell.borrow_mut(); cellref[0] = 4;...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/small_enum_size_bug.rs
src/tools/miri/tests/pass/small_enum_size_bug.rs
#[allow(dead_code)] enum E { A = 1, B = 2, C = 3, } fn main() { let enone = None::<E>; if let Some(..) = enone { panic!(); } }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/static_memory_modification.rs
src/tools/miri/tests/pass/static_memory_modification.rs
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] use std::sync::atomic::{AtomicUsize, Ordering}; static mut X: usize = 5; static Y: AtomicUsize = AtomicUsize::new(5); fn main() { unsafe { X = 6; assert_eq!(X, 6); } Y.store(6, Ordering::Relaxed); ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/observed_local_mut.rs
src/tools/miri/tests/pass/observed_local_mut.rs
// Stacked Borrows catches this (correctly) as UB. //@compile-flags: -Zmiri-disable-stacked-borrows // This test is intended to guard against the problem described in commit // 39bb1254d1eaf74f45a4e741097e33fc942168d5. // // As written, it might be considered UB in compiled Rust, but of course Miri gives it a safe, //...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/global_allocator.rs
src/tools/miri/tests/pass/global_allocator.rs
#![feature(allocator_api, slice_ptr_get)] use std::alloc::{Allocator as _, Global, GlobalAlloc, Layout, System}; #[global_allocator] static ALLOCATOR: Allocator = Allocator; struct Allocator; unsafe impl GlobalAlloc for Allocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { // use specific size...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/cast-rfc0401-vtable-kinds.rs
src/tools/miri/tests/pass/cast-rfc0401-vtable-kinds.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Check that you can cast between different pointers to trait objects // whose vtable have the same kind (both lengths, or both trait pointers). trait Foo<T> { fn foo(&self, _: T) -> u32 { 42 } } #[allow(dead_code)] trait Bar { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/binary-heap.rs
src/tools/miri/tests/pass/binary-heap.rs
use std::collections::BinaryHeap; fn zero_sized_push() { const N: usize = 8; for len in 0..N { let mut tester = BinaryHeap::with_capacity(len); assert_eq!(tester.len(), 0); assert!(tester.capacity() >= len); for _ in 0..len { tester.push(()); } asser...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/many_shr_bor.rs
src/tools/miri/tests/pass/many_shr_bor.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure validation can handle many overlapping shared borrows for different parts of a data structure use std::cell::RefCell; #[allow(unused)] struct Test { a: u32, b: u32, } fn test1() { let t = &mut Test { a: 0, b: 0 }; { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/drop_on_fat_ptr_array_elements.rs
src/tools/miri/tests/pass/drop_on_fat_ptr_array_elements.rs
#![allow(static_mut_refs)] trait Foo {} struct Bar; impl Foo for Bar {} static mut DROP_COUNT: usize = 0; impl Drop for Bar { fn drop(&mut self) { unsafe { DROP_COUNT += 1; } } } fn main() { let b: [Box<dyn Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(B...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/drop_on_zst_array_elements.rs
src/tools/miri/tests/pass/drop_on_zst_array_elements.rs
#![allow(static_mut_refs)] struct Bar; static mut DROP_COUNT: usize = 0; impl Drop for Bar { fn drop(&mut self) { unsafe { DROP_COUNT += 1; } } } fn main() { let b = [Bar, Bar, Bar, Bar]; assert_eq!(unsafe { DROP_COUNT }, 0); drop(b); assert_eq!(unsafe { DROP_COUN...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/closures.rs
src/tools/miri/tests/pass/closures.rs
fn simple() -> i32 { let y = 10; let f = |x| x + y; f(2) } fn crazy_closure() -> (i32, i32, i32) { fn inner<T: Copy>(t: T) -> (i32, T, T) { struct NonCopy; let x = NonCopy; let a = 2; let b = 40; let f = move |y, z, asdf| { drop(x); (a + ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/enums.rs
src/tools/miri/tests/pass/enums.rs
enum MyEnum { MyEmptyVariant, MyNewtypeVariant(i32), MyTupleVariant(i32, i32), MyStructVariant { my_first_field: i32, my_second_field: i32 }, } fn test(me: MyEnum) { match me { MyEnum::MyEmptyVariant => {} MyEnum::MyNewtypeVariant(ref val) => assert_eq!(val, &42), MyEnum::My...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/negative_discriminant.rs
src/tools/miri/tests/pass/negative_discriminant.rs
enum AB { A = -1, B = 1, } fn main() { match AB::A { AB::A => (), AB::B => panic!(), } match AB::B { AB::A => panic!(), AB::B => (), } }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/const-vec-of-fns.rs
src/tools/miri/tests/pass/const-vec-of-fns.rs
/*! * Try to double-check that static fns have the right size (with or * without dummy env ptr, as appropriate) by iterating a size-2 array. * If the static size differs from the runtime size, the second element * should be read as a null or otherwise wrong pointer and crash. */ fn f() {} static mut CLOSURES: &'s...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/dst-raw.rs
src/tools/miri/tests/pass/dst-raw.rs
// Test DST raw pointers #![allow(dangerous_implicit_autorefs)] trait Trait { fn foo(&self) -> isize; } struct A { f: isize, } impl Trait for A { fn foo(&self) -> isize { self.f } } struct Foo<T: ?Sized> { f: T, } fn main() { // raw trait object let x = A { f: 42 }; let z: *...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/dyn-arbitrary-self.rs
src/tools/miri/tests/pass/dyn-arbitrary-self.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(arbitrary_self_types_pointers, unsize, coerce_unsized, dispatch_from_dyn)] #![feature(rustc_attrs)] fn pin_box_dyn() { use std::pin::Pin; trait Foo { fn bar(self: Pin<&mut Self>) -> bool; } impl Foo for &'static s...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/drop_type_without_drop_glue.rs
src/tools/miri/tests/pass/drop_type_without_drop_glue.rs
#![feature(custom_mir, core_intrinsics)] use std::intrinsics::mir::*; // The `Drop` terminator on a type with no drop glue should be a NOP. #[custom_mir(dialect = "runtime", phase = "optimized")] fn drop_in_place_with_terminator(ptr: *mut i32) { mir! { { Drop(*ptr, ReturnTo(after_call), Unwind...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/btreemap.rs
src/tools/miri/tests/pass/btreemap.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance use std::collections::{BTreeMap, BTreeSet}; use std::mem; #[derive(PartialEq, Eq, PartialOrd, Ord)] pub enum Foo { A(&'static str), _B, _C, } // Gather all references from a mutable iterator and...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/enum_discriminant_ptr_value.rs
src/tools/miri/tests/pass/enum_discriminant_ptr_value.rs
// A niche-optimized enum where the discriminant is a pointer value -- relies on ptr-to-int casts in // the niche handling code. //@compile-flags: -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let x = 42; let val: Option<&i32> = unsafe { std::mem::transmute((&x as *const i32).wrapping_of...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/hide_stdout.rs
src/tools/miri/tests/pass/hide_stdout.rs
//@compile-flags: -Zmiri-mute-stdout-stderr fn main() { println!("print to stdout"); eprintln!("print to stderr"); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/provenance.rs
src/tools/miri/tests/pass/provenance.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::{mem, ptr}; const PTR_SIZE: usize = mem::size_of::<&i32>(); fn main() { basic(); bytewise_ptr_methods(); bytewise_custom_memcpy(); bytewise_custom_memcpy_chunked(); int_load_strip_provenance(); maybe_uninit_preserves...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/hello.rs
src/tools/miri/tests/pass/hello.rs
fn main() { println!("Hello, world!"); eprintln!("Hello, error!"); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/overloaded-calls-simple.rs
src/tools/miri/tests/pass/overloaded-calls-simple.rs
#![feature(unboxed_closures, fn_traits)] struct S3 { x: i32, y: i32, } impl FnOnce<(i32, i32)> for S3 { type Output = i32; extern "rust-call" fn call_once(self, (z, zz): (i32, i32)) -> i32 { self.x * self.y * z * zz } } fn main() { let s = S3 { x: 3, y: 3 }; let ans = s(3, 1); ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/recursive_static.rs
src/tools/miri/tests/pass/recursive_static.rs
struct S(&'static S); static S1: S = S(&S2); static S2: S = S(&S1); fn main() { let p: *const S = S2.0; let q: *const S = &S1; assert_eq!(p, q); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/overlapping_assignment_aggregate_scalar.rs
src/tools/miri/tests/pass/overlapping_assignment_aggregate_scalar.rs
#![feature(custom_mir, core_intrinsics)] #![allow(internal_features)] use std::intrinsics::mir::*; #[custom_mir(dialect = "runtime")] fn main() { mir! { let _1: (u8,); { _1.0 = 0_u8; // This is a scalar type, so overlap is (for now) not UB. // However, we used t...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/validation_lifetime_resolution.rs
src/tools/miri/tests/pass/validation_lifetime_resolution.rs
trait Id { type Out; fn id(self) -> Self::Out; } impl<'a> Id for &'a mut i32 { type Out = &'a mut i32; fn id(self) -> Self { self } } impl<'a> Id for &'a mut u32 { type Out = &'a mut u32; fn id(self) -> Self { self } } fn foo<T>(mut x: T) where for<'a> &'a mut T...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false