pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/RustPython/RustPython/commit/c883f0ad8af76a981eaca511fa2c3e334117dbad

8.css" /> Updates for Rust 1.82 · RustPython/RustPython@c883f0a · GitHub
Skip to content

Commit c883f0a

Browse files
committed
Updates for Rust 1.82
1 parent eae6011 commit c883f0a

File tree

9 files changed

+17
-40
lines changed

9 files changed

+17
-40
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ members = [
105105
version = "0.4.0"
106106
authors = ["RustPython Team"]
107107
edition = "2021"
108-
rust-version = "1.80.0"
108+
rust-version = "1.82.0"
109109
repository = "https://github.com/RustPython/RustPython"
110110
license = "MIT"
111111

common/src/boxvec.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! An unresizable vector backed by a `Box<[T]>`
22
33
use std::{
4-
alloc,
54
borrow::{Borrow, BorrowMut},
65
cmp, fmt,
76
mem::{self, MaybeUninit},
@@ -35,29 +34,11 @@ macro_rules! panic_oob {
3534
};
3635
}
3736

38-
fn capacity_overflow() -> ! {
39-
panic!("capacity overflow")
40-
}
41-
4237
impl<T> BoxVec<T> {
4338
pub fn new(n: usize) -> BoxVec<T> {
44-
unsafe {
45-
let layout = match alloc::Layout::array::<T>(n) {
46-
Ok(l) => l,
47-
Err(_) => capacity_overflow(),
48-
};
49-
let ptr = if mem::size_of::<T>() == 0 {
50-
ptr::NonNull::<MaybeUninit<T>>::dangling().as_ptr()
51-
} else {
52-
let ptr = alloc::alloc(layout);
53-
if ptr.is_null() {
54-
alloc::handle_alloc_error(layout)
55-
}
56-
ptr as *mut MaybeUninit<T>
57-
};
58-
let ptr = ptr::slice_from_raw_parts_mut(ptr, n);
59-
let xs = Box::from_raw(ptr);
60-
BoxVec { xs, len: 0 }
39+
BoxVec {
40+
xs: Box::new_uninit_slice(n),
41+
len: 0,
6142
}
6243
}
6344

common/src/lock/cell_lock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use lock_api::{
22
GetThreadId, RawMutex, RawRwLock, RawRwLockDowngrade, RawRwLockRecursive, RawRwLockUpgrade,
33
RawRwLockUpgradeDowngrade,
44
};
5-
use std::{cell::Cell, num::NonZeroUsize};
5+
use std::{cell::Cell, num::NonZero};
66

77
pub struct RawCellMutex {
88
locked: Cell<bool>,
@@ -203,7 +203,7 @@ fn deadlock(lock_kind: &str, ty: &str) -> ! {
203203
pub struct SingleThreadId(());
204204
unsafe impl GetThreadId for SingleThreadId {
205205
const INIT: Self = SingleThreadId(());
206-
fn nonzero_thread_id(&self) -> NonZeroUsize {
207-
NonZeroUsize::new(1).unwrap()
206+
fn nonzero_thread_id(&self) -> NonZero<usize> {
207+
NonZero::new(1).unwrap()
208208
}
209209
}

stdlib/src/grp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ mod grp {
8383
#[pyfunction]
8484
fn getgrall(vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {
8585
// setgrent, getgrent, etc are not thread safe. Could use fgetgrent_r, but this is easier
86-
static GETGRALL: parking_lot::Mutex<()> = parking_lot::const_mutex(());
86+
static GETGRALL: parking_lot::Mutex<()> = parking_lot::Mutex::new(());
8787
let _guard = GETGRALL.lock();
8888
let mut list = Vec::new();
8989

stdlib/src/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ mod platform {
3636
// based off winsock2.h: https://gist.github.com/piscisaureus/906386#file-winsock2-h-L128-L141
3737

3838
pub unsafe fn FD_SET(fd: RawFd, set: *mut fd_set) {
39-
let mut slot = std::ptr::addr_of_mut!((*set).fd_array).cast::<RawFd>();
39+
let mut slot = (&raw mut (*set).fd_array).cast::<RawFd>();
4040
let fd_count = (*set).fd_count;
4141
for _ in 0..fd_count {
4242
if *slot == fd {

stdlib/src/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ mod _socket {
22172217
fn as_slice(&self) -> &[netioapi::MIB_IF_ROW2] {
22182218
unsafe {
22192219
let p = self.ptr.as_ptr();
2220-
let ptr = ptr::addr_of!((*p).Table) as *const netioapi::MIB_IF_ROW2;
2220+
let ptr = &raw const (*p).Table as *const netioapi::MIB_IF_ROW2;
22212221
std::slice::from_raw_parts(ptr, (*p).NumEntries as usize)
22222222
}
22232223
}

stdlib/src/sqlite.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ mod _sqlite {
7676
ffi::{c_int, c_longlong, c_uint, c_void, CStr},
7777
fmt::Debug,
7878
ops::Deref,
79-
ptr::{addr_of_mut, null, null_mut},
79+
ptr::{null, null_mut},
8080
thread::ThreadId,
8181
};
8282

@@ -1178,14 +1178,10 @@ mod _sqlite {
11781178
)
11791179
};
11801180

1181-
// TODO: replace with Result.inspect_err when stable
1182-
if let Err(exc) = db.check(ret, vm) {
1181+
db.check(ret, vm).inspect_err(|_| {
11831182
// create_collation do not call destructor if error occur
11841183
let _ = unsafe { Box::from_raw(data) };
1185-
Err(exc)
1186-
} else {
1187-
Ok(())
1188-
}
1184+
})
11891185
}
11901186

11911187
#[pymethod]
@@ -2396,7 +2392,7 @@ mod _sqlite {
23962392
let ret = unsafe {
23972393
sqlite3_open_v2(
23982394
path,
2399-
addr_of_mut!(db),
2395+
&raw mut db,
24002396
SQLITE_OPEN_READWRITE
24012397
| SQLITE_OPEN_CREATE
24022398
| if uri { SQLITE_OPEN_URI } else { 0 },

vm/src/object/core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ unsafe impl Link for WeakLink {
322322

323323
#[inline(always)]
324324
unsafe fn pointers(target: NonNull<Self::Target>) -> NonNull<Pointers<Self::Target>> {
325-
NonNull::new_unchecked(ptr::addr_of_mut!((*target.as_ptr()).0.payload.pointers))
325+
NonNull::new_unchecked(&raw mut (*target.as_ptr()).0.payload.pointers)
326326
}
327327
}
328328

@@ -1047,7 +1047,7 @@ impl<T: PyObjectPayload> PyRef<T> {
10471047
pub fn leak(pyref: Self) -> &'static Py<T> {
10481048
let ptr = pyref.ptr;
10491049
std::mem::forget(pyref);
1050-
unsafe { &*ptr.as_ptr() }
1050+
unsafe { ptr.as_ref() }
10511051
}
10521052
}
10531053

vm/src/stdlib/pwd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mod pwd {
9292
#[pyfunction]
9393
fn getpwall(vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {
9494
// setpwent, getpwent, etc are not thread safe. Could use fgetpwent_r, but this is easier
95-
static GETPWALL: parking_lot::Mutex<()> = parking_lot::const_mutex(());
95+
static GETPWALL: parking_lot::Mutex<()> = parking_lot::Mutex::new(());
9696
let _guard = GETPWALL.lock();
9797
let mut list = Vec::new();
9898

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy