Skip to content

Commit 6afa791

Browse files
committed
Update to 2024-12-14 compiler
The issue with the LSP autocomplete is fixed as mentioned in rust-lang/rust-analyzer#18547
1 parent 14d402c commit 6afa791

File tree

22 files changed

+135
-141
lines changed

22 files changed

+135
-141
lines changed

common/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "common"
3-
edition = "2021"
3+
edition = "2024"
44
description.workspace = true
55
authors.workspace = true
66
version.workspace = true

kernel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "yaos"
3-
edition = "2021"
3+
edition = "2024"
44
version.workspace = true
55
authors.workspace = true
66
description.workspace = true

kernel/src/debugging/backtrace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ mod tests {
369369
use crate::debugging::backtrace::{Backtrace, BacktraceNextError, CallerSavedRegs};
370370
use alloc::collections::VecDeque;
371371
use core::ffi::c_void;
372-
use unwinding::abi::{UnwindContext, UnwindReasonCode, _Unwind_Backtrace, _Unwind_GetIP};
372+
use unwinding::abi::{_Unwind_Backtrace, _Unwind_GetIP, UnwindContext, UnwindReasonCode};
373373

374374
#[test_case]
375375
fn backtrace() {

kernel/src/debugging/eh_frame_parser.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ mod tests {
341341
};
342342
use elf::ElfBytes;
343343
use gimli::{
344-
constants, BaseAddresses, CallFrameInstruction, CallFrameInstructionIter,
345-
CommonInformationEntry, EhFrame, EndianSlice, FrameDescriptionEntry, LittleEndian,
346-
ReaderOffset, StoreOnHeap, UnwindContext, UnwindSection, UnwindTableRow,
344+
BaseAddresses, CallFrameInstruction, CallFrameInstructionIter, CommonInformationEntry,
345+
EhFrame, EndianSlice, FrameDescriptionEntry, LittleEndian, ReaderOffset, StoreOnHeap,
346+
UnwindContext, UnwindSection, UnwindTableRow, constants,
347347
};
348348

349349
const KERNEL_ELF_TEST_BINARY: &[u8] = include_bytes!("../test/test_data/elf/kernel");

kernel/src/drivers/virtio/net/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use crate::{
33
debug,
44
drivers::virtio::{
55
capability::{
6-
virtio_pci_cap, VIRTIO_PCI_CAP_COMMON_CFG, VIRTIO_PCI_CAP_DEVICE_CFG,
7-
VIRTIO_PCI_CAP_NOTIFY_CFG,
6+
VIRTIO_PCI_CAP_COMMON_CFG, VIRTIO_PCI_CAP_DEVICE_CFG, VIRTIO_PCI_CAP_NOTIFY_CFG,
7+
virtio_pci_cap,
88
},
99
virtqueue::{BufferDirection, VirtQueue},
1010
},
1111
info,
1212
klibc::{
13-
util::{is_power_of_2_or_zero, BufferExtension, ByteInterpretable},
1413
MMIO,
14+
util::{BufferExtension, ByteInterpretable, is_power_of_2_or_zero},
1515
},
1616
net::mac::MacAddress,
1717
pci::PCIDevice,

kernel/src/interrupts/trap.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::trap_cause::{exception::ENVIRONMENT_CALL_FROM_U_MODE, InterruptCause};
1+
use super::trap_cause::{InterruptCause, exception::ENVIRONMENT_CALL_FROM_U_MODE};
22
use crate::{
33
cpu::{self},
44
debug,
@@ -15,12 +15,12 @@ use crate::{
1515
use common::syscalls::trap_frame::{Register, TrapFrame};
1616
use core::panic;
1717

18-
#[no_mangle]
18+
#[unsafe(no_mangle)]
1919
extern "C" fn handle_timer_interrupt() {
2020
scheduler::THE.lock().schedule();
2121
}
2222

23-
#[no_mangle]
23+
#[unsafe(no_mangle)]
2424
fn handle_external_interrupt() {
2525
debug!("External interrupt occurred!");
2626
let plic_interrupt = plic::get_next_pending().expect("There should be a pending interrupt.");
@@ -91,7 +91,7 @@ fn handle_unhandled_exception(
9191
panic!("{}", message);
9292
}
9393

94-
#[no_mangle]
94+
#[unsafe(no_mangle)]
9595
extern "C" fn handle_exception(
9696
cause: InterruptCause,
9797
stval: usize,
@@ -105,7 +105,7 @@ extern "C" fn handle_exception(
105105
}
106106
}
107107

108-
#[no_mangle]
108+
#[unsafe(no_mangle)]
109109
extern "C" fn handle_unimplemented(
110110
cause: InterruptCause,
111111
_stval: usize,

kernel/src/klibc/elf.rs

+32-41
Original file line numberDiff line numberDiff line change
@@ -377,47 +377,38 @@ mod tests {
377377

378378
assert_eq!(program_headers.len(), 4);
379379

380-
assert_eq!(
381-
program_headers[0],
382-
ElfProgramHeaderEntry {
383-
header_type: ProgramHeaderType::PT_LOAD,
384-
access_flags: ProgramHeaderFlags::RX,
385-
offset_in_file: 0x1000,
386-
virtual_address: 0x1000,
387-
physical_address: 0x1000,
388-
file_size: 0xba,
389-
memory_size: 0xba,
390-
alignment: 0x1000,
391-
}
392-
);
393-
394-
assert_eq!(
395-
program_headers[1],
396-
ElfProgramHeaderEntry {
397-
header_type: ProgramHeaderType::PT_LOAD,
398-
access_flags: ProgramHeaderFlags::R,
399-
offset_in_file: 0x10c0,
400-
virtual_address: 0x10c0,
401-
physical_address: 0x10c0,
402-
file_size: 0xf0,
403-
memory_size: 0xf0,
404-
alignment: 0x1000,
405-
}
406-
);
407-
408-
assert_eq!(
409-
program_headers[2],
410-
ElfProgramHeaderEntry {
411-
header_type: ProgramHeaderType::PT_LOAD,
412-
access_flags: ProgramHeaderFlags::RW,
413-
offset_in_file: 0x11b0,
414-
virtual_address: 0x11b0,
415-
physical_address: 0x11b0,
416-
file_size: 0x3a0,
417-
memory_size: 0x3a0,
418-
alignment: 0x1000,
419-
}
420-
);
380+
assert_eq!(program_headers[0], ElfProgramHeaderEntry {
381+
header_type: ProgramHeaderType::PT_LOAD,
382+
access_flags: ProgramHeaderFlags::RX,
383+
offset_in_file: 0x1000,
384+
virtual_address: 0x1000,
385+
physical_address: 0x1000,
386+
file_size: 0xba,
387+
memory_size: 0xba,
388+
alignment: 0x1000,
389+
});
390+
391+
assert_eq!(program_headers[1], ElfProgramHeaderEntry {
392+
header_type: ProgramHeaderType::PT_LOAD,
393+
access_flags: ProgramHeaderFlags::R,
394+
offset_in_file: 0x10c0,
395+
virtual_address: 0x10c0,
396+
physical_address: 0x10c0,
397+
file_size: 0xf0,
398+
memory_size: 0xf0,
399+
alignment: 0x1000,
400+
});
401+
402+
assert_eq!(program_headers[2], ElfProgramHeaderEntry {
403+
header_type: ProgramHeaderType::PT_LOAD,
404+
access_flags: ProgramHeaderFlags::RW,
405+
offset_in_file: 0x11b0,
406+
virtual_address: 0x11b0,
407+
physical_address: 0x11b0,
408+
file_size: 0x3a0,
409+
memory_size: 0x3a0,
410+
alignment: 0x1000,
411+
});
421412

422413
// The fourth element is GNU_STACK. We don't need it, therefore we don't check for it here.
423414
}

kernel/src/memory/heap.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use core::{
22
alloc::{GlobalAlloc, Layout},
33
marker::PhantomData,
44
mem::{align_of, size_of},
5-
ptr::{null_mut, NonNull},
5+
ptr::{NonNull, null_mut},
66
};
77

88
use common::{mutex::Mutex, util::align_up};
99

1010
use crate::{assert::static_assert_size, klibc::util::minimum_amount_of_pages};
1111

12-
use super::{page_allocator::PageAllocator, PAGE_SIZE};
12+
use super::{PAGE_SIZE, page_allocator::PageAllocator};
1313

1414
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
1515
#[repr(transparent)]
@@ -284,7 +284,7 @@ mod test {
284284
alloc::GlobalAlloc,
285285
mem::MaybeUninit,
286286
ops::Range,
287-
ptr::{addr_of_mut, NonNull},
287+
ptr::{NonNull, addr_of_mut},
288288
};
289289

290290
const HEAP_PAGES: usize = 8;

kernel/src/memory/page.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl DerefMut for PinnedHeapPages {
9595

9696
#[cfg(test)]
9797
mod tests {
98-
use crate::memory::{page::Pages, PAGE_SIZE};
98+
use crate::memory::{PAGE_SIZE, page::Pages};
9999

100100
use super::{Page, PinnedHeapPages};
101101

kernel/src/memory/page_allocator.rs

+65-66
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::{
55
fmt::Debug,
66
mem::MaybeUninit,
77
ops::Range,
8-
ptr::{null_mut, NonNull},
8+
ptr::{NonNull, null_mut},
99
};
1010

1111
#[repr(u8)]
@@ -210,13 +210,13 @@ pub trait PageAllocator {
210210

211211
#[cfg(test)]
212212
mod tests {
213-
use super::{MetadataPageAllocator, Page, PAGE_SIZE};
213+
use super::{MetadataPageAllocator, PAGE_SIZE, Page};
214214
use crate::memory::page_allocator::PageStatus;
215215
use common::mutex::Mutex;
216216
use core::{
217217
mem::MaybeUninit,
218218
ops::Range,
219-
ptr::{addr_of, addr_of_mut, NonNull},
219+
ptr::{NonNull, addr_of, addr_of_mut},
220220
};
221221

222222
const MEMORY_PATTERN: u8 = 0x42;
@@ -249,11 +249,13 @@ mod tests {
249249
#[test_case]
250250
fn clean_start() {
251251
init_allocator(false, &[]);
252-
assert!(PAGE_ALLOC
253-
.lock()
254-
.metadata
255-
.iter()
256-
.all(|s| *s == PageStatus::FirstUse));
252+
assert!(
253+
PAGE_ALLOC
254+
.lock()
255+
.metadata
256+
.iter()
257+
.all(|s| *s == PageStatus::FirstUse)
258+
);
257259
}
258260

259261
#[test_case]
@@ -264,9 +266,11 @@ mod tests {
264266
assert!(alloc(1).is_none());
265267
let allocator = PAGE_ALLOC.lock();
266268
let (last, all_metadata_except_last) = allocator.metadata.split_last().unwrap();
267-
assert!(all_metadata_except_last
268-
.iter()
269-
.all(|s| *s == PageStatus::Used));
269+
assert!(
270+
all_metadata_except_last
271+
.iter()
272+
.all(|s| *s == PageStatus::Used)
273+
);
270274
assert_eq!(*last, PageStatus::Last);
271275
}
272276

@@ -293,68 +297,63 @@ mod tests {
293297
init_allocator(false, &[]);
294298
let page1 = alloc(1).unwrap();
295299
assert_eq!(PAGE_ALLOC.lock().metadata[0], PageStatus::Last);
296-
assert!(PAGE_ALLOC.lock().metadata[1..]
297-
.iter()
298-
.all(|s| *s == PageStatus::FirstUse));
300+
assert!(
301+
PAGE_ALLOC.lock().metadata[1..]
302+
.iter()
303+
.all(|s| *s == PageStatus::FirstUse)
304+
);
299305
let page2 = alloc(2).unwrap();
300-
assert_eq!(
301-
PAGE_ALLOC.lock().metadata[..3],
302-
[PageStatus::Last, PageStatus::Used, PageStatus::Last]
306+
assert_eq!(PAGE_ALLOC.lock().metadata[..3], [
307+
PageStatus::Last,
308+
PageStatus::Used,
309+
PageStatus::Last
310+
]);
311+
assert!(
312+
PAGE_ALLOC.lock().metadata[3..]
313+
.iter()
314+
.all(|s| *s == PageStatus::FirstUse)
303315
);
304-
assert!(PAGE_ALLOC.lock().metadata[3..]
305-
.iter()
306-
.all(|s| *s == PageStatus::FirstUse));
307316
let page3 = alloc(3).unwrap();
308-
assert_eq!(
309-
PAGE_ALLOC.lock().metadata[..6],
310-
[
311-
PageStatus::Last,
312-
PageStatus::Used,
313-
PageStatus::Last,
314-
PageStatus::Used,
315-
PageStatus::Used,
316-
PageStatus::Last
317-
]
317+
assert_eq!(PAGE_ALLOC.lock().metadata[..6], [
318+
PageStatus::Last,
319+
PageStatus::Used,
320+
PageStatus::Last,
321+
PageStatus::Used,
322+
PageStatus::Used,
323+
PageStatus::Last
324+
]);
325+
assert!(
326+
PAGE_ALLOC.lock().metadata[6..]
327+
.iter()
328+
.all(|s| *s == PageStatus::FirstUse),
318329
);
319-
assert!(PAGE_ALLOC.lock().metadata[6..]
320-
.iter()
321-
.all(|s| *s == PageStatus::FirstUse),);
322330
dealloc(page2);
323-
assert_eq!(
324-
PAGE_ALLOC.lock().metadata[..6],
325-
[
326-
PageStatus::Last,
327-
PageStatus::Free,
328-
PageStatus::Free,
329-
PageStatus::Used,
330-
PageStatus::Used,
331-
PageStatus::Last
332-
]
333-
);
331+
assert_eq!(PAGE_ALLOC.lock().metadata[..6], [
332+
PageStatus::Last,
333+
PageStatus::Free,
334+
PageStatus::Free,
335+
PageStatus::Used,
336+
PageStatus::Used,
337+
PageStatus::Last
338+
]);
334339
dealloc(page1);
335-
assert_eq!(
336-
PAGE_ALLOC.lock().metadata[..6],
337-
[
338-
PageStatus::Free,
339-
PageStatus::Free,
340-
PageStatus::Free,
341-
PageStatus::Used,
342-
PageStatus::Used,
343-
PageStatus::Last
344-
]
345-
);
340+
assert_eq!(PAGE_ALLOC.lock().metadata[..6], [
341+
PageStatus::Free,
342+
PageStatus::Free,
343+
PageStatus::Free,
344+
PageStatus::Used,
345+
PageStatus::Used,
346+
PageStatus::Last
347+
]);
346348
dealloc(page3);
347-
assert_eq!(
348-
PAGE_ALLOC.lock().metadata[..6],
349-
[
350-
PageStatus::Free,
351-
PageStatus::Free,
352-
PageStatus::Free,
353-
PageStatus::Free,
354-
PageStatus::Free,
355-
PageStatus::Free
356-
]
357-
);
349+
assert_eq!(PAGE_ALLOC.lock().metadata[..6], [
350+
PageStatus::Free,
351+
PageStatus::Free,
352+
PageStatus::Free,
353+
PageStatus::Free,
354+
PageStatus::Free,
355+
PageStatus::Free
356+
]);
358357
}
359358

360359
#[test_case]

0 commit comments

Comments
 (0)