Fix static trait object method warning that we're now hitting in Rust 1.52

The <dyn ...> syntax is gross, but I don't think there's a way to avoid
this without defining a differently named empty struct and putting the
static method on that
This commit is contained in:
Dustin Carlino 2021-05-11 12:31:58 -07:00
parent 4192f74050
commit 2c5e0dae03
15 changed files with 28 additions and 25 deletions

View File

@ -44,7 +44,7 @@ impl FindHome {
]))
.build(ctx);
SimpleState::new(panel, Box::new(FindHome { options }))
<dyn SimpleState<_>>::new(panel, Box::new(FindHome { options }))
}
}
@ -169,7 +169,7 @@ impl Results {
.aligned(HorizontalAlignment::RightInset, VerticalAlignment::TopInset)
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(Results {
draw_houses: ctx.upload(batch),

View File

@ -46,7 +46,7 @@ impl UberTurnPicker {
]))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(panel, Box::new(UberTurnPicker { members }))
<dyn SimpleState<_>>::new(panel, Box::new(UberTurnPicker { members }))
}
}
@ -174,7 +174,7 @@ impl UberTurnViewer {
]))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(UberTurnViewer {
draw: ctx.upload(batch),

View File

@ -115,7 +115,7 @@ impl LaneEditor {
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(panel, Box::new(LaneEditor { l, mode }))
<dyn SimpleState<_>>::new(panel, Box::new(LaneEditor { l, mode }))
}
}

View File

@ -78,7 +78,7 @@ impl StopSignEditor {
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(StopSignEditor {
id,

View File

@ -98,7 +98,7 @@ impl ChangeDuration {
.build_def(ctx),
]))
.build(ctx);
SimpleState::new(panel, Box::new(ChangeDuration { idx }))
<dyn SimpleState<_>>::new(panel, Box::new(ChangeDuration { idx }))
}
}

View File

@ -53,7 +53,7 @@ impl ShowAbsolute {
]))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(ShowAbsolute {
members,
@ -142,7 +142,7 @@ impl ShowRelative {
]))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(ShowRelative {
base,
@ -264,7 +264,7 @@ impl TuneRelative {
.build_def(ctx),
]))
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(TuneRelative {
i1,

View File

@ -29,7 +29,7 @@ impl Layer for SteepStreets {
}
}
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, app: &App) {
self.panel.draw(g);
@ -177,7 +177,7 @@ impl Layer for ElevationContours {
}
}
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, app: &App) {
self.panel.draw(g);

View File

@ -61,7 +61,7 @@ impl Layer for ShowFavorites {
Some("favorites")
}
fn event(&mut self, ctx: &mut EventCtx, _: &mut App) -> Option<LayerOutcome> {
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, _: &App) {
self.panel.draw(g);

View File

@ -50,7 +50,7 @@ impl Layer for BikeActivity {
self.tooltip = None;
}
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, app: &App) {
self.panel.draw(g);
@ -180,7 +180,7 @@ impl Layer for Static {
Some(self.name)
}
fn event(&mut self, ctx: &mut EventCtx, _: &mut App) -> Option<LayerOutcome> {
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, app: &App) {
self.panel.draw(g);
@ -386,7 +386,7 @@ impl Layer for CongestionCaps {
self.tooltip = None;
}
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, app: &App) {
self.panel.draw(g);

View File

@ -33,7 +33,7 @@ impl Layer for Backpressure {
*self = Backpressure::new(ctx, app);
}
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, app: &App) {
self.panel.draw(g);
@ -434,7 +434,7 @@ impl Layer for TrafficJams {
*self = TrafficJams::new(ctx, app);
}
Layer::simple_event(ctx, &mut self.panel)
<dyn Layer>::simple_event(ctx, &mut self.panel)
}
fn draw(&self, g: &mut GfxCtx, app: &App) {
self.panel.draw(g);

View File

@ -136,7 +136,10 @@ impl GameplayState for Actdev {
ctx.style().btn_outline.text("abstreet.org").build_def(ctx),
]))
.build(ctx);
Some(Transition::Push(SimpleState::new(panel, Box::new(About))))
Some(Transition::Push(<dyn SimpleState<_>>::new(
panel,
Box::new(About),
)))
}
"Follow someone" => {
if let Some((person, trip)) = find_active_trip(app) {

View File

@ -278,7 +278,7 @@ impl ChangeScenario {
.build_def(ctx),
);
SimpleState::new(
<dyn SimpleState<_>>::new(
Panel::new(Widget::col(col)).build(ctx),
Box::new(ChangeScenario),
)

View File

@ -118,7 +118,7 @@ impl EditRoad {
let panel = Panel::new(Widget::col(col))
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(EditRoad {
r,

View File

@ -113,7 +113,7 @@ impl Strategize {
]))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Top)
.build(ctx);
SimpleState::new(
<dyn SimpleState<_>>::new(
panel,
Box::new(Strategize {
unlock_messages,
@ -194,7 +194,7 @@ impl Results {
}
}
SimpleState::new(
<dyn SimpleState<_>>::new(
Panel::new(Widget::col(vec![
txt.into_widget(ctx),
ctx.style()

View File

@ -21,7 +21,7 @@ impl TitleScreen {
}
}
SimpleState::new(
<dyn SimpleState<_>>::new(
Panel::new(Widget::col(vec![
Line("15-minute Santa")
.display_title()
@ -154,7 +154,7 @@ struct Credits;
impl Credits {
fn new(ctx: &mut EventCtx) -> Box<dyn State<App>> {
SimpleState::new(
<dyn SimpleState<_>>::new(
Panel::new(Widget::col(vec![
Widget::row(vec![
Line("15-minute Santa").big_heading_plain().into_widget(ctx),