@@ -486,22 +486,22 @@ crate const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
486
486
/// Render a sequence of macro arms in a format suitable for displaying to the user
487
487
/// as part of an item declaration.
488
488
pub ( super ) fn render_macro_arms < ' a > (
489
- cx : & DocContext < ' _ > ,
489
+ tcx : TyCtxt < ' _ > ,
490
490
matchers : impl Iterator < Item = & ' a TokenTree > ,
491
491
arm_delim : & str ,
492
492
) -> String {
493
493
let mut out = String :: new ( ) ;
494
494
for matcher in matchers {
495
- writeln ! ( out, " {} => {{ ... }}{}" , render_macro_matcher( cx , matcher) , arm_delim)
495
+ writeln ! ( out, " {} => {{ ... }}{}" , render_macro_matcher( tcx , matcher) , arm_delim)
496
496
. unwrap ( ) ;
497
497
}
498
498
out
499
499
}
500
500
501
501
/// Render a macro matcher in a format suitable for displaying to the user
502
502
/// as part of an item declaration.
503
- pub ( super ) fn render_macro_matcher ( cx : & DocContext < ' _ > , matcher : & TokenTree ) -> String {
504
- if let Some ( snippet) = snippet_equal_to_token ( cx , matcher) {
503
+ pub ( super ) fn render_macro_matcher ( tcx : TyCtxt < ' _ > , matcher : & TokenTree ) -> String {
504
+ if let Some ( snippet) = snippet_equal_to_token ( tcx , matcher) {
505
505
snippet
506
506
} else {
507
507
rustc_ast_pretty:: pprust:: tt_to_string ( matcher)
@@ -510,11 +510,11 @@ pub(super) fn render_macro_matcher(cx: &DocContext<'_>, matcher: &TokenTree) ->
510
510
511
511
/// Find the source snippet for this token's Span, reparse it, and return the
512
512
/// snippet if the reparsed TokenTree matches the argument TokenTree.
513
- fn snippet_equal_to_token ( cx : & DocContext < ' _ > , matcher : & TokenTree ) -> Option < String > {
513
+ fn snippet_equal_to_token ( tcx : TyCtxt < ' _ > , matcher : & TokenTree ) -> Option < String > {
514
514
// Find what rustc thinks is the source snippet.
515
515
// This may not actually be anything meaningful if this matcher was itself
516
516
// generated by a macro.
517
- let source_map = cx . sess ( ) . source_map ( ) ;
517
+ let source_map = tcx . sess . source_map ( ) ;
518
518
let span = matcher. span ( ) ;
519
519
let snippet = source_map. span_to_snippet ( span) . ok ( ) ?;
520
520
@@ -561,21 +561,21 @@ pub(super) fn display_macro_source(
561
561
let matchers = tts. chunks ( 4 ) . map ( |arm| & arm[ 0 ] ) ;
562
562
563
563
if def. macro_rules {
564
- format ! ( "macro_rules! {} {{\n {}}}" , name, render_macro_arms( cx, matchers, ";" ) )
564
+ format ! ( "macro_rules! {} {{\n {}}}" , name, render_macro_arms( cx. tcx , matchers, ";" ) )
565
565
} else {
566
566
if matchers. len ( ) <= 1 {
567
567
format ! (
568
568
"{}macro {}{} {{\n ...\n }}" ,
569
569
vis. to_src_with_space( cx. tcx, def_id) ,
570
570
name,
571
- matchers. map( |matcher| render_macro_matcher( cx, matcher) ) . collect:: <String >( ) ,
571
+ matchers. map( |matcher| render_macro_matcher( cx. tcx , matcher) ) . collect:: <String >( ) ,
572
572
)
573
573
} else {
574
574
format ! (
575
575
"{}macro {} {{\n {}}}" ,
576
576
vis. to_src_with_space( cx. tcx, def_id) ,
577
577
name,
578
- render_macro_arms( cx, matchers, "," ) ,
578
+ render_macro_arms( cx. tcx , matchers, "," ) ,
579
579
)
580
580
}
581
581
}
0 commit comments