Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix promotion example #2

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jan 8, 2024

getting the following error after 2:30min was a bit scary 😅

error[E0277]: the trait bound `<<<<<<<<state::State<White, board::Board<board::BoardRank<Filled<piece::ColoredPiece<Rook, White>>, Filled<piece::ColoredPiece<Knight, White>>, Filled<piece::ColoredPiece<Bishop, White>>, Filled<piece::ColoredPiece<piece::Queen, White>>, Filled<piece::ColoredPiece<King, White>>, Filled<piece::ColoredPiece<Bishop, White>>, Filled<piece::ColoredPiece<Knight, White>>, Filled<piece::ColoredPiece<Rook, White>>>, board::BoardRank<Filled<piece::ColoredPiece<Pawn, White>>, Filled<piece::ColoredPiece<Pawn, White>>, Filled<piece::ColoredPiece<Pawn, White>>, Filled<piece::ColoredPiece<Pawn, White>>, Filled<piece::ColoredPiece<Pawn, White>>, Filled<piece::ColoredPiece<Pawn, White>>, Filled<piece::ColoredPiece<Pawn, White>>, Filled<piece::ColoredPiece<Pawn, White>>>, board::BoardRank<board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty>, board::BoardRank<board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty>, board::BoardRank<board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty>, board::BoardRank<board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty, board::Empty>, board::BoardRank<Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Pawn, Black>>>, board::BoardRank<Filled<piece::ColoredPiece<Pawn, Black>>, Filled<piece::ColoredPiece<Knight, Black>>, Filled<piece::ColoredPiece<Bishop, Black>>, Filled<piece::ColoredPiece<piece::Queen, Black>>, Filled<piece::ColoredPiece<King, Black>>, Filled<piece::ColoredPiece<Bishop, Black>>, Filled<piece::ColoredPiece<Knight, Black>>, Filled<piece::ColoredPiece<Rook, Black>>>>, NoSquare, state::CastleState<True, True, True, True>> as RunMakeEM<square::Square<square::rank::R2, FF>, square::Square<square::rank::R4, FF>, NoPiece>>::Output as RunMakeEM<square::Square<square::rank::R7, FA>, square::Square<square::rank::R6, FA>, NoPiece>>::Output as RunMakeEM<square::Square<square::rank::R4, FF>, square::Square<square::rank::R5, FF>, NoPiece>>::Output as RunMakeEM<square::Square<square::rank::R6, FA>, square::Square<square::rank::R5, FA>, NoPiece>>::Output as RunMakeEM<square::Square<square::rank::R5, FF>, square::Square<square::rank::R6, FF>, NoPiece>>::Output as RunMakeEM<square::Square<square::rank::R5, FA>, square::Square<square::rank::R6, FA>, NoPiece>>::Output as RunMakeEM<square::Square<square::rank::R6, FF>, square::Square<square::rank::R7, FF>, NoPiece>>::Output as RunMakeEM<square::Square<square::rank::R4, FA>, square::Square<square::rank::R3, FA>, NoPiece>>::Output: RunMakeEM<square::Square<square::rank::R7, FG>, square::Square<square::rank::R8, FH>, piece::Queen>` is not satisfied
  --> src/main.rs:37:20
   |
37 |     println!("{}", S10::reify());
   |                    ^^^ the trait `RunMakeEM<square::Square<square::rank::R7, FG>, square::Square<square::rank::R8, FH>, piece::Queen>` is not implemented for `<<<<... as RunMakeEM<..., ..., ...>>::Output as RunMakeEM<..., ..., ...>>::Output as RunMakeEM<..., ..., ...>>::Output as RunMakeEM<..., ..., ...>>::Output`

with that change and rust-lang/rust#119735 cargo +rust1 rustc -- -Znext-solver compiles successfully in 4m26,600s after changing the recursion limit to 1024. Unsure what exactly is responsible for the higher recursion limit requirement, but tbh, I don't care too much about that.

RUSTFLAGS=-Znext-solver time cargo +rust1 test takes nearly 13 minutes, can probably trivially speed this up by deduplicating obligations in the new solver as well 🤷

@Dragon-Hatcher Dragon-Hatcher merged commit 296e96d into Dragon-Hatcher:main Jan 8, 2024
@lcnr lcnr deleted the patch-1 branch January 8, 2024 15:38
@Dragon-Hatcher
Copy link
Owner

What is the difference between those two commands?

@lcnr
Copy link
Contributor Author

lcnr commented Jan 8, 2024

by adding -Znext-solver as a command line flag to rustc, either by using cargo rustc -- -Znext-solver or RUSTFLAGS=-Znext-solver <whatever>, you compile your code using the next generation trait solver for Rust: rust-lang/rust#107374.

cargo rustc is similar to cargo build, except that you can pass arguments to the compiler, rustc, after --.

The +rust1 is to change cargo to use my local toolchain instead of the default. You can also do cargo +nightly build or sth like this.

So cargo +rust1 rustc -- -Znext-solver builds your crate (in this case with the promotion example uncommented) using my local toolchain which includes the changes in rust-lang/rust#119735 and using the next gen trait solver. It does not run tests.

For RUSTFLAGS=-Znext-solver time cargo +rust1 test I changed main.rs to the smaller example again and ran all tests this time, using the time command to get accurate timings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants