Rollup merge of #74370 - Manishearth:re-spotlight, r=GuillaumeGomez
Reintroduce spotlight / "important traits" feature (Reopened version of https://github.com/rust-lang/rust/pull/74111 because Github is broken, see discussion there) Fixes https://github.com/rust-lang/rust/issues/73785 This PR reintroduces the "spotlight" ("important traits") feature. A couple changes have been made: As there were concerns about its visibility, it has been moved to be next to the return type, as opposed to being on the side. It also no longer produces a modal, it shows the traits on hover, and it can be clicked on to pin the hover bubble.   It also works fine on mobile: 
This commit is contained in:
commit
fc098170ce
23 changed files with 284 additions and 15 deletions
36
src/test/rustdoc/doc-spotlight.rs
Normal file
36
src/test/rustdoc/doc-spotlight.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#![feature(doc_spotlight)]
|
||||
|
||||
pub struct Wrapper<T> {
|
||||
inner: T,
|
||||
}
|
||||
|
||||
impl<T: SomeTrait> SomeTrait for Wrapper<T> {}
|
||||
|
||||
#[doc(spotlight)]
|
||||
pub trait SomeTrait {
|
||||
// @has doc_spotlight/trait.SomeTrait.html
|
||||
// @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
|
||||
fn wrap_me(self) -> Wrapper<Self> where Self: Sized {
|
||||
Wrapper {
|
||||
inner: self,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SomeStruct;
|
||||
impl SomeTrait for SomeStruct {}
|
||||
|
||||
impl SomeStruct {
|
||||
// @has doc_spotlight/struct.SomeStruct.html
|
||||
// @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct'
|
||||
// @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
|
||||
pub fn new() -> SomeStruct {
|
||||
SomeStruct
|
||||
}
|
||||
}
|
||||
|
||||
// @has doc_spotlight/fn.bare_fn.html
|
||||
// @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct'
|
||||
pub fn bare_fn() -> SomeStruct {
|
||||
SomeStruct
|
||||
}
|
||||
4
src/test/ui/feature-gates/feature-gate-doc_spotlight.rs
Normal file
4
src/test/ui/feature-gates/feature-gate-doc_spotlight.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#[doc(spotlight)] //~ ERROR: `#[doc(spotlight)]` is experimental
|
||||
trait SomeTrait {}
|
||||
|
||||
fn main() {}
|
||||
12
src/test/ui/feature-gates/feature-gate-doc_spotlight.stderr
Normal file
12
src/test/ui/feature-gates/feature-gate-doc_spotlight.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error[E0658]: `#[doc(spotlight)]` is experimental
|
||||
--> $DIR/feature-gate-doc_spotlight.rs:1:1
|
||||
|
|
||||
LL | #[doc(spotlight)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #45040 <https://github.com/rust-lang/rust/issues/45040> for more information
|
||||
= help: add `#![feature(doc_spotlight)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue