Skip to content

Commit 4a8790b

Browse files
committed
(main) ref: better handling of clippy lints
1 parent f2529c4 commit 4a8790b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+128
-128
lines changed

Cargo.toml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ authors = ["Tom Webber"]
66
license-file = "LICENSE"
77
repository = "https://www.github.com/t-webber/c-parser"
88
description = "A rust library to lex and parse C source files into Abstract Syntax Trees."
9-
publish = false
109
keywords = ["parsing", "lexing", "compiling", "nostd"]
11-
categories = ["compilers", "no-std", "no-std::alloc", "parser-implementations", "parsing"]
12-
13-
[dependencies]
10+
readme = "docs/README.md"
11+
categories = [
12+
"compilers",
13+
"no-std",
14+
"no-std::alloc",
15+
"parser-implementations",
16+
"parsing",
17+
]
1418

1519
[features]
16-
debug = []
20+
debug = []
21+

src/errors/compile.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ impl CompileError {
5151
}
5252

5353
impl From<(ErrorLocation, String, ErrorLevel)> for CompileError {
54-
#[inline]
5554
fn from((location, message, err_lvl): (ErrorLocation, String, ErrorLevel)) -> Self {
5655
Self {
5756
err_lvl,
@@ -108,7 +107,7 @@ pub enum ErrorLevel {
108107
Warning,
109108
}
110109

111-
#[expect(clippy::min_ident_chars)]
110+
#[expect(clippy::min_ident_chars, reason = "don't rename trait's method params")]
112111
#[coverage(off)]
113112
impl fmt::Display for ErrorLevel {
114113
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

src/errors/location.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ impl LocationPointer {
190190
}
191191

192192
impl<T: ToString> From<T> for LocationPointer {
193-
#[inline]
194193
fn from(file: T) -> Self {
195194
Self {
196195
col: 0,

src/errors/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
pub mod api {
88
//! Api module to choose what functions to export.
99
10-
#![allow(clippy::pub_use)]
10+
#![allow(clippy::pub_use, reason = "expose simple API")]
1111

1212
pub use super::compile::CompileError;
1313
#[cfg(feature = "debug")]

src/errors/result.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ impl<T: fmt::Debug> Res<T> {
6666
/// # Panics
6767
///
6868
/// If there are too many errors, a buffer overflow occurs
69-
#[inline]
7069
pub fn as_displayed_errors(&self, files: &[(String, &str)], err_type: &str) -> String {
7170
display_errors(&self.errors, files, err_type)
7271
.expect("Buffer overflow, failed to fetch errors")
@@ -83,7 +82,6 @@ impl<T: fmt::Debug> Res<T> {
8382
/// ```ignore
8483
/// assert!(Res::from_errs(vec![]).errors_empty() == true);
8584
/// ```
86-
#[inline]
8785
pub const fn errors_empty(&self) -> bool {
8886
self.errors.is_empty()
8987
}
@@ -117,9 +115,8 @@ impl<T: fmt::Debug> Res<T> {
117115
/// # Panics
118116
///
119117
/// If there is at least one error of level `Failure`.
120-
#[inline]
121118
#[coverage(off)]
122-
#[expect(clippy::print_stderr)]
119+
#[expect(clippy::print_stderr, reason = "goal of function")]
123120
pub fn unwrap_or_display(self, files: &[(String, &str)], err_type: &str) -> T {
124121
eprint!("{}", self.as_displayed_errors(files, err_type));
125122
#[cfg(feature = "debug")]
@@ -135,7 +132,6 @@ impl<T: fmt::Debug> Res<T> {
135132
}
136133

137134
impl<T: Default> From<CompileError> for Res<T> {
138-
#[inline]
139135
fn from(err: CompileError) -> Self {
140136
Self {
141137
result: T::default(),
@@ -145,14 +141,12 @@ impl<T: Default> From<CompileError> for Res<T> {
145141
}
146142

147143
impl<T> From<(T, Vec<CompileError>)> for Res<T> {
148-
#[inline]
149144
fn from((result, errors): (T, Vec<CompileError>)) -> Self {
150145
Self { errors, result }
151146
}
152147
}
153148

154149
impl<T> From<T> for Res<T> {
155-
#[inline]
156150
fn from(value: T) -> Self {
157151
Self {
158152
result: value,
@@ -162,7 +156,6 @@ impl<T> From<T> for Res<T> {
162156
}
163157

164158
impl<T: Default + fmt::Debug> ops::FromResidual<Vec<CompileError>> for Res<T> {
165-
#[inline]
166159
fn from_residual(residual: Vec<CompileError>) -> Self {
167160
Self {
168161
errors: residual,
@@ -172,7 +165,6 @@ impl<T: Default + fmt::Debug> ops::FromResidual<Vec<CompileError>> for Res<T> {
172165
}
173166

174167
impl<T: Default> ops::FromResidual<Result<convert::Infallible, CompileError>> for Res<T> {
175-
#[inline]
176168
#[coverage(off)]
177169
fn from_residual(residual: Result<convert::Infallible, CompileError>) -> Self {
178170
match residual {
@@ -186,7 +178,6 @@ impl<T: Default + fmt::Debug> ops::Try for Res<T> {
186178
type Output = T;
187179
type Residual = Vec<CompileError>;
188180

189-
#[inline]
190181
fn branch(self) -> ops::ControlFlow<Self::Residual, Self::Output> {
191182
if self.errors.is_empty() {
192183
ops::ControlFlow::Continue(self.result)
@@ -195,7 +186,6 @@ impl<T: Default + fmt::Debug> ops::Try for Res<T> {
195186
}
196187
}
197188

198-
#[inline]
199189
#[coverage(off)]
200190
fn from_output(output: Self::Output) -> Self {
201191
Self::from(output)

src/lexer/lex_content.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::errors::api::{IntoError as _, LocationPointer, Res};
1212
///
1313
/// This function updates the [`LS`] automaton, and executes the right
1414
/// handlers.
15-
#[expect(clippy::too_many_lines)]
15+
#[expect(clippy::too_many_lines, reason = "no sense in breaking that logic")]
1616
fn lex_char(
1717
ch: char,
1818
location: &LocationPointer,
@@ -152,7 +152,6 @@ fn lex_char(
152152
/// functions. Every character is parsed one by one, and the state is modified
153153
/// accordingly. When the state changes, the buffers of the state are empty into
154154
/// the data.
155-
#[inline]
156155
pub fn lex_file(content: &str, location: &mut LocationPointer) -> Res<Vec<Token>> {
157156
let mut lex_data = LexingData::default();
158157
let mut lex_state = LS::default();

src/lexer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pub mod api {
66
//! Api module to choose what functions to export.
77
8-
#![allow(clippy::pub_use)]
8+
#![allow(clippy::pub_use, reason = "expose simple API")]
99

1010
pub use super::lex_content::lex_file;
1111
pub use super::numbers::api::Number;

src/lexer/numbers/base/hexadecimal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Module to parse hexadecimal-represented number constants
22
3-
#![allow(clippy::arbitrary_source_item_ordering)]
3+
#![allow(clippy::arbitrary_source_item_ordering, reason = "macro usage")]
44

55
use core::num::{IntErrorKind, ParseIntError};
66

@@ -15,7 +15,7 @@ use crate::lexer::numbers::types::{ERR_PREFIX, Number, NumberType};
1515
/// Implements the [`FloatingPoint`] for the floating-point types.
1616
macro_rules! impl_floating_point {
1717
($x:expr, $($type:ident)*) => {
18-
$(#[allow(clippy::as_conversions, clippy::cast_precision_loss, clippy::allow_attributes)]
18+
$(#[allow(clippy::as_conversions, clippy::cast_precision_loss, clippy::allow_attributes, reason="todo")]
1919
impl FloatingPoint<${concat($type, IntPart)}> for $type {
2020
const MANTISSA_SIZE: u32 = $x;
2121

@@ -49,7 +49,7 @@ macro_rules! impl_floating_point {
4949
/// Parses the stringified version of a number into a [`HexFloatData`].
5050
macro_rules! parse_hexadecimal_float {
5151
($overflow:expr, $nb_type:ident, $float_parse:ident, $($t:ident)*) => {{
52-
#[expect(clippy::float_arithmetic, clippy::arithmetic_side_effects, clippy::as_conversions)]
52+
#[expect(clippy::float_arithmetic, clippy::arithmetic_side_effects, clippy::as_conversions, reason="todo")]
5353
match $nb_type {
5454
$(NumberType::$t => {
5555
let int_part = $t::from_unsigned(

src/lexer/numbers/macros.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Module that defines useful macros to parse integer and get useful errors.
22
3-
#![allow(clippy::arbitrary_source_item_ordering)]
4-
#![allow(clippy::pub_use)]
3+
#![allow(clippy::arbitrary_source_item_ordering, reason = "macro usage")]
54

65
/// Parses an integer from a given base
76
///

src/lexer/numbers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
pub mod api {
1818
//! Api module to choose what functions to export.
1919
20-
#![allow(clippy::pub_use)]
20+
#![allow(clippy::pub_use, reason = "expose simple API")]
2121

2222
pub use super::from_literal::literal_to_number;
2323
pub use super::parse::OverParseRes;

0 commit comments

Comments
 (0)