about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-07-20 21:21:24 +0000
committerbors <bors@rust-lang.org>2015-07-20 21:21:24 +0000
commited49bad0ccb0e9ee7e5ebea69d72a98bed08f77f (patch)
tree3a0f2dde901395b64521dc6c989354e0bc7d9774 /src/test
parent2fe870a5a7449643f5cf79c0d14d47888472c6ca (diff)
parenta219917e3f762af49f5ccf7a0975122e04f9d764 (diff)
downloadrust-ed49bad0ccb0e9ee7e5ebea69d72a98bed08f77f.tar.gz
rust-ed49bad0ccb0e9ee7e5ebea69d72a98bed08f77f.zip
Auto merge of #27056 - Eljay:doc-comments, r=nikomatsakis
Fixes #23812 by stripping the decoration when desugaring macro doc comments into #[doc] attributes, and detects whether the attribute should be inner or outer style and outputs the appropriate token tree.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/parse-fail/macro-doc-comments-1.rs19
-rw-r--r--src/test/parse-fail/macro-doc-comments-2.rs19
-rw-r--r--src/test/run-pass/macro-doc-comments.rs33
-rw-r--r--src/test/rustdoc/issue-23812.rs46
4 files changed, 117 insertions, 0 deletions
diff --git a/src/test/parse-fail/macro-doc-comments-1.rs b/src/test/parse-fail/macro-doc-comments-1.rs
new file mode 100644
index 00000000000..03bcef4fa5e
--- /dev/null
+++ b/src/test/parse-fail/macro-doc-comments-1.rs
@@ -0,0 +1,19 @@
+// Copyright 2015 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_rules! outer {
+    (#[$outer:meta]) => ()
+}
+
+outer! {
+    //! Inner
+} //~^ ERROR no rules expected the token `!`
+
+fn main() { }
diff --git a/src/test/parse-fail/macro-doc-comments-2.rs b/src/test/parse-fail/macro-doc-comments-2.rs
new file mode 100644
index 00000000000..a1b112c29b6
--- /dev/null
+++ b/src/test/parse-fail/macro-doc-comments-2.rs
@@ -0,0 +1,19 @@
+// Copyright 2015 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_rules! inner {
+    (#![$inner:meta]) => ()
+}
+
+inner! {
+    /// Outer
+} //~^ ERROR no rules expected the token `[`
+
+fn main() { }
diff --git a/src/test/run-pass/macro-doc-comments.rs b/src/test/run-pass/macro-doc-comments.rs
new file mode 100644
index 00000000000..506813df5b3
--- /dev/null
+++ b/src/test/run-pass/macro-doc-comments.rs
@@ -0,0 +1,33 @@
+// Copyright 2015 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_rules! doc {
+    (
+        $(#[$outer:meta])*
+        mod $i:ident {
+            $(#![$inner:meta])*
+        }
+    ) =>
+    (
+        $(#[$outer])*
+        pub mod $i {
+            $(#![$inner])*
+        }
+    )
+}
+
+doc! {
+    /// Outer doc
+    mod Foo {
+        //! Inner doc
+    }
+}
+
+fn main() { }
diff --git a/src/test/rustdoc/issue-23812.rs b/src/test/rustdoc/issue-23812.rs
new file mode 100644
index 00000000000..37f6749694c
--- /dev/null
+++ b/src/test/rustdoc/issue-23812.rs
@@ -0,0 +1,46 @@
+// Copyright 2015 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_rules! doc {
+    (#[$outer:meta] mod $i:ident { #![$inner:meta] }) =>
+    (
+        #[$outer]
+        pub mod $i {
+            #![$inner]
+        }
+    )
+}
+
+doc! {
+    /// Outer comment
+    mod Foo {
+        //! Inner comment
+    }
+}
+
+// @has issue_23812/Foo/index.html
+// @has - 'Outer comment'
+// @!has - '/// Outer comment'
+// @has - 'Inner comment'
+// @!has - '//! Inner comment'
+
+
+doc! {
+    /** Outer block comment */
+    mod Bar {
+        /*! Inner block comment */
+    }
+}
+
+// @has issue_23812/Bar/index.html
+// @has - 'Outer block comment'
+// @!has - '/** Outer block comment */'
+// @has - 'Inner block comment'
+// @!has - '/*! Inner block comment */'