diff options
| author | bors <bors@rust-lang.org> | 2016-02-14 10:10:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-02-14 10:10:50 +0000 |
| commit | 083dc5b12d6d29e5d88f6446664968d1f868562d (patch) | |
| tree | 7b6f545ccaf5e9f02e73493d24ae3d9a26af2ef4 | |
| parent | 86e6e3235ee0df25ce41dcb48a08387125d31d35 (diff) | |
| parent | a31d63320f20abddce1adc1a0e4d24b8063992bb (diff) | |
| download | rust-083dc5b12d6d29e5d88f6446664968d1f868562d.tar.gz rust-083dc5b12d6d29e5d88f6446664968d1f868562d.zip | |
Auto merge of #31614 - mitaa:rdoc_locitem_extmac, r=alexcrichton
fixes #26606 r? @alexcrichton
| -rw-r--r-- | src/librustdoc/html/render.rs | 16 | ||||
| -rw-r--r-- | src/test/auxiliary/issue-26606-macro.rs | 14 | ||||
| -rw-r--r-- | src/test/rustdoc/issue-26606.rs | 21 |
3 files changed, 46 insertions, 5 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index e432da3dcaf..592414dd169 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1501,11 +1501,17 @@ impl<'a> Item<'a> { true, |component| { path.push(component.to_string()); }); - Some(format!("{root}src/{krate}/{path}.html#{href}", - root = self.cx.root_path, - krate = self.cx.layout.krate, - path = path.join("/"), - href = href)) + // If the span points into an external macro the + // source-file will be bogus, i.e `<foo macros>` + if Path::new(&self.item.source.filename).is_file() { + Some(format!("{root}src/{krate}/{path}.html#{href}", + root = self.cx.root_path, + krate = self.cx.layout.krate, + path = path.join("/"), + href = href)) + } else { + None + } // If this item is not part of the local crate, then things get a little // trickier. We don't actually know the span of the external item, but diff --git a/src/test/auxiliary/issue-26606-macro.rs b/src/test/auxiliary/issue-26606-macro.rs new file mode 100644 index 00000000000..6059a252bce --- /dev/null +++ b/src/test/auxiliary/issue-26606-macro.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_export] +macro_rules! make_item ( + ($name: ident) => (pub const $name: usize = 42;) +); diff --git a/src/test/rustdoc/issue-26606.rs b/src/test/rustdoc/issue-26606.rs new file mode 100644 index 00000000000..df40c01686d --- /dev/null +++ b/src/test/rustdoc/issue-26606.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-26606-macro.rs +// ignore-cross-compile +// build-aux-docs + +// @has issue_26606_macro/macro.make_item!.html +#[macro_use] +extern crate issue_26606_macro; + +// @has issue_26606/constant.FOO.html +// @!has - '//a/@href' '../src/' +make_item!(FOO); |
