Skip to content

Commit 544a6bb

Browse files
committed
Replace &DocCtxt -> TyCtxt in macro matcher rendering
1 parent 336c85a commit 544a6bb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/librustdoc/clean/utils.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -486,22 +486,22 @@ crate const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
486486
/// Render a sequence of macro arms in a format suitable for displaying to the user
487487
/// as part of an item declaration.
488488
pub(super) fn render_macro_arms<'a>(
489-
cx: &DocContext<'_>,
489+
tcx: TyCtxt<'_>,
490490
matchers: impl Iterator<Item = &'a TokenTree>,
491491
arm_delim: &str,
492492
) -> String {
493493
let mut out = String::new();
494494
for matcher in matchers {
495-
writeln!(out, " {} => {{ ... }}{}", render_macro_matcher(cx, matcher), arm_delim)
495+
writeln!(out, " {} => {{ ... }}{}", render_macro_matcher(tcx, matcher), arm_delim)
496496
.unwrap();
497497
}
498498
out
499499
}
500500

501501
/// Render a macro matcher in a format suitable for displaying to the user
502502
/// 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) {
505505
snippet
506506
} else {
507507
rustc_ast_pretty::pprust::tt_to_string(matcher)
@@ -510,11 +510,11 @@ pub(super) fn render_macro_matcher(cx: &DocContext<'_>, matcher: &TokenTree) ->
510510

511511
/// Find the source snippet for this token's Span, reparse it, and return the
512512
/// 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> {
514514
// Find what rustc thinks is the source snippet.
515515
// This may not actually be anything meaningful if this matcher was itself
516516
// generated by a macro.
517-
let source_map = cx.sess().source_map();
517+
let source_map = tcx.sess.source_map();
518518
let span = matcher.span();
519519
let snippet = source_map.span_to_snippet(span).ok()?;
520520

@@ -561,21 +561,21 @@ pub(super) fn display_macro_source(
561561
let matchers = tts.chunks(4).map(|arm| &arm[0]);
562562

563563
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, ";"))
565565
} else {
566566
if matchers.len() <= 1 {
567567
format!(
568568
"{}macro {}{} {{\n ...\n}}",
569569
vis.to_src_with_space(cx.tcx, def_id),
570570
name,
571-
matchers.map(|matcher| render_macro_matcher(cx, matcher)).collect::<String>(),
571+
matchers.map(|matcher| render_macro_matcher(cx.tcx, matcher)).collect::<String>(),
572572
)
573573
} else {
574574
format!(
575575
"{}macro {} {{\n{}}}",
576576
vis.to_src_with_space(cx.tcx, def_id),
577577
name,
578-
render_macro_arms(cx, matchers, ","),
578+
render_macro_arms(cx.tcx, matchers, ","),
579579
)
580580
}
581581
}

0 commit comments

Comments
 (0)