From 1bf1eeac6e15a5cb3d84d94e8db5ab376e5a0186 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 14 Feb 2014 13:11:36 -0800 Subject: [PATCH] Update restrictions on rustdoc source rendering The std macros used to be injected with a filename of "", but macros are now injected with a filename of "<{} macros>" where `{}` is filled in with the crate name. This updates rustdoc to understand this new system so it'll render source more frequently. --- src/librustdoc/html/render.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 29773c60a87e2..10b2287793614 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -418,8 +418,10 @@ impl<'a> SourceCollector<'a> { // can't have the source to it anyway. let contents = match File::open(&p).read_to_end() { Ok(r) => r, - // eew macro hacks - Err(..) if filename == "" => return Ok(()), + // macros from other libraries get special filenames which we can + // safely ignore + Err(..) if filename.starts_with("<") && + filename.ends_with("macros>") => return Ok(()), Err(e) => return Err(e) }; let contents = str::from_utf8_owned(contents).unwrap();