diff --git a/cargo-n64/src/cargo.rs b/cargo-n64/src/cargo.rs index 299271f..897d37f 100644 --- a/cargo-n64/src/cargo.rs +++ b/cargo-n64/src/cargo.rs @@ -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)] @@ -63,7 +63,7 @@ struct CargoMessageMessage { rendered: String, } -crate fn run(args: &cli::BuildArgs) -> Result { +pub(crate) fn run(args: &cli::BuildArgs) -> Result { let verbose = args.verbose(); // Add -Clinker-plugin-lto if necessary diff --git a/cargo-n64/src/cli.rs b/cargo-n64/src/cli.rs index 90f53b2..29f9e87 100644 --- a/cargo-n64/src/cli.rs +++ b/cargo-n64/src/cli.rs @@ -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, +pub(crate) struct Args { + pub(crate) subcommand: Subcommand, + pub(crate) target: String, + pub(crate) rest: Vec, } #[derive(Debug)] -crate struct BuildArgs { - crate target: String, - crate name: String, - crate fs: Option, - crate ipl3: IPL3, - crate rest: Vec, +pub(crate) struct BuildArgs { + pub(crate) target: String, + pub(crate) name: String, + pub(crate) fs: Option, + pub(crate) ipl3: IPL3, + pub(crate) rest: Vec, } 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 { +pub(crate) fn parse_args() -> Result { use self::ArgParseError::*; let mut args = env::args().skip(1); @@ -124,7 +124,7 @@ crate fn parse_args() -> Result { }) } -crate fn parse_build_args(args: Args) -> Result { +pub(crate) fn parse_build_args(args: Args) -> Result { use self::ArgParseError::*; let mut target = args.target; diff --git a/cargo-n64/src/elf.rs b/cargo-n64/src/elf.rs index 7dce01f..5493feb 100644 --- a/cargo-n64/src/elf.rs +++ b/cargo-n64/src/elf.rs @@ -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), ElfError> { +pub(crate) fn dump(filename: &str) -> Result<(u32, Vec), ElfError> { use self::ElfError::DumpError; use goblin::elf::section_header; diff --git a/cargo-n64/src/fs.rs b/cargo-n64/src/fs.rs index 18eff1c..96502ab 100644 --- a/cargo-n64/src/fs.rs +++ b/cargo-n64/src/fs.rs @@ -36,7 +36,7 @@ fn traverse( Ok(acc) } -crate fn create_filesystem(fs_path: impl AsRef) -> Result, FSError> { +pub(crate) fn create_filesystem(fs_path: impl AsRef) -> Result, FSError> { // Make sure the path is normalized to absolute. let fs_path = fs_path.as_ref().canonicalize()?; diff --git a/cargo-n64/src/header.rs b/cargo-n64/src/header.rs index 2cf252b..e5ac36c 100644 --- a/cargo-n64/src/header.rs +++ b/cargo-n64/src/header.rs @@ -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 @@ -30,7 +30,7 @@ crate struct N64Header { } impl N64Header { - crate fn new( + pub(crate) fn new( entry_point: u32, name_str: &str, program: &[u8], @@ -75,7 +75,7 @@ impl N64Header { } } - crate fn to_vec(&self) -> Vec { + pub(crate) fn to_vec(&self) -> Vec { let mut buffer = Vec::new(); // 0x00 diff --git a/cargo-n64/src/ipl3.rs b/cargo-n64/src/ipl3.rs index b8e6785..28d36de 100644 --- a/cargo-n64/src/ipl3.rs +++ b/cargo-n64/src/ipl3.rs @@ -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 { @@ -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]), @@ -54,7 +54,7 @@ impl fmt::Debug for IPL3 { } impl IPL3 { - crate fn read(path: impl AsRef) -> Result { + pub(crate) fn read(path: impl AsRef) -> Result { // TODO let mut f = File::open(path)?; @@ -75,7 +75,7 @@ impl IPL3 { Self::check(ipl) } - crate fn read_from_rom(path: impl AsRef) -> Result { + pub(crate) fn read_from_rom(path: impl AsRef) -> Result { let mut f = File::open(&path)?; f.seek(SeekFrom::Start(HEADER_SIZE as u64))?; @@ -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, @@ -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 @@ -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::>())); - rotated = current.rotate_left((current & Wrapping(0x1f)).0); + rotated = Wrapping(current.0.rotate_left((current & Wrapping(0x1f)).0)); // Advance accumulator 1 acc1 += current; @@ -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, diff --git a/cargo-n64/src/lib.rs b/cargo-n64/src/lib.rs index 8957df2..b130852 100644 --- a/cargo-n64/src/lib.rs +++ b/cargo-n64/src/lib.rs @@ -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; diff --git a/examples/hello-ipl3font/src/main.rs b/examples/hello-ipl3font/src/main.rs index f9886bc..518e585 100644 --- a/examples/hello-ipl3font/src/main.rs +++ b/examples/hello-ipl3font/src/main.rs @@ -1,6 +1,5 @@ #![deny(clippy::all)] #![forbid(unsafe_code)] -#![warn(rust_2018_idioms)] #![no_std] // Pull panic into scope diff --git a/examples/n64lib/src/lib.rs b/examples/n64lib/src/lib.rs index 519a218..b89d31a 100644 --- a/examples/n64lib/src/lib.rs +++ b/examples/n64lib/src/lib.rs @@ -1,4 +1,3 @@ -#![warn(rust_2018_idioms)] #![no_std] pub mod ipl3font;