Skip to content

Commit b8deebe

Browse files
authored
Auto merge of #34402 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests - Successful merges: #34356, #34360, #34369, #34371, #34378, #34380, #34391 - Failed merges:
2 parents fe96928 + 0db6575 commit b8deebe

File tree

7 files changed

+85
-7
lines changed

7 files changed

+85
-7
lines changed

src/doc/book/compiler-plugins.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ code that manipulates syntax trees at
3434
compile time.
3535

3636
Let's write a plugin
37-
[`roman_numerals.rs`](https://github.com/rust-lang/rust/tree/master/src/test/auxiliary/roman_numerals.rs)
37+
[`roman_numerals.rs`](https://github.com/rust-lang/rust/blob/master/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs)
3838
that implements Roman numeral integer literals.
3939

4040
```rust,ignore
@@ -166,7 +166,8 @@ quasiquote as an ordinary plugin library.
166166

167167
Plugins can extend [Rust's lint
168168
infrastructure](../reference.html#lint-check-attributes) with additional checks for
169-
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)
169+
code style, safety, etc. Now let's write a plugin
170+
[`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/run-pass-fulldeps/auxiliary/lint_plugin_test.rs)
170171
that warns about any item named `lintme`.
171172

172173
```rust,ignore

src/doc/rustc-ux-guidelines.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,19 @@ Error explanations are long form descriptions of error messages provided with
5656
the compiler. They are accessible via the `--explain` flag. Each explanation
5757
comes with an example of how to trigger it and advice on how to fix it.
5858

59-
* All of them are accessible [online](https://github.com/rust-lang/rust/blob/master/src/librustc/diagnostics.rs).
59+
* All of them are accessible [online](http://doc.rust-lang.org/error-index.html),
60+
which are auto-generated from rustc source code in different places:
61+
[librustc](https://github.com/rust-lang/rust/blob/master/src/librustc/diagnostics.rs),
62+
[librustc_borrowck](https://github.com/rust-lang/rust/blob/master/src/librustc_borrowck/diagnostics.rs),
63+
[librustc_const_eval](https://github.com/rust-lang/rust/blob/master/src/librustc_const_eval/diagnostics.rs),
64+
[librustc_lint](https://github.com/rust-lang/rust/blob/master/src/librustc_lint/types.rs),
65+
[librustc_metadata](https://github.com/rust-lang/rust/blob/master/src/librustc_metadata/diagnostics.rs),
66+
[librustc_mir](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/diagnostics.rs),
67+
[librustc_passes](https://github.com/rust-lang/rust/blob/master/src/librustc_passes/diagnostics.rs),
68+
[librustc_privacy](https://github.com/rust-lang/rust/blob/master/src/librustc_privacy/diagnostics.rs),
69+
[librustc_resolve](https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/diagnostics.rs),
70+
[librustc_trans](https://github.com/rust-lang/rust/blob/master/src/librustc_trans/diagnostics.rs),
71+
[librustc_typeck](https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/diagnostics.rs).
6072
* Explanations have full markdown support. Use it, especially to highlight
6173
code with backticks.
6274
* When talking about the compiler, call it `the compiler`, not `Rust` or

src/etc/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ FROM ubuntu:xenial
44
# Download stage0, see src/bootstrap/bootstrap.py
55
# g++
66
# Compile LLVM binding in src/rustllvm
7+
# gdb
8+
# Used to run tests in src/test/debuginfo
79
# git
810
# Get commit hash and commit date in version string
911
# make
@@ -17,7 +19,7 @@ FROM ubuntu:xenial
1719
# FileCheck is used to run tests in src/test/codegen
1820

1921
RUN apt-get update && apt-get -y install \
20-
curl g++ git make \
22+
curl g++ gdb git make \
2123
libedit-dev zlib1g-dev \
2224
llvm-3.7-tools
2325

src/libcore/ops.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,7 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
16081608
/// See the [`contains()`](#method.contains) method for its characterization.
16091609
///
16101610
/// It cannot serve as an iterator because it doesn't have a starting point.
1611+
///
16111612
/// ```
16121613
/// fn main() {
16131614
/// assert_eq!((..5), std::ops::RangeTo{ end: 5 });

src/librustc_driver/driver.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use rustc::dep_graph::DepGraph;
1212
use rustc::hir;
1313
use rustc::hir::{map as hir_map, FreevarMap, TraitMap};
1414
use rustc::hir::def::DefMap;
15+
use rustc::hir::lowering::lower_crate;
1516
use rustc_mir as mir;
1617
use rustc::mir::mir_map::MirMap;
1718
use rustc::session::{Session, CompileResult, compile_result_from_err_count};
@@ -30,14 +31,12 @@ use rustc_resolve as resolve;
3031
use rustc_metadata::macro_import;
3132
use rustc_metadata::creader::read_local_crates;
3233
use rustc_metadata::cstore::CStore;
33-
use rustc_trans::back::link;
34-
use rustc_trans::back::write;
34+
use rustc_trans::back::{link, write};
3535
use rustc_trans as trans;
3636
use rustc_typeck as typeck;
3737
use rustc_privacy;
3838
use rustc_plugin::registry::Registry;
3939
use rustc_plugin as plugin;
40-
use rustc::hir::lowering::lower_crate;
4140
use rustc_passes::{ast_validation, no_asm, loops, consts, rvalues, static_recursion};
4241
use rustc_const_eval::check_match;
4342
use super::Compilation;

src/libstd/ffi/c_str.rs

+32
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,38 @@ impl CStr {
509509
/// The returned pointer will be valid for as long as `self` is and points
510510
/// to a contiguous region of memory terminated with a 0 byte to represent
511511
/// the end of the string.
512+
///
513+
/// **WARNING**
514+
///
515+
/// It is your responsibility to make sure that the underlying memory is not
516+
/// freed too early. For example, the following code will cause undefined
517+
/// behaviour when `ptr` is used inside the `unsafe` block:
518+
///
519+
/// ```no_run
520+
/// use std::ffi::{CString};
521+
///
522+
/// let ptr = CString::new("Hello").unwrap().as_ptr();
523+
/// unsafe {
524+
/// // `ptr` is dangling
525+
/// *ptr;
526+
/// }
527+
/// ```
528+
///
529+
/// This happens because the pointer returned by `as_ptr` does not carry any
530+
/// lifetime information and the string is deallocated immediately after
531+
/// the `CString::new("Hello").unwrap().as_ptr()` expression is evaluated.
532+
/// To fix the problem, bind the string to a local variable:
533+
///
534+
/// ```no_run
535+
/// use std::ffi::{CString};
536+
///
537+
/// let hello = CString::new("Hello").unwrap();
538+
/// let ptr = hello.as_ptr();
539+
/// unsafe {
540+
/// // `ptr` is valid because `hello` is in scope
541+
/// *ptr;
542+
/// }
543+
/// ```
512544
#[stable(feature = "rust1", since = "1.0.0")]
513545
pub fn as_ptr(&self) -> *const c_char {
514546
self.inner.as_ptr()

src/libstd/thread/mod.rs

+31
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,37 @@ impl Thread {
507507
}
508508

509509
/// Gets the thread's name.
510+
///
511+
/// # Examples
512+
///
513+
/// Threads by default have no name specified:
514+
///
515+
/// ```
516+
/// use std::thread;
517+
///
518+
/// let builder = thread::Builder::new();
519+
///
520+
/// let handler = builder.spawn(|| {
521+
/// assert!(thread::current().name().is_none());
522+
/// }).unwrap();
523+
///
524+
/// handler.join().unwrap();
525+
/// ```
526+
///
527+
/// Thread with a specified name:
528+
///
529+
/// ```
530+
/// use std::thread;
531+
///
532+
/// let builder = thread::Builder::new()
533+
/// .name("foo".into());
534+
///
535+
/// let handler = builder.spawn(|| {
536+
/// assert_eq!(thread::current().name(), Some("foo"))
537+
/// }).unwrap();
538+
///
539+
/// handler.join().unwrap();
540+
/// ```
510541
#[stable(feature = "rust1", since = "1.0.0")]
511542
pub fn name(&self) -> Option<&str> {
512543
self.cname().map(|s| unsafe { str::from_utf8_unchecked(s.to_bytes()) } )

0 commit comments

Comments
 (0)