Skip to content

Commit

Permalink
rustdoc: add test case for the implementors JS file placement
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed May 28, 2022
1 parent e4d48c3 commit 5d86305
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/rustdoc/inline_cross/auxiliary/implementors_inline.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pub mod my_trait {
pub trait MyTrait {
fn my_fn(&self) -> Self;
}
}

pub mod prelude {
#[doc(inline)]
pub use crate::my_trait::MyTrait;
}

pub struct SomeStruct;

impl my_trait::MyTrait for SomeStruct {
fn my_fn(&self) -> SomeStruct {
SomeStruct
}
}
25 changes: 25 additions & 0 deletions src/test/rustdoc/inline_cross/implementors-js.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// aux-build:implementors_inline.rs
// build-aux-docs
// ignore-cross-compile

extern crate implementors_inline;

// @!has implementors/implementors_js/trait.MyTrait.js
// @has implementors/implementors_inline/my_trait/trait.MyTrait.js
// @!has implementors/implementors_inline/prelude/trait.MyTrait.js
// @has implementors_inline/my_trait/trait.MyTrait.html
// @has - '//script/@src' '../../implementors/implementors_inline/my_trait/trait.MyTrait.js'
// @has implementors_js/trait.MyTrait.html
// @has - '//script/@src' '../implementors/implementors_inline/my_trait/trait.MyTrait.js'
/// When re-exporting this trait, the HTML will be inlined,
/// but, vitally, the JavaScript will be located only at the
/// one canonical path.
pub use implementors_inline::prelude::MyTrait;

pub struct OtherStruct;

impl MyTrait for OtherStruct {
fn my_fn(&self) -> OtherStruct {
OtherStruct
}
}

0 comments on commit 5d86305

Please sign in to comment.