@@ -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 ;
@@ -881,7 +882,24 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
881882 /// already seen an inlining attribute for this item.
882883 /// If so, `specified_inline` holds the value and the span of
883884 /// the first `inline`/`no_inline` attribute.
884- fn check_doc_inline ( & self , span : Span , hir_id : HirId , target : Target ) {
885+ fn check_doc_inline ( & self , hir_id : HirId , target : Target , inline : & [ ( DocInline , Span ) ] ) {
886+ let span = match inline {
887+ [ ] => return ,
888+ [ ( _, span) ] => * span,
889+ [ ( inline, span) , rest @ ..] => {
890+ for ( inline2, span2) in rest {
891+ if inline2 != inline {
892+ let mut spans = MultiSpan :: from_spans ( vec ! [ * span, * span2] ) ;
893+ spans. push_span_label ( * span, fluent:: passes_doc_inline_conflict_first) ;
894+ spans. push_span_label ( * span2, fluent:: passes_doc_inline_conflict_second) ;
895+ self . dcx ( ) . emit_err ( errors:: DocInlineConflict { spans } ) ;
896+ return ;
897+ }
898+ }
899+ * span
900+ }
901+ } ;
902+
885903 match target {
886904 Target :: Use | Target :: ExternCrate => { }
887905 _ => {
@@ -1050,9 +1068,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
10501068 }
10511069 }
10521070
1053- if let Some ( ( _, span) ) = inline {
1054- self . check_doc_inline ( * span, hir_id, target)
1055- }
1071+ self . check_doc_inline ( hir_id, target, inline) ;
10561072
10571073 if let Some ( span) = rust_logo {
10581074 if self . check_attr_crate_level ( * span, hir_id)
0 commit comments