other: enforce unused_imports lint again (#1189)

* other: enforce unused_imports lint again

I think there shouldn't be any issues with enforcing this now...

* set up cfg block so the logging feature doesn't break clippy

* some cleanup + comments
This commit is contained in:
Clement Tsang 2023-06-08 02:28:36 -04:00 committed by GitHub
parent 086b622c66
commit f0121e6af4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 19 deletions

View file

@ -1,13 +1,16 @@
#![warn(rust_2018_idioms)]
#![deny(rust_2018_idioms)]
#![deny(clippy::todo)]
#![deny(clippy::unimplemented)]
#![deny(clippy::missing_safety_doc)]
#[allow(unused_imports)] // TODO: Deny unused imports.
// Primarily used for debug purposes.
#[cfg(feature = "log")]
#[macro_use]
extern crate log;
cfg_if::cfg_if! {
if #[cfg(feature = "log")] {
#[allow(unused_imports)]
#[macro_use]
extern crate log;
}
}
use std::{
boxed::Box,

View file

@ -5,15 +5,19 @@
//! than the actual usage of the application. If you are instead looking for documentation regarding the *usage* of
//! bottom, refer to [here](https://clementtsang.github.io/bottom/stable/).
#![warn(rust_2018_idioms)]
#![deny(rust_2018_idioms)]
#![deny(clippy::todo)]
#![deny(clippy::unimplemented)]
#![deny(clippy::missing_safety_doc)]
#[allow(unused_imports)] // TODO: Deny unused imports.
// Only used for builds not intended for release.
#[cfg(feature = "log")]
#[macro_use]
extern crate log;
// Primarily used for debug purposes.
cfg_if::cfg_if! {
if #[cfg(feature = "log")] {
#[allow(unused_imports)]
#[macro_use]
extern crate log;
}
}
use std::{
boxed::Box,
@ -71,6 +75,7 @@ pub type Pid = usize;
#[cfg(target_family = "unix")]
pub type Pid = libc::pid_t;
/// Events sent to the main thread.
#[derive(Debug)]
pub enum BottomEvent {
Resize,
@ -82,6 +87,7 @@ pub enum BottomEvent {
Terminate,
}
/// Events sent to the collection thread.
#[derive(Debug)]
pub enum ThreadEvent {
Reset,
@ -241,19 +247,17 @@ pub fn read_config(config_location: Option<&String>) -> error::Result<Option<Pat
pub fn create_or_get_config(config_path: &Option<PathBuf>) -> error::Result<Config> {
if let Some(path) = config_path {
if let Ok(config_string) = fs::read_to_string(path) {
// We found a config file!
Ok(toml_edit::de::from_str(config_string.as_str())?)
} else {
// Config file DNE...
if let Some(parent_path) = path.parent() {
fs::create_dir_all(parent_path)?;
}
// fs::File::create(path)?.write_all(CONFIG_TOP_HEAD.as_bytes())?;
fs::File::create(path)?.write_all(CONFIG_TEXT.as_bytes())?;
Ok(Config::default())
}
} else {
// Don't write, the config path was somehow None...
// Don't write...
Ok(Config::default())
}
}
@ -264,10 +268,10 @@ pub fn try_drawing(
) -> error::Result<()> {
if let Err(err) = painter.draw_data(terminal, app) {
cleanup_terminal(terminal)?;
return Err(err);
Err(err)
} else {
Ok(())
}
Ok(())
}
pub fn cleanup_terminal(
@ -323,7 +327,7 @@ pub fn panic_hook(panic_info: &PanicInfo<'_>) {
)
.unwrap();
// Print stack trace. Must be done after!
// Print stack trace. Must be done after!
execute!(
stdout,
Print(format!(