serde
serde copied to clipboard
Improve error reporting about mismatched signature in `with` and `default` attributes
This PR changes the errors reported by rustc when signature of function specified in
#[serde(with = "...")]#[serde(deserialize_with = "...")]#[serde(serialize_with = "...")]#[serde(default = "...")]
is wrong. With this PR error will point to the "...".
Strange, but order of implementations shown in failed run is different from my (my removed, GitHub runner added):
= help: the following other types implement trait `Serializer`:
- FlatMapSerializer<'a, M>
- &'a mut Formatter<'b>
_::_serde::__private::ser::content::ContentSerializer<E>
+ FlatMapSerializer<'a, M>
+ &'a mut Formatter<'b>
This can create difficulties in local testing.
Probably the order of suggested implementations is heavy dependent on rustc version. With rustc 1.82.0-nightly (fbccf5053 2024-07-27) the local output is the same as at GitHub.
@oli-obk looks like the merge of this PR broke master CI. The CI on this PR was green some time ago, and it broke with time
The failing ui test was from a non-textual conflict with https://github.com/serde-rs/serde/commit/8e1ae68569db46251a88997e5e212392d4ad83ea. Fixed in #2839. (Also #2840).
It is unfortunate that:
= help: the following other types implement trait `Serializer`:
&mut Formatter<'a>
FlatMapSerializer<'a, M>
_::_serde::__private::ser::content::ContentSerializer<E>
is the set of impls chosen to be suggested by rustc. Is there something we can do with doc(hidden) to exclude nonpublic APIs from this error message? If not, this needs to be reported as a rustc bug.
Reported https://github.com/rust-lang/rust/issues/132024.
is the set of impls chosen to be suggested by rustc. Is there something we can do with
doc(hidden)to exclude nonpublic APIs from this error message? If not, this needs to be reported as a rustc bug.
We'll get diagnostics::do_not_suggest or sth. Iirc it's being worked on or works on nightly already
it looks like this change might have unintended side effects. https://github.com/rust-lang/crates.io/pull/9720 upgrades crates.io from v1.0.210 to v1.0.211 and we are now seeing various "not found in this scope" errors that were not there before.