Skip to content

Commit

Permalink
Remove unnecessary feature flags and lints (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte committed May 21, 2020
1 parent c959a1d commit 0efcf4f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 42 deletions.
12 changes: 6 additions & 6 deletions cargo-n64/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ impl Runner for Command {
}

#[derive(Deserialize, Debug)]
crate struct CargoArtifact {
crate executable: String,
crate target: CargoArtifactTarget,
pub(crate) struct CargoArtifact {
pub(crate) executable: String,
pub(crate) target: CargoArtifactTarget,
}

#[derive(Deserialize, Debug)]
crate struct CargoArtifactTarget {
crate name: String,
pub(crate) struct CargoArtifactTarget {
pub(crate) name: String,
}

#[derive(Deserialize, Debug)]
Expand All @@ -63,7 +63,7 @@ struct CargoMessageMessage {
rendered: String,
}

crate fn run(args: &cli::BuildArgs) -> Result<CargoArtifact, SubcommandError> {
pub(crate) fn run(args: &cli::BuildArgs) -> Result<CargoArtifact, SubcommandError> {
let verbose = args.verbose();

// Add -Clinker-plugin-lto if necessary
Expand Down
28 changes: 14 additions & 14 deletions cargo-n64/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,36 @@ pub enum ArgParseError {
}

#[derive(Debug)]
crate enum Subcommand {
pub(crate) enum Subcommand {
None,
Build,
}

#[derive(Debug)]
crate struct Args {
crate subcommand: Subcommand,
crate target: String,
crate rest: Vec<String>,
pub(crate) struct Args {
pub(crate) subcommand: Subcommand,
pub(crate) target: String,
pub(crate) rest: Vec<String>,
}

#[derive(Debug)]
crate struct BuildArgs {
crate target: String,
crate name: String,
crate fs: Option<String>,
crate ipl3: IPL3,
crate rest: Vec<String>,
pub(crate) struct BuildArgs {
pub(crate) target: String,
pub(crate) name: String,
pub(crate) fs: Option<String>,
pub(crate) ipl3: IPL3,
pub(crate) rest: Vec<String>,
}

impl BuildArgs {
crate fn verbose(&self) -> bool {
pub(crate) fn verbose(&self) -> bool {
self.rest
.iter()
.any(|a| a == "--verbose" || a == "-v" || a == "-vv")
}
}

crate fn parse_args() -> Result<Args, ArgParseError> {
pub(crate) fn parse_args() -> Result<Args, ArgParseError> {
use self::ArgParseError::*;

let mut args = env::args().skip(1);
Expand Down Expand Up @@ -124,7 +124,7 @@ crate fn parse_args() -> Result<Args, ArgParseError> {
})
}

crate fn parse_build_args(args: Args) -> Result<BuildArgs, ArgParseError> {
pub(crate) fn parse_build_args(args: Args) -> Result<BuildArgs, ArgParseError> {
use self::ArgParseError::*;

let mut target = args.target;
Expand Down
4 changes: 2 additions & 2 deletions cargo-n64/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ pub enum ElfError {
DumpError(String),
}

crate struct SectionInfo<'a> {
pub(crate) struct SectionInfo<'a> {
header: &'a SectionHeader,
binary: &'a [u8],
}

crate fn dump(filename: &str) -> Result<(u32, Vec<u8>), ElfError> {
pub(crate) fn dump(filename: &str) -> Result<(u32, Vec<u8>), ElfError> {
use self::ElfError::DumpError;
use goblin::elf::section_header;

Expand Down
2 changes: 1 addition & 1 deletion cargo-n64/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn traverse<T>(
Ok(acc)
}

crate fn create_filesystem(fs_path: impl AsRef<Path>) -> Result<Vec<u8>, FSError> {
pub(crate) fn create_filesystem(fs_path: impl AsRef<Path>) -> Result<Vec<u8>, FSError> {
// Make sure the path is normalized to absolute.
let fs_path = fs_path.as_ref().canonicalize()?;

Expand Down
8 changes: 4 additions & 4 deletions cargo-n64/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use byteorder::{BigEndian, WriteBytesExt};

use crate::ipl3::IPL3;

crate const HEADER_SIZE: usize = 0x40;
pub(crate) const HEADER_SIZE: usize = 0x40;

#[derive(Debug, Clone, Copy)]
crate struct N64Header {
pub(crate) struct N64Header {
// 0x00
device_latency: u8, // PI_BSD_DOM1_LAT_REG
device_rw_pulse_width: u8, // PI_BSD_DOM1_PWD_REG
Expand All @@ -30,7 +30,7 @@ crate struct N64Header {
}

impl N64Header {
crate fn new(
pub(crate) fn new(
entry_point: u32,
name_str: &str,
program: &[u8],
Expand Down Expand Up @@ -75,7 +75,7 @@ impl N64Header {
}
}

crate fn to_vec(&self) -> Vec<u8> {
pub(crate) fn to_vec(&self) -> Vec<u8> {
let mut buffer = Vec::new();

// 0x00
Expand Down
18 changes: 9 additions & 9 deletions cargo-n64/src/ipl3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::num::Wrapping;
use std::path::Path;
use thiserror::Error;

crate const IPL_SIZE: usize = 0x0fc0;
crate const PROGRAM_SIZE: usize = 1024 * 1024;
pub(crate) const IPL_SIZE: usize = 0x0fc0;
pub(crate) const PROGRAM_SIZE: usize = 1024 * 1024;

#[derive(Debug, Error)]
pub enum IPL3Error {
Expand All @@ -22,7 +22,7 @@ pub enum IPL3Error {
}

/// IPL3 definitions.
crate enum IPL3 {
pub(crate) enum IPL3 {
Cic6101([u8; IPL_SIZE]),
Cic6102([u8; IPL_SIZE]),
Cic6103([u8; IPL_SIZE]),
Expand Down Expand Up @@ -54,7 +54,7 @@ impl fmt::Debug for IPL3 {
}

impl IPL3 {
crate fn read(path: impl AsRef<Path>) -> Result<IPL3, IPL3Error> {
pub(crate) fn read(path: impl AsRef<Path>) -> Result<IPL3, IPL3Error> {
// TODO
let mut f = File::open(path)?;

Expand All @@ -75,7 +75,7 @@ impl IPL3 {
Self::check(ipl)
}

crate fn read_from_rom(path: impl AsRef<Path>) -> Result<IPL3, IPL3Error> {
pub(crate) fn read_from_rom(path: impl AsRef<Path>) -> Result<IPL3, IPL3Error> {
let mut f = File::open(&path)?;
f.seek(SeekFrom::Start(HEADER_SIZE as u64))?;

Expand Down Expand Up @@ -109,7 +109,7 @@ impl IPL3 {
Ok(ipl3)
}

crate fn get_ipl(&self) -> &[u8; IPL_SIZE] {
pub(crate) fn get_ipl(&self) -> &[u8; IPL_SIZE] {
match self {
IPL3::Cic6101(bin) => bin,
IPL3::Cic6102(bin) => bin,
Expand All @@ -121,7 +121,7 @@ impl IPL3 {
}
}

crate fn compute_crcs(&self, program: &[u8], fs: &[u8]) -> (u32, u32) {
pub(crate) fn compute_crcs(&self, program: &[u8], fs: &[u8]) -> (u32, u32) {
let padding_length = (2 - (program.len() & 1)) & 1;
let padding = [0; 1];
let program = program
Expand Down Expand Up @@ -160,7 +160,7 @@ impl IPL3 {
for chunk in &program {
// Fetch the current word and rotate it by itself
current = Wrapping(BigEndian::read_u32(&chunk.collect::<Vec<_>>()));
rotated = current.rotate_left((current & Wrapping(0x1f)).0);
rotated = Wrapping(current.0.rotate_left((current & Wrapping(0x1f)).0));

// Advance accumulator 1
acc1 += current;
Expand Down Expand Up @@ -206,7 +206,7 @@ impl IPL3 {
}

/// Offset the entry point for the current IPL3
crate fn offset(&self, entry_point: u32) -> u32 {
pub(crate) fn offset(&self, entry_point: u32) -> u32 {
entry_point
+ match self {
IPL3::Cic6103(_) => 0x0010_0000,
Expand Down
4 changes: 0 additions & 4 deletions cargo-n64/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#![deny(clippy::all)]
#![feature(backtrace)]
#![feature(crate_visibility_modifier)]
#![feature(try_trait)]
#![feature(wrapping_int_impl)]
#![forbid(unsafe_code)]
#![warn(rust_2018_idioms)]

mod cargo;
mod cli;
Expand Down
1 change: 0 additions & 1 deletion examples/hello-ipl3font/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(clippy::all)]
#![forbid(unsafe_code)]
#![warn(rust_2018_idioms)]
#![no_std]

// Pull panic into scope
Expand Down
1 change: 0 additions & 1 deletion examples/n64lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![warn(rust_2018_idioms)]
#![no_std]

pub mod ipl3font;
Expand Down

0 comments on commit 0efcf4f

Please sign in to comment.