Browse Source

Enable more clippy lints

pull/1858/head
Emil Ernerfeldt 2 years ago
parent
commit
8e2de26e4e
  1. 5
      Cranky.toml
  2. 2
      egui/src/input_state/touch_state.rs
  3. 6
      egui_demo_lib/src/demo/plot_demo.rs
  4. 4
      egui_demo_lib/src/syntax_highlighting.rs
  5. 2
      emath/src/smart_aim.rs
  6. 28
      epaint/src/mutex.rs

5
Cranky.toml

@ -22,6 +22,7 @@ warn = [
"clippy::expl_impl_clone_on_copy", "clippy::expl_impl_clone_on_copy",
"clippy::explicit_deref_methods", "clippy::explicit_deref_methods",
"clippy::explicit_into_iter_loop", "clippy::explicit_into_iter_loop",
"clippy::explicit_iter_loop",
"clippy::fallible_impl_from", "clippy::fallible_impl_from",
"clippy::filter_map_next", "clippy::filter_map_next",
"clippy::flat_map_option", "clippy::flat_map_option",
@ -43,6 +44,7 @@ warn = [
"clippy::linkedlist", "clippy::linkedlist",
"clippy::lossy_float_literal", "clippy::lossy_float_literal",
"clippy::macro_use_imports", "clippy::macro_use_imports",
"clippy::manual_assert",
"clippy::manual_ok_or", "clippy::manual_ok_or",
"clippy::map_err_ignore", "clippy::map_err_ignore",
"clippy::map_flatten", "clippy::map_flatten",
@ -88,14 +90,17 @@ warn = [
"clippy::useless_transmute", "clippy::useless_transmute",
"clippy::verbose_file_reads", "clippy::verbose_file_reads",
"clippy::zero_sized_map_values", "clippy::zero_sized_map_values",
"elided_lifetimes_in_paths",
"future_incompatible", "future_incompatible",
"nonstandard_style", "nonstandard_style",
"rust_2018_idioms", "rust_2018_idioms",
"rust_2021_prelude_collisions",
"rustdoc::missing_crate_level_docs", "rustdoc::missing_crate_level_docs",
"semicolon_in_expressions_from_macros", "semicolon_in_expressions_from_macros",
"trivial_numeric_casts", "trivial_numeric_casts",
"unused_extern_crates", "unused_extern_crates",
"unused_import_braces", "unused_import_braces",
"unused_lifetimes",
# "clippy::cloned_instead_of_copied", # "clippy::cloned_instead_of_copied",
# "clippy::mod_module_files", # "clippy::mod_module_files",
# "trivial_casts", # "trivial_casts",

2
egui/src/input_state/touch_state.rs

@ -286,7 +286,7 @@ impl TouchState {
impl Debug for TouchState { impl Debug for TouchState {
// This outputs less clutter than `#[derive(Debug)]`: // This outputs less clutter than `#[derive(Debug)]`:
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for (id, touch) in self.active_touches.iter() { for (id, touch) in &self.active_touches {
f.write_fmt(format_args!("#{:?}: {:#?}\n", id, touch))?; f.write_fmt(format_args!("#{:?}: {:#?}\n", id, touch))?;
} }
f.write_fmt(format_args!("gesture: {:#?}\n", self.gesture_state))?; f.write_fmt(format_args!("gesture: {:#?}\n", self.gesture_state))?;

6
egui_demo_lib/src/demo/plot_demo.rs

@ -90,15 +90,13 @@ impl LineDemo {
ComboBox::from_label("Line style") ComboBox::from_label("Line style")
.selected_text(line_style.to_string()) .selected_text(line_style.to_string())
.show_ui(ui, |ui| { .show_ui(ui, |ui| {
for style in [ for style in &[
LineStyle::Solid, LineStyle::Solid,
LineStyle::dashed_dense(), LineStyle::dashed_dense(),
LineStyle::dashed_loose(), LineStyle::dashed_loose(),
LineStyle::dotted_dense(), LineStyle::dotted_dense(),
LineStyle::dotted_loose(), LineStyle::dotted_loose(),
] ] {
.iter()
{
ui.selectable_value(line_style, *style, style.to_string()); ui.selectable_value(line_style, *style, style.to_string());
} }
}); });

4
egui_demo_lib/src/syntax_highlighting.rs

@ -29,10 +29,10 @@ pub fn highlight(ctx: &egui::Context, theme: &CodeTheme, code: &str, language: &
} }
} }
type HighlightCache<'a> = egui::util::cache::FrameCache<LayoutJob, Highlighter>; type HighlightCache = egui::util::cache::FrameCache<LayoutJob, Highlighter>;
let mut memory = ctx.memory(); let mut memory = ctx.memory();
let highlight_cache = memory.caches.cache::<HighlightCache<'_>>(); let highlight_cache = memory.caches.cache::<HighlightCache>();
highlight_cache.get((theme, code, language)) highlight_cache.get((theme, code, language))
} }

2
emath/src/smart_aim.rs

@ -85,7 +85,7 @@ fn to_decimal_string(v: f64) -> [i32; NUM_DECIMALS] {
crate::emath_assert!(v < 10.0, "{:?}", v); crate::emath_assert!(v < 10.0, "{:?}", v);
let mut digits = [0; NUM_DECIMALS]; let mut digits = [0; NUM_DECIMALS];
let mut v = v.abs(); let mut v = v.abs();
for r in digits.iter_mut() { for r in &mut digits {
let digit = v.floor(); let digit = v.floor();
*r = digit as i32; *r = digit as i32;
v -= digit; v -= digit;

28
epaint/src/mutex.rs

@ -170,25 +170,25 @@ mod rw_lock_impl {
} }
pub fn read(&self) -> RwLockReadGuard<'_, T> { pub fn read(&self) -> RwLockReadGuard<'_, T> {
if self.lock.is_locked_exclusive() { assert!(
panic!( !self.lock.is_locked_exclusive(),
"{} DEAD-LOCK DETECTED! Previous lock held at:\n{}\n\n", "{} DEAD-LOCK DETECTED! Previous lock held at:\n{}\n\n",
std::any::type_name::<Self>(), std::any::type_name::<Self>(),
format_backtrace(&mut self.last_lock.lock()) format_backtrace(&mut self.last_lock.lock())
); );
}
*self.last_lock.lock() = make_backtrace(); *self.last_lock.lock() = make_backtrace();
parking_lot::RwLockReadGuard::map(self.lock.read(), |v| v) parking_lot::RwLockReadGuard::map(self.lock.read(), |v| v)
} }
pub fn write(&self) -> RwLockWriteGuard<'_, T> { pub fn write(&self) -> RwLockWriteGuard<'_, T> {
if self.lock.is_locked() { assert!(
panic!( !self.lock.is_locked(),
"{} DEAD-LOCK DETECTED! Previous lock held at:\n{}\n\n", "{} DEAD-LOCK DETECTED! Previous lock held at:\n{}\n\n",
std::any::type_name::<Self>(), std::any::type_name::<Self>(),
format_backtrace(&mut self.last_lock.lock()) format_backtrace(&mut self.last_lock.lock())
); );
}
*self.last_lock.lock() = make_backtrace(); *self.last_lock.lock() = make_backtrace();
parking_lot::RwLockWriteGuard::map(self.lock.write(), |v| v) parking_lot::RwLockWriteGuard::map(self.lock.write(), |v| v)
} }

Loading…
Cancel
Save