From 35b3e4b7be73136666f2e312868c43b4b548966e Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Wed, 29 May 2019 12:55:34 -0700 Subject: [PATCH] round of clippy / unbreaking the build --- clippy.sh | 2 ++ convert_osm/src/lib.rs | 10 ++++++++-- editor/src/debug/mod.rs | 2 +- editor/src/render/car.rs | 2 +- editor/src/render/intersection.rs | 4 ++-- ezgui/src/event.rs | 2 +- halloween/src/render.rs | 7 ++++--- popdat/src/lib.rs | 2 +- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/clippy.sh b/clippy.sh index 4af99e42d0..c0bb87896d 100755 --- a/clippy.sh +++ b/clippy.sh @@ -6,11 +6,13 @@ touch `find * | grep '\.rs' | grep -v target | xargs` # TODO Remove all of these exceptions # TODO Report issues for some of these false positives cargo clippy -- \ + -A clippy::block_in_if_condition_stmt \ -A clippy::collapsible_if \ -A clippy::cyclomatic_complexity \ -A clippy::expect_fun_call \ -A clippy::float_cmp \ -A clippy::if_same_then_else \ + -A clippy::len_without_is_empty \ -A clippy::large_enum_variant \ -A clippy::many_single_char_names \ -A clippy::map_entry \ diff --git a/convert_osm/src/lib.rs b/convert_osm/src/lib.rs index 7b2cd65708..7b90eceb37 100644 --- a/convert_osm/src/lib.rs +++ b/convert_osm/src/lib.rs @@ -122,8 +122,14 @@ fn use_parking_hints( FindClosest::new(&gps_bounds.to_bounds()); for (id, r) in &map.roads { let pts = PolyLine::new(gps_bounds.must_convert(&r.points)); - closest.add((*id, true), &pts.shift_right(LANE_THICKNESS).get(timer)); - closest.add((*id, false), &pts.shift_left(LANE_THICKNESS).get(timer)); + closest.add( + (*id, true), + pts.shift_right(LANE_THICKNESS).get(timer).points(), + ); + closest.add( + (*id, false), + pts.shift_left(LANE_THICKNESS).get(timer).points(), + ); } 'SHAPE: for s in shapes.shapes.into_iter() { diff --git a/editor/src/debug/mod.rs b/editor/src/debug/mod.rs index e11879ab8d..a8c67f385b 100644 --- a/editor/src/debug/mod.rs +++ b/editor/src/debug/mod.rs @@ -555,7 +555,7 @@ fn intersection(p1: &Polygon, p2: &Polygon) -> Vec { let mut cp2 = poly_to_cpoly(p2); cp1.intersection(&mut cp2) .into_iter() - .map(|pts| cpoly_to_poly(pts)) + .map(cpoly_to_poly) .collect() } diff --git a/editor/src/render/car.rs b/editor/src/render/car.rs index a64c56dee7..8eaf247b75 100644 --- a/editor/src/render/car.rs +++ b/editor/src/render/car.rs @@ -93,7 +93,7 @@ impl DrawCar { ); let bg_color = cs.get_def("blinker background", Color::grey(0.2)); - for c in vec![&front_left, &front_right, &back_left, &back_right] { + for c in &[&front_left, &front_right, &back_left, &back_right] { draw_default.push(bg_color, c.to_polygon()); } diff --git a/editor/src/render/intersection.rs b/editor/src/render/intersection.rs index d83b8d7ec4..e7f6a69dd3 100644 --- a/editor/src/render/intersection.rs +++ b/editor/src/render/intersection.rs @@ -75,7 +75,7 @@ impl DrawIntersection { ); } IntersectionType::StopSign => { - for (_, ss) in &map.get_stop_sign(i.id).roads { + for ss in map.get_stop_sign(i.id).roads.values() { if ss.enabled { if let Some((octagon, pole)) = DrawIntersection::stop_sign_geom(ss, map) { default_geom @@ -541,7 +541,7 @@ fn make_octagon(center: Pt2D, radius: Distance, facing: Angle) -> Polygon { .map(|i| { center.project_away( radius, - facing + Angle::new_degs(22.5 + (i * 360 / 8) as f64), + facing + Angle::new_degs(22.5 + f64::from(i * 360 / 8)), ) }) .collect(), diff --git a/ezgui/src/event.rs b/ezgui/src/event.rs index 896e7383d1..858d6598d3 100644 --- a/ezgui/src/event.rs +++ b/ezgui/src/event.rs @@ -64,7 +64,7 @@ impl Event { // Probably the better way is to convert the LogicalPosition to a PhysicalPosition // somehow knowing the DPI. glutin::MouseScrollDelta::PixelDelta(pos) => { - Some(Event::MouseWheelScroll(f64::from(0.1 * pos.y))) + Some(Event::MouseWheelScroll(0.1 * pos.y)) } }, glutin::WindowEvent::Resized(size) => { diff --git a/halloween/src/render.rs b/halloween/src/render.rs index 9e01aec669..ff93528bbd 100644 --- a/halloween/src/render.rs +++ b/halloween/src/render.rs @@ -105,9 +105,10 @@ impl DrawBuilding { // TODO or modify g's ctx g.draw_polygon( BUILDING, - &self - .polygon - .translate(-1.0 * (1.0 - percent) * dx, -1.0 * (1.0 - percent) * dy), + &self.polygon.translate( + Distance::meters(-1.0 * (1.0 - percent) * dx), + Distance::meters(-1.0 * (1.0 - percent) * dy), + ), ); if let Some(new_line) = Line::maybe_new( diff --git a/popdat/src/lib.rs b/popdat/src/lib.rs index 8631d7734f..d108826614 100644 --- a/popdat/src/lib.rs +++ b/popdat/src/lib.rs @@ -153,7 +153,7 @@ impl TractData { let mut sum = 0; for (name, est) in &self.household_vehicles { match name.as_str() { - "1 vehicle avail." => sum += 1 * est.value, + "1 vehicle avail." => sum += est.value, "2 vehicles avail." => sum += 2 * est.value, "3 vehicles avail." => sum += 3 * est.value, // Many more than 4 seems unrealistic