File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -232,8 +232,13 @@ pub(crate) fn token_as_doc_comment(doc_token: &SyntaxToken) -> Option<DocComment
232232 ( match_ast ! {
233233 match doc_token {
234234 ast:: Comment ( comment) => TextSize :: try_from( comment. prefix( ) . len( ) ) . ok( ) ,
235- ast:: String ( string) => doc_token. parent_ancestors( ) . find_map( ast:: Attr :: cast)
236- . filter( |attr| attr. simple_name( ) . as_deref( ) == Some ( "doc" ) ) . and_then( |_| string. open_quote_text_range( ) . map( |it| it. len( ) ) ) ,
235+ ast:: String ( string) => {
236+ doc_token. parent_ancestors( ) . find_map( ast:: Attr :: cast) . filter( |attr| attr. simple_name( ) . as_deref( ) == Some ( "doc" ) ) ?;
237+ if doc_token. parent_ancestors( ) . find_map( ast:: MacroCall :: cast) . filter( |mac| mac. path( ) . and_then( |p| p. segment( ) ?. name_ref( ) ) . as_ref( ) . map( |n| n. text( ) ) . as_deref( ) == Some ( "include_str" ) ) . is_some( ) {
238+ return None ;
239+ }
240+ string. open_quote_text_range( ) . map( |it| it. len( ) )
241+ } ,
237242 _ => None ,
238243 }
239244 } ) . map ( |prefix_len| DocCommentToken { prefix_len, doc_token : doc_token. clone ( ) } )
Original file line number Diff line number Diff line change @@ -1367,6 +1367,24 @@ fn main() {
13671367 ) ;
13681368 }
13691369
1370+ #[ test]
1371+ fn goto_doc_include_str ( ) {
1372+ check (
1373+ r#"
1374+ //- /main.rs
1375+ #[rustc_builtin_macro]
1376+ macro_rules! include_str {}
1377+
1378+ #[doc = include_str!("docs.md$0")]
1379+ struct Item;
1380+
1381+ //- /docs.md
1382+ // docs
1383+ //^file
1384+ "# ,
1385+ ) ;
1386+ }
1387+
13701388 #[ test]
13711389 fn goto_shadow_include ( ) {
13721390 check (
You can’t perform that action at this time.
0 commit comments