├── library ├── stdarch │ ├── .gitmodules │ ├── rustfmt.toml │ ├── crates │ │ ├── stdarch-verify │ │ │ ├── .gitattributes │ │ │ └── Cargo.toml │ │ ├── core_arch │ │ │ ├── rustfmt.toml │ │ │ └── src │ │ │ │ ├── riscv32 │ │ │ │ └── mod.rs │ │ │ │ ├── s390x │ │ │ │ └── mod.rs │ │ │ │ ├── loongarch64 │ │ │ │ ├── lsx │ │ │ │ │ └── mod.rs │ │ │ │ └── lasx │ │ │ │ │ └── mod.rs │ │ │ │ ├── powerpc64 │ │ │ │ └── mod.rs │ │ │ │ ├── arm_shared │ │ │ │ └── barrier │ │ │ │ │ └── common.rs │ │ │ │ ├── powerpc │ │ │ │ └── mod.rs │ │ │ │ └── mips │ │ │ │ └── mod.rs │ │ ├── simd-test-macro │ │ │ └── Cargo.toml │ │ ├── stdarch-gen-loongarch │ │ │ └── Cargo.toml │ │ ├── assert-instr-macro │ │ │ ├── build.rs │ │ │ └── Cargo.toml │ │ └── intrinsic-test │ │ │ ├── src │ │ │ ├── arm │ │ │ │ └── argument.rs │ │ │ └── common │ │ │ │ └── indentation.rs │ │ │ └── Cargo.toml │ ├── rust-version │ ├── josh-sync.toml │ ├── vendor.yml │ ├── ci │ │ ├── docker │ │ │ ├── nvptx64-nvidia-cuda │ │ │ │ └── Dockerfile │ │ │ ├── i586-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── i686-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── riscv64gc-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── arm-unknown-linux-gnueabihf │ │ │ │ └── Dockerfile │ │ │ ├── mips-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── mips64-unknown-linux-gnuabi64 │ │ │ │ └── Dockerfile │ │ │ ├── mips64el-unknown-linux-gnuabi64 │ │ │ │ └── Dockerfile │ │ │ ├── s390x-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── loongarch64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── wasm32-wasip1 │ │ │ │ └── Dockerfile │ │ │ ├── powerpc-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── armv7-unknown-linux-gnueabihf │ │ │ │ └── Dockerfile │ │ │ ├── aarch64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── powerpc64le-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── riscv32gc-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── powerpc64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ └── x86_64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ └── style.sh │ ├── .git-blame-ignore-revs │ ├── .gitignore │ ├── Cargo.toml │ ├── .cirrus.yml │ └── examples │ │ └── Cargo.toml ├── coretests │ ├── tests │ │ ├── ffi.rs │ │ ├── panic.rs │ │ ├── io │ │ │ └── mod.rs │ │ ├── num │ │ │ ├── i8.rs │ │ │ ├── u16.rs │ │ │ ├── u32.rs │ │ │ ├── u64.rs │ │ │ ├── u8.rs │ │ │ ├── i16.rs │ │ │ ├── i64.rs │ │ │ ├── u128.rs │ │ │ ├── i128.rs │ │ │ ├── nan.rs │ │ │ ├── niche_types.rs │ │ │ ├── float_iter_sum_identity.rs │ │ │ └── const_from.rs │ │ ├── str.rs │ │ ├── wtf8.rs │ │ ├── iter │ │ │ ├── traits │ │ │ │ └── mod.rs │ │ │ └── adapters │ │ │ │ ├── scan.rs │ │ │ │ ├── copied.rs │ │ │ │ └── by_ref_sized.rs │ │ ├── unicode.rs │ │ ├── simd.rs │ │ ├── net │ │ │ └── mod.rs │ │ ├── convert.rs │ │ ├── panic │ │ │ └── location │ │ │ │ ├── file_a.rs │ │ │ │ ├── file_b.rs │ │ │ │ └── file_c.rs │ │ ├── async_iter │ │ │ └── mod.rs │ │ ├── task.rs │ │ └── manually_drop.rs │ ├── benches │ │ ├── hash │ │ │ └── mod.rs │ │ ├── char │ │ │ └── mod.rs │ │ ├── net │ │ │ └── mod.rs │ │ ├── str.rs │ │ ├── any.rs │ │ ├── ops.rs │ │ ├── str │ │ │ └── iter.rs │ │ ├── array.rs │ │ └── tuple.rs │ └── lib.rs ├── portable-simd │ ├── .gitignore │ ├── Cross.toml │ ├── crates │ │ ├── core_simd │ │ │ ├── tests │ │ │ │ ├── mask_ops.rs │ │ │ │ ├── i8_ops.rs │ │ │ │ ├── f32_ops.rs │ │ │ │ ├── f64_ops.rs │ │ │ │ ├── i16_ops.rs │ │ │ │ ├── i32_ops.rs │ │ │ │ ├── i64_ops.rs │ │ │ │ ├── isize_ops.rs │ │ │ │ ├── u16_ops.rs │ │ │ │ ├── u32_ops.rs │ │ │ │ ├── u64_ops.rs │ │ │ │ ├── u8_ops.rs │ │ │ │ ├── mask_ops_impl │ │ │ │ │ ├── mask64.rs │ │ │ │ │ ├── mask8.rs │ │ │ │ │ ├── masksize.rs │ │ │ │ │ ├── mask32.rs │ │ │ │ │ ├── mask16.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── usize_ops.rs │ │ │ │ ├── autoderef.rs │ │ │ │ └── try_from_slice.rs │ │ │ ├── src │ │ │ │ ├── simd │ │ │ │ │ ├── cmp.rs │ │ │ │ │ ├── ptr.rs │ │ │ │ │ └── num.rs │ │ │ │ └── vendor │ │ │ │ │ └── powerpc.rs │ │ │ ├── webdriver.json │ │ │ └── examples │ │ │ │ └── README.md │ │ ├── test_helpers │ │ │ └── Cargo.toml │ │ └── std_float │ │ │ └── Cargo.toml │ ├── .github │ │ ├── ISSUE_TEMPLATE │ │ │ ├── blank_issue.md │ │ │ ├── config.yml │ │ │ └── feature_request.md │ │ ├── workflows │ │ │ └── doc.yml │ │ └── PULL_REQUEST_TEMPLATE.md │ ├── rust-toolchain.toml │ └── Cargo.toml ├── std │ ├── benches │ │ ├── hash │ │ │ └── mod.rs │ │ └── lib.rs │ ├── src │ │ ├── sys │ │ │ ├── pal │ │ │ │ ├── unix │ │ │ │ │ ├── linux │ │ │ │ │ │ └── mod.rs │ │ │ │ │ └── sync │ │ │ │ │ │ └── mod.rs │ │ │ │ ├── windows │ │ │ │ │ ├── stack_overflow_uwp.rs │ │ │ │ │ ├── c │ │ │ │ │ │ └── README.md │ │ │ │ │ ├── os │ │ │ │ │ │ └── tests.rs │ │ │ │ │ └── api │ │ │ │ │ │ └── tests.rs │ │ │ │ ├── unsupported │ │ │ │ │ └── mod.rs │ │ │ │ ├── xous │ │ │ │ │ └── mod.rs │ │ │ │ ├── trusty │ │ │ │ │ └── mod.rs │ │ │ │ ├── sgx │ │ │ │ │ ├── waitqueue │ │ │ │ │ │ ├── tests.rs │ │ │ │ │ │ └── spin_mutex │ │ │ │ │ │ │ └── tests.rs │ │ │ │ │ ├── abi │ │ │ │ │ │ ├── thread.rs │ │ │ │ │ │ └── tls │ │ │ │ │ │ │ └── sync_bitset │ │ │ │ │ │ │ └── tests.rs │ │ │ │ │ └── thread_parking.rs │ │ │ │ └── common │ │ │ │ │ └── mod.rs │ │ │ ├── io │ │ │ │ └── is_terminal │ │ │ │ │ ├── unsupported.rs │ │ │ │ │ ├── hermit.rs │ │ │ │ │ └── isatty.rs │ │ │ ├── stdio │ │ │ │ └── windows │ │ │ │ │ └── tests.rs │ │ │ ├── random │ │ │ │ ├── wasip1.rs │ │ │ │ ├── espidf.rs │ │ │ │ ├── teeos.rs │ │ │ │ ├── solid.rs │ │ │ │ ├── trusty.rs │ │ │ │ ├── getrandom.rs │ │ │ │ ├── hermit.rs │ │ │ │ ├── wasip2.rs │ │ │ │ ├── redox.rs │ │ │ │ ├── fuchsia.rs │ │ │ │ ├── unsupported.rs │ │ │ │ ├── zkvm.rs │ │ │ │ └── windows.rs │ │ │ ├── anonymous_pipe │ │ │ │ ├── unsupported.rs │ │ │ │ ├── unix.rs │ │ │ │ ├── mod.rs │ │ │ │ └── windows.rs │ │ │ ├── args │ │ │ │ ├── wasip2.rs │ │ │ │ └── xous.rs │ │ │ ├── alloc │ │ │ │ ├── windows │ │ │ │ │ └── tests.rs │ │ │ │ └── zkvm.rs │ │ │ ├── os_str │ │ │ │ ├── mod.rs │ │ │ │ └── bytes │ │ │ │ │ └── tests.rs │ │ │ ├── sync │ │ │ │ ├── mod.rs │ │ │ │ ├── thread_parking │ │ │ │ │ └── unsupported.rs │ │ │ │ └── condvar │ │ │ │ │ └── no_threads.rs │ │ │ ├── fd │ │ │ │ ├── unix │ │ │ │ │ └── tests.rs │ │ │ │ └── mod.rs │ │ │ ├── platform_version │ │ │ │ └── mod.rs │ │ │ ├── thread_local │ │ │ │ └── key │ │ │ │ │ └── sgx.rs │ │ │ ├── net │ │ │ │ └── connection │ │ │ │ │ └── socket │ │ │ │ │ └── tests.rs │ │ │ ├── personality │ │ │ │ └── dwarf │ │ │ │ │ └── tests.rs │ │ │ ├── path │ │ │ │ ├── sgx.rs │ │ │ │ ├── mod.rs │ │ │ │ └── unsupported_backslash.rs │ │ │ └── configure_builtins.rs │ │ ├── os │ │ │ ├── trusty │ │ │ │ ├── mod.rs │ │ │ │ └── io │ │ │ │ │ └── mod.rs │ │ │ ├── nto │ │ │ │ └── mod.rs │ │ │ ├── aix │ │ │ │ ├── mod.rs │ │ │ │ └── raw.rs │ │ │ ├── haiku │ │ │ │ └── mod.rs │ │ │ ├── nuttx │ │ │ │ └── mod.rs │ │ │ ├── redox │ │ │ │ └── mod.rs │ │ │ ├── rtems │ │ │ │ └── mod.rs │ │ │ ├── emscripten │ │ │ │ └── mod.rs │ │ │ ├── fuchsia │ │ │ │ └── mod.rs │ │ │ ├── openbsd │ │ │ │ └── mod.rs │ │ │ ├── dragonfly │ │ │ │ └── mod.rs │ │ │ ├── hermit │ │ │ │ ├── io │ │ │ │ │ └── mod.rs │ │ │ │ └── mod.rs │ │ │ ├── cygwin │ │ │ │ ├── mod.rs │ │ │ │ └── raw.rs │ │ │ ├── espidf │ │ │ │ └── mod.rs │ │ │ ├── android │ │ │ │ ├── mod.rs │ │ │ │ └── net.rs │ │ │ ├── freebsd │ │ │ │ └── mod.rs │ │ │ ├── illumos │ │ │ │ └── mod.rs │ │ │ ├── netbsd │ │ │ │ └── mod.rs │ │ │ ├── solaris │ │ │ │ └── mod.rs │ │ │ ├── l4re │ │ │ │ └── mod.rs │ │ │ ├── hurd │ │ │ │ └── mod.rs │ │ │ ├── vita │ │ │ │ └── mod.rs │ │ │ ├── vxworks │ │ │ │ ├── mod.rs │ │ │ │ └── raw.rs │ │ │ ├── horizon │ │ │ │ └── mod.rs │ │ │ ├── linux │ │ │ │ ├── mod.rs │ │ │ │ └── net.rs │ │ │ ├── uefi │ │ │ │ └── mod.rs │ │ │ ├── wasi │ │ │ │ ├── io │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── tests.rs │ │ │ │ ├── ffi.rs │ │ │ │ └── net │ │ │ │ │ └── mod.rs │ │ │ ├── wasip2 │ │ │ │ └── mod.rs │ │ │ ├── unix │ │ │ │ └── io │ │ │ │ │ └── tests.rs │ │ │ ├── net │ │ │ │ ├── mod.rs │ │ │ │ └── linux_ext │ │ │ │ │ └── mod.rs │ │ │ ├── raw │ │ │ │ ├── tests.rs │ │ │ │ └── mod.rs │ │ │ ├── windows │ │ │ │ └── raw.rs │ │ │ ├── xous │ │ │ │ └── mod.rs │ │ │ ├── solid │ │ │ │ └── mod.rs │ │ │ └── fd │ │ │ │ └── mod.rs │ │ ├── pat.rs │ │ ├── collections │ │ │ └── hash │ │ │ │ └── mod.rs │ │ ├── lib.miri.rs │ │ ├── bstr.rs │ │ ├── sys_common │ │ │ └── tests.rs │ │ ├── net │ │ │ ├── ip_addr │ │ │ │ └── tests.rs │ │ │ └── ip_addr.rs │ │ ├── io │ │ │ ├── prelude.rs │ │ │ └── pipe │ │ │ │ └── tests.rs │ │ ├── sync │ │ │ └── mpmc │ │ │ │ └── tests.rs │ │ └── ffi │ │ │ └── c_str.rs │ └── tests │ │ ├── thread_local │ │ └── lib.rs │ │ ├── win_delete_self.rs │ │ ├── slice-from-array-issue-113238.rs │ │ ├── volatile-fat-ptr.rs │ │ ├── windows.rs │ │ ├── seq-compare.rs │ │ └── log-knows-the-names-of-variants-in-std.rs ├── alloctests │ ├── benches │ │ └── btree │ │ │ └── mod.rs │ ├── tests │ │ ├── collections │ │ │ └── mod.rs │ │ ├── testing │ │ │ └── mod.rs │ │ ├── sort │ │ │ └── mod.rs │ │ ├── linked_list.rs │ │ ├── c_str.rs │ │ └── alloc_test.rs │ └── testing │ │ ├── mod.rs │ │ └── rng.rs ├── compiler-builtins │ ├── rust-version │ ├── josh-sync.toml │ ├── .rustfmt.toml │ ├── libm │ │ ├── src │ │ │ └── math │ │ │ │ ├── generic │ │ │ │ ├── fdim.rs │ │ │ │ ├── fabs.rs │ │ │ │ ├── copysign.rs │ │ │ │ ├── fmaximum.rs │ │ │ │ └── fminimum.rs │ │ │ │ ├── remainder.rs │ │ │ │ ├── remainderf.rs │ │ │ │ ├── tgammaf.rs │ │ │ │ ├── lgamma.rs │ │ │ │ ├── lgammaf.rs │ │ │ │ ├── k_expo2f.rs │ │ │ │ ├── ldexp.rs │ │ │ │ ├── expo2.rs │ │ │ │ ├── k_expo2.rs │ │ │ │ ├── frexp.rs │ │ │ │ ├── frexpf.rs │ │ │ │ └── ilogbf.rs │ │ └── build.rs │ ├── ci │ │ ├── docker │ │ │ ├── x86_64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── i586-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── i686-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── wasm32-unknown-unknown │ │ │ │ └── Dockerfile │ │ │ ├── thumbv6m-none-eabi │ │ │ │ └── Dockerfile │ │ │ ├── thumbv7em-none-eabi │ │ │ │ └── Dockerfile │ │ │ ├── thumbv7em-none-eabihf │ │ │ │ └── Dockerfile │ │ │ ├── thumbv7m-none-eabi │ │ │ │ └── Dockerfile │ │ │ ├── arm-unknown-linux-gnueabi │ │ │ │ └── Dockerfile │ │ │ ├── loongarch64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── arm-unknown-linux-gnueabihf │ │ │ │ └── Dockerfile │ │ │ ├── aarch64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── mips-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── mipsel-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── armv7-unknown-linux-gnueabihf │ │ │ │ └── Dockerfile │ │ │ ├── powerpc-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── riscv64gc-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── powerpc64-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── powerpc64le-unknown-linux-gnu │ │ │ │ └── Dockerfile │ │ │ ├── mips64el-unknown-linux-gnuabi64 │ │ │ │ └── Dockerfile │ │ │ └── mips64-unknown-linux-gnuabi64 │ │ │ │ └── Dockerfile │ │ ├── update-musl.sh │ │ ├── download-compiler-rt.sh │ │ ├── run-extensive.sh │ │ └── miri.sh │ ├── compiler-builtins │ │ └── src │ │ │ ├── lib.miri.rs │ │ │ ├── hexagon │ │ │ ├── func_macro.s │ │ │ ├── umodsi3.s │ │ │ └── udivsi3.s │ │ │ ├── float │ │ │ └── mod.rs │ │ │ ├── int │ │ │ ├── mod.rs │ │ │ └── bswap.rs │ │ │ └── aarch64.rs │ ├── crates │ │ ├── panic-handler │ │ │ ├── src │ │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ │ ├── symbol-check │ │ │ └── Cargo.toml │ │ ├── util │ │ │ └── build.rs │ │ ├── musl-math-sys │ │ │ └── Cargo.toml │ │ └── libm-macros │ │ │ └── Cargo.toml │ ├── libm-test │ │ ├── build.rs │ │ └── tests │ │ │ └── z_extensive │ │ │ └── main.rs │ ├── .git-blame-ignore-revs │ ├── .gitignore │ ├── builtins-test-intrinsics │ │ ├── build.rs │ │ └── Cargo.toml │ ├── .editorconfig │ ├── PUBLISHING.md │ ├── etc │ │ └── thumbv7em-none-eabi-renamed.json │ └── .github │ │ └── workflows │ │ └── publish.yaml ├── rustc-std-workspace-std │ ├── lib.rs │ ├── README.md │ └── Cargo.toml ├── sysroot │ └── src │ │ └── lib.rs ├── contracts │ └── safety │ │ ├── build.rs │ │ ├── Cargo.toml │ │ └── src │ │ └── runtime.rs ├── std_detect │ └── src │ │ └── detect │ │ ├── os │ │ ├── freebsd │ │ │ ├── aarch64.rs │ │ │ ├── mod.rs │ │ │ └── powerpc.rs │ │ └── other.rs │ │ ├── test_data │ │ ├── linux-rpi3.auxv │ │ ├── linux-hwcap2-aarch64.auxv │ │ ├── linux-no-hwcap2-aarch64.auxv │ │ ├── linux-artificial-aarch64.auxv │ │ ├── linux-empty-hwcap2-aarch64.auxv │ │ └── macos-virtualbox-linux-x86-4850HQ.auxv │ │ ├── bit.rs │ │ └── arch │ │ ├── mips.rs │ │ └── mips64.rs ├── core │ └── src │ │ ├── lib.miri.rs │ │ ├── ffi │ │ ├── c_schar.md │ │ ├── c_uchar.md │ │ ├── c_ushort.md │ │ ├── c_short.md │ │ ├── c_uint.md │ │ ├── c_int.md │ │ ├── c_ulong.md │ │ ├── c_float.md │ │ ├── c_ulonglong.md │ │ ├── c_long.md │ │ ├── c_longlong.md │ │ ├── c_double.md │ │ └── c_char.md │ │ ├── io │ │ └── mod.rs │ │ ├── sync │ │ └── mod.rs │ │ ├── slice │ │ ├── sort │ │ │ └── mod.rs │ │ └── specialize.rs │ │ ├── range │ │ └── legacy.rs │ │ ├── num │ │ ├── shells │ │ │ ├── i8.rs │ │ │ ├── u8.rs │ │ │ ├── i16.rs │ │ │ ├── i32.rs │ │ │ ├── i64.rs │ │ │ ├── u16.rs │ │ │ ├── u32.rs │ │ │ ├── u64.rs │ │ │ ├── isize.rs │ │ │ ├── usize.rs │ │ │ ├── i128.rs │ │ │ └── u128.rs │ │ ├── libm.rs │ │ └── flt2dec │ │ │ └── estimator.rs │ │ ├── fmt │ │ ├── fmt_trait_method_doc.md │ │ └── nofloat.rs │ │ └── task │ │ └── mod.rs ├── alloc │ └── src │ │ ├── lib.miri.rs │ │ └── collections │ │ ├── btree │ │ ├── mod.rs │ │ └── borrow │ │ │ └── tests.rs │ │ └── vec_deque │ │ └── macros.rs ├── test │ ├── src │ │ ├── helpers │ │ │ ├── mod.rs │ │ │ └── concurrency.rs │ │ └── term │ │ │ └── terminfo │ │ │ └── parser │ │ │ └── compiled │ │ │ └── tests.rs │ └── Cargo.toml ├── rustc-std-workspace-core │ ├── lib.rs │ └── Cargo.toml ├── rustc-std-workspace-alloc │ ├── lib.rs │ └── Cargo.toml ├── profiler_builtins │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── windows_targets │ └── Cargo.toml ├── panic_unwind │ ├── src │ │ ├── dummy.rs │ │ └── hermit.rs │ └── Cargo.toml ├── proc_macro │ └── Cargo.toml └── panic_abort │ └── Cargo.toml ├── .github ├── CODEOWNERS ├── dependabot.yml ├── ISSUE_TEMPLATE │ ├── tool_application.md │ └── tracking_issue.md ├── PULL_REQUEST_TEMPLATE.md ├── pull_requests.toml └── workflows │ └── testable-simd-models.yml ├── scripts ├── kani-std-analysis │ └── requirements.txt └── autoharness_analyzer │ └── Cargo.toml ├── verifast-proofs ├── .gitignore ├── alloc │ └── collections │ │ ├── linked_list.rs │ │ ├── original │ │ │ └── linked_list │ │ │ │ └── tests.rs │ │ └── verified │ │ │ └── linked_list │ │ │ └── tests.rs │ │ └── linked_list.rs-negative │ │ ├── original │ │ └── linked_list │ │ │ └── tests.rs │ │ └── verified │ │ └── linked_list │ │ └── tests.rs └── check-verifast-proofs-negative.sh ├── testable-simd-models ├── src │ ├── core_arch │ │ ├── x86 │ │ │ └── mod.rs │ │ └── arm_shared │ │ │ └── mod.rs │ └── core_arch.rs └── Cargo.toml ├── tool_config └── kani-version.toml ├── doc ├── mdbook-metrics │ └── Cargo.toml └── src │ └── challenges.md ├── rust-toolchain.toml └── .gitmodules /library/stdarch/.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /library/stdarch/rustfmt.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /library/coretests/tests/ffi.rs: -------------------------------------------------------------------------------- 1 | mod cstr; 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @model-checking/kani-devs 2 | -------------------------------------------------------------------------------- /library/coretests/benches/hash/mod.rs: -------------------------------------------------------------------------------- 1 | mod sip; 2 | -------------------------------------------------------------------------------- /library/coretests/tests/panic.rs: -------------------------------------------------------------------------------- 1 | mod location; 2 | -------------------------------------------------------------------------------- /library/coretests/benches/char/mod.rs: -------------------------------------------------------------------------------- 1 | mod methods; 2 | -------------------------------------------------------------------------------- /library/coretests/benches/net/mod.rs: -------------------------------------------------------------------------------- 1 | mod addr_parser; 2 | -------------------------------------------------------------------------------- /library/coretests/lib.rs: -------------------------------------------------------------------------------- 1 | // Intentionally left empty. 2 | -------------------------------------------------------------------------------- /library/coretests/tests/io/mod.rs: -------------------------------------------------------------------------------- 1 | mod borrowed_buf; 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/i8.rs: -------------------------------------------------------------------------------- 1 | int_module!(i8, u8); 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/u16.rs: -------------------------------------------------------------------------------- 1 | uint_module!(u16); 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/u32.rs: -------------------------------------------------------------------------------- 1 | uint_module!(u32); 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/u64.rs: -------------------------------------------------------------------------------- 1 | uint_module!(u64); 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/u8.rs: -------------------------------------------------------------------------------- 1 | uint_module!(u8); 2 | -------------------------------------------------------------------------------- /scripts/kani-std-analysis/requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/i16.rs: -------------------------------------------------------------------------------- 1 | int_module!(i16, u16); 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/i64.rs: -------------------------------------------------------------------------------- 1 | int_module!(i64, u64); 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/u128.rs: -------------------------------------------------------------------------------- 1 | uint_module!(u128); 2 | -------------------------------------------------------------------------------- /library/portable-simd/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | git-subtree.sh 3 | -------------------------------------------------------------------------------- /library/std/benches/hash/mod.rs: -------------------------------------------------------------------------------- 1 | mod map; 2 | mod set_ops; 3 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/unix/linux/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod pidfd; 2 | -------------------------------------------------------------------------------- /library/alloctests/benches/btree/mod.rs: -------------------------------------------------------------------------------- 1 | mod map; 2 | mod set; 3 | -------------------------------------------------------------------------------- /library/alloctests/tests/collections/mod.rs: -------------------------------------------------------------------------------- 1 | mod binary_heap; 2 | -------------------------------------------------------------------------------- /library/coretests/tests/num/i128.rs: -------------------------------------------------------------------------------- 1 | int_module!(i128, u128); 2 | -------------------------------------------------------------------------------- /verifast-proofs/.gitignore: -------------------------------------------------------------------------------- 1 | *.stripped.rs 2 | *.computed.diff 3 | -------------------------------------------------------------------------------- /library/stdarch/crates/stdarch-verify/.gitattributes: -------------------------------------------------------------------------------- 1 | *.xml binary 2 | -------------------------------------------------------------------------------- /library/stdarch/rust-version: -------------------------------------------------------------------------------- 1 | 32e7a4b92b109c24e9822c862a7c74436b50e564 2 | -------------------------------------------------------------------------------- /verifast-proofs/alloc/collections/linked_list.rs/original/linked_list/tests.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /verifast-proofs/alloc/collections/linked_list.rs/verified/linked_list/tests.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /library/compiler-builtins/rust-version: -------------------------------------------------------------------------------- 1 | d36f964125163c2e698de5559efefb8217b8b7f0 2 | -------------------------------------------------------------------------------- /library/portable-simd/Cross.toml: -------------------------------------------------------------------------------- 1 | [build.env] 2 | passthrough = ["PROPTEST_CASES"] 3 | -------------------------------------------------------------------------------- /verifast-proofs/alloc/collections/linked_list.rs-negative/original/linked_list/tests.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /verifast-proofs/alloc/collections/linked_list.rs-negative/verified/linked_list/tests.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /library/coretests/tests/str.rs: -------------------------------------------------------------------------------- 1 | // All `str` tests live in library/alloctests/tests/str.rs 2 | -------------------------------------------------------------------------------- /library/rustc-std-workspace-std/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(restricted_std)] 2 | pub use std::*; 3 | -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/rustfmt.toml: -------------------------------------------------------------------------------- 1 | ignore = [ 2 | "src/simd.rs", 3 | ] 4 | -------------------------------------------------------------------------------- /library/coretests/tests/wtf8.rs: -------------------------------------------------------------------------------- 1 | // All `wtf8` tests live in library/alloctests/tests/wtf8.rs 2 | -------------------------------------------------------------------------------- /library/stdarch/josh-sync.toml: -------------------------------------------------------------------------------- 1 | org = "rust-lang" 2 | repo = "stdarch" 3 | path = "library/stdarch" 4 | -------------------------------------------------------------------------------- /library/std/src/os/trusty/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "rust1", since = "1.0.0")] 2 | 3 | pub mod io; 4 | -------------------------------------------------------------------------------- /library/coretests/tests/iter/traits/mod.rs: -------------------------------------------------------------------------------- 1 | mod accum; 2 | mod double_ended; 3 | mod iterator; 4 | mod step; 5 | -------------------------------------------------------------------------------- /library/std/src/sys/io/is_terminal/unsupported.rs: -------------------------------------------------------------------------------- 1 | pub fn is_terminal(_: &T) -> bool { 2 | false 3 | } 4 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/mask_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | mod mask_ops_impl; 4 | -------------------------------------------------------------------------------- /library/std/src/pat.rs: -------------------------------------------------------------------------------- 1 | //! Helper module for exporting the `pattern_type` macro 2 | 3 | pub use core::pattern_type; 4 | -------------------------------------------------------------------------------- /library/std/src/os/nto/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "raw_ext", since = "1.1.0")] 2 | 3 | pub mod fs; 4 | pub(super) mod raw; 5 | -------------------------------------------------------------------------------- /library/sysroot/src/lib.rs: -------------------------------------------------------------------------------- 1 | // This is intentionally empty since this crate is only used to depend on other library crates. 2 | -------------------------------------------------------------------------------- /library/compiler-builtins/josh-sync.toml: -------------------------------------------------------------------------------- 1 | org = "rust-lang" 2 | repo = "compiler-builtins" 3 | path = "library/compiler-builtins" 4 | -------------------------------------------------------------------------------- /library/portable-simd/.github/ISSUE_TEMPLATE/blank_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Blank Issue 3 | about: Create a blank issue. 4 | --- 5 | -------------------------------------------------------------------------------- /library/std/src/collections/hash/mod.rs: -------------------------------------------------------------------------------- 1 | //! Unordered containers, implemented as hash-tables 2 | 3 | pub mod map; 4 | pub mod set; 5 | -------------------------------------------------------------------------------- /library/alloctests/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod crash_test; 2 | pub(crate) mod macros; 3 | pub(crate) mod ord_chaos; 4 | pub(crate) mod rng; 5 | -------------------------------------------------------------------------------- /library/portable-simd/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly-2025-01-16" 3 | components = ["rustfmt", "clippy", "miri", "rust-src"] 4 | -------------------------------------------------------------------------------- /library/rustc-std-workspace-std/README.md: -------------------------------------------------------------------------------- 1 | # The `rustc-std-workspace-std` crate 2 | 3 | See documentation for the `rustc-std-workspace-core` crate. 4 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/windows/stack_overflow_uwp.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr(test, allow(dead_code))] 2 | 3 | pub fn reserve_stack() {} 4 | pub fn init() {} 5 | -------------------------------------------------------------------------------- /library/stdarch/vendor.yml: -------------------------------------------------------------------------------- 1 | - crates/stdarch-verify/x86-intel.xml 2 | - crates/stdarch-verify/mips-msa.h 3 | - intrinsics_data/arm_intrinsics.json 4 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/i8_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_signed_tests! { i8 } 6 | -------------------------------------------------------------------------------- /testable-simd-models/src/core_arch/x86/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod models; 2 | #[cfg(test)] 3 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 4 | mod tests; 5 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/f32_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_float_tests! { f32, i32 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/f64_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_float_tests! { f64, i64 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/i16_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_signed_tests! { i16 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/i32_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_signed_tests! { i32 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/i64_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_signed_tests! { i64 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/isize_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_signed_tests! { isize } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/u16_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_unsigned_tests! { u16 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/u32_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_unsigned_tests! { u32 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/u64_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_unsigned_tests! { u64 } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/u8_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_unsigned_tests! { u8 } 6 | -------------------------------------------------------------------------------- /library/std/src/os/aix/mod.rs: -------------------------------------------------------------------------------- 1 | //! AIX specific definitions. 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/std/src/os/haiku/mod.rs: -------------------------------------------------------------------------------- 1 | //! Haiku-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/std/src/os/nuttx/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "raw_ext", since = "1.1.0")] 2 | #![forbid(unsafe_op_in_unsafe_fn)] 3 | pub mod fs; 4 | pub(crate) mod raw; 5 | -------------------------------------------------------------------------------- /library/std/src/os/redox/mod.rs: -------------------------------------------------------------------------------- 1 | //! Redox-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/std/src/os/rtems/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "raw_ext", since = "1.1.0")] 2 | #![forbid(unsafe_op_in_unsafe_fn)] 3 | pub mod fs; 4 | pub(crate) mod raw; 5 | -------------------------------------------------------------------------------- /testable-simd-models/src/core_arch.rs: -------------------------------------------------------------------------------- 1 | /// This is a (partial) mirror of [`core::arch`] 2 | pub mod x86; 3 | pub use x86 as x86_64; 4 | 5 | pub mod arm_shared; 6 | -------------------------------------------------------------------------------- /library/alloctests/tests/testing/mod.rs: -------------------------------------------------------------------------------- 1 | #[path = "../../testing/crash_test.rs"] 2 | pub mod crash_test; 3 | #[path = "../../testing/macros.rs"] 4 | pub mod macros; 5 | -------------------------------------------------------------------------------- /library/compiler-builtins/.rustfmt.toml: -------------------------------------------------------------------------------- 1 | # This matches rustc 2 | style_edition = "2024" 3 | group_imports = "StdExternalCrate" 4 | imports_granularity = "Module" 5 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/mask_ops_impl/mask64.rs: -------------------------------------------------------------------------------- 1 | mask_tests! { mask64x2, 2 } 2 | mask_tests! { mask64x4, 4 } 3 | mask_tests! { mask64x8, 8 } 4 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/mask_ops_impl/mask8.rs: -------------------------------------------------------------------------------- 1 | mask_tests! { mask8x8, 8 } 2 | mask_tests! { mask8x16, 16 } 3 | mask_tests! { mask8x32, 32 } 4 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/usize_ops.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[macro_use] 4 | mod ops_macros; 5 | impl_unsigned_tests! { usize } 6 | -------------------------------------------------------------------------------- /library/std/src/os/emscripten/mod.rs: -------------------------------------------------------------------------------- 1 | //! Linux-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/std/src/os/fuchsia/mod.rs: -------------------------------------------------------------------------------- 1 | //! Fuchsia-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/std/src/os/openbsd/mod.rs: -------------------------------------------------------------------------------- 1 | //! OpenBSD-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/contracts/safety/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | // We add the configurations here to be checked. 3 | println!("cargo:rustc-check-cfg=cfg(kani_host)"); 4 | } 5 | -------------------------------------------------------------------------------- /library/coretests/tests/unicode.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | pub fn version() { 3 | let (major, _minor, _update) = core::char::UNICODE_VERSION; 4 | assert!(major >= 10); 5 | } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/mask_ops_impl/masksize.rs: -------------------------------------------------------------------------------- 1 | mask_tests! { masksizex2, 2 } 2 | mask_tests! { masksizex4, 4 } 3 | mask_tests! { masksizex8, 8 } 4 | -------------------------------------------------------------------------------- /library/std/src/os/dragonfly/mod.rs: -------------------------------------------------------------------------------- 1 | //! Dragonfly-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/std/src/os/hermit/io/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "rust1", since = "1.0.0")] 2 | 3 | #[stable(feature = "rust1", since = "1.0.0")] 4 | pub use crate::os::fd::*; 5 | -------------------------------------------------------------------------------- /library/std/src/os/trusty/io/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "os_fd", since = "1.66.0")] 2 | 3 | #[stable(feature = "os_fd", since = "1.66.0")] 4 | pub use crate::os::fd::*; 5 | -------------------------------------------------------------------------------- /testable-simd-models/src/core_arch/arm_shared/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod models; 2 | #[cfg(test)] 3 | #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] 4 | pub mod tests; 5 | -------------------------------------------------------------------------------- /library/std/src/os/cygwin/mod.rs: -------------------------------------------------------------------------------- 1 | //! Cygwin-specific definitions 2 | #![stable(feature = "raw_ext", since = "1.1.0")] 3 | pub mod fs; 4 | pub mod net; 5 | pub(crate) mod raw; 6 | -------------------------------------------------------------------------------- /library/std/src/os/espidf/mod.rs: -------------------------------------------------------------------------------- 1 | //! Definitions for the ESP-IDF framework. 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod raw; 7 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/os/freebsd/aarch64.rs: -------------------------------------------------------------------------------- 1 | //! Run-time feature detection for Aarch64 on FreeBSD. 2 | 3 | pub(crate) use super::super::aarch64::detect_features; 4 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/test_data/linux-rpi3.auxv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/model-checking/verify-rust-std/HEAD/library/std_detect/src/detect/test_data/linux-rpi3.auxv -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/src/simd/cmp.rs: -------------------------------------------------------------------------------- 1 | //! Traits for comparing and ordering vectors. 2 | 3 | mod eq; 4 | mod ord; 5 | 6 | pub use eq::*; 7 | pub use ord::*; 8 | -------------------------------------------------------------------------------- /library/std/src/os/android/mod.rs: -------------------------------------------------------------------------------- 1 | //! Android-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod net; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std/src/os/freebsd/mod.rs: -------------------------------------------------------------------------------- 1 | //! FreeBSD-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod net; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std/src/os/illumos/mod.rs: -------------------------------------------------------------------------------- 1 | //! illumos-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod net; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std/src/os/netbsd/mod.rs: -------------------------------------------------------------------------------- 1 | //! OpenBSD-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod net; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std/src/os/solaris/mod.rs: -------------------------------------------------------------------------------- 1 | //! Solaris-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | pub mod fs; 6 | pub mod net; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std/src/sys/stdio/windows/tests.rs: -------------------------------------------------------------------------------- 1 | use super::utf16_to_utf8; 2 | 3 | #[test] 4 | fn zero_size_read() { 5 | assert_eq!(utf16_to_utf8(&[], &mut []).unwrap(), 0); 6 | } 7 | -------------------------------------------------------------------------------- /library/std/src/lib.miri.rs: -------------------------------------------------------------------------------- 1 | //! Grep bootstrap for `MIRI_REPLACE_LIBRS_IF_NOT_TEST` to learn what this is about. 2 | #![no_std] 3 | extern crate std as realstd; 4 | pub use realstd::*; 5 | -------------------------------------------------------------------------------- /library/core/src/lib.miri.rs: -------------------------------------------------------------------------------- 1 | //! Grep bootstrap for `MIRI_REPLACE_LIBRS_IF_NOT_TEST` to learn what this is about. 2 | #![no_std] 3 | extern crate core as realcore; 4 | pub use realcore::*; 5 | -------------------------------------------------------------------------------- /library/std/tests/thread_local/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(cfg_target_thread_local)] 2 | 3 | #[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] 4 | mod tests; 5 | 6 | mod dynamic_tests; 7 | -------------------------------------------------------------------------------- /library/alloc/src/lib.miri.rs: -------------------------------------------------------------------------------- 1 | //! Grep bootstrap for `MIRI_REPLACE_LIBRS_IF_NOT_TEST` to learn what this is about. 2 | #![no_std] 3 | extern crate alloc as realalloc; 4 | pub use realalloc::*; 5 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/mask_ops_impl/mask32.rs: -------------------------------------------------------------------------------- 1 | mask_tests! { mask32x2, 2 } 2 | mask_tests! { mask32x4, 4 } 3 | mask_tests! { mask32x8, 8 } 4 | mask_tests! { mask32x16, 16 } 5 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/webdriver.json: -------------------------------------------------------------------------------- 1 | { 2 | "goog:chromeOptions": { 3 | "args": [ 4 | "--enable-features=WebAssemblySimd" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /library/std/src/os/l4re/mod.rs: -------------------------------------------------------------------------------- 1 | //! L4Re-specific definitions. 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | #![doc(cfg(target_os = "l4re"))] 5 | 6 | pub mod fs; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/test_data/linux-hwcap2-aarch64.auxv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/model-checking/verify-rust-std/HEAD/library/std_detect/src/detect/test_data/linux-hwcap2-aarch64.auxv -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/generic/fdim.rs: -------------------------------------------------------------------------------- 1 | use crate::support::Float; 2 | 3 | #[inline] 4 | pub fn fdim(x: F, y: F) -> F { 5 | if x <= y { F::ZERO } else { x - y } 6 | } 7 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/mask_ops_impl/mask16.rs: -------------------------------------------------------------------------------- 1 | mask_tests! { mask16x4, 4 } 2 | mask_tests! { mask16x8, 8 } 3 | mask_tests! { mask16x16, 16 } 4 | mask_tests! { mask16x32, 32 } 5 | -------------------------------------------------------------------------------- /library/std/src/bstr.rs: -------------------------------------------------------------------------------- 1 | //! The `ByteStr` and `ByteString` types and trait implementations. 2 | 3 | #[unstable(feature = "bstr", issue = "134915")] 4 | pub use alloc::bstr::{ByteStr, ByteString}; 5 | -------------------------------------------------------------------------------- /library/std/src/os/hurd/mod.rs: -------------------------------------------------------------------------------- 1 | //! Hurd-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | #![forbid(unsafe_op_in_unsafe_fn)] 5 | 6 | pub mod fs; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std/src/os/vita/mod.rs: -------------------------------------------------------------------------------- 1 | //! Definitions for vita 2 | 3 | #![forbid(unsafe_op_in_unsafe_fn)] 4 | #![stable(feature = "raw_ext", since = "1.1.0")] 5 | 6 | pub mod fs; 7 | pub(crate) mod raw; 8 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/test_data/linux-no-hwcap2-aarch64.auxv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/model-checking/verify-rust-std/HEAD/library/std_detect/src/detect/test_data/linux-no-hwcap2-aarch64.auxv -------------------------------------------------------------------------------- /library/stdarch/ci/docker/nvptx64-nvidia-cuda/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | gcc \ 4 | libc6-dev \ 5 | ca-certificates 6 | -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/riscv32/mod.rs: -------------------------------------------------------------------------------- 1 | //! RISC-V RV32 specific intrinsics 2 | 3 | mod zk; 4 | 5 | #[unstable(feature = "riscv_ext_intrinsics", issue = "114544")] 6 | pub use zk::*; 7 | -------------------------------------------------------------------------------- /library/std/src/os/vxworks/mod.rs: -------------------------------------------------------------------------------- 1 | //! VxWorks-specific definitions 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | #![forbid(unsafe_op_in_unsafe_fn)] 5 | 6 | pub mod fs; 7 | pub mod raw; 8 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/test_data/linux-artificial-aarch64.auxv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/model-checking/verify-rust-std/HEAD/library/std_detect/src/detect/test_data/linux-artificial-aarch64.auxv -------------------------------------------------------------------------------- /library/std_detect/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/model-checking/verify-rust-std/HEAD/library/std_detect/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv -------------------------------------------------------------------------------- /library/std/benches/lib.rs: -------------------------------------------------------------------------------- 1 | // Disabling in Miri as these would take too long. 2 | #![cfg(not(miri))] 3 | #![feature(test)] 4 | 5 | extern crate test; 6 | 7 | mod hash; 8 | mod path; 9 | mod time; 10 | -------------------------------------------------------------------------------- /library/std/src/os/horizon/mod.rs: -------------------------------------------------------------------------------- 1 | //! Definitions for Horizon OS 2 | 3 | #![forbid(unsafe_op_in_unsafe_fn)] 4 | #![stable(feature = "raw_ext", since = "1.1.0")] 5 | 6 | pub mod fs; 7 | pub(crate) mod raw; 8 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/unsupported/mod.rs: -------------------------------------------------------------------------------- 1 | #![deny(unsafe_op_in_unsafe_fn)] 2 | 3 | pub mod os; 4 | pub mod pipe; 5 | pub mod thread; 6 | pub mod time; 7 | 8 | mod common; 9 | pub use common::*; 10 | -------------------------------------------------------------------------------- /library/std/src/sys_common/tests.rs: -------------------------------------------------------------------------------- 1 | use super::mul_div_u64; 2 | 3 | #[test] 4 | fn test_muldiv() { 5 | assert_eq!(mul_div_u64(1_000_000_000_001, 1_000_000_000, 1_000_000), 1_000_000_000_001_000); 6 | } 7 | -------------------------------------------------------------------------------- /library/std/src/sys/io/is_terminal/hermit.rs: -------------------------------------------------------------------------------- 1 | use crate::os::fd::{AsFd, AsRawFd}; 2 | 3 | pub fn is_terminal(fd: &impl AsFd) -> bool { 4 | let fd = fd.as_fd(); 5 | hermit_abi::isatty(fd.as_raw_fd()) 6 | } 7 | -------------------------------------------------------------------------------- /library/std/src/sys/random/wasip1.rs: -------------------------------------------------------------------------------- 1 | pub fn fill_bytes(bytes: &mut [u8]) { 2 | unsafe { 3 | wasi::random_get(bytes.as_mut_ptr(), bytes.len()).expect("failed to generate random data") 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/remainder.rs: -------------------------------------------------------------------------------- 1 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 2 | pub fn remainder(x: f64, y: f64) -> f64 { 3 | let (result, _) = super::remquo(x, y); 4 | result 5 | } 6 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/remainderf.rs: -------------------------------------------------------------------------------- 1 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 2 | pub fn remainderf(x: f32, y: f32) -> f32 { 3 | let (result, _) = super::remquof(x, y); 4 | result 5 | } 6 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/mask_ops_impl/mod.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod mask_macros; 3 | 4 | #[rustfmt::skip] 5 | mod mask8; 6 | mod mask16; 7 | mod mask32; 8 | mod mask64; 9 | mod masksize; 10 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/model-checking/verify-rust-std/HEAD/library/std_detect/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/s390x/mod.rs: -------------------------------------------------------------------------------- 1 | //! `s390x` intrinsics 2 | 3 | pub(crate) mod macros; 4 | 5 | mod vector; 6 | #[unstable(feature = "stdarch_s390x", issue = "130869")] 7 | pub use self::vector::*; 8 | -------------------------------------------------------------------------------- /library/test/src/helpers/mod.rs: -------------------------------------------------------------------------------- 1 | //! Module with common helpers not directly related to tests 2 | //! but used in `libtest`. 3 | 4 | pub(crate) mod concurrency; 5 | pub(crate) mod metrics; 6 | pub(crate) mod shuffle; 7 | -------------------------------------------------------------------------------- /library/std/src/sys/io/is_terminal/isatty.rs: -------------------------------------------------------------------------------- 1 | use crate::os::fd::{AsFd, AsRawFd}; 2 | 3 | pub fn is_terminal(fd: &impl AsFd) -> bool { 4 | let fd = fd.as_fd(); 5 | unsafe { libc::isatty(fd.as_raw_fd()) != 0 } 6 | } 7 | -------------------------------------------------------------------------------- /library/std/src/os/cygwin/raw.rs: -------------------------------------------------------------------------------- 1 | //! Cygwin-specific raw type definitions. 2 | 3 | #[stable(feature = "raw_ext", since = "1.1.0")] 4 | pub use libc::{blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t, pthread_t, time_t}; 5 | -------------------------------------------------------------------------------- /library/std/src/sys/anonymous_pipe/unsupported.rs: -------------------------------------------------------------------------------- 1 | use crate::io; 2 | pub use crate::sys::pipe::AnonPipe; 3 | 4 | #[inline] 5 | pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> { 6 | Err(io::Error::UNSUPPORTED_PLATFORM) 7 | } 8 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/os/other.rs: -------------------------------------------------------------------------------- 1 | //! Other operating systems 2 | 3 | use crate::detect::cache; 4 | 5 | #[allow(dead_code)] 6 | pub(crate) fn detect_features() -> cache::Initializer { 7 | cache::Initializer::default() 8 | } 9 | -------------------------------------------------------------------------------- /library/stdarch/.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Use `git config blame.ignorerevsfile .git-blame-ignore-revs` to make `git blame` ignore the following commits. 2 | 3 | # format with style edition 2024 4 | fc87bd98d689590a0b6f5ee4110c5b9f962faa66 5 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/i586-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | gcc-multilib \ 4 | libc6-dev \ 5 | file \ 6 | make \ 7 | ca-certificates 8 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/i686-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | gcc-multilib \ 4 | libc6-dev \ 5 | file \ 6 | make \ 7 | ca-certificates 8 | -------------------------------------------------------------------------------- /tool_config/kani-version.toml: -------------------------------------------------------------------------------- 1 | # This version should be updated whenever there is a change that makes this version of kani 2 | # incompatible with the verify-std repo. 3 | 4 | [kani] 5 | commit = "54bb431831f931b372028fed50708b82f59c6c68" 6 | -------------------------------------------------------------------------------- /doc/mdbook-metrics/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mdbook-kani-metrics" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | mdbook = { version = "^0.4" } 8 | mdbook-linkcheck = "0.7.7" 9 | serde_json = "1.0.132" 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/x86_64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc m4 make libc6-dev ca-certificates 7 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_schar.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `signed char` type. 2 | 3 | This type will always be [`i8`], but is included for completeness. It is defined as being a signed integer the same size as a C [`char`]. 4 | 5 | [`char`]: c_char 6 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/i586-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc-multilib m4 make libc6-dev ca-certificates 7 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/i686-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc-multilib m4 make libc6-dev ca-certificates 7 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_uchar.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `unsigned char` type. 2 | 3 | This type will always be [`u8`], but is included for completeness. It is defined as being an unsigned integer the same size as a C [`char`]. 4 | 5 | [`char`]: c_char 6 | -------------------------------------------------------------------------------- /library/std/src/os/linux/mod.rs: -------------------------------------------------------------------------------- 1 | //! Linux-specific definitions. 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | #![doc(cfg(target_os = "linux"))] 5 | 6 | pub mod fs; 7 | pub mod net; 8 | pub mod process; 9 | pub mod raw; 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/generic/fabs.rs: -------------------------------------------------------------------------------- 1 | use crate::support::Float; 2 | 3 | /// Absolute value. 4 | #[inline] 5 | pub fn fabs(x: F) -> F { 6 | let abs_mask = !F::SIGN_MASK; 7 | F::from_bits(x.to_bits() & abs_mask) 8 | } 9 | -------------------------------------------------------------------------------- /library/coretests/tests/num/nan.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn test_nan() { 3 | let x = "NaN".to_string(); 4 | assert_eq!(format!("{}", f64::NAN), x); 5 | assert_eq!(format!("{:e}", f64::NAN), x); 6 | assert_eq!(format!("{:E}", f64::NAN), x); 7 | } 8 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/src/simd/ptr.rs: -------------------------------------------------------------------------------- 1 | //! Traits for vectors of pointers. 2 | 3 | mod const_ptr; 4 | mod mut_ptr; 5 | 6 | mod sealed { 7 | pub trait Sealed {} 8 | } 9 | 10 | pub use const_ptr::*; 11 | pub use mut_ptr::*; 12 | -------------------------------------------------------------------------------- /library/std/src/sys/args/wasip2.rs: -------------------------------------------------------------------------------- 1 | pub use super::common::Args; 2 | 3 | /// Returns the command line arguments 4 | pub fn args() -> Args { 5 | Args::new(wasip2::cli::environment::get_arguments().into_iter().map(|arg| arg.into()).collect()) 6 | } 7 | -------------------------------------------------------------------------------- /library/stdarch/.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | target 3 | tags 4 | crates/stdarch-gen-arm/aarch64.rs 5 | crates/stdarch-gen-arm/arm.rs 6 | crates/stdarch-gen-loongarch/lasx.c 7 | crates/stdarch-gen-loongarch/lsx.c 8 | c_programs/* 9 | rust_programs/* 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/lib.miri.rs: -------------------------------------------------------------------------------- 1 | //! Grep bootstrap for `MIRI_REPLACE_LIBRS_IF_NOT_TEST` to learn what this is about. 2 | #![no_std] 3 | #![feature(rustc_private)] 4 | extern crate compiler_builtins as real; 5 | pub use real::*; 6 | -------------------------------------------------------------------------------- /library/core/src/io/mod.rs: -------------------------------------------------------------------------------- 1 | //! Traits, helpers, and type definitions for core I/O functionality. 2 | 3 | mod borrowed_buf; 4 | 5 | #[unstable(feature = "core_io_borrowed_buf", issue = "117693")] 6 | pub use self::borrowed_buf::{BorrowedBuf, BorrowedCursor}; 7 | -------------------------------------------------------------------------------- /library/core/src/sync/mod.rs: -------------------------------------------------------------------------------- 1 | //! Synchronization primitives 2 | 3 | #![stable(feature = "rust1", since = "1.0.0")] 4 | 5 | pub mod atomic; 6 | mod exclusive; 7 | #[unstable(feature = "exclusive_wrapper", issue = "98407")] 8 | pub use exclusive::Exclusive; 9 | -------------------------------------------------------------------------------- /library/portable-simd/crates/test_helpers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test_helpers" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | proptest = { version = "0.10", default-features = false, features = ["alloc"] } 9 | -------------------------------------------------------------------------------- /library/compiler-builtins/crates/panic-handler/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This is needed for tests on targets that require a `#[panic_handler]` function 2 | 3 | #![no_std] 4 | 5 | #[panic_handler] 6 | fn panic(_: &core::panic::PanicInfo<'_>) -> ! { 7 | loop {} 8 | } 9 | -------------------------------------------------------------------------------- /library/std/src/net/ip_addr/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::net::Ipv4Addr; 2 | use crate::net::test::{sa4, tsa}; 3 | 4 | #[test] 5 | fn to_socket_addr_socketaddr() { 6 | let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 12345); 7 | assert_eq!(Ok(vec![a]), tsa(a)); 8 | } 9 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | # This version should be updated whenever we update the version of the Rust 2 | # standard library we currently track. 3 | 4 | [toolchain] 5 | channel = "nightly-2025-09-09" 6 | components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"] 7 | -------------------------------------------------------------------------------- /library/rustc-std-workspace-core/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(no_core)] 2 | #![no_core] 3 | 4 | pub use core::*; 5 | 6 | // Crate must be brought into scope so it appears in the crate graph for anything that 7 | // depends on `rustc-std-workspace-core`. 8 | use compiler_builtins as _; 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "library/stdarch"] 2 | path = library/stdarch 3 | url = https://github.com/rust-lang/stdarch.git 4 | shallow = true 5 | [submodule "library/backtrace"] 6 | path = library/backtrace 7 | url = https://github.com/rust-lang/backtrace-rs.git 8 | shallow = true 9 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/hexagon/func_macro.s: -------------------------------------------------------------------------------- 1 | .macro FUNCTION_BEGIN name 2 | .text 3 | .p2align 5 4 | .globl \name 5 | .type \name, @function 6 | \name: 7 | .endm 8 | 9 | .macro FUNCTION_END name 10 | .size \name, . - \name 11 | .endm 12 | 13 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/tgammaf.rs: -------------------------------------------------------------------------------- 1 | use super::tgamma; 2 | 3 | /// The [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f32). 4 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 5 | pub fn tgammaf(x: f32) -> f32 { 6 | tgamma(x as f64) as f32 7 | } 8 | -------------------------------------------------------------------------------- /library/test/src/term/terminfo/parser/compiled/tests.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | 3 | #[test] 4 | fn test_veclens() { 5 | assert_eq!(boolfnames.len(), boolnames.len()); 6 | assert_eq!(numfnames.len(), numnames.len()); 7 | assert_eq!(stringfnames.len(), stringnames.len()); 8 | } 9 | -------------------------------------------------------------------------------- /library/compiler-builtins/crates/symbol-check/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "symbol-check" 3 | version = "0.1.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | object = "0.37.1" 9 | serde_json = "1.0.140" 10 | 11 | [features] 12 | wasm = ["object/wasm"] 13 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/src/simd/num.rs: -------------------------------------------------------------------------------- 1 | //! Traits for vectors with numeric elements. 2 | 3 | mod float; 4 | mod int; 5 | mod uint; 6 | 7 | mod sealed { 8 | pub trait Sealed {} 9 | } 10 | 11 | pub use float::*; 12 | pub use int::*; 13 | pub use uint::*; 14 | -------------------------------------------------------------------------------- /library/std/src/sys/alloc/windows/tests.rs: -------------------------------------------------------------------------------- 1 | use super::{Header, MIN_ALIGN}; 2 | 3 | #[test] 4 | fn alloc_header() { 5 | // Header must fit in the padding before an aligned pointer 6 | assert!(size_of::
() <= MIN_ALIGN); 7 | assert!(align_of::
() <= MIN_ALIGN); 8 | } 9 | -------------------------------------------------------------------------------- /library/std/src/sys/random/espidf.rs: -------------------------------------------------------------------------------- 1 | use crate::ffi::c_void; 2 | 3 | unsafe extern "C" { 4 | fn esp_fill_random(buf: *mut c_void, len: usize); 5 | } 6 | 7 | pub fn fill_bytes(bytes: &mut [u8]) { 8 | unsafe { esp_fill_random(bytes.as_mut_ptr().cast(), bytes.len()) } 9 | } 10 | -------------------------------------------------------------------------------- /library/std/src/sys/random/teeos.rs: -------------------------------------------------------------------------------- 1 | unsafe extern "C" { 2 | fn TEE_GenerateRandom(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t); 3 | } 4 | 5 | pub fn fill_bytes(bytes: &mut [u8]) { 6 | unsafe { TEE_GenerateRandom(bytes.as_mut_ptr().cast(), bytes.len()) } 7 | } 8 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/wasm32-unknown-unknown/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:20.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc clang libc6-dev ca-certificates 7 | 8 | ENV CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=true 9 | -------------------------------------------------------------------------------- /library/rustc-std-workspace-alloc/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(no_core)] 2 | #![no_core] 3 | 4 | // See rustc-std-workspace-core for why this crate is needed. 5 | 6 | // Rename the crate to avoid conflicting with the alloc module in alloc. 7 | extern crate alloc as foo; 8 | 9 | pub use foo::*; 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: "github-actions" 6 | directory: "/" 7 | schedule: 8 | interval: "weekly" 9 | -------------------------------------------------------------------------------- /library/alloc/src/collections/btree/mod.rs: -------------------------------------------------------------------------------- 1 | mod append; 2 | mod borrow; 3 | mod dedup_sorted_iter; 4 | mod fix; 5 | pub(super) mod map; 6 | mod mem; 7 | mod merge_iter; 8 | mod navigate; 9 | mod node; 10 | mod remove; 11 | mod search; 12 | pub(super) mod set; 13 | mod set_val; 14 | mod split; 15 | -------------------------------------------------------------------------------- /library/compiler-builtins/crates/panic-handler/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "panic-handler" 3 | version = "0.1.0" 4 | authors = ["Alex Crichton "] 5 | edition = "2024" 6 | publish = false 7 | 8 | [lib] 9 | test = false 10 | bench = false 11 | 12 | [dependencies] 13 | -------------------------------------------------------------------------------- /library/portable-simd/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "1" 3 | members = [ 4 | "crates/core_simd", 5 | "crates/std_float", 6 | "crates/test_helpers", 7 | ] 8 | 9 | [profile.test.package."*"] 10 | opt-level = 2 11 | 12 | [profile.test.package.test_helpers] 13 | opt-level = 2 14 | -------------------------------------------------------------------------------- /library/std/src/os/uefi/mod.rs: -------------------------------------------------------------------------------- 1 | //! Platform-specific extensions to `std` for UEFI. 2 | 3 | #![unstable(feature = "uefi_std", issue = "100499")] 4 | #![doc(cfg(target_os = "uefi"))] 5 | #![forbid(unsafe_op_in_unsafe_fn)] 6 | 7 | pub mod env; 8 | #[path = "../windows/ffi.rs"] 9 | pub mod ffi; 10 | -------------------------------------------------------------------------------- /library/std/src/sys/random/solid.rs: -------------------------------------------------------------------------------- 1 | use crate::sys::pal::abi; 2 | 3 | pub fn fill_bytes(bytes: &mut [u8]) { 4 | unsafe { 5 | let result = abi::SOLID_RNG_SampleRandomBytes(bytes.as_mut_ptr(), bytes.len()); 6 | assert_eq!(result, 0, "failed to generate random data"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /library/std/src/sys/random/trusty.rs: -------------------------------------------------------------------------------- 1 | unsafe extern "C" { 2 | fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t); 3 | } 4 | 5 | pub fn fill_bytes(bytes: &mut [u8]) { 6 | unsafe { trusty_rng_secure_rand(bytes.as_mut_ptr().cast(), bytes.len()) } 7 | } 8 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm-test/build.rs: -------------------------------------------------------------------------------- 1 | #[path = "../libm/configure.rs"] 2 | mod configure; 3 | use configure::Config; 4 | 5 | fn main() { 6 | println!("cargo:rerun-if-changed=../libm/configure.rs"); 7 | let cfg = Config::from_env(); 8 | configure::emit_test_config(&cfg); 9 | } 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/lgamma.rs: -------------------------------------------------------------------------------- 1 | use super::lgamma_r; 2 | 3 | /// The natural logarithm of the 4 | /// [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f64). 5 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 6 | pub fn lgamma(x: f64) -> f64 { 7 | lgamma_r(x).0 8 | } 9 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_ushort.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `unsigned short` type. 2 | 3 | This type will almost always be [`u16`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as a [`short`]. 4 | 5 | [`short`]: c_short 6 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/bit.rs: -------------------------------------------------------------------------------- 1 | //! Bit manipulation utilities. 2 | 3 | /// Tests the `bit` of `x`. 4 | #[allow(dead_code)] 5 | #[inline] 6 | pub(crate) fn test(x: usize, bit: u32) -> bool { 7 | debug_assert!(bit < usize::BITS, "bit index out-of-bounds"); 8 | x & (1 << bit) != 0 9 | } 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/lgammaf.rs: -------------------------------------------------------------------------------- 1 | use super::lgammaf_r; 2 | 3 | /// The natural logarithm of the 4 | /// [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f32). 5 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 6 | pub fn lgammaf(x: f32) -> f32 { 7 | lgammaf_r(x).0 8 | } 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/tool_application.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Tool Application 3 | about: Submit a new tool application 4 | title: "[Tool Application] " 5 | labels: Tool Application 6 | --- 7 | 8 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/thumbv6m-none-eabi/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-arm-none-eabi \ 8 | libnewlib-arm-none-eabi 9 | ENV BUILD_ONLY=1 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/thumbv7em-none-eabi/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-arm-none-eabi \ 8 | libnewlib-arm-none-eabi 9 | ENV BUILD_ONLY=1 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/thumbv7em-none-eabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-arm-none-eabi \ 8 | libnewlib-arm-none-eabi 9 | ENV BUILD_ONLY=1 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/thumbv7m-none-eabi/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-arm-none-eabi \ 8 | libnewlib-arm-none-eabi 9 | ENV BUILD_ONLY=1 10 | -------------------------------------------------------------------------------- /library/coretests/benches/str.rs: -------------------------------------------------------------------------------- 1 | use std::str; 2 | 3 | use test::{Bencher, black_box}; 4 | 5 | mod char_count; 6 | mod corpora; 7 | mod debug; 8 | mod iter; 9 | 10 | #[bench] 11 | fn str_validate_emoji(b: &mut Bencher) { 12 | b.iter(|| str::from_utf8(black_box(corpora::emoji::LARGE.as_bytes()))); 13 | } 14 | -------------------------------------------------------------------------------- /library/std/src/os/wasi/io/mod.rs: -------------------------------------------------------------------------------- 1 | //! WASI-specific extensions to general I/O primitives. 2 | 3 | #![stable(feature = "io_safety_wasi", since = "1.65.0")] 4 | 5 | #[stable(feature = "io_safety_wasi", since = "1.65.0")] 6 | pub use crate::os::fd::*; 7 | 8 | // Tests for this module 9 | #[cfg(test)] 10 | mod tests; 11 | -------------------------------------------------------------------------------- /library/compiler-builtins/.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Use `git config blame.ignorerevsfile .git-blame-ignore-revs` to make 2 | # `git blame` ignore the following commits. 3 | 4 | # Reformat with a new `.rustfmt.toml` 5 | # In rust-lang/libm this was 5882cabb83c30bf7c36023f9a55a80583636b0e8 6 | 4bb07a6275cc628ef81c65ac971dc6479963322f 7 | -------------------------------------------------------------------------------- /library/compiler-builtins/.gitignore: -------------------------------------------------------------------------------- 1 | # Rust files 2 | Cargo.lock 3 | target 4 | 5 | # Sources for external files 6 | compiler-rt 7 | *.tar.gz 8 | 9 | # Benchmark cache 10 | baseline-* 11 | iai-home 12 | 13 | # Temporary files 14 | *.bk 15 | *.rs.bk 16 | .#* 17 | 18 | # Manually managed 19 | crates/musl-math-sys/musl 20 | -------------------------------------------------------------------------------- /library/core/src/slice/sort/mod.rs: -------------------------------------------------------------------------------- 1 | //! This module and the contained sub-modules contains the code for efficient and robust sort 2 | //! implementations, as well as the domain adjacent implementation of `select_nth_unstable`. 3 | 4 | pub mod stable; 5 | pub mod unstable; 6 | 7 | pub(crate) mod select; 8 | pub(crate) mod shared; 9 | -------------------------------------------------------------------------------- /library/coretests/tests/simd.rs: -------------------------------------------------------------------------------- 1 | use core::simd::prelude::*; 2 | 3 | #[test] 4 | fn testing() { 5 | let x = f32x4::from_array([1.0, 1.0, 1.0, 1.0]); 6 | let y = -x; 7 | 8 | let h = x * f32x4::splat(0.5); 9 | 10 | let r = y.abs(); 11 | assert_eq!(x, r); 12 | assert_eq!(h, f32x4::splat(0.5)); 13 | } 14 | -------------------------------------------------------------------------------- /library/profiler_builtins/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "profiler_builtins" 3 | version = "0.0.0" 4 | edition = "2024" 5 | 6 | [lib] 7 | test = false 8 | bench = false 9 | doc = false 10 | 11 | [dependencies] 12 | 13 | [build-dependencies] 14 | # Pinned so `cargo update` bumps don't cause breakage 15 | cc = "=1.2.0" 16 | -------------------------------------------------------------------------------- /library/std/src/sys/os_str/mod.rs: -------------------------------------------------------------------------------- 1 | #![forbid(unsafe_op_in_unsafe_fn)] 2 | 3 | cfg_select! { 4 | any(target_os = "windows", target_os = "uefi") => { 5 | mod wtf8; 6 | pub use wtf8::{Buf, Slice}; 7 | } 8 | _ => { 9 | mod bytes; 10 | pub use bytes::{Buf, Slice}; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/std/src/sys/random/getrandom.rs: -------------------------------------------------------------------------------- 1 | pub fn fill_bytes(mut bytes: &mut [u8]) { 2 | while !bytes.is_empty() { 3 | let r = unsafe { libc::getrandom(bytes.as_mut_ptr().cast(), bytes.len(), 0) }; 4 | assert_ne!(r, -1, "failed to generate random data"); 5 | bytes = &mut bytes[r as usize..]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /library/compiler-builtins/crates/util/build.rs: -------------------------------------------------------------------------------- 1 | #![allow(unexpected_cfgs)] 2 | 3 | #[path = "../../libm/configure.rs"] 4 | mod configure; 5 | 6 | fn main() { 7 | println!("cargo:rerun-if-changed=../../libm/configure.rs"); 8 | let cfg = configure::Config::from_env(); 9 | configure::emit_libm_config(&cfg); 10 | } 11 | -------------------------------------------------------------------------------- /library/std/src/sys/random/hermit.rs: -------------------------------------------------------------------------------- 1 | pub fn fill_bytes(mut bytes: &mut [u8]) { 2 | while !bytes.is_empty() { 3 | let res = unsafe { hermit_abi::read_entropy(bytes.as_mut_ptr(), bytes.len(), 0) }; 4 | assert_ne!(res, -1, "failed to generate random data"); 5 | bytes = &mut bytes[res as usize..]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /library/std/src/sys/random/wasip2.rs: -------------------------------------------------------------------------------- 1 | pub fn fill_bytes(bytes: &mut [u8]) { 2 | bytes.copy_from_slice(&wasip2::random::random::get_random_bytes( 3 | u64::try_from(bytes.len()).unwrap(), 4 | )); 5 | } 6 | 7 | pub fn hashmap_random_keys() -> (u64, u64) { 8 | wasip2::random::insecure_seed::insecure_seed() 9 | } 10 | -------------------------------------------------------------------------------- /library/compiler-builtins/crates/musl-math-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "musl-math-sys" 3 | version = "0.1.0" 4 | edition = "2024" 5 | publish = false 6 | license = "MIT OR Apache-2.0" 7 | 8 | [dependencies] 9 | 10 | [dev-dependencies] 11 | libm = { path = "../../libm" } 12 | 13 | [build-dependencies] 14 | cc = "1.2.29" 15 | -------------------------------------------------------------------------------- /library/contracts/safety/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "safety" 3 | version = "0.1.0" 4 | edition = "2021" 5 | license = "MIT OR Apache-2.0" 6 | 7 | [lib] 8 | proc-macro = true 9 | 10 | [dependencies] 11 | proc-macro2 = "1.0" 12 | proc-macro-error = "1.0.4" 13 | quote = "1.0.20" 14 | syn = { version = "2.0.18", features = ["full"] } 15 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_short.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `signed short` (`short`) type. 2 | 3 | This type will almost always be [`i16`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer with at least 16 bits; some systems may define it as `i32`, for example. 4 | 5 | [`char`]: c_char 6 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_uint.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `unsigned int` type. 2 | 3 | This type will almost always be [`u32`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as an [`int`]; some systems define it as a [`u16`], for example. 4 | 5 | [`int`]: c_int 6 | -------------------------------------------------------------------------------- /library/std/src/os/aix/raw.rs: -------------------------------------------------------------------------------- 1 | //! AIX specific raw type definitions. 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | #[stable(feature = "pthread_t", since = "1.8.0")] 6 | pub use libc::pthread_t; 7 | #[stable(feature = "raw_ext", since = "1.1.0")] 8 | pub use libc::{blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t, stat, time_t}; 9 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/generic/copysign.rs: -------------------------------------------------------------------------------- 1 | use crate::support::Float; 2 | 3 | /// Copy the sign of `y` to `x`. 4 | #[inline] 5 | pub fn copysign(x: F, y: F) -> F { 6 | let mut ux = x.to_bits(); 7 | let uy = y.to_bits(); 8 | ux &= !F::SIGN_MASK; 9 | ux |= uy & F::SIGN_MASK; 10 | F::from_bits(ux) 11 | } 12 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_int.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `signed int` (`int`) type. 2 | 3 | This type will almost always be [`i32`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer that is at least the size of a [`short`]; some systems define it as an [`i16`], for example. 4 | 5 | [`short`]: c_short 6 | -------------------------------------------------------------------------------- /library/std/src/os/wasip2/mod.rs: -------------------------------------------------------------------------------- 1 | //! Platform-specific extensions to `std` for Preview 2 of the WebAssembly System Interface (WASI). 2 | //! 3 | //! This module is currently empty, but will be filled over time as wasi-libc support for WASI Preview 2 is stabilized. 4 | 5 | #![forbid(unsafe_op_in_unsafe_fn)] 6 | #![stable(feature = "raw_ext", since = "1.1.0")] 7 | -------------------------------------------------------------------------------- /library/compiler-builtins/builtins-test-intrinsics/build.rs: -------------------------------------------------------------------------------- 1 | mod builtins_configure { 2 | include!("../compiler-builtins/configure.rs"); 3 | } 4 | 5 | fn main() { 6 | println!("cargo::rerun-if-changed=../configure.rs"); 7 | 8 | let target = builtins_configure::Target::from_env(); 9 | builtins_configure::configure_aliases(&target); 10 | } 11 | -------------------------------------------------------------------------------- /library/std/src/sys/anonymous_pipe/unix.rs: -------------------------------------------------------------------------------- 1 | use crate::io; 2 | use crate::sys::fd::FileDesc; 3 | use crate::sys::pipe::anon_pipe; 4 | use crate::sys_common::IntoInner; 5 | 6 | pub type AnonPipe = FileDesc; 7 | 8 | #[inline] 9 | pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> { 10 | anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner())) 11 | } 12 | -------------------------------------------------------------------------------- /library/coretests/benches/any.rs: -------------------------------------------------------------------------------- 1 | use core::any::*; 2 | 3 | use test::{Bencher, black_box}; 4 | 5 | #[bench] 6 | fn bench_downcast_ref(b: &mut Bencher) { 7 | b.iter(|| { 8 | let mut x = 0; 9 | let mut y = &mut x as &mut dyn Any; 10 | black_box(&mut y); 11 | black_box(y.downcast_ref::() == Some(&0)); 12 | }); 13 | } 14 | -------------------------------------------------------------------------------- /library/std/src/os/wasi/ffi.rs: -------------------------------------------------------------------------------- 1 | //! WASI-specific extensions to primitives in the [`std::ffi`] module 2 | //! 3 | //! [`std::ffi`]: crate::ffi 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | 7 | #[path = "../unix/ffi/os_str.rs"] 8 | mod os_str; 9 | 10 | #[stable(feature = "rust1", since = "1.0.0")] 11 | pub use self::os_str::{OsStrExt, OsStringExt}; 12 | -------------------------------------------------------------------------------- /library/stdarch/crates/simd-test-macro/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "simd-test-macro" 3 | version = "0.1.0" 4 | authors = ["Alex Crichton "] 5 | edition = "2024" 6 | 7 | [lib] 8 | proc-macro = true 9 | test = false 10 | 11 | [dependencies] 12 | proc-macro2 = "1.0" 13 | quote = "1.0" 14 | syn = { version = "2.0", features = ["full"] } 15 | -------------------------------------------------------------------------------- /library/coretests/benches/ops.rs: -------------------------------------------------------------------------------- 1 | use core::ops::*; 2 | 3 | use test::Bencher; 4 | 5 | // Overhead of dtors 6 | 7 | struct HasDtor { 8 | _x: isize, 9 | } 10 | 11 | impl Drop for HasDtor { 12 | fn drop(&mut self) {} 13 | } 14 | 15 | #[bench] 16 | fn alloc_obj_with_dtor(b: &mut Bencher) { 17 | b.iter(|| { 18 | HasDtor { _x: 10 }; 19 | }) 20 | } 21 | -------------------------------------------------------------------------------- /library/coretests/tests/num/niche_types.rs: -------------------------------------------------------------------------------- 1 | use core::num::NonZero; 2 | 3 | #[test] 4 | fn test_new_from_zero_is_none() { 5 | assert_eq!(NonZero::::new(0 as char), None); 6 | } 7 | 8 | #[test] 9 | fn test_new_from_extreme_is_some() { 10 | assert!(NonZero::::new(1 as char).is_some()); 11 | assert!(NonZero::::new(char::MAX).is_some()); 12 | } 13 | -------------------------------------------------------------------------------- /library/std/tests/win_delete_self.rs: -------------------------------------------------------------------------------- 1 | #![cfg(windows)] 2 | 3 | /// Attempting to delete a running binary should return an error on Windows. 4 | #[test] 5 | #[cfg_attr(miri, ignore)] // `remove_file` does not work in Miri on Windows 6 | fn win_delete_self() { 7 | let path = std::env::current_exe().unwrap(); 8 | assert!(std::fs::remove_file(path).is_err()); 9 | } 10 | -------------------------------------------------------------------------------- /library/std/src/sys/sync/mod.rs: -------------------------------------------------------------------------------- 1 | mod condvar; 2 | mod mutex; 3 | mod once; 4 | mod once_box; 5 | mod rwlock; 6 | mod thread_parking; 7 | 8 | pub use condvar::Condvar; 9 | pub use mutex::Mutex; 10 | pub use once::{Once, OnceState}; 11 | #[allow(unused)] // Only used on some platforms. 12 | use once_box::OnceBox; 13 | pub use rwlock::RwLock; 14 | pub use thread_parking::Parker; 15 | -------------------------------------------------------------------------------- /library/stdarch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "1" 3 | members = [ 4 | "crates/*", 5 | "examples", 6 | ] 7 | exclude = [ 8 | "crates/wasm-assert-instr-tests", 9 | "rust_programs", 10 | ] 11 | 12 | [profile.release] 13 | debug = true 14 | opt-level = 3 15 | incremental = true 16 | 17 | [profile.bench] 18 | debug = 1 19 | opt-level = 3 20 | incremental = true 21 | -------------------------------------------------------------------------------- /library/stdarch/crates/stdarch-gen-loongarch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stdarch-gen-loongarch" 3 | version = "0.1.0" 4 | authors = ["ZHAI Xiang ", "WANG Rui "] 5 | edition = "2024" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | rand = "0.8.5" 11 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/xous/mod.rs: -------------------------------------------------------------------------------- 1 | #![forbid(unsafe_op_in_unsafe_fn)] 2 | 3 | use crate::os::xous::ffi::exit; 4 | 5 | pub mod os; 6 | #[path = "../unsupported/pipe.rs"] 7 | pub mod pipe; 8 | pub mod thread; 9 | pub mod time; 10 | 11 | #[path = "../unsupported/common.rs"] 12 | mod common; 13 | pub use common::*; 14 | 15 | pub fn abort_internal() -> ! { 16 | exit(101); 17 | } 18 | -------------------------------------------------------------------------------- /library/alloctests/tests/sort/mod.rs: -------------------------------------------------------------------------------- 1 | pub trait Sort { 2 | fn name() -> String; 3 | 4 | fn sort(v: &mut [T]) 5 | where 6 | T: Ord; 7 | 8 | fn sort_by(v: &mut [T], compare: F) 9 | where 10 | F: FnMut(&T, &T) -> std::cmp::Ordering; 11 | } 12 | 13 | mod ffi_types; 14 | mod known_good_stable_sort; 15 | mod patterns; 16 | mod tests; 17 | mod zipf; 18 | -------------------------------------------------------------------------------- /library/core/src/range/legacy.rs: -------------------------------------------------------------------------------- 1 | //! # Legacy range types 2 | //! 3 | //! The types within this module will be replaced by the types 4 | //! [`Range`], [`RangeInclusive`], and [`RangeFrom`] in the parent 5 | //! module, [`core::range`]. 6 | //! 7 | //! The types here are equivalent to those in [`core::ops`]. 8 | 9 | #[doc(inline)] 10 | pub use crate::ops::{Range, RangeFrom, RangeInclusive}; 11 | -------------------------------------------------------------------------------- /library/rustc-std-workspace-std/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustc-std-workspace-std" 3 | version = "1.99.0" 4 | license = 'MIT OR Apache-2.0' 5 | description = """ 6 | Hack for the compiler's own build system 7 | """ 8 | edition = "2024" 9 | 10 | [lib] 11 | path = "lib.rs" 12 | test = false 13 | bench = false 14 | doc = false 15 | 16 | [dependencies] 17 | std = { path = "../std" } 18 | -------------------------------------------------------------------------------- /library/std/src/sys/sync/thread_parking/unsupported.rs: -------------------------------------------------------------------------------- 1 | use crate::pin::Pin; 2 | use crate::time::Duration; 3 | 4 | pub struct Parker {} 5 | 6 | impl Parker { 7 | pub unsafe fn new_in_place(_parker: *mut Parker) {} 8 | pub unsafe fn park(self: Pin<&Self>) {} 9 | pub unsafe fn park_timeout(self: Pin<&Self>, _dur: Duration) {} 10 | pub fn unpark(self: Pin<&Self>) {} 11 | } 12 | -------------------------------------------------------------------------------- /doc/src/challenges.md: -------------------------------------------------------------------------------- 1 | This chapter contains all existing challenges, including the ones that have already been solved or expired. 2 | 3 | For the most up-to-date information on a challenge status, 4 | please check their tracking issue linked in the challenge description. 5 | 6 | If you would like to submit a new challenge, please see 7 | ["Call for Challenges" section](./general-rules.md#call-for-challenges). -------------------------------------------------------------------------------- /library/compiler-builtins/libm-test/tests/z_extensive/main.rs: -------------------------------------------------------------------------------- 1 | //! `main` is just a wrapper to handle configuration. 2 | 3 | #[cfg(not(feature = "build-mpfr"))] 4 | fn main() { 5 | eprintln!("multiprecision not enabled; skipping extensive tests"); 6 | } 7 | 8 | #[cfg(feature = "build-mpfr")] 9 | mod run; 10 | 11 | #[cfg(feature = "build-mpfr")] 12 | fn main() { 13 | run::run(); 14 | } 15 | -------------------------------------------------------------------------------- /library/rustc-std-workspace-alloc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustc-std-workspace-alloc" 3 | version = "1.99.0" 4 | license = 'MIT OR Apache-2.0' 5 | description = """ 6 | Hack for the compiler's own build system 7 | """ 8 | edition = "2024" 9 | 10 | [lib] 11 | path = "lib.rs" 12 | test = false 13 | bench = false 14 | doc = false 15 | 16 | [dependencies] 17 | alloc = { path = "../alloc" } 18 | -------------------------------------------------------------------------------- /scripts/autoharness_analyzer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "autoharness_analyzer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | anyhow = "1.0.97" 8 | clap = {version = "4.5.37", features = ["derive"] } 9 | serde = { version = "1.0.219", features = ["derive"] } 10 | serde_json = "1.0.140" 11 | strum = "0.27.1" 12 | strum_macros = "0.27.1" 13 | to_markdown_table = "0.1.5" 14 | -------------------------------------------------------------------------------- /library/coretests/tests/net/mod.rs: -------------------------------------------------------------------------------- 1 | use core::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; 2 | 3 | mod ip_addr; 4 | mod parser; 5 | mod socket_addr; 6 | 7 | pub fn sa4(a: Ipv4Addr, p: u16) -> SocketAddr { 8 | SocketAddr::V4(SocketAddrV4::new(a, p)) 9 | } 10 | 11 | pub fn sa6(a: Ipv6Addr, p: u16) -> SocketAddr { 12 | SocketAddr::V6(SocketAddrV6::new(a, p, 0, 0)) 13 | } 14 | -------------------------------------------------------------------------------- /library/stdarch/crates/assert-instr-macro/build.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | 3 | fn main() { 4 | let opt_level = env::var("OPT_LEVEL") 5 | .ok() 6 | .and_then(|s| s.parse().ok()) 7 | .unwrap_or(0); 8 | let profile = env::var("PROFILE").unwrap_or_default(); 9 | if profile == "release" || opt_level >= 2 { 10 | println!("cargo:rustc-cfg=optimized"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/std/src/os/vxworks/raw.rs: -------------------------------------------------------------------------------- 1 | //! VxWorks-specific raw type definitions 2 | #![stable(feature = "metadata_ext", since = "1.1.0")] 3 | 4 | use crate::os::raw::c_ulong; 5 | 6 | #[stable(feature = "pthread_t", since = "1.8.0")] 7 | pub type pthread_t = c_ulong; 8 | 9 | #[stable(feature = "raw_ext", since = "1.1.0")] 10 | pub use libc::{blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t, time_t}; 11 | -------------------------------------------------------------------------------- /library/compiler-builtins/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 4 14 | 15 | [*.yml] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /library/core/src/num/shells/i8.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`i8` primitive type][i8]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `i8`" 9 | )] 10 | 11 | int_module! { i8 } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/u8.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`u8` primitive type][u8]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `u8`" 9 | )] 10 | 11 | int_module! { u8 } 12 | -------------------------------------------------------------------------------- /library/coretests/tests/convert.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn convert() { 3 | const fn from(x: i32) -> i32 { 4 | i32::from(x) 5 | } 6 | 7 | const FOO: i32 = from(42); 8 | assert_eq!(FOO, 42); 9 | 10 | const fn into(x: Vec) -> Vec { 11 | x.into() 12 | } 13 | 14 | const BAR: Vec = into(Vec::new()); 15 | assert_eq!(BAR, Vec::::new()); 16 | } 17 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/src/vendor/powerpc.rs: -------------------------------------------------------------------------------- 1 | use crate::simd::*; 2 | 3 | #[cfg(target_arch = "powerpc")] 4 | use core::arch::powerpc::*; 5 | 6 | #[cfg(target_arch = "powerpc64")] 7 | use core::arch::powerpc64::*; 8 | 9 | from_transmute! { unsafe f64x2 => vector_double } 10 | from_transmute! { unsafe i64x2 => vector_signed_long } 11 | from_transmute! { unsafe u64x2 => vector_unsigned_long } 12 | -------------------------------------------------------------------------------- /library/std/src/sys/anonymous_pipe/mod.rs: -------------------------------------------------------------------------------- 1 | #![forbid(unsafe_op_in_unsafe_fn)] 2 | 3 | cfg_select! { 4 | unix => { 5 | mod unix; 6 | pub use unix::{AnonPipe, pipe}; 7 | } 8 | windows => { 9 | mod windows; 10 | pub use windows::{AnonPipe, pipe}; 11 | } 12 | _ => { 13 | mod unsupported; 14 | pub use unsupported::{AnonPipe, pipe}; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/windows/c/README.md: -------------------------------------------------------------------------------- 1 | The `windows_sys.rs` file is autogenerated from `bindings.txt` and must not 2 | be edited manually. 3 | 4 | To add bindings, edit `bindings.txt` then regenerate using the following command: 5 | 6 | ./x run generate-windows-sys && ./x fmt 7 | 8 | If you need to override generated functions or types then add them to 9 | `library/std/src/sys/pal/windows/c.rs`. 10 | -------------------------------------------------------------------------------- /library/std/tests/slice-from-array-issue-113238.rs: -------------------------------------------------------------------------------- 1 | // This intends to use the unsizing coercion from array to slice, but it only 2 | // works if we resolve `<&[u8]>::from` as the reflexive `From for T`. In 3 | // #113238, we found that gimli had added its own `From for &[u8]` 4 | // that affected all `std/backtrace` users. 5 | #[test] 6 | fn slice_from_array() { 7 | let _ = <&[u8]>::from(&[]); 8 | } 9 | -------------------------------------------------------------------------------- /library/core/src/num/shells/i16.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`i16` primitive type][i16]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `i16`" 9 | )] 10 | 11 | int_module! { i16 } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/i32.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`i32` primitive type][i32]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `i32`" 9 | )] 10 | 11 | int_module! { i32 } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/i64.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`i64` primitive type][i64]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `i64`" 9 | )] 10 | 11 | int_module! { i64 } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/u16.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`u16` primitive type][u16]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `u16`" 9 | )] 10 | 11 | int_module! { u16 } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/u32.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`u32` primitive type][u32]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `u32`" 9 | )] 10 | 11 | int_module! { u32 } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/u64.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`u64` primitive type][u64]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `u64`" 9 | )] 10 | 11 | int_module! { u64 } 12 | -------------------------------------------------------------------------------- /library/std/src/sys/random/redox.rs: -------------------------------------------------------------------------------- 1 | use crate::fs::File; 2 | use crate::io::Read; 3 | use crate::sync::OnceLock; 4 | 5 | static SCHEME: OnceLock = OnceLock::new(); 6 | 7 | pub fn fill_bytes(bytes: &mut [u8]) { 8 | SCHEME 9 | .get_or_try_init(|| File::open("/scheme/rand")) 10 | .and_then(|mut scheme| scheme.read_exact(bytes)) 11 | .expect("failed to generate random data"); 12 | } 13 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_ulong.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `unsigned long` type. 2 | 3 | This type will always be [`u32`] or [`u64`]. Most notably, many Linux-based systems assume an `u64`, but Windows assumes `u32`. The C standard technically only requires that this type be an unsigned integer with the size of a [`long`], although in practice, no system would have a `ulong` that is neither a `u32` nor `u64`. 4 | 5 | [`long`]: c_long 6 | -------------------------------------------------------------------------------- /library/std/tests/volatile-fat-ptr.rs: -------------------------------------------------------------------------------- 1 | #![allow(stable_features)] 2 | #![feature(volatile)] 3 | 4 | use std::ptr::{read_volatile, write_volatile}; 5 | 6 | #[test] 7 | fn volatile_fat_ptr() { 8 | let mut x: &'static str = "test"; 9 | unsafe { 10 | let a = read_volatile(&x); 11 | assert_eq!(a, "test"); 12 | write_volatile(&mut x, "foo"); 13 | assert_eq!(x, "foo"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/tracking_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Tracking issue for challenge 3 | about: Create a new tracking issue for a challenge 4 | title: "[Tracking Challenge] " 5 | labels: Challenge 6 | --- 7 | 8 | > **IMPORTANT:** Before submitting this issue, please add this challenge to the runbook and include the link below. 9 | 10 | ## Runbook Link 11 | 12 | [Paste the link to the runbook page for this challenge here] 13 | -------------------------------------------------------------------------------- /library/core/src/num/shells/isize.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`isize` primitive type][isize]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `isize`" 9 | )] 10 | 11 | int_module! { isize } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/usize.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`usize` primitive type][usize]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "rust1", since = "1.0.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `usize`" 9 | )] 10 | 11 | int_module! { usize } 12 | -------------------------------------------------------------------------------- /library/std/src/sys/fd/unix/tests.rs: -------------------------------------------------------------------------------- 1 | use core::mem::ManuallyDrop; 2 | 3 | use super::FileDesc; 4 | use crate::io::IoSlice; 5 | use crate::os::unix::io::FromRawFd; 6 | 7 | #[test] 8 | fn limit_vector_count() { 9 | let stdout = ManuallyDrop::new(unsafe { FileDesc::from_raw_fd(1) }); 10 | let bufs = (0..1500).map(|_| IoSlice::new(&[])).collect::>(); 11 | assert!(stdout.write_vectored(&bufs).is_ok()); 12 | } 13 | -------------------------------------------------------------------------------- /library/windows_targets/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "windows-targets" 3 | description = "A drop-in replacement for the real windows-targets crate for use in std only." 4 | version = "0.0.0" 5 | edition = "2024" 6 | 7 | [lib] 8 | test = false 9 | bench = false 10 | doc = false 11 | 12 | [features] 13 | # Enable using raw-dylib for Windows imports. 14 | # This will eventually be the default. 15 | windows_raw_dylib = [] 16 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_float.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `float` type. 2 | 3 | This type will almost always be [`f32`], which is guaranteed to be an [IEEE 754 single-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number, and it may have less precision than `f32` or not follow the IEEE-754 standard at all. 4 | 5 | [IEEE 754 single-precision float]: https://en.wikipedia.org/wiki/IEEE_754 6 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/windows/os/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::io::Error; 2 | use crate::sys::c; 3 | 4 | // tests `error_string` above 5 | #[test] 6 | fn ntstatus_error() { 7 | const STATUS_UNSUCCESSFUL: u32 = 0xc000_0001; 8 | assert!( 9 | !Error::from_raw_os_error((STATUS_UNSUCCESSFUL | c::FACILITY_NT_BIT) as _) 10 | .to_string() 11 | .contains("FormatMessageW() returned error") 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_ulonglong.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `unsigned long long` type. 2 | 3 | This type will almost always be [`u64`], but may differ on some systems. The C standard technically only requires that this type be an unsigned integer with the size of a [`long long`], although in practice, no system would have a `long long` that is not a `u64`, as most systems do not have a standardised [`u128`] type. 4 | 5 | [`long long`]: c_longlong 6 | -------------------------------------------------------------------------------- /library/std/src/os/unix/io/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::os::unix::io::RawFd; 2 | 3 | #[test] 4 | fn test_raw_fd_layout() { 5 | // `OwnedFd` and `BorrowedFd` use `rustc_layout_scalar_valid_range_start` 6 | // and `rustc_layout_scalar_valid_range_end`, with values that depend on 7 | // the bit width of `RawFd`. If this ever changes, those values will need 8 | // to be updated. 9 | assert_eq!(size_of::(), 4); 10 | } 11 | -------------------------------------------------------------------------------- /library/std/src/os/wasi/io/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::os::wasi::io::RawFd; 2 | 3 | #[test] 4 | fn test_raw_fd_layout() { 5 | // `OwnedFd` and `BorrowedFd` use `rustc_layout_scalar_valid_range_start` 6 | // and `rustc_layout_scalar_valid_range_end`, with values that depend on 7 | // the bit width of `RawFd`. If this ever changes, those values will need 8 | // to be updated. 9 | assert_eq!(size_of::(), 4); 10 | } 11 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/trusty/mod.rs: -------------------------------------------------------------------------------- 1 | //! System bindings for the Trusty OS. 2 | 3 | #[path = "../unsupported/common.rs"] 4 | #[deny(unsafe_op_in_unsafe_fn)] 5 | mod common; 6 | #[path = "../unsupported/os.rs"] 7 | pub mod os; 8 | #[path = "../unsupported/pipe.rs"] 9 | pub mod pipe; 10 | #[path = "../unsupported/thread.rs"] 11 | pub mod thread; 12 | #[path = "../unsupported/time.rs"] 13 | pub mod time; 14 | 15 | pub use common::*; 16 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/update-musl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Download musl to a repository for `musl-math-sys` 3 | 4 | set -eux 5 | 6 | url=https://github.com/kraj/musl.git 7 | ref=c47ad25ea3b484e10326f933e927c0bc8cded3da 8 | dst=crates/musl-math-sys/musl 9 | 10 | if ! [ -d "$dst" ]; then 11 | git clone "$url" "$dst" --single-branch --depth=1000 12 | fi 13 | 14 | git -C "$dst" fetch "$url" --depth=1 15 | git -C "$dst" checkout "$ref" 16 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/float/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod add; 2 | pub mod cmp; 3 | pub mod conv; 4 | pub mod div; 5 | pub mod extend; 6 | pub mod mul; 7 | pub mod pow; 8 | pub mod sub; 9 | pub(crate) mod traits; 10 | pub mod trunc; 11 | 12 | #[cfg(not(feature = "unstable-public-internals"))] 13 | pub(crate) use traits::{Float, HalfRep}; 14 | #[cfg(feature = "unstable-public-internals")] 15 | pub use traits::{Float, HalfRep}; 16 | -------------------------------------------------------------------------------- /library/coretests/tests/panic/location/file_a.rs: -------------------------------------------------------------------------------- 1 | use core::panic::Location; 2 | 3 | // Used for test super::location_{ord, eq}. Must be in a dedicated file. 4 | 5 | pub const fn one() -> &'static Location<'static> { 6 | Location::caller() 7 | } 8 | 9 | pub const fn two() -> &'static Location<'static> { 10 | Location::caller() 11 | } 12 | 13 | pub const fn three() -> &'static Location<'static> { 14 | Location::caller() 15 | } 16 | -------------------------------------------------------------------------------- /library/coretests/tests/panic/location/file_b.rs: -------------------------------------------------------------------------------- 1 | use core::panic::Location; 2 | 3 | // Used for test super::location_{ord, eq}. Must be in a dedicated file. 4 | 5 | pub const fn one() -> &'static Location<'static> { 6 | Location::caller() 7 | } 8 | 9 | pub const fn two() -> &'static Location<'static> { 10 | Location::caller() 11 | } 12 | 13 | pub const fn three() -> &'static Location<'static> { 14 | Location::caller() 15 | } 16 | -------------------------------------------------------------------------------- /library/profiler_builtins/src/lib.rs: -------------------------------------------------------------------------------- 1 | // tidy-alphabetical-start 2 | #![allow(internal_features)] 3 | #![feature(no_core)] 4 | #![feature(profiler_runtime)] 5 | #![feature(staged_api)] 6 | // tidy-alphabetical-end 7 | 8 | // Other attributes: 9 | #![no_core] 10 | #![profiler_runtime] 11 | #![unstable( 12 | feature = "profiler_runtime_lib", 13 | reason = "internal implementation detail of rustc right now", 14 | issue = "none" 15 | )] 16 | -------------------------------------------------------------------------------- /library/std/src/net/ip_addr.rs: -------------------------------------------------------------------------------- 1 | // Tests for this module 2 | #[cfg(all(test, not(any(target_os = "emscripten", all(target_os = "wasi", target_env = "p1")))))] 3 | mod tests; 4 | 5 | #[stable(feature = "ip_addr", since = "1.7.0")] 6 | pub use core::net::IpAddr; 7 | #[unstable(feature = "ip", issue = "27709")] 8 | pub use core::net::Ipv6MulticastScope; 9 | #[stable(feature = "rust1", since = "1.0.0")] 10 | pub use core::net::{Ipv4Addr, Ipv6Addr}; 11 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_long.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `signed long` (`long`) type. 2 | 3 | This type will always be [`i32`] or [`i64`]. Most notably, many Linux-based systems assume an `i64`, but Windows assumes `i32`. The C standard technically only requires that this type be a signed integer that is at least 32 bits and at least the size of an [`int`], although in practice, no system would have a `long` that is neither an `i32` nor `i64`. 4 | 5 | [`int`]: c_int 6 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/download-compiler-rt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Download sources to build C versions of intrinsics. Once being run, 3 | # `RUST_COMPILER_RT_ROOT` must be set. 4 | 5 | set -eux 6 | 7 | rust_llvm_version=20.1-2025-02-13 8 | 9 | curl -L -o code.tar.gz "https://github.com/rust-lang/llvm-project/archive/rustc/${rust_llvm_version}.tar.gz" 10 | tar xzf code.tar.gz --strip-components 1 llvm-project-rustc-${rust_llvm_version}/compiler-rt 11 | -------------------------------------------------------------------------------- /library/core/src/fmt/fmt_trait_method_doc.md: -------------------------------------------------------------------------------- 1 | Formats the value using the given formatter. 2 | 3 | # Errors 4 | 5 | This function should return [`Err`] if, and only if, the provided [`Formatter`] returns [`Err`]. 6 | String formatting is considered an infallible operation; this function only 7 | returns a [`Result`] because writing to the underlying stream might fail and it must 8 | provide a way to propagate the fact that an error has occurred back up the stack. 9 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_longlong.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `signed long long` (`long long`) type. 2 | 3 | This type will almost always be [`i64`], but may differ on some systems. The C standard technically only requires that this type be a signed integer that is at least 64 bits and at least the size of a [`long`], although in practice, no system would have a `long long` that is not an `i64`, as most systems do not have a standardised [`i128`] type. 4 | 5 | [`long`]: c_int 6 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/unix/sync/mod.rs: -------------------------------------------------------------------------------- 1 | #![cfg(not(any( 2 | target_os = "linux", 3 | target_os = "android", 4 | all(target_os = "emscripten", target_feature = "atomics"), 5 | target_os = "freebsd", 6 | target_os = "openbsd", 7 | target_os = "dragonfly", 8 | target_os = "fuchsia", 9 | )))] 10 | #![forbid(unsafe_op_in_unsafe_fn)] 11 | 12 | mod condvar; 13 | mod mutex; 14 | 15 | pub use condvar::Condvar; 16 | pub use mutex::Mutex; 17 | -------------------------------------------------------------------------------- /library/core/src/num/shells/i128.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`i128` primitive type][i128]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "i128", since = "1.26.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `i128`" 9 | )] 10 | 11 | int_module! { i128, #[stable(feature = "i128", since="1.26.0")] } 12 | -------------------------------------------------------------------------------- /library/core/src/num/shells/u128.rs: -------------------------------------------------------------------------------- 1 | //! Redundant constants module for the [`u128` primitive type][u128]. 2 | //! 3 | //! New code should use the associated constants directly on the primitive type. 4 | 5 | #![stable(feature = "i128", since = "1.26.0")] 6 | #![deprecated( 7 | since = "TBD", 8 | note = "all constants in this module replaced by associated constants on `u128`" 9 | )] 10 | 11 | int_module! { u128, #[stable(feature = "i128", since="1.26.0")] } 12 | -------------------------------------------------------------------------------- /library/stdarch/crates/assert-instr-macro/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "assert-instr-macro" 3 | version = "0.1.0" 4 | authors = ["Alex Crichton "] 5 | edition = "2024" 6 | 7 | [lib] 8 | proc-macro = true 9 | test = false 10 | 11 | [dependencies] 12 | proc-macro2 = "1.0" 13 | quote = "1.0" 14 | syn = { version = "2.0", features = ["full"] } 15 | 16 | [lints.rust] 17 | unexpected_cfgs = {level = "warn", check-cfg = ['cfg(optimized)'] } 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | > Please add a description of your PR. 2 | > If this is a solution to an open challenge, please explain your solution. 3 | > 4 | > Don't forget to check our book to ensure your solution satisfy the overall 5 | > requirements as well as the challenge success criteria. 6 | > 7 | 8 | Resolves #ISSUE-NUMBER 9 | 10 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. 11 | -------------------------------------------------------------------------------- /library/panic_unwind/src/dummy.rs: -------------------------------------------------------------------------------- 1 | //! Unwinding for unsupported target. 2 | //! 3 | //! Stubs that simply abort for targets that don't support unwinding otherwise. 4 | 5 | use alloc::boxed::Box; 6 | use core::any::Any; 7 | use core::intrinsics; 8 | 9 | pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box { 10 | intrinsics::abort() 11 | } 12 | 13 | pub(crate) unsafe fn panic(_data: Box) -> u32 { 14 | intrinsics::abort() 15 | } 16 | -------------------------------------------------------------------------------- /library/std/src/io/prelude.rs: -------------------------------------------------------------------------------- 1 | //! The I/O Prelude. 2 | //! 3 | //! The purpose of this module is to alleviate imports of many common I/O traits 4 | //! by adding a glob import to the top of I/O heavy modules: 5 | //! 6 | //! ``` 7 | //! # #![allow(unused_imports)] 8 | //! use std::io::prelude::*; 9 | //! ``` 10 | 11 | #![stable(feature = "rust1", since = "1.0.0")] 12 | 13 | #[stable(feature = "rust1", since = "1.0.0")] 14 | pub use super::{BufRead, Read, Seek, Write}; 15 | -------------------------------------------------------------------------------- /library/test/Cargo.toml: -------------------------------------------------------------------------------- 1 | cargo-features = ["public-dependency"] 2 | 3 | [package] 4 | name = "test" 5 | version = "0.0.0" 6 | edition = "2024" 7 | 8 | [dependencies] 9 | getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] } 10 | std = { path = "../std", public = true } 11 | core = { path = "../core", public = true } 12 | 13 | [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] 14 | libc = { version = "0.2.150", default-features = false } 15 | -------------------------------------------------------------------------------- /library/alloctests/tests/linked_list.rs: -------------------------------------------------------------------------------- 1 | use std::collections::LinkedList; 2 | 3 | #[test] 4 | fn test_hash() { 5 | use crate::hash; 6 | 7 | let mut x = LinkedList::new(); 8 | let mut y = LinkedList::new(); 9 | 10 | assert!(hash(&x) == hash(&y)); 11 | 12 | x.push_back(1); 13 | x.push_back(2); 14 | x.push_back(3); 15 | 16 | y.push_front(3); 17 | y.push_front(2); 18 | y.push_front(1); 19 | 20 | assert!(hash(&x) == hash(&y)); 21 | } 22 | -------------------------------------------------------------------------------- /library/std/src/sys/random/fuchsia.rs: -------------------------------------------------------------------------------- 1 | //! Random data generation using the Zircon kernel. 2 | //! 3 | //! Fuchsia, as always, is quite nice and provides exactly the API we need: 4 | //! . 5 | 6 | #[link(name = "zircon")] 7 | unsafe extern "C" { 8 | fn zx_cprng_draw(buffer: *mut u8, len: usize); 9 | } 10 | 11 | pub fn fill_bytes(bytes: &mut [u8]) { 12 | unsafe { zx_cprng_draw(bytes.as_mut_ptr(), bytes.len()) } 13 | } 14 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_double.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `double` type. 2 | 3 | This type will almost always be [`f64`], which is guaranteed to be an [IEEE 754 double-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`], and it may be `f32` or something entirely different from the IEEE-754 standard. 4 | 5 | [IEEE 754 double-precision float]: https://en.wikipedia.org/wiki/IEEE_754 6 | [`float`]: c_float 7 | -------------------------------------------------------------------------------- /library/std/src/sys/platform_version/mod.rs: -------------------------------------------------------------------------------- 1 | //! Runtime lookup of operating system / platform version. 2 | //! 3 | //! Related to [RFC 3750](https://github.com/rust-lang/rfcs/pull/3750), which 4 | //! does version detection at compile-time. 5 | //! 6 | //! See also the `os_info` crate. 7 | 8 | #[cfg(target_vendor = "apple")] 9 | mod darwin; 10 | 11 | // In the future, we could expand this module with: 12 | // - `RtlGetVersion` on Windows. 13 | // - `__system_property_get` on Android. 14 | -------------------------------------------------------------------------------- /testable-simd-models/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "testable-simd-models" 3 | version = "0.0.2" 4 | authors = ["Cryspen"] 5 | license = "Apache-2.0" 6 | homepage = "https://github.com/cryspen/verify-rust-std/testable-simd-models" 7 | edition = "2021" 8 | repository = "https://github.com/cryspen/verify-rust-std/testable-simd-models" 9 | readme = "README.md" 10 | 11 | [dependencies] 12 | rand = "0.9" 13 | pastey = "0.1.0" 14 | 15 | [lints.rust] 16 | unexpected_cfgs = { level = "warn" } 17 | -------------------------------------------------------------------------------- /.github/pull_requests.toml: -------------------------------------------------------------------------------- 1 | [committee] 2 | members = [ 3 | "celinval", 4 | "rahulku", 5 | "pnkfelix", 6 | "adpaco-aws", 7 | "feliperodri", 8 | "zhassan-aws", 9 | "remi-delmas-3000", 10 | "qinheping", 11 | "tautschnig", 12 | "patricklam", 13 | "ranjitjhala", 14 | "carolynzech", 15 | "robdockins", 16 | "HuStmpHrrr", 17 | "Eh2406", 18 | "jswrenn", 19 | "havelund", 20 | "jorajeev", 21 | "rajath-mk", 22 | "thanhnguyen-aws" 23 | ] 24 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | gcc-riscv64-linux-gnu libc6-dev-riscv64-cross \ 6 | llvm 7 | 8 | ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc \ 9 | CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER="qemu-riscv64 -cpu max -L /usr/riscv64-linux-gnu" \ 10 | OBJDUMP=llvm-objdump 11 | -------------------------------------------------------------------------------- /library/stdarch/ci/style.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -ex 4 | 5 | if rustup component add rustfmt-preview ; then 6 | command -v rustfmt 7 | rustfmt -V 8 | cargo fmt --all -- --check 9 | fi 10 | 11 | # if rustup component add clippy-preview ; then 12 | # cargo clippy -V 13 | # cargo clippy --all -- -D clippy::pedantic 14 | # fi 15 | 16 | if shellcheck --version ; then 17 | shellcheck -e SC2103 ci/*.sh 18 | else 19 | echo "shellcheck not found" 20 | exit 1 21 | fi 22 | 23 | -------------------------------------------------------------------------------- /library/std/src/io/pipe/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::io::{Read, Write, pipe}; 2 | 3 | #[test] 4 | #[cfg(all(any(unix, windows), not(miri)))] 5 | fn pipe_creation_clone_and_rw() { 6 | let (rx, tx) = pipe().unwrap(); 7 | 8 | tx.try_clone().unwrap().write_all(b"12345").unwrap(); 9 | drop(tx); 10 | 11 | let mut rx2 = rx.try_clone().unwrap(); 12 | drop(rx); 13 | 14 | let mut s = String::new(); 15 | rx2.read_to_string(&mut s).unwrap(); 16 | drop(rx2); 17 | assert_eq!(s, "12345"); 18 | } 19 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/arch/mips.rs: -------------------------------------------------------------------------------- 1 | //! Run-time feature detection on MIPS. 2 | 3 | features! { 4 | @TARGET: mips; 5 | @CFG: target_arch = "mips"; 6 | @MACRO_NAME: is_mips_feature_detected; 7 | @MACRO_ATTRS: 8 | /// Checks if `mips` feature is enabled. 9 | #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] 10 | @FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa"; 11 | /// MIPS SIMD Architecture (MSA) 12 | } 13 | -------------------------------------------------------------------------------- /library/std/src/os/net/mod.rs: -------------------------------------------------------------------------------- 1 | //! OS-specific networking functionality. 2 | 3 | // See cfg macros in `library/std/src/os/mod.rs` for why these platforms must 4 | // be special-cased during rustdoc generation. 5 | #[cfg(not(all( 6 | doc, 7 | any( 8 | all(target_arch = "wasm32", not(target_os = "wasi")), 9 | all(target_vendor = "fortanix", target_env = "sgx") 10 | ) 11 | )))] 12 | #[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin", doc))] 13 | pub(super) mod linux_ext; 14 | -------------------------------------------------------------------------------- /library/std/src/os/raw/tests.rs: -------------------------------------------------------------------------------- 1 | #![cfg(not(all(windows, target_env = "msvc")))] 2 | 3 | use crate::any::TypeId; 4 | 5 | macro_rules! ok { 6 | ($($t:ident)*) => {$( 7 | assert!(TypeId::of::() == TypeId::of::(), 8 | "{} is wrong", stringify!($t)); 9 | )*} 10 | } 11 | 12 | #[test] 13 | fn same() { 14 | use crate::os::raw; 15 | ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong 16 | c_longlong c_ulonglong c_float c_double); 17 | } 18 | -------------------------------------------------------------------------------- /library/compiler-builtins/builtins-test-intrinsics/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "builtins-test-intrinsics" 3 | version = "0.1.0" 4 | edition = "2024" 5 | publish = false 6 | license = "MIT OR Apache-2.0" 7 | 8 | [dependencies] 9 | compiler_builtins = { path = "../builtins-shim", features = ["compiler-builtins"] } 10 | panic-handler = { path = "../crates/panic-handler" } 11 | 12 | [features] 13 | c = ["compiler_builtins/c"] 14 | 15 | [profile.release] 16 | panic = "abort" 17 | 18 | [profile.dev] 19 | panic = "abort" 20 | -------------------------------------------------------------------------------- /library/std/src/os/net/linux_ext/mod.rs: -------------------------------------------------------------------------------- 1 | //! Linux, Android and Cygwin-specific networking functionality. 2 | 3 | #![doc(cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin")))] 4 | 5 | #[stable(feature = "unix_socket_abstract", since = "1.70.0")] 6 | pub(crate) mod addr; 7 | 8 | #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] 9 | pub(crate) mod socket; 10 | 11 | #[stable(feature = "tcp_quickack", since = "1.89.0")] 12 | pub(crate) mod tcp; 13 | 14 | #[cfg(test)] 15 | mod tests; 16 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/arch/mips64.rs: -------------------------------------------------------------------------------- 1 | //! Run-time feature detection on MIPS64. 2 | 3 | features! { 4 | @TARGET: mips64; 5 | @CFG: target_arch = "mips64"; 6 | @MACRO_NAME: is_mips64_feature_detected; 7 | @MACRO_ATTRS: 8 | /// Checks if `mips64` feature is enabled. 9 | #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] 10 | @FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa"; 11 | /// MIPS SIMD Architecture (MSA) 12 | } 13 | -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/loongarch64/lsx/mod.rs: -------------------------------------------------------------------------------- 1 | //! LoongArch64 LSX intrinsics 2 | 3 | #![allow(non_camel_case_types)] 4 | 5 | #[rustfmt::skip] 6 | mod types; 7 | 8 | #[rustfmt::skip] 9 | #[unstable(feature = "stdarch_loongarch", issue = "117427")] 10 | pub use self::types::*; 11 | 12 | #[rustfmt::skip] 13 | mod generated; 14 | 15 | #[rustfmt::skip] 16 | #[unstable(feature = "stdarch_loongarch", issue = "117427")] 17 | pub use self::generated::*; 18 | 19 | #[rustfmt::skip] 20 | #[cfg(test)] 21 | mod tests; 22 | -------------------------------------------------------------------------------- /library/std/src/os/linux/net.rs: -------------------------------------------------------------------------------- 1 | //! Linux-specific networking functionality. 2 | 3 | #![stable(feature = "unix_socket_abstract", since = "1.70.0")] 4 | 5 | #[stable(feature = "unix_socket_abstract", since = "1.70.0")] 6 | pub use crate::os::net::linux_ext::addr::SocketAddrExt; 7 | #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] 8 | pub use crate::os::net::linux_ext::socket::UnixSocketExt; 9 | #[stable(feature = "tcp_quickack", since = "1.89.0")] 10 | pub use crate::os::net::linux_ext::tcp::TcpStreamExt; 11 | -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/loongarch64/lasx/mod.rs: -------------------------------------------------------------------------------- 1 | //! LoongArch64 LASX intrinsics 2 | 3 | #![allow(non_camel_case_types)] 4 | 5 | #[rustfmt::skip] 6 | mod types; 7 | 8 | #[rustfmt::skip] 9 | #[unstable(feature = "stdarch_loongarch", issue = "117427")] 10 | pub use self::types::*; 11 | 12 | #[rustfmt::skip] 13 | mod generated; 14 | 15 | #[rustfmt::skip] 16 | #[unstable(feature = "stdarch_loongarch", issue = "117427")] 17 | pub use self::generated::*; 18 | 19 | #[rustfmt::skip] 20 | #[cfg(test)] 21 | mod tests; 22 | -------------------------------------------------------------------------------- /library/core/src/task/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "futures_api", since = "1.36.0")] 2 | 3 | //! Types and Traits for working with asynchronous tasks. 4 | 5 | mod poll; 6 | #[stable(feature = "futures_api", since = "1.36.0")] 7 | pub use self::poll::Poll; 8 | 9 | mod wake; 10 | #[stable(feature = "futures_api", since = "1.36.0")] 11 | pub use self::wake::{Context, ContextBuilder, LocalWaker, RawWaker, RawWakerVTable, Waker}; 12 | 13 | mod ready; 14 | #[stable(feature = "ready_macro", since = "1.64.0")] 15 | pub use ready::ready; 16 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/examples/README.md: -------------------------------------------------------------------------------- 1 | ### `stdsimd` examples 2 | 3 | This crate is a port of example uses of `stdsimd`, mostly taken from the `packed_simd` crate. 4 | 5 | The examples contain, as in the case of `dot_product.rs`, multiple ways of solving the problem, in order to show idiomatic uses of SIMD and iteration of performance designs. 6 | 7 | Run the tests with the command 8 | 9 | ``` 10 | cargo run --example dot_product 11 | ``` 12 | 13 | and verify the code for `dot_product.rs` on your machine. 14 | -------------------------------------------------------------------------------- /library/std/src/os/android/net.rs: -------------------------------------------------------------------------------- 1 | //! Android-specific networking functionality. 2 | 3 | #![stable(feature = "unix_socket_abstract", since = "1.70.0")] 4 | 5 | #[stable(feature = "unix_socket_abstract", since = "1.70.0")] 6 | pub use crate::os::net::linux_ext::addr::SocketAddrExt; 7 | #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] 8 | pub use crate::os::net::linux_ext::socket::UnixSocketExt; 9 | #[stable(feature = "tcp_quickack", since = "1.89.0")] 10 | pub use crate::os::net::linux_ext::tcp::TcpStreamExt; 11 | -------------------------------------------------------------------------------- /library/coretests/benches/str/iter.rs: -------------------------------------------------------------------------------- 1 | use test::{Bencher, black_box}; 2 | 3 | use super::corpora; 4 | 5 | #[bench] 6 | fn chars_advance_by_1000(b: &mut Bencher) { 7 | b.iter(|| black_box(corpora::ru::LARGE).chars().advance_by(1000)); 8 | } 9 | 10 | #[bench] 11 | fn chars_advance_by_0010(b: &mut Bencher) { 12 | b.iter(|| black_box(corpora::ru::LARGE).chars().advance_by(10)); 13 | } 14 | 15 | #[bench] 16 | fn chars_advance_by_0001(b: &mut Bencher) { 17 | b.iter(|| black_box(corpora::ru::LARGE).chars().advance_by(1)); 18 | } 19 | -------------------------------------------------------------------------------- /library/std/src/os/windows/raw.rs: -------------------------------------------------------------------------------- 1 | //! Windows-specific primitives. 2 | 3 | #![stable(feature = "raw_ext", since = "1.1.0")] 4 | 5 | use crate::os::raw::c_void; 6 | 7 | #[stable(feature = "raw_ext", since = "1.1.0")] 8 | pub type HANDLE = *mut c_void; 9 | #[cfg(target_pointer_width = "32")] 10 | #[doc(cfg(all()))] 11 | #[stable(feature = "raw_ext", since = "1.1.0")] 12 | pub type SOCKET = u32; 13 | #[cfg(target_pointer_width = "64")] 14 | #[doc(cfg(all()))] 15 | #[stable(feature = "raw_ext", since = "1.1.0")] 16 | pub type SOCKET = u64; 17 | -------------------------------------------------------------------------------- /library/core/src/fmt/nofloat.rs: -------------------------------------------------------------------------------- 1 | use crate::fmt::{Debug, Formatter, Result}; 2 | 3 | macro_rules! floating { 4 | ($($ty:ident)*) => { 5 | $( 6 | #[stable(feature = "rust1", since = "1.0.0")] 7 | impl Debug for $ty { 8 | #[inline] 9 | fn fmt(&self, _fmt: &mut Formatter<'_>) -> Result { 10 | panic!("floating point fmt support is turned off"); 11 | } 12 | } 13 | )* 14 | }; 15 | } 16 | 17 | floating! { f16 f32 f64 f128 } 18 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | gcc \ 4 | ca-certificates \ 5 | libc6-dev \ 6 | gcc-arm-linux-gnueabihf \ 7 | libc6-dev-armhf-cross \ 8 | qemu-user \ 9 | make \ 10 | file 11 | ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ 12 | CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -cpu max -L /usr/arm-linux-gnueabihf" \ 13 | OBJDUMP=arm-linux-gnueabihf-objdump 14 | -------------------------------------------------------------------------------- /library/std/src/sys/alloc/zkvm.rs: -------------------------------------------------------------------------------- 1 | use crate::alloc::{GlobalAlloc, Layout, System}; 2 | use crate::sys::pal::abi; 3 | 4 | #[stable(feature = "alloc_system_type", since = "1.28.0")] 5 | unsafe impl GlobalAlloc for System { 6 | #[inline] 7 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 { 8 | unsafe { abi::sys_alloc_aligned(layout.size(), layout.align()) } 9 | } 10 | 11 | #[inline] 12 | unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) { 13 | // this allocator never deallocates memory 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/mips-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | gcc-mips-linux-gnu libc6-dev-mips-cross \ 6 | qemu-system-mips \ 7 | qemu-user \ 8 | make \ 9 | file 10 | 11 | ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ 12 | CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" \ 13 | OBJDUMP=mips-linux-gnu-objdump -------------------------------------------------------------------------------- /library/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ 6 | qemu-system-mips64 qemu-user 7 | 8 | ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ 9 | CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \ 10 | OBJDUMP=mips64-linux-gnuabi64-objdump -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/powerpc64/mod.rs: -------------------------------------------------------------------------------- 1 | //! PowerPC 64 2 | //! 3 | //! The reference is the [64-Bit ELF V2 ABI Specification - Power 4 | //! Architecture]. 5 | //! 6 | //! [64-Bit ELF V2 ABI Specification - Power Architecture]: http://openpowerfoundation.org/wp-content/uploads/resources/leabi/leabi-20170510.pdf 7 | 8 | mod vsx; 9 | 10 | #[unstable(feature = "stdarch_powerpc", issue = "111145")] 11 | pub use crate::core_arch::powerpc::*; 12 | 13 | #[unstable(feature = "stdarch_powerpc", issue = "111145")] 14 | pub use self::vsx::*; 15 | -------------------------------------------------------------------------------- /library/core/src/num/libm.rs: -------------------------------------------------------------------------------- 1 | //! Bindings to math functions provided by the system `libm` or by the `libm` crate, exposed 2 | //! via `compiler-builtins`. 3 | 4 | // SAFETY: These symbols have standard interfaces in C and are defined by `libm`, or are 5 | // provided by `compiler-builtins` on unsupported platforms. 6 | unsafe extern "C" { 7 | pub(crate) safe fn cbrt(n: f64) -> f64; 8 | pub(crate) safe fn cbrtf(n: f32) -> f32; 9 | pub(crate) safe fn fdim(a: f64, b: f64) -> f64; 10 | pub(crate) safe fn fdimf(a: f32, b: f32) -> f32; 11 | } 12 | -------------------------------------------------------------------------------- /library/portable-simd/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # This only controls whether a tiny, hard-to-find "open a blank issue" link appears at the end of 2 | # the template list. 3 | blank_issues_enabled: true 4 | contact_links: 5 | - name: Intrinsic Support 6 | url: https://github.com/rust-lang/stdarch/issues 7 | about: Please direct issues about Rust's support for vendor intrinsics to core::arch 8 | - name: Internal Compiler Error 9 | url: https://github.com/rust-lang/rust/issues 10 | about: Please report ICEs to the rustc repository 11 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ 6 | qemu-system-mips64el 7 | 8 | ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ 9 | CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \ 10 | OBJDUMP=mips64el-linux-gnuabi64-objdump -------------------------------------------------------------------------------- /library/stdarch/crates/stdarch-verify/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stdarch-verify" 3 | version = "0.1.0" 4 | authors = ["Alex Crichton "] 5 | edition = "2024" 6 | 7 | [dependencies] 8 | proc-macro2 = "1.0" 9 | quote = "1.0" 10 | syn = { version = "2.0", features = ["full"] } 11 | 12 | [lib] 13 | proc-macro = true 14 | test = false 15 | 16 | [dev-dependencies] 17 | serde = { version = "1.0", features = ['derive'] } 18 | serde_json = "1.0.96" 19 | quick-xml = { version = "0.33.0", features = ["serialize", "overlapped-lists"] } 20 | -------------------------------------------------------------------------------- /library/coretests/tests/iter/adapters/scan.rs: -------------------------------------------------------------------------------- 1 | use core::iter::*; 2 | 3 | #[test] 4 | fn test_iterator_scan() { 5 | // test the type inference 6 | fn add(old: &mut isize, new: &usize) -> Option { 7 | *old += *new as isize; 8 | Some(*old as f64) 9 | } 10 | let xs = [0, 1, 2, 3, 4]; 11 | let ys = [0f64, 1.0, 3.0, 6.0, 10.0]; 12 | 13 | let it = xs.iter().scan(0, add); 14 | let mut i = 0; 15 | for x in it { 16 | assert_eq!(x, ys[i]); 17 | i += 1; 18 | } 19 | assert_eq!(i, ys.len()); 20 | } 21 | -------------------------------------------------------------------------------- /library/panic_unwind/src/hermit.rs: -------------------------------------------------------------------------------- 1 | //! Unwinding for *hermit* target. 2 | //! 3 | //! Right now we don't support this, so this is just stubs. 4 | 5 | use alloc::boxed::Box; 6 | use core::any::Any; 7 | 8 | unsafe extern "Rust" { 9 | // This is defined in std::rt 10 | #[rustc_std_internal_symbol] 11 | safe fn __rust_abort() -> !; 12 | } 13 | 14 | pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box { 15 | __rust_abort() 16 | } 17 | 18 | pub(crate) unsafe fn panic(_data: Box) -> u32 { 19 | __rust_abort() 20 | } 21 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/sgx/waitqueue/tests.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::sync::Arc; 3 | use crate::thread; 4 | 5 | #[test] 6 | fn queue() { 7 | let wq = Arc::new(SpinMutex::>::default()); 8 | let wq2 = wq.clone(); 9 | 10 | let locked = wq.lock(); 11 | 12 | let t1 = thread::spawn(move || { 13 | // if we obtain the lock, the main thread should be waiting 14 | assert!(WaitQueue::notify_one(wq2.lock()).is_ok()); 15 | }); 16 | 17 | WaitQueue::wait(locked, || {}); 18 | 19 | t1.join().unwrap(); 20 | } 21 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/windows/api/tests.rs: -------------------------------------------------------------------------------- 1 | use crate::sys::pal::windows::api::{utf16, wide_str}; 2 | 3 | macro_rules! check_utf16 { 4 | ($str:literal) => {{ 5 | assert!(wide_str!($str).iter().copied().eq($str.encode_utf16().chain([0]))); 6 | assert!(utf16!($str).iter().copied().eq($str.encode_utf16())); 7 | }}; 8 | } 9 | 10 | #[test] 11 | fn test_utf16_macros() { 12 | check_utf16!("hello world"); 13 | check_utf16!("€4.50"); 14 | check_utf16!("𨉟呐㗂越"); 15 | check_utf16!("Pchnąć w tę łódź jeża lub ośm skrzyń fig"); 16 | } 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/int/mod.rs: -------------------------------------------------------------------------------- 1 | mod specialized_div_rem; 2 | 3 | pub mod addsub; 4 | mod big; 5 | pub mod bswap; 6 | pub mod leading_zeros; 7 | pub mod mul; 8 | pub mod sdiv; 9 | pub mod shift; 10 | pub mod trailing_zeros; 11 | mod traits; 12 | pub mod udiv; 13 | 14 | pub use big::{i256, u256}; 15 | #[cfg(not(feature = "unstable-public-internals"))] 16 | pub(crate) use traits::{CastFrom, CastInto, DInt, HInt, Int, MinInt}; 17 | #[cfg(feature = "unstable-public-internals")] 18 | pub use traits::{CastFrom, CastInto, DInt, HInt, Int, MinInt}; 19 | -------------------------------------------------------------------------------- /library/std/src/sys/os_str/bytes/tests.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | 3 | #[test] 4 | fn slice_debug_output() { 5 | let input = unsafe { Slice::from_encoded_bytes_unchecked(b"\xF0hello,\tworld") }; 6 | let expected = r#""\xF0hello,\tworld""#; 7 | let output = format!("{input:?}"); 8 | 9 | assert_eq!(output, expected); 10 | } 11 | 12 | #[test] 13 | fn display() { 14 | assert_eq!("Hello\u{FFFD}\u{FFFD} There\u{FFFD} Goodbye", unsafe { 15 | Slice::from_encoded_bytes_unchecked(b"Hello\xC0\x80 There\xE6\x83 Goodbye").to_string() 16 | },); 17 | } 18 | -------------------------------------------------------------------------------- /library/std/src/sys/random/unsupported.rs: -------------------------------------------------------------------------------- 1 | use crate::ptr; 2 | 3 | pub fn fill_bytes(_: &mut [u8]) { 4 | panic!("this target does not support random data generation"); 5 | } 6 | 7 | pub fn hashmap_random_keys() -> (u64, u64) { 8 | // Use allocation addresses for a bit of randomness. This isn't 9 | // particularly secure, but there isn't really an alternative. 10 | let stack = 0u8; 11 | let heap = Box::new(0u8); 12 | let k1 = ptr::from_ref(&stack).addr() as u64; 13 | let k2 = ptr::from_ref(&*heap).addr() as u64; 14 | (k1, k2) 15 | } 16 | -------------------------------------------------------------------------------- /library/std/tests/windows.rs: -------------------------------------------------------------------------------- 1 | #![cfg(windows)] 2 | //! An external tests 3 | 4 | use std::ffi::OsString; 5 | use std::os::windows::ffi::OsStringExt; 6 | use std::path::PathBuf; 7 | 8 | #[test] 9 | #[should_panic] 10 | fn os_string_must_know_it_isnt_utf8_issue_126291() { 11 | let mut utf8 = PathBuf::from(OsString::from("utf8".to_owned())); 12 | let non_utf8: OsString = 13 | OsStringExt::from_wide(&[0x6e, 0x6f, 0x6e, 0xd800, 0x75, 0x74, 0x66, 0x38]); 14 | utf8.set_extension(&non_utf8); 15 | utf8.into_os_string().into_string().unwrap(); 16 | } 17 | -------------------------------------------------------------------------------- /library/coretests/tests/iter/adapters/copied.rs: -------------------------------------------------------------------------------- 1 | use core::iter::*; 2 | 3 | #[test] 4 | fn test_copied() { 5 | let xs = [2, 4, 6, 8]; 6 | 7 | let mut it = xs.iter().copied(); 8 | assert_eq!(it.len(), 4); 9 | assert_eq!(it.next(), Some(2)); 10 | assert_eq!(it.len(), 3); 11 | assert_eq!(it.next(), Some(4)); 12 | assert_eq!(it.len(), 2); 13 | assert_eq!(it.next_back(), Some(8)); 14 | assert_eq!(it.len(), 1); 15 | assert_eq!(it.next_back(), Some(6)); 16 | assert_eq!(it.len(), 0); 17 | assert_eq!(it.next_back(), None); 18 | } 19 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/s390x-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | curl ca-certificates \ 5 | gcc libc6-dev \ 6 | gcc-s390x-linux-gnu libc6-dev-s390x-cross \ 7 | qemu-user \ 8 | make \ 9 | clang \ 10 | file 11 | 12 | ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ 13 | CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -cpu max -L /usr/s390x-linux-gnu" \ 14 | OBJDUMP=s390x-linux-gnu-objdump 15 | -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/arm_shared/barrier/common.rs: -------------------------------------------------------------------------------- 1 | //! Access types available on all architectures 2 | 3 | /// Full system is the required shareability domain, reads and writes are the 4 | /// required access types 5 | #[unstable(feature = "stdarch_arm_barrier", issue = "117219")] 6 | pub struct SY; 7 | 8 | dmb_dsb!(SY); 9 | 10 | #[unstable(feature = "stdarch_arm_barrier", issue = "117219")] 11 | impl super::super::sealed::Isb for SY { 12 | #[inline(always)] 13 | unsafe fn __isb(&self) { 14 | super::isb(super::arg::SY) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/crates/libm-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "libm-macros" 3 | version = "0.1.0" 4 | edition = "2024" 5 | publish = false 6 | license = "MIT OR Apache-2.0" 7 | 8 | [lib] 9 | proc-macro = true 10 | 11 | [dependencies] 12 | heck = "0.5.0" 13 | proc-macro2 = "1.0.95" 14 | quote = "1.0.40" 15 | syn = { version = "2.0.104", features = ["full", "extra-traits", "visit-mut"] } 16 | 17 | [lints.rust] 18 | # Values used during testing 19 | unexpected_cfgs = { level = "warn", check-cfg = [ 20 | 'cfg(f16_enabled)', 21 | 'cfg(f128_enabled)', 22 | ] } 23 | -------------------------------------------------------------------------------- /library/stdarch/.cirrus.yml: -------------------------------------------------------------------------------- 1 | task: 2 | name: x86_64-unknown-freebsd 3 | freebsd_instance: 4 | image_family: freebsd-13-4 5 | env: 6 | # FIXME(freebsd): FreeBSD has a segfault when `RUST_BACKTRACE` is set 7 | # https://github.com/rust-lang/rust/issues/132185 8 | RUST_BACKTRACE: "0" 9 | setup_script: 10 | - curl https://sh.rustup.rs -sSf --output rustup.sh 11 | - sh rustup.sh --default-toolchain nightly -y 12 | - . $HOME/.cargo/env 13 | - rustup default nightly 14 | test_script: 15 | - . $HOME/.cargo/env 16 | - cargo build --all 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/build.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | 3 | mod configure; 4 | 5 | fn main() { 6 | let cfg = configure::Config::from_env(); 7 | 8 | println!("cargo:rerun-if-changed=build.rs"); 9 | println!("cargo:rerun-if-changed=configure.rs"); 10 | println!("cargo:rustc-check-cfg=cfg(assert_no_panic)"); 11 | 12 | // If set, enable `no-panic`. Requires LTO (`release-opt` profile). 13 | if env::var("ENSURE_NO_PANIC").is_ok() { 14 | println!("cargo:rustc-cfg=assert_no_panic"); 15 | } 16 | 17 | configure::emit_libm_config(&cfg); 18 | } 19 | -------------------------------------------------------------------------------- /library/portable-simd/crates/std_float/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "std_float" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | core_simd = { path = "../core_simd", default-features = false } 10 | 11 | [dev-dependencies.test_helpers] 12 | path = "../test_helpers" 13 | 14 | [target.'cfg(target_arch = "wasm32")'.dev-dependencies] 15 | wasm-bindgen = "0.2" 16 | wasm-bindgen-test = "0.3" 17 | 18 | [features] 19 | default = ["as_crate"] 20 | as_crate = [] 21 | -------------------------------------------------------------------------------- /library/rustc-std-workspace-core/Cargo.toml: -------------------------------------------------------------------------------- 1 | cargo-features = ["public-dependency"] 2 | 3 | [package] 4 | name = "rustc-std-workspace-core" 5 | version = "1.99.0" 6 | license = 'MIT OR Apache-2.0' 7 | description = """ 8 | Hack for the compiler's own build system 9 | """ 10 | edition = "2024" 11 | 12 | [lib] 13 | path = "lib.rs" 14 | test = false 15 | bench = false 16 | doc = false 17 | 18 | [dependencies] 19 | core = { path = "../core", public = true } 20 | compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = [ 21 | "compiler-builtins", 22 | ] } 23 | -------------------------------------------------------------------------------- /library/std/src/sys/fd/mod.rs: -------------------------------------------------------------------------------- 1 | //! Platform-dependent file descriptor abstraction. 2 | 3 | #![forbid(unsafe_op_in_unsafe_fn)] 4 | 5 | cfg_select! { 6 | target_family = "unix" => { 7 | mod unix; 8 | pub use unix::*; 9 | } 10 | target_os = "hermit" => { 11 | mod hermit; 12 | pub use hermit::*; 13 | } 14 | all(target_vendor = "fortanix", target_env = "sgx") => { 15 | mod sgx; 16 | pub use sgx::*; 17 | } 18 | target_os = "wasi" => { 19 | mod wasi; 20 | pub use wasi::*; 21 | } 22 | _ => {} 23 | } 24 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y --no-install-recommends \ 5 | gcc libc6-dev qemu-user-static ca-certificates \ 6 | gcc-loongarch64-linux-gnu libc6-dev-loong64-cross 7 | 8 | 9 | ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER=loongarch64-linux-gnu-gcc \ 10 | CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-loongarch64-static -cpu max -L /usr/loongarch64-linux-gnu" \ 11 | OBJDUMP=loongarch64-linux-gnu-objdump \ 12 | STDARCH_TEST_SKIP_FEATURE=frecipe 13 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/wasm32-wasip1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | RUN apt-get update -y && apt-get install -y --no-install-recommends \ 5 | ca-certificates \ 6 | curl \ 7 | xz-utils \ 8 | clang 9 | 10 | ENV VERSION=v34.0.1 11 | 12 | RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/${VERSION}/wasmtime-${VERSION}-x86_64-linux.tar.xz | tar xJf - 13 | ENV PATH=$PATH:/wasmtime-${VERSION}-x86_64-linux 14 | 15 | ENV CARGO_TARGET_WASM32_WASIP1_RUNNER="wasmtime --dir /checkout/target/wasm32-wasip1/release/deps::." 16 | -------------------------------------------------------------------------------- /library/alloc/src/collections/btree/borrow/tests.rs: -------------------------------------------------------------------------------- 1 | use super::DormantMutRef; 2 | 3 | #[test] 4 | fn test_borrow() { 5 | let mut data = 1; 6 | let mut stack = vec![]; 7 | let mut rr = &mut data; 8 | for factor in [2, 3, 7].iter() { 9 | let (r, dormant_r) = DormantMutRef::new(rr); 10 | rr = r; 11 | assert_eq!(*rr, 1); 12 | stack.push((factor, dormant_r)); 13 | } 14 | while let Some((factor, dormant_r)) = stack.pop() { 15 | let r = unsafe { dormant_r.awaken() }; 16 | *r *= factor; 17 | } 18 | assert_eq!(data, 42); 19 | } 20 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/run-extensive.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | echo "Tests to run: '$TO_TEST'" 6 | 7 | if [ -z "$TO_TEST" ]; then 8 | echo "No tests to run, exiting." 9 | exit 10 | fi 11 | 12 | set -x 13 | 14 | test_cmd=( 15 | cargo test 16 | --package libm-test 17 | --features "build-mpfr,libm/unstable,libm/force-soft-floats" 18 | --profile release-checked 19 | ) 20 | 21 | # Run the non-extensive tests first to catch any easy failures 22 | "${test_cmd[@]}" -- "$TO_TEST" 23 | 24 | LIBM_EXTENSIVE_TESTS="$TO_TEST" "${test_cmd[@]}" -- extensive 25 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/int/bswap.rs: -------------------------------------------------------------------------------- 1 | intrinsics! { 2 | #[maybe_use_optimized_c_shim] 3 | /// Swaps bytes in 32-bit number 4 | pub extern "C" fn __bswapsi2(x: u32) -> u32 { 5 | x.swap_bytes() 6 | } 7 | 8 | #[maybe_use_optimized_c_shim] 9 | /// Swaps bytes in 64-bit number 10 | pub extern "C" fn __bswapdi2(x: u64) -> u64 { 11 | x.swap_bytes() 12 | } 13 | 14 | #[maybe_use_optimized_c_shim] 15 | /// Swaps bytes in 128-bit number 16 | pub extern "C" fn __bswapti2(x: u128) -> u128 { 17 | x.swap_bytes() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/proc_macro/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "proc_macro" 3 | version = "0.0.0" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | std = { path = "../std" } 8 | # Workaround: when documenting this crate rustdoc will try to load crate named 9 | # `core` when resolving doc links. Without this line a different `core` will be 10 | # loaded from sysroot causing duplicate lang items and other similar errors. 11 | core = { path = "../core" } 12 | rustc-literal-escaper = { version = "0.0.5", features = ["rustc-dep-of-std"] } 13 | 14 | [features] 15 | default = ["rustc-dep-of-std"] 16 | rustc-dep-of-std = [] 17 | -------------------------------------------------------------------------------- /library/std/src/sync/mpmc/tests.rs: -------------------------------------------------------------------------------- 1 | // Ensure that thread_local init with `const { 0 }` still has unique address at run-time 2 | #[test] 3 | fn waker_current_thread_id() { 4 | let first = super::waker::current_thread_id(); 5 | let t = crate::thread::spawn(move || { 6 | let second = super::waker::current_thread_id(); 7 | assert_ne!(first, second); 8 | assert_eq!(second, super::waker::current_thread_id()); 9 | }); 10 | 11 | assert_eq!(first, super::waker::current_thread_id()); 12 | t.join().unwrap(); 13 | assert_eq!(first, super::waker::current_thread_id()); 14 | } 15 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/powerpc-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \ 6 | qemu-system-ppc make file 7 | 8 | ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ 9 | CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -cpu mpc8610 -L /usr/powerpc-linux-gnu" \ 10 | CC=powerpc-linux-gnu-gcc \ 11 | OBJDUMP=powerpc-linux-gnu-objdump \ 12 | STDARCH_TEST_SKIP_FEATURE=vsx 13 | -------------------------------------------------------------------------------- /library/stdarch/crates/intrinsic-test/src/arm/argument.rs: -------------------------------------------------------------------------------- 1 | use crate::arm::intrinsic::ArmIntrinsicType; 2 | use crate::common::argument::Argument; 3 | 4 | // This functionality is present due to the nature 5 | // of how intrinsics are defined in the JSON source 6 | // of ARM intrinsics. 7 | impl Argument { 8 | pub fn type_and_name_from_c(arg: &str) -> (&str, &str) { 9 | let split_index = arg 10 | .rfind([' ', '*']) 11 | .expect("Couldn't split type and argname"); 12 | 13 | (arg[..split_index + 1].trim_end(), &arg[split_index + 1..]) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/aarch64.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused_imports)] 2 | 3 | use core::intrinsics; 4 | 5 | intrinsics! { 6 | #[unsafe(naked)] 7 | #[cfg(target_os = "uefi")] 8 | pub unsafe extern "custom" fn __chkstk() { 9 | core::arch::naked_asm!( 10 | ".p2align 2", 11 | "lsl x16, x15, #4", 12 | "mov x17, sp", 13 | "1:", 14 | "sub x17, x17, 4096", 15 | "subs x16, x16, 4096", 16 | "ldr xzr, [x17]", 17 | "b.gt 1b", 18 | "ret", 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /library/std/src/sys/thread_local/key/sgx.rs: -------------------------------------------------------------------------------- 1 | use crate::sys::pal::abi::tls::{Key as AbiKey, Tls}; 2 | 3 | pub type Key = usize; 4 | 5 | #[inline] 6 | pub fn create(dtor: Option) -> Key { 7 | Tls::create(dtor).as_usize() 8 | } 9 | 10 | #[inline] 11 | pub unsafe fn set(key: Key, value: *mut u8) { 12 | Tls::set(AbiKey::from_usize(key), value) 13 | } 14 | 15 | #[inline] 16 | pub unsafe fn get(key: Key) -> *mut u8 { 17 | Tls::get(AbiKey::from_usize(key)) 18 | } 19 | 20 | #[inline] 21 | pub unsafe fn destroy(key: Key) { 22 | Tls::destroy(AbiKey::from_usize(key)) 23 | } 24 | -------------------------------------------------------------------------------- /library/std/src/os/xous/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "rust1", since = "1.0.0")] 2 | #![doc(cfg(target_os = "xous"))] 3 | #![forbid(unsafe_op_in_unsafe_fn)] 4 | 5 | pub mod ffi; 6 | 7 | #[stable(feature = "rust1", since = "1.0.0")] 8 | pub mod services; 9 | 10 | /// A prelude for conveniently writing platform-specific code. 11 | /// 12 | /// Includes all extension traits, and some important type definitions. 13 | #[stable(feature = "rust1", since = "1.0.0")] 14 | pub mod prelude { 15 | #[doc(no_inline)] 16 | #[stable(feature = "rust1", since = "1.0.0")] 17 | pub use super::ffi::{OsStrExt, OsStringExt}; 18 | } 19 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/sgx/waitqueue/spin_mutex/tests.rs: -------------------------------------------------------------------------------- 1 | #![allow(deprecated)] 2 | 3 | use super::*; 4 | use crate::sync::Arc; 5 | use crate::thread; 6 | use crate::time::Duration; 7 | 8 | #[test] 9 | fn sleep() { 10 | let mutex = Arc::new(SpinMutex::::default()); 11 | let mutex2 = mutex.clone(); 12 | let guard = mutex.lock(); 13 | let t1 = thread::spawn(move || { 14 | *mutex2.lock() = 1; 15 | }); 16 | 17 | thread::sleep(Duration::from_millis(50)); 18 | 19 | assert_eq!(*guard, 0); 20 | drop(guard); 21 | t1.join().unwrap(); 22 | assert_eq!(*mutex.lock(), 1); 23 | } 24 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | gcc \ 4 | g++ \ 5 | ca-certificates \ 6 | libc6-dev \ 7 | gcc-arm-linux-gnueabihf \ 8 | g++-arm-linux-gnueabihf \ 9 | libc6-dev-armhf-cross \ 10 | qemu-user \ 11 | make \ 12 | file \ 13 | clang \ 14 | lld 15 | ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ 16 | CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -cpu max -L /usr/arm-linux-gnueabihf" \ 17 | OBJDUMP=arm-linux-gnueabihf-objdump 18 | -------------------------------------------------------------------------------- /library/test/src/helpers/concurrency.rs: -------------------------------------------------------------------------------- 1 | //! Helper module which helps to determine amount of threads to be used 2 | //! during tests execution. 3 | 4 | use std::num::NonZero; 5 | use std::{env, thread}; 6 | 7 | pub(crate) fn get_concurrency() -> usize { 8 | if let Ok(value) = env::var("RUST_TEST_THREADS") { 9 | match value.parse::>().ok() { 10 | Some(n) => n.get(), 11 | _ => panic!("RUST_TEST_THREADS is `{value}`, should be a positive integer."), 12 | } 13 | } else { 14 | thread::available_parallelism().map(|n| n.get()).unwrap_or(1) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/k_expo2f.rs: -------------------------------------------------------------------------------- 1 | use super::expf; 2 | 3 | /* k is such that k*ln2 has minimal relative error and x - kln2 > log(FLT_MIN) */ 4 | const K: i32 = 235; 5 | 6 | /* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */ 7 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 8 | pub(crate) fn k_expo2f(x: f32) -> f32 { 9 | let k_ln2 = f32::from_bits(0x4322e3bc); 10 | /* note that k is odd and scale*scale overflows */ 11 | let scale = f32::from_bits(((0x7f + K / 2) as u32) << 23); 12 | /* exp(x - k ln2) * 2**(k-1) */ 13 | expf(x - k_ln2) * scale * scale 14 | } 15 | -------------------------------------------------------------------------------- /library/portable-simd/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Request an addition to the core::simd API 4 | labels: C-feature-request 5 | --- 6 | 15 | -------------------------------------------------------------------------------- /library/coretests/tests/panic/location/file_c.rs: -------------------------------------------------------------------------------- 1 | // Used for test super::location_{ord, eq}. Must be in a dedicated file. 2 | 3 | // This is used for testing column ordering of Location, hence this ugly one-liner. 4 | // We must fmt skip the entire containing module or else tidy will still complain. 5 | #[rustfmt::skip] 6 | mod no_fmt { 7 | use core::panic::Location; 8 | pub const fn one() -> &'static Location<'static> { Location::caller() } pub const fn two() -> &'static Location<'static> { Location::caller() } pub const fn three() -> &'static Location<'static> { Location::caller() } 9 | } 10 | 11 | pub use no_fmt::*; 12 | -------------------------------------------------------------------------------- /library/std/src/sys/net/connection/socket/tests.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | use crate::collections::HashMap; 3 | 4 | #[test] 5 | fn no_lookup_host_duplicates() { 6 | let mut addrs = HashMap::new(); 7 | let lh = match LookupHost::try_from(("localhost", 0)) { 8 | Ok(lh) => lh, 9 | Err(e) => panic!("couldn't resolve `localhost`: {e}"), 10 | }; 11 | for sa in lh { 12 | *addrs.entry(sa).or_insert(0) += 1; 13 | } 14 | assert_eq!( 15 | addrs.iter().filter(|&(_, &v)| v > 1).collect::>(), 16 | vec![], 17 | "There should be no duplicate localhost entries" 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/powerpc/mod.rs: -------------------------------------------------------------------------------- 1 | //! PowerPC intrinsics 2 | 3 | pub(crate) mod macros; 4 | 5 | mod altivec; 6 | #[unstable(feature = "stdarch_powerpc", issue = "111145")] 7 | pub use self::altivec::*; 8 | 9 | mod vsx; 10 | #[unstable(feature = "stdarch_powerpc", issue = "111145")] 11 | pub use self::vsx::*; 12 | 13 | #[cfg(test)] 14 | use stdarch_test::assert_instr; 15 | 16 | /// Generates the trap instruction `TRAP` 17 | #[cfg_attr(test, assert_instr(trap))] 18 | #[inline] 19 | #[unstable(feature = "stdarch_powerpc", issue = "111145")] 20 | pub unsafe fn trap() -> ! { 21 | crate::intrinsics::abort() 22 | } 23 | -------------------------------------------------------------------------------- /library/core/src/slice/specialize.rs: -------------------------------------------------------------------------------- 1 | pub(super) trait SpecFill { 2 | fn spec_fill(&mut self, value: T); 3 | } 4 | 5 | impl SpecFill for [T] { 6 | default fn spec_fill(&mut self, value: T) { 7 | if let Some((last, elems)) = self.split_last_mut() { 8 | for el in elems { 9 | el.clone_from(&value); 10 | } 11 | 12 | *last = value 13 | } 14 | } 15 | } 16 | 17 | impl SpecFill for [T] { 18 | fn spec_fill(&mut self, value: T) { 19 | for item in self.iter_mut() { 20 | *item = value; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/stdarch/crates/core_arch/src/mips/mod.rs: -------------------------------------------------------------------------------- 1 | //! MIPS 2 | 3 | // Building this module (even if unused) for non-fp64 targets fails with an LLVM 4 | // error. 5 | #[cfg(target_feature = "fp64")] 6 | mod msa; 7 | #[cfg(target_feature = "fp64")] 8 | #[unstable(feature = "stdarch_mips", issue = "111198")] 9 | pub use self::msa::*; 10 | 11 | #[cfg(test)] 12 | use stdarch_test::assert_instr; 13 | 14 | /// Generates the trap instruction `BREAK` 15 | #[cfg_attr(test, assert_instr(break))] 16 | #[inline] 17 | #[unstable(feature = "stdarch_mips", issue = "111198")] 18 | pub unsafe fn break_() -> ! { 19 | crate::intrinsics::abort() 20 | } 21 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/ldexp.rs: -------------------------------------------------------------------------------- 1 | #[cfg(f16_enabled)] 2 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 3 | pub fn ldexpf16(x: f16, n: i32) -> f16 { 4 | super::scalbnf16(x, n) 5 | } 6 | 7 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 8 | pub fn ldexpf(x: f32, n: i32) -> f32 { 9 | super::scalbnf(x, n) 10 | } 11 | 12 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 13 | pub fn ldexp(x: f64, n: i32) -> f64 { 14 | super::scalbn(x, n) 15 | } 16 | 17 | #[cfg(f128_enabled)] 18 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 19 | pub fn ldexpf128(x: f128, n: i32) -> f128 { 20 | super::scalbnf128(x, n) 21 | } 22 | -------------------------------------------------------------------------------- /library/std/src/os/hermit/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "rust1", since = "1.0.0")] 2 | #![deny(unsafe_op_in_unsafe_fn)] 3 | 4 | #[allow(unused_extern_crates)] 5 | #[stable(feature = "rust1", since = "1.0.0")] 6 | pub extern crate hermit_abi; 7 | 8 | pub mod ffi; 9 | pub mod io; 10 | 11 | /// A prelude for conveniently writing platform-specific code. 12 | /// 13 | /// Includes all extension traits, and some important type definitions. 14 | #[stable(feature = "rust1", since = "1.0.0")] 15 | pub mod prelude { 16 | #[doc(no_inline)] 17 | #[stable(feature = "rust1", since = "1.0.0")] 18 | pub use super::ffi::{OsStrExt, OsStringExt}; 19 | } 20 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/aarch64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | gcc \ 4 | g++ \ 5 | ca-certificates \ 6 | libc6-dev \ 7 | gcc-aarch64-linux-gnu \ 8 | g++-aarch64-linux-gnu \ 9 | libc6-dev-arm64-cross \ 10 | qemu-user \ 11 | make \ 12 | file \ 13 | clang \ 14 | lld 15 | 16 | ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ 17 | CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -cpu max -L /usr/aarch64-linux-gnu" \ 18 | OBJDUMP=aarch64-linux-gnu-objdump \ 19 | STDARCH_TEST_SKIP_FEATURE=tme 20 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/expo2.rs: -------------------------------------------------------------------------------- 1 | use super::{combine_words, exp}; 2 | 3 | /* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */ 4 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 5 | pub(crate) fn expo2(x: f64) -> f64 { 6 | /* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */ 7 | const K: i32 = 2043; 8 | let kln2 = f64::from_bits(0x40962066151add8b); 9 | 10 | /* note that k is odd and scale*scale overflows */ 11 | let scale = combine_words(((0x3ff + K / 2) as u32) << 20, 0); 12 | /* exp(x - k ln2) * 2**(k-1) */ 13 | exp(x - kln2) * scale * scale 14 | } 15 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/k_expo2.rs: -------------------------------------------------------------------------------- 1 | use super::exp; 2 | 3 | /* k is such that k*ln2 has minimal relative error and x - kln2 > log(FLT_MIN) */ 4 | const K: i32 = 2043; 5 | 6 | /* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */ 7 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 8 | pub(crate) fn k_expo2(x: f64) -> f64 { 9 | let k_ln2 = f64::from_bits(0x40962066151add8b); 10 | /* note that k is odd and scale*scale overflows */ 11 | let scale = f64::from_bits(((((0x3ff + K / 2) as u32) << 20) as u64) << 32); 12 | /* exp(x - k ln2) * 2**(k-1) */ 13 | exp(x - k_ln2) * scale * scale 14 | } 15 | -------------------------------------------------------------------------------- /library/core/src/num/flt2dec/estimator.rs: -------------------------------------------------------------------------------- 1 | //! The exponent estimator. 2 | 3 | /// Finds `k_0` such that `10^(k_0-1) < mant * 2^exp <= 10^(k_0+1)`. 4 | /// 5 | /// This is used to approximate `k = ceil(log_10 (mant * 2^exp))`; 6 | /// the true `k` is either `k_0` or `k_0+1`. 7 | #[doc(hidden)] 8 | pub fn estimate_scaling_factor(mant: u64, exp: i16) -> i16 { 9 | // 2^(nbits-1) < mant <= 2^nbits if mant > 0 10 | let nbits = 64 - (mant - 1).leading_zeros() as i64; 11 | // 1292913986 = floor(2^32 * log_10 2) 12 | // therefore this always underestimates (or is exact), but not much. 13 | (((nbits + exp as i64) * 1292913986) >> 32) as i16 14 | } 15 | -------------------------------------------------------------------------------- /library/std/src/sys/args/xous.rs: -------------------------------------------------------------------------------- 1 | pub use super::common::Args; 2 | use crate::sys::pal::os::get_application_parameters; 3 | use crate::sys::pal::os::params::ArgumentList; 4 | 5 | pub fn args() -> Args { 6 | let Some(params) = get_application_parameters() else { 7 | return Args::new(vec![]); 8 | }; 9 | 10 | for param in params { 11 | if let Ok(args) = ArgumentList::try_from(¶m) { 12 | let mut parsed_args = vec![]; 13 | for arg in args { 14 | parsed_args.push(arg.into()); 15 | } 16 | return Args::new(parsed_args); 17 | } 18 | } 19 | Args::new(vec![]) 20 | } 21 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/miri.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eux 3 | 4 | # We need Tree Borrows as some of our raw pointer patterns are not 5 | # compatible with Stacked Borrows. 6 | export MIRIFLAGS="-Zmiri-tree-borrows" 7 | 8 | # One target that sets `mem-unaligned` and one that does not, 9 | # and a big-endian target. 10 | targets=( 11 | x86_64-unknown-linux-gnu 12 | armv7-unknown-linux-gnueabihf 13 | s390x-unknown-linux-gnu 14 | ) 15 | for target in "${targets[@]}"; do 16 | # Only run the `mem` tests to avoid this taking too long. 17 | cargo miri test --manifest-path builtins-test/Cargo.toml --features no-asm --target "$target" -- mem 18 | done 19 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/frexp.rs: -------------------------------------------------------------------------------- 1 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 2 | pub fn frexp(x: f64) -> (f64, i32) { 3 | let mut y = x.to_bits(); 4 | let ee = ((y >> 52) & 0x7ff) as i32; 5 | 6 | if ee == 0 { 7 | if x != 0.0 { 8 | let x1p64 = f64::from_bits(0x43f0000000000000); 9 | let (x, e) = frexp(x * x1p64); 10 | return (x, e - 64); 11 | } 12 | return (x, 0); 13 | } else if ee == 0x7ff { 14 | return (x, 0); 15 | } 16 | 17 | let e = ee - 0x3fe; 18 | y &= 0x800fffffffffffff; 19 | y |= 0x3fe0000000000000; 20 | return (f64::from_bits(y), e); 21 | } 22 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/frexpf.rs: -------------------------------------------------------------------------------- 1 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 2 | pub fn frexpf(x: f32) -> (f32, i32) { 3 | let mut y = x.to_bits(); 4 | let ee: i32 = ((y >> 23) & 0xff) as i32; 5 | 6 | if ee == 0 { 7 | if x != 0.0 { 8 | let x1p64 = f32::from_bits(0x5f800000); 9 | let (x, e) = frexpf(x * x1p64); 10 | return (x, e - 64); 11 | } else { 12 | return (x, 0); 13 | } 14 | } else if ee == 0xff { 15 | return (x, 0); 16 | } 17 | 18 | let e = ee - 0x7e; 19 | y &= 0x807fffff; 20 | y |= 0x3f000000; 21 | (f32::from_bits(y), e) 22 | } 23 | -------------------------------------------------------------------------------- /library/std/src/sys/sync/condvar/no_threads.rs: -------------------------------------------------------------------------------- 1 | use crate::sys::sync::Mutex; 2 | use crate::thread::sleep; 3 | use crate::time::Duration; 4 | 5 | pub struct Condvar {} 6 | 7 | impl Condvar { 8 | #[inline] 9 | pub const fn new() -> Condvar { 10 | Condvar {} 11 | } 12 | 13 | #[inline] 14 | pub fn notify_one(&self) {} 15 | 16 | #[inline] 17 | pub fn notify_all(&self) {} 18 | 19 | pub unsafe fn wait(&self, _mutex: &Mutex) { 20 | panic!("condvar wait not supported") 21 | } 22 | 23 | pub unsafe fn wait_timeout(&self, _mutex: &Mutex, dur: Duration) -> bool { 24 | sleep(dur); 25 | false 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /library/stdarch/crates/intrinsic-test/src/common/indentation.rs: -------------------------------------------------------------------------------- 1 | //! Basic code formatting tools. 2 | //! 3 | //! We don't need perfect formatting for the generated tests, but simple indentation can make 4 | //! debugging a lot easier. 5 | 6 | #[derive(Copy, Clone, Debug, Default)] 7 | pub struct Indentation(u32); 8 | 9 | impl Indentation { 10 | pub fn nested(self) -> Self { 11 | Self(self.0 + 1) 12 | } 13 | } 14 | 15 | impl std::fmt::Display for Indentation { 16 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 17 | for _ in 0..self.0 { 18 | write!(f, " ")?; 19 | } 20 | Ok(()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /library/compiler-builtins/PUBLISHING.md: -------------------------------------------------------------------------------- 1 | # Publishing to crates.io 2 | 3 | Publishing `compiler-builtins` to crates.io takes a few steps unfortunately. 4 | It's not great, but it works for now. PRs to improve this process would be 5 | greatly appreciated! 6 | 7 | 1. Make sure you've got a clean working tree and it's updated with the latest 8 | changes on `master` 9 | 2. Edit `Cargo.toml` to bump the version number 10 | 3. Commit this change 11 | 4. Run `git tag` to create a tag for this version 12 | 5. Delete the `libm/Cargo.toml` file 13 | 6. Run `cargo +nightly publish` 14 | 7. Push the tag 15 | 8. Push the commit 16 | 9. Undo changes to `Cargo.toml` and the `libm` submodule 17 | -------------------------------------------------------------------------------- /library/core/src/ffi/c_char.md: -------------------------------------------------------------------------------- 1 | Equivalent to C's `char` type. 2 | 3 | [C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. On modern architectures this type will always be either [`i8`] or [`u8`], as they use byte-addressed memory with 8-bit bytes. 4 | 5 | C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with the character `'\0'`. See `CStr` for more information. 6 | 7 | [C's `char` type]: https://en.wikipedia.org/wiki/C_data_types#Basic_types 8 | [Rust's `char` type]: char 9 | -------------------------------------------------------------------------------- /library/std/src/sys/personality/dwarf/tests.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | 3 | #[test] 4 | fn dwarf_reader() { 5 | let encoded: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 0xE5, 0x8E, 0x26, 0x9B, 0xF1, 0x59, 0xFF, 0xFF]; 6 | 7 | let mut reader = DwarfReader::new(encoded.as_ptr()); 8 | 9 | unsafe { 10 | assert!(reader.read::() == u8::to_be(1u8)); 11 | assert!(reader.read::() == u16::to_be(0x0203)); 12 | assert!(reader.read::() == u32::to_be(0x04050607)); 13 | 14 | assert!(reader.read_uleb128() == 624485); 15 | assert!(reader.read_sleb128() == -624485); 16 | 17 | assert!(reader.read::() == i8::to_be(-1)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \ 6 | file make 7 | 8 | # Work around qemu triggering a sigill on vec_subs if the cpu target is not defined. 9 | ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ 10 | CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -cpu power11 -L /usr/powerpc64le-linux-gnu" \ 11 | CC=powerpc64le-linux-gnu-gcc \ 12 | OBJDUMP=powerpc64le-linux-gnu-objdump 13 | -------------------------------------------------------------------------------- /library/coretests/tests/num/float_iter_sum_identity.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn f32_ref() { 3 | let x: f32 = -0.0; 4 | let still_x: f32 = [x].iter().sum(); 5 | assert_eq!(1. / x, 1. / still_x) 6 | } 7 | 8 | #[test] 9 | fn f32_own() { 10 | let x: f32 = -0.0; 11 | let still_x: f32 = [x].into_iter().sum(); 12 | assert_eq!(1. / x, 1. / still_x) 13 | } 14 | 15 | #[test] 16 | fn f64_ref() { 17 | let x: f64 = -0.0; 18 | let still_x: f64 = [x].iter().sum(); 19 | assert_eq!(1. / x, 1. / still_x) 20 | } 21 | 22 | #[test] 23 | fn f64_own() { 24 | let x: f64 = -0.0; 25 | let still_x: f64 = [x].into_iter().sum(); 26 | assert_eq!(1. / x, 1. / still_x) 27 | } 28 | -------------------------------------------------------------------------------- /library/panic_abort/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "panic_abort" 3 | version = "0.0.0" 4 | license = "MIT OR Apache-2.0" 5 | repository = "https://github.com/rust-lang/rust.git" 6 | description = "Implementation of Rust panics via process aborts" 7 | edition = "2024" 8 | 9 | [lib] 10 | test = false 11 | bench = false 12 | doc = false 13 | 14 | [dependencies] 15 | core = { path = "../rustc-std-workspace-core", package = "rustc-std-workspace-core" } 16 | 17 | [target.'cfg(target_os = "android")'.dependencies] 18 | libc = { version = "0.2", default-features = false } 19 | 20 | [target.'cfg(any(target_os = "android", target_os = "zkvm"))'.dependencies] 21 | alloc = { path = "../alloc" } 22 | -------------------------------------------------------------------------------- /library/std/src/sys/anonymous_pipe/windows.rs: -------------------------------------------------------------------------------- 1 | use crate::os::windows::io::FromRawHandle; 2 | use crate::sys::c; 3 | use crate::sys::handle::Handle; 4 | use crate::{io, ptr}; 5 | 6 | pub type AnonPipe = Handle; 7 | 8 | pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> { 9 | let mut read_pipe = c::INVALID_HANDLE_VALUE; 10 | let mut write_pipe = c::INVALID_HANDLE_VALUE; 11 | 12 | let ret = unsafe { c::CreatePipe(&mut read_pipe, &mut write_pipe, ptr::null_mut(), 0) }; 13 | 14 | if ret == 0 { 15 | Err(io::Error::last_os_error()) 16 | } else { 17 | unsafe { Ok((Handle::from_raw_handle(read_pipe), Handle::from_raw_handle(write_pipe))) } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/hexagon/umodsi3.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | FUNCTION_BEGIN __hexagon_umodsi3 4 | { 5 | r2 = cl0(r0) 6 | r3 = cl0(r1) 7 | p0 = cmp.gtu(r1,r0) 8 | } 9 | { 10 | r2 = sub(r3,r2) 11 | if (p0) jumpr r31 12 | } 13 | { 14 | loop0(1f,r2) 15 | p1 = cmp.eq(r2,#0) 16 | r2 = lsl(r1,r2) 17 | } 18 | .falign 19 | 1: 20 | { 21 | p0 = cmp.gtu(r2,r0) 22 | if (!p0.new) r0 = sub(r0,r2) 23 | r2 = lsr(r2,#1) 24 | if (p1) r1 = #0 25 | }:endloop0 26 | { 27 | p0 = cmp.gtu(r2,r0) 28 | if (!p0.new) r0 = sub(r0,r1) 29 | jumpr r31 30 | } 31 | FUNCTION_END __hexagon_umodsi3 32 | 33 | .globl __qdsp_umodsi3 34 | .set __qdsp_umodsi3, __hexagon_umodsi3 35 | -------------------------------------------------------------------------------- /library/coretests/benches/array.rs: -------------------------------------------------------------------------------- 1 | use test::{Bencher, black_box}; 2 | 3 | macro_rules! map_array { 4 | ($func_name:ident, $start_item: expr, $map_item: expr, $arr_size: expr) => { 5 | #[bench] 6 | fn $func_name(b: &mut Bencher) { 7 | let arr = [$start_item; $arr_size]; 8 | b.iter(|| black_box(arr).map(|_| black_box($map_item))); 9 | } 10 | }; 11 | } 12 | 13 | map_array!(map_8byte_8byte_8, 0u64, 1u64, 80); 14 | map_array!(map_8byte_8byte_64, 0u64, 1u64, 640); 15 | map_array!(map_8byte_8byte_256, 0u64, 1u64, 2560); 16 | 17 | map_array!(map_8byte_256byte_256, 0u64, [0u64; 4], 2560); 18 | map_array!(map_256byte_8byte_256, [0u64; 4], 0u64, 2560); 19 | -------------------------------------------------------------------------------- /library/std/src/os/solid/mod.rs: -------------------------------------------------------------------------------- 1 | #![stable(feature = "rust1", since = "1.0.0")] 2 | #![forbid(unsafe_op_in_unsafe_fn)] 3 | 4 | pub mod ffi; 5 | pub mod io; 6 | 7 | /// A prelude for conveniently writing platform-specific code. 8 | /// 9 | /// Includes all extension traits, and some important type definitions. 10 | #[stable(feature = "rust1", since = "1.0.0")] 11 | pub mod prelude { 12 | #[doc(no_inline)] 13 | #[stable(feature = "rust1", since = "1.0.0")] 14 | pub use super::ffi::{OsStrExt, OsStringExt}; 15 | #[doc(no_inline)] 16 | #[stable(feature = "rust1", since = "1.0.0")] 17 | pub use super::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; 18 | } 19 | -------------------------------------------------------------------------------- /library/stdarch/examples/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stdarch_examples" 3 | version = "0.0.0" 4 | authors = [ 5 | "Alex Crichton ", 6 | "Andrew Gallant ", 7 | "Gonzalo Brito Gadeschi ", 8 | ] 9 | description = "Examples of the stdarch crate." 10 | edition = "2024" 11 | default-run = "hex" 12 | 13 | [dependencies] 14 | core_arch = { path = "../crates/core_arch" } 15 | quickcheck = "1.0" 16 | rand = "0.8" 17 | 18 | [[bin]] 19 | name = "hex" 20 | path = "hex.rs" 21 | 22 | [[bin]] 23 | name = "connect5" 24 | path = "connect5.rs" 25 | 26 | [[example]] 27 | name = "wasm" 28 | crate-type = ["cdylib"] 29 | path = "wasm.rs" 30 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/arm-unknown-linux-gnueabi/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-arm-linux-gnueabi libc6-dev-armel-cross qemu-user-static 8 | 9 | ENV TOOLCHAIN_PREFIX=arm-linux-gnueabi- 10 | ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER="$TOOLCHAIN_PREFIX"gcc \ 11 | CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_RUNNER=qemu-arm-static \ 12 | AR_arm_unknown_linux_gnueabi="$TOOLCHAIN_PREFIX"ar \ 13 | CC_arm_unknown_linux_gnueabi="$TOOLCHAIN_PREFIX"gcc \ 14 | QEMU_LD_PREFIX=/usr/arm-linux-gnueabi \ 15 | RUST_TEST_THREADS=1 16 | -------------------------------------------------------------------------------- /library/alloctests/tests/c_str.rs: -------------------------------------------------------------------------------- 1 | use std::borrow::Cow::{Borrowed, Owned}; 2 | use std::ffi::CStr; 3 | use std::os::raw::c_char; 4 | 5 | #[test] 6 | fn to_str() { 7 | let data = b"123\xE2\x80\xA6\0"; 8 | let ptr = data.as_ptr() as *const c_char; 9 | unsafe { 10 | assert_eq!(CStr::from_ptr(ptr).to_str(), Ok("123…")); 11 | assert_eq!(CStr::from_ptr(ptr).to_string_lossy(), Borrowed("123…")); 12 | } 13 | let data = b"123\xE2\0"; 14 | let ptr = data.as_ptr() as *const c_char; 15 | unsafe { 16 | assert!(CStr::from_ptr(ptr).to_str().is_err()); 17 | assert_eq!(CStr::from_ptr(ptr).to_string_lossy(), Owned::(format!("123\u{FFFD}"))); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/coretests/tests/iter/adapters/by_ref_sized.rs: -------------------------------------------------------------------------------- 1 | use core::iter::*; 2 | 3 | #[test] 4 | fn test_iterator_by_ref_sized() { 5 | let a = ['a', 'b', 'c', 'd']; 6 | 7 | let mut s = String::from("Z"); 8 | let mut it = a.iter().copied(); 9 | ByRefSized(&mut it).take(2).for_each(|x| s.push(x)); 10 | assert_eq!(s, "Zab"); 11 | ByRefSized(&mut it).fold((), |(), x| s.push(x)); 12 | assert_eq!(s, "Zabcd"); 13 | 14 | let mut s = String::from("Z"); 15 | let mut it = a.iter().copied(); 16 | ByRefSized(&mut it).rev().take(2).for_each(|x| s.push(x)); 17 | assert_eq!(s, "Zdc"); 18 | ByRefSized(&mut it).rfold((), |(), x| s.push(x)); 19 | assert_eq!(s, "Zdcba"); 20 | } 21 | -------------------------------------------------------------------------------- /library/std/tests/seq-compare.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn seq_compare() { 3 | assert!("hello".to_string() < "hellr".to_string()); 4 | assert!("hello ".to_string() > "hello".to_string()); 5 | assert!("hello".to_string() != "there".to_string()); 6 | assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]); 7 | assert!(vec![1, 2, 3] < vec![1, 2, 3, 4]); 8 | assert!(vec![1, 2, 4, 4] > vec![1, 2, 3, 4]); 9 | assert!(vec![1, 2, 3, 4] < vec![1, 2, 4, 4]); 10 | assert!(vec![1, 2, 3] <= vec![1, 2, 3]); 11 | assert!(vec![1, 2, 3] <= vec![1, 2, 3, 3]); 12 | assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]); 13 | assert_eq!(vec![1, 2, 3], vec![1, 2, 3]); 14 | assert!(vec![1, 2, 3] != vec![1, 1, 3]); 15 | } 16 | -------------------------------------------------------------------------------- /library/stdarch/crates/intrinsic-test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "intrinsic-test" 3 | version = "0.1.0" 4 | authors = ["Jamie Cunliffe ", 5 | "James McGregor ", 8 | "James Barford-Evans " 9 | ] 10 | license = "MIT OR Apache-2.0" 11 | edition = "2024" 12 | 13 | [dependencies] 14 | serde = { version = "1", features = ["derive"] } 15 | serde_json = "1.0" 16 | clap = { version = "4.4", features = ["derive"] } 17 | log = "0.4.11" 18 | pretty_env_logger = "0.5.0" 19 | rayon = "1.5.0" 20 | diff = "0.1.12" 21 | itertools = "0.14.0" 22 | -------------------------------------------------------------------------------- /verifast-proofs/check-verifast-proofs-negative.sh: -------------------------------------------------------------------------------- 1 | set -e -x 2 | 3 | cd alloc 4 | cd collections 5 | cd linked_list.rs-negative 6 | ! verifast -rustc_args "--edition 2021 --cfg test" -skip_specless_fns verified/lib.rs 7 | ! refinement-checker --rustc-args "--edition 2021 --cfg test" original/lib.rs verified/lib.rs 8 | if ! diff ../../../../library/alloc/src/collections/linked_list.rs original/linked_list.rs; then 9 | echo "::error title=Please run verifast-proofs/patch-verifast-proofs.sh::Some VeriFast proofs are out of date; please chdir to verifast-proofs and run patch-verifast-proofs.sh to update them." 10 | false 11 | fi 12 | cd .. 13 | cd .. 14 | cd .. 15 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev qemu-user-static ca-certificates \ 7 | gcc-14-loongarch64-linux-gnu libc6-dev-loong64-cross 8 | 9 | ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER=loongarch64-linux-gnu-gcc-14 \ 10 | CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_RUNNER=qemu-loongarch64-static \ 11 | AR_loongarch64_unknown_linux_gnu=loongarch64-linux-gnu-ar \ 12 | CC_loongarch64_unknown_linux_gnu=loongarch64-linux-gnu-gcc-14 \ 13 | QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu \ 14 | RUST_TEST_THREADS=1 15 | -------------------------------------------------------------------------------- /library/std/src/sys/path/sgx.rs: -------------------------------------------------------------------------------- 1 | use crate::ffi::OsStr; 2 | use crate::io; 3 | use crate::path::{Path, PathBuf, Prefix}; 4 | use crate::sys::unsupported; 5 | 6 | #[inline] 7 | pub fn is_sep_byte(b: u8) -> bool { 8 | b == b'/' 9 | } 10 | 11 | #[inline] 12 | pub fn is_verbatim_sep(b: u8) -> bool { 13 | b == b'/' 14 | } 15 | 16 | pub fn parse_prefix(_: &OsStr) -> Option> { 17 | None 18 | } 19 | 20 | pub const MAIN_SEP_STR: &str = "/"; 21 | pub const MAIN_SEP: char = '/'; 22 | 23 | pub(crate) fn absolute(_path: &Path) -> io::Result { 24 | unsupported() 25 | } 26 | 27 | pub(crate) fn is_absolute(path: &Path) -> bool { 28 | path.has_root() && path.prefix().is_some() 29 | } 30 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static 8 | 9 | ENV TOOLCHAIN_PREFIX=arm-linux-gnueabihf- 10 | ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER="$TOOLCHAIN_PREFIX"gcc \ 11 | CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm-static \ 12 | AR_arm_unknown_linux_gnueabihf="$TOOLCHAIN_PREFIX"ar \ 13 | CC_arm_unknown_linux_gnueabihf="$TOOLCHAIN_PREFIX"gcc \ 14 | QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf \ 15 | RUST_TEST_THREADS=1 16 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/aarch64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-aarch64-linux-gnu m4 make libc6-dev-arm64-cross \ 8 | qemu-user-static 9 | 10 | ENV TOOLCHAIN_PREFIX=aarch64-linux-gnu- 11 | ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="$TOOLCHAIN_PREFIX"gcc \ 12 | CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER=qemu-aarch64-static \ 13 | AR_aarch64_unknown_linux_gnu="$TOOLCHAIN_PREFIX"ar \ 14 | CC_aarch64_unknown_linux_gnu="$TOOLCHAIN_PREFIX"gcc \ 15 | QEMU_LD_PREFIX=/usr/aarch64-linux-gnu \ 16 | RUST_TEST_THREADS=1 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/mips-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-mips-linux-gnu libc6-dev-mips-cross \ 8 | binfmt-support qemu-user-static qemu-system-mips 9 | 10 | ENV TOOLCHAIN_PREFIX=mips-linux-gnu- 11 | ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER="$TOOLCHAIN_PREFIX"gcc \ 12 | CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER=qemu-mips-static \ 13 | AR_mips_unknown_linux_gnu="$TOOLCHAIN_PREFIX"ar \ 14 | CC_mips_unknown_linux_gnu="$TOOLCHAIN_PREFIX"gcc \ 15 | QEMU_LD_PREFIX=/usr/mips-linux-gnu \ 16 | RUST_TEST_THREADS=1 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/mipsel-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-mipsel-linux-gnu libc6-dev-mipsel-cross \ 8 | binfmt-support qemu-user-static 9 | 10 | ENV TOOLCHAIN_PREFIX=mipsel-linux-gnu- 11 | ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER="$TOOLCHAIN_PREFIX"gcc \ 12 | CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER=qemu-mipsel-static \ 13 | AR_mipsel_unknown_linux_gnu="$TOOLCHAIN_PREFIX"ar \ 14 | CC_mipsel_unknown_linux_gnu="$TOOLCHAIN_PREFIX"gcc \ 15 | QEMU_LD_PREFIX=/usr/mipsel-linux-gnu \ 16 | RUST_TEST_THREADS=1 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static 8 | 9 | ENV TOOLCHAIN_PREFIX=arm-linux-gnueabihf- 10 | ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER="$TOOLCHAIN_PREFIX"gcc \ 11 | CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm-static \ 12 | AR_armv7_unknown_linux_gnueabihf="$TOOLCHAIN_PREFIX"ar \ 13 | CC_armv7_unknown_linux_gnueabihf="$TOOLCHAIN_PREFIX"gcc \ 14 | QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf \ 15 | RUST_TEST_THREADS=1 16 | -------------------------------------------------------------------------------- /library/std/src/ffi/c_str.rs: -------------------------------------------------------------------------------- 1 | //! [`CStr`], [`CString`], and related types. 2 | 3 | #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] 4 | pub use alloc::ffi::c_str::FromVecWithNulError; 5 | #[stable(feature = "cstring_into", since = "1.7.0")] 6 | pub use alloc::ffi::c_str::IntoStringError; 7 | #[stable(feature = "rust1", since = "1.0.0")] 8 | pub use alloc::ffi::c_str::{CString, NulError}; 9 | #[stable(feature = "rust1", since = "1.0.0")] 10 | pub use core::ffi::c_str::CStr; 11 | #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] 12 | pub use core::ffi::c_str::FromBytesUntilNulError; 13 | #[stable(feature = "cstr_from_bytes", since = "1.10.0")] 14 | pub use core::ffi::c_str::FromBytesWithNulError; 15 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/powerpc-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev qemu-user-static ca-certificates \ 7 | gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \ 8 | qemu-system-ppc 9 | 10 | ENV TOOLCHAIN_PREFIX=powerpc-linux-gnu- 11 | ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER="$TOOLCHAIN_PREFIX"gcc \ 12 | CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc-static \ 13 | AR_powerpc_unknown_linux_gnu="$TOOLCHAIN_PREFIX"ar \ 14 | CC_powerpc_unknown_linux_gnu="$TOOLCHAIN_PREFIX"gcc \ 15 | QEMU_LD_PREFIX=/usr/powerpc-linux-gnu \ 16 | RUST_TEST_THREADS=1 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/etc/thumbv7em-none-eabi-renamed.json: -------------------------------------------------------------------------------- 1 | { 2 | "abi": "eabi", 3 | "arch": "arm", 4 | "c-enum-min-bits": 8, 5 | "crt-objects-fallback": "false", 6 | "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", 7 | "emit-debug-gdb-scripts": false, 8 | "frame-pointer": "always", 9 | "linker": "rust-lld", 10 | "linker-flavor": "gnu-lld", 11 | "llvm-floatabi": "soft", 12 | "llvm-target": "thumbv7em-none-eabi", 13 | "max-atomic-width": 32, 14 | "metadata": { 15 | "description": "Bare ARMv7E-M", 16 | "host_tools": false, 17 | "std": false, 18 | "tier": 2 19 | }, 20 | "panic-strategy": "abort", 21 | "relocation-model": "static", 22 | "target-pointer-width": 32 23 | } 24 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/autoderef.rs: -------------------------------------------------------------------------------- 1 | // Test that we handle all our "auto-deref" cases correctly. 2 | #![feature(portable_simd)] 3 | use core_simd::simd::f32x4; 4 | 5 | #[cfg(target_arch = "wasm32")] 6 | use wasm_bindgen_test::*; 7 | 8 | #[cfg(target_arch = "wasm32")] 9 | wasm_bindgen_test_configure!(run_in_browser); 10 | 11 | #[test] 12 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] 13 | fn deref() { 14 | let x = f32x4::splat(1.0); 15 | let y = f32x4::splat(2.0); 16 | let a = &x; 17 | let b = &y; 18 | assert_eq!(f32x4::splat(3.0), x + y); 19 | assert_eq!(f32x4::splat(3.0), x + b); 20 | assert_eq!(f32x4::splat(3.0), a + y); 21 | assert_eq!(f32x4::splat(3.0), a + b); 22 | } 23 | -------------------------------------------------------------------------------- /library/std/src/os/raw/mod.rs: -------------------------------------------------------------------------------- 1 | //! Compatibility module for C platform-specific types. Use [`core::ffi`] instead. 2 | 3 | #![stable(feature = "raw_os", since = "1.1.0")] 4 | 5 | #[cfg(test)] 6 | mod tests; 7 | 8 | macro_rules! alias_core_ffi { 9 | ($($t:ident)*) => {$( 10 | #[stable(feature = "raw_os", since = "1.1.0")] 11 | #[doc = include_str!(concat!("../../../../core/src/ffi/", stringify!($t), ".md"))] 12 | #[doc(cfg(all()))] 13 | pub type $t = core::ffi::$t; 14 | )*} 15 | } 16 | 17 | alias_core_ffi! { 18 | c_char c_schar c_uchar 19 | c_short c_ushort 20 | c_int c_uint 21 | c_long c_ulong 22 | c_longlong c_ulonglong 23 | c_float 24 | c_double 25 | c_void 26 | } 27 | -------------------------------------------------------------------------------- /library/std/tests/log-knows-the-names-of-variants-in-std.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | #![allow(dead_code)] 3 | 4 | #[derive(Clone, Debug)] 5 | enum foo { 6 | a(usize), 7 | b(String), 8 | } 9 | 10 | fn check_log(exp: String, v: T) { 11 | assert_eq!(exp, format!("{:?}", v)); 12 | } 13 | 14 | #[test] 15 | fn log_knows_the_names_of_variants_in_std() { 16 | let mut x = Some(foo::a(22)); 17 | let exp = "Some(a(22))".to_string(); 18 | let act = format!("{:?}", x); 19 | assert_eq!(act, exp); 20 | check_log(exp, x); 21 | 22 | x = None; 23 | let exp = "None".to_string(); 24 | let act = format!("{:?}", x); 25 | assert_eq!(act, exp); 26 | check_log(exp, x); 27 | } 28 | -------------------------------------------------------------------------------- /library/coretests/tests/async_iter/mod.rs: -------------------------------------------------------------------------------- 1 | use core::async_iter::{self, AsyncIterator, IntoAsyncIterator}; 2 | use core::pin::pin; 3 | use core::task::Poll; 4 | 5 | #[test] 6 | fn into_async_iter() { 7 | let async_iter = async_iter::from_iter(0..3); 8 | let mut async_iter = pin!(async_iter.into_async_iter()); 9 | 10 | let mut cx = &mut core::task::Context::from_waker(core::task::Waker::noop()); 11 | 12 | assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(0))); 13 | assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(1))); 14 | assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(Some(2))); 15 | assert_eq!(async_iter.as_mut().poll_next(&mut cx), Poll::Ready(None)); 16 | } 17 | -------------------------------------------------------------------------------- /library/std/src/os/wasi/net/mod.rs: -------------------------------------------------------------------------------- 1 | //! WASI-specific networking functionality 2 | 3 | #![unstable(feature = "wasi_ext", issue = "71213")] 4 | 5 | use crate::sys_common::AsInner; 6 | use crate::{io, net}; 7 | 8 | /// WASI-specific extensions to [`std::net::TcpListener`]. 9 | /// 10 | /// [`std::net::TcpListener`]: crate::net::TcpListener 11 | pub trait TcpListenerExt { 12 | /// Accept a socket. 13 | /// 14 | /// This corresponds to the `sock_accept` syscall. 15 | fn sock_accept(&self, flags: u16) -> io::Result; 16 | } 17 | 18 | impl TcpListenerExt for net::TcpListener { 19 | fn sock_accept(&self, flags: u16) -> io::Result { 20 | self.as_inner().as_inner().as_inner().sock_accept(flags) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev qemu-user-static ca-certificates \ 7 | gcc-riscv64-linux-gnu libc6-dev-riscv64-cross \ 8 | qemu-system-riscv64 9 | 10 | ENV TOOLCHAIN_PREFIX=riscv64-linux-gnu- 11 | ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER="$TOOLCHAIN_PREFIX"gcc \ 12 | CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER=qemu-riscv64-static \ 13 | AR_riscv64gc_unknown_linux_gnu="$TOOLCHAIN_PREFIX"ar \ 14 | CC_riscv64gc_unknown_linux_gnu="$TOOLCHAIN_PREFIX"gcc \ 15 | QEMU_LD_PREFIX=/usr/riscv64-linux-gnu \ 16 | RUST_TEST_THREADS=1 17 | -------------------------------------------------------------------------------- /library/std/src/sys/path/mod.rs: -------------------------------------------------------------------------------- 1 | cfg_select! { 2 | target_os = "windows" => { 3 | mod windows; 4 | mod windows_prefix; 5 | pub use windows::*; 6 | } 7 | all(target_vendor = "fortanix", target_env = "sgx") => { 8 | mod sgx; 9 | pub use sgx::*; 10 | } 11 | target_os = "solid_asp3" => { 12 | mod unsupported_backslash; 13 | pub use unsupported_backslash::*; 14 | } 15 | target_os = "uefi" => { 16 | mod uefi; 17 | pub use uefi::*; 18 | } 19 | target_os = "cygwin" => { 20 | mod cygwin; 21 | mod windows_prefix; 22 | pub use cygwin::*; 23 | } 24 | _ => { 25 | mod unix; 26 | pub use unix::*; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /library/std/src/sys/random/zkvm.rs: -------------------------------------------------------------------------------- 1 | use crate::sys::pal::abi; 2 | 3 | pub fn fill_bytes(bytes: &mut [u8]) { 4 | let (pre, words, post) = unsafe { bytes.align_to_mut::() }; 5 | if !words.is_empty() { 6 | unsafe { 7 | abi::sys_rand(words.as_mut_ptr(), words.len()); 8 | } 9 | } 10 | 11 | let mut buf = [0u32; 2]; 12 | let len = (pre.len() + post.len() + size_of::() - 1) / size_of::(); 13 | if len != 0 { 14 | unsafe { abi::sys_rand(buf.as_mut_ptr(), len) }; 15 | } 16 | 17 | let buf = buf.map(u32::to_ne_bytes); 18 | let buf = buf.as_flattened(); 19 | pre.copy_from_slice(&buf[..pre.len()]); 20 | post.copy_from_slice(&buf[pre.len()..pre.len() + post.len()]); 21 | } 22 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/riscv32gc-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | wget xz-utils make file llvm 6 | 7 | ENV VERSION=2025.07.03 8 | 9 | RUN wget "https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/${VERSION}/riscv32-glibc-ubuntu-24.04-gcc-nightly-${VERSION}-nightly.tar.xz" \ 10 | -O riscv-toolchain.tar.xz 11 | RUN tar -xJf riscv-toolchain.tar.xz 12 | 13 | ENV CARGO_TARGET_RISCV32GC_UNKNOWN_LINUX_GNU_LINKER=/riscv/bin/riscv32-unknown-linux-gnu-gcc \ 14 | CARGO_TARGET_RISCV32GC_UNKNOWN_LINUX_GNU_RUNNER="qemu-riscv32 -cpu max -L /riscv/sysroot" \ 15 | OBJDUMP=llvm-objdump 16 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev ca-certificates \ 7 | gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \ 8 | binfmt-support qemu-user-static qemu-system-ppc 9 | 10 | ENV TOOLCHAIN_PREFIX=powerpc64-linux-gnu- 11 | ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER="$TOOLCHAIN_PREFIX"gcc \ 12 | CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc64-static \ 13 | AR_powerpc64_unknown_linux_gnu="$TOOLCHAIN_PREFIX"ar \ 14 | CC_powerpc64_unknown_linux_gnu="$TOOLCHAIN_PREFIX"gcc \ 15 | QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu \ 16 | RUST_TEST_THREADS=1 17 | -------------------------------------------------------------------------------- /library/panic_unwind/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "panic_unwind" 3 | version = "0.0.0" 4 | license = "MIT OR Apache-2.0" 5 | repository = "https://github.com/rust-lang/rust.git" 6 | description = "Implementation of Rust panics via stack unwinding" 7 | edition = "2024" 8 | 9 | [lib] 10 | test = false 11 | bench = false 12 | doc = false 13 | 14 | [dependencies] 15 | alloc = { path = "../alloc" } 16 | core = { path = "../rustc-std-workspace-core", package = "rustc-std-workspace-core" } 17 | unwind = { path = "../unwind" } 18 | 19 | [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] 20 | libc = { version = "0.2", default-features = false } 21 | 22 | [lints.rust.unexpected_cfgs] 23 | level = "warn" 24 | check-cfg = ['cfg(emscripten_wasm_eh)'] 25 | -------------------------------------------------------------------------------- /library/std/src/sys/configure_builtins.rs: -------------------------------------------------------------------------------- 1 | /// Hook into .init_array to enable LSE atomic operations at startup, if 2 | /// supported. 3 | #[cfg(all(target_arch = "aarch64", target_os = "linux", not(feature = "compiler-builtins-c")))] 4 | #[used] 5 | #[unsafe(link_section = ".init_array.90")] 6 | static RUST_LSE_INIT: extern "C" fn() = { 7 | extern "C" fn init_lse() { 8 | use crate::arch; 9 | 10 | // This is provided by compiler-builtins::aarch64_linux. 11 | unsafe extern "C" { 12 | fn __rust_enable_lse(); 13 | } 14 | 15 | if arch::is_aarch64_feature_detected!("lse") { 16 | unsafe { 17 | __rust_enable_lse(); 18 | } 19 | } 20 | } 21 | init_lse 22 | }; 23 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | gcc libc6-dev qemu-user-static ca-certificates \ 7 | gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \ 8 | qemu-system-ppc 9 | 10 | ENV TOOLCHAIN_PREFIX=powerpc64le-linux-gnu- 11 | ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER="$TOOLCHAIN_PREFIX"gcc \ 12 | CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc64le-static \ 13 | AR_powerpc64le_unknown_linux_gnu="$TOOLCHAIN_PREFIX"ar \ 14 | CC_powerpc64le_unknown_linux_gnu="$TOOLCHAIN_PREFIX"gcc \ 15 | QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu \ 16 | RUST_TEST_THREADS=1 17 | -------------------------------------------------------------------------------- /library/compiler-builtins/compiler-builtins/src/hexagon/udivsi3.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | FUNCTION_BEGIN __hexagon_udivsi3 4 | { 5 | r2 = cl0(r0) 6 | r3 = cl0(r1) 7 | r5:4 = combine(#1,#0) 8 | p0 = cmp.gtu(r1,r0) 9 | } 10 | { 11 | r6 = sub(r3,r2) 12 | r4 = r1 13 | r1:0 = combine(r0,r4) 14 | if (p0) jumpr r31 15 | } 16 | { 17 | r3:2 = vlslw(r5:4,r6) 18 | loop0(1f,r6) 19 | } 20 | .falign 21 | 1: 22 | { 23 | p0 = cmp.gtu(r2,r1) 24 | if (!p0.new) r1 = sub(r1,r2) 25 | if (!p0.new) r0 = add(r0,r3) 26 | r3:2 = vlsrw(r3:2,#1) 27 | }:endloop0 28 | { 29 | p0 = cmp.gtu(r2,r1) 30 | if (!p0.new) r0 = add(r0,r3) 31 | jumpr r31 32 | } 33 | FUNCTION_END __hexagon_udivsi3 34 | 35 | .globl __qdsp_udivsi3 36 | .set __qdsp_udivsi3, __hexagon_udivsi3 37 | -------------------------------------------------------------------------------- /library/coretests/tests/task.rs: -------------------------------------------------------------------------------- 1 | use core::task::{Poll, RawWaker, RawWakerVTable, Waker}; 2 | 3 | #[test] 4 | fn poll_const() { 5 | // test that the methods of `Poll` are usable in a const context 6 | 7 | const POLL: Poll = Poll::Pending; 8 | 9 | const IS_READY: bool = POLL.is_ready(); 10 | assert!(!IS_READY); 11 | 12 | const IS_PENDING: bool = POLL.is_pending(); 13 | assert!(IS_PENDING); 14 | } 15 | 16 | #[test] 17 | fn waker_const() { 18 | const VOID_TABLE: RawWakerVTable = RawWakerVTable::new(|_| VOID_WAKER, |_| {}, |_| {}, |_| {}); 19 | 20 | const VOID_WAKER: RawWaker = RawWaker::new(&(), &VOID_TABLE); 21 | 22 | static WAKER: Waker = unsafe { Waker::from_raw(VOID_WAKER) }; 23 | 24 | WAKER.wake_by_ref(); 25 | } 26 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/common/mod.rs: -------------------------------------------------------------------------------- 1 | // This module contains code that is shared between all platforms, mostly utility or fallback code. 2 | // This explicitly does not include code that is shared between only a few platforms, 3 | // such as when reusing an implementation from `unix` or `unsupported`. 4 | // In those cases the desired code should be included directly using the #[path] attribute, 5 | // not moved to this module. 6 | // 7 | // Currently `sys_common` contains a lot of code that should live in this module, 8 | // ideally `sys_common` would only contain platform-independent abstractions on top of `sys`. 9 | // Progress on this is tracked in #84187. 10 | 11 | #![allow(dead_code)] 12 | 13 | pub mod small_c_string; 14 | 15 | #[cfg(test)] 16 | mod tests; 17 | -------------------------------------------------------------------------------- /library/alloc/src/collections/vec_deque/macros.rs: -------------------------------------------------------------------------------- 1 | macro_rules! __impl_slice_eq1 { 2 | ([$($vars:tt)*] $lhs:ty, $rhs:ty, $($constraints:tt)*) => { 3 | #[stable(feature = "vec_deque_partial_eq_slice", since = "1.17.0")] 4 | impl PartialEq<$rhs> for $lhs 5 | where 6 | T: PartialEq, 7 | $($constraints)* 8 | { 9 | fn eq(&self, other: &$rhs) -> bool { 10 | if self.len() != other.len() { 11 | return false; 12 | } 13 | let (sa, sb) = self.as_slices(); 14 | let (oa, ob) = other[..].split_at(sa.len()); 15 | sa == oa && sb == ob 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/std/src/sys/path/unsupported_backslash.rs: -------------------------------------------------------------------------------- 1 | #![forbid(unsafe_op_in_unsafe_fn)] 2 | use crate::ffi::OsStr; 3 | use crate::io; 4 | use crate::path::{Path, PathBuf, Prefix}; 5 | use crate::sys::unsupported; 6 | 7 | #[inline] 8 | pub fn is_sep_byte(b: u8) -> bool { 9 | b == b'\\' 10 | } 11 | 12 | #[inline] 13 | pub fn is_verbatim_sep(b: u8) -> bool { 14 | b == b'\\' 15 | } 16 | 17 | pub fn parse_prefix(_: &OsStr) -> Option> { 18 | None 19 | } 20 | 21 | pub const MAIN_SEP_STR: &str = "\\"; 22 | pub const MAIN_SEP: char = '\\'; 23 | 24 | pub(crate) fn absolute(_path: &Path) -> io::Result { 25 | unsupported() 26 | } 27 | 28 | pub(crate) fn is_absolute(path: &Path) -> bool { 29 | path.has_root() && path.prefix().is_some() 30 | } 31 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/os/freebsd/mod.rs: -------------------------------------------------------------------------------- 1 | //! Run-time feature detection on FreeBSD 2 | 3 | mod auxvec; 4 | 5 | cfg_select! { 6 | target_arch = "aarch64" => { 7 | mod aarch64; 8 | pub(crate) use self::aarch64::detect_features; 9 | } 10 | target_arch = "arm" => { 11 | mod arm; 12 | pub(crate) use self::arm::detect_features; 13 | } 14 | target_arch = "powerpc64" => { 15 | mod powerpc; 16 | pub(crate) use self::powerpc::detect_features; 17 | } 18 | _ => { 19 | use crate::detect::cache; 20 | /// Performs run-time feature detection. 21 | pub(crate) fn detect_features() -> cache::Initializer { 22 | cache::Initializer::default() 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /library/compiler-builtins/.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | name: Release-plz 2 | 3 | permissions: 4 | pull-requests: write 5 | contents: write 6 | 7 | on: 8 | push: { branches: [master] } 9 | 10 | jobs: 11 | release-plz: 12 | name: Release-plz 13 | runs-on: ubuntu-24.04 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | - name: Install Rust (rustup) 20 | run: rustup update nightly --no-self-update && rustup default nightly 21 | - name: Run release-plz 22 | uses: MarcoIeni/release-plz-action@v0.5 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} 26 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/sgx/abi/thread.rs: -------------------------------------------------------------------------------- 1 | use fortanix_sgx_abi::Tcs; 2 | 3 | /// Gets the ID for the current thread. The ID is guaranteed to be unique among 4 | /// all currently running threads in the enclave, and it is guaranteed to be 5 | /// constant for the lifetime of the thread. More specifically for SGX, there 6 | /// is a one-to-one correspondence of the ID to the address of the TCS. 7 | #[unstable(feature = "sgx_platform", issue = "56975")] 8 | pub fn current() -> Tcs { 9 | unsafe extern "C" { 10 | fn get_tcs_addr() -> *mut u8; 11 | } 12 | let addr = unsafe { get_tcs_addr() }; 13 | match Tcs::new(addr) { 14 | Some(tcs) => tcs, 15 | None => rtabort!("TCS must not be placed at address zero (this is a linker error)"), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/coretests/benches/tuple.rs: -------------------------------------------------------------------------------- 1 | use rand::prelude::*; 2 | use test::{Bencher, black_box}; 3 | 4 | #[bench] 5 | fn bench_tuple_comparison(b: &mut Bencher) { 6 | let mut rng = black_box(super::bench_rng()); 7 | 8 | let data = black_box([ 9 | ("core::iter::adapters::Chain", 123_usize), 10 | ("core::iter::adapters::Clone", 456_usize), 11 | ("core::iter::adapters::Copie", 789_usize), 12 | ("core::iter::adapters::Cycle", 123_usize), 13 | ("core::iter::adapters::Flatt", 456_usize), 14 | ("core::iter::adapters::TakeN", 789_usize), 15 | ]); 16 | 17 | b.iter(|| { 18 | let x = data.choose(&mut rng).unwrap(); 19 | let y = data.choose(&mut rng).unwrap(); 20 | [x < y, x <= y, x > y, x >= y] 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /library/portable-simd/crates/core_simd/tests/try_from_slice.rs: -------------------------------------------------------------------------------- 1 | #![feature(portable_simd)] 2 | 3 | #[cfg(target_arch = "wasm32")] 4 | use wasm_bindgen_test::*; 5 | 6 | #[cfg(target_arch = "wasm32")] 7 | wasm_bindgen_test_configure!(run_in_browser); 8 | 9 | use core_simd::simd::i32x4; 10 | 11 | #[test] 12 | #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] 13 | fn try_from_slice() { 14 | // Equal length 15 | assert_eq!( 16 | i32x4::try_from([1, 2, 3, 4].as_slice()).unwrap(), 17 | i32x4::from_array([1, 2, 3, 4]) 18 | ); 19 | 20 | // Slice length > vector length 21 | assert!(i32x4::try_from([1, 2, 3, 4, 5].as_slice()).is_err()); 22 | 23 | // Slice length < vector length 24 | assert!(i32x4::try_from([1, 2, 3].as_slice()).is_err()); 25 | } 26 | -------------------------------------------------------------------------------- /library/std/src/os/fd/mod.rs: -------------------------------------------------------------------------------- 1 | //! Owned and borrowed Unix-like file descriptors. 2 | //! 3 | //! This module is supported on Unix platforms and WASI, which both use a 4 | //! similar file descriptor system for referencing OS resources. 5 | 6 | #![stable(feature = "os_fd", since = "1.66.0")] 7 | #![deny(unsafe_op_in_unsafe_fn)] 8 | 9 | // `RawFd`, `AsRawFd`, etc. 10 | mod raw; 11 | 12 | // `OwnedFd`, `AsFd`, etc. 13 | mod owned; 14 | 15 | // Implementations for `AsRawFd` etc. for network types. 16 | #[cfg(not(target_os = "trusty"))] 17 | mod net; 18 | 19 | #[cfg(test)] 20 | mod tests; 21 | 22 | // Export the types and traits for the public API. 23 | #[stable(feature = "os_fd", since = "1.66.0")] 24 | pub use owned::*; 25 | #[stable(feature = "os_fd", since = "1.66.0")] 26 | pub use raw::*; 27 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/sgx/abi/tls/sync_bitset/tests.rs: -------------------------------------------------------------------------------- 1 | use super::*; 2 | 3 | fn test_data(bitset: [usize; 2], bit_indices: &[usize]) { 4 | let set = SyncBitset([AtomicUsize::new(bitset[0]), AtomicUsize::new(bitset[1])]); 5 | assert_eq!(set.iter().collect::>(), bit_indices); 6 | for &i in bit_indices { 7 | assert!(set.get(i)); 8 | } 9 | } 10 | 11 | #[test] 12 | fn iter() { 13 | test_data([0b0110_1001, 0], &[0, 3, 5, 6]); 14 | test_data([0x8000_0000_0000_0000, 0x8000_0000_0000_0001], &[63, 64, 127]); 15 | test_data([0, 0], &[]); 16 | } 17 | 18 | #[test] 19 | fn set_get_clear() { 20 | let set = SYNC_BITSET_INIT; 21 | let key = set.set().unwrap(); 22 | assert!(set.get(key)); 23 | set.clear(key); 24 | assert!(!set.get(key)); 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/testable-simd-models.yml: -------------------------------------------------------------------------------- 1 | # This workflow runs the tests for testable simd models. 2 | 3 | name: Testable simd models 4 | 5 | on: 6 | workflow_dispatch: 7 | merge_group: 8 | pull_request: 9 | branches: [ main ] 10 | push: 11 | paths: 12 | - '.github/workflows/testable-simd-models.yml' 13 | - 'testable-simd-models/**' 14 | 15 | defaults: 16 | run: 17 | shell: bash 18 | 19 | jobs: 20 | testable-simd-models: 21 | name: Test testable simd models 22 | runs-on: ubuntu-latest 23 | 24 | steps: 25 | - name: Checkout Repository 26 | uses: actions/checkout@v4 27 | 28 | - name: Run tests 29 | working-directory: testable-simd-models 30 | run: cargo test -- --test-threads=1 --nocapture 31 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/generic/fmaximum.rs: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT OR Apache-2.0 */ 2 | //! IEEE 754-2019 `maximum`. 3 | //! 4 | //! Per the spec, returns the canonicalized result of: 5 | //! - `x` if `x > y` 6 | //! - `y` if `y > x` 7 | //! - +0.0 if x and y are zero with opposite signs 8 | //! - qNaN if either operation is NaN 9 | //! 10 | //! Excluded from our implementation is sNaN handling. 11 | 12 | use crate::support::Float; 13 | 14 | #[inline] 15 | pub fn fmaximum(x: F, y: F) -> F { 16 | let res = if x.is_nan() { 17 | x 18 | } else if y.is_nan() { 19 | y 20 | } else if x > y || (y.biteq(F::NEG_ZERO) && x.is_sign_positive()) { 21 | x 22 | } else { 23 | y 24 | }; 25 | 26 | res.canonicalize() 27 | } 28 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/generic/fminimum.rs: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: MIT OR Apache-2.0 */ 2 | //! IEEE 754-2019 `minimum`. 3 | //! 4 | //! Per the spec, returns the canonicalized result of: 5 | //! - `x` if `x < y` 6 | //! - `y` if `y < x` 7 | //! - -0.0 if x and y are zero with opposite signs 8 | //! - qNaN if either operation is NaN 9 | //! 10 | //! Excluded from our implementation is sNaN handling. 11 | 12 | use crate::support::Float; 13 | 14 | #[inline] 15 | pub fn fminimum(x: F, y: F) -> F { 16 | let res = if x.is_nan() { 17 | x 18 | } else if y.is_nan() { 19 | y 20 | } else if x < y || (x.biteq(F::NEG_ZERO) && y.is_sign_positive()) { 21 | x 22 | } else { 23 | y 24 | }; 25 | 26 | res.canonicalize() 27 | } 28 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | gcc libc6-dev qemu-user ca-certificates \ 5 | gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \ 6 | file make 7 | 8 | ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ 9 | CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -cpu power11 -L /usr/powerpc64-linux-gnu" \ 10 | CC=powerpc64-linux-gnu-gcc \ 11 | OBJDUMP=powerpc64-linux-gnu-objdump \ 12 | STDARCH_TEST_SKIP_FEATURE=vsx \ 13 | # These 2 tests have erratic behaviour with qemu, see https://gitlab.com/qemu-project/qemu/-/issues/1623#note_2449012173 14 | STDARCH_TEST_SKIP_FUNCTION=vec_lde_u16,vec_lde_u32 15 | -------------------------------------------------------------------------------- /library/stdarch/ci/docker/x86_64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.10 2 | RUN apt-get update && apt-get install -y --no-install-recommends \ 3 | gcc \ 4 | libc6-dev \ 5 | file \ 6 | make \ 7 | ca-certificates \ 8 | wget \ 9 | xz-utils 10 | 11 | RUN wget http://ci-mirrors.rust-lang.org/stdarch/sde-external-9.58.0-2025-06-16-lin.tar.xz -O sde.tar.xz 12 | RUN mkdir intel-sde 13 | RUN tar -xJf sde.tar.xz --strip-components=1 -C intel-sde 14 | ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/intel-sde/sde64 \ 15 | -cpuid-in /checkout/ci/docker/x86_64-unknown-linux-gnu/cpuid.def \ 16 | -rtm-mode full -tsx --" 17 | # These tests fail with SDE as it doesn't support saving register data 18 | ENV STDARCH_TEST_SKIP_FUNCTION="xsave,xsaveopt,xsave64,xsaveopt64" 19 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | ca-certificates \ 7 | gcc \ 8 | gcc-mips64el-linux-gnuabi64 \ 9 | libc6-dev \ 10 | libc6-dev-mips64el-cross \ 11 | qemu-user-static 12 | 13 | ENV TOOLCHAIN_PREFIX=mips64el-linux-gnuabi64- 14 | ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER="$TOOLCHAIN_PREFIX"gcc \ 15 | CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER=qemu-mips64el-static \ 16 | AR_mips64el_unknown_linux_gnuabi64="$TOOLCHAIN_PREFIX"ar \ 17 | CC_mips64el_unknown_linux_gnuabi64="$TOOLCHAIN_PREFIX"gcc \ 18 | QEMU_LD_PREFIX=/usr/mips64el-linux-gnuabi64 \ 19 | RUST_TEST_THREADS=1 20 | -------------------------------------------------------------------------------- /library/compiler-builtins/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu:25.04 2 | FROM $IMAGE 3 | 4 | RUN apt-get update && \ 5 | apt-get install -y --no-install-recommends \ 6 | ca-certificates \ 7 | gcc \ 8 | gcc-mips64-linux-gnuabi64 \ 9 | libc6-dev \ 10 | libc6-dev-mips64-cross \ 11 | qemu-user-static \ 12 | qemu-system-mips 13 | 14 | ENV TOOLCHAIN_PREFIX=mips64-linux-gnuabi64- 15 | ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER="$TOOLCHAIN_PREFIX"gcc \ 16 | CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER=qemu-mips64-static \ 17 | AR_mips64_unknown_linux_gnuabi64="$TOOLCHAIN_PREFIX"ar \ 18 | CC_mips64_unknown_linux_gnuabi64="$TOOLCHAIN_PREFIX"gcc \ 19 | QEMU_LD_PREFIX=/usr/mips64-linux-gnuabi64 \ 20 | RUST_TEST_THREADS=1 21 | -------------------------------------------------------------------------------- /library/portable-simd/.github/workflows/doc.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release: 10 | name: Deploy Documentation 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout Repository 15 | uses: actions/checkout@v4 16 | 17 | - name: Setup Rust 18 | run: | 19 | rustup update nightly --no-self-update 20 | rustup default nightly 21 | 22 | - name: Build Documentation 23 | run: cargo doc --no-deps 24 | 25 | - name: Deploy Documentation 26 | uses: peaceiris/actions-gh-pages@v3 27 | with: 28 | github_token: ${{ secrets.GITHUB_TOKEN }} 29 | publish_branch: gh-pages 30 | publish_dir: ./target/doc 31 | -------------------------------------------------------------------------------- /library/contracts/safety/src/runtime.rs: -------------------------------------------------------------------------------- 1 | use proc_macro::TokenStream; 2 | 3 | /// For now, runtime requires is a no-op. 4 | /// 5 | /// TODO: At runtime the `requires` should become an assert unsafe precondition. 6 | pub(crate) fn requires(_attr: TokenStream, item: TokenStream) -> TokenStream { 7 | item 8 | } 9 | 10 | /// For now, runtime ensures is a no-op. 11 | /// 12 | /// TODO: At runtime the `ensures` should become an assert as well. 13 | pub(crate) fn ensures(_attr: TokenStream, item: TokenStream) -> TokenStream { 14 | item 15 | } 16 | 17 | /// For now, runtime loop_invariant is a no-op. 18 | /// 19 | /// TODO: At runtime the `loop_invariant` should become an assert as well. 20 | pub(crate) fn loop_invariant(_attr: TokenStream, stmt_stream: TokenStream) -> TokenStream { 21 | stmt_stream 22 | } 23 | -------------------------------------------------------------------------------- /library/coretests/tests/manually_drop.rs: -------------------------------------------------------------------------------- 1 | #![allow(undropped_manually_drops)] 2 | 3 | use core::mem::ManuallyDrop; 4 | 5 | #[test] 6 | fn smoke() { 7 | #[derive(Clone)] 8 | struct TypeWithDrop; 9 | impl Drop for TypeWithDrop { 10 | fn drop(&mut self) { 11 | unreachable!("Should not get dropped"); 12 | } 13 | } 14 | 15 | let x = ManuallyDrop::new(TypeWithDrop); 16 | drop(x); 17 | 18 | // also test unsizing 19 | let x: Box> = 20 | Box::new(ManuallyDrop::new([TypeWithDrop, TypeWithDrop])); 21 | drop(x); 22 | 23 | // test clone and clone_from implementations 24 | let mut x = ManuallyDrop::new(TypeWithDrop); 25 | let y = x.clone(); 26 | x.clone_from(&y); 27 | drop(x); 28 | drop(y); 29 | } 30 | -------------------------------------------------------------------------------- /library/coretests/tests/num/const_from.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn from() { 3 | use core::convert::TryFrom; 4 | use core::num::TryFromIntError; 5 | 6 | // From 7 | const FROM: i64 = i64::from(1i32); 8 | assert_eq!(FROM, 1i64); 9 | 10 | // From int to float 11 | const FROM_F64: f64 = f64::from(42u8); 12 | assert_eq!(FROM_F64, 42f64); 13 | 14 | // Upper bounded 15 | const U8_FROM_U16: Result = u8::try_from(1u16); 16 | assert_eq!(U8_FROM_U16, Ok(1u8)); 17 | 18 | // Both bounded 19 | const I8_FROM_I16: Result = i8::try_from(1i16); 20 | assert_eq!(I8_FROM_I16, Ok(1i8)); 21 | 22 | // Lower bounded 23 | const I16_FROM_U16: Result = i16::try_from(1u16); 24 | assert_eq!(I16_FROM_U16, Ok(1i16)); 25 | } 26 | -------------------------------------------------------------------------------- /library/portable-simd/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Hello, welcome to `std::simd`! 2 | 3 | It seems this pull request template checklist was created while a lot of vector math ops were being implemented, and only really applies to ops. Feel free to delete everything here if it's not applicable, or ask for help if you're not sure what it means! 4 | 5 | For a given vector math operation on TxN, please add tests for interactions with: 6 | - [ ] `T::MAX` 7 | - [ ] `T::MIN` 8 | - [ ] -1 9 | - [ ] 1 10 | - [ ] 0 11 | 12 | 13 | For a given vector math operation on TxN where T is a float, please add tests for test interactions with: 14 | - [ ] a really large number, larger than the mantissa 15 | - [ ] a really small "subnormal" number 16 | - [ ] NaN 17 | - [ ] Infinity 18 | - [ ] Negative Infinity 19 | -------------------------------------------------------------------------------- /library/compiler-builtins/libm/src/math/ilogbf.rs: -------------------------------------------------------------------------------- 1 | const FP_ILOGBNAN: i32 = -1 - 0x7fffffff; 2 | const FP_ILOGB0: i32 = FP_ILOGBNAN; 3 | 4 | #[cfg_attr(assert_no_panic, no_panic::no_panic)] 5 | pub fn ilogbf(x: f32) -> i32 { 6 | let mut i = x.to_bits(); 7 | let e = ((i >> 23) & 0xff) as i32; 8 | 9 | if e == 0 { 10 | i <<= 9; 11 | if i == 0 { 12 | force_eval!(0.0 / 0.0); 13 | return FP_ILOGB0; 14 | } 15 | /* subnormal x */ 16 | let mut e = -0x7f; 17 | while (i >> 31) == 0 { 18 | e -= 1; 19 | i <<= 1; 20 | } 21 | e 22 | } else if e == 0xff { 23 | force_eval!(0.0 / 0.0); 24 | if (i << 9) != 0 { FP_ILOGBNAN } else { i32::MAX } 25 | } else { 26 | e - 0x7f 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /library/std_detect/src/detect/os/freebsd/powerpc.rs: -------------------------------------------------------------------------------- 1 | //! Run-time feature detection for PowerPC on FreeBSD. 2 | 3 | use super::auxvec; 4 | use crate::detect::{Feature, cache}; 5 | 6 | pub(crate) fn detect_features() -> cache::Initializer { 7 | let mut value = cache::Initializer::default(); 8 | let enable_feature = |value: &mut cache::Initializer, f, enable| { 9 | if enable { 10 | value.set(f as u32); 11 | } 12 | }; 13 | 14 | if let Ok(auxv) = auxvec::auxv() { 15 | enable_feature(&mut value, Feature::altivec, auxv.hwcap & 0x10000000 != 0); 16 | enable_feature(&mut value, Feature::vsx, auxv.hwcap & 0x00000080 != 0); 17 | enable_feature(&mut value, Feature::power8, auxv.hwcap2 & 0x80000000 != 0); 18 | return value; 19 | } 20 | value 21 | } 22 | -------------------------------------------------------------------------------- /library/alloctests/testing/rng.rs: -------------------------------------------------------------------------------- 1 | /// XorShiftRng 2 | pub(crate) struct DeterministicRng { 3 | count: usize, 4 | x: u32, 5 | y: u32, 6 | z: u32, 7 | w: u32, 8 | } 9 | 10 | impl DeterministicRng { 11 | pub(crate) fn new() -> Self { 12 | DeterministicRng { count: 0, x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb } 13 | } 14 | 15 | /// Guarantees that each returned number is unique. 16 | pub(crate) fn next(&mut self) -> u32 { 17 | self.count += 1; 18 | assert!(self.count <= 70029); 19 | let x = self.x; 20 | let t = x ^ (x << 11); 21 | self.x = self.y; 22 | self.y = self.z; 23 | self.z = self.w; 24 | let w_ = self.w; 25 | self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8)); 26 | self.w 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /library/std/src/sys/pal/sgx/thread_parking.rs: -------------------------------------------------------------------------------- 1 | use fortanix_sgx_abi::{EV_UNPARK, WAIT_INDEFINITE}; 2 | 3 | use super::abi::usercalls; 4 | use crate::io::ErrorKind; 5 | use crate::time::Duration; 6 | 7 | pub type ThreadId = fortanix_sgx_abi::Tcs; 8 | 9 | pub use super::abi::thread::current; 10 | 11 | pub fn park(_hint: usize) { 12 | usercalls::wait(EV_UNPARK, WAIT_INDEFINITE).unwrap(); 13 | } 14 | 15 | pub fn park_timeout(dur: Duration, _hint: usize) { 16 | let timeout = u128::min(dur.as_nanos(), WAIT_INDEFINITE as u128 - 1) as u64; 17 | if let Err(e) = usercalls::wait(EV_UNPARK, timeout) { 18 | assert!(matches!(e.kind(), ErrorKind::TimedOut | ErrorKind::WouldBlock)) 19 | } 20 | } 21 | 22 | pub fn unpark(tid: ThreadId, _hint: usize) { 23 | let _ = usercalls::send(EV_UNPARK, Some(tid)); 24 | } 25 | -------------------------------------------------------------------------------- /library/alloctests/tests/alloc_test.rs: -------------------------------------------------------------------------------- 1 | use alloc::alloc::*; 2 | use alloc::boxed::Box; 3 | 4 | extern crate test; 5 | use test::Bencher; 6 | 7 | #[test] 8 | fn allocate_zeroed() { 9 | unsafe { 10 | let layout = Layout::from_size_align(1024, 1).unwrap(); 11 | let ptr = 12 | Global.allocate_zeroed(layout.clone()).unwrap_or_else(|_| handle_alloc_error(layout)); 13 | 14 | let mut i = ptr.as_non_null_ptr().as_ptr(); 15 | let end = i.add(layout.size()); 16 | while i < end { 17 | assert_eq!(*i, 0); 18 | i = i.add(1); 19 | } 20 | Global.deallocate(ptr.as_non_null_ptr(), layout); 21 | } 22 | } 23 | 24 | #[bench] 25 | fn alloc_owned_small(b: &mut Bencher) { 26 | b.iter(|| { 27 | let _: Box<_> = Box::new(10); 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /library/std/src/sys/random/windows.rs: -------------------------------------------------------------------------------- 1 | use crate::sys::c; 2 | 3 | #[cfg(not(target_vendor = "win7"))] 4 | #[inline] 5 | pub fn fill_bytes(bytes: &mut [u8]) { 6 | let ret = unsafe { c::ProcessPrng(bytes.as_mut_ptr(), bytes.len()) }; 7 | // ProcessPrng is documented as always returning `TRUE`. 8 | // https://learn.microsoft.com/en-us/windows/win32/seccng/processprng#return-value 9 | debug_assert_eq!(ret, c::TRUE); 10 | } 11 | 12 | #[cfg(target_vendor = "win7")] 13 | pub fn fill_bytes(mut bytes: &mut [u8]) { 14 | while !bytes.is_empty() { 15 | let len = bytes.len().try_into().unwrap_or(u32::MAX); 16 | let ret = unsafe { c::RtlGenRandom(bytes.as_mut_ptr().cast(), len) }; 17 | assert!(ret, "failed to generate random data"); 18 | bytes = &mut bytes[len as usize..]; 19 | } 20 | } 21 | --------------------------------------------------------------------------------