Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest Rust nightly v1.75 #1065

Merged
merged 6 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion applications/hull/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Shell {
// TODO: Sort IDs.
for (id, job) in self.jobs.lock().iter() {
// TODO: Separate job parts if they are in different states.
let Some(state) = &job.parts.get(0).map(|part| &part.state) else {
let Some(state) = &job.parts.first().map(|part| &part.state) else {
continue;
};
let line = &job.string;
Expand Down
2 changes: 1 addition & 1 deletion applications/loadc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn rmain(matches: Matches) -> Result<c_int, String> {
)
).map_err(|_| String::from("failed to get current task"))?;

let path = matches.free.get(0).ok_or_else(|| "Missing path to ELF executable".to_string())?;
let path = matches.free.first().ok_or_else(|| "Missing path to ELF executable".to_string())?;
let file_ref = Path::new(path).get_file(&curr_wd)
.ok_or_else(|| format!("Failed to access file at {path:?}"))?;
let file = file_ref.lock();
Expand Down
2 changes: 1 addition & 1 deletion applications/ping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn main(args: Vec<String>) -> isize {
}

fn _main(matches: Matches) -> Result<(), &'static str> {
let remote = IpAddress::from_str(matches.free.get(0).ok_or("no arguments_provided")?)
let remote = IpAddress::from_str(matches.free.first().ok_or("no arguments_provided")?)
.map_err(|_| "invalid argument")?;

let interface = net::get_default_interface().ok_or("no network interfaces available")?;
Expand Down
2 changes: 1 addition & 1 deletion applications/serial_echo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use serial_port::{SerialPort, SerialPortAddress, get_serial_port};


pub fn main(args: Vec<String>) -> isize {
let serial_port_address = args.get(0)
let serial_port_address = args.first()
.and_then(|s| SerialPortAddress::try_from(&**s).ok())
.unwrap_or(SerialPortAddress::COM1);

Expand Down
2 changes: 1 addition & 1 deletion applications/shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ impl Shell {
/// Try to match the incomplete command against all internal commands. Returns a
/// vector that contains all matching results.
fn find_internal_cmd_match(&mut self, incomplete_cmd: &String) -> Result<Vec<String>, &'static str> {
let internal_cmds = vec!["fg", "bg", "jobs", "clear"];
let internal_cmds = ["fg", "bg", "jobs", "clear"];
let mut match_cmds = Vec::new();
for cmd in internal_cmds.iter() {
if cmd.starts_with(incomplete_cmd) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/ata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.1.0"
edition = "2018"

[dependencies]
bitflags = "1.1.0"
bitflags = "2.4.1"
log = "0.4.8"
spin = "0.9.4"
x86_64 = "0.14.8"
Expand Down
3 changes: 3 additions & 0 deletions kernel/ata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const PCI_BAR_PORT_MASK: u16 = 0xFFFC;

bitflags! {
/// The possible error values found in an ATA drive's error port.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct AtaError: u8 {
const BAD_BLOCK = 0x80;
const UNCORRECTABLE_DATA = 0x40;
Expand All @@ -55,6 +56,7 @@ bitflags! {

bitflags! {
/// The possible status values found in an ATA drive's status port.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct AtaStatus: u8 {
/// When set, the drive's port values are still changing, so ports shouldn't be accessed.
const BUSY = 0x80;
Expand All @@ -73,6 +75,7 @@ bitflags! {

bitflags! {
/// The possible control values used in an ATA drive's status port.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
struct AtaControl: u8 {
/// Set this to read back the High Order Byte of the last-written LBA48 value.
const HOB = 0x80;
Expand Down
2 changes: 1 addition & 1 deletion kernel/boot_info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Abstraction over multiboot2 and UEFI boot information"
edition = "2021"

[dependencies]
bitflags = "1.3"
bitflags = "2.4.1"
kernel_config = { path = "../kernel_config" }
memory_structs = { path = "../memory_structs" }
multiboot2 = { version = "0.14", optional = true }
Expand Down
6 changes: 3 additions & 3 deletions kernel/frame_allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,13 +1196,13 @@ pub fn allocate_frames_deferred(
// because we are searching the general frames list, it doesn't matter if part of the chunk was found
// since we only create new reserved frames.
trace!("Only part of the requested allocation was found in the general frames list.");
return Err(alloc_err).map_err(From::from);
return Err(From::from(alloc_err));
}
Err(_other) => return Err(alloc_err).map_err(From::from),
Err(_other) => return Err(From::from(alloc_err)),
}
},
AllocationError::ContiguousChunkNotFound(f, numf) => (f, numf),
_ => return Err(alloc_err).map_err(From::from),
_ => return Err(From::from(alloc_err)),
}
};

Expand Down
7 changes: 2 additions & 5 deletions kernel/framebuffer_compositor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern crate shapes;

use alloc::collections::BTreeMap;
use alloc::vec::{Vec};
use core::hash::{Hash, Hasher, BuildHasher};
use core::hash::{Hash, BuildHasher};
use hashbrown::hash_map::{DefaultHashBuilder};
use compositor::{Compositor, FramebufferUpdates, CompositableRegion};
use framebuffer::{Framebuffer, Pixel};
Expand Down Expand Up @@ -268,8 +268,5 @@ impl Compositor for FrameCompositor {

/// Gets the hash of an item
fn hash<T: Hash>(item: T) -> u64 {
let builder = DefaultHashBuilder::default();
let mut hasher = builder.build_hasher();
item.hash(&mut hasher);
hasher.finish()
DefaultHashBuilder::default().hash_one(&item)
}
2 changes: 1 addition & 1 deletion kernel/gdt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
spin = "0.9.4"
x86_64 = "0.14.8"
bit_field = "0.7.0"
bitflags = "1.1.0"
bitflags = "2.4.1"
log = "0.4.8"

[dependencies.atomic_linked_list]
Expand Down
2 changes: 1 addition & 1 deletion kernel/iommu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ log = "0.4.8"
spin = "0.9.4"
volatile = "0.2.7"
zerocopy = "0.5.0"
bitflags = "1.3.2"
bitflags = "2.4.1"

[dependencies.sync_irq]
path = "../../libs/sync_irq"
Expand Down
1 change: 1 addition & 0 deletions kernel/iommu/src/regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ bitflags! {
///
/// The least significant bits `[22:0]` are `RsvdZ`,
/// meaning that they are reserved for future usage and must be set to 0.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct GlobalStatus: u32 {
/// Compatibility Format Interrupt Status
const CFIS = 1 << 23;
Expand Down
4 changes: 2 additions & 2 deletions kernel/logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern crate sync_irq;
extern crate serial_port_basic;

use log::{Record, Level, Metadata, Log};
use core::{borrow::Borrow, fmt::{self, Write}, ops::Deref};
use core::{fmt::{self, Write}, ops::Deref};
use sync_irq::IrqSafeMutex;
use serial_port_basic::SerialPort;
use alloc::{sync::Arc, vec::Vec};
Expand Down Expand Up @@ -210,7 +210,7 @@ impl DummyLogger {
fn write_fmt(&self, arguments: fmt::Arguments) -> fmt::Result {
if let Some(logger) = &*LOGGER.lock() {
for writer in logger.writers.iter() {
let _ = writer.deref().borrow().lock().write_fmt(arguments);
let _ = writer.deref().lock().write_fmt(arguments);
}
} else {
let _ = EARLY_LOGGER.lock().write_fmt(arguments);
Expand Down
2 changes: 1 addition & 1 deletion kernel/memory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
spin = "0.9.4"
bitflags = "1.1.0"
bitflags = "2.4.1"
xmas-elf = { version = "0.6.2", git = "https://github.com/theseus-os/xmas-elf.git" }
bit_field = "0.7.0"
zerocopy = "0.5.0"
Expand Down
26 changes: 20 additions & 6 deletions kernel/mod_mgmt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn parse_bootloader_modules_into_files(

// Closure to create the directory for a new namespace.
let create_dir = |dir_name: &str| -> Result<NamespaceDir, &'static str> {
VFSDirectory::create(dir_name.to_string(), &namespaces_dir).map(|d| NamespaceDir(d))
VFSDirectory::create(dir_name.to_string(), &namespaces_dir).map(NamespaceDir)
};

let mut process_module = |name: &str, size, pages| -> Result<_, &'static str> {
Expand Down Expand Up @@ -1085,13 +1085,27 @@ impl CrateNamespace {
return Err("not a relocatable elf file");
}

// If a `.theseus_merged` section exists, then the object file's sections have been merged by a partial relinking step.
// If a `.theseus_merged` section exists (it should come before any .text section),
// then the object file's sections have been merged by a partial relinking step.
// If so, then we can use a much faster version of loading/linking.
const THESEUS_MERGED_SEC_NAME: &str = ".theseus_merged";
const THESEUS_MERGED_SEC_SHNDX: u16 = 1;
let sections_are_merged = elf_file.section_header(THESEUS_MERGED_SEC_SHNDX)
.map(|sec| sec.get_name(&elf_file) == Ok(THESEUS_MERGED_SEC_NAME))
.unwrap_or(false);
let sections_are_merged = {
let mut found = false;
for sec_name in elf_file
.section_iter()
.filter_map(|sec| sec.get_name(&elf_file).ok())
{
if sec_name == THESEUS_MERGED_SEC_NAME {
found = true;
break;
}
else if sec_name.starts_with(TEXT_SECTION_NAME) {
found = false;
break;
}
}
found
};

// Allocate enough space to load the sections
let section_pages = allocate_section_pages(&elf_file, kernel_mmi_ref)?;
Expand Down
2 changes: 1 addition & 1 deletion kernel/net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn get_interfaces() -> &'static Mutex<Vec<Arc<NetworkInterface>>> {

/// Returns the first available interface.
pub fn get_default_interface() -> Option<Arc<NetworkInterface>> {
NETWORK_INTERFACES.lock().get(0).cloned()
NETWORK_INTERFACES.lock().first().cloned()
}

/// Returns a port in the range reserved for private, dynamic, and ephemeral
Expand Down
1 change: 1 addition & 0 deletions kernel/panic_entry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#![no_std]
#![feature(alloc_error_handler)]
#![allow(internal_features)]
#![feature(lang_items)]
#![feature(panic_info_message)]

Expand Down
Loading