forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#125134 - compiler-errors:negative-traits-are-…
…not-notable, r=fmease rustdoc: Negative impls are not notable In rust-lang#124097, we add `impl !Iterator for [T]` for coherence reasons, and since `Iterator` is a [notable trait](https://github.com/rust-lang/rust/blob/8387315ab3c26a57a1f53a90f188f0bc88514bca/library/core/src/iter/traits/iterator.rs#L40), this means that all `-> &[_]` now are tagged with a `!Iterator` impl as a notable trait. I "fixed" the failing tests in that PR with 6cbbb8b, where I just blessed the tests, since I didn't want to mix these changes with that PR; however, don't believe negative impls are notable, and this PR aims to prevent these impls from being mentioned. In the standard library, we use negative impls purely to guide coherence. They're not really a signal of anything useful to the end-user. If there ever is a case that we want negative impls to be mentioned as notable, this really should be an opt-in feature.
- Loading branch information
Showing
4 changed files
with
32 additions
and
0 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
1 change: 1 addition & 0 deletions
1
tests/rustdoc/notable-trait/doc-notable_trait-negative.negative.html
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 @@ | ||
<script type="text/json" id="notable-traits-data">{"Negative":"</code></pre>"}</script> |
1 change: 1 addition & 0 deletions
1
tests/rustdoc/notable-trait/doc-notable_trait-negative.positive.html
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 @@ | ||
<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> |
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,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 { | ||
&[] | ||
} |