Skip to content

Commit f4db07e

Browse files
Add test for macro support in "jump to def" feature
1 parent 810254b commit f4db07e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/test/rustdoc/check-source-code-urls-to-def-std.rs

+25
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,28 @@ pub fn foo(a: u32, b: &str, c: String) {
1515
let y: bool = true;
1616
babar();
1717
}
18+
19+
macro_rules! yolo { () => {}}
20+
21+
fn bar(a: i32) {}
22+
23+
macro_rules! bar {
24+
($a:ident) => { bar($a) }
25+
}
26+
27+
macro_rules! data {
28+
($x:expr) => { $x * 2 }
29+
}
30+
31+
pub fn another_foo() {
32+
// This is known limitation: if the macro doesn't generate anything, the visitor
33+
// can't find any item or anything that could tell us that it comes from expansion.
34+
// @!has - '//a[@href="../../src/foo/check-source-code-urls-to-def-std.rs.html#19"]' 'yolo!'
35+
yolo!();
36+
// @has - '//a[@href="{{channel}}/std/macro.eprintln.html"]' 'eprintln!'
37+
eprintln!();
38+
// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def-std.rs.html#27-29"]' 'data!'
39+
let x = data!(4);
40+
// @has - '//a[@href="../../src/foo/check-source-code-urls-to-def-std.rs.html#23-25"]' 'bar!'
41+
bar!(x);
42+
}

0 commit comments

Comments
 (0)