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/src/concurrency/weak_memory.rs
src/tools/miri/src/concurrency/weak_memory.rs
//! Implementation of C++11-consistent weak memory emulation using store buffers //! based on Dynamic Race Detection for C++ ("the paper"): //! <https://www.doc.ic.ac.uk/~afd/homepages/papers/pdfs/2017/POPL.pdf> //! //! This implementation will never generate weak memory behaviours forbidden by the C++11 model, //! but...
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/src/concurrency/thread.rs
src/tools/miri/src/concurrency/thread.rs
//! Implements threads. use std::mem; use std::sync::atomic::Ordering::Relaxed; use std::task::Poll; use std::time::{Duration, SystemTime}; use rand::seq::IteratorRandom; use rustc_abi::ExternAbi; use rustc_const_eval::CTRL_C_RECEIVED; use rustc_data_structures::either::Either; use rustc_data_structures::fx::FxHashMa...
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/src/concurrency/genmc/config.rs
src/tools/miri/src/concurrency/genmc/config.rs
use genmc_sys::LogLevel; use super::GenmcParams; use crate::{IsolatedOp, MiriConfig, RejectOpWith}; /// Configuration for GenMC mode. /// The `params` field is shared with the C++ side. /// The remaining options are kept on the Rust side. #[derive(Debug, Default, Clone)] pub struct GenmcConfig { /// Parameters se...
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/src/concurrency/genmc/global_allocations.rs
src/tools/miri/src/concurrency/genmc/global_allocations.rs
use std::collections::hash_map::Entry; use std::sync::RwLock; use genmc_sys::{GENMC_GLOBAL_ADDRESSES_MASK, get_global_alloc_static_mask}; use rand::SeedableRng; use rand::rngs::StdRng; use rustc_const_eval::interpret::{AllocId, AllocInfo, InterpResult, interp_ok}; use rustc_data_structures::fx::FxHashMap; use rustc_lo...
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/src/concurrency/genmc/scheduling.rs
src/tools/miri/src/concurrency/genmc/scheduling.rs
use genmc_sys::{ActionKind, ExecutionState}; use rustc_data_structures::either::Either; use rustc_middle::mir::TerminatorKind; use rustc_middle::ty::{self, Ty}; use super::GenmcCtx; use crate::{ InterpCx, InterpResult, MiriMachine, TerminationInfo, ThreadId, interp_ok, throw_machine_stop, }; enum NextInstrKind { ...
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/src/concurrency/genmc/shims.rs
src/tools/miri/src/concurrency/genmc/shims.rs
use genmc_sys::AssumeType; use rustc_middle::ty; use tracing::debug; use crate::concurrency::genmc::MAX_ACCESS_SIZE; use crate::concurrency::thread::EvalContextExt as _; use crate::*; impl GenmcCtx { /// Handle a user thread getting blocked. /// This may happen due to an manual `assume` statement added by a 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/src/concurrency/genmc/helper.rs
src/tools/miri/src/concurrency/genmc/helper.rs
use genmc_sys::{MemOrdering, RMWBinOp}; use rustc_abi::Size; use rustc_const_eval::interpret::{InterpResult, interp_ok}; use rustc_middle::mir; use rustc_middle::mir::interpret; use rustc_middle::ty::ScalarInt; use tracing::debug; use super::GenmcScalar; use crate::alloc_addresses::EvalContextExt as _; use crate::intr...
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/src/concurrency/genmc/thread_id_map.rs
src/tools/miri/src/concurrency/genmc/thread_id_map.rs
use genmc_sys::GENMC_MAIN_THREAD_ID; use rustc_data_structures::fx::FxHashMap; use crate::ThreadId; #[derive(Debug)] pub struct ThreadIdMap { /// Map from Miri thread IDs to GenMC thread IDs. /// We assume as little as possible about Miri thread IDs, so we use a map. miri_to_genmc: FxHashMap<ThreadId, 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/src/concurrency/genmc/mod.rs
src/tools/miri/src/concurrency/genmc/mod.rs
use std::cell::{Cell, RefCell}; use std::sync::Arc; use genmc_sys::{ EstimationResult, GENMC_GLOBAL_ADDRESSES_MASK, GenmcScalar, MemOrdering, MiriGenmcShim, RMWBinOp, UniquePtr, create_genmc_driver_handle, }; use rustc_abi::{Align, Size}; use rustc_const_eval::interpret::{AllocId, InterpCx, InterpResult, inter...
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/src/concurrency/genmc/run.rs
src/tools/miri/src/concurrency/genmc/run.rs
use std::num::NonZeroI32; use std::rc::Rc; use std::sync::Arc; use std::time::Instant; use genmc_sys::EstimationResult; use rustc_abi::Endian; use rustc_log::tracing; use rustc_middle::ty::TyCtxt; use super::GlobalState; use crate::concurrency::genmc::ExecutionEndResult; use crate::rustc_const_eval::interpret::Pointe...
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/src/concurrency/genmc/dummy.rs
src/tools/miri/src/concurrency/genmc/dummy.rs
use rustc_abi::{Align, Size}; use rustc_const_eval::interpret::{AllocId, InterpCx, InterpResult}; pub use self::intercept::EvalContextExt as GenmcEvalContextExt; pub use self::run::run_genmc_mode; use crate::intrinsics::AtomicRmwOp; use crate::{ AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, MemoryKin...
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/src/intrinsics/math.rs
src/tools/miri/src/intrinsics/math.rs
use rustc_apfloat::{self, Float, FloatConvert, Round}; use rustc_middle::mir; use rustc_middle::ty::{self, FloatTy}; use self::helpers::{ToHost, ToSoft}; use super::check_intrinsic_arg_count; use crate::*; fn sqrt<'tcx, F: Float + FloatConvert<F> + Into<Scalar>>( this: &mut MiriInterpCx<'tcx>, args: &[OpTy<'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/src/intrinsics/mod.rs
src/tools/miri/src/intrinsics/mod.rs
#![warn(clippy::arithmetic_side_effects)] mod atomic; mod math; mod simd; pub use self::atomic::AtomicRmwOp; #[rustfmt::skip] // prevent `use` reordering use rand::Rng; use rustc_abi::Size; use rustc_middle::{mir, ty}; use rustc_span::{Symbol, sym}; use self::atomic::EvalContextExt as _; use self::math::EvalContext...
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/src/intrinsics/simd.rs
src/tools/miri/src/intrinsics/simd.rs
use rustc_middle::ty; use rustc_middle::ty::FloatTy; use super::check_intrinsic_arg_count; use crate::helpers::{ToHost, ToSoft}; use crate::*; impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { /// Calls the simd intrinsic `intrinsic`; 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/src/intrinsics/atomic.rs
src/tools/miri/src/intrinsics/atomic.rs
use rustc_middle::mir::BinOp; use rustc_middle::ty::AtomicOrdering; use rustc_middle::{mir, ty}; use super::check_intrinsic_arg_count; use crate::*; pub enum AtomicRmwOp { MirOp { op: mir::BinOp, /// Indicates whether the result of the operation should be negated (`UnOp::Not`, must be 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/src/bin/miri.rs
src/tools/miri/src/bin/miri.rs
#![feature(rustc_private, stmt_expr_attributes)] #![allow( clippy::manual_range_contains, clippy::useless_format, clippy::field_reassign_with_default, clippy::needless_lifetimes, rustc::diagnostic_outside_of_impl, rustc::untranslatable_diagnostic )] // The rustc crates we need extern crate rust...
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/src/bin/log/setup.rs
src/tools/miri/src/bin/log/setup.rs
use std::env::{self, VarError}; use std::str::FromStr; use std::sync::{Mutex, OnceLock}; use rustc_log::tracing; use rustc_middle::ty::TyCtxt; use rustc_session::{CtfeBacktrace, EarlyDiagCtxt}; /// The tracing layer from `tracing-chrome` starts a thread in the background that saves data to /// file and closes the fil...
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/src/bin/log/tracing_chrome_instant.rs
src/tools/miri/src/bin/log/tracing_chrome_instant.rs
//! Code in this class was in part inspired by //! <https://github.com/tikv/minstant/blob/27c9ec5ec90b5b67113a748a4defee0d2519518c/src/tsc_now.rs>. //! A useful resource is also //! <https://www.pingcap.com/blog/how-we-trace-a-kv-database-with-less-than-5-percent-performance-impact/>, //! although this file does not im...
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/src/bin/log/tracing_chrome.rs
src/tools/miri/src/bin/log/tracing_chrome.rs
// SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: Copyright (c) 2020 Thoren Paulson //! This file was initially taken from the following link: //! <https://github.com/thoren-d/tracing-chrome/blob/7e2625ab4aeeef2f0ef9bde9d6258dd181c04472/src/lib.rs> //! //! The precise changes that were made to the original fil...
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/src/bin/log/mod.rs
src/tools/miri/src/bin/log/mod.rs
pub mod setup; mod tracing_chrome; mod tracing_chrome_instant;
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/src/alloc/isolated_alloc.rs
src/tools/miri/src/alloc/isolated_alloc.rs
use std::alloc::Layout; use std::ptr::NonNull; use rustc_index::bit_set::DenseBitSet; /// How many bytes of memory each bit in the bitset represents. const COMPRESSION_FACTOR: usize = 4; /// A dedicated allocator for interpreter memory contents, ensuring they are stored on dedicated /// pages (not mixed with Miri'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/src/alloc/alloc_bytes.rs
src/tools/miri/src/alloc/alloc_bytes.rs
use std::alloc::Layout; use std::borrow::Cow; use std::cell::RefCell; use std::rc::Rc; use std::{alloc, slice}; use rustc_abi::{Align, Size}; use rustc_middle::mir::interpret::AllocBytes; use crate::alloc::isolated_alloc::IsolatedAlloc; use crate::helpers::ToU64 as _; #[derive(Clone, Debug)] pub enum MiriAllocParams...
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/src/alloc/mod.rs
src/tools/miri/src/alloc/mod.rs
mod alloc_bytes; #[cfg(all(unix, feature = "native-lib"))] pub mod isolated_alloc; #[cfg(not(all(unix, feature = "native-lib")))] pub mod isolated_alloc { use std::alloc::Layout; /// Stub allocator to avoid `cfg`s in the rest of Miri. #[derive(Debug)] pub struct IsolatedAlloc(!); impl IsolatedAllo...
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/src/borrow_tracker/mod.rs
src/tools/miri/src/borrow_tracker/mod.rs
use std::cell::RefCell; use std::fmt; use std::num::NonZero; use rustc_abi::Size; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_middle::mir::RetagKind; use smallvec::SmallVec; use crate::*; pub mod stacked_borrows; pub mod tree_borrows; /// Indicates which kind of access is being performed. #[deri...
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/src/borrow_tracker/stacked_borrows/diagnostics.rs
src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs
use std::fmt; use rustc_abi::Size; use rustc_data_structures::fx::FxHashSet; use rustc_span::{Span, SpanData}; use smallvec::SmallVec; use crate::borrow_tracker::{AccessKind, GlobalStateInner, ProtectorKind}; use crate::*; /// Error reporting fn err_sb_ub<'tcx>( msg: String, help: Vec<String>, history: O...
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/src/borrow_tracker/stacked_borrows/mod.rs
src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
//! Implements "Stacked Borrows". See <https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md> //! for further information. pub mod diagnostics; mod item; mod stack; use std::fmt::Write; use std::sync::atomic::AtomicBool; use std::{cmp, mem}; use rustc_abi::Size; use rustc_data_struc...
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/src/borrow_tracker/stacked_borrows/stack.rs
src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs
#[cfg(feature = "stack-cache")] use std::ops::Range; use rustc_data_structures::fx::FxHashSet; use rustc_log::tracing::trace; use crate::borrow_tracker::stacked_borrows::{Item, Permission}; use crate::borrow_tracker::{AccessKind, BorTag}; use crate::{InterpResult, ProvenanceExtra, interp_ok}; /// Exactly what cache ...
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/src/borrow_tracker/stacked_borrows/item.rs
src/tools/miri/src/borrow_tracker/stacked_borrows/item.rs
use std::fmt; use crate::borrow_tracker::BorTag; /// An item in the per-location borrow stack. #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Item(u64); // An Item contains 3 bitfields: // * Bits 0-61 store a BorTag. // * Bits 61-63 store a Permission. // * Bit 64 stores a flag which indicates if we might ha...
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/src/borrow_tracker/tree_borrows/wildcard.rs
src/tools/miri/src/borrow_tracker/tree_borrows/wildcard.rs
use std::cmp::max; use std::fmt::Debug; use super::Tree; use super::tree::{AccessRelatedness, Node}; use super::unimap::{UniIndex, UniValMap}; use crate::BorTag; use crate::borrow_tracker::AccessKind; #[cfg(feature = "expensive-consistency-checks")] use crate::borrow_tracker::GlobalState; /// Represents the maximum 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/src/borrow_tracker/tree_borrows/diagnostics.rs
src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs
use std::fmt; use std::ops::Range; use rustc_data_structures::fx::FxHashMap; use rustc_span::{Span, SpanData}; use crate::borrow_tracker::tree_borrows::perms::{PermTransition, Permission}; use crate::borrow_tracker::tree_borrows::tree::LocationState; use crate::borrow_tracker::tree_borrows::unimap::UniIndex; use crat...
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/src/borrow_tracker/tree_borrows/perms.rs
src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs
use std::cmp::{Ordering, PartialOrd}; use std::fmt; use crate::borrow_tracker::AccessKind; use crate::borrow_tracker::tree_borrows::diagnostics::TransitionError; use crate::borrow_tracker::tree_borrows::tree::AccessRelatedness; /// The activation states of a pointer. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]...
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/src/borrow_tracker/tree_borrows/foreign_access_skipping.rs
src/tools/miri/src/borrow_tracker/tree_borrows/foreign_access_skipping.rs
use super::AccessKind; use super::tree::AccessRelatedness; /// To speed up tree traversals, we want to skip traversing subtrees when we know the traversal will have no effect. /// This is often the case for foreign accesses, since usually foreign accesses happen several times in a row, but also /// foreign accesses 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/src/borrow_tracker/tree_borrows/exhaustive.rs
src/tools/miri/src/borrow_tracker/tree_borrows/exhaustive.rs
//! Exhaustive testing utilities. //! (These are used in Tree Borrows `#[test]`s for thorough verification //! of the behavior of the state machine of permissions, //! but the contents of this file are extremely generic) pub trait Exhaustive: Sized { fn exhaustive() -> Box<dyn Iterator<Item = Self>>; } macro_rule...
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/src/borrow_tracker/tree_borrows/tree.rs
src/tools/miri/src/borrow_tracker/tree_borrows/tree.rs
//! In this file we handle the "Tree" part of Tree Borrows, i.e. all tree //! traversal functions, optimizations to trim branches, and keeping track of //! the relative position of the access to each node being updated. This of course //! also includes the definition of the tree structure. //! //! Functions here manipu...
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/src/borrow_tracker/tree_borrows/tree_visitor.rs
src/tools/miri/src/borrow_tracker/tree_borrows/tree_visitor.rs
use std::marker::PhantomData; use super::tree::{AccessRelatedness, Node}; use super::unimap::{UniIndex, UniValMap}; /// Data given to the transition function pub struct NodeAppArgs<'visit, T> { /// The index of the current node. pub idx: UniIndex, /// Relative position of the access. pub rel_pos: Acce...
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/src/borrow_tracker/tree_borrows/mod.rs
src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
use rustc_abi::Size; use rustc_middle::mir::{Mutability, RetagKind}; use rustc_middle::ty::layout::HasTypingEnv; use rustc_middle::ty::{self, Ty}; use self::foreign_access_skipping::IdempotentForeignAccess; use self::tree::LocationState; use crate::borrow_tracker::{AccessKind, GlobalState, GlobalStateInner, ProtectorK...
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/src/borrow_tracker/tree_borrows/unimap.rs
src/tools/miri/src/borrow_tracker/tree_borrows/unimap.rs
//! This module implements the `UniMap`, which is a way to get efficient mappings //! optimized for the setting of `tree_borrows/tree.rs`. //! //! A `UniKeyMap<K>` is a (slow) mapping from `K` to `UniIndex`, //! and `UniValMap<V>` is a (fast) mapping from `UniIndex` to `V`. //! Thus a pair `(UniKeyMap<K>, UniValMap<V>)...
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/src/borrow_tracker/tree_borrows/tree/tests.rs
src/tools/miri/src/borrow_tracker/tree_borrows/tree/tests.rs
//! Tests for the tree #![cfg(test)] use std::fmt; use super::*; use crate::borrow_tracker::tree_borrows::exhaustive::{Exhaustive, precondition}; impl Exhaustive for LocationState { fn exhaustive() -> Box<dyn Iterator<Item = Self>> { // We keep `latest_foreign_access` at `None` as that's just a cache. ...
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/src/data_structures/range_object_map.rs
src/tools/miri/src/data_structures/range_object_map.rs
//! Implements a map from allocation ranges to data. This is somewhat similar to RangeMap, but the //! ranges and data are discrete and non-splittable -- they represent distinct "objects". An //! allocation in the map will always have the same range until explicitly removed use std::ops::{Index, IndexMut, Range}; 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/src/data_structures/mono_hash_map.rs
src/tools/miri/src/data_structures/mono_hash_map.rs
//! This is a "monotonic `FxHashMap`": A `FxHashMap` that, when shared, can be pushed to but not //! otherwise mutated. We also box items in the map. This means we can safely provide //! shared references into existing items in the `FxHashMap`, because they will not be dropped //! (from being removed) or moved (because...
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/src/data_structures/mod.rs
src/tools/miri/src/data_structures/mod.rs
pub mod dedup_range_map; pub mod mono_hash_map; pub mod range_object_map;
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/src/data_structures/dedup_range_map.rs
src/tools/miri/src/data_structures/dedup_range_map.rs
//! Implements a map from integer indices to data. //! Rather than storing data for every index, internally, this maps entire ranges to the data. //! To this end, the APIs all work on ranges, not on individual integers. Ranges are split as //! necessary (e.g., when [0,5) is first associated with X, and then [1,2) is mu...
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/ui.rs
src/tools/miri/tests/ui.rs
use std::env; use std::ffi::OsString; use std::num::NonZero; use std::path::{Path, PathBuf}; use std::process::Command; use std::sync::OnceLock; use colored::*; use regex::bytes::Regex; use ui_test::build_manager::BuildManager; use ui_test::color_eyre::eyre::{Context, Result}; use ui_test::custom_flags::edition::Editi...
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/many-seeds/scoped-thread-leak.rs
src/tools/miri/tests/many-seeds/scoped-thread-leak.rs
//! Regression test for https://github.com/rust-lang/miri/issues/2629 use std::thread; fn main() { thread::scope(|s| { s.spawn(|| {}); }); }
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/many-seeds/reentrant-lock.rs
src/tools/miri/tests/many-seeds/reentrant-lock.rs
#![feature(reentrant_lock)] //! This is a regression test for //! <https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/reentrant.20lock.20failure.20on.20mips>. use std::cell::Cell; use std::sync::ReentrantLock; use std::thread; static LOCK: ReentrantLock<Cell<i32>> = ReentrantLock::new(Cell::new(0)); 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/many-seeds/tls-leak.rs
src/tools/miri/tests/many-seeds/tls-leak.rs
//! Regression test for <https://github.com/rust-lang/rust/issues/123583>. use std::thread; fn with_thread_local1() { thread_local! { static X: Box<u8> = Box::new(0); } X.with(|_x| {}) } fn with_thread_local2() { thread_local! { static Y: Box<u8> = Box::new(0); } Y.with(|_y| {}) } 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/native-lib/fail/struct_not_extern_c.rs
src/tools/miri/tests/native-lib/fail/struct_not_extern_c.rs
// Only works on Unix targets //@ignore-target: windows wasm //@only-on-host #![allow(improper_ctypes)] pub struct PassMe { pub value: i32, pub other_value: i64, } extern "C" { fn pass_struct(s: PassMe) -> i64; } fn main() { let pass_me = PassMe { value: 42, other_value: 1337 }; unsafe { pass_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/native-lib/fail/pass_struct_expose_only_range.rs
src/tools/miri/tests/native-lib/fail/pass_struct_expose_only_range.rs
//@compile-flags: -Zmiri-permissive-provenance #[repr(C)] #[derive(Copy, Clone)] struct HasPointer { ptr: *const u8, } extern "C" { fn access_struct_ptr(s: HasPointer) -> u8; } fn main() { let structs = vec![HasPointer { ptr: &0 }, HasPointer { ptr: &1 }]; unsafe { let r = access_struct_ptr(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/native-lib/fail/private_function.rs
src/tools/miri/tests/native-lib/fail/private_function.rs
// Only works on Unix targets //@ignore-target: windows wasm //@only-on-host //@normalize-stderr-test: "OS `.*`" -> "$$OS" extern "C" { fn not_exported(); } fn main() { unsafe { not_exported(); //~ ERROR: unsupported operation: can't call foreign function `not_exported` } }
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/native-lib/fail/function_not_in_so.rs
src/tools/miri/tests/native-lib/fail/function_not_in_so.rs
// Only works on Unix targets //@ignore-target: windows wasm //@only-on-host //@normalize-stderr-test: "OS `.*`" -> "$$OS" extern "C" { fn foo(); } fn main() { unsafe { foo(); //~ ERROR: unsupported operation: can't call foreign function `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/native-lib/fail/uninit_struct.rs
src/tools/miri/tests/native-lib/fail/uninit_struct.rs
#[repr(C)] #[derive(Copy, Clone)] struct ComplexStruct { part_1: Part1, part_2: Part2, part_3: u32, } #[repr(C)] #[derive(Copy, Clone)] struct Part1 { high: u16, low: u16, } #[repr(C)] #[derive(Copy, Clone)] struct Part2 { bits: u32, } extern "C" { fn pass_struct_complex(s: ComplexStruct, h...
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/native-lib/fail/tracing/partial_init.rs
src/tools/miri/tests/native-lib/fail/tracing/partial_init.rs
//@only-target: x86_64-unknown-linux-gnu i686-unknown-linux-gnu //@compile-flags: -Zmiri-native-lib-enable-tracing extern "C" { fn init_n(n: i32, ptr: *mut u8); } fn main() { partial_init(); } // Initialise the first 2 elements of the slice from native code, and check // that the 3rd is correctly deemed unin...
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/native-lib/fail/tracing/unexposed_reachable_alloc.rs
src/tools/miri/tests/native-lib/fail/tracing/unexposed_reachable_alloc.rs
//@only-target: x86_64-unknown-linux-gnu i686-unknown-linux-gnu //@compile-flags: -Zmiri-permissive-provenance -Zmiri-native-lib-enable-tracing extern "C" { fn do_one_deref(ptr: *const *const *const i32) -> usize; } fn main() { unexposed_reachable_alloc(); } // Expose 2 pointers by virtue of doing a native 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/native-lib/pass/aggregate_arguments.rs
src/tools/miri/tests/native-lib/pass/aggregate_arguments.rs
fn main() { test_pass_struct(); test_pass_struct_complex(); } /// Test passing a basic struct as an argument. fn test_pass_struct() { // Exactly two fields, so that we hit the ScalarPair case. #[repr(C)] struct PassMe { value: i32, other_value: i64, } extern "C" { 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/native-lib/pass/ptr_write_access.rs
src/tools/miri/tests/native-lib/pass/ptr_write_access.rs
//@revisions: trace notrace //@[trace] only-target: x86_64-unknown-linux-gnu i686-unknown-linux-gnu //@[trace] compile-flags: -Zmiri-native-lib-enable-tracing //@compile-flags: -Zmiri-permissive-provenance #![feature(box_as_ptr)] use std::mem::MaybeUninit; use std::ptr; fn main() { test_increment_int(); 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/native-lib/pass/scalar_arguments.rs
src/tools/miri/tests/native-lib/pass/scalar_arguments.rs
extern "C" { fn add_one_int(x: i32) -> i32; fn add_int16(x: i16) -> i16; fn test_stack_spill( a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32, i: i32, j: i32, k: i32, l: i32, ) -> i32; fn 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/native-lib/pass/ptr_read_access.rs
src/tools/miri/tests/native-lib/pass/ptr_read_access.rs
//@revisions: trace notrace //@[trace] only-target: x86_64-unknown-linux-gnu i686-unknown-linux-gnu //@[trace] compile-flags: -Zmiri-native-lib-enable-tracing //@compile-flags: -Zmiri-permissive-provenance use std::ptr::NonNull; fn main() { test_access_pointer(); test_access_simple(); test_access_nested()...
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/fail/storage-live-resets-var.rs
src/tools/miri/tests/fail/storage-live-resets-var.rs
#![feature(core_intrinsics, custom_mir)] use std::intrinsics::mir::*; #[custom_mir(dialect = "runtime")] fn main() { mir! { let val: i32; let _val2: i32; { StorageLive(val); val = 42; StorageLive(val); // reset val to `uninit` _val2 = val; //~...
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/fail/branchless-select-i128-pointer.rs
src/tools/miri/tests/fail/branchless-select-i128-pointer.rs
#![allow(integer_to_ptr_transmutes)] use std::mem::transmute; #[cfg(target_pointer_width = "32")] type TwoPtrs = i64; #[cfg(target_pointer_width = "64")] type TwoPtrs = i128; fn main() { for &my_bool in &[true, false] { let mask = -(my_bool as TwoPtrs); // false -> 0, true -> -1 aka !0 // This 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/fail/erroneous_const2.rs
src/tools/miri/tests/fail/erroneous_const2.rs
const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; //~^ERROR: overflow #[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391 fn main() { println!("{}", 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/fail/type-too-large.rs
src/tools/miri/tests/fail/type-too-large.rs
//@ignore-bitwidth: 32 fn main() { let _fat: [u8; (1 << 61) + (1 << 31)]; // ideally we'd error here, but we avoid computing the layout until absolutely necessary _fat = [0; (1u64 << 61) as usize + (1u64 << 31) as usize]; //~ ERROR: post-monomorphization 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/fail/async-shared-mutable.rs
src/tools/miri/tests/fail/async-shared-mutable.rs
//! FIXME: This test should pass! However, `async fn` does not yet use `UnsafePinned`. //! This is a regression test for <https://github.com/rust-lang/rust/issues/137750>: //! `UnsafePinned` must include the effects of `UnsafeCell`. //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@normalize-stder...
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/fail/dyn-upcast-trait-mismatch.rs
src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs
// Validation stops this too early. //@compile-flags: -Zmiri-disable-validation trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { #[allow(dead_code)] fn a(&self) -> i32 { 10 } #[allow(dead_code)] fn z(&self) -> i32 { 11 } #[allow(dead_code)] fn y(&self) -> i3...
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/fail/extern-type-field-offset.rs
src/tools/miri/tests/fail/extern-type-field-offset.rs
#![feature(extern_types)] extern "C" { type Opaque; } struct Newtype(Opaque); struct S { i: i32, j: i32, a: Newtype, } fn main() { let buf = [0i32; 4]; let x: &Newtype = unsafe { &*(&buf as *const _ as *const Newtype) }; // Projecting to the newtype works, because it is always at offset...
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/fail/erroneous_const.rs
src/tools/miri/tests/fail/erroneous_const.rs
//! Make sure we detect erroneous constants post-monomorphization even when they are unused. //! (https://github.com/rust-lang/miri/issues/1382) #![feature(never_type)] struct PrintName<T>(T); impl<T> PrintName<T> { const VOID: ! = panic!(); //~ERROR: explicit panic } fn no_codegen<T>() { if false { 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/fail/static_memory_modification1.rs
src/tools/miri/tests/fail/static_memory_modification1.rs
// Stacked Borrows detects that we are casting & to &mut and so it changes why we fail //@compile-flags: -Zmiri-disable-stacked-borrows static X: usize = 5; #[allow(mutable_transmutes)] fn main() { unsafe { *std::mem::transmute::<&usize, &mut usize>(&X) = 6; //~ ERROR: read-only assert_eq!(X, 6); ...
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/fail/issue-miri-1112.rs
src/tools/miri/tests/fail/issue-miri-1112.rs
trait Empty {} #[repr(transparent)] pub struct FunnyPointer(dyn Empty); #[repr(C)] pub struct Meta { drop_fn: fn(&mut ()), size: usize, align: usize, } impl Meta { fn new() -> Self { Meta { drop_fn: |_| {}, size: 0, align: 1 } } } #[repr(C)] pub struct FatPointer { pub data: *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/fail/layout_cycle.rs
src/tools/miri/tests/fail/layout_cycle.rs
//@error-in-other-file: a cycle occurred during layout computation //~^ ERROR: cycle detected when computing layout of use std::mem; pub struct S<T: Tr> { pub f: <T as Tr>::I, } pub trait Tr { type I: Tr; } impl<T: Tr> Tr for S<T> { type I = S<S<T>>; } impl Tr for () { type I = (); } fn foo<T: Tr>...
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/fail/miri_start_wrong_sig.rs
src/tools/miri/tests/fail/miri_start_wrong_sig.rs
//@compile-flags: -Cpanic=abort //@error-in-other-file: `miri_start` must have the following signature: #![no_main] #![no_std] use core::fmt::Write; #[path = "../utils/mod.no_std.rs"] mod utils; #[no_mangle] fn miri_start() -> isize { //~^ ERROR: mismatched types writeln!(utils::MiriStdout, "Hello from 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/fail/environ-gets-deallocated.rs
src/tools/miri/tests/fail/environ-gets-deallocated.rs
//@ignore-target: windows # Windows does not have a global environ list that the program can access directly fn get_environ() -> *const *const u8 { extern "C" { static mut environ: *const *const u8; } unsafe { environ } } fn main() { let pointer = get_environ(); let _x = unsafe { *pointer ...
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/fail/memleak.rs
src/tools/miri/tests/fail/memleak.rs
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$" fn main() { std::mem::forget(Box::new(42)); //~ERROR: memory leaked }
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/fail/breakpoint.rs
src/tools/miri/tests/fail/breakpoint.rs
#![feature(core_intrinsics)] fn main() { core::intrinsics::breakpoint(); //~ ERROR: trace/breakpoint trap }
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/fail/extern_static.rs
src/tools/miri/tests/fail/extern_static.rs
//! Even referencing an unknown `extern static` already triggers an error. extern "C" { static mut FOO: i32; } fn main() { let _val = std::ptr::addr_of!(FOO); //~ ERROR: is not supported by 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/fail/unwind-action-terminate.rs
src/tools/miri/tests/fail/unwind-action-terminate.rs
//@error-in-other-file: aborted execution //@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> "" //@normalize-stderr-test: "\n +at [^\n]+" -> "" extern "C" fn panic_abort() { panic!() } fn main() { panic_abort(); }
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/fail/tls_static_leak.rs
src/tools/miri/tests/fail/tls_static_leak.rs
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$" #![feature(thread_local)] use std::cell::Cell; /// Ensure that leaks through `thread_local` statics *not in the main thread* /// are detected. fn main() { #[thread_local] static TLS: Cell<Option<&'static i32>> = Cell::new(None); std::thread::spawn(|| {...
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/fail/deny_lint.rs
src/tools/miri/tests/fail/deny_lint.rs
#![deny(warnings, unused)] struct Foo; //~^ ERROR: struct `Foo` is never constructed 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/fail/dyn-call-trait-mismatch.rs
src/tools/miri/tests/fail/dyn-call-trait-mismatch.rs
// Validation and SB stop this too early. //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows trait T1 { #[allow(dead_code)] fn method1(self: Box<Self>); } trait T2 { fn method2(self: Box<Self>); } impl T1 for i32 { fn method1(self: Box<Self>) {} } fn main() { let r = Box::...
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/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.rs
src/tools/miri/tests/fail/issue-miri-3288-ice-symbolic-alignment-extern-static.rs
//@compile-flags: -Zmiri-symbolic-alignment-check extern "C" { static _dispatch_queue_attr_concurrent: [u8; 0]; } static DISPATCH_QUEUE_CONCURRENT: &'static [u8; 0] = unsafe { &_dispatch_queue_attr_concurrent }; fn main() { let _val = *DISPATCH_QUEUE_CONCURRENT; //~ERROR: is not supported }
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/fail/ptr_swap_nonoverlapping.rs
src/tools/miri/tests/fail/ptr_swap_nonoverlapping.rs
//! This is a regression test for <https://github.com/rust-lang/miri/issues/4188>: The precondition //! check in `ptr::swap_nonoverlapping` was incorrectly disabled in Miri. //@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> "" //@normalize-stderr-test: "\n +at [^\n]+" -> "" //@error-in-other-file: aborted execution 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/fail/box-cell-alias.rs
src/tools/miri/tests/fail/box-cell-alias.rs
//@compile-flags: -Zmiri-strict-provenance // Taken from <https://github.com/rust-lang/unsafe-code-guidelines/issues/194#issuecomment-520934222>. use std::cell::Cell; fn helper(val: Box<Cell<u8>>, ptr: *const Cell<u8>) -> u8 { val.set(10); unsafe { (*ptr).set(20) }; //~ ERROR: does not exist in the borrow 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/fail/static_memory_modification3.rs
src/tools/miri/tests/fail/static_memory_modification3.rs
// Stacked Borrows detects that we are casting & to &mut and so it changes why we fail //@compile-flags: -Zmiri-disable-stacked-borrows use std::mem::transmute; #[allow(mutable_transmutes)] fn main() { unsafe { let bs = b"this is a test"; transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR: 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/fail/static_memory_modification2.rs
src/tools/miri/tests/fail/static_memory_modification2.rs
// Stacked Borrows detects that we are casting & to &mut and so it changes why we fail //@compile-flags: -Zmiri-disable-stacked-borrows use std::mem::transmute; #[allow(mutable_transmutes)] fn main() { unsafe { let s = "this is a test"; transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERRO...
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/fail/reading_half_a_pointer.rs
src/tools/miri/tests/fail/reading_half_a_pointer.rs
#![allow(dead_code)] // We use packed structs to get around alignment restrictions #[repr(C, packed)] struct Data { pad: u8, ptr: &'static i32, } // But we need to guarantee some alignment struct Wrapper { align: u64, data: Data, } static G: i32 = 0; fn main() { let mut w = Wrapper { align: 0, 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/fail/extern_static_in_const.rs
src/tools/miri/tests/fail/extern_static_in_const.rs
//! Even referencing an unknown `extern static` already triggers an error. extern "C" { static E: [u8; 0]; } static X: &'static [u8; 0] = unsafe { &E }; fn main() { let _val = X; //~ ERROR: is not supported by 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/fail/storage-live-dead-var.rs
src/tools/miri/tests/fail/storage-live-dead-var.rs
#![feature(core_intrinsics, custom_mir)] use std::intrinsics::mir::*; #[custom_mir(dialect = "runtime")] fn main() { mir! { let val: i32; { val = 42; //~ERROR: accessing a dead local variable StorageLive(val); // too late... (but needs to be here to make `val` not implicitly...
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/fail/memleak_no_backtrace.rs
src/tools/miri/tests/fail/memleak_no_backtrace.rs
//@compile-flags: -Zmiri-disable-leak-backtraces //@error-in-other-file: memory leaked //@normalize-stderr-test: ".*│.*" -> "$$stripped$$" 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/fail/never_match_never.rs
src/tools/miri/tests/fail/never_match_never.rs
// This should fail even without validation //@compile-flags: -Zmiri-disable-validation #![feature(never_type)] #![allow(unreachable_code)] fn main() { let ptr: *const (i32, !) = &0i32 as *const i32 as *const _; unsafe { match (*ptr).1 {} } //~ ERROR: entering unreachable code }
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/fail/never_say_never.rs
src/tools/miri/tests/fail/never_say_never.rs
// This should fail even without validation //@compile-flags: -Zmiri-disable-validation #![feature(never_type)] #![allow(unreachable_code)] fn main() { let y = &5; let x: ! = unsafe { *(y as *const _ as *const !) }; f(x) //~ ERROR: entering unreachable code } fn f(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/fail/overlapping_assignment.rs
src/tools/miri/tests/fail/overlapping_assignment.rs
#![feature(core_intrinsics)] #![feature(custom_mir)] use std::intrinsics::mir::*; // It's not that easy to fool the MIR validity check // which wants to prevent overlapping assignments... // So we use two separate pointer arguments, and then arrange for them to alias. #[custom_mir(dialect = "runtime", phase = "optimi...
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/fail/modifying_constants.rs
src/tools/miri/tests/fail/modifying_constants.rs
// This should fail even without validation/SB //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows #![allow(invalid_reference_casting)] fn main() { let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee let y = unsafe...
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/fail/rustc-error2.rs
src/tools/miri/tests/fail/rustc-error2.rs
// Regression test for https://github.com/rust-lang/rust/issues/121508. struct Struct<T>(T); impl<T> std::ops::Deref for Struct<T> { type Target = dyn Fn(T); fn deref(&self) -> &assert_mem_uninitialized_valid::Target { //~^ERROR: use of unresolved module or unlinked crate unimplemented!() }...
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/fail/overlapping_assignment_aggregate.rs
src/tools/miri/tests/fail/overlapping_assignment_aggregate.rs
//! This is like `pass/overlapping_assignment_aggregate_scalar.rs` but with a non-scalar //! type, and that makes it definite UB. #![feature(custom_mir, core_intrinsics)] #![allow(internal_features)] use std::intrinsics::mir::*; #[custom_mir(dialect = "runtime")] fn main() { mir! { let _1: ([u8; 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/fail/coroutine-pinned-moved.rs
src/tools/miri/tests/fail/coroutine-pinned-moved.rs
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] use std::ops::{Coroutine, CoroutineState}; use std::pin::Pin; fn firstn() -> impl Coroutine<Yield = u64, Return = ()> { #[coroutine] static move || { let mut num = ...
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/fail/terminate-terminator.rs
src/tools/miri/tests/fail/terminate-terminator.rs
//@compile-flags: -Zmir-opt-level=3 -Zinline-mir-hint-threshold=1000 //@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> "" //@normalize-stderr-test: "\n +at [^\n]+" -> "" //@error-in-other-file: aborted execution // Enable MIR inlining to ensure that `TerminatorKind::UnwindTerminate` is generated // instead of just `Unwi...
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/fail/extern_static_wrong_size.rs
src/tools/miri/tests/fail/extern_static_wrong_size.rs
//@only-target: linux # we need a specific extern supported on this target //@normalize-stderr-test: "[48] bytes" -> "N bytes" extern "C" { static mut environ: i8; } fn main() { let _val = unsafe { environ }; //~ ERROR: /with a size of 1 bytes and alignment of 1 bytes, but Miri emulates it via an extern stati...
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/fail/const-ub-checks.rs
src/tools/miri/tests/fail/const-ub-checks.rs
const UNALIGNED_READ: () = unsafe { let x = &[0u8; 4]; let ptr = x.as_ptr().cast::<u32>(); ptr.read(); //~ERROR: accessing memory based on pointer with alignment 1, but alignment 4 is required }; fn main() { let _x = UNALIGNED_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/fail/dyn-upcast-nop-wrong-trait.rs
src/tools/miri/tests/fail/dyn-upcast-nop-wrong-trait.rs
// This upcast is currently forbidden because it involves an invalid value. // However, if in the future we relax the validity requirements for raw pointer vtables, // we could consider allowing this again -- the cast itself isn't doing anything wrong, // only the transmutes needed to set up the testcase are wrong. us...
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/fail/never_transmute_humans.rs
src/tools/miri/tests/fail/never_transmute_humans.rs
// This should fail even without validation //@compile-flags: -Zmiri-disable-validation #![feature(never_type)] struct Human; fn main() { let _x: ! = unsafe { std::mem::transmute::<Human, !>(Human) //~ ERROR: entering unreachable code }; }
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/fail/rc_as_ptr.rs
src/tools/miri/tests/fail/rc_as_ptr.rs
// This should fail even without validation //@compile-flags: -Zmiri-disable-validation use std::ptr; use std::rc::{Rc, Weak}; /// Taken from the `Weak::as_ptr` doctest. fn main() { let strong = Rc::new(Box::new(42)); let weak = Rc::downgrade(&strong); // Both point to the same object assert!(ptr::eq(...
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/fail/no_main.rs
src/tools/miri/tests/fail/no_main.rs
//@error-in-other-file: Miri can only run programs that have a main function. #![no_main]
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false