Browse Source

Clippy

master
Adrian Heine 11 months ago
parent
commit
5ca1e45b66
  1. 2
      src/async_utils.rs
  2. 10
      src/loggers.rs
  3. 2
      src/setup/core.rs
  4. 2
      src/setup/setup.rs
  5. 9
      src/setup/symbol_runner.rs
  6. 11
      src/symbols/systemd/user_service.rs
  7. 2
      src/symbols/wordpress/translation.rs

2
src/async_utils.rs

@ -52,7 +52,7 @@ impl Future for TimerFuture {
};
*state = State::Completed;
if let Some(w) = waker {
w.wake()
w.wake();
}
});
}

10
src/loggers.rs

@ -21,19 +21,19 @@ pub trait Logger {
where
Self: Sized,
{
self.writeln(3, msg)
self.writeln(3, msg);
}
fn debug<S: AsRef<str> + Into<String>>(&self, msg: S)
where
Self: Sized,
{
self.writeln(4, msg)
self.writeln(4, msg);
}
fn trace<S: AsRef<str> + Into<String>>(&self, msg: S)
where
Self: Sized,
{
self.writeln(5, msg)
self.writeln(5, msg);
}
fn put<S: AsRef<str> + Into<String>>(&self, entries: impl IntoIterator<Item = Entry<S>>) -> usize
where
@ -88,12 +88,12 @@ impl<'a, L> FilteringLogger<'a, L> {
impl<'a, L: Logger> Logger for FilteringLogger<'a, L> {
fn write<S: AsRef<str> + Into<String>>(&self, level: Level, str: S) {
if level <= self.max_level {
self.logger.write(level, str)
self.logger.write(level, str);
}
}
fn writeln<S: AsRef<str> + Into<String>>(&self, level: Level, str: S) {
if level <= self.max_level {
self.logger.writeln(level, str)
self.logger.writeln(level, str);
}
}
}

2
src/setup/core.rs

@ -33,7 +33,7 @@ macro_rules! add_generic {
$name::Artifact: Clone
),*
{
#[allow(unused)]
#[allow(unused, clippy::shadow_unrelated)]
async fn add_generic(&self, ($($name,)*): ($($name,)*)) -> Result<(StoringLogger, ($($name::Artifact,)*), bool), (StoringLogger, Box<dyn Error>)>
{
let ($($name,)*) = join!($(self.add($name, false),)*);

2
src/setup/setup.rs

@ -34,6 +34,8 @@ impl<L: 'static, B: 'static, SR: 'static, Rs: Hash + Eq + 'static, As: 'static>
self.0.resources.borrow_mut()
}
// FIXME: https://github.com/rust-lang/rust-clippy/issues/6353
#[allow(clippy::await_holding_refcell_ref)]
pub async fn add<R: AddableResource>(&self, resource: R, force_run: bool) -> InternalAddResult<R>
where
Rs: FromResource<R>,

9
src/setup/symbol_runner.rs

@ -101,6 +101,11 @@ impl<R> SymbolRunner for DelayingSymbolRunner<R>
where
R: SymbolRunner,
{
#[allow(
clippy::cast_sign_loss,
clippy::cast_possible_truncation,
clippy::cast_precision_loss
)]
async fn run_symbol<S: Symbol + Debug, L: Logger>(
&self,
symbol: &S,
@ -182,9 +187,9 @@ where
logger.debug(format!("Running symbol {:?}", symbol));
let res = self.0.run_symbol(symbol, logger, force).await;
if let Err(ref e) = res {
logger.info(format!("Failed on {:?} with {}, aborting.", symbol, e))
logger.info(format!("Failed on {:?} with {}, aborting.", symbol, e));
} else {
logger.debug(format!("Successfully finished {:?}", symbol))
logger.debug(format!("Successfully finished {:?}", symbol));
}
res
}

11
src/symbols/systemd/user_service.rs

@ -36,12 +36,11 @@ impl<S: AsRef<Path>, U: AsRef<str>, R: CommandRunner> UserService<'_, S, U, R> {
let result = self.command_runner.run_with_args("systemctl", args).await?;
if result.status.success() {
return Ok(String::from_utf8(result.stdout)?.trim_end().to_string());
} else {
let raw_stderr = String::from_utf8(result.stderr)?;
let stderr = raw_stderr.trim_end();
if stderr != "Failed to connect to bus: No such file or directory" {
return Err(stderr.into());
}
}
let raw_stderr = String::from_utf8(result.stderr)?;
let stderr = raw_stderr.trim_end();
if stderr != "Failed to connect to bus: No such file or directory" {
return Err(stderr.into());
}
tries -= 1;
if tries == 0 {

2
src/symbols/wordpress/translation.rs

@ -53,7 +53,7 @@ impl<C: AsRef<str>, D: AsRef<Path>, R: CommandRunner> Translation<'_, C, D, R> {
res.push((
format!("https://translate.wordpress.org/projects/wp/{}/{}{}/default/export-translations?format={}", version_x, in_slug, path_locale, format),
[self.path.as_ref(), format!("{}{}.{}", out_slug, self.locale.as_ref(), format).as_ref()].iter().collect()
))
));
}
}
res

Loading…
Cancel
Save