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

WIP fixing breaking change on poise (serenity-next branch) #340

Open
wants to merge 1 commit into
base: serenity-next
Choose a base branch
from

Conversation

FabseGP
Copy link

@FabseGP FabseGP commented Mar 2, 2025

Fixed accessing the ShardManager runners, but... don't know how to tackle

error[E0507]: cannot move out of `client.shard_manager` which is behind a shared reference
  --> src/framework/mod.rs:97:44
   |
97 |         self.shard_manager = Some(Arc::new(client.shard_manager));
   |                                            ^^^^^^^^^^^^^^^^^^^^ move occurs because `client.shard_manager` has type `serenity::gateway::ShardManager`, which does not implement the `Copy` trait

Serenity doesn't store shard_manager as an Arc, nor do shard_manager implement Copy or Clone (got changed in Serenity next-branch)

@FabseGP FabseGP changed the title Fix: Use correct method to access ShardManager runners WIP fixing breaking change on poise (serenity-next branch) Mar 2, 2025
@simxnet
Copy link

simxnet commented Mar 2, 2025

You cannot Arc shard manager as it doesn't implement Copy

@FabseGP
Copy link
Author

FabseGP commented Mar 2, 2025

You cannot Arc shard manager as it doesn't implement Copy

That makes sense, but...

    /// Initialized to Some during construction; so shouldn't be None at any observable point
    shard_manager: Option<Arc<serenity::ShardManager>>,

the framework expects an Arc for shard_manager. I did try and remove the Arc line by line, but I ended with a breakage in src/dispatch/mod.rs:

error[E0308]: mismatched types
  --> src/dispatch/mod.rs:58:9
   |
57 |     pub fn shard_manager(&self) -> serenity::ShardManager {
   |                                    ---------------------- expected `serenity::gateway::ShardManager` because of return type
58 |         self.shard_manager.clone()
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ShardManager`, found `&ShardManager`
   |
note: `serenity::gateway::ShardManager` does not implement `Clone`, so `&serenity::gateway::ShardManager` was cloned instead
  --> src/dispatch/mod.rs:58:9
   |
58 |         self.shard_manager.clone()
   |         ^^^^^^^^^^^^^^^^^^

(used to return Arc<serenity::ShardManager>)

More or less I'm stuck xD

@FabseGP
Copy link
Author

FabseGP commented Mar 2, 2025

currently I'm at adding a Mutex to shard_manager in Serenity (fork) and then passing Arc<Mutex> around, but that requires changing more than I like in Poise's framework

(as to why not just change it back to Arc, shard_manager now have methods that require interior mutability)

@cheesycod
Copy link

currently I'm at adding a Mutex to shard_manager in Serenity (fork) and then passing Arc around, but that requires changing more than I like in Poise's framework

(as to why not just change it back to Arc, shard_manager now have methods that require interior mutability)

Checked your fork. The mutex looks highly suspicious though and might cause deadlocks if code ever tries to lock the shard manager after starting the bot?

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.

3 participants