You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 21, 2024. It is now read-only.
error[E0308]: mismatched types
--> src/crates.rs:42:1
|
42 | #[command]
| ^^^^^^^^^^
| |
| expected `()`, found struct `Data`
| expected `serenity_framework::command::Command` because of return type
|
= note: expected struct `serenity_framework::command::Command<()>`
found struct `serenity_framework::command::Command<Data>`
I think the reason for this failure is that #[command] attempts to deduce the user data type by parsing generic parameters of the ctx function argument. Because of the type alias, it can't find any generic parameters and falsely thinks this function uses the default user data (()).
If this suspicion is correct, the issue can be worked around something like this:
The command_attr crate then uses <ARGUMENTTYPE as _ContextTypes>::D and <ARGUMENTTYPE as _ContextTypes>::E instead of trying to deduce the generic parameters from ARGUMENTTYPE.
The text was updated successfully, but these errors were encountered:
I have successfully fixed this in my local framework fork. It's based upon #25 so I haven't created a PR yet (that would be a little messy, a PR blocked on a draft PR blocked on a PR in a different repository). Just thought I'd mention to prevent duplicate efforts
kangalio
added a commit
to kangalio/framework
that referenced
this issue
Feb 23, 2021
Code like this can be successfully processed by the
#[command]
proc-macro:However, code like this fails:
Error:
I think the reason for this failure is that
#[command]
attempts to deduce the user data type by parsing generic parameters of thectx
function argument. Because of the type alias, it can't find any generic parameters and falsely thinks this function uses the default user data (()
).If this suspicion is correct, the issue can be worked around something like this:
The
command_attr
crate then uses<ARGUMENTTYPE as _ContextTypes>::D
and<ARGUMENTTYPE as _ContextTypes>::E
instead of trying to deduce the generic parameters fromARGUMENTTYPE
.The text was updated successfully, but these errors were encountered: