From 301401e568e6ed297ab0b06c5cf60d8ba8109750 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 16 Aug 2016 14:25:12 +1200 Subject: [PATCH] Redirect --- src/librustdoc/html/render.rs | 10 ++++++++++ src/test/rustdoc/macros.rs | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index d654429146d83..e02cfb96dddf1 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1426,6 +1426,16 @@ impl Context { .open(&redir_dst) { try_err!(layout::redirect(&mut redirect_out, file_name), &redir_dst); } + + // If the item is a macro, redirect from the old macro URL (with !) + // to the new one (without). + // FIXME(#35705) remove this redirect. + if item_type == ItemType::Macro { + let redir_name = format!("{}.{}!.html", item_type, name); + let redir_dst = self.dst.join(redir_name); + let mut redirect_out = try_err!(File::create(&redir_dst), &redir_dst); + try_err!(layout::redirect(&mut redirect_out, file_name), &redir_dst); + } } } Ok(()) diff --git a/src/test/rustdoc/macros.rs b/src/test/rustdoc/macros.rs index f4115d8229a54..9aeeb71707c90 100644 --- a/src/test/rustdoc/macros.rs +++ b/src/test/rustdoc/macros.rs @@ -12,6 +12,8 @@ // @has - //pre '() => { ... };' // @has - //pre '($a:tt) => { ... };' // @has - //pre '($e:expr) => { ... };' +// @has macros/macro.my_macro!.html +// @has - //a 'macro.my_macro.html' #[macro_export] macro_rules! my_macro { () => [];