Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftSpider committed Feb 28, 2024
1 parent 145e063 commit 1dbe117
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 10 additions & 2 deletions crates/bridge_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2016-2022 the Tectonic Project
// Licensed under the MIT License.

// #![deny(missing_docs)]
#![deny(missing_docs)]

//! Core APIs for bridging the C and Rust portions of Tectonic’s processing
//! backends.
Expand Down Expand Up @@ -54,9 +54,11 @@ use tectonic_io_base::{
};
use tectonic_status_base::{tt_error, tt_warning, MessageKind, StatusBackend};

/// The ID of an InputHandle, used for Rust core state
#[derive(Copy, Clone, PartialEq)]
pub struct InputId(*mut InputHandle);

/// The ID of an OutputHandle, used for Rust core state
#[derive(Copy, Clone, PartialEq)]
pub struct OutputId(*mut OutputHandle);

Expand Down Expand Up @@ -489,13 +491,15 @@ impl<'a> CoreBridgeState<'a> {
OutputId(output)
}

/// Get a mutable reference to an [`OutputHandle`] associated with an [`OutputId`]
pub fn get_output(&mut self, id: OutputId) -> &mut OutputHandle {
self.output_handles
.iter_mut()
.find(|o| ptr::addr_eq(&***o, id.0))
.unwrap()
}

/// Open a new output, provided the output name and whether it is gzipped.
pub fn output_open(&mut self, name: &str, is_gz: bool) -> Option<OutputId> {
let io = self.hooks.io();
let name = normalize_tex_path(name);
Expand All @@ -521,6 +525,7 @@ impl<'a> CoreBridgeState<'a> {
Some(OutputId(&mut **self.output_handles.last_mut().unwrap()))
}

/// Open a new stdout output.
pub fn output_open_stdout(&mut self) -> Option<OutputId> {
let io = self.hooks.io();

Expand Down Expand Up @@ -563,6 +568,7 @@ impl<'a> CoreBridgeState<'a> {
}
}

/// Close the provided output, flushing it and performing any necessary handling.
pub fn output_close(&mut self, id: OutputId) -> bool {
let mut rv = false;

Expand All @@ -571,7 +577,6 @@ impl<'a> CoreBridgeState<'a> {
.iter()
.position(|o| ptr::addr_eq(&**o, id.0));
if let Some(pos) = pos {
// TODO: How to handle removing IDs? Need a slotmap or some other form of stable ID
let mut oh = self.output_handles.swap_remove(pos);
if let Err(e) = oh.flush() {
tt_warning!(self.status, "error when closing output {}", oh.name(); e.into());
Expand All @@ -588,13 +593,15 @@ impl<'a> CoreBridgeState<'a> {
InputId(input)
}

/// Get a mutable reference to an [`InputHandle`] associated with an [`InputId`]
pub fn get_input(&mut self, input: InputId) -> &mut InputHandle {
self.input_handles
.iter_mut()
.find(|i| ptr::addr_eq(&***i, input.0))
.unwrap()
}

/// Open a new input, provided the input name, the file format, and whether it is gzipped.
pub fn input_open(&mut self, name: &str, format: FileFormat, is_gz: bool) -> Option<InputId> {
let name = normalize_tex_path(name);

Expand Down Expand Up @@ -687,6 +694,7 @@ impl<'a> CoreBridgeState<'a> {
rhandle.ungetc(byte)
}

/// Close the provided output, performing any necessary handling.
pub fn input_close(&mut self, id: InputId) -> bool {
let pos = self
.input_handles
Expand Down
4 changes: 2 additions & 2 deletions crates/engine_bibtex/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ impl<'bib, 'cbs> Deref for ExecCtx<'_, 'bib, 'cbs> {
type Target = Bibtex<'bib, 'cbs>;

fn deref(&self) -> &Self::Target {
&self.glbl_ctx
self.glbl_ctx
}
}

impl DerefMut for ExecCtx<'_, '_, '_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.glbl_ctx
self.glbl_ctx
}
}

Expand Down
9 changes: 2 additions & 7 deletions crates/engine_bibtex/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ pub(crate) enum BstFn {
StrGlbl(usize),
}

#[derive(Clone, Debug)]
#[derive(Clone, Default, Debug)]
pub enum HashExtra {
#[default]
Text,
Integer(i32),
AuxCommand(AuxCommand),
Expand Down Expand Up @@ -152,12 +153,6 @@ impl HashExtra {
}
}

impl Default for HashExtra {
fn default() -> Self {
HashExtra::Text
}
}

#[derive(Clone, Default, Debug)]
pub struct HashNode {
next: HashPointer,
Expand Down

0 comments on commit 1dbe117

Please sign in to comment.