Skip to content

Commit 032c411

Browse files
authored
Merge pull request #92 from Enselic/hrtb-for-function-pointer
Render HRTBs for WherePredicate::BoundPredicate
2 parents 300d0b0 + 0b91573 commit 032c411

File tree

9 files changed

+37
-9
lines changed

9 files changed

+37
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ thiserror = "1.0.29"
1717

1818
[dependencies.rustdoc-types]
1919
# path = "/Users/martin/src/rustdoc-types"
20-
version = "0.10.0"
20+
version = "0.11.0"
2121

2222
[dev-dependencies]
2323
assert_cmd = "2.0.4"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The library comes with a thin bin wrapper that can be used to explore the capabi
1414
# Build and install the thin bin wrapper with a recent stable Rust toolchain
1515
cargo install public-api
1616

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

@@ -110,7 +110,8 @@ labeled issues.
110110

111111
| public-api | Understands the rustdoc JSON output of |
112112
| ------------- | --------------------------------------- |
113-
| v0.10.x | nightly-2022-03-14 — |
113+
| v0.11.x | nightly-2022-05-19 |
114+
| v0.10.x | nightly-2022-03-14 — nightly-2022-05-18 |
114115
| v0.5.x | nightly-2022-02-23 — nightly-2022-03-13 |
115116
| v0.2.x | nightly-2022-01-19 — nightly-2022-02-22 |
116117
| v0.0.5 | nightly-2021-10-11 — nightly-2022-01-18 |

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub use item_iterator::PublicItem;
5858
/// The rustdoc JSON format is still changing, so every now and then we update
5959
/// this library to support the latest format. If you use this version of
6060
/// nightly or later, you should be fine.
61-
pub const MINIMUM_RUSTDOC_JSON_VERSION: &str = "nightly-2022-03-14";
61+
pub const MINIMUM_RUSTDOC_JSON_VERSION: &str = "nightly-2022-05-19";
6262

6363
/// Contains various options that you can pass to [`public_api_from_rustdoc_json_str`].
6464
#[derive(Copy, Clone, Debug)]

src/render.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,12 @@ fn render_where_predicates(root: &Crate, where_predicates: &[WherePredicate]) ->
621621
fn render_where_predicate(root: &Crate, where_predicate: &WherePredicate) -> Vec<Token> {
622622
let mut output = vec![];
623623
match where_predicate {
624-
WherePredicate::BoundPredicate { type_, bounds } => {
624+
WherePredicate::BoundPredicate {
625+
type_,
626+
bounds,
627+
generic_params,
628+
} => {
629+
output.extend(render_higher_rank_trait_bounds(root, generic_params));
625630
output.extend(render_type(root, type_));
626631
output.extend(colon());
627632
output.extend(render_generic_bounds(root, bounds));

tests/crates/comprehensive_api/src/higher_ranked_trait_bounds.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@
2222
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
// SOFTWARE.
2424

25+
// @has foo/trait.Trait.html
26+
pub trait Trait<'x> {}
27+
28+
// @has foo/fn.test1.html
29+
// @has - '//pre' "pub fn test1<T>() where for<'a> &'a T: Iterator,"
30+
pub fn test1<T>()
31+
where
32+
for<'a> &'a T: Iterator,
33+
{
34+
}
35+
36+
// @has foo/fn.test2.html
37+
// @has - '//pre' "pub fn test2<T>() where for<'a, 'b> &'a T: Trait<'b>,"
38+
pub fn test2<T>()
39+
where
40+
for<'a, 'b> &'a T: Trait<'b>,
41+
{
42+
}
43+
2544
// @has foo/fn.test3.html
2645
// @has - '//pre' "pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8),"
2746
pub fn test3<F>()

tests/expected-output/comprehensive_api.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ pub fn comprehensive_api::functions::return_tuple() -> (bool, Basic)
3737
pub fn comprehensive_api::functions::somewhere<T, U>(t: T, u: U) where T: Display, U: Debug
3838
pub fn comprehensive_api::functions::struct_arg(s: PrivateField)
3939
pub fn comprehensive_api::functions::synthetic_arg(t: impl Simple) -> impl Simple
40+
pub fn comprehensive_api::higher_ranked_trait_bounds::test1<T>() where for<'a> &'a T: Iterator
41+
pub fn comprehensive_api::higher_ranked_trait_bounds::test2<T>() where for<'a, 'b> &'a T: Trait<'b>
4042
pub fn comprehensive_api::higher_ranked_trait_bounds::test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8)
4143
pub fn comprehensive_api::structs::Plain::f()
4244
pub fn comprehensive_api::structs::Plain::new() -> Plain
@@ -85,6 +87,7 @@ pub struct field comprehensive_api::structs::WithLifetimeAndGenericParam::unit_r
8587
pub struct field comprehensive_api::unions::Basic::x: usize
8688
pub struct field comprehensive_api::unions::Basic::y: usize
8789
pub trait comprehensive_api::RngCore
90+
pub trait comprehensive_api::higher_ranked_trait_bounds::Trait<'x>
8891
pub trait comprehensive_api::traits::AssociatedConst
8992
pub trait comprehensive_api::traits::AssociatedConstDefault
9093
pub trait comprehensive_api::traits::AssociatedType

tests/rustdoc-json/example_api-v0.1.0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/rustdoc-json/example_api-v0.2.0.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)