Enable and fix a bunch more lints
This commit is contained in:
parent
e76c919c7e
commit
898f4804b7
21 changed files with 65 additions and 48 deletions
|
@ -10,6 +10,7 @@ rustflags = [
|
|||
"-Wclippy::dbg_macro",
|
||||
"-Wclippy::debug_assert_with_mut_call",
|
||||
"-Wclippy::disallowed_methods",
|
||||
"-Wclippy::disallowed_script_idents",
|
||||
"-Wclippy::doc_markdown",
|
||||
"-Wclippy::empty_enum",
|
||||
"-Wclippy::enum_glob_use",
|
||||
|
@ -23,10 +24,12 @@ rustflags = [
|
|||
"-Wclippy::flat_map_option",
|
||||
"-Wclippy::float_cmp_const",
|
||||
"-Wclippy::fn_params_excessive_bools",
|
||||
"-Wclippy::fn_to_numeric_cast_any",
|
||||
"-Wclippy::from_iter_instead_of_collect",
|
||||
"-Wclippy::if_let_mutex",
|
||||
"-Wclippy::implicit_clone",
|
||||
"-Wclippy::imprecise_flops",
|
||||
"-Wclippy::index_refutable_slice",
|
||||
"-Wclippy::inefficient_to_string",
|
||||
"-Wclippy::invalid_upcast_comparisons",
|
||||
"-Wclippy::iter_not_returning_iterator",
|
||||
|
@ -56,6 +59,8 @@ rustflags = [
|
|||
"-Wclippy::needless_continue",
|
||||
"-Wclippy::needless_for_each",
|
||||
"-Wclippy::needless_pass_by_value",
|
||||
"-Wclippy::negative_feature_names",
|
||||
"-Wclippy::nonstandard_macro_braces",
|
||||
"-Wclippy::option_option",
|
||||
"-Wclippy::path_buf_push_overwrite",
|
||||
"-Wclippy::ptr_as_ptr",
|
||||
|
@ -65,13 +70,16 @@ rustflags = [
|
|||
"-Wclippy::same_functions_in_if_condition",
|
||||
"-Wclippy::semicolon_if_nothing_returned",
|
||||
"-Wclippy::single_match_else",
|
||||
"-Wclippy::str_to_string",
|
||||
"-Wclippy::string_add_assign",
|
||||
"-Wclippy::string_add",
|
||||
"-Wclippy::string_lit_as_bytes",
|
||||
"-Wclippy::string_to_string",
|
||||
"-Wclippy::todo",
|
||||
"-Wclippy::trailing_empty_array",
|
||||
"-Wclippy::trait_duplication_in_bounds",
|
||||
"-Wclippy::unimplemented",
|
||||
"-Wclippy::unnecessary_wraps",
|
||||
"-Wclippy::unnested_or_patterns",
|
||||
"-Wclippy::unused_self",
|
||||
"-Wclippy::useless_transmute",
|
||||
|
@ -81,4 +89,12 @@ rustflags = [
|
|||
"-Wnonstandard_style",
|
||||
"-Wrust_2018_idioms",
|
||||
"-Wrustdoc::missing_crate_level_docs",
|
||||
"-Wsemicolon_in_expressions_from_macros",
|
||||
"-Wtrivial_numeric_casts",
|
||||
"-Wunused_extern_crates",
|
||||
"-Wunused_import_braces",
|
||||
# "-Wclippy::cloned_instead_of_copied",
|
||||
# "-Wclippy::mod_module_files",
|
||||
# "-Wtrivial_casts",
|
||||
# "-Wunused_qualifications",
|
||||
]
|
||||
|
|
|
@ -374,7 +374,7 @@ impl Theme {
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// WebGl Context options
|
||||
/// `WebGl` Context options
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum WebGlContextOption {
|
||||
|
|
|
@ -30,8 +30,8 @@ impl WindowSettings {
|
|||
Self {
|
||||
position,
|
||||
inner_size_points: Some(egui::vec2(
|
||||
inner_size_points.width as f32,
|
||||
inner_size_points.height as f32,
|
||||
inner_size_points.width,
|
||||
inner_size_points.height,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ struct ContextImpl {
|
|||
repaint_after: std::time::Duration,
|
||||
/// While positive, keep requesting repaints. Decrement at the end of each frame.
|
||||
repaint_requests: u32,
|
||||
request_repaint_callbacks: Option<Box<dyn Fn() + Send + Sync>>,
|
||||
request_repaint_callback: Option<Box<dyn Fn() + Send + Sync>>,
|
||||
requested_repaint_last_frame: bool,
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,7 @@ impl Context {
|
|||
// request two frames of repaint, just to cover some corner cases (frame delays):
|
||||
let mut ctx = self.write();
|
||||
ctx.repaint_requests = 2;
|
||||
if let Some(callback) = &ctx.request_repaint_callbacks {
|
||||
if let Some(callback) = &ctx.request_repaint_callback {
|
||||
(callback)();
|
||||
}
|
||||
}
|
||||
|
@ -611,9 +611,11 @@ impl Context {
|
|||
/// For integrations: this callback will be called when an egui user calls [`Self::request_repaint`].
|
||||
///
|
||||
/// This lets you wake up a sleeping UI thread.
|
||||
///
|
||||
/// Note that only one callback can be set. Any new call overrides the previous callback.
|
||||
pub fn set_request_repaint_callback(&self, callback: impl Fn() + Send + Sync + 'static) {
|
||||
let callback = Box::new(callback);
|
||||
self.write().request_repaint_callbacks = Some(callback);
|
||||
self.write().request_repaint_callback = Some(callback);
|
||||
}
|
||||
|
||||
/// Tell `egui` which fonts to use.
|
||||
|
|
|
@ -316,19 +316,19 @@ use crate::Id;
|
|||
///
|
||||
/// // `b` associated with an f64 and a `&'static str`
|
||||
/// map.insert_persisted(b, 13.37);
|
||||
/// map.insert_temp(b, "Hello World".to_string());
|
||||
/// map.insert_temp(b, "Hello World".to_owned());
|
||||
///
|
||||
/// // we can retrieve all four values:
|
||||
/// assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
||||
/// assert_eq!(map.get_temp::<i32>(a), Some(42));
|
||||
/// assert_eq!(map.get_temp::<f64>(b), Some(13.37));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
///
|
||||
/// // we can retrieve them like so also:
|
||||
/// assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
||||
/// assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
||||
/// assert_eq!(map.get_persisted::<f64>(b), Some(13.37));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
/// ```
|
||||
#[derive(Clone, Debug, Default)]
|
||||
// We store use `id XOR typeid` as a key, so we don't need to hash again!
|
||||
|
@ -574,19 +574,19 @@ fn test_two_id_x_two_types() {
|
|||
|
||||
// `b` associated with an f64 and a `&'static str`
|
||||
map.insert_persisted(b, 13.37);
|
||||
map.insert_temp(b, "Hello World".to_string());
|
||||
map.insert_temp(b, "Hello World".to_owned());
|
||||
|
||||
// we can retrieve all four values:
|
||||
assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
||||
assert_eq!(map.get_temp::<i32>(a), Some(42));
|
||||
assert_eq!(map.get_temp::<f64>(b), Some(13.37));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
|
||||
// we can retrieve them like so also:
|
||||
assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
||||
assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
||||
assert_eq!(map.get_persisted::<f64>(b), Some(13.37));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -249,7 +249,7 @@ impl<'a> Widget for DragValue<'a> {
|
|||
.then(|| drag_state.last_dragged_value)
|
||||
.flatten();
|
||||
let stored_value = stored_value.unwrap_or(value);
|
||||
let stored_value = stored_value + delta_value as f64;
|
||||
let stored_value = stored_value + delta_value;
|
||||
|
||||
let aim_delta = aim_rad * speed;
|
||||
let rounded_new_value = emath::smart_aim::best_in_range_f64(
|
||||
|
|
|
@ -837,8 +837,7 @@ impl PlotItem for Points {
|
|||
stem_stroke.width *= 2.0;
|
||||
}
|
||||
|
||||
let y_reference =
|
||||
stems.map(|y| transform.position_from_value(&Value::new(0.0, y)).y as f32);
|
||||
let y_reference = stems.map(|y| transform.position_from_value(&Value::new(0.0, y)).y);
|
||||
|
||||
series
|
||||
.values
|
||||
|
@ -1619,7 +1618,7 @@ fn add_rulers_and_text(
|
|||
|
||||
// Text
|
||||
let text = text.unwrap_or({
|
||||
let mut text = elem.name().to_string(); // could be empty
|
||||
let mut text = elem.name().to_owned(); // could be empty
|
||||
|
||||
if show_values {
|
||||
text.push_str(&elem.default_values_format(plot.transform));
|
||||
|
|
|
@ -178,7 +178,7 @@ impl LegendWidget {
|
|||
.filter(|item| !item.name().is_empty())
|
||||
.for_each(|item| {
|
||||
entries
|
||||
.entry(item.name().to_string())
|
||||
.entry(item.name().to_owned())
|
||||
.and_modify(|entry| {
|
||||
if entry.color != item.color() {
|
||||
// Multiple items with different colors
|
||||
|
|
|
@ -370,7 +370,7 @@ impl Plot {
|
|||
/// if !name.is_empty() {
|
||||
/// format!("{}: {:.*}%", name, 1, value.y)
|
||||
/// } else {
|
||||
/// "".to_string()
|
||||
/// "".to_owned()
|
||||
/// }
|
||||
/// })
|
||||
/// .show(ui, |plot_ui| plot_ui.line(line));
|
||||
|
|
|
@ -108,7 +108,7 @@ impl Widget for ProgressBar {
|
|||
|
||||
if animate {
|
||||
let n_points = 20;
|
||||
let start_angle = ui.input().time as f64 * 360f64.to_radians();
|
||||
let start_angle = ui.input().time * std::f64::consts::TAU;
|
||||
let end_angle = start_angle + 240f64.to_radians() * ui.input().time.sin();
|
||||
let circle_radius = rounding - 2.0;
|
||||
let points: Vec<Pos2> = (0..n_points)
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Widget for Spinner {
|
|||
|
||||
let radius = (rect.height() / 2.0) - 2.0;
|
||||
let n_points = 20;
|
||||
let start_angle = ui.input().time as f64 * 360f64.to_radians();
|
||||
let start_angle = ui.input().time * std::f64::consts::TAU;
|
||||
let end_angle = start_angle + 240f64.to_radians() * ui.input().time.sin();
|
||||
let points: Vec<Pos2> = (0..n_points)
|
||||
.map(|i| {
|
||||
|
|
|
@ -8,12 +8,10 @@ mod wrap_app;
|
|||
pub use wrap_app::WrapApp;
|
||||
|
||||
/// Time of day as seconds since midnight. Used for clock in demo app.
|
||||
pub(crate) fn seconds_since_midnight() -> Option<f64> {
|
||||
pub(crate) fn seconds_since_midnight() -> f64 {
|
||||
use chrono::Timelike;
|
||||
let time = chrono::Local::now().time();
|
||||
let seconds_since_midnight =
|
||||
time.num_seconds_from_midnight() as f64 + 1e-9 * (time.nanosecond() as f64);
|
||||
Some(seconds_since_midnight)
|
||||
time.num_seconds_from_midnight() as f64 + 1e-9 * (time.nanosecond() as f64)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -42,7 +42,8 @@ impl eframe::App for FractalClockApp {
|
|||
egui::CentralPanel::default()
|
||||
.frame(egui::Frame::dark_canvas(&ctx.style()))
|
||||
.show(ctx, |ui| {
|
||||
self.fractal_clock.ui(ui, crate::seconds_since_midnight());
|
||||
self.fractal_clock
|
||||
.ui(ui, Some(crate::seconds_since_midnight()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -287,15 +288,13 @@ impl WrapApp {
|
|||
ui.with_layout(egui::Layout::right_to_left(), |ui| {
|
||||
if false {
|
||||
// TODO(emilk): fix the overlap on small screens
|
||||
if let Some(seconds_since_midnight) = crate::seconds_since_midnight() {
|
||||
if clock_button(ui, seconds_since_midnight).clicked() {
|
||||
if clock_button(ui, crate::seconds_since_midnight()).clicked() {
|
||||
self.state.selected_anchor = "clock".to_owned();
|
||||
if frame.is_web() {
|
||||
ui.output().open_url("#clock");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
egui::warn_if_debug_build(ui);
|
||||
});
|
||||
|
|
|
@ -147,7 +147,7 @@ impl super::View for DragAndDropDemo {
|
|||
|
||||
let response = response.context_menu(|ui| {
|
||||
if ui.button("New Item").clicked() {
|
||||
self.columns[col_idx].push("New Item".to_string());
|
||||
self.columns[col_idx].push("New Item".to_owned());
|
||||
ui.close_menu();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -647,7 +647,7 @@ fn text_layout_ui(
|
|||
ui.label("Overflow character");
|
||||
});
|
||||
|
||||
let mut job = LayoutJob::single_section(LOREM_IPSUM.to_string(), TextFormat::default());
|
||||
let mut job = LayoutJob::single_section(LOREM_IPSUM.to_owned(), TextFormat::default());
|
||||
job.wrap = TextWrapping {
|
||||
max_rows: *max_rows,
|
||||
break_anywhere: *break_anywhere,
|
||||
|
|
|
@ -621,7 +621,7 @@ impl InteractionDemo {
|
|||
let coordinate_text = if let Some(coordinate) = pointer_coordinate {
|
||||
format!("x: {:.02}, y: {:.02}", coordinate.x, coordinate.y)
|
||||
} else {
|
||||
"None".to_string()
|
||||
"None".to_owned()
|
||||
};
|
||||
ui.label(format!("pointer coordinate: {}", coordinate_text));
|
||||
let coordinate_text = format!(
|
||||
|
|
|
@ -684,10 +684,10 @@ pub fn clear(gl: &glow::Context, screen_size_in_pixels: [u32; 2], clear_color: e
|
|||
if true {
|
||||
// verified to be correct on eframe native (on Mac).
|
||||
gl.clear_color(
|
||||
clear_color[0] as f32,
|
||||
clear_color[1] as f32,
|
||||
clear_color[2] as f32,
|
||||
clear_color[3] as f32,
|
||||
clear_color[0],
|
||||
clear_color[1],
|
||||
clear_color[2],
|
||||
clear_color[3],
|
||||
);
|
||||
} else {
|
||||
let clear_color: Color32 = clear_color.into();
|
||||
|
|
|
@ -141,7 +141,7 @@ impl PostProcess {
|
|||
|
||||
let a_pos_loc = gl
|
||||
.get_attrib_location(program, "a_pos")
|
||||
.ok_or_else(|| "failed to get location of a_pos".to_string())?;
|
||||
.ok_or_else(|| "failed to get location of a_pos".to_owned())?;
|
||||
let vao = crate::vao::VertexArrayObject::new(
|
||||
&gl,
|
||||
pos_buffer,
|
||||
|
|
|
@ -23,14 +23,20 @@ macro_rules! impl_numeric_float {
|
|||
|
||||
#[inline(always)]
|
||||
fn to_f64(self) -> f64 {
|
||||
#[allow(trivial_numeric_casts)]
|
||||
{
|
||||
self as f64
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn from_f64(num: f64) -> Self {
|
||||
#[allow(trivial_numeric_casts)]
|
||||
{
|
||||
num as Self
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ type FontIndex = usize;
|
|||
pub struct Font {
|
||||
fonts: Vec<Arc<FontImpl>>,
|
||||
/// Lazily calculated.
|
||||
characters: Option<std::collections::BTreeSet<char>>,
|
||||
characters: Option<BTreeSet<char>>,
|
||||
replacement_glyph: (FontIndex, GlyphInfo),
|
||||
pixels_per_point: f32,
|
||||
row_height: f32,
|
||||
|
@ -382,7 +382,7 @@ fn allocate_glyph(
|
|||
}
|
||||
});
|
||||
|
||||
let offset_in_pixels = vec2(bb.min.x as f32, scale_in_pixels + bb.min.y as f32);
|
||||
let offset_in_pixels = vec2(bb.min.x, scale_in_pixels + bb.min.y);
|
||||
let offset = offset_in_pixels / pixels_per_point + y_offset * Vec2::Y;
|
||||
UvRect {
|
||||
offset,
|
||||
|
|
|
@ -104,11 +104,8 @@ impl TextureAtlas {
|
|||
for dx in -hw..=hw {
|
||||
for dy in -hw..=hw {
|
||||
let distance_to_center = ((dx * dx + dy * dy) as f32).sqrt();
|
||||
let coverage = remap_clamp(
|
||||
distance_to_center,
|
||||
(r as f32 - 0.5)..=(r as f32 + 0.5),
|
||||
1.0..=0.0,
|
||||
);
|
||||
let coverage =
|
||||
remap_clamp(distance_to_center, (r - 0.5)..=(r + 0.5), 1.0..=0.0);
|
||||
image[((x as i32 + hw + dx) as usize, (y as i32 + hw + dy) as usize)] =
|
||||
coverage;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue