remove more extern crate's; import macros directly

This commit is contained in:
Dustin Carlino 2018-12-06 11:05:11 -08:00
parent 375a923a9d
commit 91b2b07fbd
65 changed files with 76 additions and 79 deletions

View File

@ -1,8 +1,3 @@
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate serde_derive;
mod clone;
mod collections;
mod error;

View File

@ -1,3 +1,4 @@
use lazy_static::lazy_static;
use std::sync::Mutex;
lazy_static! {

View File

@ -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.

View File

@ -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;

View File

@ -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

View File

@ -1,5 +1,6 @@
use abstutil;
use ezgui::Color;
use serde_derive::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashMap};
use std::io::Error;

View File

@ -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, )* );
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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};

View File

@ -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;

View File

@ -1,4 +1,5 @@
use palette;
use serde_derive::{Deserialize, Serialize};
use std::fmt;
// Copy could be reconsidered, but eh

View File

@ -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;

View File

@ -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 {

View File

@ -1,3 +1,4 @@
use serde_derive::{Deserialize, Serialize};
use std;
use std::f64;
use std::fmt;

View File

@ -1,4 +1,5 @@
use crate::{Bounds, Pt2D};
use serde_derive::{Deserialize, Serialize};
use std::fmt;
#[derive(Serialize, Deserialize, Debug)]

View File

@ -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;

View File

@ -1,6 +1,3 @@
#[macro_use]
extern crate serde_derive;
mod angle;
mod circle;
mod gps;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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")]

View File

@ -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;

View File

@ -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;

View File

@ -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)]

View File

@ -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)]

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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, )* );
}
}

View File

@ -1,4 +1,5 @@
use crate::{raw_data, LaneType, MapEdits, RoadID};
use serde_derive::{Deserialize, Serialize};
use std::iter;
// (original direction, reversed direction)

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -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)]

View File

@ -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;

View File

@ -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)]

View File

@ -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;

View File

@ -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)]

View File

@ -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;

View File

@ -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};

View File

@ -1,5 +1,6 @@
use abstutil;
use backtrace::Backtrace;
use lazy_static::lazy_static;
use std::collections::HashSet;
use std::sync::Mutex;

View File

@ -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};

View File

@ -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 {

View File

@ -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)]

View File

@ -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, )* );
}
}

View File

@ -1,5 +1,6 @@
use crate::ScoreSummary;
use abstutil;
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ABTest {

View File

@ -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")]

View File

@ -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};

View File

@ -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)]

View File

@ -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;

View File

@ -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,

View File

@ -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};

View File

@ -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 {

View File

@ -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 {

View File

@ -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)]

View File

@ -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)]

View File

@ -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.

View File

@ -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)]

View File

@ -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};

View File

@ -1,6 +1,3 @@
#[macro_use]
extern crate serde_derive;
mod model;
use crate::model::{BuildingID, Direction, IntersectionID, Model, RoadID};

View File

@ -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;

View File

@ -1,3 +1,4 @@
// Can't figure out what macros to import using the 2018 use style.
#[macro_use]
extern crate gfx;