-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #88467 - sexxi-goose:issue-88431, r=nikomatsakis
2229: Drop any deref in move closure Fixes: #88431 r? `@nikomatsakis`
- Loading branch information
Showing
6 changed files
with
77 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/ui/closures/2229_closure_analysis/run_pass/issue-88431.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// edition:2021 | ||
// check-pass | ||
|
||
use std::collections::HashMap; | ||
use std::future::Future; | ||
use std::pin::Pin; | ||
|
||
pub struct GameMode {} | ||
|
||
struct GameStateManager<'a> { | ||
gamestate_stack: Vec<Box<dyn GameState<'a> + 'a>>, | ||
} | ||
|
||
pub trait GameState<'a> {} | ||
|
||
async fn construct_gamestate_replay<'a>( | ||
_gamemode: &GameMode, | ||
_factory: &mut GameStateManager<'a>, | ||
) -> Box<dyn GameState<'a> + 'a> { | ||
unimplemented!() | ||
} | ||
|
||
type FutureGameState<'a, 'b> = Pin<Box<dyn Future<Output = Box<dyn GameState<'a> + 'a>> + 'b>>; | ||
|
||
struct MenuOption<'a> { | ||
command: Box<dyn for<'b> Fn(&'b mut GameStateManager<'a>) -> FutureGameState<'a, 'b> + 'a>, | ||
} | ||
|
||
impl<'a> MenuOption<'a> { | ||
fn new( | ||
_command: impl for<'b> Fn(&'b mut GameStateManager<'a>) -> FutureGameState<'a, 'b> + 'a, | ||
) -> Self { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
struct MenuState<'a> { | ||
options: Vec<MenuOption<'a>>, | ||
} | ||
|
||
impl<'a> GameState<'a> for MenuState<'a> {} | ||
|
||
pub async fn get_replay_menu<'a>( | ||
gamemodes: &'a HashMap<&str, GameMode>, | ||
) -> Box<dyn GameState<'a> + 'a> { | ||
let recordings: Vec<String> = vec![]; | ||
let _ = recordings | ||
.into_iter() | ||
.map(|entry| { | ||
MenuOption::new(move |f| { | ||
Box::pin(construct_gamestate_replay(&gamemodes[entry.as_str()], f)) | ||
}) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
todo!() | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters