Skip to content

Commit cd18e64

Browse files
committed
style: (actually) fix CI for Tia
1 parent 1a0f72f commit cd18e64

File tree

8 files changed

+35
-26
lines changed

8 files changed

+35
-26
lines changed

crates/muropeptide/src/parser.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ impl<T: ?Sized, U> Captures<U> for T {}
5757
#[allow(clippy::too_many_lines)]
5858
pub fn muropeptide<'z, 'a, 'p, 's>(
5959
polymerizer: &'z Polymerizer<'a, 'p>,
60-
) -> impl FnMut(&'s str) -> ParseResult<Muropeptide<'a, 'p>> + Captures<(&'z (), &'a (), &'p ())> {
60+
) -> impl FnMut(&'s str) -> ParseResult<'s, Muropeptide<'a, 'p>> + Captures<(&'z (), &'a (), &'p ())>
61+
{
6162
move |i| {
6263
let polymer = RefCell::new(polymerizer.new_polymer());
6364
// FIXME: Perhaps there is a better way to shorten that `polymer` borrow...
@@ -222,7 +223,7 @@ pub fn muropeptide<'z, 'a, 'p, 's>(
222223
// FIXME: Make private again
223224
pub fn monomer<'c, 'a, 'p, 's>(
224225
polymer: &'c RefCell<Polymer<'a, 'p>>,
225-
) -> impl FnMut(&'s str) -> ParseResult<Monomer> + Captures<(&'c (), &'a (), &'p ())> {
226+
) -> impl FnMut(&'s str) -> ParseResult<'s, Monomer> + Captures<(&'c (), &'a (), &'p ())> {
226227
let optional_peptide = opt(preceded(char('-'), cut(peptide(polymer))));
227228
let glycan_and_peptide = map_res(
228229
pair(glycan(polymer), optional_peptide),
@@ -260,7 +261,8 @@ pub fn monomer<'c, 'a, 'p, 's>(
260261
/// Glycan = { Monosaccharide }- ;
261262
fn glycan<'c, 'a, 'p, 's>(
262263
polymer: &'c RefCell<Polymer<'a, 'p>>,
263-
) -> impl FnMut(&'s str) -> ParseResult<Vec<Monosaccharide>> + Captures<(&'c (), &'a (), &'p ())> {
264+
) -> impl FnMut(&'s str) -> ParseResult<'s, Vec<Monosaccharide>> + Captures<(&'c (), &'a (), &'p ())>
265+
{
264266
let parser = many1(monosaccharide(polymer));
265267
map_res(parser, |residues| {
266268
polymer
@@ -273,7 +275,7 @@ fn glycan<'c, 'a, 'p, 's>(
273275
/// Peptide = { Amino Acid }- ;
274276
fn peptide<'c, 'a, 'p, 's>(
275277
polymer: &'c RefCell<Polymer<'a, 'p>>,
276-
) -> impl FnMut(&'s str) -> ParseResult<Vec<AminoAcid>> + Captures<(&'c (), &'a (), &'p ())> {
278+
) -> impl FnMut(&'s str) -> ParseResult<'s, Vec<AminoAcid>> + Captures<(&'c (), &'a (), &'p ())> {
277279
let parser = many1(amino_acid(polymer));
278280
map_res(parser, |residues| {
279281
let residue_ids = residues.iter().map(|aa| aa.residue);
@@ -287,7 +289,7 @@ fn peptide<'c, 'a, 'p, 's>(
287289
/// Monosaccharide = lowercase , [ Modifications ] ;
288290
fn monosaccharide<'c, 'a, 'p, 's>(
289291
polymer: &'c RefCell<Polymer<'a, 'p>>,
290-
) -> impl FnMut(&'s str) -> ParseResult<Monosaccharide> + Captures<(&'c (), &'a (), &'p ())> {
292+
) -> impl FnMut(&'s str) -> ParseResult<'s, Monosaccharide> + Captures<(&'c (), &'a (), &'p ())> {
291293
let parser = pair(recognize(lowercase), opt(modifications(polymer)));
292294
map_res(parser, |(abbr, modifications)| {
293295
let residue = polymer.borrow_mut().new_residue(abbr)?;
@@ -305,7 +307,7 @@ fn monosaccharide<'c, 'a, 'p, 's>(
305307
/// Amino Acid = Unbranched Amino Acid , [ Lateral Chain ] ;
306308
fn amino_acid<'c, 'a, 'p, 's>(
307309
polymer: &'c RefCell<Polymer<'a, 'p>>,
308-
) -> impl FnMut(&'s str) -> ParseResult<AminoAcid> + Captures<(&'c (), &'a (), &'p ())> {
310+
) -> impl FnMut(&'s str) -> ParseResult<'s, AminoAcid> + Captures<(&'c (), &'a (), &'p ())> {
309311
let parser = pair(unbranched_amino_acid(polymer), opt(lateral_chain(polymer)));
310312
map_res(parser, |(residue, lateral_chain)| {
311313
if let Some(LateralChain { direction, peptide }) = &lateral_chain {
@@ -349,7 +351,8 @@ fn amino_acid<'c, 'a, 'p, 's>(
349351
/// { { " " } , "," , { " " } , Any Modification } , ")" ;
350352
fn modifications<'c, 'a, 'p, 's>(
351353
polymer: &'c RefCell<Polymer<'a, 'p>>,
352-
) -> impl FnMut(&'s str) -> ParseResult<Vec<ModificationId>> + Captures<(&'c (), &'a (), &'p ())> {
354+
) -> impl FnMut(&'s str) -> ParseResult<'s, Vec<ModificationId>> + Captures<(&'c (), &'a (), &'p ())>
355+
{
353356
let separator = delimited(space0, char(','), space0);
354357
delimited(
355358
char('('),
@@ -361,7 +364,8 @@ fn modifications<'c, 'a, 'p, 's>(
361364
/// Unbranched Amino Acid = [ lowercase ] , uppercase , [ Modifications ] ;
362365
fn unbranched_amino_acid<'c, 'a, 'p, 's>(
363366
polymer: &'c RefCell<Polymer<'a, 'p>>,
364-
) -> impl FnMut(&'s str) -> ParseResult<UnbranchedAminoAcid> + Captures<(&'c (), &'a (), &'p ())> {
367+
) -> impl FnMut(&'s str) -> ParseResult<'s, UnbranchedAminoAcid> + Captures<(&'c (), &'a (), &'p ())>
368+
{
365369
let abbr = recognize(preceded(opt(lowercase), uppercase));
366370
let parser = pair(abbr, opt(modifications(polymer)));
367371
map_res(parser, |(abbr, modifications)| {
@@ -381,7 +385,7 @@ fn unbranched_amino_acid<'c, 'a, 'p, 's>(
381385
/// Lateral Chain = "[" , Peptide Direction , { Unbranched Amino Acid }- , "]" ;
382386
fn lateral_chain<'c, 'a, 'p, 's>(
383387
polymer: &'c RefCell<Polymer<'a, 'p>>,
384-
) -> impl FnMut(&'s str) -> ParseResult<LateralChain> + Captures<(&'c (), &'a (), &'p ())> {
388+
) -> impl FnMut(&'s str) -> ParseResult<'s, LateralChain> + Captures<(&'c (), &'a (), &'p ())> {
385389
let peptide = many1(unbranched_amino_acid(polymer));
386390
let parser = delimited(char('['), peptide, char(']'));
387391
map(parser, |peptide| LateralChain {
@@ -413,15 +417,15 @@ fn identifier(i: &str) -> ParseResult<&str> {
413417
/// Any Modification = Named Modification | Offset Modification
414418
pub fn any_modification<'c, 'a, 'p, 's>(
415419
polymer: &'c RefCell<Polymer<'a, 'p>>,
416-
) -> impl FnMut(&'s str) -> ParseResult<ModificationId> + Captures<(&'c (), &'a (), &'p ())> {
420+
) -> impl FnMut(&'s str) -> ParseResult<'s, ModificationId> + Captures<(&'c (), &'a (), &'p ())> {
417421
alt((named_modification(polymer), offset_modification(polymer)))
418422
}
419423

420424
// FIXME: I probably need to add a lot of `wrap_err`s around these parsers!
421425
/// Named Modification = [ Multiplier ] , Identifier
422426
pub fn named_modification<'c, 'a, 'p, 's>(
423427
polymer: &'c RefCell<Polymer<'a, 'p>>,
424-
) -> impl FnMut(&'s str) -> ParseResult<ModificationId> + Captures<(&'c (), &'a (), &'p ())> {
428+
) -> impl FnMut(&'s str) -> ParseResult<'s, ModificationId> + Captures<(&'c (), &'a (), &'p ())> {
425429
let parser = pair(opt(multiplier), identifier);
426430
map_res(parser, |(multiplier, named_mod)| {
427431
polymer
@@ -435,7 +439,7 @@ pub fn named_modification<'c, 'a, 'p, 's>(
435439
/// Chemical Composition ;
436440
pub fn offset_modification<'c, 'a, 'p, 's>(
437441
polymer: &'c RefCell<Polymer<'a, 'p>>,
438-
) -> impl FnMut(&'s str) -> ParseResult<ModificationId> + Captures<(&'c (), &'a (), &'p ())> {
442+
) -> impl FnMut(&'s str) -> ParseResult<'s, ModificationId> + Captures<(&'c (), &'a (), &'p ())> {
439443
let chemical_composition = chemical_composition(polymer.borrow().atomic_db());
440444
let parser = tuple((offset_kind, opt(multiplier), chemical_composition));
441445

crates/polychem/src/moieties/any_mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<'a, 'p> From<NamedMod<'a, 'p>> for AnyMod<'a, 'p> {
2020
}
2121
}
2222

23-
impl<'a, 'p> From<OffsetMod<'a>> for AnyMod<'a, 'p> {
23+
impl<'a> From<OffsetMod<'a>> for AnyMod<'a, '_> {
2424
fn from(value: OffsetMod<'a>) -> Self {
2525
Self::Offset(value)
2626
}

crates/polychem/src/moieties/polymer_database.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ impl<'a: 'r, 'r> ValidateInto<'r, ResidueEntry<'a>> for ResidueKdl {
295295
let groups_from_type = ctx
296296
.1
297297
.get(&self.residue_type)
298-
.ok_or_else(|| ChemistryErrorKind::UndefinedResidueType(self.span, self.residue_type))?
298+
.ok_or(ChemistryErrorKind::UndefinedResidueType(
299+
self.span,
300+
self.residue_type,
301+
))?
299302
.clone();
300303

301304
let mut seen_groups = HashMap::new();

crates/polychem/src/moieties/target.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'p> From<Target<&'p str>> for Target {
199199

200200
// NOTE: Sometimes you might end up with `&Target<&str>`, but `Target<&str>` is `Copy`, so you can just dereference to
201201
// get the desired `Target<&str>` type. This is helpful when dealing with the items of `&[Target<&str>]` containers!
202-
impl<'p> From<&Self> for Target<&'p str> {
202+
impl From<&Self> for Target<&str> {
203203
fn from(value: &Self) -> Self {
204204
*value
205205
}
@@ -378,7 +378,7 @@ mod tests {
378378
impl<'p, V> Index<'p, V> {
379379
// NOTE: Probably not super useful public API, but if it does end up being useful outside of these tests, it
380380
// can be made public again
381-
fn get_values(&'p self, target: impl Into<Target<&'p str>>) -> Vec<&V> {
381+
fn get_values(&'p self, target: impl Into<Target<&'p str>>) -> Vec<&'p V> {
382382
self.matches(target, |_, _, _, v| v).collect()
383383
}
384384
}

crates/polychem/src/parsers/chemical_composition.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
/// ;
2727
pub fn chemical_composition<'a, 's, K: UserErrorKind>(
2828
db: &'a AtomicDatabase,
29-
) -> impl FnMut(&'s str) -> ParseResult<ChemicalComposition<'a>, K> {
29+
) -> impl FnMut(&'s str) -> ParseResult<'s, ChemicalComposition<'a>, K> {
3030
let chemical_formula = many1(atomic_offset(db));
3131
let optional_particle_offset = opt(pair(offset_kind, cut(particle_offset(db))));
3232
let atoms_and_particles = map(
@@ -60,7 +60,7 @@ pub fn chemical_composition<'a, 's, K: UserErrorKind>(
6060
/// Atomic Offset = ( Element | Isotope ) , [ Count ] ;
6161
fn atomic_offset<'a, 's>(
6262
db: &'a AtomicDatabase,
63-
) -> impl FnMut(&'s str) -> ParseResult<(Element<'a>, Count)> {
63+
) -> impl FnMut(&'s str) -> ParseResult<'s, (Element<'a>, Count)> {
6464
let element_or_isotope = alt((element(db), isotope(db)));
6565
let optional_count = opt(count).map(Option::unwrap_or_default);
6666
let parser = pair(element_or_isotope, optional_count);
@@ -70,7 +70,7 @@ fn atomic_offset<'a, 's>(
7070
/// Particle Offset = [ Count ] , Particle ;
7171
fn particle_offset<'a, 's>(
7272
db: &'a AtomicDatabase,
73-
) -> impl FnMut(&'s str) -> ParseResult<(Count, Particle<'a>)> {
73+
) -> impl FnMut(&'s str) -> ParseResult<'s, (Count, Particle<'a>)> {
7474
let optional_count = opt(count).map(Option::unwrap_or_default);
7575
let parser = pair(optional_count, particle(db));
7676
wrap_err(parser, PolychemErrorKind::ExpectedParticleOffset)
@@ -79,21 +79,23 @@ fn particle_offset<'a, 's>(
7979
// ---------------------------------------------------------------------------------------------------------------------
8080

8181
/// Element = uppercase , [ lowercase ] ;
82-
fn element<'a, 's>(db: &'a AtomicDatabase) -> impl FnMut(&'s str) -> ParseResult<Element<'a>> {
82+
fn element<'a, 's>(db: &'a AtomicDatabase) -> impl FnMut(&'s str) -> ParseResult<'s, Element<'a>> {
8383
map_res(element_symbol, |symbol| Element::new(db, symbol))
8484
}
8585

8686
// NOTE: These are not meant to be links, it's just EBNF
8787
#[allow(clippy::doc_link_with_quotes)]
8888
/// Isotope = "[" , Count , Element , "]" ;
89-
fn isotope<'a, 's>(db: &'a AtomicDatabase) -> impl FnMut(&'s str) -> ParseResult<Element<'a>> {
89+
fn isotope<'a, 's>(db: &'a AtomicDatabase) -> impl FnMut(&'s str) -> ParseResult<'s, Element<'a>> {
9090
map_res(isotope_expr, |(mass_number, symbol)| {
9191
Element::new_isotope(db, symbol, mass_number)
9292
})
9393
}
9494

9595
/// Particle = lowercase ;
96-
fn particle<'a, 's>(db: &'a AtomicDatabase) -> impl FnMut(&'s str) -> ParseResult<Particle<'a>> {
96+
fn particle<'a, 's>(
97+
db: &'a AtomicDatabase,
98+
) -> impl FnMut(&'s str) -> ParseResult<'s, Particle<'a>> {
9799
map_res(particle_symbol, |symbol| Particle::new(db, symbol))
98100
}
99101

crates/polychem/src/parsers/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ impl LabeledErrorKind for PolychemErrorKind {
119119
impl<'a> FromExternalError<'a, AtomicLookupError> for PolychemErrorKind {
120120
const FATAL: bool = true;
121121

122-
fn from_external_error(input: &'a str, e: AtomicLookupError) -> LabeledParseError<'_, Self> {
122+
fn from_external_error(input: &'a str, e: AtomicLookupError) -> LabeledParseError<'a, Self> {
123123
LabeledParseError::new(input, Self::LookupError(Box::new(e)))
124124
}
125125
}
126126

127127
impl<'a> FromExternalError<'a, Box<PolychemError>> for PolychemErrorKind {
128128
const FATAL: bool = true;
129129

130-
fn from_external_error(input: &'a str, e: Box<PolychemError>) -> LabeledParseError<'_, Self> {
130+
fn from_external_error(input: &'a str, e: Box<PolychemError>) -> LabeledParseError<'a, Self> {
131131
LabeledParseError::new(input, Self::PolychemError(e))
132132
}
133133
}

crates/polychem/src/polymers/polymerizer_state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl<'a, 'p> PolymerizerState<'a, 'p> {
222222

223223
// Private Methods =====================================================================================================
224224

225-
impl<'a, 'p> PolymerizerState<'a, 'p> {
225+
impl<'p> PolymerizerState<'_, 'p> {
226226
fn diagnose_any_missing_groups<'t, T: 'p>(
227227
&self,
228228
targets: &'t [T],

crates/smithereens/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<'p> Index<NodeId> for Fragment<'p> {
410410
}
411411

412412
// FIXME: Honestly, these might be making the code more confusing... Consider removing or replacing with a method?
413-
impl<'p> IndexMut<NodeId> for Fragment<'p> {
413+
impl IndexMut<NodeId> for Fragment<'_> {
414414
fn index_mut(&mut self, index: NodeId) -> &mut Self::Output {
415415
self.residues[index].as_mut().unwrap()
416416
}

0 commit comments

Comments
 (0)