8000 migrate to the 2024 edition · RustPython/RustPython@17d6efa · GitHub
[go: up one dir, main page]

Skip to content

Commit 17d6efa

Browse files
committed
migrate to the 2024 edition
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
1 parent 235adaf commit 17d6efa

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ members = [
103103
[workspace.package]
104104
version = "0.4.0"
105105
authors = ["RustPython Team"]
106-
edition = "2021"
106+
edition = "2024"
107107
rust-version = "1.85.0"
108108
repository = "https://github.com/RustPython/RustPython"
109109
license = "MIT"

vm/src/suggestion.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ pub fn offer_suggestions(exc: &PyBaseExceptionRef, vm: &VirtualMachine) -> Optio
5252
calculate_suggestions(vm.dir(Some(obj)).ok()?.borrow_vec().iter(), &name)
5353
} else if exc.class().is(vm.ctx.exceptions.name_error) {
5454
let name = exc.as_object().get_attr("name", vm).unwrap();
55-
let mut tb = exc.traceback()?;
56-
for traceback in tb.iter() {
57-
tb = traceback;
58-
}
55+
let tb = exc.traceback()?;
56+
let tb = tb.iter().last().unwrap_or(tb);
5957

6058
let varnames = tb.frame.code.clone().co_varnames(vm);
6159
if let Some(suggestions) = calculate_suggestions(varnames.iter(), &name) {

vm/sre_engine/src/string.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ impl StrDrive for &str {
157157
#[inline]
158158
unsafe fn next_code_point(ptr: &mut *const u8) -> u32 {
159159
// Decode UTF-8
160-
let x = **ptr;
161-
*ptr = ptr.offset(1);
160+
let x = unsafe { **ptr};
161+
*ptr = unsafe { ptr.offset(1) };
162162

163163
if x < 128 {
164164
return x as u32;
@@ -170,25 +170,25 @@ unsafe fn next_code_point(ptr: &mut *const u8) -> u32 {
170170
let init = utf8_first_byte(x, 2);
171171
// SAFETY: `bytes` produces an UTF-8-like string,
172172
// so the iterator must produce a value here.
173-
let y = **ptr;
174-
*ptr = ptr.offset(1);
173+
let y = unsafe { **ptr };
174+
*ptr = unsafe { ptr.offset(1) };
175175
let mut ch = utf8_acc_cont_byte(init, y);
176176
if x >= 0xE0 {
177177
// [[x y z] w] case
178178
// 5th bit in 0xE0 .. 0xEF is always clear, so `init` is still valid
179179
// SAFETY: `bytes` produces an UTF-8-like string,
180180
// so the iterator must produce a value here.
181-
let z = **ptr;
182-
*ptr = ptr.offset(1);
181+
let z = unsafe { **ptr };
182+
*ptr = unsafe { ptr.offset(1) };
183183
let y_z = utf8_acc_cont_byte((y & CONT_MASK) as u32, z);
184184
ch = (init << 12) | y_z;
185185
if x >= 0xF0 {
186186
// [x y z w] case
187187
// use only the lower 3 bits of `init`
188188
// SAFETY: `bytes` produces an UTF-8-like string,
189189
// so the iterator must produce a value here.
190-
let w = **ptr;
191-
*ptr = ptr.offset(1);
190+
let w = unsafe { **ptr};
191+
*ptr = unsafe { ptr.offset(1) };
192192
ch = ((init & 7) << 18) | utf8_acc_cont_byte(y_z, w);
193193
}
194194
}
@@ -205,8 +205,8 @@ unsafe fn next_code_point(ptr: &mut *const u8) -> u32 {
205205
#[inline]
206206
unsafe fn next_code_point_reverse(ptr: &mut *const u8) -> u32 {
207207
// Decode UTF-8
208-
*ptr = ptr.offset(-1);
209-
let w = match **ptr {
208+
*ptr = unsafe { ptr.offset(-1) };
209+
let w = match unsafe { **ptr } {
210210
next_byte if next_byte < 128 => return next_byte as u32,
211211
back_byte => back_byte,
212212
};
@@ -216,20 +216,20 @@ unsafe fn next_code_point_reverse(ptr: &mut *const u8) -> u32 {
216216
let mut ch;
217217
// SAFETY: `bytes` produces an UTF-8-like string,
218218
// so the iterator must produce a value here.
219-
*ptr = ptr.offset(-1);
220-
let z = **ptr;
219+
*ptr = unsafe { ptr.offset(-1) };
220+
let z = unsafe { **ptr };
221221
ch = utf8_first_byte(z, 2);
222222
if utf8_is_cont_byte(z) {
223223
// SAFETY: `bytes` produces an UTF-8-like string,
224224
// so the iterator must produce a value here.
225-
*ptr = ptr.offset(-1);
226-
let y = **ptr;
225+
*ptr = unsafe { ptr.offset(-1) };
226+
let y = unsafe { **ptr };
227227
ch = utf8_first_byte(y, 3);
228228
if utf8_is_cont_byte(y) {
229229
// SAFETY: `bytes` produces an UTF-8-like string,
230230
// so the iterator must produce a value here.
231-
*ptr = ptr.offset(-1);
232-
let x = **ptr;
231+
*ptr = unsafe { ptr.offset(-1) };
232+
let x = unsafe { **ptr };
233233
ch = utf8_first_byte(x, 4);
234234
ch = utf8_acc_cont_byte(ch, y);
235235
}

0 commit comments

Comments
 (0)
0