-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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 #108954 - notriddle:notriddle/notable-trait-generic, …
…r=camelid rustdoc: handle generics better when matching notable traits This commit makes the `clean::Type::is_same` non-commutative (renaming it `is_doc_subtype_of`), so that a generic `impl` matches a concrete return, but a generic return does not match a concrete `impl`. It makes slice and vector Write for `u8` not match on every generic return value. Fixes #100322 Fixes #55082 Preview: * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.new * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.from-12 * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/iter/trait.Iterator.html#method.intersperse_with * https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/string/struct.String.html#method.as_bytes
- Loading branch information
Showing
15 changed files
with
105 additions
and
12 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,35 @@ | ||
#![feature(doc_notable_trait)] | ||
|
||
// Notable traits SHOULD NOT be shown when the `impl` has a concrete type and | ||
// the return type has a generic type. | ||
pub mod generic_return { | ||
pub struct Wrapper<T>(T); | ||
|
||
#[doc(notable_trait)] | ||
pub trait NotableTrait {} | ||
|
||
impl NotableTrait for Wrapper<u8> {} | ||
|
||
// @has notable_trait_generics/generic_return/fn.returning.html | ||
// @!has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<T>' | ||
pub fn returning<T>() -> Wrapper<T> { | ||
loop {} | ||
} | ||
} | ||
|
||
// Notable traits SHOULD be shown when the `impl` has a generic type and the | ||
// return type has a concrete type. | ||
pub mod generic_impl { | ||
pub struct Wrapper<T>(T); | ||
|
||
#[doc(notable_trait)] | ||
pub trait NotableTrait {} | ||
|
||
impl<T> NotableTrait for Wrapper<T> {} | ||
|
||
// @has notable_trait_generics/generic_impl/fn.returning.html | ||
// @has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<u8>' | ||
pub fn returning() -> Wrapper<u8> { | ||
loop {} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.