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/align.rs
src/tools/miri/tests/pass/align.rs
//@compile-flags: -Zmiri-permissive-provenance /// This manually makes sure that we have a pointer with the proper alignment. fn manual_alignment() { let x = &mut [0u8; 3]; let base_addr = x as *mut _ as usize; let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr + 1 }; let u16_...
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-field-align.rs
src/tools/miri/tests/pass/dst-field-align.rs
#[allow(dead_code)] struct Foo<T: ?Sized> { a: u16, b: T, } trait Bar { fn get(&self) -> usize; } impl Bar for usize { fn get(&self) -> usize { *self } } struct Baz<T: ?Sized> { a: T, } #[allow(dead_code)] struct HasDrop<T: ?Sized> { ptr: Box<usize>, data: T, } fn main() { ...
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.rs
src/tools/miri/tests/pass/async-closure.rs
#![feature(async_fn_traits)] #![allow(unused)] use std::future::Future; use std::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; 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 { mat...
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_owned_slice.rs
src/tools/miri/tests/pass/drop_through_owned_slice.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: Box<[Bar]> = vec![Bar, Bar, Bar, Bar].into_boxed_slice(); assert_eq!(unsafe { DROP_COUNT }, 0); 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/imported_main.rs
src/tools/miri/tests/pass/imported_main.rs
pub mod foo { pub fn mymain() { println!("Hello, world!"); } } use foo::mymain as main;
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/zero-sized-accesses-and-offsets.rs
src/tools/miri/tests/pass/zero-sized-accesses-and-offsets.rs
//! Tests specific for <https://github.com/rust-lang/rust/issues/117945>: zero-sized operations. use std::ptr; fn main() { // Null. test_ptr(ptr::null_mut::<()>()); // No provenance. test_ptr(ptr::without_provenance_mut::<()>(1)); // Out-of-bounds. let mut b = Box::new(0i32); 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/calls.rs
src/tools/miri/tests/pass/calls.rs
fn call() -> i32 { fn increment(x: i32) -> i32 { x + 1 } increment(1) } fn factorial_recursive() -> i64 { fn fact(n: i64) -> i64 { if n == 0 { 1 } else { n * fact(n - 1) } } fact(10) } fn call_generic() -> (i16, bool) { fn id<T>(t: T) -> T { t } (id(42), 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/main_result.rs
src/tools/miri/tests/pass/main_result.rs
fn main() -> Result<(), Box<dyn std::error::Error>> { 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/unops.rs
src/tools/miri/tests/pass/unops.rs
fn main() { assert_eq!(!true, false); assert_eq!(!0xFFu16, 0xFF00); assert_eq!(-{ 1i16 }, -1i16); }
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/protector-gc.rs
src/tools/miri/tests/pass/protector-gc.rs
// When we pop a stack frame with weak protectors, we need to check if the protected pointer's // allocation is still live. If the provenance GC only knows about the BorTag that is protected, // we can ICE. This test checks that we don't. // See https://github.com/rust-lang/miri/issues/3228 #[path = "../utils/mod.rs"]...
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/empty_main.rs
src/tools/miri/tests/pass/empty_main.rs
// This may look trivial, but a bunch of code runs in std before // `main` is called, so we are ensuring that that all works. fn main() {}
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/vecdeque.rs
src/tools/miri/tests/pass/vecdeque.rs
//@revisions: stack tree //@compile-flags: -Zmiri-strict-provenance //@[tree]compile-flags: -Zmiri-tree-borrows use std::collections::VecDeque; fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator<Item = &'a mut T>) { // Gather all those references. let mut refs: Vec<&mut T> = iter.collect(); // ...
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/rc.rs
src/tools/miri/tests/pass/rc.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance #![feature(get_mut_unchecked)] #![allow(ambiguous_wide_pointer_comparisons)] use std::cell::{Cell, RefCell}; use std::fmt::Debug; use std::rc::{Rc, Weak}; use std::sync::{Arc, Weak as ArcWeak}; fn rc_refcel...
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/linked-list.rs
src/tools/miri/tests/pass/linked-list.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(linked_list_cursors)] use std::collections::LinkedList; fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> { v.iter().cloned().collect() } // Gather all references from a mutable iterator and make sure Miri notices if // using them is 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/memchr.rs
src/tools/miri/tests/pass/memchr.rs
#![feature(slice_internals)] use core::slice::memchr::{memchr, memrchr}; // test fallback implementations on all targets fn matches_one() { assert_eq!(Some(0), memchr(b'a', b"a")); } fn matches_begin() { assert_eq!(Some(0), memchr(b'a', b"aaaa")); } fn matches_end() { assert_eq!(Some(4), memchr(b'z', 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/format.rs
src/tools/miri/tests/pass/format.rs
fn main() { println!("Hello {}", 13); println!("{:0<width$}", "hello", width = 10); }
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-field-ty.rs
src/tools/miri/tests/pass/closure-field-ty.rs
// miri issue #304 fn main() { let mut y = 0; { let mut box_maybe_closure = Box::new(None); *box_maybe_closure = Some(|| y += 1); (box_maybe_closure.unwrap())(); } assert_eq!(y, 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/integer-ops.rs
src/tools/miri/tests/pass/integer-ops.rs
//@compile-flags: -Coverflow-checks=off #![allow(arithmetic_overflow)] fn basic() { fn ret() -> i64 { 1 } fn neg() -> i64 { -1 } fn add() -> i64 { 1 + 2 } fn indirect_add() -> i64 { let x = 1; let y = 2; x + y } fn arith() -> 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/binops.rs
src/tools/miri/tests/pass/binops.rs
// Binop corner cases fn test_nil() { assert_eq!((), ()); assert!(!(() != ())); assert!(!(() < ())); assert!(() <= ()); assert!(!(() > ())); assert!(() >= ()); } fn test_bool() { assert!(!(true < false)); assert!(!(true <= false)); assert!(true > false); assert!(true >= false);...
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.rs
src/tools/miri/tests/pass/tuple_like_enum_variant_constructor.rs
fn main() { assert_eq!(Some(42).map(Some), Some(Some(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.rs
src/tools/miri/tests/pass/float.rs
#![feature(stmt_expr_attributes)] #![feature(float_erf)] #![feature(float_gamma)] #![feature(core_intrinsics)] #![feature(f128)] #![feature(f16)] #![allow(arithmetic_overflow)] #![allow(internal_features)] #![allow(unnecessary_transmutes)] #[path = "../utils/mod.rs"] mod utils; use std::any::type_name; use std::cmp::m...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
true
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/pass/write-bytes.rs
src/tools/miri/tests/pass/write-bytes.rs
#![feature(core_intrinsics)] // for `volatile_set_memory` #[repr(C)] #[derive(Copy, Clone)] struct Foo { a: u64, b: u64, c: u64, } fn main() { const LENGTH: usize = 10; let mut v: [u64; LENGTH] = [0; LENGTH]; for idx in 0..LENGTH { assert_eq!(v[idx], 0); } unsafe { le...
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/sums.rs
src/tools/miri/tests/pass/sums.rs
#[derive(Debug, PartialEq)] enum Unit { Unit(()), // Force non-C-enum representation. } fn return_unit() -> Unit { Unit::Unit(()) } #[derive(Debug, PartialEq)] enum MyBool { False(()), // Force non-C-enum representation. True(()), } fn return_true() -> MyBool { MyBool::True(()) } fn return_false...
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/specialization.rs
src/tools/miri/tests/pass/specialization.rs
#![allow(incomplete_features)] #![feature(specialization)] trait IsUnit { fn is_unit() -> bool; } impl<T> IsUnit for T { default fn is_unit() -> bool { false } } impl IsUnit for () { fn is_unit() -> bool { true } } fn specialization() -> (bool, bool) { (i32::is_unit(), <()>::...
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_empty_slice.rs
src/tools/miri/tests/pass/drop_empty_slice.rs
fn main() { // With the nested Vec, this is calling Offset(Unique::empty(), 0) on drop. let args: Vec<Vec<i32>> = Vec::new(); let _val = Box::new(args); }
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/assume_bug.rs
src/tools/miri/tests/pass/assume_bug.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows fn main() { vec![()].into_iter(); }
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_repeat_into_well_aligned_array.rs
src/tools/miri/tests/pass/align_repeat_into_well_aligned_array.rs
//@compile-flags: -Zmiri-symbolic-alignment-check use std::mem::size_of; #[expect(unused_variables, unused_assignments)] fn main() { let mut a = Params::new(); // The array itself here happens to be quite well-aligned, but not all its elements have that // large alignment and we better make sure that is 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/target-cpu-implies-target-feature.rs
src/tools/miri/tests/pass/target-cpu-implies-target-feature.rs
// Test that target-cpu implies the correct target features //@only-target: x86_64 //@compile-flags: -C target-cpu=x86-64-v4 fn main() { assert!(cfg!(target_feature = "avx2")); assert!(cfg!(target_feature = "avx512bw")); assert!(cfg!(target_feature = "avx512cd")); assert!(cfg!(target_feature = "avx512d...
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/getpid.rs
src/tools/miri/tests/pass/getpid.rs
//@revisions: with_isolation without_isolation //@[without_isolation] compile-flags: -Zmiri-disable-isolation fn getpid() -> u32 { std::process::id() } fn main() { let pid = getpid(); std::thread::spawn(move || { assert_eq!(getpid(), pid); }); // Test that in isolation mode a determinist...
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_struct_pointer_opt.rs
src/tools/miri/tests/pass/tuple_like_enum_variant_constructor_struct_pointer_opt.rs
#[derive(Copy, Clone, PartialEq, Debug)] struct A<'a> { x: i32, y: &'a i32, } #[derive(Copy, Clone, PartialEq, Debug)] struct B<'a>(i32, &'a i32); #[derive(Copy, Clone, PartialEq, Debug)] enum C<'a> { Value(i32, &'a i32), #[allow(dead_code)] NoValue, } fn main() { let x = 5; let a = A { 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/strange_references.rs
src/tools/miri/tests/pass/strange_references.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Create zero-sized references to vtables and function data. // Just make sure nothing explodes. use std::{mem, ptr}; fn check_ref(x: &()) { let _ptr = ptr::addr_of!(*x); } fn main() { check_ref({ // Create reference to a function...
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-matching-fold.rs
src/tools/miri/tests/pass/vec-matching-fold.rs
use std::fmt::Debug; fn foldl<T, U, F>(values: &[T], initial: U, mut function: F) -> U where U: Clone + Debug, T: Debug, F: FnMut(U, &T) -> U, { match values { [head, tail @ ..] => foldl(tail, function(initial, head), function), [] => { let res = initial.clone(); ...
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/adjacent-allocs.rs
src/tools/miri/tests/pass/adjacent-allocs.rs
//@compile-flags: -Zmiri-permissive-provenance fn ensure_allocs_can_be_adjacent() { for _ in 0..512 { let n = 0u64; let ptr: *const u64 = &n; let ptr2 = { let m = 0u64; &m as *const u64 }; if ptr.wrapping_add(1) == ptr2 { return; }...
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/partially-uninit.rs
src/tools/miri/tests/pass/partially-uninit.rs
use std::mem::{self, MaybeUninit}; #[repr(C)] #[derive(Copy, Clone, Debug, PartialEq)] struct Demo(bool, u16); fn main() { unsafe { // Transmute-round-trip through a type with Scalar layout is lossless. // This is tricky because that 'scalar' is *partially* uninitialized. let x = Demo(true...
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_from_exposed.rs
src/tools/miri/tests/pass/ptr_int_from_exposed.rs
//@compile-flags: -Zmiri-permissive-provenance //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::ptr; /// Ensure we can expose the address of a pointer that is out-of-bounds fn ptr_roundtrip_out_of_bounds() { let x: i32 = 3; let x_ptr = &x as *const i32; let x_usize = x_ptr.wr...
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/leak-in-static.rs
src/tools/miri/tests/pass/leak-in-static.rs
use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; static mut LEAKER: Option<Box<Vec<i32>>> = None; fn main() { // Having memory "leaked" in globals is allowed. unsafe { LEAKER = Some(Box::new(vec![0; 42])); } // Make sure this is allowed even when `AtomicPtr` is used. { ...
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/future-self-referential.rs
src/tools/miri/tests/pass/future-self-referential.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::future::*; use std::marker::PhantomPinned; use std::pin::*; use std::ptr; use std::task::*; struct Delay { delay: usize, } impl Delay { fn new(delay: usize) -> Self { Delay { delay } } } impl Future for Delay { typ...
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.rs
src/tools/miri/tests/pass/zst.rs
//@compile-flags: -Zmiri-permissive-provenance #[derive(PartialEq, Debug)] struct A; fn zst_ret() -> A { A } fn use_zst() -> A { let a = A; a } fn main() { // Not using the () type here, as writes of that type do not even have MIR generated. // Also not assigning directly as that's array initiali...
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-3-unique.rs
src/tools/miri/tests/pass/move-arg-3-unique.rs
fn main() { let x = Box::new(10); let y = x; assert_eq!(*y, 10); }
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/strings.rs
src/tools/miri/tests/pass/strings.rs
//@compile-flags: -Zmiri-strict-provenance fn empty() -> &'static str { "" } fn hello() -> &'static str { "Hello, world!" } fn hello_bytes() -> &'static [u8; 13] { b"Hello, world!" } fn hello_bytes_fat() -> &'static [u8] { b"Hello, world!" } fn fat_pointer_on_32_bit() { Some(5).expect("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/tag-align-dyn-u64.rs
src/tools/miri/tests/pass/tag-align-dyn-u64.rs
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-FileCopyrightText: The Rust Project Developers (see https://thanks.rust-lang.org) use std::mem; enum Tag<A> { Tag2(A), } #[allow(dead_code)] struct Rec { c8: u8, t: Tag<u64>, } fn mk_rec() -> Rec { return Rec { c8: 0, t: Tag::Tag2(0) }; } fn is_...
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_strange_enum_discriminant_offset.rs
src/tools/miri/tests/pass/align_strange_enum_discriminant_offset.rs
#![allow(unused)] #[repr(u16)] enum DeviceKind { Nil = 0, } #[repr(C, packed)] struct DeviceInfo { endianness: u8, device_kind: DeviceKind, } fn main() { // The layout of `Option<(DeviceInfo, u64)>` is funny: it uses the // `DeviceKind` enum as niche, so that is offset 1, but the niche type is u1...
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-addrs.rs
src/tools/miri/tests/pass/const-addrs.rs
// The interpreter used to create a new AllocId every time it evaluates any const. // This caused unbounded memory use in Miri. // This test verifies that we only create a bounded amount of addresses for any given const. // In practice, the interpreter always returns the same address, but we *do not guarantee* that. //...
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/multi_arg_closure.rs
src/tools/miri/tests/pass/multi_arg_closure.rs
fn foo(f: &mut dyn FnMut(isize, isize) -> isize) -> isize { f(1, 2) } fn main() { let z = foo(&mut |x, y| x * 10 + y); assert_eq!(z, 12); }
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/catch.rs
src/tools/miri/tests/pass/catch.rs
use std::panic::{AssertUnwindSafe, catch_unwind}; fn main() { let mut i = 3; let _val = catch_unwind(AssertUnwindSafe(|| i -= 2)); println!("{}", i); }
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/bools.rs
src/tools/miri/tests/pass/bools.rs
fn boolean() -> bool { true } fn if_false() -> i64 { let c = false; if c { 1 } else { 0 } } fn if_true() -> i64 { let c = true; if c { 1 } else { 0 } } fn match_bool() -> i16 { let b = true; match b { true => 1, _ => 0, } } fn main() { assert!(boolean()); 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/cast_fn_ptr_unsafe.rs
src/tools/miri/tests/pass/cast_fn_ptr_unsafe.rs
fn main() { fn f() {} let g = f as fn() as unsafe fn(); unsafe { g(); } }
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/sysroot.rs
src/tools/miri/tests/pass/sysroot.rs
//! Just check that some things are available in the sysroot. #![feature(test)] #![allow(unused)] extern crate proc_macro; extern crate std; extern crate test; fn main() {}
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/trivial.rs
src/tools/miri/tests/pass/trivial.rs
fn empty() {} fn unit_var() { let x = (); x } fn main() { empty(); unit_var(); }
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/send-is-not-static-par-for.rs
src/tools/miri/tests/pass/send-is-not-static-par-for.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::sync::Mutex; fn par_for<I, F>(iter: I, f: F) where I: Iterator, I::Item: Send, F: Fn(I::Item) + Sync, { for item in iter { f(item) } } fn sum(x: &[i32]) { let sum_lengths = Mutex::new(0); par_for(x.window...
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/constants.rs
src/tools/miri/tests/pass/constants.rs
const A: usize = *&5; fn foo() -> usize { A } fn main() { assert_eq!(foo(), 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/coercions.rs
src/tools/miri/tests/pass/coercions.rs
#![feature(coerce_unsized, unsize)] use std::marker::Unsize; use std::ops::CoerceUnsized; fn identity_coercion(x: &(dyn Fn(u32) -> u32 + Send)) -> &dyn Fn(u32) -> u32 { x } fn fn_coercions(f: &fn(u32) -> u32) -> (unsafe fn(u32) -> u32, &(dyn Fn(u32) -> u32 + Send)) { (*f, f) } fn simple_array_coercion(x: &[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/regions-lifetime-nonfree-late-bound.rs
src/tools/miri/tests/pass/regions-lifetime-nonfree-late-bound.rs
// This is a regression test for the ICE from issue #10846. // // The original issue causing the ICE: the LUB-computations during // type inference were encountering late-bound lifetimes, and // asserting that such lifetimes should have already been substituted // with a concrete lifetime. // // However, those encounte...
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/iter_macro.rs
src/tools/miri/tests/pass/iter_macro.rs
#![feature(iter_macro, yield_expr)] use std::iter::iter; fn main() { let i = iter! { || { yield 0; for x in 5..10 { yield x * 2; } } }; let mut i = i(); assert_eq!(i.next(), Some(0)); assert_eq!(i.next(), Some(10)); assert_eq!(i.next(), Some(12)); assert...
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/option_eq.rs
src/tools/miri/tests/pass/option_eq.rs
fn main() { 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/atomic.rs
src/tools/miri/tests/pass/atomic.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] use std::sync::atomic::Ordering::*; use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicPtr, AtomicUsize, compile...
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/rust-lang-org.rs
src/tools/miri/tests/pass/rust-lang-org.rs
// This code is editable and runnable! fn main() { // A simple integer calculator: // `+` or `-` means add or subtract by 1 // `*` or `/` means multiply or divide by 2 let program = "+ + * - /"; let mut accumulator = 0; for token in program.chars() { match token { '+' => ac...
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/too-large-primval-write-problem.rs
src/tools/miri/tests/pass/too-large-primval-write-problem.rs
// `PrimVal`s in Miri are represented with 8 bytes (u64) and at the time of writing, the `-x` // will sign extend into the entire 8 bytes. Then, if you tried to write the `-x` into // something smaller than 8 bytes, like a 4 byte pointer, it would crash in byteorder crate // code that assumed only the low 4 bytes would...
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_types.rs
src/tools/miri/tests/pass/extern_types.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![feature(extern_types)] use std::ptr; extern "C" { type Foo; } fn main() { let x: &Foo = unsafe { &*(ptr::without_provenance::<()>(16) as *const Foo) }; let _y: &Foo = &*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/miri-alloc.rs
src/tools/miri/tests/pass/miri-alloc.rs
#![no_std] #![no_main] //@compile-flags: -Cpanic=abort // windows tls dtors go through libstd right now, thus this test // cannot pass. When windows tls dtors go through the special magic // windows linker section, we can run this test on windows again. //@ignore-target: windows # no-std not supported on Windows exter...
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-traits.rs
src/tools/miri/tests/pass/dyn-traits.rs
#[path = "../utils/mod.rs"] mod utils; use utils::check_nondet; fn ref_box_dyn() { struct Struct(i32); trait Trait { fn method(&self); fn box_method(self: Box<Self>); } impl Trait for Struct { fn method(&self) { assert_eq!(self.0, 42); } fn box_me...
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/sendable-class.rs
src/tools/miri/tests/pass/sendable-class.rs
// Test that a class with only sendable fields can be sent use std::sync::mpsc::channel; #[allow(dead_code)] struct Foo { i: isize, j: char, } fn foo(i: isize, j: char) -> Foo { Foo { i: i, j: j } } fn main() { let (tx, rx) = channel(); tx.send(foo(42, 'c')).unwrap(); let _val = rx; }
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-sole.rs
src/tools/miri/tests/pass/dst-struct-sole.rs
// As dst-struct.rs, but the unsized field is the only field in the struct. struct Fat<T: ?Sized> { 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); } fn foo2<T: ToBar>(x: &Fat<[T]>) { let y = ...
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/track-caller-attribute.rs
src/tools/miri/tests/pass/track-caller-attribute.rs
#![feature(core_intrinsics)] #![feature(stmt_expr_attributes)] #![feature(closure_track_caller)] #![feature(coroutine_trait)] #![feature(coroutines)] use std::ops::{Coroutine, CoroutineState}; use std::panic::Location; use std::pin::Pin; type Loc = &'static Location<'static>; #[track_caller] fn tracked() -> Loc { ...
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-irrefutable-bind.rs
src/tools/miri/tests/pass/dst-irrefutable-bind.rs
struct Test<T: ?Sized>(T); fn main() { let x = Test([1, 2, 3]); let x: &Test<[i32]> = &x; let &ref _y = x; // Make sure binding to a fat pointer behind a reference // still works let slice = &[1, 2, 3]; let x = Test(&slice); let Test(&_slice) = 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/ptr_int_transmute.rs
src/tools/miri/tests/pass/ptr_int_transmute.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Test what happens when we read parts of a pointer. // Related to <https://github.com/rust-lang/rust/issues/69488>. fn ptr_partial_read() { let x = 13; let y = &x; let z = &y as *const &i32 as *const u8; // This just strips provenan...
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/threadleak_ignored.rs
src/tools/miri/tests/pass/threadleak_ignored.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-ignore-leaks //! Test that leaking threads works, and that their destructors are not executed. use std::cell::RefCell; struct LoudDrop(i32); impl Drop for LoudDrop { fn drop(&mut self) { eprintln!("Dropping {}",...
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/function_pointers.rs
src/tools/miri/tests/pass/function_pointers.rs
#![allow(unpredictable_function_pointer_comparisons)] use std::mem; #[path = "../utils/mod.rs"] mod utils; use utils::check_nondet; trait Answer { fn answer() -> Self; } impl Answer for i32 { fn answer() -> i32 { 42 } } // A generic function, to make its address unstable fn f<T: Answer>() -> 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/bad_substs.rs
src/tools/miri/tests/pass/bad_substs.rs
fn main() { let f: fn(i32) -> Option<i32> = Some::<i32>; f(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/from_utf8.rs
src/tools/miri/tests/pass/from_utf8.rs
fn main() { let _val = ::std::str::from_utf8(b"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/iter.rs
src/tools/miri/tests/pass/iter.rs
fn iter_empty_and_zst() { // Iterate over a Unique::empty() for _ in Vec::<u32>::new().iter() { panic!("We should never be here."); } // Iterate over a ZST (uses arith_offset internally) let mut count = 0; for _ in &[(), (), ()] { count += 1; } assert_eq!(count, 3); } 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/u128.rs
src/tools/miri/tests/pass/u128.rs
use std::hint::black_box as b; fn main() { let x: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFF; assert_eq!(0, !x); assert_eq!(0, !x); let y: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFE; assert_eq!(!1, y); assert_eq!(x, y | 1); assert_eq!( 0xFAFF_0000_FF8F_0000__FFFF_0000_...
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/memleak_ignored.rs
src/tools/miri/tests/pass/memleak_ignored.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-ignore-leaks fn main() { std::mem::forget(Box::new(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/async-niche-aliasing.rs
src/tools/miri/tests/pass/async-niche-aliasing.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::future::Future; use std::mem::MaybeUninit; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll, Wake}; struct ThingAdder<'a> { // Using `MaybeUninit` to ensure there are no niches here. thing: MaybeUninit<&'a mut St...
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/target-spec-implies-target-feature.rs
src/tools/miri/tests/pass/target-spec-implies-target-feature.rs
//! Ensure that the target features given in the target spec are actually enabled. //@only-target: armv7 fn main() { assert!(cfg!(target_feature = "v7")); assert!(cfg!(target_feature = "vfp2")); assert!(cfg!(target_feature = "thumb2")); }
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_in_place.rs
src/tools/miri/tests/pass/drop_in_place.rs
// Miri currently doesn't require types without drop glue to be // valid when dropped. This test confirms that behavior. // This is not a stable guarantee! use std::ptr; fn main() { let mut not_a_bool = 13u8; unsafe { ptr::drop_in_place(&mut not_a_bool as *mut u8 as *mut bool) }; }
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/option_box_transmute_ptr.rs
src/tools/miri/tests/pass/option_box_transmute_ptr.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // This tests that the size of Option<Box<i32>> is the same as *const i32. fn option_box_deref() -> i32 { let val = Some(Box::new(42)); unsafe { let ptr: *const i32 = std::mem::transmute::<Option<Box<i32>>, *const i32>(val); le...
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/rename_std.rs
src/tools/miri/tests/pass/rename_std.rs
#![no_std] extern crate std as foo; fn main() {}
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/heap_allocator.rs
src/tools/miri/tests/pass/heap_allocator.rs
#![feature(allocator_api, slice_ptr_get)] use std::alloc::{Allocator, Global, Layout, System}; use std::ptr::NonNull; use std::slice; fn check_alloc<T: Allocator>(allocator: T) { unsafe { for &align in &[4, 8, 16, 32] { let layout_20 = Layout::from_size_align(20, align).unwrap(); l...
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-upcast.rs
src/tools/miri/tests/pass/dyn-upcast.rs
use std::fmt; fn main() { basic(); diamond(); struct_(); replace_vptr(); vtable_nop_cast(); drop_principal(); modulo_binder(); modulo_assoc(); bidirectional_subtyping(); } fn vtable_nop_cast() { let ptr: &dyn fmt::Debug = &0; // We transmute things around, but the principal...
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/rfc1623.rs
src/tools/miri/tests/pass/rfc1623.rs
#![allow(dead_code)] // tons of unused statics here... // very simple test for a 'static static with default lifetime static STATIC_STR: &str = "&'static str"; const CONST_STR: &str = "&'static str"; // this should be the same as without default: static EXPLICIT_STATIC_STR: &'static str = "&'static str"; const EXPLIC...
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/heap.rs
src/tools/miri/tests/pass/heap.rs
fn make_box() -> Box<(i16, i16)> { Box::new((1, 2)) } fn allocate_reallocate() { let mut s = String::new(); // 6 byte heap alloc (__rust_allocate) s.push_str("foobar"); assert_eq!(s.len(), 6); assert_eq!(s.capacity(), 8); // heap size doubled to 12 (__rust_reallocate) s.push_str("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/function_calls/return_place_on_heap.rs
src/tools/miri/tests/pass/function_calls/return_place_on_heap.rs
#![feature(core_intrinsics)] #![feature(custom_mir)] use std::intrinsics::mir::*; // Make sure calls with the return place "on the heap" work. #[custom_mir(dialect = "runtime", phase = "optimized")] fn main() { mir! { { let x = 0; let ptr = &raw mut x; Call(*ptr = myfun...
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/function_calls/abi_compat.rs
src/tools/miri/tests/pass/function_calls/abi_compat.rs
#![feature(never_type)] use std::rc::Rc; use std::{mem, num, ptr}; #[derive(Copy, Clone, Default)] struct Zst; #[repr(transparent)] #[derive(Copy, Clone)] struct Wrapper<T>(T); fn id<T>(x: T) -> T { x } #[derive(Copy, Clone)] enum Either<T, U> { Left(T), Right(U), } #[derive(Copy, Clone)] enum Either2<...
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/function_calls/exported_symbol_weak.rs
src/tools/miri/tests/pass/function_calls/exported_symbol_weak.rs
#![feature(linkage)] // FIXME move this module to a separate crate once aux-build is allowed // This currently depends on the fact that miri skips the codegen check // that denies multiple symbols with the same name. mod first { #[no_mangle] #[linkage = "weak"] extern "C" fn foo() -> i32 { 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/function_calls/exported_symbol.rs
src/tools/miri/tests/pass/function_calls/exported_symbol.rs
#![feature(rustc_attrs)] #[no_mangle] extern "C" fn foo() -> i32 { -1 } #[export_name = "bar"] fn bar() -> i32 { -2 } #[rustc_std_internal_symbol] fn baz() -> i32 { -3 } struct AssocFn; impl AssocFn { #[no_mangle] fn qux() -> i32 { -4 } } fn main() { // Repeat calls to make sur...
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/function_calls/target_feature.rs
src/tools/miri/tests/pass/function_calls/target_feature.rs
//@only-target: x86_64 # uses x86 target features //@compile-flags: -C target-feature=+ssse3 fn main() { assert!(is_x86_feature_detected!("ssse3")); unsafe { ssse3_fn(); } } #[target_feature(enable = "ssse3")] unsafe fn ssse3_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/issues/issue-34571.rs
src/tools/miri/tests/pass/issues/issue-34571.rs
#[repr(u8)] enum Foo { Foo(#[allow(dead_code)] u8), } fn main() { match Foo::Foo(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/issues/issue-73223.rs
src/tools/miri/tests/pass/issues/issue-73223.rs
fn main() { let mut state = State { prev: None, next: Some(8) }; let path = "/nested/some/more"; assert_eq!(state.rest(path), "some/more"); } #[allow(unused)] struct State { prev: Option<usize>, next: Option<usize>, } impl State { fn rest<'r>(&mut self, path: &'r str) -> &'r str { let ...
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/issues/issue-94371.rs
src/tools/miri/tests/pass/issues/issue-94371.rs
#[repr(C)] struct Demo(u64, bool, u64, u32, u64, u64, u64); fn test() -> (Demo, Demo) { let mut x = Demo(1, true, 3, 4, 5, 6, 7); let mut y = Demo(10, false, 12, 13, 14, 15, 16); std::mem::swap(&mut x, &mut y); (x, y) } fn main() { drop(test()); }
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/issues/issue-15063.rs
src/tools/miri/tests/pass/issues/issue-15063.rs
#[allow(dead_code)] enum Two { A, B, } impl Drop for Two { fn drop(&mut self) {} } fn main() { let _k = Two::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/issues/issue-30530.rs
src/tools/miri/tests/pass/issues/issue-30530.rs
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-FileCopyrightText: The Rust Project Developers (see https://thanks.rust-lang.org) // Regression test for Issue #30530: alloca's created for storing // intermediate scratch values during brace-less match arms need to be // initialized with their drop-flag set to "dr...
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/issues/issue-91636.rs
src/tools/miri/tests/pass/issues/issue-91636.rs
#![allow(unpredictable_function_pointer_comparisons)] type BuiltIn = for<'a> fn(&str); struct Function { inner: BuiltIn, } impl Function { fn new(subr: BuiltIn) -> Self { Self { inner: subr } } } #[inline(never)] fn dummy(_: &str) {} fn main() { let func1 = Function::new(dummy); let fun...
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/issues/issue-miri-3541-dyn-vtable-trait-normalization.rs
src/tools/miri/tests/pass/issues/issue-miri-3541-dyn-vtable-trait-normalization.rs
#![feature(ptr_metadata)] // This test is the result of minimizing the `emplacable` crate to reproduce // <https://github.com/rust-lang/miri/issues/3541>. use std::ops::FnMut; use std::ptr::Pointee; pub type EmplacerFn<'a, T> = dyn for<'b> FnMut(<T as Pointee>::Metadata) + 'a; #[repr(transparent)] pub struct Emplace...
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/issues/issue-miri-2123.rs
src/tools/miri/tests/pass/issues/issue-miri-2123.rs
#![feature(ptr_metadata, layout_for_ptr)] use std::{mem, ptr}; trait Foo {} impl Foo for u32 {} fn uwu(thin: *const (), meta: &'static ()) -> *const dyn Foo { ptr::from_raw_parts(thin, unsafe { mem::transmute(meta) }) } fn main() { unsafe { let orig = 1_u32; let x = &orig as &dyn 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/issues/issue-miri-4698-stashed-diagnostic.rs
src/tools/miri/tests/pass/issues/issue-miri-4698-stashed-diagnostic.rs
// This test seems to involve a "stashed diagnostic" (or at least it used to at the time of // writing). Ensure we handle that correctly. pub trait Trait { type Assoc: Assoc; } pub trait Assoc {} fn main() {}
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/issues/issue-3200-packed2-field-offset.rs
src/tools/miri/tests/pass/issues/issue-3200-packed2-field-offset.rs
#![feature(layout_for_ptr)] use std::mem; #[repr(packed(4))] struct Slice(#[allow(dead_code)] [u32]); #[repr(packed(2), C)] struct PackedSized { f: u8, d: [u32; 4], } #[repr(packed(2), C)] struct PackedUnsized { f: u8, d: Slice, } impl PackedSized { fn unsize(&self) -> &PackedUnsized { /...
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/issues/issue-miri-2068.rs
src/tools/miri/tests/pass/issues/issue-miri-2068.rs
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll, Waker}; fn fuzzing_block_on<O, F: Future<Output = O>>(fut: F) -> O { let mut fut = std::pin::pin!(fut); let mut context = Context::from_waker(Waker::noop()); loop { match fut.as_mut().poll(&mut context) { Poll::R...
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/issues/issue-17877.rs
src/tools/miri/tests/pass/issues/issue-17877.rs
fn main() { assert_eq!( match [0u8; 16 * 1024] { _ => 42_usize, }, 42_usize, ); assert_eq!( match [0u8; 16 * 1024] { [1, ..] => 0_usize, [0, ..] => 1_usize, _ => 2_usize, }, 1_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/issues/issue-5917.rs
src/tools/miri/tests/pass/issues/issue-5917.rs
struct T(&'static [isize]); static STATIC: T = T(&[5, 4, 3]); fn main() { let T(ref v) = STATIC; assert_eq!(v[0], 5); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false