-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #105182 - aDotInTheVoid:rdj-no-foreign-traits, r=Ense…
…lic,GuillaumeGomez Rustdoc-Json: Don't inline foreign traits It wasn't done correctly, and [we want to move towards only having local items in the index, and making foreign items easier to resolved](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Rustdoc.20JSON.3A.20Include.20All.20Foreign.20Items.3F) Fixes #105025. This means #105015 is included to test this Fixes #105022 r? `@GuillaumeGomez`
- Loading branch information
Showing
8 changed files
with
95 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/test/rustdoc-json/intra-doc-links/auxiliary/enum_variant_in_trait_method.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pub trait Trait { | ||
/// [`Enum::Variant`] | ||
fn method() {} | ||
} | ||
|
||
pub enum Enum { | ||
Variant, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Regression test for <https://github.com/rust-lang/rust/issues/105025> | ||
// aux-build: enum_variant_in_trait_method.rs | ||
|
||
extern crate enum_variant_in_trait_method; | ||
|
||
pub struct Local; | ||
|
||
/// local impl | ||
impl enum_variant_in_trait_method::Trait for Local {} | ||
|
||
// @!has "$.index[*][?(@.name == 'Trait')]" | ||
// @!has "$.index[*][?(@.name == 'method')]" | ||
// @count "$.index[*][?(@.docs == 'local impl')].inner.items[*]" 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// The Docs | ||
pub trait HasDocs {} |
10 changes: 10 additions & 0 deletions
10
src/test/rustdoc-json/reexport/synthesize_trait_with_docs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Regression test for <https://github.com/rust-lang/rust/issues/105022> | ||
// aux-build: trait_with_docs.rs | ||
|
||
extern crate trait_with_docs; | ||
|
||
pub struct Local; | ||
|
||
impl trait_with_docs::HasDocs for Local {} | ||
|
||
// @!has "$.index[*][?(@.name == 'HasDocs')]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
#![no_std] | ||
pub fn drop_default<T: core::default::Default>(_x: T) {} | ||
|
||
// FIXME(adotinthevoid): Theses shouldn't be here | ||
// @has "$.index[*][?(@.name=='Debug')]" | ||
|
||
// Debug may have several items. All we depend on here the that `fmt` is first. See | ||
// https://github.com/rust-lang/rust/pull/104525#issuecomment-1331087852 for why we | ||
// can't use [*]. | ||
|
||
// @set Debug_fmt = "$.index[*][?(@.name=='Debug')].inner.items[0]" | ||
// @has "$.index[*][?(@.name=='fmt')].id" $Debug_fmt | ||
// @!has "$.index[*][?(@.name=='Debug')]" | ||
// @!has "$.index[*][?(@.name=='Default')]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::collections::HashMap; | ||
|
||
use rustdoc_json_types::{Crate, Item, Visibility}; | ||
|
||
use super::*; | ||
|
||
#[track_caller] | ||
fn check(krate: &Crate, errs: &[Error]) { | ||
let mut validator = Validator::new(krate); | ||
validator.check_crate(); | ||
|
||
assert_eq!(errs, &validator.errs[..]); | ||
} | ||
|
||
fn id(s: &str) -> Id { | ||
Id(s.to_owned()) | ||
} | ||
|
||
#[test] | ||
fn errors_on_missing_links() { | ||
let k = Crate { | ||
root: id("0"), | ||
crate_version: None, | ||
includes_private: false, | ||
index: HashMap::from_iter([( | ||
id("0"), | ||
Item { | ||
name: Some("root".to_owned()), | ||
id: id(""), | ||
crate_id: 0, | ||
span: None, | ||
visibility: Visibility::Public, | ||
docs: None, | ||
links: HashMap::from_iter([("Not Found".to_owned(), id("1"))]), | ||
attrs: vec![], | ||
deprecation: None, | ||
inner: ItemEnum::Module(Module { | ||
is_crate: true, | ||
items: vec![], | ||
is_stripped: false, | ||
}), | ||
}, | ||
)]), | ||
paths: HashMap::new(), | ||
external_crates: HashMap::new(), | ||
format_version: rustdoc_json_types::FORMAT_VERSION, | ||
}; | ||
|
||
check(&k, &[Error { kind: ErrorKind::NotFound, id: id("1") }]); | ||
} |