File tree 3 files changed +23
-3
lines changed
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change
1
+ expand-explain-doc-comment-outer =
2
+ outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match
3
+
4
+ expand-explain-doc-comment-inner =
5
+ inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match
Original file line number Diff line number Diff line change @@ -33,11 +33,12 @@ pub use unic_langid::{langid, LanguageIdentifier};
33
33
fluent_messages ! {
34
34
borrowck => "../locales/en-US/borrowck.ftl" ,
35
35
builtin_macros => "../locales/en-US/builtin_macros.ftl" ,
36
+ const_eval => "../locales/en-US/const_eval.ftl" ,
37
+ expand => "../locales/en-US/expand.ftl" ,
36
38
lint => "../locales/en-US/lint.ftl" ,
37
39
parser => "../locales/en-US/parser.ftl" ,
38
40
privacy => "../locales/en-US/privacy.ftl" ,
39
41
typeck => "../locales/en-US/typeck.ftl" ,
40
- const_eval => "../locales/en-US/const_eval.ftl" ,
41
42
}
42
43
43
44
pub use fluent_generated:: { self as fluent, DEFAULT_LOCALE_RESOURCES } ;
Original file line number Diff line number Diff line change @@ -594,16 +594,30 @@ pub fn compile_declarative_macro(
594
594
( mk_syn_ext ( expander) , rule_spans)
595
595
}
596
596
597
+ #[ derive( SessionSubdiagnostic ) ]
598
+ enum ExplainDocComment {
599
+ #[ label( expand:: explain_doc_comment_inner) ]
600
+ Inner {
601
+ #[ primary_span]
602
+ span : Span ,
603
+ } ,
604
+ #[ label( expand:: explain_doc_comment_outer) ]
605
+ Outer {
606
+ #[ primary_span]
607
+ span : Span ,
608
+ } ,
609
+ }
610
+
597
611
fn annotate_doc_comment (
598
612
err : & mut DiagnosticBuilder < ' _ , ErrorGuaranteed > ,
599
613
sm : & SourceMap ,
600
614
span : Span ,
601
615
) {
602
616
if let Ok ( src) = sm. span_to_snippet ( span) {
603
617
if src. starts_with ( "///" ) || src. starts_with ( "/**" ) {
604
- err. span_label ( span , "outer doc comments expand to `#[doc = \" ... \" ]`, which is what this macro attempted to match" ) ;
618
+ err. subdiagnostic ( ExplainDocComment :: Outer { span } ) ;
605
619
} else if src. starts_with ( "//!" ) || src. starts_with ( "/*!" ) {
606
- err. span_label ( span , "inner doc comments expand to `#![doc = \" ... \" ]`, which is what this macro attempted to match" ) ;
620
+ err. subdiagnostic ( ExplainDocComment :: Inner { span } ) ;
607
621
}
608
622
}
609
623
}
You can’t perform that action at this time.
0 commit comments