From 2e6f3bd1d32455e535de1d9ee154253c333aec73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sat, 12 Oct 2024 12:47:08 +0200 Subject: [PATCH] rustdoc-JSON: Rename "object safe" to "dyn compatible" --- src/librustdoc/json/conversions.rs | 4 ++-- src/rustdoc-json-types/lib.rs | 9 ++++++--- .../rustdoc-json/traits/is_dyn_compatible.rs | 19 +++++++++++++++++++ tests/rustdoc-json/traits/is_object_safe.rs | 19 ------------------- 4 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 tests/rustdoc-json/traits/is_dyn_compatible.rs delete mode 100644 tests/rustdoc-json/traits/is_object_safe.rs diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 77e7d83090b94..0130f2ce517bf 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -672,12 +672,12 @@ impl FromClean for Trait { let tcx = renderer.tcx; let is_auto = trait_.is_auto(tcx); let is_unsafe = trait_.safety(tcx) == rustc_hir::Safety::Unsafe; - let is_object_safe = trait_.is_dyn_compatible(tcx); + let is_dyn_compatible = trait_.is_dyn_compatible(tcx); let clean::Trait { items, generics, bounds, .. } = trait_; Trait { is_auto, is_unsafe, - is_object_safe, + is_dyn_compatible, items: renderer.ids(items), generics: generics.into_json(renderer), bounds: bounds.into_json(renderer), diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index fc64bc98bb981..b0bedab495f7b 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; /// This integer is incremented with every breaking change to the API, /// and is returned along with the JSON blob as [`Crate::format_version`]. /// Consuming code should assert that this value matches the format version(s) that it supports. -pub const FORMAT_VERSION: u32 = 35; +pub const FORMAT_VERSION: u32 = 36; /// The root of the emitted JSON blob. /// @@ -1082,8 +1082,11 @@ pub struct Trait { pub is_auto: bool, /// Whether the trait is marked as `unsafe`. pub is_unsafe: bool, - /// Whether the trait is [object safe](https://doc.rust-lang.org/reference/items/traits.html#object-safety). - pub is_object_safe: bool, + // FIXME(dyn_compat_renaming): Update the URL once the Reference is updated and hits stable. + /// Whether the trait is [dyn compatible](https://doc.rust-lang.org/reference/items/traits.html#object-safety)[^1]. + /// + /// [^1]: Formerly known as "object safe". + pub is_dyn_compatible: bool, /// Associated [`Item`]s that can/must be implemented by the `impl` blocks. pub items: Vec, /// Information about the type parameters and `where` clauses of the trait. diff --git a/tests/rustdoc-json/traits/is_dyn_compatible.rs b/tests/rustdoc-json/traits/is_dyn_compatible.rs new file mode 100644 index 0000000000000..bccf94d17d606 --- /dev/null +++ b/tests/rustdoc-json/traits/is_dyn_compatible.rs @@ -0,0 +1,19 @@ +#![no_std] + +//@ has "$.index[*][?(@.name=='FooDynIncompatible')]" +//@ is "$.index[*][?(@.name=='FooDynIncompatible')].inner.trait.is_dyn_compatible" false +pub trait FooDynIncompatible { + fn foo() -> Self; +} + +//@ has "$.index[*][?(@.name=='BarDynIncompatible')]" +//@ is "$.index[*][?(@.name=='BarDynIncompatible')].inner.trait.is_dyn_compatible" false +pub trait BarDynIncompatible { + fn foo(i: T); +} + +//@ has "$.index[*][?(@.name=='FooDynCompatible')]" +//@ is "$.index[*][?(@.name=='FooDynCompatible')].inner.trait.is_dyn_compatible" true +pub trait FooDynCompatible { + fn foo(&self); +} diff --git a/tests/rustdoc-json/traits/is_object_safe.rs b/tests/rustdoc-json/traits/is_object_safe.rs deleted file mode 100644 index 35c4e4eb84799..0000000000000 --- a/tests/rustdoc-json/traits/is_object_safe.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![no_std] - -//@ has "$.index[*][?(@.name=='FooUnsafe')]" -//@ is "$.index[*][?(@.name=='FooUnsafe')].inner.trait.is_object_safe" false -pub trait FooUnsafe { - fn foo() -> Self; -} - -//@ has "$.index[*][?(@.name=='BarUnsafe')]" -//@ is "$.index[*][?(@.name=='BarUnsafe')].inner.trait.is_object_safe" false -pub trait BarUnsafe { - fn foo(i: T); -} - -//@ has "$.index[*][?(@.name=='FooSafe')]" -//@ is "$.index[*][?(@.name=='FooSafe')].inner.trait.is_object_safe" true -pub trait FooSafe { - fn foo(&self); -}