Skip to content

Commit 4a3ab8b

Browse files
committed
Auto merge of #50003 - kennytm:rollup, r=kennytm
Rollup of 8 pull requests Successful merges: - #49555 (Inline most of the code paths for conversions with boxed slices) - #49606 (Prevent broken pipes causing ICEs) - #49646 (Use box syntax instead of Box::new in Mutex::remutex on Windows) - #49647 (Remove `underscore_lifetimes` and `match_default_bindings` from active feature list) - #49931 (Fix incorrect span in `&mut` suggestion) - #49959 (rustbuild: allow building tools with debuginfo) - #49965 (Remove warning about f64->f32 cast being potential UB) - #49994 (Remove unnecessary indentation in rustdoc book codeblock.) Failed merges:
2 parents 49317cd + bf16e4b commit 4a3ab8b

File tree

21 files changed

+86
-45
lines changed

21 files changed

+86
-45
lines changed

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ configuration used in the build process. Some options to note:
121121
#### `[rust]`:
122122
- `debuginfo = true` - Build a compiler with debuginfo. Makes building rustc slower, but then you can use a debugger to debug `rustc`.
123123
- `debuginfo-lines = true` - An alternative to `debuginfo = true` that doesn't let you use a debugger, but doesn't make building rustc slower and still gives you line numbers in backtraces.
124+
- `debuginfo-tools = true` - Build the extended tools with debuginfo.
124125
- `debug-assertions = true` - Makes the log output of `debug!` work.
125126
- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust, but makes the stage1 compiler x100 slower.
126127

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@
262262
# standard library.
263263
#debuginfo-only-std = false
264264

265+
# Enable debuginfo for the extended tools: cargo, rls, rustfmt
266+
# Adding debuginfo makes them several times larger.
267+
#debuginfo-tools = false
268+
265269
# Whether or not jemalloc is built and enabled
266270
#use-jemalloc = true
267271

src/bootstrap/builder.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,14 @@ impl<'a> Builder<'a> {
622622
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
623623
}
624624

625-
if mode != Mode::Tool {
626-
// Tools don't get debuginfo right now, e.g. cargo and rls don't
627-
// get compiled with debuginfo.
628-
// Adding debuginfo increases their sizes by a factor of 3-4.
625+
if mode == Mode::Tool {
626+
// Tools like cargo and rls don't get debuginfo by default right now, but this can be
627+
// enabled in the config. Adding debuginfo makes them several times larger.
628+
if self.config.rust_debuginfo_tools {
629+
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
630+
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
631+
}
632+
} else {
629633
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
630634
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
631635
cargo.env("RUSTC_FORCE_UNSTABLE", "1");

src/bootstrap/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub struct Config {
9494
pub rust_debuginfo: bool,
9595
pub rust_debuginfo_lines: bool,
9696
pub rust_debuginfo_only_std: bool,
97+
pub rust_debuginfo_tools: bool,
9798
pub rust_rpath: bool,
9899
pub rustc_parallel_queries: bool,
99100
pub rustc_default_linker: Option<String>,
@@ -282,6 +283,7 @@ struct Rust {
282283
debuginfo: Option<bool>,
283284
debuginfo_lines: Option<bool>,
284285
debuginfo_only_std: Option<bool>,
286+
debuginfo_tools: Option<bool>,
285287
experimental_parallel_queries: Option<bool>,
286288
debug_jemalloc: Option<bool>,
287289
use_jemalloc: Option<bool>,
@@ -462,6 +464,7 @@ impl Config {
462464
let mut llvm_assertions = None;
463465
let mut debuginfo_lines = None;
464466
let mut debuginfo_only_std = None;
467+
let mut debuginfo_tools = None;
465468
let mut debug = None;
466469
let mut debug_jemalloc = None;
467470
let mut debuginfo = None;
@@ -499,6 +502,7 @@ impl Config {
499502
debuginfo = rust.debuginfo;
500503
debuginfo_lines = rust.debuginfo_lines;
501504
debuginfo_only_std = rust.debuginfo_only_std;
505+
debuginfo_tools = rust.debuginfo_tools;
502506
optimize = rust.optimize;
503507
ignore_git = rust.ignore_git;
504508
debug_jemalloc = rust.debug_jemalloc;
@@ -582,6 +586,7 @@ impl Config {
582586
};
583587
config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default);
584588
config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default);
589+
config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false);
585590

586591
let default = debug == Some(true);
587592
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def v(*args):
7979
o("debuginfo", "rust.debuginfo", "build with debugger metadata")
8080
o("debuginfo-lines", "rust.debuginfo-lines", "build with line number debugger metadata")
8181
o("debuginfo-only-std", "rust.debuginfo-only-std", "build only libstd with debugging information")
82+
o("debuginfo-tools", "rust.debuginfo-tools", "build extended tools with debugging information")
8283
o("debug-jemalloc", "rust.debug-jemalloc", "build jemalloc with --enable-debug --enable-fill")
8384
v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file")
8485

src/doc/rustdoc/src/documentation-tests.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,31 @@ To keep each code block testable, we want the whole program in each block, but
138138
we don't want the reader to see every line every time. Here's what we put in
139139
our source code:
140140
141-
```text
142-
First, we set `x` to five:
141+
``````markdown
142+
First, we set `x` to five:
143143
144-
```
145-
let x = 5;
146-
# let y = 6;
147-
# println!("{}", x + y);
148-
```
144+
```
145+
let x = 5;
146+
# let y = 6;
147+
# println!("{}", x + y);
148+
```
149149
150-
Next, we set `y` to six:
150+
Next, we set `y` to six:
151151
152-
```
153-
# let x = 5;
154-
let y = 6;
155-
# println!("{}", x + y);
156-
```
152+
```
153+
# let x = 5;
154+
let y = 6;
155+
# println!("{}", x + y);
156+
```
157157
158-
Finally, we print the sum of `x` and `y`:
158+
Finally, we print the sum of `x` and `y`:
159159
160-
```
161-
# let x = 5;
162-
# let y = 6;
163-
println!("{}", x + y);
164-
```
165160
```
161+
# let x = 5;
162+
# let y = 6;
163+
println!("{}", x + y);
164+
```
165+
``````
166166
167167
By repeating all parts of the example, you can ensure that your example still
168168
compiles, while only showing the parts that are relevant to that part of your

src/liballoc/boxed.rs

+2
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,15 @@ impl<'a, T: Copy> From<&'a [T]> for Box<[T]> {
429429

430430
#[stable(feature = "box_from_slice", since = "1.17.0")]
431431
impl<'a> From<&'a str> for Box<str> {
432+
#[inline]
432433
fn from(s: &'a str) -> Box<str> {
433434
unsafe { from_boxed_utf8_unchecked(Box::from(s.as_bytes())) }
434435
}
435436
}
436437

437438
#[stable(feature = "boxed_str_conv", since = "1.19.0")]
438439
impl From<Box<str>> for Box<[u8]> {
440+
#[inline]
439441
fn from(s: Box<str>) -> Self {
440442
unsafe { Box::from_raw(Box::into_raw(s) as *mut [u8]) }
441443
}

src/liballoc/str.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,7 @@ impl str {
18271827
/// assert_eq!(*boxed_bytes, *s.as_bytes());
18281828
/// ```
18291829
#[stable(feature = "str_box_extras", since = "1.20.0")]
1830+
#[inline]
18301831
pub fn into_boxed_bytes(self: Box<str>) -> Box<[u8]> {
18311832
self.into()
18321833
}
@@ -2065,6 +2066,7 @@ impl str {
20652066
/// assert_eq!(boxed_str.into_string(), string);
20662067
/// ```
20672068
#[stable(feature = "box_str", since = "1.4.0")]
2069+
#[inline]
20682070
pub fn into_string(self: Box<str>) -> String {
20692071
let slice = Box::<[u8]>::from(self);
20702072
unsafe { String::from_utf8_unchecked(slice.into_vec()) }
@@ -2323,6 +2325,7 @@ impl str {
23232325
/// assert_eq!("☺", &*smile);
23242326
/// ```
23252327
#[stable(feature = "str_box_extras", since = "1.20.0")]
2328+
#[inline]
23262329
pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> {
23272330
Box::from_raw(Box::into_raw(v) as *mut str)
23282331
}

src/liballoc/string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,7 @@ impl String {
15861586
/// let b = s.into_boxed_str();
15871587
/// ```
15881588
#[stable(feature = "box_str", since = "1.4.0")]
1589+
#[inline]
15891590
pub fn into_boxed_str(self) -> Box<str> {
15901591
let slice = self.vec.into_boxed_slice();
15911592
unsafe { from_boxed_utf8_unchecked(slice) }

src/liballoc/vec.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,9 @@ impl<T> Vec<T> {
583583
/// ```
584584
#[stable(feature = "rust1", since = "1.0.0")]
585585
pub fn shrink_to_fit(&mut self) {
586-
self.buf.shrink_to_fit(self.len);
586+
if self.capacity() != self.len {
587+
self.buf.shrink_to_fit(self.len);
588+
}
587589
}
588590

589591
/// Shrinks the capacity of the vector with a lower bound.

src/librustc_driver/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,18 @@ fn run_compiler_impl<'a>(args: &[String],
547547
(result, Some(sess))
548548
}
549549

550+
#[cfg(unix)]
551+
pub fn set_sigpipe_handler() {
552+
unsafe {
553+
// Set the SIGPIPE signal handler, so that an EPIPE
554+
// will cause rustc to terminate, as expected.
555+
assert!(libc::signal(libc::SIGPIPE, libc::SIG_DFL) != libc::SIG_ERR);
556+
}
557+
}
558+
559+
#[cfg(windows)]
560+
pub fn set_sigpipe_handler() {}
561+
550562
// Extract output directory and file from matches.
551563
fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>) {
552564
let odir = matches.opt_str("out-dir").map(|o| PathBuf::from(&o));

src/librustc_mir/borrow_check/mod.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -1639,10 +1639,18 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16391639
} else {
16401640
self.get_default_err_msg(place)
16411641
};
1642+
let sp = self.mir.source_info(locations[0]).span;
1643+
let mut to_suggest_span = String::new();
1644+
if let Ok(src) =
1645+
self.tcx.sess.codemap().span_to_snippet(sp) {
1646+
to_suggest_span = src[1..].to_string();
1647+
};
16421648
err_info = Some((
1643-
self.mir.source_info(locations[0]).span,
1649+
sp,
16441650
"consider changing this to be a \
1645-
mutable reference: `&mut`", item_msg,
1651+
mutable reference",
1652+
to_suggest_span,
1653+
item_msg,
16461654
self.get_primary_err_msg(base)));
16471655
}
16481656
},
@@ -1652,9 +1660,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16521660
_ => {},
16531661
}
16541662

1655-
if let Some((err_help_span, err_help_stmt, item_msg, sec_span)) = err_info {
1663+
if let Some((err_help_span,
1664+
err_help_stmt,
1665+
to_suggest_span,
1666+
item_msg,
1667+
sec_span)) = err_info {
16561668
let mut err = self.tcx.cannot_assign(span, &item_msg, Origin::Mir);
1657-
err.span_suggestion(err_help_span, err_help_stmt, format!(""));
1669+
err.span_suggestion(err_help_span,
1670+
err_help_stmt,
1671+
format!("&mut {}", to_suggest_span));
16581672
if place != place_err {
16591673
err.span_label(span, sec_span);
16601674
}

src/librustc_trans/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![feature(slice_sort_by_cached_key)]
3030
#![feature(optin_builtin_traits)]
3131
#![feature(inclusive_range_fields)]
32-
#![feature(underscore_lifetimes)]
3332

3433
use rustc::dep_graph::WorkProduct;
3534
use syntax_pos::symbol::Symbol;

src/librustc_typeck/check/demand.rs

-4
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
502502
&format!("{}, producing the closest possible value",
503503
msg),
504504
cast_suggestion);
505-
err.warn("casting here will cause undefined behavior if the value is \
506-
finite but larger or smaller than the largest or smallest \
507-
finite value representable by `f32` (this is a bug and will be \
508-
fixed)");
509505
}
510506
true
511507
}

src/librustc_typeck/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ This API is completely unstable and subject to change.
8282
#![feature(slice_patterns)]
8383
#![feature(slice_sort_by_cached_key)]
8484
#![feature(dyn_trait)]
85-
#![feature(underscore_lifetimes)]
8685

8786
#[macro_use] extern crate log;
8887
#[macro_use] extern crate syntax;

src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct Output {
100100

101101
pub fn main() {
102102
const STACK_SIZE: usize = 32_000_000; // 32MB
103+
rustc_driver::set_sigpipe_handler();
103104
env_logger::init();
104105
let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
105106
syntax::with_globals(move || {

src/libstd/sys/unix/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ pub fn init() {
8080
reset_sigpipe();
8181
}
8282

83-
#[cfg(not(any(target_os = "emscripten", target_os="fuchsia")))]
83+
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia")))]
8484
unsafe fn reset_sigpipe() {
8585
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
8686
}
87-
#[cfg(any(target_os = "emscripten", target_os="fuchsia"))]
87+
#[cfg(any(target_os = "emscripten", target_os = "fuchsia"))]
8888
unsafe fn reset_sigpipe() {}
8989
}
9090

src/libstd/sys/windows/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl Mutex {
117117
0 => {}
118118
n => return n as *mut _,
119119
}
120-
let mut re = Box::new(ReentrantMutex::uninitialized());
120+
let mut re = box ReentrantMutex::uninitialized();
121121
re.init();
122122
let re = Box::into_raw(re);
123123
match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) {

src/libsyntax/feature_gate.rs

-6
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,6 @@ declare_features! (
378378
// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
379379
(active, non_exhaustive, "1.22.0", Some(44109), None),
380380

381-
// allow `'_` placeholder lifetimes
382-
(active, underscore_lifetimes, "1.22.0", Some(44524), None),
383-
384-
// Default match binding modes (RFC 2005)
385-
(active, match_default_bindings, "1.22.0", Some(42640), None),
386-
387381
// Trait object syntax with `dyn` prefix
388382
(active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),
389383

src/rustc/rustc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ extern {}
2323

2424
extern crate rustc_driver;
2525

26-
fn main() { rustc_driver::main() }
26+
fn main() {
27+
rustc_driver::set_sigpipe_handler();
28+
rustc_driver::main()
29+
}

src/test/ui/nll/issue-47388.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0594]: cannot assign to data in a `&` reference
22
--> $DIR/issue-47388.rs:18:5
33
|
44
LL | let fancy_ref = &(&mut fancy);
5-
| ------------- help: consider changing this to be a mutable reference: `&mut`
5+
| ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)`
66
LL | fancy_ref.num = 6; //~ ERROR E0594
77
| ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written
88

0 commit comments

Comments
 (0)