diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a62405f059..73d4188d695 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -121,6 +121,7 @@ configuration used in the build process. Some options to note: #### `[rust]`: - `debuginfo = true` - Build a compiler with debuginfo. Makes building rustc slower, but then you can use a debugger to debug `rustc`. - `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. +- `debuginfo-tools = true` - Build the extended tools with debuginfo. - `debug-assertions = true` - Makes the log output of `debug!` work. - `optimize = false` - Disable optimizations to speed up compilation of stage1 rust, but makes the stage1 compiler x100 slower. diff --git a/config.toml.example b/config.toml.example index 68bc7dfe720..effe0084381 100644 --- a/config.toml.example +++ b/config.toml.example @@ -262,6 +262,10 @@ # standard library. #debuginfo-only-std = false +# Enable debuginfo for the extended tools: cargo, rls, rustfmt +# Adding debuginfo makes them several times larger. +#debuginfo-tools = false + # Whether or not jemalloc is built and enabled #use-jemalloc = true diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 7ff64af9196..6874efa5a4c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -622,10 +622,14 @@ impl<'a> Builder<'a> { cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build))); } - if mode != Mode::Tool { - // Tools don't get debuginfo right now, e.g. cargo and rls don't - // get compiled with debuginfo. - // Adding debuginfo increases their sizes by a factor of 3-4. + if mode == Mode::Tool { + // Tools like cargo and rls don't get debuginfo by default right now, but this can be + // enabled in the config. Adding debuginfo makes them several times larger. + if self.config.rust_debuginfo_tools { + cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()); + cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string()); + } + } else { cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()); cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string()); cargo.env("RUSTC_FORCE_UNSTABLE", "1"); diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 239316d45c4..1b4b2c5fb2a 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -94,6 +94,7 @@ pub struct Config { pub rust_debuginfo: bool, pub rust_debuginfo_lines: bool, pub rust_debuginfo_only_std: bool, + pub rust_debuginfo_tools: bool, pub rust_rpath: bool, pub rustc_parallel_queries: bool, pub rustc_default_linker: Option, @@ -282,6 +283,7 @@ struct Rust { debuginfo: Option, debuginfo_lines: Option, debuginfo_only_std: Option, + debuginfo_tools: Option, experimental_parallel_queries: Option, debug_jemalloc: Option, use_jemalloc: Option, @@ -462,6 +464,7 @@ impl Config { let mut llvm_assertions = None; let mut debuginfo_lines = None; let mut debuginfo_only_std = None; + let mut debuginfo_tools = None; let mut debug = None; let mut debug_jemalloc = None; let mut debuginfo = None; @@ -499,6 +502,7 @@ impl Config { debuginfo = rust.debuginfo; debuginfo_lines = rust.debuginfo_lines; debuginfo_only_std = rust.debuginfo_only_std; + debuginfo_tools = rust.debuginfo_tools; optimize = rust.optimize; ignore_git = rust.ignore_git; debug_jemalloc = rust.debug_jemalloc; @@ -582,6 +586,7 @@ impl Config { }; config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default); config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default); + config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false); let default = debug == Some(true); config.debug_jemalloc = debug_jemalloc.unwrap_or(default); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index b06968d313b..a0123da6d8f 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -79,6 +79,7 @@ o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger o("debuginfo", "rust.debuginfo", "build with debugger metadata") o("debuginfo-lines", "rust.debuginfo-lines", "build with line number debugger metadata") o("debuginfo-only-std", "rust.debuginfo-only-std", "build only libstd with debugging information") +o("debuginfo-tools", "rust.debuginfo-tools", "build extended tools with debugging information") o("debug-jemalloc", "rust.debug-jemalloc", "build jemalloc with --enable-debug --enable-fill") v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file") diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md index fea8685a605..3098587a8a4 100644 --- a/src/doc/rustdoc/src/documentation-tests.md +++ b/src/doc/rustdoc/src/documentation-tests.md @@ -138,31 +138,31 @@ To keep each code block testable, we want the whole program in each block, but we don't want the reader to see every line every time. Here's what we put in our source code: -```text - First, we set `x` to five: +``````markdown +First, we set `x` to five: - ``` - let x = 5; - # let y = 6; - # println!("{}", x + y); - ``` - - Next, we set `y` to six: - - ``` - # let x = 5; - let y = 6; - # println!("{}", x + y); - ``` - - Finally, we print the sum of `x` and `y`: - - ``` - # let x = 5; - # let y = 6; - println!("{}", x + y); - ``` ``` +let x = 5; +# let y = 6; +# println!("{}", x + y); +``` + +Next, we set `y` to six: + +``` +# let x = 5; +let y = 6; +# println!("{}", x + y); +``` + +Finally, we print the sum of `x` and `y`: + +``` +# let x = 5; +# let y = 6; +println!("{}", x + y); +``` +`````` By repeating all parts of the example, you can ensure that your example still compiles, while only showing the parts that are relevant to that part of your diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index aceb6ff8abe..5ebd2cc6146 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -429,6 +429,7 @@ impl<'a, T: Copy> From<&'a [T]> for Box<[T]> { #[stable(feature = "box_from_slice", since = "1.17.0")] impl<'a> From<&'a str> for Box { + #[inline] fn from(s: &'a str) -> Box { unsafe { from_boxed_utf8_unchecked(Box::from(s.as_bytes())) } } @@ -436,6 +437,7 @@ impl<'a> From<&'a str> for Box { #[stable(feature = "boxed_str_conv", since = "1.19.0")] impl From> for Box<[u8]> { + #[inline] fn from(s: Box) -> Self { unsafe { Box::from_raw(Box::into_raw(s) as *mut [u8]) } } diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 6c9f3dd7ec9..0e708465332 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -1827,6 +1827,7 @@ impl str { /// assert_eq!(*boxed_bytes, *s.as_bytes()); /// ``` #[stable(feature = "str_box_extras", since = "1.20.0")] + #[inline] pub fn into_boxed_bytes(self: Box) -> Box<[u8]> { self.into() } @@ -2065,6 +2066,7 @@ impl str { /// assert_eq!(boxed_str.into_string(), string); /// ``` #[stable(feature = "box_str", since = "1.4.0")] + #[inline] pub fn into_string(self: Box) -> String { let slice = Box::<[u8]>::from(self); unsafe { String::from_utf8_unchecked(slice.into_vec()) } @@ -2323,6 +2325,7 @@ impl str { /// assert_eq!("☺", &*smile); /// ``` #[stable(feature = "str_box_extras", since = "1.20.0")] +#[inline] pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box { Box::from_raw(Box::into_raw(v) as *mut str) } diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 0924ca24791..11fb82c09d3 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1586,6 +1586,7 @@ impl String { /// let b = s.into_boxed_str(); /// ``` #[stable(feature = "box_str", since = "1.4.0")] + #[inline] pub fn into_boxed_str(self) -> Box { let slice = self.vec.into_boxed_slice(); unsafe { from_boxed_utf8_unchecked(slice) } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 8ab25dfe7d8..7d1b2ed85c7 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -583,7 +583,9 @@ impl Vec { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn shrink_to_fit(&mut self) { - self.buf.shrink_to_fit(self.len); + if self.capacity() != self.len { + self.buf.shrink_to_fit(self.len); + } } /// Shrinks the capacity of the vector with a lower bound. diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 3dec84d174d..cb91ff6a43e 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -547,6 +547,18 @@ fn run_compiler_impl<'a>(args: &[String], (result, Some(sess)) } +#[cfg(unix)] +pub fn set_sigpipe_handler() { + unsafe { + // Set the SIGPIPE signal handler, so that an EPIPE + // will cause rustc to terminate, as expected. + assert!(libc::signal(libc::SIGPIPE, libc::SIG_DFL) != libc::SIG_ERR); + } +} + +#[cfg(windows)] +pub fn set_sigpipe_handler() {} + // Extract output directory and file from matches. fn make_output(matches: &getopts::Matches) -> (Option, Option) { let odir = matches.opt_str("out-dir").map(|o| PathBuf::from(&o)); diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 62acdf76546..87379651c23 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1639,10 +1639,18 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } else { self.get_default_err_msg(place) }; + let sp = self.mir.source_info(locations[0]).span; + let mut to_suggest_span = String::new(); + if let Ok(src) = + self.tcx.sess.codemap().span_to_snippet(sp) { + to_suggest_span = src[1..].to_string(); + }; err_info = Some(( - self.mir.source_info(locations[0]).span, + sp, "consider changing this to be a \ - mutable reference: `&mut`", item_msg, + mutable reference", + to_suggest_span, + item_msg, self.get_primary_err_msg(base))); } }, @@ -1652,9 +1660,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { _ => {}, } - if let Some((err_help_span, err_help_stmt, item_msg, sec_span)) = err_info { + if let Some((err_help_span, + err_help_stmt, + to_suggest_span, + item_msg, + sec_span)) = err_info { let mut err = self.tcx.cannot_assign(span, &item_msg, Origin::Mir); - err.span_suggestion(err_help_span, err_help_stmt, format!("")); + err.span_suggestion(err_help_span, + err_help_stmt, + format!("&mut {}", to_suggest_span)); if place != place_err { err.span_label(span, sec_span); } diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index a38d51e7546..49d0f638f20 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -29,7 +29,6 @@ #![feature(slice_sort_by_cached_key)] #![feature(optin_builtin_traits)] #![feature(inclusive_range_fields)] -#![feature(underscore_lifetimes)] use rustc::dep_graph::WorkProduct; use syntax_pos::symbol::Symbol; diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index ecfe1416050..c0d6993c7d4 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -502,10 +502,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { &format!("{}, producing the closest possible value", msg), cast_suggestion); - err.warn("casting here will cause undefined behavior if the value is \ - finite but larger or smaller than the largest or smallest \ - finite value representable by `f32` (this is a bug and will be \ - fixed)"); } true } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index a4477e80b98..4b66939963e 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -82,7 +82,6 @@ This API is completely unstable and subject to change. #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] #![feature(dyn_trait)] -#![feature(underscore_lifetimes)] #[macro_use] extern crate log; #[macro_use] extern crate syntax; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 1339a66f8b2..148a57c420f 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -100,6 +100,7 @@ struct Output { pub fn main() { const STACK_SIZE: usize = 32_000_000; // 32MB + rustc_driver::set_sigpipe_handler(); env_logger::init(); let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || { syntax::with_globals(move || { diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 9bdea945ea4..c1298e5040d 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -80,11 +80,11 @@ pub fn init() { reset_sigpipe(); } - #[cfg(not(any(target_os = "emscripten", target_os="fuchsia")))] + #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia")))] unsafe fn reset_sigpipe() { assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR); } - #[cfg(any(target_os = "emscripten", target_os="fuchsia"))] + #[cfg(any(target_os = "emscripten", target_os = "fuchsia"))] unsafe fn reset_sigpipe() {} } diff --git a/src/libstd/sys/windows/mutex.rs b/src/libstd/sys/windows/mutex.rs index 85560368590..9bf9f749d4d 100644 --- a/src/libstd/sys/windows/mutex.rs +++ b/src/libstd/sys/windows/mutex.rs @@ -117,7 +117,7 @@ impl Mutex { 0 => {} n => return n as *mut _, } - let mut re = Box::new(ReentrantMutex::uninitialized()); + let mut re = box ReentrantMutex::uninitialized(); re.init(); let re = Box::into_raw(re); match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 73ebfc20876..eaa2050f608 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -378,12 +378,6 @@ declare_features! ( // Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008) (active, non_exhaustive, "1.22.0", Some(44109), None), - // allow `'_` placeholder lifetimes - (active, underscore_lifetimes, "1.22.0", Some(44524), None), - - // Default match binding modes (RFC 2005) - (active, match_default_bindings, "1.22.0", Some(42640), None), - // Trait object syntax with `dyn` prefix (active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)), diff --git a/src/rustc/rustc.rs b/src/rustc/rustc.rs index a888838ce43..ab5a7c3f747 100644 --- a/src/rustc/rustc.rs +++ b/src/rustc/rustc.rs @@ -23,4 +23,7 @@ extern {} extern crate rustc_driver; -fn main() { rustc_driver::main() } +fn main() { + rustc_driver::set_sigpipe_handler(); + rustc_driver::main() +} diff --git a/src/test/ui/nll/issue-47388.stderr b/src/test/ui/nll/issue-47388.stderr index 272cb6510aa..f3952c49a2a 100644 --- a/src/test/ui/nll/issue-47388.stderr +++ b/src/test/ui/nll/issue-47388.stderr @@ -2,7 +2,7 @@ error[E0594]: cannot assign to data in a `&` reference --> $DIR/issue-47388.rs:18:5 | LL | let fancy_ref = &(&mut fancy); - | ------------- help: consider changing this to be a mutable reference: `&mut` + | ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)` LL | fancy_ref.num = 6; //~ ERROR E0594 | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written