This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 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};
3333fluent_messages ! {
3434 borrowck => "../locales/en-US/borrowck.ftl" ,
3535 builtin_macros => "../locales/en-US/builtin_macros.ftl" ,
36+ const_eval => "../locales/en-US/const_eval.ftl" ,
37+ expand => "../locales/en-US/expand.ftl" ,
3638 lint => "../locales/en-US/lint.ftl" ,
3739 parser => "../locales/en-US/parser.ftl" ,
3840 privacy => "../locales/en-US/privacy.ftl" ,
3941 typeck => "../locales/en-US/typeck.ftl" ,
40- const_eval => "../locales/en-US/const_eval.ftl" ,
4142}
4243
4344pub 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(
594594 ( mk_syn_ext ( expander) , rule_spans)
595595}
596596
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+
597611fn annotate_doc_comment (
598612 err : & mut DiagnosticBuilder < ' _ , ErrorGuaranteed > ,
599613 sm : & SourceMap ,
600614 span : Span ,
601615) {
602616 if let Ok ( src) = sm. span_to_snippet ( span) {
603617 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 } ) ;
605619 } 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 } ) ;
607621 }
608622 }
609623}
You can’t perform that action at this time.
0 commit comments