Cargo publish vs cargo check/build/test

I can not understand how cargo publish run rustc. It gives me compile time error during validation,
but I can not see them when I run cargo build --all.

cargo publish gives me this:

error[E0046]: not all trait items implemented, missing: `collect_str`
   --> src/ser/map.rs:16:1
    |
16  | / impl<'a, 'b> ser::Serializer for &'a mut MapKeySerializer<'b>
17  | | where
18  | |     'b: 'a,
19  | | {
...   |
190 | |     }
191 | | }
    | |_^ missing `collect_str` in implementation
    |
    = help: implement the missing item: `fn collect_str<T>(self, _: &T) -> Result<<Self as serde::Serializer>::Ok, <Self as serde::Serializer>::Error> where T: std::fmt::Display { todo!() }`

Serializer implementation for MapKeySerializer (indeed) have no implementation for collect_str, but this method has default implementation in trait:

So how can I emulate what does cargo publish with cargo build?

I found --future-incompat-report option, but cargo build --all --future-incompat-report reports nothing.

Is your crate part of a cargo workspace? If so try adding resolver = 2 to the [workspace] section in the workspace Cargo.toml and build using cargo build -p crate_name. Otherwise features enabled by one crate in the workspace may leak into others.

1 Like

Thanks this is it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.