Skip to content

Commit 4332a61

Browse files
authored
Unrolled build for rust-lang#131594
Rollup merge of rust-lang#131594 - fmease:rustdoc-mv-obj-safe-dyn-compat, r=notriddle rustdoc: Rename "object safe" to "dyn compatible" Supersedes rust-lang#126554: 1. In line with [T-lang's latest resolution](rust-lang/lang-team#286 (comment)). 2. More comprehensive: Not only updates user-facing text but also source code. Part of rust-lang#130852. Doesn't update rustdoc-JSON (will be filed separately). r? `@notriddle` (rust-lang/lang-team#286) `@GuillaumeGomez` (for visibility)
2 parents bed75e7 + 6d82559 commit 4332a61

File tree

8 files changed

+44
-42
lines changed

8 files changed

+44
-42
lines changed

src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ impl Trait {
14501450
pub(crate) fn safety(&self, tcx: TyCtxt<'_>) -> hir::Safety {
14511451
tcx.trait_def(self.def_id).safety
14521452
}
1453-
pub(crate) fn is_object_safe(&self, tcx: TyCtxt<'_>) -> bool {
1453+
pub(crate) fn is_dyn_compatible(&self, tcx: TyCtxt<'_>) -> bool {
14541454
tcx.is_dyn_compatible(self.def_id)
14551455
}
14561456
}

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
20022002
map.insert("required-associated-consts".into(), 1);
20032003
map.insert("required-methods".into(), 1);
20042004
map.insert("provided-methods".into(), 1);
2005-
map.insert("object-safety".into(), 1);
2005+
map.insert("dyn-compatibility".into(), 1);
20062006
map.insert("implementors".into(), 1);
20072007
map.insert("synthetic-implementors".into(), 1);
20082008
map.insert("implementations-list".into(), 1);

src/librustdoc/html/render/print_item.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -934,16 +934,18 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
934934
let cache = &cloned_shared.cache;
935935
let mut extern_crates = FxIndexSet::default();
936936

937-
if !t.is_object_safe(cx.tcx()) {
937+
if !t.is_dyn_compatible(cx.tcx()) {
938+
// FIXME(dyn_compat_renaming): Update the URL once the Reference is updated.
938939
write_section_heading(
939940
w,
940-
"Object Safety",
941-
"object-safety",
941+
"Dyn Compatibility",
942+
"dyn-compatibility",
942943
None,
943944
&format!(
944-
"<div class=\"object-safety-info\">This trait is <b>not</b> \
945-
<a href=\"{base}/reference/items/traits.html#object-safety\">\
946-
object safe</a>.</div>",
945+
"<div class=\"dyn-compatibility-info\"><p>This trait is <b>not</b> \
946+
<a href=\"{base}/reference/items/traits.html#object-safety\">dyn compatible</a>.</p>\
947+
<p><i>In older versions of Rust, dyn compatibility was called \"object safety\", \
948+
so this trait is not object safe.</i></p></div>",
947949
base = crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL
948950
),
949951
);

src/librustdoc/html/render/sidebar.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ fn sidebar_trait<'a>(
315315
);
316316
sidebar_assoc_items(cx, it, blocks);
317317

318-
if !t.is_object_safe(cx.tcx()) {
318+
if !t.is_dyn_compatible(cx.tcx()) {
319319
blocks.push(LinkBlock::forced(
320-
Link::new("object-safety", "Object Safety"),
321-
"object-safety-note",
320+
Link::new("dyn-compatibility", "Dyn Compatibility"),
321+
"dyn-compatibility-note",
322322
));
323323
}
324324

src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ impl FromClean<clean::Trait> for Trait {
672672
let tcx = renderer.tcx;
673673
let is_auto = trait_.is_auto(tcx);
674674
let is_unsafe = trait_.safety(tcx) == rustc_hir::Safety::Unsafe;
675-
let is_object_safe = trait_.is_object_safe(tcx);
675+
let is_object_safe = trait_.is_dyn_compatible(tcx);
676676
let clean::Trait { items, generics, bounds, .. } = trait_;
677677
Trait {
678678
is_auto,

tests/rustdoc/dyn-compatibility.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![crate_name = "foo"]
2+
3+
//@ has 'foo/trait.DynIncompatible.html'
4+
//@ has - '//*[@class="dyn-compatibility-info"]' 'This trait is not dyn compatible.'
5+
//@ has - '//*[@id="dyn-compatibility"]' 'Dyn Compatibility'
6+
pub trait DynIncompatible {
7+
fn foo() -> Self;
8+
}
9+
10+
//@ has 'foo/trait.DynIncompatible2.html'
11+
//@ has - '//*[@class="dyn-compatibility-info"]' 'This trait is not dyn compatible.'
12+
//@ has - '//*[@id="dyn-compatibility"]' 'Dyn Compatibility'
13+
pub trait DynIncompatible2<T> {
14+
fn foo(i: T);
15+
}
16+
17+
//@ has 'foo/trait.DynCompatible.html'
18+
//@ !has - '//*[@class="dyn-compatibility-info"]' ''
19+
//@ !has - '//*[@id="dyn-compatibility"]' ''
20+
pub trait DynCompatible {
21+
fn foo(&self);
22+
}
23+
24+
//@ has 'foo/struct.Foo.html'
25+
//@ count - '//*[@class="dyn-compatibility-info"]' 0
26+
//@ count - '//*[@id="dyn-compatibility"]' 0
27+
pub struct Foo;

tests/rustdoc/sidebar/sidebar-items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//@ has - '//*[@class="sidebar-elems"]//section//a' 'Output'
1515
//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types'
1616
//@ has - '//*[@class="sidebar-elems"]//section//a' 'Extra'
17-
//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' 'Object Safety'
17+
//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#dyn-compatibility"]' 'Dyn Compatibility'
1818
pub trait Foo {
1919
const FOO: usize;
2020
const BAR: u32 = 0;
@@ -25,9 +25,9 @@ pub trait Foo {
2525
fn bar() -> Self::Output;
2626
}
2727

28-
//@ has foo/trait.Safe.html
28+
//@ has foo/trait.DynCompatible.html
2929
//@ !has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' ''
30-
pub trait Safe {
30+
pub trait DynCompatible {
3131
fn access(&self);
3232
}
3333

tests/rustdoc/trait-object-safe.rs

-27
This file was deleted.

0 commit comments

Comments
 (0)