diff options
| author | The Miri Cronjob Bot <miri@cron.bot> | 2024-12-07 05:03:57 +0000 |
|---|---|---|
| committer | The Miri Cronjob Bot <miri@cron.bot> | 2024-12-07 05:03:57 +0000 |
| commit | 97633d8e607f10c7558e07351bc32d7893f3e675 (patch) | |
| tree | 1a8c1df7aacc9fcf83e0ca955adc4a0c18ecc540 /src/tools | |
| parent | 8afc3c695e22d8f816e8b3da1af671c432d5e59f (diff) | |
| parent | ca13e9169fbbbb126190631b5a1e3e20053a52c1 (diff) | |
| download | rust-97633d8e607f10c7558e07351bc32d7893f3e675.tar.gz rust-97633d8e607f10c7558e07351bc32d7893f3e675.zip | |
Merge from rustc
Diffstat (limited to 'src/tools')
32 files changed, 551 insertions, 277 deletions
diff --git a/src/tools/miri/src/alloc_addresses/mod.rs b/src/tools/miri/src/alloc_addresses/mod.rs index fe7d8db245b..f7295fd7d8a 100644 --- a/src/tools/miri/src/alloc_addresses/mod.rs +++ b/src/tools/miri/src/alloc_addresses/mod.rs @@ -286,9 +286,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { - fn expose_ptr(&mut self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { - let this = self.eval_context_mut(); - let global_state = this.machine.alloc_addresses.get_mut(); + fn expose_ptr(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { + let this = self.eval_context_ref(); + let mut global_state = this.machine.alloc_addresses.borrow_mut(); // In strict mode, we don't need this, so we can save some cycles by not tracking it. if global_state.provenance_mode == ProvenanceMode::Strict { return interp_ok(()); @@ -299,8 +299,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { return interp_ok(()); } trace!("Exposing allocation id {alloc_id:?}"); - let global_state = this.machine.alloc_addresses.get_mut(); global_state.exposed.insert(alloc_id); + // Release the global state before we call `expose_tag`, which may call `get_alloc_info_extra`, + // which may need access to the global state. + drop(global_state); if this.machine.borrow_tracker.is_some() { this.expose_tag(alloc_id, tag)?; } diff --git a/src/tools/miri/src/borrow_tracker/mod.rs b/src/tools/miri/src/borrow_tracker/mod.rs index 4883613dea5..9808102f4ba 100644 --- a/src/tools/miri/src/borrow_tracker/mod.rs +++ b/src/tools/miri/src/borrow_tracker/mod.rs @@ -302,8 +302,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } } - fn expose_tag(&mut self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { - let this = self.eval_context_mut(); + fn expose_tag(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { + let this = self.eval_context_ref(); let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method; match method { BorrowTrackerMethod::StackedBorrows => this.sb_expose_tag(alloc_id, tag), diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs index a855603eeb3..ea75131078e 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -1011,8 +1011,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } /// Mark the given tag as exposed. It was found on a pointer with the given AllocId. - fn sb_expose_tag(&mut self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { - let this = self.eval_context_mut(); + fn sb_expose_tag(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { + let this = self.eval_context_ref(); // Function pointers and dead objects don't have an alloc_extra so we ignore them. // This is okay because accessing them is UB anyway, no need for any Stacked Borrows checks. diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs index d376b8c3598..f39a606513d 100644 --- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs @@ -540,8 +540,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { } /// Mark the given tag as exposed. It was found on a pointer with the given AllocId. - fn tb_expose_tag(&mut self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { - let this = self.eval_context_mut(); + fn tb_expose_tag(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> { + let this = self.eval_context_ref(); // Function pointers and dead objects don't have an alloc_extra so we ignore them. // This is okay because accessing them is UB anyway, no need for any Tree Borrows checks. diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 814dc6d2b01..888465c5262 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -270,6 +270,9 @@ impl interpret::Provenance for Provenance { /// We use absolute addresses in the `offset` of a `StrictPointer`. const OFFSET_IS_ADDR: bool = true; + /// Miri implements wildcard provenance. + const WILDCARD: Option<Self> = Some(Provenance::Wildcard); + fn get_alloc_id(self) -> Option<AllocId> { match self { Provenance::Concrete { alloc_id, .. } => Some(alloc_id), @@ -1242,8 +1245,8 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { /// Called on `ptr as usize` casts. /// (Actually computing the resulting `usize` doesn't need machine help, /// that's just `Scalar::try_to_int`.) - fn expose_ptr(ecx: &mut InterpCx<'tcx, Self>, ptr: StrictPointer) -> InterpResult<'tcx> { - match ptr.provenance { + fn expose_provenance(ecx: &InterpCx<'tcx, Self>, provenance: Self::Provenance) -> InterpResult<'tcx> { + match provenance { Provenance::Concrete { alloc_id, tag } => ecx.expose_ptr(alloc_id, tag), Provenance::Wildcard => { // No need to do anything for wildcard pointers as diff --git a/src/tools/miri/src/shims/native_lib.rs b/src/tools/miri/src/shims/native_lib.rs index e7a4251242e..4082b8eed45 100644 --- a/src/tools/miri/src/shims/native_lib.rs +++ b/src/tools/miri/src/shims/native_lib.rs @@ -3,8 +3,11 @@ use std::ops::Deref; use libffi::high::call as ffi; use libffi::low::CodePtr; -use rustc_abi::{BackendRepr, HasDataLayout}; -use rustc_middle::ty::{self as ty, IntTy, UintTy}; +use rustc_abi::{BackendRepr, HasDataLayout, Size}; +use rustc_middle::{ + mir::interpret::Pointer, + ty::{self as ty, IntTy, UintTy}, +}; use rustc_span::Symbol; use crate::*; @@ -75,6 +78,11 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { unsafe { ffi::call::<()>(ptr, libffi_args.as_slice()) }; return interp_ok(ImmTy::uninit(dest.layout)); } + ty::RawPtr(..) => { + let x = unsafe { ffi::call::<*const ()>(ptr, libffi_args.as_slice()) }; + let ptr = Pointer::new(Provenance::Wildcard, Size::from_bytes(x.addr())); + Scalar::from_pointer(ptr, this) + } _ => throw_unsup_format!("unsupported return type for native call: {:?}", link_name), }; interp_ok(ImmTy::from_scalar(scalar, dest.layout)) @@ -152,8 +160,26 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { if !matches!(arg.layout.backend_repr, BackendRepr::Scalar(_)) { throw_unsup_format!("only scalar argument types are support for native calls") } - libffi_args.push(imm_to_carg(this.read_immediate(arg)?, this)?); + let imm = this.read_immediate(arg)?; + libffi_args.push(imm_to_carg(&imm, this)?); + // If we are passing a pointer, prepare the memory it points to. + if matches!(arg.layout.ty.kind(), ty::RawPtr(..)) { + let ptr = imm.to_scalar().to_pointer(this)?; + let Some(prov) = ptr.provenance else { + // Pointer without provenance may not access any memory. + continue; + }; + // We use `get_alloc_id` for its best-effort behaviour with Wildcard provenance. + let Some(alloc_id) = prov.get_alloc_id() else { + // Wildcard pointer, whatever it points to must be already exposed. + continue; + }; + this.prepare_for_native_call(alloc_id, prov)?; + } } + + // FIXME: In the future, we should also call `prepare_for_native_call` on all previously + // exposed allocations, since C may access any of them. // Convert them to `libffi::high::Arg` type. let libffi_args = libffi_args @@ -220,7 +246,7 @@ impl<'a> CArg { /// Extract the scalar value from the result of reading a scalar from the machine, /// and convert it to a `CArg`. -fn imm_to_carg<'tcx>(v: ImmTy<'tcx>, cx: &impl HasDataLayout) -> InterpResult<'tcx, CArg> { +fn imm_to_carg<'tcx>(v: &ImmTy<'tcx>, cx: &impl HasDataLayout) -> InterpResult<'tcx, CArg> { interp_ok(match v.layout.ty.kind() { // If the primitive provided can be converted to a type matching the type pattern // then create a `CArg` of this primitive value with the corresponding `CArg` constructor. @@ -238,18 +264,10 @@ fn imm_to_carg<'tcx>(v: ImmTy<'tcx>, cx: &impl HasDataLayout) -> InterpResult<'t ty::Uint(UintTy::U64) => CArg::UInt64(v.to_scalar().to_u64()?), ty::Uint(UintTy::Usize) => CArg::USize(v.to_scalar().to_target_usize(cx)?.try_into().unwrap()), - ty::RawPtr(_, mutability) => { - // Arbitrary mutable pointer accesses are not currently supported in Miri. - if mutability.is_mut() { - throw_unsup_format!( - "unsupported mutable pointer type for native call: {}", - v.layout.ty - ); - } else { - let s = v.to_scalar().to_pointer(cx)?.addr(); - // This relies on the `expose_provenance` in `addr_from_alloc_id`. - CArg::RawPtr(std::ptr::with_exposed_provenance_mut(s.bytes_usize())) - } + ty::RawPtr(..) => { + let s = v.to_scalar().to_pointer(cx)?.addr(); + // This relies on the `expose_provenance` in `addr_from_alloc_id`. + CArg::RawPtr(std::ptr::with_exposed_provenance_mut(s.bytes_usize())) } _ => throw_unsup_format!("unsupported argument type for native call: {}", v.layout.ty), }) diff --git a/src/tools/miri/tests/native-lib/pass/ptr_read_access.rs b/src/tools/miri/tests/native-lib/pass/ptr_read_access.rs index 46eb5778b32..3ccfecc6fb3 100644 --- a/src/tools/miri/tests/native-lib/pass/ptr_read_access.rs +++ b/src/tools/miri/tests/native-lib/pass/ptr_read_access.rs @@ -3,17 +3,14 @@ //@only-on-host fn main() { - test_pointer(); - - test_simple(); - - test_nested(); - - test_static(); + test_access_pointer(); + test_access_simple(); + test_access_nested(); + test_access_static(); } -// Test void function that dereferences a pointer and prints its contents from C. -fn test_pointer() { +/// Test function that dereferences an int pointer and prints its contents from C. +fn test_access_pointer() { extern "C" { fn print_pointer(ptr: *const i32); } @@ -23,8 +20,8 @@ fn test_pointer() { unsafe { print_pointer(&x) }; } -// Test function that dereferences a simple struct pointer and accesses a field. -fn test_simple() { +/// Test function that dereferences a simple struct pointer and accesses a field. +fn test_access_simple() { #[repr(C)] struct Simple { field: i32, @@ -39,8 +36,8 @@ fn test_simple() { assert_eq!(unsafe { access_simple(&simple) }, -42); } -// Test function that dereferences nested struct pointers and accesses fields. -fn test_nested() { +/// Test function that dereferences nested struct pointers and accesses fields. +fn test_access_nested() { use std::ptr::NonNull; #[derive(Debug, PartialEq, Eq)] @@ -61,8 +58,8 @@ fn test_nested() { assert_eq!(unsafe { access_nested(&nested_2) }, 97); } -// Test function that dereferences static struct pointers and accesses fields. -fn test_static() { +/// Test function that dereferences a static struct pointer and accesses fields. +fn test_access_static() { #[repr(C)] struct Static { value: i32, diff --git a/src/tools/miri/tests/native-lib/pass/ptr_write_access.rs b/src/tools/miri/tests/native-lib/pass/ptr_write_access.rs new file mode 100644 index 00000000000..4045ef3cee5 --- /dev/null +++ b/src/tools/miri/tests/native-lib/pass/ptr_write_access.rs @@ -0,0 +1,208 @@ +// Only works on Unix targets +//@ignore-target: windows wasm +//@only-on-host +//@compile-flags: -Zmiri-permissive-provenance + + +#![feature(box_as_ptr)] + +use std::mem::MaybeUninit; +use std::ptr::null; + +fn main() { + test_increment_int(); + test_init_int(); + test_init_array(); + test_init_static_inner(); + test_exposed(); + test_swap_ptr(); + test_swap_ptr_tuple(); + test_overwrite_dangling(); + test_pass_dangling(); + test_swap_ptr_triple_dangling(); + test_return_ptr(); +} + +/// Test function that modifies an int. +fn test_increment_int() { + extern "C" { + fn increment_int(ptr: *mut i32); + } + + let mut x = 11; + + unsafe { increment_int(&mut x) }; + assert_eq!(x, 12); +} + +/// Test function that initializes an int. +fn test_init_int() { + extern "C" { + fn init_int(ptr: *mut i32, val: i32); + } + + let mut x = MaybeUninit::<i32>::uninit(); + let val = 21; + + let x = unsafe { + init_int(x.as_mut_ptr(), val); + x.assume_init() + }; + assert_eq!(x, val); +} + +/// Test function that initializes an array. +fn test_init_array() { + extern "C" { + fn init_array(ptr: *mut i32, len: usize, val: i32); + } + + const LEN: usize = 3; + let mut array = MaybeUninit::<[i32; LEN]>::uninit(); + let val = 31; + + let array = unsafe { + init_array(array.as_mut_ptr().cast::<i32>(), LEN, val); + array.assume_init() + }; + assert_eq!(array, [val; LEN]); +} + +/// Test function that initializes an int pointed to by an immutable static. +fn test_init_static_inner() { + #[repr(C)] + struct SyncPtr { + ptr: *mut i32 + } + unsafe impl Sync for SyncPtr {} + + extern "C" { + fn init_static_inner(s_ptr: *const SyncPtr, val: i32); + } + + static mut INNER: MaybeUninit<i32> = MaybeUninit::uninit(); + #[allow(static_mut_refs)] + static STATIC: SyncPtr = SyncPtr { ptr: unsafe { INNER.as_mut_ptr() } }; + let val = 41; + + let inner = unsafe { + init_static_inner(&STATIC, val); + INNER.assume_init() + }; + assert_eq!(inner, val); +} + +// Test function that marks an allocation as exposed. +fn test_exposed() { + extern "C" { + fn ignore_ptr(ptr: *const i32); + } + + let x = 51; + let ptr = &raw const x; + let p = ptr.addr(); + + unsafe { ignore_ptr(ptr) }; + assert_eq!(unsafe { *(p as *const i32) }, x); +} + +/// Test function that swaps two pointers and exposes the alloc of an int. +fn test_swap_ptr() { + extern "C" { + fn swap_ptr(pptr0: *mut *const i32, pptr1: *mut *const i32); + } + + let x = 61; + let (mut ptr0, mut ptr1) = (&raw const x, null()); + + unsafe { swap_ptr(&mut ptr0, &mut ptr1) }; + assert_eq!(unsafe { *ptr1 }, x); +} + +/// Test function that swaps two pointers in a struct and exposes the alloc of an int. +fn test_swap_ptr_tuple() { + #[repr(C)] + struct Tuple { + ptr0: *const i32, + ptr1: *const i32, + } + + extern "C" { + fn swap_ptr_tuple(t_ptr: *mut Tuple); + } + + let x = 71; + let mut tuple = Tuple { ptr0: &raw const x, ptr1: null() }; + + unsafe { swap_ptr_tuple(&mut tuple) } + assert_eq!(unsafe { *tuple.ptr1 }, x); +} + +/// Test function that interacts with a dangling pointer. +fn test_overwrite_dangling() { + extern "C" { + fn overwrite_ptr(pptr: *mut *const i32); + } + + let b = Box::new(81); + let mut ptr = Box::as_ptr(&b); + drop(b); + + unsafe { overwrite_ptr(&mut ptr) }; + assert_eq!(ptr, null()); +} + +/// Test function that passes a dangling pointer. +fn test_pass_dangling() { + extern "C" { + fn ignore_ptr(ptr: *const i32); + } + + let b = Box::new(91); + let ptr = Box::as_ptr(&b); + drop(b); + + unsafe { ignore_ptr(ptr) }; +} + +/// Test function that interacts with a struct storing a dangling pointer. +fn test_swap_ptr_triple_dangling() { + #[repr(C)] + struct Triple { + ptr0: *const i32, + ptr1: *const i32, + ptr2: *const i32, + } + + extern "C" { + fn swap_ptr_triple_dangling(t_ptr: *const Triple); + } + + let x = 101; + let b = Box::new(111); + let ptr = Box::as_ptr(&b); + drop(b); + let z = 121; + let triple = Triple { + ptr0: &raw const x, + ptr1: ptr, + ptr2: &raw const z + }; + + unsafe { swap_ptr_triple_dangling(&triple) } + assert_eq!(unsafe { *triple.ptr2 }, x); +} + + +/// Test function that directly returns its pointer argument. +fn test_return_ptr() { + extern "C" { + fn return_ptr(ptr: *const i32) -> *const i32; + } + + let x = 131; + let ptr = &raw const x; + + let ptr = unsafe { return_ptr(ptr) }; + assert_eq!(unsafe { *ptr }, x); +} diff --git a/src/tools/miri/tests/native-lib/ptr_read_access.c b/src/tools/miri/tests/native-lib/ptr_read_access.c index 540845d53a7..3b427d6033e 100644 --- a/src/tools/miri/tests/native-lib/ptr_read_access.c +++ b/src/tools/miri/tests/native-lib/ptr_read_access.c @@ -3,13 +3,13 @@ // See comments in build_native_lib() #define EXPORT __attribute__((visibility("default"))) -/* Test: test_pointer */ +/* Test: test_access_pointer */ EXPORT void print_pointer(const int *ptr) { printf("printing pointer dereference from C: %d\n", *ptr); } -/* Test: test_simple */ +/* Test: test_access_simple */ typedef struct Simple { int field; @@ -19,7 +19,7 @@ EXPORT int access_simple(const Simple *s_ptr) { return s_ptr->field; } -/* Test: test_nested */ +/* Test: test_access_nested */ typedef struct Nested { int value; @@ -38,7 +38,7 @@ EXPORT int access_nested(const Nested *n_ptr) { return n_ptr->value; } -/* Test: test_static */ +/* Test: test_access_static */ typedef struct Static { int value; diff --git a/src/tools/miri/tests/native-lib/ptr_write_access.c b/src/tools/miri/tests/native-lib/ptr_write_access.c new file mode 100644 index 00000000000..b54c5d86b21 --- /dev/null +++ b/src/tools/miri/tests/native-lib/ptr_write_access.c @@ -0,0 +1,90 @@ +#include <stddef.h> + +// See comments in build_native_lib() +#define EXPORT __attribute__((visibility("default"))) + +/* Test: test_increment_int */ + +EXPORT void increment_int(int *ptr) { + *ptr += 1; +} + +/* Test: test_init_int */ + +EXPORT void init_int(int *ptr, int val) { + *ptr = val; +} + +/* Test: test_init_array */ + +EXPORT void init_array(int *array, size_t len, int val) { + for (size_t i = 0; i < len; i++) { + array[i] = val; + } +} + +/* Test: test_init_static_inner */ + +typedef struct SyncPtr { + int *ptr; +} SyncPtr; + +EXPORT void init_static_inner(const SyncPtr *s_ptr, int val) { + *(s_ptr->ptr) = val; +} + +/* Tests: test_exposed, test_pass_dangling */ + +EXPORT void ignore_ptr(__attribute__((unused)) const int *ptr) { + return; +} + +/* Test: test_expose_int */ +EXPORT void expose_int(const int *int_ptr, const int **pptr) { + *pptr = int_ptr; +} + +/* Test: test_swap_ptr */ + +EXPORT void swap_ptr(const int **pptr0, const int **pptr1) { + const int *tmp = *pptr0; + *pptr0 = *pptr1; + *pptr1 = tmp; +} + +/* Test: test_swap_ptr_tuple */ + +typedef struct Tuple { + int *ptr0; + int *ptr1; +} Tuple; + +EXPORT void swap_ptr_tuple(Tuple *t_ptr) { + int *tmp = t_ptr->ptr0; + t_ptr->ptr0 = t_ptr->ptr1; + t_ptr->ptr1 = tmp; +} + +/* Test: test_overwrite_dangling */ + +EXPORT void overwrite_ptr(const int **pptr) { + *pptr = NULL; +} + +/* Test: test_swap_ptr_triple_dangling */ + +typedef struct Triple { + int *ptr0; + int *ptr1; + int *ptr2; +} Triple; + +EXPORT void swap_ptr_triple_dangling(Triple *t_ptr) { + int *tmp = t_ptr->ptr0; + t_ptr->ptr0 = t_ptr->ptr2; + t_ptr->ptr2 = tmp; +} + +EXPORT const int *return_ptr(const int *ptr) { + return ptr; +} diff --git a/src/tools/miri/tests/pass/async-closure-captures.rs b/src/tools/miri/tests/pass/async-closure-captures.rs index 423ef7a5cf7..979a6d1cbe0 100644 --- a/src/tools/miri/tests/pass/async-closure-captures.rs +++ b/src/tools/miri/tests/pass/async-closure-captures.rs @@ -1,6 +1,6 @@ // Same as rustc's `tests/ui/async-await/async-closures/captures.rs`, keep in sync -#![feature(async_closure, noop_waker, async_trait_bounds)] +#![feature(async_closure, async_trait_bounds)] use std::future::Future; use std::pin::pin; diff --git a/src/tools/miri/tests/pass/async-closure-drop.rs b/src/tools/miri/tests/pass/async-closure-drop.rs index 264da5a9518..ad9822fa46d 100644 --- a/src/tools/miri/tests/pass/async-closure-drop.rs +++ b/src/tools/miri/tests/pass/async-closure-drop.rs @@ -1,4 +1,4 @@ -#![feature(async_closure, noop_waker, async_trait_bounds)] +#![feature(async_closure, async_trait_bounds)] use std::future::Future; use std::pin::pin; diff --git a/src/tools/miri/tests/pass/async-closure.rs b/src/tools/miri/tests/pass/async-closure.rs index 721af578883..979b83687e4 100644 --- a/src/tools/miri/tests/pass/async-closure.rs +++ b/src/tools/miri/tests/pass/async-closure.rs @@ -1,4 +1,4 @@ -#![feature(async_closure, noop_waker, async_fn_traits)] +#![feature(async_closure, async_fn_traits)] #![allow(unused)] use std::future::Future; diff --git a/src/tools/miri/tests/pass/async-drop.rs b/src/tools/miri/tests/pass/async-drop.rs index 53e3476f620..a455f377e85 100644 --- a/src/tools/miri/tests/pass/async-drop.rs +++ b/src/tools/miri/tests/pass/async-drop.rs @@ -6,7 +6,7 @@ // please consider modifying rustc's async drop test at // `tests/ui/async-await/async-drop.rs`. -#![feature(async_drop, impl_trait_in_assoc_type, noop_waker, async_closure)] +#![feature(async_drop, impl_trait_in_assoc_type, async_closure)] #![allow(incomplete_features, dead_code)] // FIXME(zetanumbers): consider AsyncDestruct::async_drop cleanup tests diff --git a/src/tools/miri/tests/pass/async-fn.rs b/src/tools/miri/tests/pass/async-fn.rs index 67ec2e26b30..42c60bb4fab 100644 --- a/src/tools/miri/tests/pass/async-fn.rs +++ b/src/tools/miri/tests/pass/async-fn.rs @@ -1,5 +1,4 @@ #![feature(never_type)] -#![feature(noop_waker)] use std::future::Future; diff --git a/src/tools/miri/tests/pass/dyn-star.rs b/src/tools/miri/tests/pass/dyn-star.rs index dab589b4651..1ce0dd3c9d5 100644 --- a/src/tools/miri/tests/pass/dyn-star.rs +++ b/src/tools/miri/tests/pass/dyn-star.rs @@ -1,7 +1,6 @@ #![feature(dyn_star)] #![allow(incomplete_features)] #![feature(custom_inner_attributes)] -#![feature(noop_waker)] // rustfmt destroys `dyn* Trait` syntax #![rustfmt::skip] diff --git a/src/tools/miri/tests/pass/future-self-referential.rs b/src/tools/miri/tests/pass/future-self-referential.rs index 8aeb26a7a95..88d52d8f1c1 100644 --- a/src/tools/miri/tests/pass/future-self-referential.rs +++ b/src/tools/miri/tests/pass/future-self-referential.rs @@ -1,6 +1,5 @@ //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(noop_waker)] use std::future::*; use std::marker::PhantomPinned; diff --git a/src/tools/miri/tests/pass/issues/issue-miri-2068.rs b/src/tools/miri/tests/pass/issues/issue-miri-2068.rs index ccee2221e29..1931b6c9d79 100644 --- a/src/tools/miri/tests/pass/issues/issue-miri-2068.rs +++ b/src/tools/miri/tests/pass/issues/issue-miri-2068.rs @@ -1,5 +1,3 @@ -#![feature(noop_waker)] - use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll, Waker}; diff --git a/src/tools/miri/tests/pass/move-data-across-await-point.rs b/src/tools/miri/tests/pass/move-data-across-await-point.rs index 1a93a6bf664..5aafddd99b9 100644 --- a/src/tools/miri/tests/pass/move-data-across-await-point.rs +++ b/src/tools/miri/tests/pass/move-data-across-await-point.rs @@ -1,4 +1,3 @@ -#![feature(noop_waker)] use std::future::Future; use std::ptr; diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index 9553a37c9a8..9b9542b88a9 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -64,6 +64,7 @@ fn build_native_lib() -> PathBuf { // FIXME: Automate gathering of all relevant C source files in the directory. "tests/native-lib/scalar_arguments.c", "tests/native-lib/ptr_read_access.c", + "tests/native-lib/ptr_write_access.c", // Ensure we notice serious problems in the C code. "-Wall", "-Wextra", diff --git a/src/tools/publish_toolstate.py b/src/tools/publish_toolstate.py index 328b48e04d2..a639dc20a60 100755 --- a/src/tools/publish_toolstate.py +++ b/src/tools/publish_toolstate.py @@ -14,6 +14,7 @@ import json import datetime import collections import textwrap + try: import urllib2 from urllib2 import HTTPError @@ -21,7 +22,7 @@ except ImportError: import urllib.request as urllib2 from urllib.error import HTTPError try: - import typing # noqa: F401 FIXME: py2 + import typing # noqa: F401 FIXME: py2 except ImportError: pass @@ -29,40 +30,41 @@ except ImportError: # These should be collaborators of the rust-lang/rust repository (with at least # read privileges on it). CI will fail otherwise. MAINTAINERS = { - 'book': {'carols10cents'}, - 'nomicon': {'frewsxcv', 'Gankra', 'JohnTitor'}, - 'reference': {'Havvy', 'matthewjasper', 'ehuss'}, - 'rust-by-example': {'marioidival'}, - 'embedded-book': {'adamgreig', 'andre-richter', 'jamesmunns', 'therealprof'}, - 'edition-guide': {'ehuss'}, - 'rustc-dev-guide': {'spastorino', 'amanjeev', 'JohnTitor'}, + "book": {"carols10cents"}, + "nomicon": {"frewsxcv", "Gankra", "JohnTitor"}, + "reference": {"Havvy", "matthewjasper", "ehuss"}, + "rust-by-example": {"marioidival"}, + "embedded-book": {"adamgreig", "andre-richter", "jamesmunns", "therealprof"}, + "edition-guide": {"ehuss"}, + "rustc-dev-guide": {"spastorino", "amanjeev", "JohnTitor"}, } LABELS = { - 'book': ['C-bug'], - 'nomicon': ['C-bug'], - 'reference': ['C-bug'], - 'rust-by-example': ['C-bug'], - 'embedded-book': ['C-bug'], - 'edition-guide': ['C-bug'], - 'rustc-dev-guide': ['C-bug'], + "book": ["C-bug"], + "nomicon": ["C-bug"], + "reference": ["C-bug"], + "rust-by-example": ["C-bug"], + "embedded-book": ["C-bug"], + "edition-guide": ["C-bug"], + "rustc-dev-guide": ["C-bug"], } REPOS = { - 'book': 'https://github.com/rust-lang/book', - 'nomicon': 'https://github.com/rust-lang/nomicon', - 'reference': 'https://github.com/rust-lang/reference', - 'rust-by-example': 'https://github.com/rust-lang/rust-by-example', - 'embedded-book': 'https://github.com/rust-embedded/book', - 'edition-guide': 'https://github.com/rust-lang/edition-guide', - 'rustc-dev-guide': 'https://github.com/rust-lang/rustc-dev-guide', + "book": "https://github.com/rust-lang/book", + "nomicon": "https://github.com/rust-lang/nomicon", + "reference": "https://github.com/rust-lang/reference", + "rust-by-example": "https://github.com/rust-lang/rust-by-example", + "embedded-book": "https://github.com/rust-embedded/book", + "edition-guide": "https://github.com/rust-lang/edition-guide", + "rustc-dev-guide": "https://github.com/rust-lang/rustc-dev-guide", } + def load_json_from_response(resp): # type: (typing.Any) -> typing.Any content = resp.read() if isinstance(content, bytes): - content_str = content.decode('utf-8') + content_str = content.decode("utf-8") else: print("Refusing to decode " + str(type(content)) + " to str") return json.loads(content_str) @@ -70,11 +72,10 @@ def load_json_from_response(resp): def read_current_status(current_commit, path): # type: (str, str) -> typing.Mapping[str, typing.Any] - '''Reads build status of `current_commit` from content of `history/*.tsv` - ''' - with open(path, 'r') as f: + """Reads build status of `current_commit` from content of `history/*.tsv`""" + with open(path, "r") as f: for line in f: - (commit, status) = line.split('\t', 1) + (commit, status) = line.split("\t", 1) if commit == current_commit: return json.loads(status) return {} @@ -82,12 +83,12 @@ def read_current_status(current_commit, path): def gh_url(): # type: () -> str - return os.environ['TOOLSTATE_ISSUES_API_URL'] + return os.environ["TOOLSTATE_ISSUES_API_URL"] def maybe_remove_mention(message): # type: (str) -> str - if os.environ.get('TOOLSTATE_SKIP_MENTIONS') is not None: + if os.environ.get("TOOLSTATE_SKIP_MENTIONS") is not None: return message.replace("@", "") return message @@ -102,36 +103,45 @@ def issue( github_token, ): # type: (str, str, typing.Iterable[str], str, str, typing.List[str], str) -> None - '''Open an issue about the toolstate failure.''' - if status == 'test-fail': - status_description = 'has failing tests' + """Open an issue about the toolstate failure.""" + if status == "test-fail": + status_description = "has failing tests" else: - status_description = 'no longer builds' - request = json.dumps({ - 'body': maybe_remove_mention(textwrap.dedent('''\ + status_description = "no longer builds" + request = json.dumps( + { + "body": maybe_remove_mention( + textwrap.dedent("""\ Hello, this is your friendly neighborhood mergebot. After merging PR {}, I observed that the tool {} {}. A follow-up PR to the repository {} is needed to fix the fallout. cc @{}, do you think you would have time to do the follow-up work? If so, that would be great! - ''').format( - relevant_pr_number, tool, status_description, - REPOS.get(tool), relevant_pr_user - )), - 'title': '`{}` no longer builds after {}'.format(tool, relevant_pr_number), - 'assignees': list(assignees), - 'labels': labels, - }) - print("Creating issue:\n{}".format(request)) - response = urllib2.urlopen(urllib2.Request( - gh_url(), - request.encode(), - { - 'Authorization': 'token ' + github_token, - 'Content-Type': 'application/json', + """).format( + relevant_pr_number, + tool, + status_description, + REPOS.get(tool), + relevant_pr_user, + ) + ), + "title": "`{}` no longer builds after {}".format(tool, relevant_pr_number), + "assignees": list(assignees), + "labels": labels, } - )) + ) + print("Creating issue:\n{}".format(request)) + response = urllib2.urlopen( + urllib2.Request( + gh_url(), + request.encode(), + { + "Authorization": "token " + github_token, + "Content-Type": "application/json", + }, + ) + ) response.read() @@ -145,27 +155,26 @@ def update_latest( github_token, ): # type: (str, str, str, str, str, str, str) -> str - '''Updates `_data/latest.json` to match build result of the given commit. - ''' - with open('_data/latest.json', 'r+') as f: + """Updates `_data/latest.json` to match build result of the given commit.""" + with open("_data/latest.json", "r+") as f: latest = json.load(f, object_pairs_hook=collections.OrderedDict) current_status = { - os_: read_current_status(current_commit, 'history/' + os_ + '.tsv') - for os_ in ['windows', 'linux'] + os_: read_current_status(current_commit, "history/" + os_ + ".tsv") + for os_ in ["windows", "linux"] } - slug = 'rust-lang/rust' - message = textwrap.dedent('''\ + slug = "rust-lang/rust" + message = textwrap.dedent("""\ 📣 Toolstate changed by {}! Tested on commit {}@{}. Direct link to PR: <{}> - ''').format(relevant_pr_number, slug, current_commit, relevant_pr_url) + """).format(relevant_pr_number, slug, current_commit, relevant_pr_url) anything_changed = False for status in latest: - tool = status['tool'] + tool = status["tool"] changed = False create_issue_for_status = None # set to the status that caused the issue @@ -173,57 +182,70 @@ def update_latest( old = status[os_] new = s.get(tool, old) status[os_] = new - maintainers = ' '.join('@'+name for name in MAINTAINERS.get(tool, ())) + maintainers = " ".join("@" + name for name in MAINTAINERS.get(tool, ())) # comparing the strings, but they are ordered appropriately: # "test-pass" > "test-fail" > "build-fail" if new > old: # things got fixed or at least the status quo improved changed = True - message += '🎉 {} on {}: {} → {} (cc {}).\n' \ - .format(tool, os_, old, new, maintainers) + message += "🎉 {} on {}: {} → {} (cc {}).\n".format( + tool, os_, old, new, maintainers + ) elif new < old: # tests or builds are failing and were not failing before changed = True - title = '💔 {} on {}: {} → {}' \ - .format(tool, os_, old, new) - message += '{} (cc {}).\n' \ - .format(title, maintainers) + title = "💔 {} on {}: {} → {}".format(tool, os_, old, new) + message += "{} (cc {}).\n".format(title, maintainers) # See if we need to create an issue. # Create issue if things no longer build. # (No issue for mere test failures to avoid spurious issues.) - if new == 'build-fail': + if new == "build-fail": create_issue_for_status = new if create_issue_for_status is not None: try: issue( - tool, create_issue_for_status, MAINTAINERS.get(tool, ()), - relevant_pr_number, relevant_pr_user, LABELS.get(tool, []), + tool, + create_issue_for_status, + MAINTAINERS.get(tool, ()), + relevant_pr_number, + relevant_pr_user, + LABELS.get(tool, []), github_token, ) except HTTPError as e: # network errors will simply end up not creating an issue, but that's better # than failing the entire build job - print("HTTPError when creating issue for status regression: {0}\n{1!r}" - .format(e, e.read())) + print( + "HTTPError when creating issue for status regression: {0}\n{1!r}".format( + e, e.read() + ) + ) except IOError as e: - print("I/O error when creating issue for status regression: {0}".format(e)) + print( + "I/O error when creating issue for status regression: {0}".format( + e + ) + ) except: - print("Unexpected error when creating issue for status regression: {0}" - .format(sys.exc_info()[0])) + print( + "Unexpected error when creating issue for status regression: {0}".format( + sys.exc_info()[0] + ) + ) raise if changed: - status['commit'] = current_commit - status['datetime'] = current_datetime + status["commit"] = current_commit + status["datetime"] = current_datetime anything_changed = True if not anything_changed: - return '' + return "" f.seek(0) f.truncate(0) - json.dump(latest, f, indent=4, separators=(',', ': ')) + json.dump(latest, f, indent=4, separators=(",", ": ")) return message @@ -231,12 +253,12 @@ def update_latest( # There are variables declared within that are implicitly global; it is unknown # which ones precisely but at least this is true for `github_token`. try: - if __name__ != '__main__': + if __name__ != "__main__": exit(0) cur_commit = sys.argv[1] cur_datetime = datetime.datetime.now(datetime.timezone.utc).strftime( - '%Y-%m-%dT%H:%M:%SZ' + "%Y-%m-%dT%H:%M:%SZ" ) cur_commit_msg = sys.argv[2] save_message_to_path = sys.argv[3] @@ -244,21 +266,21 @@ try: # assume that PR authors are also owners of the repo where the branch lives relevant_pr_match = re.search( - r'Auto merge of #([0-9]+) - ([^:]+):[^,]+, r=(\S+)', + r"Auto merge of #([0-9]+) - ([^:]+):[^,]+, r=(\S+)", cur_commit_msg, ) if relevant_pr_match: number = relevant_pr_match.group(1) relevant_pr_user = relevant_pr_match.group(2) - relevant_pr_number = 'rust-lang/rust#' + number - relevant_pr_url = 'https://github.com/rust-lang/rust/pull/' + number + relevant_pr_number = "rust-lang/rust#" + number + relevant_pr_url = "https://github.com/rust-lang/rust/pull/" + number pr_reviewer = relevant_pr_match.group(3) else: - number = '-1' - relevant_pr_user = 'ghost' - relevant_pr_number = '<unknown PR>' - relevant_pr_url = '<unknown>' - pr_reviewer = 'ghost' + number = "-1" + relevant_pr_user = "ghost" + relevant_pr_number = "<unknown PR>" + relevant_pr_url = "<unknown>" + pr_reviewer = "ghost" message = update_latest( cur_commit, @@ -270,28 +292,30 @@ try: github_token, ) if not message: - print('<Nothing changed>') + print("<Nothing changed>") sys.exit(0) print(message) if not github_token: - print('Dry run only, not committing anything') + print("Dry run only, not committing anything") sys.exit(0) - with open(save_message_to_path, 'w') as f: + with open(save_message_to_path, "w") as f: f.write(message) # Write the toolstate comment on the PR as well. - issue_url = gh_url() + '/{}/comments'.format(number) - response = urllib2.urlopen(urllib2.Request( - issue_url, - json.dumps({'body': maybe_remove_mention(message)}).encode(), - { - 'Authorization': 'token ' + github_token, - 'Content-Type': 'application/json', - } - )) + issue_url = gh_url() + "/{}/comments".format(number) + response = urllib2.urlopen( + urllib2.Request( + issue_url, + json.dumps({"body": maybe_remove_mention(message)}).encode(), + { + "Authorization": "token " + github_token, + "Content-Type": "application/json", + }, + ) + ) response.read() except HTTPError as e: print("HTTPError: %s\n%r" % (e, e.read())) diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs b/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs index 95dfe56ff54..9a7a1a01a09 100644 --- a/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs +++ b/src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs @@ -695,7 +695,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[ template!(List: r#"cfg = "...", module = "...", kind = "...""#), DuplicatesOk, ), rustc_attr!(TEST, rustc_symbol_name, Normal, template!(Word), WarnFollowing), - rustc_attr!(TEST, rustc_polymorphize_error, Normal, template!(Word), WarnFollowing), rustc_attr!(TEST, rustc_def_path, Normal, template!(Word), WarnFollowing), rustc_attr!(TEST, rustc_mir, Normal, template!(List: "arg1, arg2, ..."), DuplicatesOk), gated!( diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock index 400eb7c5e0d..024b8f9becb 100644 --- a/src/tools/rustbook/Cargo.lock +++ b/src/tools/rustbook/Cargo.lock @@ -709,31 +709,21 @@ dependencies = [ ] [[package]] -name = "mdbook-trpl-listing" +name = "mdbook-trpl" version = "0.1.0" dependencies = [ + "anyhow", "clap", "html_parser", "mdbook", - "pulldown-cmark 0.10.3", - "pulldown-cmark-to-cmark 13.0.0", + "pulldown-cmark 0.12.2", + "pulldown-cmark-to-cmark 19.0.0", "serde_json", "thiserror", "toml 0.8.19", ] [[package]] -name = "mdbook-trpl-note" -version = "1.0.0" -dependencies = [ - "clap", - "mdbook", - "pulldown-cmark 0.10.3", - "pulldown-cmark-to-cmark 13.0.0", - "serde_json", -] - -[[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1010,7 +1000,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76979bea66e7875e7509c4ec5300112b316af87fa7a252ca91c448b32dfe3993" dependencies = [ "bitflags 2.6.0", - "getopts", "memchr", "pulldown-cmark-escape 0.10.1", "unicase", @@ -1029,6 +1018,19 @@ dependencies = [ ] [[package]] +name = "pulldown-cmark" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86ba2052aebccc42cbbb3ed234b8b13ce76f75c3551a303cb2bcffcff12bb14" +dependencies = [ + "bitflags 2.6.0", + "getopts", + "memchr", + "pulldown-cmark-escape 0.11.0", + "unicase", +] + +[[package]] name = "pulldown-cmark-escape" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1042,20 +1044,20 @@ checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae" [[package]] name = "pulldown-cmark-to-cmark" -version = "13.0.0" +version = "15.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f609795c8d835f79dcfcf768415b9fb57ef1b74891e99f86e73f43a7a257163b" +checksum = "b9c77db841443d89a57ae94f22d29c022f6d9f41b00bddbf1f4024dbaf4bdce1" dependencies = [ - "pulldown-cmark 0.10.3", + "pulldown-cmark 0.11.3", ] [[package]] name = "pulldown-cmark-to-cmark" -version = "15.0.1" +version = "19.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c77db841443d89a57ae94f22d29c022f6d9f41b00bddbf1f4024dbaf4bdce1" +checksum = "7d742adcc7b655dba3e9ebab47954ca229fc0fa1df01fdc94349b6f3a2e6d257" dependencies = [ - "pulldown-cmark 0.11.3", + "pulldown-cmark 0.12.2", ] [[package]] @@ -1144,8 +1146,7 @@ dependencies = [ "mdbook", "mdbook-i18n-helpers", "mdbook-spec", - "mdbook-trpl-listing", - "mdbook-trpl-note", + "mdbook-trpl", ] [[package]] diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index 854c4547337..c2ce8fef4d0 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -9,8 +9,7 @@ edition = "2021" [dependencies] clap = "4.0.32" env_logger = "0.11" -mdbook-trpl-listing = { path = "../../doc/book/packages/mdbook-trpl-listing" } -mdbook-trpl-note = { path = "../../doc/book/packages/mdbook-trpl-note" } +mdbook-trpl = { path = "../../doc/book/packages/mdbook-trpl" } mdbook-i18n-helpers = "0.3.3" mdbook-spec = { path = "../../doc/reference/mdbook-spec" } diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index a1ef18610b0..33f2a51215d 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -6,8 +6,7 @@ use mdbook::MDBook; use mdbook::errors::Result as Result3; use mdbook_i18n_helpers::preprocessors::Gettext; use mdbook_spec::Spec; -use mdbook_trpl_listing::TrplListing; -use mdbook_trpl_note::TrplNote; +use mdbook_trpl::{Figure, Listing, Note}; fn main() { let crate_version = concat!("v", crate_version!()); @@ -109,11 +108,15 @@ pub fn build(args: &ArgMatches) -> Result3<()> { // preprocessor, or this should modify the config and use // MDBook::load_with_config. if book.config.get_preprocessor("trpl-note").is_some() { - book.with_preprocessor(TrplNote); + book.with_preprocessor(Note); } if book.config.get_preprocessor("trpl-listing").is_some() { - book.with_preprocessor(TrplListing); + book.with_preprocessor(Listing); + } + + if book.config.get_preprocessor("trpl-figure").is_some() { + book.with_preprocessor(Figure); } if book.config.get_preprocessor("spec").is_some() { diff --git a/src/tools/tidy/config/black.toml b/src/tools/tidy/config/black.toml deleted file mode 100644 index d5b8b198afb..00000000000 --- a/src/tools/tidy/config/black.toml +++ /dev/null @@ -1,18 +0,0 @@ -[tool.black] -# Ignore all submodules -extend-exclude = """(\ - src/doc/nomicon|\ - src/tools/cargo/|\ - src/doc/reference/|\ - src/doc/book/|\ - src/doc/rust-by-example/|\ - library/stdarch/|\ - src/doc/rustc-dev-guide/|\ - src/doc/edition-guide/|\ - src/llvm-project/|\ - src/doc/embedded-book/|\ - src/tools/rustc-perf/|\ - src/tools/enzyme/|\ - library/backtrace/|\ - src/gcc/ - )""" diff --git a/src/tools/tidy/config/requirements.in b/src/tools/tidy/config/requirements.in index 8938dc03243..1b2c38f2b5d 100644 --- a/src/tools/tidy/config/requirements.in +++ b/src/tools/tidy/config/requirements.in @@ -6,6 +6,5 @@ # Note: this generation step should be run with the oldest supported python # version (currently 3.9) to ensure backward compatibility -black==24.4.2 ruff==0.4.9 clang-format==18.1.7 diff --git a/src/tools/tidy/config/requirements.txt b/src/tools/tidy/config/requirements.txt index 790eabf5cf8..938179d5b3e 100644 --- a/src/tools/tidy/config/requirements.txt +++ b/src/tools/tidy/config/requirements.txt @@ -4,30 +4,6 @@ # # pip-compile --generate-hashes --strip-extras src/tools/tidy/config/requirements.in # -black==24.4.2 \ - --hash=sha256:257d724c2c9b1660f353b36c802ccece186a30accc7742c176d29c146df6e474 \ - --hash=sha256:37aae07b029fa0174d39daf02748b379399b909652a806e5708199bd93899da1 \ - --hash=sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0 \ - --hash=sha256:48a85f2cb5e6799a9ef05347b476cce6c182d6c71ee36925a6c194d074336ef8 \ - --hash=sha256:7768a0dbf16a39aa5e9a3ded568bb545c8c2727396d063bbaf847df05b08cd96 \ - --hash=sha256:7e122b1c4fb252fd85df3ca93578732b4749d9be076593076ef4d07a0233c3e1 \ - --hash=sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04 \ - --hash=sha256:8e537d281831ad0e71007dcdcbe50a71470b978c453fa41ce77186bbe0ed6021 \ - --hash=sha256:98e123f1d5cfd42f886624d84464f7756f60ff6eab89ae845210631714f6db94 \ - --hash=sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d \ - --hash=sha256:b1530ae42e9d6d5b670a34db49a94115a64596bc77710b1d05e9801e62ca0a7c \ - --hash=sha256:b9176b9832e84308818a99a561e90aa479e73c523b3f77afd07913380ae2eab7 \ - --hash=sha256:bdde6f877a18f24844e381d45e9947a49e97933573ac9d4345399be37621e26c \ - --hash=sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc \ - --hash=sha256:bf10f7310db693bb62692609b397e8d67257c55f949abde4c67f9cc574492cc7 \ - --hash=sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d \ - --hash=sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c \ - --hash=sha256:da33a1a5e49c4122ccdfd56cd021ff1ebc4a1ec4e2d01594fef9b6f267a9e741 \ - --hash=sha256:dd1b5a14e417189db4c7b64a6540f31730713d173f0b63e55fabd52d61d8fdce \ - --hash=sha256:e151054aa00bad1f4e1f04919542885f89f5f7d086b8a59e5000e6c616896ffb \ - --hash=sha256:eaea3008c281f1038edb473c1aa8ed8143a5535ff18f978a318f10302b254063 \ - --hash=sha256:ef703f83fc32e131e9bcc0a5094cfe85599e7109f896fe8bc96cc402f3eb4b6e - # via -r src/tools/tidy/config/requirements.in clang-format==18.1.7 \ --hash=sha256:035204410f65d03f98cb81c9c39d6d193f9987917cc88de9d0dbd01f2aa9c302 \ --hash=sha256:05c482a854287a5d21f7567186c0bd4b8dbd4a871751e655a45849185f30b931 \ @@ -45,26 +21,6 @@ clang-format==18.1.7 \ --hash=sha256:f4f77ac0f4f9a659213fedda0f2d216886c410132e6e7dd4b13f92b34e925554 \ --hash=sha256:f935d34152a2e11e55120eb9182862f432bc9789ab819f680c9f6db4edebf9e3 # via -r src/tools/tidy/config/requirements.in -click==8.1.3 \ - --hash=sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e \ - --hash=sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48 - # via black -mypy-extensions==1.0.0 \ - --hash=sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d \ - --hash=sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782 - # via black -packaging==23.1 \ - --hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \ - --hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f - # via black -pathspec==0.11.1 \ - --hash=sha256:2798de800fa92780e33acca925945e9a19a133b715067cf165b8866c15a31687 \ - --hash=sha256:d8af70af76652554bd134c22b3e8a1cc46ed7d91edcdd721ef1a0c51a84a5293 - # via black -platformdirs==4.2.2 \ - --hash=sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee \ - --hash=sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3 - # via black ruff==0.4.9 \ --hash=sha256:06b60f91bfa5514bb689b500a25ba48e897d18fea14dce14b48a0c40d1635893 \ --hash=sha256:0e8e7b95673f22e0efd3571fb5b0cf71a5eaaa3cc8a776584f3b2cc878e46bff \ @@ -84,11 +40,3 @@ ruff==0.4.9 \ --hash=sha256:e91175fbe48f8a2174c9aad70438fe9cb0a5732c4159b2a10a3565fea2d94cde \ --hash=sha256:f1cb0828ac9533ba0135d148d214e284711ede33640465e706772645483427e3 # via -r src/tools/tidy/config/requirements.in -tomli==2.0.1 \ - --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \ - --hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f - # via black -typing-extensions==4.12.2 \ - --hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \ - --hash=sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8 - # via black diff --git a/src/tools/tidy/config/ruff.toml b/src/tools/tidy/config/ruff.toml index de23d93593c..4a5aa618be1 100644 --- a/src/tools/tidy/config/ruff.toml +++ b/src/tools/tidy/config/ruff.toml @@ -19,6 +19,9 @@ extend-exclude = [ "src/tools/enzyme/", "src/tools/rustc-perf/", "src/gcc/", + "compiler/rustc_codegen_gcc", + "src/tools/clippy", + "src/tools/miri", # Hack: CI runs from a subdirectory under the main checkout "../src/doc/nomicon/", "../src/tools/cargo/", @@ -34,6 +37,9 @@ extend-exclude = [ "../src/tools/enzyme/", "../src/tools/rustc-perf/", "../src/gcc/", + "../compiler/rustc_codegen_gcc", + "../src/tools/clippy", + "../src/tools/miri", ] [lint] diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index afa0b9a6760..7d3287aaeb9 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -535,6 +535,8 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[ "regalloc2", "region", "rustc-hash", + "serde", + "serde_derive", "slice-group-by", "smallvec", "stable_deref_trait", diff --git a/src/tools/tidy/src/ext_tool_checks.rs b/src/tools/tidy/src/ext_tool_checks.rs index 8f21338c7db..9792650d37d 100644 --- a/src/tools/tidy/src/ext_tool_checks.rs +++ b/src/tools/tidy/src/ext_tool_checks.rs @@ -32,9 +32,8 @@ const REL_PY_PATH: &[&str] = &["Scripts", "python3.exe"]; const REL_PY_PATH: &[&str] = &["bin", "python3"]; const RUFF_CONFIG_PATH: &[&str] = &["src", "tools", "tidy", "config", "ruff.toml"]; -const BLACK_CONFIG_PATH: &[&str] = &["src", "tools", "tidy", "config", "black.toml"]; /// Location within build directory -const RUFF_CACH_PATH: &[&str] = &["cache", "ruff_cache"]; +const RUFF_CACHE_PATH: &[&str] = &["cache", "ruff_cache"]; const PIP_REQ_PATH: &[&str] = &["src", "tools", "tidy", "config", "requirements.txt"]; pub fn check( @@ -96,7 +95,7 @@ fn check_impl( let mut cfg_path = root_path.to_owned(); cfg_path.extend(RUFF_CONFIG_PATH); let mut cache_dir = outdir.to_owned(); - cache_dir.extend(RUFF_CACH_PATH); + cache_dir.extend(RUFF_CACHE_PATH); cfg_args_ruff.extend([ "--config".as_ref(), @@ -124,33 +123,36 @@ fn check_impl( } if python_fmt { - let mut cfg_args_black = cfg_args.clone(); - let mut file_args_black = file_args.clone(); + let mut cfg_args_ruff = cfg_args.clone(); + let mut file_args_ruff = file_args.clone(); if bless { eprintln!("formatting python files"); } else { eprintln!("checking python file formatting"); - cfg_args_black.push("--check".as_ref()); + cfg_args_ruff.push("--check".as_ref()); } let mut cfg_path = root_path.to_owned(); - cfg_path.extend(BLACK_CONFIG_PATH); + cfg_path.extend(RUFF_CONFIG_PATH); + let mut cache_dir = outdir.to_owned(); + cache_dir.extend(RUFF_CACHE_PATH); - cfg_args_black.extend(["--config".as_ref(), cfg_path.as_os_str()]); + cfg_args_ruff.extend(["--config".as_ref(), cfg_path.as_os_str()]); - if file_args_black.is_empty() { - file_args_black.push(root_path.as_os_str()); + if file_args_ruff.is_empty() { + file_args_ruff.push(root_path.as_os_str()); } - let mut args = merge_args(&cfg_args_black, &file_args_black); - let res = py_runner(py_path.as_ref().unwrap(), true, None, "black", &args); + let mut args = merge_args(&cfg_args_ruff, &file_args_ruff); + args.insert(0, "format".as_ref()); + let res = py_runner(py_path.as_ref().unwrap(), true, None, "ruff", &args); if res.is_err() && show_diff { eprintln!("\npython formatting does not match! Printing diff:"); args.insert(0, "--diff".as_ref()); - let _ = py_runner(py_path.as_ref().unwrap(), true, None, "black", &args); + let _ = py_runner(py_path.as_ref().unwrap(), true, None, "ruff", &args); } // Rethrow error let _ = res?; @@ -445,7 +447,7 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> { } let status = Command::new("shellcheck").args(args).status()?; - if status.success() { Ok(()) } else { Err(Error::FailedCheck("black")) } + if status.success() { Ok(()) } else { Err(Error::FailedCheck("shellcheck")) } } /// Check git for tracked files matching an extension diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index ac82a17e145..3a021e189f3 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -510,7 +510,6 @@ ui/confuse-field-and-method/issue-2392.rs ui/confuse-field-and-method/issue-32128.rs ui/confuse-field-and-method/issue-33784.rs ui/const-generics/generic_arg_infer/issue-91614.rs -ui/const-generics/generic_const_exprs/auxiliary/issue-94287-aux.rs ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs ui/const-generics/generic_const_exprs/issue-100217.rs ui/const-generics/generic_const_exprs/issue-100360.rs @@ -540,7 +539,6 @@ ui/const-generics/generic_const_exprs/issue-85848.rs ui/const-generics/generic_const_exprs/issue-86710.rs ui/const-generics/generic_const_exprs/issue-89851.rs ui/const-generics/generic_const_exprs/issue-90847.rs -ui/const-generics/generic_const_exprs/issue-94287.rs ui/const-generics/generic_const_exprs/issue-94293.rs ui/const-generics/generic_const_exprs/issue-96699.rs ui/const-generics/generic_const_exprs/issue-97047-ice-1.rs @@ -3481,8 +3479,6 @@ ui/pattern/usefulness/issue-80501-or-pat-and-macro.rs ui/pattern/usefulness/issue-82772-match-box-as-struct.rs ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs ui/pattern/usefulness/issue-88747.rs -ui/polymorphization/issue-74614.rs -ui/polymorphization/issue-74636.rs ui/privacy/auxiliary/issue-117997.rs ui/privacy/auxiliary/issue-119463-extern.rs ui/privacy/auxiliary/issue-17718-const-privacy.rs |
