Some more clippy fixes, warnings are noisy

This commit is contained in:
2025-03-05 00:57:06 +00:00
parent d53661b9a0
commit 014ec5310c
8 changed files with 34 additions and 19 deletions
+2 -1
View File
@@ -5,5 +5,6 @@
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
},
"rust-analyzer.check.command": "clippy"
"rust-analyzer.check.command": "clippy",
"rust-analyzer.cargo.buildScripts.enable": true
}
+2
View File
@@ -1,3 +1,5 @@
#![expect(unused)]
use core::arch::x86_64::__cpuid;
use crate::arch::x86_64::memory::mapping::PHYSICAL_MEMORY_OFFSET;
+1
View File
@@ -1,3 +1,4 @@
#![expect(unused)]
use core::arch::x86_64::__cpuid;
use spin::Lazy;
use x86_64::registers::model_specific::Msr;
+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::missing_safety_doc)]
use x86_64::instructions::port::Port;
const CMD_INIT: u8 = 0x11;
@@ -173,15 +173,22 @@ impl FoundryFallbackAllocator {
}
}
/// Initialises the Foundry OS fallback allocator. This is currently a
/// linked list allocator pulled from the linked_list_allocator crate.
///
/// # Safety
///
/// This function assumes you passed a valid `heap_start` and `heap_size`,
/// as these are unchecked.
pub unsafe fn init(&mut self, heap_start: usize, heap_size: usize) {
unsafe { self.add_region(heap_start, heap_size) };
}
unsafe fn add_region(&mut self, addr: usize, size: usize) {
unsafe {
let mut node = FallbackListNode::new(size);
node.next = self.head.next.take();
let node_ptr = addr as *mut FallbackListNode;
unsafe {
node_ptr.write(node);
self.head.next = Some(&mut *node_ptr);
}
+6 -4
View File
@@ -1,8 +1,8 @@
use libm::include_font;
pub static FONT_SPLEEN_8X16: Font =
pub const FONT_SPLEEN_8X16: Font =
Font::new(include_font!("../../../resources/font/spleen-8x16.psf"));
pub static FONT_CP850_8X16: Font =
pub const FONT_CP850_8X16: Font =
Font::new(include_font!("../../../resources/font/cp850-8x16.psf"));
// pub struct Font(pub [[u8; 16]; 512]);
@@ -39,8 +39,10 @@ impl Font {
pub const fn height(&self) -> usize {
self.height
}
}
pub fn default() -> &'static Self {
&FONT_CP850_8X16
impl Default for Font {
fn default() -> Self {
FONT_CP850_8X16
}
}
+7 -6
View File
@@ -2,10 +2,9 @@ use crate::arch::x86_64::drivers::keyboard::{KeyStroke, get_keystroke_async};
use crate::resources::font::Font;
use crate::serial_print;
use crate::serial_println;
use crate::std::application::frame::Frame;
use crate::std::application::render::RenderError;
use crate::std::application::window::Window;
use crate::std::application::{Application, Error};
use crate::std::application::{
Application, Error, frame::Frame, render::RenderError, window::Window,
};
use crate::std::ascii::Writer;
use crate::std::maths::geometry::Vec2;
use alloc::string::{String, ToString};
@@ -42,7 +41,8 @@ impl<'a> Editor {
fn render(&'a self) -> Result<Frame<'a>, RenderError> {
let mut frame = Frame::new(&self.window);
let writer = Writer::new(Font::default());
let font = Font::default();
let writer = Writer::new(&font);
let (width, height) = writer.font_size().into();
@@ -127,7 +127,8 @@ impl<'a> Editor {
fn get_char_idx(&self) -> usize {
let frame = Frame::new(&self.window);
let writer = Writer::new(Font::default());
let font = Font::default();
let writer = Writer::new(&font);
let (width, _height) = writer.font_size().into();
let mut col = 0;
+4 -5
View File
@@ -1,3 +1,4 @@
#![allow(dead_code)]
#![feature(proc_macro_span)]
#![warn(
clippy::correctness,
@@ -10,9 +11,6 @@
rustdoc::missing_panics_doc
)]
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use proc_macro::{Span, TokenStream};
use quote::quote;
use std::path::PathBuf;
@@ -36,7 +34,8 @@ pub fn include_font(item: TokenStream) -> TokenStream {
let source_filepath: PathBuf = source_file.path();
let file_path = format!(
"{}/{}",
source_filepath.parent().unwrap_or_else(|| panic!("Expected to find the calling source file in a folder like src! Got: {}", source_filepath.display())).display(),
source_filepath.parent()
.unwrap_or_else(|| panic!("Expected to find the calling source file in a folder like src! Got: {}", source_filepath.display())).display(),
filename.value()
);
@@ -124,7 +123,7 @@ impl FontBuilder {
})
}
fn parse_psf2(data: &[u8]) -> Result<FontData, &'static str> {
const fn parse_psf2(_data: &[u8]) -> Result<FontData, &'static str> {
Err("PSF2 support is not implemented yet!")
}
}