Skip to content

Commit e9b5a82

Browse files
authored
Unrolled build for rust-lang#119246
Rollup merge of rust-lang#119246 - GuillaumeGomez:trait-is_object_safe-json, r=aDotInTheVoid [rustdoc] Add `is_object_safe` information for traits in JSON output As asked by `@obi1kenobi` [here](rust-lang#113241 (comment)). cc `@aDotInTheVoid` r? `@notriddle`
2 parents 520e30b + 431ac40 commit e9b5a82

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

Diff for: src/librustdoc/json/conversions.rs

+2
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,12 @@ impl FromWithTcx<clean::Trait> for Trait {
648648
fn from_tcx(trait_: clean::Trait, tcx: TyCtxt<'_>) -> Self {
649649
let is_auto = trait_.is_auto(tcx);
650650
let is_unsafe = trait_.unsafety(tcx) == rustc_hir::Unsafety::Unsafe;
651+
let is_object_safe = trait_.is_object_safe(tcx);
651652
let clean::Trait { items, generics, bounds, .. } = trait_;
652653
Trait {
653654
is_auto,
654655
is_unsafe,
656+
is_object_safe,
655657
items: ids(items, tcx),
656658
generics: generics.into_tcx(tcx),
657659
bounds: bounds.into_tcx(tcx),

Diff for: src/rustdoc-json-types/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
88
use std::path::PathBuf;
99

1010
/// rustdoc format-version.
11-
pub const FORMAT_VERSION: u32 = 27;
11+
pub const FORMAT_VERSION: u32 = 28;
1212

1313
/// A `Crate` is the root of the emitted JSON blob. It contains all type/documentation information
1414
/// about the language items in the local crate, as well as info about external items to allow
@@ -634,6 +634,7 @@ pub struct FnDecl {
634634
pub struct Trait {
635635
pub is_auto: bool,
636636
pub is_unsafe: bool,
637+
pub is_object_safe: bool,
637638
pub items: Vec<Id>,
638639
pub generics: Generics,
639640
pub bounds: Vec<GenericBound>,

Diff for: tests/rustdoc-json/traits/is_object_safe.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![no_std]
2+
3+
// @has "$.index[*][?(@.name=='FooUnsafe')]"
4+
// @is "$.index[*][?(@.name=='FooUnsafe')].inner.trait.is_object_safe" false
5+
pub trait FooUnsafe {
6+
fn foo() -> Self;
7+
}
8+
9+
// @has "$.index[*][?(@.name=='BarUnsafe')]"
10+
// @is "$.index[*][?(@.name=='BarUnsafe')].inner.trait.is_object_safe" false
11+
pub trait BarUnsafe<T> {
12+
fn foo(i: T);
13+
}
14+
15+
// @has "$.index[*][?(@.name=='FooSafe')]"
16+
// @is "$.index[*][?(@.name=='FooSafe')].inner.trait.is_object_safe" true
17+
pub trait FooSafe {
18+
fn foo(&self);
19+
}

Diff for: tests/rustdoc/trait-object-safe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ pub trait Safe {
2222
}
2323

2424
// @has 'foo/struct.Foo.html'
25-
// @!has - '//*[@class="object-safety-info"]' ''
26-
// @!has - '//*[@id="object-safety"]' ''
25+
// @count - '//*[@class="object-safety-info"]' 0
26+
// @count - '//*[@id="object-safety"]' 0
2727
pub struct Foo;

0 commit comments

Comments
 (0)