Fix some warnings

This commit is contained in:
Sofia 2025-07-17 20:26:01 +03:00
parent ce2278ce45
commit 292688a840
8 changed files with 8 additions and 35 deletions

View File

@ -392,7 +392,7 @@ impl Parse for Block {
// if semicolon is missing. // if semicolon is missing.
if !matches!(e, Expression(ExpressionKind::IfExpr(_), _)) { if !matches!(e, Expression(ExpressionKind::IfExpr(_), _)) {
// In theory could ignore the missing semicolon.. // In theory could ignore the missing semicolon..
return Err(stream.expected_err("expected semicolon to complete statement")?); return Err(stream.expected_err("semicolon to complete statement")?);
} }
statements.push(BlockLevelStatement::Expression(e)); statements.push(BlockLevelStatement::Expression(e));

View File

@ -4,18 +4,11 @@ use std::{
}; };
use crate::{ use crate::{
ast,
lexer::{self, Cursor, FullToken, Position}, lexer::{self, Cursor, FullToken, Position},
mir::{self, pass, Metadata, SourceModuleId}, mir::{self, pass, Metadata, SourceModuleId},
token_stream::{self, TokenRange}, token_stream::{self, TokenRange},
}; };
impl<T: std::error::Error + std::fmt::Display> pass::Error<T> {
fn fmt_simple(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.kind, f)
}
}
fn label(text: &str) -> &str { fn label(text: &str) -> &str {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {

View File

@ -1,7 +1,4 @@
use std::{ use std::{fmt::Debug, str::Chars};
fmt::{Debug, Write},
str::Chars,
};
static DECIMAL_NUMERICS: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; static DECIMAL_NUMERICS: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];

View File

@ -41,13 +41,12 @@
//! - Debug Symbols //! - Debug Symbols
//! ``` //! ```
use std::{convert::Infallible, path::PathBuf}; use std::path::PathBuf;
use error_raporting::{ErrorKind as ErrorRapKind, ModuleMap, ReidError}; use error_raporting::{ErrorKind as ErrorRapKind, ModuleMap, ReidError};
use lexer::FullToken; use lexer::FullToken;
use mir::{ use mir::{
linker::LinkerPass, typecheck::TypeCheck, typeinference::TypeInference, typerefs::TypeRefs, linker::LinkerPass, typecheck::TypeCheck, typeinference::TypeInference, typerefs::TypeRefs,
SourceModuleId,
}; };
use reid_lib::{compile::CompileOutput, Context}; use reid_lib::{compile::CompileOutput, Context};

View File

@ -1,8 +1,4 @@
use super::{ use super::{typecheck::ErrorKind, typerefs::TypeRefs, VagueType as Vague, *};
typecheck::ErrorKind,
typerefs::{ScopeTypeRefs, TypeRef, TypeRefs},
VagueType as Vague, *,
};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ReturnTypeOther { pub enum ReturnTypeOther {

View File

@ -12,7 +12,7 @@ use crate::{compile_module, error_raporting::ModuleMap, lexer::FullToken, parse_
use super::{ use super::{
pass::{Pass, PassState}, pass::{Pass, PassState},
r#impl::EqualsIssue, r#impl::EqualsIssue,
Context, FunctionDefinition, Import, Metadata, Module, SourceModuleId, Context, FunctionDefinition, Import, Metadata, Module,
}; };
pub static STD_SOURCE: &str = include_str!("../../lib/std.reid"); pub static STD_SOURCE: &str = include_str!("../../lib/std.reid");

View File

@ -4,10 +4,7 @@
use std::{collections::HashMap, path::PathBuf}; use std::{collections::HashMap, path::PathBuf};
use crate::{ use crate::{lexer::Position, token_stream::TokenRange};
lexer::{FullToken, Position},
token_stream::TokenRange,
};
mod display; mod display;
pub mod r#impl; pub mod r#impl;

View File

@ -3,7 +3,7 @@
use crate::{ use crate::{
ast::parse::Parse, ast::parse::Parse,
lexer::{FullToken, Position, Token}, lexer::{FullToken, Token},
}; };
/// Utility struct that is able to parse [`FullToken`]s while being /// Utility struct that is able to parse [`FullToken`]s while being
@ -175,15 +175,6 @@ impl<'a, 'b> TokenStream<'a, 'b> {
} }
} }
fn get_position(&self, offset: usize) -> Result<Position, Error> {
if self.tokens.is_empty() {
Err(Error::FileEmpty)
} else {
let token_idx = (self.position - 1).min(self.tokens.len() - 1);
Ok(self.tokens[token_idx].position)
}
}
pub fn get_range(&self) -> Option<TokenRange> { pub fn get_range(&self) -> Option<TokenRange> {
self.ref_position.as_ref().map(|ref_pos| TokenRange { self.ref_position.as_ref().map(|ref_pos| TokenRange {
start: **ref_pos, start: **ref_pos,
@ -237,7 +228,7 @@ impl std::iter::Sum for TokenRange {
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] #[derive(thiserror::Error, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Error { pub enum Error {
#[error("Expected {} got {:?}", .0, .1)] #[error("Expected {} got \"{}\"", .0, .1.to_string())]
Expected(String, Token, TokenRange), Expected(String, Token, TokenRange),
#[error("Source file contains no tokens")] #[error("Source file contains no tokens")]
FileEmpty, FileEmpty,