diff --git a/src/doc/trpl/testing.md b/src/doc/trpl/testing.md index 759543140b57..a5a0127031ae 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 3848263c5309..2127ac11436b 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -231,6 +231,7 @@ impl Vec { /// /// * `ptr` needs to have been previously allocated via `String`/`Vec` /// (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 117b3544f026..5a3778c3656f 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -946,7 +946,7 @@ impl VecDeque { /// 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 939991da2030..c7125c38aa97 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 e797da7b8f64..ec02963980bd 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, ¬e_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, ¬e_msg); } } } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1eb1556a25d2..b3ad4774091f 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 e844b206cc0a..a944acad84df 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 055ade46a3f0..669b930ecc92 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 000000000000..ea92f0ffebe6 --- /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 or the MIT license +// , 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() { }