Skip to content

Commit df991ee

Browse files
committed
Enable absolute_paths warning
1 parent beec762 commit df991ee

10 files changed

Lines changed: 53 additions & 48 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ too-many-lines = "allow"
8484
unreadable-literal = "allow"
8585

8686
# restriction lints
87+
absolute_paths = "warn"
8788
allow_attributes = "deny"
8889
allow_attributes_without_reason = "deny"
8990
arbitrary_source_item_ordering = "warn"

pineappl/src/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Error types for the `pineappl` library.
22
3+
use std::result::Result as StdResult;
34
use thiserror::Error;
45

56
/// Catch-all error for this crate.
@@ -14,4 +15,4 @@ pub enum Error {
1415
}
1516

1617
/// Convenient result type using [`Error`].
17-
pub type Result<T> = std::result::Result<T, Error>;
18+
pub type Result<T> = StdResult<T, Error>;

pineappl/src/grid.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use serde::{Deserialize, Serialize};
2525
use std::collections::BTreeMap;
2626
use std::io::{BufRead, BufReader, BufWriter, Read, Write};
2727
use std::ops::{Bound, RangeBounds};
28+
use std::result::Result as StdResult;
2829
use std::{iter, mem};
2930

3031
const BIN_AXIS: Axis = Axis(1);
@@ -379,7 +380,7 @@ impl Grid {
379380
pub fn evolve<
380381
'a,
381382
E: Into<anyhow::Error>,
382-
S: IntoIterator<Item = std::result::Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>,
383+
S: IntoIterator<Item = StdResult<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>,
383384
>(
384385
&self,
385386
slices: Vec<S>,

pineappl/src/interpolation.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ fn lagrange_weights(i: usize, n: usize, u: f64) -> f64 {
366366
#[cfg(test)]
367367
mod tests {
368368
use super::*;
369+
use crate::packed_array::PackedArray;
369370
use float_cmp::Ulps as _;
370371
use float_cmp::assert_approx_eq;
371372

@@ -516,7 +517,7 @@ mod tests {
516517
assert_approx_eq!(f64, node, ref_node, ulps = 4);
517518
}
518519

519-
let mut array = crate::packed_array::PackedArray::<f64>::new(vec![40, 50, 50]);
520+
let mut array = PackedArray::<f64>::new(vec![40, 50, 50]);
520521
let ntuples = [[100000.0, 0.25, 0.5], [1000.0, 0.5, 0.5]];
521522
let weight = 1.0;
522523

@@ -711,7 +712,7 @@ mod tests {
711712
InterpMeth::Lagrange,
712713
),
713714
];
714-
let mut array = crate::packed_array::PackedArray::<f64>::new(vec![40, 50, 50]);
715+
let mut array = PackedArray::<f64>::new(vec![40, 50, 50]);
715716

716717
let ntuple = [1000.0, 0.5, 0.5];
717718
let weight = 0.0;
@@ -741,7 +742,7 @@ mod tests {
741742
Map::ApplGridH0,
742743
InterpMeth::Lagrange,
743744
)];
744-
let mut array = crate::packed_array::PackedArray::<f64>::new(vec![1]);
745+
let mut array = PackedArray::<f64>::new(vec![1]);
745746

746747
let ntuple = [90.0_f64.powi(2)];
747748
let weight = 1.0;

pineappl_applgrid/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! TODO.
22
3+
#![expect(clippy::absolute_paths, reason = "does not work properly with cxx")]
34
#![expect(
45
clippy::arbitrary_source_item_ordering,
56
reason = "does not work properly with cxx"

pineappl_capi/src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ use pineappl::subgrid::{ImportSubgridV1, Subgrid as _};
7070
use std::collections::HashMap;
7171
use std::ffi::{CStr, CString};
7272
use std::fs::File;
73+
use std::io::Error as IoError;
7374
use std::mem;
7475
use std::os::raw::{c_char, c_void};
7576
use std::path::Path;
7677
use std::slice;
78+
use std::ptr;
7779

7880
/// Select subgrid type optimization when passed to grid optimization (see `GridOptFlags::OPTIMIZE_SUBGRID_TYPE`).
7981
pub const PINEAPPL_GOF_OPTIMIZE_SUBGRID_TYPE: GridOptFlags = GridOptFlags::OPTIMIZE_SUBGRID_TYPE;
@@ -948,7 +950,7 @@ pub unsafe extern "C" fn pineappl_grid_delete_bins(
948950
bin_indices_len: usize,
949951
) {
950952
let grid = unsafe { &mut *grid };
951-
let bin_indices = unsafe { std::slice::from_raw_parts(bin_indices_ptr, bin_indices_len) };
953+
let bin_indices = unsafe { slice::from_raw_parts(bin_indices_ptr, bin_indices_len) };
952954
grid.delete_bins(bin_indices);
953955
}
954956

@@ -1730,7 +1732,7 @@ pub unsafe extern "C" fn pineappl_grid_new2(
17301732
let convolutions = unsafe { slice::from_raw_parts(convolutions, nb_convolutions) }.to_vec();
17311733

17321734
// Grid interpolations
1733-
let interp_slices = unsafe { std::slice::from_raw_parts(interps, interpolations) };
1735+
let interp_slices = unsafe { slice::from_raw_parts(interps, interpolations) };
17341736
let interp_vecs: Vec<_> = interp_slices
17351737
.iter()
17361738
.map(|interp| {
@@ -1750,7 +1752,7 @@ pub unsafe extern "C" fn pineappl_grid_new2(
17501752
let kinematics = unsafe { slice::from_raw_parts(kinematics, interp_vecs.len()) }.to_vec();
17511753

17521754
// Scales. An array containing the values of `ScaleFuncForm` objects
1753-
let mu_scales = unsafe { std::slice::from_raw_parts(scales, 3) };
1755+
let mu_scales = unsafe { slice::from_raw_parts(scales, 3) };
17541756

17551757
Box::new(Grid::new(
17561758
bins,
@@ -1918,7 +1920,7 @@ pub unsafe extern "C" fn pineappl_grid_metadata(
19181920

19191921
grid.metadata()
19201922
.get(key.as_ref())
1921-
.map_or(std::ptr::null_mut(), |value| {
1923+
.map_or(ptr::null_mut(), |value| {
19221924
CString::new(value.as_str()).unwrap().into_raw()
19231925
})
19241926
}
@@ -2492,7 +2494,7 @@ pub unsafe extern "C" fn pineappl_grid_evolve(
24922494
}
24932495

24942496
// we specify an arbitrary error type since we don't return an error anywhere
2495-
Ok::<_, std::io::Error>((operator_slice_info, array))
2497+
Ok::<_, IoError>((operator_slice_info, array))
24962498
})
24972499
})
24982500
.collect();
@@ -2527,10 +2529,10 @@ pub unsafe extern "C" fn pineappl_grid_evolve(
25272529
pub unsafe extern "C" fn pineappl_fktable_optimize(grid: *mut Grid, assumptions: FkAssumptions) {
25282530
let grid = unsafe { &mut *grid };
25292531
// SAFETY: this code has been copied from the `take_mut` crate
2530-
let read_grid = unsafe { std::ptr::read(grid) };
2532+
let read_grid = unsafe { ptr::read(grid) };
25312533
let mut fktable = FkTable::try_from(read_grid)
25322534
// UNWRAP: error handling in the CAPI is to abort
25332535
.unwrap();
25342536
fktable.optimize(assumptions);
2535-
unsafe { std::ptr::write(grid, fktable.into_grid()) };
2537+
unsafe { ptr::write(grid, fktable.into_grid()) };
25362538
}

pineappl_cli/src/helpers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::iter;
1212
use std::ops::RangeInclusive;
1313
use std::path::Path;
1414
use std::process::ExitCode;
15+
use std::result::Result as StdResult;
1516
use std::str::FromStr;
1617

1718
pub const SCALES_VECTOR_REN_FAC: [(f64, f64, f64); 9] = [
@@ -79,7 +80,7 @@ pub struct ConvFuns {
7980
impl FromStr for ConvFuns {
8081
type Err = Error;
8182

82-
fn from_str(arg: &str) -> std::result::Result<Self, Self::Err> {
83+
fn from_str(arg: &str) -> StdResult<Self, Self::Err> {
8384
// split from the left, as '=' characters are allowed in labels but not in names
8485
let (names, label) = arg.split_once('=').unwrap_or((arg, arg));
8586
let (lhapdf_names, members, conv_types) = names

pineappl_cli/tests/export.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![expect(missing_docs, reason = "non-public items will not be documented")]
22

33
use assert_cmd::Command;
4+
use predicates::str as pred_str;
45

56
#[cfg(feature = "applgrid")]
67
use assert_fs::NamedTempFile;
@@ -139,7 +140,7 @@ fn export_applgrid() {
139140
])
140141
.assert()
141142
.success()
142-
.stdout(predicates::str::ends_with(EXPORT_APPLGRID_STR));
143+
.stdout(pred_str::ends_with(EXPORT_APPLGRID_STR));
143144
}
144145

145146
#[test]
@@ -159,7 +160,7 @@ fn export_nnlo_ak5_ptj_discard_non_matching_values() {
159160
])
160161
.assert()
161162
.success()
162-
.stdout(predicates::str::ends_with(EXPORT_NNLO_AK5_PTJ_STR));
163+
.stdout(pred_str::ends_with(EXPORT_NNLO_AK5_PTJ_STR));
163164
}
164165

165166
#[test]
@@ -179,7 +180,7 @@ fn export_nnlo_ak5_ptj_discard_non_matching_scales_alias() {
179180
])
180181
.assert()
181182
.success()
182-
.stdout(predicates::str::ends_with(EXPORT_NNLO_AK5_PTJ_STR));
183+
.stdout(pred_str::ends_with(EXPORT_NNLO_AK5_PTJ_STR));
183184
}
184185

185186
#[test]
@@ -199,7 +200,7 @@ fn export_nnlo_ak5_ptj_discard_non_matching_momentum_alias() {
199200
])
200201
.assert()
201202
.success()
202-
.stdout(predicates::str::ends_with(EXPORT_NNLO_AK5_PTJ_STR));
203+
.stdout(pred_str::ends_with(EXPORT_NNLO_AK5_PTJ_STR));
203204
}
204205

205206
#[test]
@@ -249,5 +250,5 @@ fn export_dis_applgrid() {
249250
])
250251
.assert()
251252
.success()
252-
.stdout(predicates::str::ends_with(EXPORT_DIS_APPLGRID_STR));
253+
.stdout(pred_str::ends_with(EXPORT_DIS_APPLGRID_STR));
253254
}

0 commit comments

Comments
 (0)