mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-17 23:11:02 +00:00
Merge pull request #2767 from weiznich/feature/diagnostic_on_unimplemented
Use the `#[diagnostic::on_unimplemented]` attribute when possible
This commit is contained in:
@@ -25,6 +25,7 @@ fn main() {
|
|||||||
println!("cargo:rustc-check-cfg=cfg(no_std_atomic64)");
|
println!("cargo:rustc-check-cfg=cfg(no_std_atomic64)");
|
||||||
println!("cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)");
|
println!("cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)");
|
||||||
println!("cargo:rustc-check-cfg=cfg(no_target_has_atomic)");
|
println!("cargo:rustc-check-cfg=cfg(no_target_has_atomic)");
|
||||||
|
println!("cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)");
|
||||||
}
|
}
|
||||||
|
|
||||||
let target = env::var("TARGET").unwrap();
|
let target = env::var("TARGET").unwrap();
|
||||||
@@ -84,6 +85,12 @@ fn main() {
|
|||||||
if minor < 74 {
|
if minor < 74 {
|
||||||
println!("cargo:rustc-cfg=no_core_num_saturating");
|
println!("cargo:rustc-cfg=no_core_num_saturating");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support for the `#[diagnostic]` tool attribute namespace
|
||||||
|
// https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#diagnostic-attributes
|
||||||
|
if minor < 78 {
|
||||||
|
println!("cargo:rustc-cfg=no_diagnostic_namespace");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rustc_minor_version() -> Option<u32> {
|
fn rustc_minor_version() -> Option<u32> {
|
||||||
|
|||||||
@@ -532,6 +532,13 @@ impl<'a> Display for Expected + 'a {
|
|||||||
/// deserializer lifetimes] for a more detailed explanation of these lifetimes.
|
/// deserializer lifetimes] for a more detailed explanation of these lifetimes.
|
||||||
///
|
///
|
||||||
/// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html
|
/// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html
|
||||||
|
#[cfg_attr(
|
||||||
|
not(no_diagnostic_namespace),
|
||||||
|
diagnostic::on_unimplemented(
|
||||||
|
note = "for local types consider adding `#[derive(serde::Deserialize)]` to your `{Self}` type",
|
||||||
|
note = "for types from other crates check whether the crate offers a `serde` feature flag",
|
||||||
|
)
|
||||||
|
)]
|
||||||
pub trait Deserialize<'de>: Sized {
|
pub trait Deserialize<'de>: Sized {
|
||||||
/// Deserialize this value from the given Serde deserializer.
|
/// Deserialize this value from the given Serde deserializer.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -215,6 +215,13 @@ declare_error_trait!(Error: Sized + Debug + Display);
|
|||||||
/// [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
/// [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||||
/// [`serde_derive`]: https://crates.io/crates/serde_derive
|
/// [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||||
/// [derive section of the manual]: https://serde.rs/derive.html
|
/// [derive section of the manual]: https://serde.rs/derive.html
|
||||||
|
#[cfg_attr(
|
||||||
|
not(no_diagnostic_namespace),
|
||||||
|
diagnostic::on_unimplemented(
|
||||||
|
note = "for local types consider adding `#[derive(serde::Serialize)]` to your `{Self}` type",
|
||||||
|
note = "for types from other crates check whether the crate offers a `serde` feature flag",
|
||||||
|
)
|
||||||
|
)]
|
||||||
pub trait Serialize {
|
pub trait Serialize {
|
||||||
/// Serialize this value into the given Serde serializer.
|
/// Serialize this value into the given Serde serializer.
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user