@@ -13,13 +13,14 @@ use rustc_abi::{Align, ExternAbi, Size};
1313use rustc_ast:: { AttrStyle , LitKind , MetaItemKind , ast} ;
1414use rustc_attr_parsing:: { AttributeParser , Late } ;
1515use rustc_data_structures:: fx:: FxHashMap ;
16- use rustc_errors:: { DiagCtxtHandle , IntoDiagArg , StashKey } ;
16+ use rustc_errors:: { DiagCtxtHandle , IntoDiagArg , MultiSpan , StashKey } ;
1717use rustc_feature:: {
1818 ACCEPTED_LANG_FEATURES , AttributeDuplicates , AttributeType , BUILTIN_ATTRIBUTE_MAP ,
1919 BuiltinAttribute ,
2020} ;
2121use rustc_hir:: attrs:: {
22- AttributeKind , DocAttribute , InlineAttr , MirDialect , MirPhase , ReprAttr , SanitizerSet ,
22+ AttributeKind , DocAttribute , DocInline , InlineAttr , MirDialect , MirPhase , ReprAttr ,
23+ SanitizerSet ,
2324} ;
2425use rustc_hir:: def:: DefKind ;
2526use rustc_hir:: def_id:: LocalModDefId ;
@@ -877,7 +878,24 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
877878 /// already seen an inlining attribute for this item.
878879 /// If so, `specified_inline` holds the value and the span of
879880 /// the first `inline`/`no_inline` attribute.
880- fn check_doc_inline ( & self , span : Span , hir_id : HirId , target : Target ) {
881+ fn check_doc_inline ( & self , hir_id : HirId , target : Target , inline : & [ ( DocInline , Span ) ] ) {
882+ let span = match inline {
883+ [ ] => return ,
884+ [ ( _, span) ] => * span,
885+ [ ( inline, span) , rest @ ..] => {
886+ for ( inline2, span2) in rest {
887+ if inline2 != inline {
888+ let mut spans = MultiSpan :: from_spans ( vec ! [ * span, * span2] ) ;
889+ spans. push_span_label ( * span, fluent:: passes_doc_inline_conflict_first) ;
890+ spans. push_span_label ( * span2, fluent:: passes_doc_inline_conflict_second) ;
891+ self . dcx ( ) . emit_err ( errors:: DocInlineConflict { spans } ) ;
892+ return ;
893+ }
894+ }
895+ * span
896+ }
897+ } ;
898+
881899 match target {
882900 Target :: Use | Target :: ExternCrate => { }
883901 _ => {
@@ -1046,9 +1064,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
10461064 }
10471065 }
10481066
1049- if let Some ( ( _, span) ) = inline {
1050- self . check_doc_inline ( * span, hir_id, target)
1051- }
1067+ self . check_doc_inline ( hir_id, target, inline) ;
10521068
10531069 if let Some ( span) = rust_logo {
10541070 if self . check_attr_crate_level ( * span, hir_id)
0 commit comments