Skip to content

Commit

Permalink
Update to Rust 2018 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrmaxmeier committed Jun 9, 2019
1 parent f6e2fe0 commit 9c91019
Show file tree
Hide file tree
Showing 27 changed files with 85 additions and 80 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ readme = "README.md"
keywords = ["tex", "latex", "typesetting", "font"]
categories = ["command-line-interface", "parser-implementations", "rendering", "science", "text-processing"]
license = "MIT"
edition = "2018"

[badges]
travis-ci = { repository = "tectonic-typesetting/tectonic" }
Expand Down
32 changes: 18 additions & 14 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use std::sync::atomic::{AtomicBool, Ordering};

use app_dirs::{app_dir, sanitized, AppDataType};

use errors::{ErrorKind, Result};
use io::itarbundle::{HttpITarIoFactory, ITarBundle};
use io::local_cache::LocalCache;
use io::zipbundle::ZipBundle;
use io::Bundle;
use status::StatusBackend;
use crate::errors::{ErrorKind, Result};
use crate::io::itarbundle::{HttpITarIoFactory, ITarBundle};
use crate::io::local_cache::LocalCache;
use crate::io::zipbundle::ZipBundle;
use crate::io::Bundle;
use crate::status::StatusBackend;

/// Awesome hack time!!!
///
Expand Down Expand Up @@ -65,9 +65,9 @@ impl PersistentConfig {
use std::io::ErrorKind as IoErrorKind;
use std::io::{Read, Write};
let mut cfg_path = if auto_create_config_file {
app_root(AppDataType::UserConfig, &::APP_INFO)?
app_root(AppDataType::UserConfig, &crate::APP_INFO)?
} else {
get_app_root(AppDataType::UserConfig, &::APP_INFO)?
get_app_root(AppDataType::UserConfig, &crate::APP_INFO)?
};
cfg_path.push("config.toml");

Expand Down Expand Up @@ -116,14 +116,14 @@ impl PersistentConfig {
) -> Result<Box<dyn Bundle>> {
let itb = ITarBundle::<HttpITarIoFactory>::new(url);

let mut url2digest_path = app_dir(AppDataType::UserCache, &::APP_INFO, "urls")?;
let mut url2digest_path = app_dir(AppDataType::UserCache, &crate::APP_INFO, "urls")?;
url2digest_path.push(sanitized(url));

let bundle = LocalCache::<ITarBundle<HttpITarIoFactory>>::new(
itb,
&url2digest_path,
&app_dir(AppDataType::UserCache, &::APP_INFO, "manifests")?,
&app_dir(AppDataType::UserCache, &::APP_INFO, "files")?,
&app_dir(AppDataType::UserCache, &crate::APP_INFO, "manifests")?,
&app_dir(AppDataType::UserCache, &crate::APP_INFO, "files")?,
only_cached,
status,
)?;
Expand Down Expand Up @@ -152,7 +152,7 @@ impl PersistentConfig {
use std::io;

if CONFIG_TEST_MODE_ACTIVATED.load(Ordering::SeqCst) {
return Ok(Box::new(::test_util::TestBundle::default()));
return Ok(Box::new(crate::test_util::TestBundle::default()));
}

if self.default_bundles.len() != 1 {
Expand Down Expand Up @@ -180,9 +180,13 @@ impl PersistentConfig {

pub fn format_cache_path(&self) -> Result<PathBuf> {
if CONFIG_TEST_MODE_ACTIVATED.load(Ordering::SeqCst) {
Ok(::test_util::test_path(&[]))
Ok(crate::test_util::test_path(&[]))
} else {
Ok(app_dir(AppDataType::UserCache, &::APP_INFO, "formats")?)
Ok(app_dir(
AppDataType::UserCache,
&crate::APP_INFO,
"formats",
)?)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::string::ToString;

use errors::{Error, ErrorKind, Result};
use crate::errors::{Error, ErrorKind, Result};

// Generic helpers

Expand Down
12 changes: 6 additions & 6 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use std::io::Write;
use std::path::{Path, PathBuf};
use std::rc::Rc;

use digest::DigestData;
use engines::IoEventBackend;
use errors::{ErrorKind, Result, ResultExt};
use io::{Bundle, InputOrigin, IoProvider, IoSetup, IoSetupBuilder, OpenResult};
use status::StatusBackend;
use {BibtexEngine, Spx2HtmlEngine, TexEngine, TexResult, XdvipdfmxEngine};
use crate::digest::DigestData;
use crate::engines::IoEventBackend;
use crate::errors::{ErrorKind, Result, ResultExt};
use crate::io::{Bundle, InputOrigin, IoProvider, IoSetup, IoSetupBuilder, OpenResult};
use crate::status::StatusBackend;
use crate::{BibtexEngine, Spx2HtmlEngine, TexEngine, TexResult, XdvipdfmxEngine};

/// Different patterns with which files may have been accessed by the
/// underlying engines. Once a file is marked as ReadThenWritten or
Expand Down
6 changes: 3 additions & 3 deletions src/engines/bibtex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::ffi::{CStr, CString};

use super::tex::TexResult;
use super::{ExecutionState, IoEventBackend, TectonicBridgeApi};
use errors::{ErrorKind, Result};
use io::IoStack;
use status::StatusBackend;
use crate::errors::{ErrorKind, Result};
use crate::io::IoStack;
use crate::status::StatusBackend;

#[derive(Default)]
pub struct BibtexEngine {}
Expand Down
8 changes: 4 additions & 4 deletions src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ use std::path::Path;
use std::sync::Mutex;
use std::{io, ptr, slice};

use digest::DigestData;
use errors::{Error, ErrorKind, Result};
use io::{InputFeatures, InputHandle, InputOrigin, IoProvider, OpenResult, OutputHandle};
use status::StatusBackend;
use crate::digest::DigestData;
use crate::errors::{Error, ErrorKind, Result};
use crate::io::{InputFeatures, InputHandle, InputOrigin, IoProvider, OpenResult, OutputHandle};
use crate::status::StatusBackend;

// Public sub-modules and reexports.

Expand Down
6 changes: 3 additions & 3 deletions src/engines/spx2html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::io::Write;
use tectonic_xdv::{FileType, XdvEvents, XdvParser};

use super::IoEventBackend;
use errors::{Error, Result};
use io::{IoProvider, IoStack, OpenResult, OutputHandle};
use status::StatusBackend;
use crate::errors::{Error, Result};
use crate::io::{IoProvider, IoStack, OpenResult, OutputHandle};
use crate::status::StatusBackend;

#[derive(Default)]
pub struct Spx2HtmlEngine {}
Expand Down
6 changes: 3 additions & 3 deletions src/engines/tex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use std::ffi::{CStr, CString};

use super::{ExecutionState, IoEventBackend, TectonicBridgeApi};
use errors::{DefinitelySame, ErrorKind, Result};
use io::IoStack;
use status::StatusBackend;
use crate::errors::{DefinitelySame, ErrorKind, Result};
use crate::io::IoStack;
use crate::status::StatusBackend;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TexResult {
Expand Down
6 changes: 3 additions & 3 deletions src/engines/xdvipdfmx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use std::ffi::{CStr, CString};

use super::{ExecutionState, IoEventBackend, TectonicBridgeApi};
use errors::{ErrorKind, Result};
use io::IoStack;
use status::StatusBackend;
use crate::errors::{ErrorKind, Result};
use crate::io::IoStack;
use crate::status::StatusBackend;

pub struct XdvipdfmxEngine {
enable_compression: bool,
Expand Down
4 changes: 2 additions & 2 deletions src/io/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use std::path::{Path, PathBuf};
use super::{
try_open_file, InputFeatures, InputHandle, InputOrigin, IoProvider, OpenResult, OutputHandle,
};
use errors::{ErrorKind, Result};
use status::StatusBackend;
use crate::errors::{ErrorKind, Result};
use crate::status::StatusBackend;

/// FilesystemPrimaryInputIo is an I/O provider that provides the TeX "primary input"
/// file off of the filesystem. This can *pretty much* be achieved with
Expand Down
8 changes: 4 additions & 4 deletions src/io/format_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::path::PathBuf;
use tempfile;

use super::{InputHandle, InputOrigin, IoProvider, OpenResult};
use digest::DigestData;
use errors::{ErrorKind, Result};
use status::StatusBackend;
use crate::digest::DigestData;
use crate::errors::{ErrorKind, Result};
use crate::status::StatusBackend;

/// A local cache for compiled format files.
///
Expand Down Expand Up @@ -61,7 +61,7 @@ impl FormatCache {
"{}-{}-{}.fmt",
self.bundle_digest.to_string(),
stem,
::FORMAT_SERIAL
crate::FORMAT_SERIAL
));
Ok(p)
}
Expand Down
4 changes: 2 additions & 2 deletions src/io/itarbundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use std::ffi::{OsStr, OsString};
use std::io::{BufRead, BufReader, Cursor, Read};

use super::{create_hyper_client, Bundle, InputHandle, InputOrigin, IoProvider, OpenResult};
use errors::{Error, ErrorKind, Result, ResultExt};
use status::StatusBackend;
use crate::errors::{Error, ErrorKind, Result, ResultExt};
use crate::status::StatusBackend;

const MAX_HTTP_ATTEMPTS: usize = 4;

Expand Down
6 changes: 3 additions & 3 deletions src/io/local_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use std::str::FromStr;
use tempfile;

use super::{try_open_file, Bundle, InputHandle, InputOrigin, IoProvider, OpenResult};
use digest::{self, Digest, DigestData};
use errors::{ErrorKind, Result};
use status::StatusBackend;
use crate::digest::{self, Digest, DigestData};
use crate::errors::{ErrorKind, Result};
use crate::status::StatusBackend;

struct LocalCacheItem {
_length: u64,
Expand Down
6 changes: 3 additions & 3 deletions src/io/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use super::{
normalize_tex_path, InputFeatures, InputHandle, InputOrigin, IoProvider, OpenResult,
OutputHandle,
};
use errors::Result;
use status::StatusBackend;
use crate::errors::Result;
use crate::status::StatusBackend;

// MemoryIo is an IoProvider that stores "files" in in-memory buffers.
//
Expand Down Expand Up @@ -170,7 +170,7 @@ impl IoProvider for MemoryIo {
#[cfg(test)]
mod tests {
use super::*;
use status::NoopStatusBackend;
use crate::status::NoopStatusBackend;
use std::io::{BufRead, BufReader};

/// Early versions had a bug where files were not truncated when opened
Expand Down
6 changes: 3 additions & 3 deletions src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use std::io::{self, Cursor, Read, Seek, SeekFrom, Write};
use std::path::Path;
use std::str::FromStr;

use digest::{self, Digest, DigestData};
use errors::{Error, ErrorKind, Result};
use status::StatusBackend;
use crate::digest::{self, Digest, DigestData};
use crate::errors::{Error, ErrorKind, Result};
use crate::status::StatusBackend;

pub mod filesystem;
pub mod format_cache;
Expand Down
10 changes: 5 additions & 5 deletions src/io/setup.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::HashSet;
use std::path::{Path, PathBuf};

use errors::Result;
use io::format_cache::FormatCache;
use io::stdstreams::BufferedPrimaryIo;
use io::{
use crate::errors::Result;
use crate::io::format_cache::FormatCache;
use crate::io::stdstreams::BufferedPrimaryIo;
use crate::io::{
Bundle, FilesystemIo, FilesystemPrimaryInputIo, GenuineStdoutIo, IoProvider, IoStack, MemoryIo,
};
use status::StatusBackend;
use crate::status::StatusBackend;

/// An `IoSetup` is essentially a typed, structured version of an [`IoStack`].
///
Expand Down
2 changes: 1 addition & 1 deletion src/io/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::ffi::OsStr;

use super::{InputHandle, IoProvider, OpenResult, OutputHandle};
use status::StatusBackend;
use crate::status::StatusBackend;

/// An IoStack is an IoProvider that delegates to an ordered list of
/// subordinate IoProviders. It also checks the order in which files are read
Expand Down
4 changes: 2 additions & 2 deletions src/io/stdstreams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::io::{stdin, stdout, Cursor, Read, Seek, SeekFrom};
use std::rc::Rc;

use super::{InputFeatures, InputHandle, InputOrigin, IoProvider, OpenResult, OutputHandle};
use errors::Result;
use status::StatusBackend;
use crate::errors::Result;
use crate::status::StatusBackend;

/// GenuineStdoutIo provides a mechanism for the "stdout" output to actually
/// go to the process's stdout.
Expand Down
4 changes: 2 additions & 2 deletions src/io/zipbundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use zip::result::ZipError;
use zip::ZipArchive;

use super::{Bundle, InputHandle, InputOrigin, IoProvider, OpenResult};
use errors::Result;
use status::StatusBackend;
use crate::errors::Result;
use crate::status::StatusBackend;

pub struct ZipBundle<R: Read + Seek> {
zip: ZipArchive<R>,
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ pub mod io;
#[doc(hidden)]
pub mod test_util;

pub use engines::bibtex::BibtexEngine;
pub use engines::spx2html::Spx2HtmlEngine;
pub use engines::tex::{TexEngine, TexResult};
pub use engines::xdvipdfmx::XdvipdfmxEngine;
pub use errors::{Error, ErrorKind, Result};
pub use crate::engines::bibtex::BibtexEngine;
pub use crate::engines::spx2html::Spx2HtmlEngine;
pub use crate::engines::tex::{TexEngine, TexResult};
pub use crate::engines::xdvipdfmx::XdvipdfmxEngine;
pub use crate::errors::{Error, ErrorKind, Result};

const APP_INFO: app_dirs::AppInfo = app_dirs::AppInfo {
name: "Tectonic",
Expand Down
2 changes: 1 addition & 1 deletion src/status/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod termcolor;
use std::cmp;
use std::fmt::Arguments;

use errors::Error;
use crate::errors::Error;

#[repr(usize)]
#[derive(Clone, Copy, Eq, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/status/termcolor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::io::Write;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};

use super::{ChatterLevel, MessageKind, StatusBackend};
use errors::Error;
use crate::errors::Error;

pub struct TermcolorStatusBackend {
chatter: ChatterLevel,
Expand Down
10 changes: 5 additions & 5 deletions src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ use std::env;
use std::ffi::OsStr;
use std::path::PathBuf;

use digest::DigestData;
use errors::Result;
use io::{Bundle, FilesystemIo, InputHandle, IoProvider, OpenResult};
use status::StatusBackend;
use crate::digest::DigestData;
use crate::errors::Result;
use crate::io::{Bundle, FilesystemIo, InputHandle, IoProvider, OpenResult};
use crate::status::StatusBackend;

/// The name of the environment variable that the test code will consult to
/// figure out where to find the testing resource files.
Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn maybe_activate_test_mode() {
return;
}

::config::activate_config_test_mode(true);
crate::config::activate_config_test_mode(true);
}

/// A combination of the two above functions. Set the "test root" variable,
Expand Down
2 changes: 1 addition & 1 deletion tests/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tempfile::TempDir;

#[path = "util/mod.rs"]
mod util;
use util::{cargo_dir, ensure_plain_format};
use crate::util::{cargo_dir, ensure_plain_format};

lazy_static! {
static ref TEST_ROOT: PathBuf = {
Expand Down
2 changes: 1 addition & 1 deletion tests/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tectonic::status::NoopStatusBackend;
use tectonic::TexEngine;

mod util;
use util::test_path;
use crate::util::test_path;

const DEBUG: bool = false; // TODO: this is kind of ugly

Expand Down
Loading

0 comments on commit 9c91019

Please sign in to comment.