rustdoc-JSON: Rename "object safe" to "dyn compatible"

This commit is contained in:
León Orell Valerian Liehr 2024-10-12 12:47:08 +02:00
parent 7342830c05
commit 2e6f3bd1d3
No known key found for this signature in database
GPG Key ID: D17A07215F68E713
4 changed files with 27 additions and 24 deletions

View File

@ -672,12 +672,12 @@ fn from_clean(trait_: clean::Trait, renderer: &JsonRenderer<'_>) -> Self {
let tcx = renderer.tcx; let tcx = renderer.tcx;
let is_auto = trait_.is_auto(tcx); let is_auto = trait_.is_auto(tcx);
let is_unsafe = trait_.safety(tcx) == rustc_hir::Safety::Unsafe; 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_; let clean::Trait { items, generics, bounds, .. } = trait_;
Trait { Trait {
is_auto, is_auto,
is_unsafe, is_unsafe,
is_object_safe, is_dyn_compatible,
items: renderer.ids(items), items: renderer.ids(items),
generics: generics.into_json(renderer), generics: generics.into_json(renderer),
bounds: bounds.into_json(renderer), bounds: bounds.into_json(renderer),

View File

@ -13,7 +13,7 @@
/// This integer is incremented with every breaking change to the API, /// This integer is incremented with every breaking change to the API,
/// and is returned along with the JSON blob as [`Crate::format_version`]. /// 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. /// 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. /// The root of the emitted JSON blob.
/// ///
@ -1082,8 +1082,11 @@ pub struct Trait {
pub is_auto: bool, pub is_auto: bool,
/// Whether the trait is marked as `unsafe`. /// Whether the trait is marked as `unsafe`.
pub is_unsafe: bool, pub is_unsafe: bool,
/// Whether the trait is [object safe](https://doc.rust-lang.org/reference/items/traits.html#object-safety). // FIXME(dyn_compat_renaming): Update the URL once the Reference is updated and hits stable.
pub is_object_safe: bool, /// 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. /// Associated [`Item`]s that can/must be implemented by the `impl` blocks.
pub items: Vec<Id>, pub items: Vec<Id>,
/// Information about the type parameters and `where` clauses of the trait. /// Information about the type parameters and `where` clauses of the trait.

View File

@ -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<T> {
fn foo(i: T);
}
//@ has "$.index[*][?(@.name=='FooDynCompatible')]"
//@ is "$.index[*][?(@.name=='FooDynCompatible')].inner.trait.is_dyn_compatible" true
pub trait FooDynCompatible {
fn foo(&self);
}

View File

@ -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<T> {
fn foo(i: T);
}
//@ has "$.index[*][?(@.name=='FooSafe')]"
//@ is "$.index[*][?(@.name=='FooSafe')].inner.trait.is_object_safe" true
pub trait FooSafe {
fn foo(&self);
}