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

Use trait object for progress in PrepareFetch::fetch_only #1014

Merged
merged 6 commits into from
Sep 9, 2023

Conversation

NobodyXu
Copy link
Contributor

@NobodyXu NobodyXu commented Sep 9, 2023

No description provided.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@NobodyXu
Copy link
Contributor Author

NobodyXu commented Sep 9, 2023

It turns out that using DynNestedProgress as a trait object and then use DynNestedProgressToNestedProgress doesn't work:

error[E0277]: the trait bound `dyn gix_features::progress::DynNestedProgress: gix_features::progress::Nest
edProgress` is not satisfied
   --> gix/src/clone/fetch/mod.rs:146:14
    |
146 |             .receive(DynNestedProgressToNestedProgress(progress), should_interrupt)
    |              ^^^^^^^ the trait `gix_features::progress::NestedProgress` is not implemented for `dyn 
gix_features::progress::DynNestedProgress`
    |
    = help: the following other types implement trait `gix_features::progress::NestedProgress`:              gix_features::progress::prodash::tree::Item
              gix_features::progress::Discard
              gix_features::progress::Either<L, R>
              gix_features::progress::DoOrDiscard<T>
              gix_features::progress::ThroughputOnDrop<T>
              gix_features::progress::BoxedDynNestedProgress
              gix_features::progress::DynNestedProgressToNestedProgress<T>
              &'a mut T
    = note: required for `&mut dyn gix_features::progress::DynNestedProgress` to implement `gix_features::
progress::NestedProgress`
    = note: required for `&mut dyn gix_features::progress::DynNestedProgress` to implement `gix_features::
progress::DynNestedProgress`
    = note: 1 redundant requirement hidden
    = note: required for `DynNestedProgressToNestedProgress<&mut dyn DynNestedProgress>` to implement `gix
_features::progress::NestedProgress`
    = note: the full type name has been written to '/Users/nobodyxu/Dev/gitoxide/target/debug/deps/gix-c1b
f5d15fa5fd661.long-type-8934911478669783998.txt'

For more information about this error, try `rustc --explain E0277`.
error: could not compile `gix` (lib) due to previous error

Content of /Users/nobodyxu/Dev/gitoxide/target/debug/deps/gix-c1b f5d15fa5fd661.long-type-8934911478669783998.txt:

gix_features::progress::DynNestedProgressToNestedProgress<&mut dyn gix_features::progress::DynNestedProgress>

@NobodyXu
Copy link
Contributor Author

NobodyXu commented Sep 9, 2023

I've already opened Byron/prodash#24 for fixing use of Progress and Count as trait object, but I still haven't figured out how to fix DynNestedProgressToProgress.

@Byron
Copy link
Member

Byron commented Sep 9, 2023

Is DynNestedProgressToProgress actually needed anywhere? I thought that in all places, one should be able to use &mut dyn DynNestedProgress. Maybe that can be an avenue towards solving the issue, by avoidance. Disclaimer: I do definitely speak out of ignorance here.

@NobodyXu
Copy link
Contributor Author

NobodyXu commented Sep 9, 2023

It's used in gix::remote::fetch::Prepare::receive since it expects NestedProgress.

I can actually workaround this issue by creating a receive_inner that takes DynNestedProgress instead.

…ceive`

and expose a new `pub(crate)` fn `receive_inner`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@NobodyXu NobodyXu marked this pull request as ready for review September 9, 2023 10:10
Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to hear that this wasn't a blocker! Thanks again for the initiative!

@@ -292,6 +292,9 @@ members = [
"gix-traverse/tests",
]

[workspace.dependencies]
prodash = { version = "26.2.2", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice! Thanks for introducing this feature!

@Byron Byron merged commit 1f2ffb6 into GitoxideLabs:main Sep 9, 2023
18 checks passed
@NobodyXu NobodyXu deleted the optimize/progress-use branch September 9, 2023 22:13
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