about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-07-17 22:27:37 +0000
committerbors <bors@rust-lang.org>2015-07-17 22:27:37 +0000
commit5df259b9da287043e8284eb53d61a17b89a89bee (patch)
tree474e6bafb9e6dc80a3b89e3561e89198269a2fcf
parente05ac3938bcbdd616930bb010a3bbfa35f22850e (diff)
parent8638dc7f9ae55d9b3102d152b2e2cca92bb83acf (diff)
Auto merge of #27098 - Manishearth:rollup, r=Manishearth
- Successful merges: #26777, #27067, #27071, #27081, #27091, #27094, #27095
- Failed merges: 
-rw-r--r--src/doc/trpl/testing.md5
-rw-r--r--src/libcollections/vec.rs1
-rw-r--r--src/libcollections/vec_deque.rs2
-rw-r--r--src/librustc_resolve/diagnostics.rs60
-rw-r--r--src/librustc_resolve/resolve_imports.rs13
-rw-r--r--src/librustdoc/html/static/main.js4
-rw-r--r--src/libsyntax/ast.rs2
-rw-r--r--src/libsyntax/diagnostics/macros.rs6
-rw-r--r--src/test/run-pass/macro-doc-escapes.rs25
9 files changed, 107 insertions, 11 deletions
diff --git a/src/doc/trpl/testing.md b/src/doc/trpl/testing.md
index 759543140b5..a5a0127031a 100644
--- a/src/doc/trpl/testing.md
+++ b/src/doc/trpl/testing.md
@@ -250,11 +250,10 @@ that our tests are entirely left out of a normal build.
 
 The second change is the `use` declaration. Because we're in an inner module,
 we need to bring our test function into scope. This can be annoying if you have
-a large module, and so this is a common use of the `glob` feature. Let's change
-our `src/lib.rs` to make use of it:
+a large module, and so this is a common use of globs. Let's change our
+`src/lib.rs` to make use of it:
 
 ```rust,ignore
-
 pub fn add_two(a: i32) -> i32 {
     a + 2
 }
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 3848263c530..2127ac11436 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -231,6 +231,7 @@ impl<T> Vec<T> {
     ///
     /// * `ptr` needs to have been previously allocated via `String`/`Vec<T>`
     ///   (at least, it's highly likely to be incorrect if it wasn't).
+    /// * `length` needs to be the length that less than or equal to `capacity`.
     /// * `capacity` needs to be the capacity that the pointer was allocated with.
     ///
     /// Violating these may cause problems like corrupting the allocator's
diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs
index 117b3544f02..5a3778c3656 100644
--- a/src/libcollections/vec_deque.rs
+++ b/src/libcollections/vec_deque.rs
@@ -946,7 +946,7 @@ impl<T> VecDeque<T> {
     /// let mut buf = VecDeque::new();
     /// buf.push_back(10);
     /// buf.push_back(12);
-    /// buf.insert(1,11);
+    /// buf.insert(1, 11);
     /// assert_eq!(Some(&11), buf.get(1));
     /// ```
     pub fn insert(&mut self, i: usize, t: T) {
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 939991da203..c7125c38aa9 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -197,6 +197,64 @@ See the Types section of the reference for more information about the primitive
 types:
 
 http://doc.rust-lang.org/reference.html#types
+"##,
+
+E0364: r##"
+Private items cannot be publicly re-exported.  This error indicates that
+you attempted to `pub use` a type or value that was not itself public.
+
+Here is an example that demonstrates the error:
+
+```
+mod foo {
+    const X: u32 = 1;
+}
+pub use foo::X;
+```
+
+The solution to this problem is to ensure that the items that you are
+re-exporting are themselves marked with `pub`:
+
+```
+mod foo {
+    pub const X: u32 = 1;
+}
+pub use foo::X;
+```
+
+See the 'Use Declarations' section of the reference for more information
+on this topic:
+
+http://doc.rust-lang.org/reference.html#use-declarations
+"##,
+
+E0365: r##"
+Private modules cannot be publicly re-exported.  This error indicates
+that you attempted to `pub use` a module that was not itself public.
+
+Here is an example that demonstrates the error:
+
+```
+mod foo {
+    pub const X: u32 = 1;
+}
+pub use foo as foo2;
+
+```
+The solution to this problem is to ensure that the module that you are
+re-exporting is itself marked with `pub`:
+
+```
+pub mod foo {
+    pub const X: u32 = 1;
+}
+pub use foo as foo2;
+```
+
+See the 'Use Declarations' section of the reference for more information
+on this topic:
+
+http://doc.rust-lang.org/reference.html#use-declarations
 "##
 
 }
@@ -208,8 +266,6 @@ register_diagnostics! {
     E0254, // import conflicts with imported crate in this module
     E0257,
     E0258,
-    E0364, // item is private
-    E0365, // item is private
     E0401, // can't use type parameters from outer function
     E0402, // cannot use an outer type parameter in this context
     E0403, // the name `{}` is already used
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
index e797da7b8f6..ec02963980b 100644
--- a/src/librustc_resolve/resolve_imports.rs
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -434,8 +434,13 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
                     value_result = BoundResult(target_module.clone(),
                                                (*child_name_bindings).clone());
                     if directive.is_public && !child_name_bindings.is_public(ValueNS) {
-                        let msg = format!("`{}` is private", source);
+                        let msg = format!("`{}` is private, and cannot be reexported",
+                                          token::get_name(source));
+                        let note_msg =
+                            format!("Consider marking `{}` as `pub` in the imported module",
+                                    token::get_name(source));
                         span_err!(self.resolver.session, directive.span, E0364, "{}", &msg);
+                        self.resolver.session.span_note(directive.span, &note_msg);
                         pub_err = true;
                     }
                 }
@@ -444,8 +449,12 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
                     type_result = BoundResult(target_module.clone(),
                                               (*child_name_bindings).clone());
                     if !pub_err && directive.is_public && !child_name_bindings.is_public(TypeNS) {
-                        let msg = format!("`{}` is private", source);
+                        let msg = format!("`{}` is private, and cannot be reexported",
+                                          token::get_name(source));
+                        let note_msg = format!("Consider declaring module `{}` as a `pub mod`",
+                                               token::get_name(source));
                         span_err!(self.resolver.session, directive.span, E0365, "{}", &msg);
+                        self.resolver.session.span_note(directive.span, &note_msg);
                     }
                 }
             }
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 1eb1556a25d..b3ad4774091 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -115,7 +115,7 @@
         case "s":
         case "S":
             ev.preventDefault();
-            $(".search-input").focus();
+            focusSearchBar()
             break;
 
         case "?":
@@ -960,5 +960,5 @@
 
 // Sets the focus on the search bar at the top of the page
 function focusSearchBar() {
-    document.getElementsByName('search')[0].focus();
+    $('.search-input').focus();
 }
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index e844b206cc0..a944acad84d 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1104,7 +1104,7 @@ impl TokenTree {
                     tts: vec![TtToken(sp, token::Ident(token::str_to_ident("doc"),
                                                        token::Plain)),
                               TtToken(sp, token::Eq),
-                              TtToken(sp, token::Literal(token::Str_(name), None))],
+                              TtToken(sp, token::Literal(token::StrRaw(name, 0), None))],
                     close_span: sp,
                 }))
             }
diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs
index 055ade46a3f..669b930ecc9 100644
--- a/src/libsyntax/diagnostics/macros.rs
+++ b/src/libsyntax/diagnostics/macros.rs
@@ -63,6 +63,9 @@ macro_rules! fileline_help {
 macro_rules! register_diagnostics {
     ($($code:tt),*) => (
         $(register_diagnostic! { $code })*
+    );
+    ($($code:tt),*,) => (
+        $(register_diagnostic! { $code })*
     )
 }
 
@@ -70,5 +73,8 @@ macro_rules! register_diagnostics {
 macro_rules! register_long_diagnostics {
     ($($code:tt: $description:tt),*) => (
         $(register_diagnostic! { $code, $description })*
+    );
+    ($($code:tt: $description:tt),*,) => (
+        $(register_diagnostic! { $code, $description })*
     )
 }
diff --git a/src/test/run-pass/macro-doc-escapes.rs b/src/test/run-pass/macro-doc-escapes.rs
new file mode 100644
index 00000000000..ea92f0ffebe
--- /dev/null
+++ b/src/test/run-pass/macro-doc-escapes.rs
@@ -0,0 +1,25 @@
+// 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.
+
+// When expanding a macro, documentation attributes (including documentation comments) must be
+// passed "as is" without being parsed. Otherwise, some text will be incorrectly interpreted as
+// escape sequences, leading to an ICE.
+//
+// Related issues: #25929, #25943
+
+macro_rules! homura {
+    (#[$x:meta]) => ()
+}
+
+homura! {
+    /// \madoka \x41
+}
+
+fn main() { }