11use clean:: AttributesExt ;
22
3- use std:: cmp:: Ordering ;
4- use std:: fmt;
5- use std:: rc:: Rc ;
6-
73use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
84use rustc_hir as hir;
95use rustc_hir:: def:: CtorKind ;
@@ -15,6 +11,9 @@ use rustc_middle::ty::{Adt, TyCtxt};
1511use rustc_span:: hygiene:: MacroKind ;
1612use rustc_span:: symbol:: { kw, sym, Symbol } ;
1713use rustc_target:: abi:: { Layout , Primitive , TagEncoding , Variants } ;
14+ use std:: cmp:: Ordering ;
15+ use std:: fmt;
16+ use std:: rc:: Rc ;
1817
1918use super :: {
2019 collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_section,
@@ -37,6 +36,7 @@ use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
3736use crate :: html:: url_parts_builder:: UrlPartsBuilder ;
3837
3938use askama:: Template ;
39+ use itertools:: Itertools ;
4040
4141const ITEM_TABLE_OPEN : & str = "<div class=\" item-table\" >" ;
4242const ITEM_TABLE_CLOSE : & str = "</div>" ;
@@ -539,6 +539,8 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
539539 let count_types = required_types. len ( ) + provided_types. len ( ) ;
540540 let count_consts = required_consts. len ( ) + provided_consts. len ( ) ;
541541 let count_methods = required_methods. len ( ) + provided_methods. len ( ) ;
542+ let must_implement_one_of_functions =
543+ cx. tcx ( ) . trait_def ( t. def_id ) . must_implement_one_of . clone ( ) ;
542544
543545 // Output the trait definition
544546 wrap_into_docblock ( w, |w| {
@@ -784,13 +786,22 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
784786 }
785787
786788 // Output the documentation for each function individually
787- if !required_methods. is_empty ( ) {
789+ if !required_methods. is_empty ( ) || must_implement_one_of_functions . is_some ( ) {
788790 write_small_section_header (
789791 w,
790792 "required-methods" ,
791793 "Required Methods" ,
792794 "<div class=\" methods\" >" ,
793795 ) ;
796+
797+ if let Some ( list) = must_implement_one_of_functions. as_deref ( ) {
798+ write ! (
799+ w,
800+ "<div class=\" stab must_implement\" >At least one of {} methods is required.</div>" ,
801+ list. iter( ) . join( ", " )
802+ ) ;
803+ }
804+
794805 for m in required_methods {
795806 trait_item ( w, cx, m, it) ;
796807 }
0 commit comments