Skip to content

Commit

Permalink
refactor: fix new lints and some typos
Browse files Browse the repository at this point in the history
Adjust to the new lints from Rust 1.78 and fix some small typos along
the way.
  • Loading branch information
dnaka91 committed May 4, 2024
1 parent ec76370 commit 4a782f5
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 76 deletions.
2 changes: 1 addition & 1 deletion crates/mabo-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum Error {
/// Failed to load the Mabo project.
#[error("failed to load the Mabo project")]
LoadProject(#[source] mabo_project::Error),
/// The required OUT_DIR env var doesn't exist.
/// The required `OUT_DIR` env var doesn't exist.
#[error("missing OUT_DIR environment variable")]
NoOutDir,
/// The file name resulting from a glob pattern didn't produce a usable file path.
Expand Down
11 changes: 0 additions & 11 deletions crates/mabo-doc/src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,6 @@ fn merge_comments(item: &[&str]) -> String {
})
}

struct MergeComments<'a>(&'a [&'a str]);

impl Display for MergeComments<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for line in self.0 {
writeln!(f, "{line}")?;
}
Ok(())
}
}

struct PrintField<'a>(&'a Field<'a>, FieldKind);

impl Display for PrintField<'_> {
Expand Down
60 changes: 0 additions & 60 deletions crates/mabo-parser/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ pub(crate) trait ParserExt {
where
G: Fn(usize, E) -> E2,
Self: Parser<I, O, E> + Sized;

fn map_err_input<G, I, O, E, E2>(self, map: G) -> MapErrInput<Self, G, I, O, E, E2>
where
G: Fn(I, E) -> E2,
Self: Parser<I, O, E> + Sized;
}

impl<T> ParserExt for T {
Expand All @@ -39,15 +34,6 @@ impl<T> ParserExt for T {
{
MapErrLoc::new(self, map)
}

#[inline(always)]
fn map_err_input<G, I, O, E, E2>(self, map: G) -> MapErrInput<Self, G, I, O, E, E2>
where
G: Fn(I, E) -> E2,
Self: Parser<I, O, E> + Sized,
{
MapErrInput::new(self, map)
}
}

pub(crate) struct MapErr<F, G, I, O, E, E2>
Expand Down Expand Up @@ -140,49 +126,3 @@ where
}
}
}

pub(crate) struct MapErrInput<F, G, I, O, E, E2>
where
F: Parser<I, O, E>,
G: Fn(I, E) -> E2,
{
parser: F,
map: G,
i: PhantomData<I>,
o: PhantomData<O>,
e: PhantomData<E>,
e2: PhantomData<E2>,
}

impl<F, G, I, O, E, E2> MapErrInput<F, G, I, O, E, E2>
where
F: Parser<I, O, E>,
G: Fn(I, E) -> E2,
{
#[inline(always)]
pub(crate) fn new(parser: F, map: G) -> Self {
Self {
parser,
map,
i: PhantomData,
o: PhantomData,
e: PhantomData,
e2: PhantomData,
}
}
}

impl<F, G, I, O, E, E2> Parser<I, O, E2> for MapErrInput<F, G, I, O, E, E2>
where
F: Parser<I, O, E>,
G: Fn(I, E) -> E2,
I: Copy,
{
#[inline]
fn parse_next(&mut self, i: &mut I) -> PResult<O, E2> {
match self.parser.parse_next(i) {
Ok(o) => Ok(o),
Err(e) => Err(e.map(|e| (self.map)(*i, e))),
}
}
}
2 changes: 1 addition & 1 deletion crates/mabo-project/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct Package {
#[serde(default, deserialize_with = "de::spdx_expression_opt")]
pub license: Option<spdx::Expression>,
/// List of files that make up the schema package. These are not regular file paths but glob
/// patterns, meaning that file trees can be defined in a consise way like `schemas/**/*.mabo`.
/// patterns, meaning that file trees can be defined in a concise way like `schemas/**/*.mabo`.
///
/// Regardless of the [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) defined
/// the final file list is always filtered by the `.mabo` file extension.
Expand Down
4 changes: 2 additions & 2 deletions vscode-extension/schemas/mabo.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
},
"Files": {
"title": "Files",
"description": "List of files that make up the schema package. These are not regular file paths but glob patterns, meaning that\nfile trees can be defined in a consise way like `schemas/**/*.mabo`.\n\nRegardless of the [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) defined the final file list is\nalways filtered by the `.mabo` file extension.\n",
"description": "List of files that make up the schema package. These are not regular file paths but glob patterns, meaning that\nfile trees can be defined in a concise way like `schemas/**/*.mabo`.\n\nRegardless of the [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) defined the final file list is\nalways filtered by the `.mabo` file extension.\n",
"type": "array",
"items": [
{
"type": "string",
"description": "List of files that make up the schema package. These are not regular file paths but glob patterns, meaning that\nfile trees can be defined in a consise way like `schemas/**/*.mabo`.\n\nRegardless of the [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) defined the final file list is\nalways filtered by the `.mabo` file extension.\n"
"description": "List of files that make up the schema package. These are not regular file paths but glob patterns, meaning that\nfile trees can be defined in a concise way like `schemas/**/*.mabo`.\n\nRegardless of the [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) defined the final file list is\nalways filtered by the `.mabo` file extension.\n"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion vscode-extension/schemas/mabo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ definitions:
title: Files
description: &filesDesc |
List of files that make up the schema package. These are not regular file paths but glob patterns, meaning that
file trees can be defined in a consise way like `schemas/**/*.mabo`.
file trees can be defined in a concise way like `schemas/**/*.mabo`.

Regardless of the [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) defined the final file list is
always filtered by the `.mabo` file extension.
Expand Down

0 comments on commit 4a782f5

Please sign in to comment.