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

Failed to compile teloxide v0.3.3 with serde v1.0.119 #328

Closed
Nouzan opened this issue Jan 12, 2021 · 3 comments
Closed

Failed to compile teloxide v0.3.3 with serde v1.0.119 #328

Nouzan opened this issue Jan 12, 2021 · 3 comments
Assignees
Labels
K-bug Kind: bug

Comments

@Nouzan
Copy link

Nouzan commented Jan 12, 2021

When I tried to compile my bot (with the latest serde version v1.0.119), the compiler gave me this error:

error[E0603]: module `export` is private
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/teloxide-0.3.3/src/types/non_telegram_types/mime_wrapper.rs:3:26
    |
3   | use serde::{de::Visitor, export::Formatter, Deserialize, Deserializer, Serialize, Serializer};
    |                          ^^^^^^ private module
    |
note: the module `export` is defined here
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.119/src/lib.rs:275:5
    |
275 | use self::__private as export;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0603]: module `export` is private
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/teloxide-0.3.3/src/utils/command.rs:47:12
    |
47  | use serde::export::Formatter;
    |            ^^^^^^ private module
    |
note: the module `export` is defined here
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.119/src/lib.rs:275:5
    |
275 | use self::__private as export;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0603]: module `export` is private
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/teloxide-0.3.3/src/types/non_telegram_types/mime_wrapper.rs:22:77
    |
22  |     fn expecting(&self, formatter: &mut Formatter<'_>) -> Result<(), serde::export::fmt::Error> {
    |                                                                             ^^^^^^ private module
    |
note: the module `export` is defined here
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.119/src/lib.rs:275:5
    |
275 | use self::__private as export;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0603`.
error: could not compile `teloxide`.

But after I changed the dependency to the following (which fixed serde's version to v1.0.118):

serde = { version="=1.0.118", features = ["derive"] }

the compilation succeeded.

Meta

  • teloxide version: 0.3.3
  • rustc version:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0
@Nouzan Nouzan added the K-bug Kind: bug label Jan 12, 2021
@WaffleLapkin
Copy link
Member

The problem is in this teloxide file:

use serde::{de::Visitor, export::Formatter, Deserialize, Deserializer, Serialize, Serializer};
/// Serializable & deserializable `MIME` wrapper.
#[derive(Clone, Debug, Eq, Hash, PartialEq, From)]
pub struct MimeWrapper(pub Mime);
impl Serialize for MimeWrapper {
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where
S: Serializer,
{
serializer.serialize_str(self.0.as_ref())
}
}
struct MimeVisitor;
impl<'a> Visitor<'a> for MimeVisitor {
type Value = MimeWrapper;
fn expecting(&self, formatter: &mut Formatter<'_>) -> Result<(), serde::export::fmt::Error> {

It uses serde::export instead of std:: path which is totally wrong. The latest serde version (1.0.119) have renamed the module, so it's more obvious that it shouldn't be used (serde-rs/serde@dd1f4b4).

@WaffleLapkin
Copy link
Member

The problem is already fixed in teloxide-core, but we may want to release a patch to teloxide 0.3 anyway, cc @Hirrolot

@WaffleLapkin
Copy link
Member

Was fixed in #331, the fix is published in 0.3.4 version of the teloxide crate.

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

Successfully merging a pull request may close this issue.

3 participants