Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render HRTBs for WherePredicate::BoundPredicate #92

Merged
merged 1 commit into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ thiserror = "1.0.29"

[dependencies.rustdoc-types]
# path = "/Users/martin/src/rustdoc-types"
version = "0.10.0"
version = "0.11.0"

[dev-dependencies]
assert_cmd = "2.0.4"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The library comes with a thin bin wrapper that can be used to explore the capabi
# Build and install the thin bin wrapper with a recent stable Rust toolchain
cargo install public-api

# Install nightly-2022-03-14 or later so you can build up-to-date rustdoc JSON files
# Install nightly-2022-05-19 or later so you can build up-to-date rustdoc JSON files
rustup install nightly
```

Expand Down Expand Up @@ -110,7 +110,8 @@ labeled issues.

| public-api | Understands the rustdoc JSON output of |
| ------------- | --------------------------------------- |
| v0.10.x | nightly-2022-03-14 — |
| v0.11.x | nightly-2022-05-19 |
| v0.10.x | nightly-2022-03-14 — nightly-2022-05-18 |
| v0.5.x | nightly-2022-02-23 — nightly-2022-03-13 |
| v0.2.x | nightly-2022-01-19 — nightly-2022-02-22 |
| v0.0.5 | nightly-2021-10-11 — nightly-2022-01-18 |
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub use item_iterator::PublicItem;
/// The rustdoc JSON format is still changing, so every now and then we update
/// this library to support the latest format. If you use this version of
/// nightly or later, you should be fine.
pub const MINIMUM_RUSTDOC_JSON_VERSION: &str = "nightly-2022-03-14";
pub const MINIMUM_RUSTDOC_JSON_VERSION: &str = "nightly-2022-05-19";

/// Contains various options that you can pass to [`public_api_from_rustdoc_json_str`].
#[derive(Copy, Clone, Debug)]
Expand Down
7 changes: 6 additions & 1 deletion src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,12 @@ fn render_where_predicates(root: &Crate, where_predicates: &[WherePredicate]) ->
fn render_where_predicate(root: &Crate, where_predicate: &WherePredicate) -> Vec<Token> {
let mut output = vec![];
match where_predicate {
WherePredicate::BoundPredicate { type_, bounds } => {
WherePredicate::BoundPredicate {
type_,
bounds,
generic_params,
} => {
output.extend(render_higher_rank_trait_bounds(root, generic_params));
output.extend(render_type(root, type_));
output.extend(colon());
output.extend(render_generic_bounds(root, bounds));
Expand Down
19 changes: 19 additions & 0 deletions tests/crates/comprehensive_api/src/higher_ranked_trait_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

// @has foo/trait.Trait.html
pub trait Trait<'x> {}

// @has foo/fn.test1.html
// @has - '//pre' "pub fn test1<T>() where for<'a> &'a T: Iterator,"
pub fn test1<T>()
where
for<'a> &'a T: Iterator,
{
}

// @has foo/fn.test2.html
// @has - '//pre' "pub fn test2<T>() where for<'a, 'b> &'a T: Trait<'b>,"
pub fn test2<T>()
where
for<'a, 'b> &'a T: Trait<'b>,
{
}

// @has foo/fn.test3.html
// @has - '//pre' "pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8),"
pub fn test3<F>()
Expand Down
3 changes: 3 additions & 0 deletions tests/expected-output/comprehensive_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub fn comprehensive_api::functions::return_tuple() -> (bool, Basic)
pub fn comprehensive_api::functions::somewhere<T, U>(t: T, u: U) where T: Display, U: Debug
pub fn comprehensive_api::functions::struct_arg(s: PrivateField)
pub fn comprehensive_api::functions::synthetic_arg(t: impl Simple) -> impl Simple
pub fn comprehensive_api::higher_ranked_trait_bounds::test1<T>() where for<'a> &'a T: Iterator
pub fn comprehensive_api::higher_ranked_trait_bounds::test2<T>() where for<'a, 'b> &'a T: Trait<'b>
pub fn comprehensive_api::higher_ranked_trait_bounds::test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8)
pub fn comprehensive_api::structs::Plain::f()
pub fn comprehensive_api::structs::Plain::new() -> Plain
Expand Down Expand Up @@ -85,6 +87,7 @@ pub struct field comprehensive_api::structs::WithLifetimeAndGenericParam::unit_r
pub struct field comprehensive_api::unions::Basic::x: usize
pub struct field comprehensive_api::unions::Basic::y: usize
pub trait comprehensive_api::RngCore
pub trait comprehensive_api::higher_ranked_trait_bounds::Trait<'x>
pub trait comprehensive_api::traits::AssociatedConst
pub trait comprehensive_api::traits::AssociatedConstDefault
pub trait comprehensive_api::traits::AssociatedType
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-json/example_api-v0.1.0.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/rustdoc-json/example_api-v0.2.0.json

Large diffs are not rendered by default.