Skip to content

Commit

Permalink
Fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
themkat authored and sagacity committed Aug 31, 2022
1 parent a448ce8 commit 5a2ece3
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 54 deletions.
6 changes: 3 additions & 3 deletions mos-core/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@ impl CodegenContext {
if segment.emit(bytes) {
Ok(())
} else {
return Err(Diagnostic::error()
Err(Diagnostic::error()
.with_message(format!("segment '{}' is out of range", name))
.with_labels(vec![span.to_label()])
.into());
.into())
}
}
None => {
Expand Down Expand Up @@ -881,7 +881,7 @@ impl CodegenContext {
+ 2)
.as_i64();
let mut offset = target_pc - cur_pc;
if offset >= -128 && offset <= 127 {
if (-128..=127).contains(&offset) {
if offset < 0 {
offset += 256;
}
Expand Down
2 changes: 1 addition & 1 deletion mos-core/src/codegen/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct SourceMap {
offsets: Vec<SourceMapOffset>,
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct SourceMapOffset {
pub scope: SymbolIndex,
pub span: Span,
Expand Down
2 changes: 1 addition & 1 deletion mos-core/src/codegen/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct SymbolTable<S: Clone + Debug> {
pub type SymbolIndex = NodeIndex;
pub type SymbolIndices<'a, S> = NodeIndices<'a, Item<S>>;

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum QueryTraversalStep {
Symbol(SymbolIndex),
Super(SymbolIndex),
Expand Down
16 changes: 8 additions & 8 deletions mos-core/src/formatting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::fmt::Display;
use std::path::PathBuf;
use std::sync::Arc;

#[derive(Debug, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum Casing {
Uppercase,
Expand All @@ -25,7 +25,7 @@ impl Casing {
}
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct MnemonicOptions {
pub casing: Casing,
Expand All @@ -41,14 +41,14 @@ impl Default for MnemonicOptions {
}
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum BracePosition {
SameLine,
NewLine,
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct BraceOptions {
pub position: BracePosition,
Expand All @@ -62,7 +62,7 @@ impl Default for BraceOptions {
}
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct WhitespaceOptions {
pub indent: usize,
Expand All @@ -71,7 +71,7 @@ pub struct WhitespaceOptions {
pub code_margin: usize,
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub enum Alignment {
Left,
Expand All @@ -89,7 +89,7 @@ impl Default for WhitespaceOptions {
}
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct ListingOptions {
pub num_bytes_per_line: usize,
Expand All @@ -103,7 +103,7 @@ impl Default for ListingOptions {
}
}

#[derive(Debug, Default, Clone, Copy, Deserialize, PartialEq)]
#[derive(Debug, Default, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct FormattingOptions {
pub mnemonics: MnemonicOptions,
Expand Down
24 changes: 12 additions & 12 deletions mos-core/src/parser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub enum Trivia {
}

/// Registers used for indexing
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum IndexRegister {
X,
Y,
Expand All @@ -179,7 +179,7 @@ pub struct Instruction {
}

/// The addressing mode for the instruction
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AddressingMode {
/// Absolute or Zero-Page addressing (e.g. `LDA $34`)
AbsoluteOrZp,
Expand Down Expand Up @@ -211,7 +211,7 @@ pub struct RegisterSuffix {
}

/// A number, which can be hexadecimal (`$23AB`), decimal (`123`) or binary (`%11011`)
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum NumberType {
Hex,
Dec,
Expand All @@ -229,7 +229,7 @@ impl Display for NumberType {
}

/// An address modifier which can be used to get the low (`<`) or high (`>`) byte of an address
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AddressModifier {
HighByte,
LowByte,
Expand All @@ -245,7 +245,7 @@ impl Display for AddressModifier {
}

/// Any kind of binary operation that can be found in an expression
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BinaryOp {
/// Addition
Add,
Expand Down Expand Up @@ -339,7 +339,7 @@ pub enum ExpressionFactor {
}

/// A wrapper that stores the original number string and its radix, so that any zero-prefixes are kept
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Number {
radix: u32,
data: String,
Expand Down Expand Up @@ -422,7 +422,7 @@ impl Expression {
}

/// User-defined variables
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum VariableType {
Constant,
Variable,
Expand All @@ -438,7 +438,7 @@ impl Display for VariableType {
}

/// The size of a data directive (e.g. `.byte 1, 2, 3`)
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DataSize {
Byte,
Word,
Expand Down Expand Up @@ -475,7 +475,7 @@ impl Display for ImportAs {
}
}

#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum TextEncoding {
Ascii,
Petscii,
Expand Down Expand Up @@ -854,19 +854,19 @@ pub fn format_trivia(trivia: &Option<Box<Located<Vec<Trivia>>>>) -> String {
.unwrap_or_else(|| "".to_string())
}

impl<'a, T: Display> Display for Located<T> {
impl<T: Display> Display for Located<T> {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{}{}", format_trivia(&self.trivia), &self.data)
}
}

impl<'a, T: Display + LowerHex> LowerHex for Located<T> {
impl<T: Display + LowerHex> LowerHex for Located<T> {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{}{:x}", format_trivia(&self.trivia), &self.data)
}
}

impl<'a, T: Display + Binary> Binary for Located<T> {
impl<T: Display + Binary> Binary for Located<T> {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{}{:b}", format_trivia(&self.trivia), &self.data)
}
Expand Down
2 changes: 1 addition & 1 deletion mos-core/src/parser/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use nom::bytes::complete::tag_no_case;
use nom::combinator::map;

/// The available 6502 instructions.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Mnemonic {
Adc,
And,
Expand Down
8 changes: 4 additions & 4 deletions mos/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ use std::path::{Path, PathBuf};
use strum::EnumString;

/// Assembles input file(s)
#[derive(argh::FromArgs, PartialEq, Debug)]
#[derive(argh::FromArgs, PartialEq, Eq, Debug)]
#[argh(subcommand, name = "build")]
pub struct BuildArgs {}

#[derive(Debug, Clone, Deserialize, PartialEq)]
#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct BuildOptions {
pub entry: String,
Expand Down Expand Up @@ -72,14 +72,14 @@ impl Default for BuildOptions {
}
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq, EnumString)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq, EnumString)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub enum OutputFormat {
Prg,
Bin,
}

#[derive(Debug, Clone, Copy, Deserialize, PartialEq, EnumString)]
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq, EnumString)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub enum SymbolType {
Vice,
Expand Down
2 changes: 1 addition & 1 deletion mos/src/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use mos_core::LINE_ENDING;
use std::io::Write;

/// Formats input file(s)
#[derive(argh::FromArgs, PartialEq, Debug)]
#[derive(argh::FromArgs, PartialEq, Eq, Debug)]
#[argh(subcommand, name = "format")]
pub struct FormatArgs {}

Expand Down
2 changes: 1 addition & 1 deletion mos/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use mos_core::errors::{map_io_error, Diagnostics};
use std::path::Path;

/// Creates a new MOS project configuration file
#[derive(argh::FromArgs, PartialEq, Debug)]
#[derive(argh::FromArgs, PartialEq, Eq, Debug)]
#[argh(subcommand, name = "init")]
pub struct InitArgs {}

Expand Down
2 changes: 1 addition & 1 deletion mos/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::diagnostic_emitter::MosResult;
use crate::lsp::{LspContext, LspServer};

/// Starts a Language Server
#[derive(argh::FromArgs, PartialEq, Debug)]
#[derive(argh::FromArgs, PartialEq, Eq, Debug)]
#[argh(subcommand, name = "lsp")]
pub struct LspArgs {
/// the port on which the debug adapter server should listen
Expand Down
4 changes: 2 additions & 2 deletions mos/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};

/// Runs unit test(s)
#[derive(argh::FromArgs, PartialEq, Debug)]
#[derive(argh::FromArgs, PartialEq, Eq, Debug)]
#[argh(subcommand, name = "test")]
pub struct TestArgs {}

#[derive(Debug, Default, Clone, Deserialize, PartialEq)]
#[derive(Debug, Default, Clone, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct TestOptions {
pub name: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion mos/src/commands/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::diagnostic_emitter::MosResult;

/// Prints the version of the application
#[derive(argh::FromArgs, PartialEq, Debug)]
#[derive(argh::FromArgs, PartialEq, Eq, Debug)]
#[argh(subcommand, name = "version")]
pub struct VersionArgs {}

Expand Down
2 changes: 1 addition & 1 deletion mos/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::diagnostic_emitter::MosResult;
use mos_core::formatting::FormattingOptions;
use serde::Deserialize;

#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
pub struct Config {
pub build: BuildOptions,
Expand Down
8 changes: 4 additions & 4 deletions mos/src/debugger/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Machine {
}
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum MachineEvent {
RunningStateChanged {
old: MachineRunningState,
Expand Down Expand Up @@ -116,22 +116,22 @@ pub trait MachineAdapter: MemoryAccessor {
fn flags(&self) -> MosResult<u8>;
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MachineBreakpoint {
pub line: usize,
pub column: Option<usize>,
pub range: Range<ProgramCounter>,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MachineValidatedBreakpoint {
pub id: usize,
pub source_path: String,
pub requested: MachineBreakpoint,
pub range: Range<ProgramCounter>,
}

#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MachineRunningState {
Launching,
Running,
Expand Down
10 changes: 5 additions & 5 deletions mos/src/debugger/adapters/vice/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;
use std::io;
use std::io::{BufRead, Write};

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ViceResponse {
AdvanceInstructions,
BanksAvailable(HashMap<u16, String>),
Expand All @@ -24,7 +24,7 @@ pub enum ViceResponse {
Resumed(u16),
}

#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct CheckpointResponse {
pub number: u32,
pub currently_hit: bool,
Expand All @@ -40,7 +40,7 @@ pub struct CheckpointResponse {
}

#[allow(dead_code)]
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum ViceRequest {
AdvanceInstructions(bool, u16),
BanksAvailable,
Expand All @@ -58,7 +58,7 @@ pub enum ViceRequest {
Quit,
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct CheckpointSet {
pub start: u16,
pub end: u16,
Expand All @@ -68,7 +68,7 @@ pub struct CheckpointSet {
pub temporary: bool,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MemoryDescriptor {
pub cause_side_effects: bool,
pub start: u16,
Expand Down
Loading

0 comments on commit 5a2ece3

Please sign in to comment.