diff --git a/src/librustdoc/html/highlight/fixtures/sample.html b/src/librustdoc/html/highlight/fixtures/sample.html index aa735e81597c7..773afd5c2cc30 100644 --- a/src/librustdoc/html/highlight/fixtures/sample.html +++ b/src/librustdoc/html/highlight/fixtures/sample.html @@ -32,7 +32,7 @@ } } -macro_rules! bar { +macro_rules! bar { ($foo:tt) => {}; } diff --git a/tests/rustdoc/source-code-highlight.rs b/tests/rustdoc/source-code-highlight.rs new file mode 100644 index 0000000000000..8d7c7782dc5b3 --- /dev/null +++ b/tests/rustdoc/source-code-highlight.rs @@ -0,0 +1,29 @@ +// We need this option to be enabled for the `foo` macro declaration to ensure +// that the link on the ident is not including whitespace characters. + +//@ compile-flags: -Zunstable-options --generate-link-to-definition +#![crate_name = "foo"] + +// @has 'src/foo/source-code-highlight.rs.html' + +// @hasraw - 'foo' +#[macro_export] +macro_rules! foo { + () => {} +} + +// @hasraw - 'foo!' +foo! {} + +// @hasraw - 'f' +#[rustfmt::skip] +pub fn f () {} +// @hasraw - 'Bar' +// @hasraw - 'Bar' +// @hasraw - 'u32' +#[rustfmt::skip] +pub struct Bar ( u32 ); +// @hasraw - 'Foo' +pub enum Foo { + A, +}