diff --git a/src/doc/book/compiler-plugins.md b/src/doc/book/compiler-plugins.md index 2d0cc61fb11d6..5b75ad6cfa858 100644 --- a/src/doc/book/compiler-plugins.md +++ b/src/doc/book/compiler-plugins.md @@ -34,7 +34,7 @@ code that manipulates syntax trees at compile time. Let's write a plugin -[`roman_numerals.rs`](https://github.com/rust-lang/rust/tree/master/src/test/auxiliary/roman_numerals.rs) +[`roman_numerals.rs`](https://github.com/rust-lang/rust/blob/master/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs) that implements Roman numeral integer literals. ```rust,ignore @@ -166,7 +166,8 @@ quasiquote as an ordinary plugin library. Plugins can extend [Rust's lint infrastructure](../reference.html#lint-check-attributes) with additional checks for -code style, safety, etc. Now let's write a plugin [`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/auxiliary/lint_plugin_test.rs) +code style, safety, etc. Now let's write a plugin +[`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/run-pass-fulldeps/auxiliary/lint_plugin_test.rs) that warns about any item named `lintme`. ```rust,ignore diff --git a/src/doc/rustc-ux-guidelines.md b/src/doc/rustc-ux-guidelines.md index 6fc7219cdb368..15b3bfebfac2e 100644 --- a/src/doc/rustc-ux-guidelines.md +++ b/src/doc/rustc-ux-guidelines.md @@ -56,7 +56,19 @@ Error explanations are long form descriptions of error messages provided with the compiler. They are accessible via the `--explain` flag. Each explanation comes with an example of how to trigger it and advice on how to fix it. -* All of them are accessible [online](https://github.com/rust-lang/rust/blob/master/src/librustc/diagnostics.rs). +* All of them are accessible [online](http://doc.rust-lang.org/error-index.html), + which are auto-generated from rustc source code in different places: + [librustc](https://github.com/rust-lang/rust/blob/master/src/librustc/diagnostics.rs), + [librustc_borrowck](https://github.com/rust-lang/rust/blob/master/src/librustc_borrowck/diagnostics.rs), + [librustc_const_eval](https://github.com/rust-lang/rust/blob/master/src/librustc_const_eval/diagnostics.rs), + [librustc_lint](https://github.com/rust-lang/rust/blob/master/src/librustc_lint/types.rs), + [librustc_metadata](https://github.com/rust-lang/rust/blob/master/src/librustc_metadata/diagnostics.rs), + [librustc_mir](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/diagnostics.rs), + [librustc_passes](https://github.com/rust-lang/rust/blob/master/src/librustc_passes/diagnostics.rs), + [librustc_privacy](https://github.com/rust-lang/rust/blob/master/src/librustc_privacy/diagnostics.rs), + [librustc_resolve](https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/diagnostics.rs), + [librustc_trans](https://github.com/rust-lang/rust/blob/master/src/librustc_trans/diagnostics.rs), + [librustc_typeck](https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/diagnostics.rs). * Explanations have full markdown support. Use it, especially to highlight code with backticks. * When talking about the compiler, call it `the compiler`, not `Rust` or diff --git a/src/etc/Dockerfile b/src/etc/Dockerfile index 58fa1474444a1..f1c56d8d3960f 100644 --- a/src/etc/Dockerfile +++ b/src/etc/Dockerfile @@ -4,6 +4,8 @@ FROM ubuntu:xenial # Download stage0, see src/bootstrap/bootstrap.py # g++ # Compile LLVM binding in src/rustllvm +# gdb +# Used to run tests in src/test/debuginfo # git # Get commit hash and commit date in version string # make @@ -17,7 +19,7 @@ FROM ubuntu:xenial # FileCheck is used to run tests in src/test/codegen RUN apt-get update && apt-get -y install \ - curl g++ git make \ + curl g++ gdb git make \ libedit-dev zlib1g-dev \ llvm-3.7-tools diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 5e1210b2ff9bd..7258c8a1b6b3d 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -1608,6 +1608,7 @@ impl> RangeFrom { /// See the [`contains()`](#method.contains) method for its characterization. /// /// It cannot serve as an iterator because it doesn't have a starting point. +/// /// ``` /// fn main() { /// assert_eq!((..5), std::ops::RangeTo{ end: 5 }); diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index e31a1f1624fe1..927953b034ba2 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -12,6 +12,7 @@ use rustc::dep_graph::DepGraph; use rustc::hir; use rustc::hir::{map as hir_map, FreevarMap, TraitMap}; use rustc::hir::def::DefMap; +use rustc::hir::lowering::lower_crate; use rustc_mir as mir; use rustc::mir::mir_map::MirMap; use rustc::session::{Session, CompileResult, compile_result_from_err_count}; @@ -30,14 +31,12 @@ use rustc_resolve as resolve; use rustc_metadata::macro_import; use rustc_metadata::creader::read_local_crates; use rustc_metadata::cstore::CStore; -use rustc_trans::back::link; -use rustc_trans::back::write; +use rustc_trans::back::{link, write}; use rustc_trans as trans; use rustc_typeck as typeck; use rustc_privacy; use rustc_plugin::registry::Registry; use rustc_plugin as plugin; -use rustc::hir::lowering::lower_crate; use rustc_passes::{ast_validation, no_asm, loops, consts, rvalues, static_recursion}; use rustc_const_eval::check_match; use super::Compilation; diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 2bc7585f5fba9..0d3e18f9b966a 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -509,6 +509,38 @@ impl CStr { /// The returned pointer will be valid for as long as `self` is and points /// to a contiguous region of memory terminated with a 0 byte to represent /// the end of the string. + /// + /// **WARNING** + /// + /// It is your responsibility to make sure that the underlying memory is not + /// freed too early. For example, the following code will cause undefined + /// behaviour when `ptr` is used inside the `unsafe` block: + /// + /// ```no_run + /// use std::ffi::{CString}; + /// + /// let ptr = CString::new("Hello").unwrap().as_ptr(); + /// unsafe { + /// // `ptr` is dangling + /// *ptr; + /// } + /// ``` + /// + /// This happens because the pointer returned by `as_ptr` does not carry any + /// lifetime information and the string is deallocated immediately after + /// the `CString::new("Hello").unwrap().as_ptr()` expression is evaluated. + /// To fix the problem, bind the string to a local variable: + /// + /// ```no_run + /// use std::ffi::{CString}; + /// + /// let hello = CString::new("Hello").unwrap(); + /// let ptr = hello.as_ptr(); + /// unsafe { + /// // `ptr` is valid because `hello` is in scope + /// *ptr; + /// } + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn as_ptr(&self) -> *const c_char { self.inner.as_ptr() diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index c474aa60b3ee4..1f78b32bcf38e 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -507,6 +507,37 @@ impl Thread { } /// Gets the thread's name. + /// + /// # Examples + /// + /// Threads by default have no name specified: + /// + /// ``` + /// use std::thread; + /// + /// let builder = thread::Builder::new(); + /// + /// let handler = builder.spawn(|| { + /// assert!(thread::current().name().is_none()); + /// }).unwrap(); + /// + /// handler.join().unwrap(); + /// ``` + /// + /// Thread with a specified name: + /// + /// ``` + /// use std::thread; + /// + /// let builder = thread::Builder::new() + /// .name("foo".into()); + /// + /// let handler = builder.spawn(|| { + /// assert_eq!(thread::current().name(), Some("foo")) + /// }).unwrap(); + /// + /// handler.join().unwrap(); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn name(&self) -> Option<&str> { self.cname().map(|s| unsafe { str::from_utf8_unchecked(s.to_bytes()) } )