rustdoc: Negative impls are not notable
This commit is contained in:
parent
8387315ab3
commit
8994840f7e
@ -1424,6 +1424,10 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> O
|
||||
if let Some(impls) = cx.cache().impls.get(&did) {
|
||||
for i in impls {
|
||||
let impl_ = i.inner_impl();
|
||||
if impl_.polarity != ty::ImplPolarity::Positive {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !ty.is_doc_subtype_of(&impl_.for_, cx.cache()) {
|
||||
// Two different types might have the same did,
|
||||
// without actually being the same.
|
||||
@ -1459,6 +1463,10 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
|
||||
|
||||
for i in impls {
|
||||
let impl_ = i.inner_impl();
|
||||
if impl_.polarity != ty::ImplPolarity::Positive {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !ty.is_doc_subtype_of(&impl_.for_, cx.cache()) {
|
||||
// Two different types might have the same did,
|
||||
// without actually being the same.
|
||||
|
@ -0,0 +1 @@
|
||||
<script type="text/json" id="notable-traits-data">{"Negative":"</code></pre>"}</script>
|
@ -0,0 +1 @@
|
||||
<script type="text/json" id="notable-traits-data">{"Positive":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Positive.html\" title=\"struct doc_notable_trait_negative::Positive\">Positive</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait_negative::SomeTrait\">SomeTrait</a> for <a class=\"struct\" href=\"struct.Positive.html\" title=\"struct doc_notable_trait_negative::Positive\">Positive</a></div>"}</script>
|
22
tests/rustdoc/notable-trait/doc-notable_trait-negative.rs
Normal file
22
tests/rustdoc/notable-trait/doc-notable_trait-negative.rs
Normal file
@ -0,0 +1,22 @@
|
||||
#![feature(doc_notable_trait, negative_impls)]
|
||||
|
||||
#[doc(notable_trait)]
|
||||
pub trait SomeTrait {}
|
||||
|
||||
pub struct Positive;
|
||||
impl SomeTrait for Positive {}
|
||||
|
||||
pub struct Negative;
|
||||
impl !SomeTrait for Negative {}
|
||||
|
||||
// @has doc_notable_trait_negative/fn.positive.html
|
||||
// @snapshot positive - '//script[@id="notable-traits-data"]'
|
||||
pub fn positive() -> Positive {
|
||||
todo!()
|
||||
}
|
||||
|
||||
// @has doc_notable_trait_negative/fn.negative.html
|
||||
// @count - '//script[@id="notable-traits-data"]' 0
|
||||
pub fn negative() -> Negative {
|
||||
&[]
|
||||
}
|
Loading…
Reference in New Issue
Block a user