From 7d8ca6d4fc650535480dda4faffa8078e2b1206c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 6 Nov 2024 15:50:37 +0000 Subject: [PATCH] Clean middle generics using paren sugar if trait has rustc_paren_sugar --- src/librustdoc/clean/utils.rs | 2 +- tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs | 1 + .../inline_cross/auxiliary/assoc_item_trait_bounds.rs | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index d3a545fe0b61f..560831197f05f 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -206,7 +206,7 @@ fn clean_middle_generic_args_with_constraints<'tcx>( ) -> GenericArgs { let args = clean_middle_generic_args(cx, ty_args.map_bound(|args| &args[..]), has_self, did); - if cx.tcx.fn_trait_kind_from_def_id(did).is_some() { + if cx.tcx.is_trait(did) && cx.tcx.trait_def(did).paren_sugar { let ty = ty_args .iter() .nth(if has_self { 1 } else { 0 }) diff --git a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs index 346f7120b5b90..d301c35599427 100644 --- a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs @@ -22,6 +22,7 @@ extern crate assoc_item_trait_bounds as aux; //@ has - '//*[@id="associatedtype.Out12"]' "type Out12: for<'w> Helper = Cow<'w, str>, A<'w> = bool>" //@ has - '//*[@id="associatedtype.Out13"]' "type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>" //@ has - '//*[@id="associatedtype.Out14"]' "type Out14" +//@ has - '//*[@id="associatedtype.Out15"]' "type Out15: AsyncFnMut(i32) -> bool" // // Snapshots: // Check that we don't render any where-clauses for the following associated types since diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs index 551e97a2fa9ac..56708ec9310e8 100644 --- a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs @@ -1,3 +1,7 @@ +#![feature(async_closure)] + +use std::ops::AsyncFnMut; + pub trait Main { type Item; @@ -16,6 +20,7 @@ pub trait Main { type Out12: for<'w> Helper = std::borrow::Cow<'w, str>, A<'w> = bool>; type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>; type Out14; + type Out15: AsyncFnMut(i32) -> bool; fn make(_: F, _: impl FnMut(&str) -> bool) where