From 5406cbfb1c498812de69200c9ad8db2b5b25eff7 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Sat, 22 Jan 2022 14:46:19 +0800 Subject: [PATCH] Do not display hidden `~const Drop` bounds --- src/librustdoc/html/format.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 3aa8421456b8..f703a6789493 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -279,7 +279,24 @@ crate fn print_where_clause<'a, 'tcx: 'a>( clause.push_str(" where"); } } - for (i, pred) in gens.where_predicates.iter().enumerate() { + + #[derive(Clone, Copy)] + enum Print<'a> { + Predicate(&'a clean::WherePredicate), + Comma, + } + + for pred in gens.where_predicates.iter().filter(|pred| { + !matches!(pred, clean::WherePredicate::BoundPredicate { bounds, .. } if bounds.is_empty()) + }).map(Print::Predicate).intersperse(Print::Comma) { + let pred = match pred { + Print::Predicate(pred) => pred, + Print::Comma => { + clause.push(','); + continue; + } + }; + if f.alternate() { clause.push(' '); } else { @@ -338,13 +355,10 @@ crate fn print_where_clause<'a, 'tcx: 'a>( } } } - - if i < gens.where_predicates.len() - 1 || end_newline { - clause.push(','); - } } if end_newline { + clause.push(','); // add a space so stripping
tags and breaking spaces still renders properly if f.alternate() { clause.push(' ');