Skip to content

Commit

Permalink
Merge pull request #621 from KisaragiEffective/expect-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective authored Nov 30, 2024
2 parents e39ce65 + 4b1b68a commit 6ae2ef6
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package/origlang-ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::after_parse::Expression;
pub mod after_parse;

/// 現時点のプログラムとは、プリントするべき式の列である
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct RootAst {
pub statement: Vec<Statement>
Expand Down Expand Up @@ -84,7 +84,7 @@ impl Identifier {
self.0
}

#[allow(clippy::must_use_candidate)]
#[expect(clippy::must_use_candidate)]
pub fn as_name(&self) -> &str {
&self.0
}
Expand Down
2 changes: 1 addition & 1 deletion package/origlang-cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use origlang_runtime::RuntimeError;
use crate::args::ReadSourceError;

#[derive(Error, Debug)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub enum TaskExecutionError {
#[error("Failed to read source: {0}")]
Source(#[from] ReadSourceError),
Expand Down
6 changes: 3 additions & 3 deletions package/origlang-ir-optimizer/src/ir1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl FoldBinaryOperatorInvocationWithConstant {
}).collect()
}

#[allow(clippy::cast_lossless, clippy::too_many_lines)]
#[expect(clippy::cast_lossless, clippy::too_many_lines)]
#[deny(clippy::as_underscore)]
#[must_use]
fn walk_expression(expr: TypedExpression) -> TypedExpression {
Expand Down Expand Up @@ -189,7 +189,7 @@ impl FoldBinaryOperatorInvocationWithConstant {
}
}

#[allow(clippy::redundant_closure_call)]
#[expect(clippy::redundant_closure_call)]
fn fold_compare_into_bool_literal(lhs: &TypedIntLiteral, rhs: &TypedIntLiteral, compare: BinaryOperatorKind) -> TypedExpression {
// [T, O] =>> (T, T) => O
macro_rules! poly_input_lambda {
Expand Down Expand Up @@ -222,7 +222,7 @@ impl FoldBinaryOperatorInvocationWithConstant {
BinaryOperatorKind::LessEqual => poly_input_lambda!(|lhs, rhs| TypedExpression::BooleanLiteral(lhs <= rhs)),
BinaryOperatorKind::Equal => poly_input_lambda!(|lhs, rhs| TypedExpression::BooleanLiteral(lhs == rhs)),
BinaryOperatorKind::NotEqual => poly_input_lambda!(|lhs, rhs| TypedExpression::BooleanLiteral(lhs != rhs)),
#[allow(clippy::panic)]
#[expect(clippy::panic)]
other => panic!("operator {other} is not supported by this function"),
}
}
Expand Down
6 changes: 3 additions & 3 deletions package/origlang-ir-optimizer/src/preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct NoOptimization;

impl OptimizationPreset<IR1> for NoOptimization {
fn optimize(&self, seq: Vec<IR1>) -> Vec<IR1> {
#[allow(unused_imports)]
#[expect(unused_imports)]
use crate::ir1::EliminateAfterExit;

seq
Expand All @@ -33,9 +33,9 @@ impl OptimizationPreset<IR2> for NoOptimization {
pub struct SimpleOptimization;

impl OptimizationPreset<IR1> for SimpleOptimization {
#[allow(clippy::redundant_closure_for_method_calls)]
#[expect(clippy::redundant_closure_for_method_calls)]
fn optimize(&self, seq: Vec<IR1>) -> Vec<IR1> {
#[allow(clippy::wildcard_imports)]
#[expect(clippy::wildcard_imports)]
use crate::ir1::*;

seq
Expand Down
4 changes: 2 additions & 2 deletions package/origlang-lexer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use thiserror::Error;
use crate::boundary::Utf8CharBoundaryStartByte;

#[derive(Error, Debug, Eq, PartialEq)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub enum LexerError {
#[error("Invalid suffix for integer literal. Supported suffixes are [`i8`, `i16`, `i32`, `i64`]")]
InvalidSuffix,
Expand All @@ -21,7 +21,7 @@ pub enum LexerError {

#[derive(Debug, Error, Eq, PartialEq)]
#[error("lexer index overflow: {current:?} > {max}")]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub struct OutOfRangeError {
pub current: Utf8CharBoundaryStartByte,
pub max: usize,
Expand Down
8 changes: 4 additions & 4 deletions package/origlang-lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ pub struct Lexer<'src> {

impl<'src> Lexer<'src> {
#[must_use = "Lexer do nothing unless calling parsing function"]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn create(source: &'src str) -> Self {
Self {
source_bytes_nth: Cell::new(Utf8CharBoundaryStartByte::new(0)),
source,
lc_manager: LcManager {
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
line: Cell::new(1.try_into().expect("unreachable!!")),
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
column: Cell::new(1.try_into().expect("unreachable!!")),
}
}
Expand Down Expand Up @@ -160,7 +160,7 @@ impl Lexer<'_> {

let s = unsafe { this.source.get_unchecked(index..(index + stride.as_usize())) };

#[allow(clippy::or_fun_call)] // latter is fine because it does not cost
#[expect(clippy::or_fun_call)] // latter is fine because it does not cost
let c = s.chars().next().ok_or(this.report_out_of_range_error())?;


Expand Down
2 changes: 1 addition & 1 deletion package/origlang-parser/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl ParserError {
}

#[derive(ThisError, Debug, Eq, PartialEq)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub enum ParserErrorInner {
#[error("lexer error: {_0}")]
LexerError(#[from] LexerError),
Expand Down
4 changes: 2 additions & 2 deletions package/origlang-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl Runtime {
}

#[derive(Error, Debug, Eq, PartialEq)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub enum RuntimeError {
#[error("variable {identifier} is not defined in current scope")]
UndefinedVariable {
Expand Down Expand Up @@ -387,7 +387,7 @@ fn evaluate_bin_op(runtime: &Runtime, lhs: &CompiledTypedExpression, rhs: &Compi
impl CanBeEvaluated for CompiledTypedExpression {
fn evaluate(&self, runtime: &Runtime) -> EvaluateResult {
match self {
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
Self::IntLiteral(int) => match int {
TypedIntLiteral::Generic(i) => Ok(NonCoerced(*i).into()),
TypedIntLiteral::Bit64(i) => Ok(Coerced(*i).into()),
Expand Down
6 changes: 3 additions & 3 deletions package/origlang-typecheck/src/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl TryIntoTypeCheckedForm for Expression {
type Success = TypedExpression;
type Err = TypeCheckError;

#[allow(clippy::too_many_lines, clippy::cast_possible_truncation)]
#[expect(clippy::too_many_lines, clippy::cast_possible_truncation)]
fn type_check(self, checker: &TypeChecker) -> Result<Self::Success, Self::Err> {
match self {
Self::IntLiteral { value, suffix } => {
Expand Down Expand Up @@ -467,7 +467,7 @@ pub struct TypeChecker {
}

impl TypeChecker {
#[allow(clippy::result_unit_err)]
#[expect(clippy::result_unit_err)]
pub fn lower_type_signature_into_type(&self, p0: &TypeSignature) -> Result<Type, ()> {
match p0 {
TypeSignature::Simple(ident) => {
Expand All @@ -494,7 +494,7 @@ impl TypeChecker {
}

#[must_use]
#[allow(clippy::missing_panics_doc)] // do not panic
#[expect(clippy::missing_panics_doc)] // do not panic
pub fn make_fresh_identifier(&self) -> Identifier {
// TODO: this implementation is poor. choice more elegant algorithm.
let hello = RandomState::new().hash_one(());
Expand Down
2 changes: 1 addition & 1 deletion package/origlang-typecheck/src/type_check/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use origlang_typesystem_model::TypedExpression;
use origlang_typesystem_model::Type;

#[derive(Debug, Eq, PartialEq, Clone, Error)]
#[allow(clippy::module_name_repetitions)]
#[expect(clippy::module_name_repetitions)]
pub enum TypeCheckError {
#[error("Only ({accepted_lhs}) {operator} ({accepted_rhs}) is defined, but got {got_lhs} {operator} {got_rhs}")]
InvalidCombinationForBinaryOperator {
Expand Down

0 comments on commit 6ae2ef6

Please sign in to comment.