diff --git a/abstutil/src/lib.rs b/abstutil/src/lib.rs index 5710b74909..1fdbd2e1eb 100644 --- a/abstutil/src/lib.rs +++ b/abstutil/src/lib.rs @@ -1,8 +1,3 @@ -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate serde_derive; - mod clone; mod collections; mod error; diff --git a/abstutil/src/notes.rs b/abstutil/src/notes.rs index 9ef87d9094..f348f254a0 100644 --- a/abstutil/src/notes.rs +++ b/abstutil/src/notes.rs @@ -1,3 +1,4 @@ +use lazy_static::lazy_static; use std::sync::Mutex; lazy_static! { diff --git a/abstutil/src/random.rs b/abstutil/src/random.rs index a33e049313..4ffb19748f 100644 --- a/abstutil/src/random.rs +++ b/abstutil/src/random.rs @@ -1,5 +1,6 @@ use rand::distributions::{Distribution, Weighted, WeightedChoice}; use rand::{RngCore, SeedableRng, XorShiftRng}; +use serde_derive::{Deserialize, Serialize}; // Need to explain this trick -- basically keeps consistency between two different simulations when // each one might make slightly different sequences of calls to the RNG. diff --git a/convert_osm/src/lib.rs b/convert_osm/src/lib.rs index f8d80e4142..2b30e402f5 100644 --- a/convert_osm/src/lib.rs +++ b/convert_osm/src/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate structopt; - mod group_parcels; mod neighborhoods; mod osm; @@ -15,6 +12,7 @@ use kml::ExtraShapes; use map_model::{raw_data, FindClosest, LANE_THICKNESS}; use ordered_float::NotNaN; use std::path::Path; +use structopt::StructOpt; const MAX_METERS_BTWN_INTERSECTION_AND_SIGNAL: f64 = 50.0; diff --git a/docs/backlog.md b/docs/backlog.md index 1c84607637..c591c0b209 100644 --- a/docs/backlog.md +++ b/docs/backlog.md @@ -8,7 +8,7 @@ - document pieces that're stabilizing - run clippy everywhere - presubmit script - - also enforce consistent style (import order, extern crate only in mod.rs or lib.rs, derive order, struct initialization order) + - also enforce consistent style (derive order, struct initialization order) ## Conga line idea diff --git a/editor/src/colors.rs b/editor/src/colors.rs index dee6cdafb9..27cd7a1768 100644 --- a/editor/src/colors.rs +++ b/editor/src/colors.rs @@ -1,5 +1,6 @@ use abstutil; use ezgui::Color; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap}; use std::io::Error; diff --git a/editor/src/macros.rs b/editor/src/macros.rs index bb3ae72482..2ba66e8fca 100644 --- a/editor/src/macros.rs +++ b/editor/src/macros.rs @@ -4,7 +4,7 @@ macro_rules! debug { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "UI", log::Level::Debug, $( $x, )* ); } } @@ -13,7 +13,7 @@ macro_rules! debug { macro_rules! info { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "UI", log::Level::Info, $( $x, )* ); } } @@ -22,7 +22,7 @@ macro_rules! info { macro_rules! warn { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "UI", log::Level::Warn, $( $x, )* ); } } @@ -31,7 +31,7 @@ macro_rules! warn { macro_rules! error { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "UI", log::Level::Error, $( $x, )* ); } } diff --git a/editor/src/main.rs b/editor/src/main.rs index d496cb8fe8..f4053162e3 100644 --- a/editor/src/main.rs +++ b/editor/src/main.rs @@ -1,18 +1,5 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 -#[macro_use] -extern crate downcast; -#[macro_use] -extern crate generator; -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; -#[macro_use] -extern crate pretty_assertions; -#[macro_use] -extern crate serde_derive; - #[macro_use] mod macros; diff --git a/editor/src/plugins/debug/geom_validation.rs b/editor/src/plugins/debug/geom_validation.rs index e22ab8437e..d04570109e 100644 --- a/editor/src/plugins/debug/geom_validation.rs +++ b/editor/src/plugins/debug/geom_validation.rs @@ -2,6 +2,7 @@ use crate::objects::{DEBUG, ID}; use crate::plugins::{Plugin, PluginCtx}; use crate::render::DrawMap; use generator; +use generator::done; use geo; use geo::prelude::Intersects; use geom::Polygon; diff --git a/editor/src/plugins/logs.rs b/editor/src/plugins/logs.rs index 82e5ca25b3..993b1f7715 100644 --- a/editor/src/plugins/logs.rs +++ b/editor/src/plugins/logs.rs @@ -2,6 +2,7 @@ use crate::objects::{Ctx, ROOT_MENU}; use crate::plugins::{Plugin, PluginCtx}; use abstutil::format_log_record; use ezgui::{GfxCtx, LogScroller}; +use lazy_static::lazy_static; use log::{set_logger, set_max_level, LevelFilter, Log, Metadata, Record}; use piston::input::Key; use std::sync::Mutex; diff --git a/editor/src/plugins/mod.rs b/editor/src/plugins/mod.rs index b053df4231..01ca6e4487 100644 --- a/editor/src/plugins/mod.rs +++ b/editor/src/plugins/mod.rs @@ -11,7 +11,9 @@ use crate::objects::{Ctx, ID}; use crate::ui::PluginCtx; use abstutil; use abstutil::WeightedUsizeChoice; -use downcast::Any; +use downcast::{ + downcast, downcast_methods, downcast_methods_core, downcast_methods_std, impl_downcast, Any, +}; use ezgui::{Color, GfxCtx, WrappedWizard}; use map_model::{IntersectionID, Map}; use sim::{ABTest, Neighborhood, NeighborhoodBuilder, OriginDestination, Scenario, Tick}; diff --git a/editor/src/ui.rs b/editor/src/ui.rs index b70b23715d..03ee4cc32d 100644 --- a/editor/src/ui.rs +++ b/editor/src/ui.rs @@ -13,6 +13,7 @@ use ezgui::{Canvas, Color, EventLoopMode, GfxCtx, Text, UserInput, BOTTOM_LEFT, use kml; use map_model::{BuildingID, IntersectionID, LaneID, Map}; use piston::input::Key; +use serde_derive::{Deserialize, Serialize}; use sim; use sim::{GetDrawAgents, Sim, SimFlags, Tick}; use std::cell::RefCell; diff --git a/ezgui/src/color.rs b/ezgui/src/color.rs index 26d891de76..b72fa23641 100644 --- a/ezgui/src/color.rs +++ b/ezgui/src/color.rs @@ -1,4 +1,5 @@ use palette; +use serde_derive::{Deserialize, Serialize}; use std::fmt; // Copy could be reconsidered, but eh diff --git a/ezgui/src/lib.rs b/ezgui/src/lib.rs index a519299958..c028ef7b09 100644 --- a/ezgui/src/lib.rs +++ b/ezgui/src/lib.rs @@ -1,10 +1,5 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 -#[macro_use] -extern crate log; -#[macro_use] -extern crate serde_derive; - mod canvas; mod color; mod input; diff --git a/ezgui/src/wizard.rs b/ezgui/src/wizard.rs index d355870cf7..9178d7dc17 100644 --- a/ezgui/src/wizard.rs +++ b/ezgui/src/wizard.rs @@ -1,5 +1,6 @@ use crate::{Canvas, GfxCtx, InputResult, LogScroller, Menu, TextBox, UserInput}; use abstutil::Cloneable; +use log::warn; use std::collections::VecDeque; pub struct Wizard { diff --git a/geom/src/angle.rs b/geom/src/angle.rs index d83a80f9a9..11c6838728 100644 --- a/geom/src/angle.rs +++ b/geom/src/angle.rs @@ -1,3 +1,4 @@ +use serde_derive::{Deserialize, Serialize}; use std; use std::f64; use std::fmt; diff --git a/geom/src/circle.rs b/geom/src/circle.rs index 9a92d13925..94a101c10f 100644 --- a/geom/src/circle.rs +++ b/geom/src/circle.rs @@ -1,4 +1,5 @@ use crate::{Bounds, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std::fmt; #[derive(Serialize, Deserialize, Debug)] diff --git a/geom/src/gps.rs b/geom/src/gps.rs index 52d72494e8..61b13f79e5 100644 --- a/geom/src/gps.rs +++ b/geom/src/gps.rs @@ -1,5 +1,6 @@ use crate::{Bounds, HashablePt2D, Pt2D}; use aabb_quadtree::geom::{Point, Rect}; +use serde_derive::{Deserialize, Serialize}; use std::f64; use std::fmt; diff --git a/geom/src/lib.rs b/geom/src/lib.rs index 1a7ac18b41..aadffefeae 100644 --- a/geom/src/lib.rs +++ b/geom/src/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate serde_derive; - mod angle; mod circle; mod gps; diff --git a/geom/src/line.rs b/geom/src/line.rs index aa1c702061..15fd0f8fb5 100644 --- a/geom/src/line.rs +++ b/geom/src/line.rs @@ -1,5 +1,6 @@ use crate::{line_intersection, Angle, Pt2D, EPSILON_DIST}; use dimensioned::si; +use serde_derive::{Deserialize, Serialize}; use std::fmt; // Segment, technically diff --git a/geom/src/polyline.rs b/geom/src/polyline.rs index 167ea21262..bb847f0af4 100644 --- a/geom/src/polyline.rs +++ b/geom/src/polyline.rs @@ -1,6 +1,7 @@ use crate::{line_intersection, Angle, Bounds, Line, Polygon, Pt2D, Triangle, EPSILON_DIST}; use dimensioned::si; use ordered_float::NotNaN; +use serde_derive::{Deserialize, Serialize}; use std::f64; use std::fmt; diff --git a/geom/src/pt.rs b/geom/src/pt.rs index 9297ffa751..2c9aa31f23 100644 --- a/geom/src/pt.rs +++ b/geom/src/pt.rs @@ -1,6 +1,7 @@ use crate::{Angle, GPSBounds, LonLat}; use aabb_quadtree::geom::{Point, Rect}; use ordered_float::NotNaN; +use serde_derive::{Deserialize, Serialize}; use std::f64; use std::fmt; diff --git a/gtfs/src/lib.rs b/gtfs/src/lib.rs index 733a69fb57..c59083c20d 100644 --- a/gtfs/src/lib.rs +++ b/gtfs/src/lib.rs @@ -1,10 +1,8 @@ -#[macro_use] -extern crate serde_derive; - use abstutil::elapsed_seconds; use failure::Error; use geom::LonLat; use itertools::Itertools; +use serde_derive::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::fs::File; use std::time::Instant; diff --git a/kml/src/lib.rs b/kml/src/lib.rs index e6b07bf470..e4bed50673 100644 --- a/kml/src/lib.rs +++ b/kml/src/lib.rs @@ -1,16 +1,12 @@ -#[macro_use] -extern crate log; -#[macro_use] -extern crate serde_derive; -#[macro_use] -extern crate structopt; - use abstutil::{FileWithProgress, Timer}; use geom::{GPSBounds, LonLat}; +use log::info; use quick_xml::events::Event; use quick_xml::reader::Reader; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::io; +use structopt::StructOpt; #[derive(StructOpt)] #[structopt(name = "kml")] diff --git a/map_model/src/area.rs b/map_model/src/area.rs index d487763eb4..7ccff2e9f5 100644 --- a/map_model/src/area.rs +++ b/map_model/src/area.rs @@ -1,6 +1,7 @@ use crate::LANE_THICKNESS; use abstutil; use geom::{PolyLine, Polygon, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::fmt; diff --git a/map_model/src/building.rs b/map_model/src/building.rs index 40123242e3..272bccee7b 100644 --- a/map_model/src/building.rs +++ b/map_model/src/building.rs @@ -3,6 +3,7 @@ use crate::Position; use abstutil; use geom::{Line, PolyLine, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::fmt; diff --git a/map_model/src/bus_stop.rs b/map_model/src/bus_stop.rs index 0035df715e..1a368dc6c6 100644 --- a/map_model/src/bus_stop.rs +++ b/map_model/src/bus_stop.rs @@ -1,5 +1,6 @@ use crate::{LaneID, Position}; use abstutil; +use serde_derive::{Deserialize, Serialize}; use std::fmt; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] diff --git a/map_model/src/edits.rs b/map_model/src/edits.rs index 276f3a5eb4..1088f2553d 100644 --- a/map_model/src/edits.rs +++ b/map_model/src/edits.rs @@ -1,5 +1,6 @@ use crate::{ControlStopSign, ControlTrafficSignal, IntersectionID, Lane, LaneType, Road, RoadID}; use abstutil; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/map_model/src/intersection.rs b/map_model/src/intersection.rs index 3303fa1260..44a78fdd68 100644 --- a/map_model/src/intersection.rs +++ b/map_model/src/intersection.rs @@ -4,6 +4,7 @@ use crate::{LaneID, LaneType, Map, RoadID, TurnID}; use abstutil; use dimensioned::si; use geom::Pt2D; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeSet; use std::fmt; diff --git a/map_model/src/lane.rs b/map_model/src/lane.rs index b1a5364aa6..f48130a057 100644 --- a/map_model/src/lane.rs +++ b/map_model/src/lane.rs @@ -4,6 +4,7 @@ use crate::{BuildingID, BusStopID, IntersectionID, RoadID}; use abstutil; use dimensioned::si; use geom::{Angle, Line, PolyLine, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std; use std::f64; use std::fmt; diff --git a/map_model/src/lib.rs b/map_model/src/lib.rs index b2ddbd29ce..c6412b7f41 100644 --- a/map_model/src/lib.rs +++ b/map_model/src/lib.rs @@ -1,10 +1,3 @@ -#[macro_use] -extern crate log; -#[macro_use] -extern crate pretty_assertions; -#[macro_use] -extern crate serde_derive; - #[macro_use] mod macros; diff --git a/map_model/src/macros.rs b/map_model/src/macros.rs index 1952a0b586..86ba885532 100644 --- a/map_model/src/macros.rs +++ b/map_model/src/macros.rs @@ -4,7 +4,7 @@ macro_rules! debug { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "map", log::Level::Debug, $( $x, )* ); } } @@ -14,7 +14,7 @@ macro_rules! debug { macro_rules! info { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "map", log::Level::Info, $( $x, )* ); } } @@ -23,7 +23,7 @@ macro_rules! info { macro_rules! warn { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "map", log::Level::Warn, $( $x, )* ); } } @@ -32,7 +32,7 @@ macro_rules! warn { macro_rules! error { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "map", log::Level::Error, $( $x, )* ); } } diff --git a/map_model/src/make/lanes.rs b/map_model/src/make/lanes.rs index 1e6b19c9d2..98ea370bfe 100644 --- a/map_model/src/make/lanes.rs +++ b/map_model/src/make/lanes.rs @@ -1,4 +1,5 @@ use crate::{raw_data, LaneType, MapEdits, RoadID}; +use serde_derive::{Deserialize, Serialize}; use std::iter; // (original direction, reversed direction) diff --git a/map_model/src/map.rs b/map_model/src/map.rs index 5619ac209d..5a7e888818 100644 --- a/map_model/src/map.rs +++ b/map_model/src/map.rs @@ -9,6 +9,7 @@ use crate::{ use abstutil; use abstutil::{deserialize_btreemap, serialize_btreemap, Error, Timer}; use geom::{Bounds, GPSBounds, HashablePt2D, PolyLine, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::io; use std::path; diff --git a/map_model/src/parcel.rs b/map_model/src/parcel.rs index 36b4fd03b1..f37ad9ad6b 100644 --- a/map_model/src/parcel.rs +++ b/map_model/src/parcel.rs @@ -1,5 +1,6 @@ use abstutil; use geom::{PolyLine, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std::fmt; // TODO reconsider pub usize. maybe outside world shouldnt know. diff --git a/map_model/src/pathfind.rs b/map_model/src/pathfind.rs index 4efc82f820..7dea8257c7 100644 --- a/map_model/src/pathfind.rs +++ b/map_model/src/pathfind.rs @@ -2,6 +2,7 @@ use crate::{BusRouteID, BusStopID, LaneID, LaneType, Map, Position, Traversable, use dimensioned::si; use geom::{Line, PolyLine, Pt2D}; use ordered_float::NotNaN; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BinaryHeap, HashMap, VecDeque}; pub type Trace = PolyLine; diff --git a/map_model/src/raw_data.rs b/map_model/src/raw_data.rs index c7c5f9c319..a873d2754f 100644 --- a/map_model/src/raw_data.rs +++ b/map_model/src/raw_data.rs @@ -2,6 +2,7 @@ use crate::AreaType; use dimensioned::si; use geom::{GPSBounds, LonLat}; use gtfs::Route; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; #[derive(PartialEq, Debug, Serialize, Deserialize)] diff --git a/map_model/src/road.rs b/map_model/src/road.rs index d95b4b0666..6b63b897f5 100644 --- a/map_model/src/road.rs +++ b/map_model/src/road.rs @@ -2,6 +2,7 @@ use crate::{IntersectionID, LaneID, LaneType}; use abstutil::Error; use dimensioned::si; use geom::PolyLine; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashSet}; use std::fmt; diff --git a/map_model/src/stop_signs.rs b/map_model/src/stop_signs.rs index ec849a3539..7d079d3eb9 100644 --- a/map_model/src/stop_signs.rs +++ b/map_model/src/stop_signs.rs @@ -1,5 +1,6 @@ use crate::{IntersectionID, LaneID, Map, TurnID, TurnPriority, TurnType}; use abstutil::{deserialize_btreemap, serialize_btreemap, Error}; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet}; #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/map_model/src/traffic_signals.rs b/map_model/src/traffic_signals.rs index a05272c2d7..c061b6e46f 100644 --- a/map_model/src/traffic_signals.rs +++ b/map_model/src/traffic_signals.rs @@ -1,6 +1,7 @@ use crate::{IntersectionID, Map, RoadID, TurnID, TurnPriority, TurnType}; use abstutil::Error; use dimensioned::si; +use serde_derive::{Deserialize, Serialize}; use std; use std::collections::BTreeSet; diff --git a/map_model/src/traversable.rs b/map_model/src/traversable.rs index c805382ef2..81c952d3a7 100644 --- a/map_model/src/traversable.rs +++ b/map_model/src/traversable.rs @@ -1,6 +1,7 @@ use crate::{LaneID, Map, TurnID}; use dimensioned::si; use geom::{Angle, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] diff --git a/map_model/src/turn.rs b/map_model/src/turn.rs index 5683c423a0..d3856e52e5 100644 --- a/map_model/src/turn.rs +++ b/map_model/src/turn.rs @@ -2,6 +2,7 @@ use crate::{IntersectionID, LaneID}; use abstutil; use dimensioned::si; use geom::{Angle, Line, PolyLine, Pt2D}; +use serde_derive::{Deserialize, Serialize}; use std::f64; use std::fmt; diff --git a/sim/src/driving.rs b/sim/src/driving.rs index 663a0d4fd6..71bab4482d 100644 --- a/sim/src/driving.rs +++ b/sim/src/driving.rs @@ -20,6 +20,7 @@ use map_model::{ use multimap::MultiMap; use ordered_float::NotNaN; use rand::XorShiftRng; +use serde_derive::{Deserialize, Serialize}; use std; use std::collections::{BTreeMap, HashSet}; diff --git a/sim/src/instrument.rs b/sim/src/instrument.rs index 4fb67481d3..e75ebe3df8 100644 --- a/sim/src/instrument.rs +++ b/sim/src/instrument.rs @@ -1,5 +1,6 @@ use abstutil; use backtrace::Backtrace; +use lazy_static::lazy_static; use std::collections::HashSet; use std::sync::Mutex; diff --git a/sim/src/intersections.rs b/sim/src/intersections.rs index 6ba2269ea1..7cb54a4eba 100644 --- a/sim/src/intersections.rs +++ b/sim/src/intersections.rs @@ -7,6 +7,7 @@ use abstutil; use abstutil::{deserialize_btreemap, serialize_btreemap, Error}; use dimensioned::si; use map_model::{ControlStopSign, IntersectionID, IntersectionType, Map, TurnID, TurnPriority}; +use serde_derive::{Deserialize, Serialize}; use std; use std::collections::{BTreeMap, BTreeSet}; diff --git a/sim/src/kinematics.rs b/sim/src/kinematics.rs index 6ee37e0846..5bd5d1c9d1 100644 --- a/sim/src/kinematics.rs +++ b/sim/src/kinematics.rs @@ -2,7 +2,9 @@ use crate::{Acceleration, CarID, Distance, Speed, Time, TIMESTEP}; use abstutil::Error; use dimensioned::si; use geom::EPSILON_DIST; +use more_asserts::assert_ge; use rand::{Rng, XorShiftRng}; +use serde_derive::{Deserialize, Serialize}; use std; pub const EPSILON_SPEED: Speed = si::MeterPerSecond { diff --git a/sim/src/lib.rs b/sim/src/lib.rs index 51a4617c32..9e640fc0c8 100644 --- a/sim/src/lib.rs +++ b/sim/src/lib.rs @@ -1,21 +1,5 @@ // Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0 -#[macro_use] -extern crate derivative; -#[macro_use] -extern crate lazy_static; -// Order matters -- this must be before 'mod macros' -#[macro_use] -extern crate log; -#[macro_use] -extern crate more_asserts; -#[macro_use] -extern crate pretty_assertions; -#[macro_use] -extern crate serde_derive; -#[macro_use] -extern crate structopt; - #[macro_use] mod macros; @@ -54,6 +38,7 @@ pub use crate::render::{CarState, DrawCarInput, DrawPedestrianInput, GetDrawAgen pub use crate::sim::Sim; use abstutil::Cloneable; use map_model::{BuildingID, LaneID}; +use serde_derive::{Deserialize, Serialize}; use std::fmt; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] diff --git a/sim/src/macros.rs b/sim/src/macros.rs index 8fe079e399..35147a8ce7 100644 --- a/sim/src/macros.rs +++ b/sim/src/macros.rs @@ -3,7 +3,7 @@ macro_rules! debug { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "sim", log::Level::Debug, $( $x, )* ); } } @@ -12,7 +12,7 @@ macro_rules! debug { macro_rules! info { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "sim", log::Level::Info, $( $x, )* ); } } @@ -21,7 +21,7 @@ macro_rules! info { macro_rules! warn { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "sim", log::Level::Warn, $( $x, )* ); } } @@ -30,7 +30,7 @@ macro_rules! warn { macro_rules! error { ( $( $x:expr ),* ) => { { - extern crate log; + use log::log; log!(target: "sim", log::Level::Error, $( $x, )* ); } } diff --git a/sim/src/make/a_b_test.rs b/sim/src/make/a_b_test.rs index d56662edd3..c7e3b1be18 100644 --- a/sim/src/make/a_b_test.rs +++ b/sim/src/make/a_b_test.rs @@ -1,5 +1,6 @@ use crate::ScoreSummary; use abstutil; +use serde_derive::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ABTest { diff --git a/sim/src/make/load.rs b/sim/src/make/load.rs index 45ba473f07..ea2f5e0139 100644 --- a/sim/src/make/load.rs +++ b/sim/src/make/load.rs @@ -1,6 +1,7 @@ use crate::{Scenario, Sim, Tick}; use abstutil; use map_model::{Map, MapEdits}; +use structopt::StructOpt; #[derive(StructOpt, Debug, Clone)] #[structopt(name = "sim_flags")] diff --git a/sim/src/make/neighborhood.rs b/sim/src/make/neighborhood.rs index c798651467..74ed640905 100644 --- a/sim/src/make/neighborhood.rs +++ b/sim/src/make/neighborhood.rs @@ -1,6 +1,7 @@ use abstutil; use geom::{GPSBounds, LonLat, Polygon, Pt2D}; use map_model::{BuildingID, Map, RoadID}; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeSet; use std::fs::File; use std::io::{Error, Write}; diff --git a/sim/src/make/scenario.rs b/sim/src/make/scenario.rs index 2298e53e3d..658bf42d7a 100644 --- a/sim/src/make/scenario.rs +++ b/sim/src/make/scenario.rs @@ -5,6 +5,7 @@ use abstutil; use abstutil::WeightedUsizeChoice; use map_model::{BuildingID, IntersectionID, LaneType, Map, Pathfinder, RoadID}; use rand::{Rng, XorShiftRng}; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeSet, HashMap, HashSet}; #[derive(Clone, Serialize, Deserialize, Debug)] diff --git a/sim/src/parking.rs b/sim/src/parking.rs index 7613e0da99..984b1393d1 100644 --- a/sim/src/parking.rs +++ b/sim/src/parking.rs @@ -3,6 +3,7 @@ use crate::{CarID, CarState, Distance, DrawCarInput, ParkedCar, ParkingSpot, Veh use geom::{Angle, Pt2D}; use map_model; use map_model::{BuildingID, Lane, LaneID, LaneType, Map, Position, Traversable}; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashSet}; use std::iter; diff --git a/sim/src/physics.rs b/sim/src/physics.rs index c996c15ae4..470c411b25 100644 --- a/sim/src/physics.rs +++ b/sim/src/physics.rs @@ -1,6 +1,8 @@ use dimensioned::si; +use lazy_static::lazy_static; use rand::{Rng, XorShiftRng}; use regex::Regex; +use serde_derive::{Deserialize, Serialize}; pub const TIMESTEP: Time = si::Second { value_unsafe: 0.1, diff --git a/sim/src/query.rs b/sim/src/query.rs index 09a88208a0..ed611640f9 100644 --- a/sim/src/query.rs +++ b/sim/src/query.rs @@ -4,6 +4,7 @@ use crate::{Sim, Tick, TripID}; use dimensioned::si; use geom::Pt2D; use map_model::LaneID; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::collections::HashSet; use std::time::{Duration, Instant}; diff --git a/sim/src/router.rs b/sim/src/router.rs index dabdb650a0..ec83550612 100644 --- a/sim/src/router.rs +++ b/sim/src/router.rs @@ -10,6 +10,7 @@ use map_model::{ BuildingID, LaneID, LaneType, Map, Path, PathStep, Position, Trace, Traversable, TurnID, }; use rand::{Rng, XorShiftRng}; +use serde_derive::{Deserialize, Serialize}; #[derive(Clone, PartialEq, Serialize, Deserialize)] enum Goal { diff --git a/sim/src/scheduler.rs b/sim/src/scheduler.rs index 8e431f6f3d..5b6c77b915 100644 --- a/sim/src/scheduler.rs +++ b/sim/src/scheduler.rs @@ -5,6 +5,7 @@ use crate::trips::TripManager; use crate::walking::{CreatePedestrian, WalkingSimState}; use crate::{AgentID, Tick}; use map_model::Map; +use serde_derive::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, PartialEq)] pub enum Command { diff --git a/sim/src/sim.rs b/sim/src/sim.rs index a1899dc998..166ae686ca 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -15,8 +15,10 @@ use crate::{ }; use abstutil; use abstutil::Error; +use derivative::Derivative; use map_model::{BuildingID, IntersectionID, LaneID, LaneType, Map, Path, Trace, Turn}; use rand::{FromEntropy, SeedableRng, XorShiftRng}; +use serde_derive::{Deserialize, Serialize}; use std; #[derive(Serialize, Deserialize, Derivative)] diff --git a/sim/src/spawn.rs b/sim/src/spawn.rs index 8fdd6eb1d3..60c96f3c85 100644 --- a/sim/src/spawn.rs +++ b/sim/src/spawn.rs @@ -16,6 +16,7 @@ use map_model::{ Pathfinder, Position, RoadID, }; use rand::{Rng, XorShiftRng}; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] diff --git a/sim/src/transit.rs b/sim/src/transit.rs index 023d058c86..fb2c235047 100644 --- a/sim/src/transit.rs +++ b/sim/src/transit.rs @@ -8,6 +8,7 @@ use crate::{CarID, Distance, PedestrianID, Tick}; use abstutil::{deserialize_btreemap, serialize_btreemap}; use dimensioned::si; use map_model::{BusRoute, BusRouteID, BusStop, LaneID, Map, Path, PathRequest, Pathfinder}; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; // These index stops along a route, not stops along a single sidewalk. diff --git a/sim/src/trips.rs b/sim/src/trips.rs index a8b7c98c02..80ceb179fb 100644 --- a/sim/src/trips.rs +++ b/sim/src/trips.rs @@ -4,6 +4,7 @@ use crate::walking::SidewalkSpot; use crate::{AgentID, CarID, ParkedCar, PedestrianID, ScoreSummary, Tick, TripID}; use abstutil::{deserialize_btreemap, serialize_btreemap}; use map_model::{BusRouteID, BusStopID}; +use serde_derive::{Deserialize, Serialize}; use std::collections::{BTreeMap, VecDeque}; #[derive(Serialize, Deserialize, PartialEq, Debug)] diff --git a/sim/src/walking.rs b/sim/src/walking.rs index e2be6884d1..0dfbf07b01 100644 --- a/sim/src/walking.rs +++ b/sim/src/walking.rs @@ -9,6 +9,7 @@ use crate::{ }; use abstutil; use abstutil::{deserialize_multimap, serialize_multimap, Error}; +use derivative::Derivative; use dimensioned::si; use geom::{Line, Pt2D}; use map_model::{ @@ -16,6 +17,7 @@ use map_model::{ Traversable, TurnID, }; use multimap::MultiMap; +use serde_derive::{Deserialize, Serialize}; use std; use std::collections::{BTreeMap, HashSet}; diff --git a/synthetic/src/main.rs b/synthetic/src/main.rs index 73903aadaf..04968781cc 100644 --- a/synthetic/src/main.rs +++ b/synthetic/src/main.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate serde_derive; - mod model; use crate::model::{BuildingID, Direction, IntersectionID, Model, RoadID}; diff --git a/synthetic/src/model.rs b/synthetic/src/model.rs index 34c41c5485..baba967207 100644 --- a/synthetic/src/model.rs +++ b/synthetic/src/model.rs @@ -3,6 +3,7 @@ use dimensioned::si; use ezgui::{Canvas, Color, GfxCtx, Text}; use geom::{Circle, LonLat, PolyLine, Polygon, Pt2D}; use map_model::{raw_data, LaneType, RoadSpec, LANE_THICKNESS}; +use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::mem; diff --git a/tmp_gfx/src/main.rs b/tmp_gfx/src/main.rs index 27216260e9..74e5bfccfe 100644 --- a/tmp_gfx/src/main.rs +++ b/tmp_gfx/src/main.rs @@ -1,3 +1,4 @@ +// Can't figure out what macros to import using the 2018 use style. #[macro_use] extern crate gfx;