Rollup merge of #131594 - fmease:rustdoc-mv-obj-safe-dyn-compat, r=notriddle
rustdoc: Rename "object safe" to "dyn compatible" Supersedes #126554: 1. In line with [T-lang's latest resolution](https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118). 2. More comprehensive: Not only updates user-facing text but also source code. Part of #130852. Doesn't update rustdoc-JSON (will be filed separately). r? `@notriddle` (rust-lang/lang-team#286) `@GuillaumeGomez` (for visibility)
This commit is contained in:
commit
70477487b1
@ -1450,7 +1450,7 @@ pub(crate) fn is_notable_trait(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
pub(crate) fn safety(&self, tcx: TyCtxt<'_>) -> hir::Safety {
|
||||
tcx.trait_def(self.def_id).safety
|
||||
}
|
||||
pub(crate) fn is_object_safe(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
pub(crate) fn is_dyn_compatible(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
tcx.is_dyn_compatible(self.def_id)
|
||||
}
|
||||
}
|
||||
|
@ -2002,7 +2002,7 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
|
||||
map.insert("required-associated-consts".into(), 1);
|
||||
map.insert("required-methods".into(), 1);
|
||||
map.insert("provided-methods".into(), 1);
|
||||
map.insert("object-safety".into(), 1);
|
||||
map.insert("dyn-compatibility".into(), 1);
|
||||
map.insert("implementors".into(), 1);
|
||||
map.insert("synthetic-implementors".into(), 1);
|
||||
map.insert("implementations-list".into(), 1);
|
||||
|
@ -934,16 +934,18 @@ fn trait_item(w: &mut Buffer, cx: &mut Context<'_>, m: &clean::Item, t: &clean::
|
||||
let cache = &cloned_shared.cache;
|
||||
let mut extern_crates = FxIndexSet::default();
|
||||
|
||||
if !t.is_object_safe(cx.tcx()) {
|
||||
if !t.is_dyn_compatible(cx.tcx()) {
|
||||
// FIXME(dyn_compat_renaming): Update the URL once the Reference is updated.
|
||||
write_section_heading(
|
||||
w,
|
||||
"Object Safety",
|
||||
"object-safety",
|
||||
"Dyn Compatibility",
|
||||
"dyn-compatibility",
|
||||
None,
|
||||
&format!(
|
||||
"<div class=\"object-safety-info\">This trait is <b>not</b> \
|
||||
<a href=\"{base}/reference/items/traits.html#object-safety\">\
|
||||
object safe</a>.</div>",
|
||||
"<div class=\"dyn-compatibility-info\"><p>This trait is <b>not</b> \
|
||||
<a href=\"{base}/reference/items/traits.html#object-safety\">dyn compatible</a>.</p>\
|
||||
<p><i>In older versions of Rust, dyn compatibility was called \"object safety\", \
|
||||
so this trait is not object safe.</i></p></div>",
|
||||
base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL
|
||||
),
|
||||
);
|
||||
|
@ -315,10 +315,10 @@ fn filter_items<'a>(
|
||||
);
|
||||
sidebar_assoc_items(cx, it, blocks);
|
||||
|
||||
if !t.is_object_safe(cx.tcx()) {
|
||||
if !t.is_dyn_compatible(cx.tcx()) {
|
||||
blocks.push(LinkBlock::forced(
|
||||
Link::new("object-safety", "Object Safety"),
|
||||
"object-safety-note",
|
||||
Link::new("dyn-compatibility", "Dyn Compatibility"),
|
||||
"dyn-compatibility-note",
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ fn from_clean(trait_: clean::Trait, renderer: &JsonRenderer<'_>) -> Self {
|
||||
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_object_safe(tcx);
|
||||
let is_object_safe = trait_.is_dyn_compatible(tcx);
|
||||
let clean::Trait { items, generics, bounds, .. } = trait_;
|
||||
Trait {
|
||||
is_auto,
|
||||
|
27
tests/rustdoc/dyn-compatibility.rs
Normal file
27
tests/rustdoc/dyn-compatibility.rs
Normal file
@ -0,0 +1,27 @@
|
||||
#![crate_name = "foo"]
|
||||
|
||||
//@ has 'foo/trait.DynIncompatible.html'
|
||||
//@ has - '//*[@class="dyn-compatibility-info"]' 'This trait is not dyn compatible.'
|
||||
//@ has - '//*[@id="dyn-compatibility"]' 'Dyn Compatibility'
|
||||
pub trait DynIncompatible {
|
||||
fn foo() -> Self;
|
||||
}
|
||||
|
||||
//@ has 'foo/trait.DynIncompatible2.html'
|
||||
//@ has - '//*[@class="dyn-compatibility-info"]' 'This trait is not dyn compatible.'
|
||||
//@ has - '//*[@id="dyn-compatibility"]' 'Dyn Compatibility'
|
||||
pub trait DynIncompatible2<T> {
|
||||
fn foo(i: T);
|
||||
}
|
||||
|
||||
//@ has 'foo/trait.DynCompatible.html'
|
||||
//@ !has - '//*[@class="dyn-compatibility-info"]' ''
|
||||
//@ !has - '//*[@id="dyn-compatibility"]' ''
|
||||
pub trait DynCompatible {
|
||||
fn foo(&self);
|
||||
}
|
||||
|
||||
//@ has 'foo/struct.Foo.html'
|
||||
//@ count - '//*[@class="dyn-compatibility-info"]' 0
|
||||
//@ count - '//*[@id="dyn-compatibility"]' 0
|
||||
pub struct Foo;
|
@ -14,7 +14,7 @@
|
||||
//@ has - '//*[@class="sidebar-elems"]//section//a' 'Output'
|
||||
//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types'
|
||||
//@ has - '//*[@class="sidebar-elems"]//section//a' 'Extra'
|
||||
//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' 'Object Safety'
|
||||
//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#dyn-compatibility"]' 'Dyn Compatibility'
|
||||
pub trait Foo {
|
||||
const FOO: usize;
|
||||
const BAR: u32 = 0;
|
||||
@ -25,9 +25,9 @@ fn foo() {}
|
||||
fn bar() -> Self::Output;
|
||||
}
|
||||
|
||||
//@ has foo/trait.Safe.html
|
||||
//@ has foo/trait.DynCompatible.html
|
||||
//@ !has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' ''
|
||||
pub trait Safe {
|
||||
pub trait DynCompatible {
|
||||
fn access(&self);
|
||||
}
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
#![crate_name = "foo"]
|
||||
|
||||
//@ has 'foo/trait.Unsafe.html'
|
||||
//@ has - '//*[@class="object-safety-info"]' 'This trait is not object safe.'
|
||||
//@ has - '//*[@id="object-safety"]' 'Object Safety'
|
||||
pub trait Unsafe {
|
||||
fn foo() -> Self;
|
||||
}
|
||||
|
||||
//@ has 'foo/trait.Unsafe2.html'
|
||||
//@ has - '//*[@class="object-safety-info"]' 'This trait is not object safe.'
|
||||
//@ has - '//*[@id="object-safety"]' 'Object Safety'
|
||||
pub trait Unsafe2<T> {
|
||||
fn foo(i: T);
|
||||
}
|
||||
|
||||
//@ has 'foo/trait.Safe.html'
|
||||
//@ !has - '//*[@class="object-safety-info"]' ''
|
||||
//@ !has - '//*[@id="object-safety"]' ''
|
||||
pub trait Safe {
|
||||
fn foo(&self);
|
||||
}
|
||||
|
||||
//@ has 'foo/struct.Foo.html'
|
||||
//@ count - '//*[@class="object-safety-info"]' 0
|
||||
//@ count - '//*[@id="object-safety"]' 0
|
||||
pub struct Foo;
|
Loading…
Reference in New Issue
Block a user