From fb9fa5ba3ee08171e7d2ff35d28ec0dd93b0287b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 3 Jul 2020 12:12:50 +0200 Subject: [PATCH 01/20] adjust ub-enum test to be endianess-independent --- src/test/ui/consts/const-eval/ub-enum.rs | 5 +++-- src/test/ui/consts/const-eval/ub-enum.stderr | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/ui/consts/const-eval/ub-enum.rs b/src/test/ui/consts/const-eval/ub-enum.rs index c49997c6c33f6..136b33208c293 100644 --- a/src/test/ui/consts/const-eval/ub-enum.rs +++ b/src/test/ui/consts/const-eval/ub-enum.rs @@ -88,9 +88,10 @@ const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute //~^ ERROR is undefined behavior // All variants are uninhabited but also have data. -const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(1u64) }; +// Use `0` as constant to make behavior endianess-independent. +const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; //~^ ERROR is undefined behavior -const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(1u64) }; +const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; //~^ ERROR is undefined behavior fn main() { diff --git a/src/test/ui/consts/const-eval/ub-enum.stderr b/src/test/ui/consts/const-eval/ub-enum.stderr index 1f7593c6db9b6..9c29aa1a51d1c 100644 --- a/src/test/ui/consts/const-eval/ub-enum.stderr +++ b/src/test/ui/consts/const-eval/ub-enum.stderr @@ -87,18 +87,18 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:91:1 + --> $DIR/ub-enum.rs:92:1 | -LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(1u64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of the never type `!` at ..0.1 +LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Never at ..0.1 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-enum.rs:93:1 + --> $DIR/ub-enum.rs:94:1 | -LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(1u64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Never at ..0.1 +LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of the never type `!` at ..0.1 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. From bcef848a6971217d4b8df50c17e047174018d316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sun, 5 Jul 2020 00:00:00 +0000 Subject: [PATCH 02/20] Explain effects of debugging options from config.toml Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com> --- config.toml.example | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config.toml.example b/config.toml.example index 2fa613755d64c..79e4e46d85ba3 100644 --- a/config.toml.example +++ b/config.toml.example @@ -318,7 +318,9 @@ #codegen-units-std = 1 # Whether or not debug assertions are enabled for the compiler and standard -# library. +# library. Debug assertions control the maximum log level used by rustc. When +# enabled calls to `trace!` and `debug!` macros are preserved in the compiled +# binary, otherwise they are omitted. # # Defaults to rust.debug value #debug-assertions = false @@ -331,7 +333,9 @@ # Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`. # `0` - no debug info -# `1` - line tables only +# `1` - line tables only - sufficient to generate backtraces that include line +# information and inlined functions, set breakpoints at source code +# locations, and step through execution in a debugger. # `2` - full debug info with variable and type information # Can be overridden for specific subsets of Rust code (rustc, std or tools). # Debuginfo for tests run with compiletest is not controlled by this option From 6b59cac1197fafda31951aa05a55b0dd7871400f Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum Date: Mon, 6 Jul 2020 14:32:30 -0400 Subject: [PATCH 03/20] Suppress debuginfo on naked function arguments A function that has no prologue cannot be reasonably expected to support debuginfo. In fact, the existing code (before this patch) would generate invalid instructions that caused crashes. We can solve this easily by just not emitting the debuginfo in this case. Fixes https://github.com/rust-lang/rust/issues/42779 cc https://github.com/rust-lang/rust/issues/32408 --- src/librustc_mir_build/build/mod.rs | 12 +++++++++++- src/test/codegen/naked-functions.rs | 4 ++-- src/test/debuginfo/function-arguments.rs | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index e69f6b30abd5c..d6dd3711dba19 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -10,6 +10,7 @@ use rustc_hir::lang_items; use rustc_hir::{GeneratorKind, HirIdMap, Node}; use rustc_index::vec::{Idx, IndexVec}; use rustc_infer::infer::TyCtxtInferExt; +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::region; use rustc_middle::mir::*; use rustc_middle::ty::subst::Subst; @@ -790,12 +791,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { argument_scope: region::Scope, ast_body: &'tcx hir::Expr<'tcx>, ) -> BlockAnd<()> { + let tcx = self.hir.tcx(); + let attrs = tcx.codegen_fn_attrs(fn_def_id); + let naked = attrs.flags.contains(CodegenFnAttrFlags::NAKED); + // Allocate locals for the function arguments for &ArgInfo(ty, _, arg_opt, _) in arguments.iter() { let source_info = SourceInfo::outermost(arg_opt.map_or(self.fn_span, |arg| arg.pat.span)); let arg_local = self.local_decls.push(LocalDecl::with_source_info(ty, source_info)); + // Emit function argument debuginfo only for non-naked functions. + // See: https://github.com/rust-lang/rust/issues/42779 + if naked { + continue; + } + // If this is a simple binding pattern, give debuginfo a nice name. if let Some(arg) = arg_opt { if let Some(ident) = arg.pat.simple_ident() { @@ -808,7 +819,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - let tcx = self.hir.tcx(); let tcx_hir = tcx.hir(); let hir_tables = self.hir.tables(); diff --git a/src/test/codegen/naked-functions.rs b/src/test/codegen/naked-functions.rs index 493c1b9f0ba6b..758c6c4da9293 100644 --- a/src/test/codegen/naked-functions.rs +++ b/src/test/codegen/naked-functions.rs @@ -18,7 +18,7 @@ pub fn naked_empty() { // CHECK-NEXT: define void @naked_with_args(i{{[0-9]+( %0)?}}) pub fn naked_with_args(a: isize) { // CHECK-NEXT: {{.+}}: - // CHECK-NEXT: %a = alloca i{{[0-9]+}} + // CHECK-NEXT: %_1 = alloca i{{[0-9]+}} &a; // keep variable in an alloca // CHECK: ret void } @@ -39,7 +39,7 @@ pub fn naked_with_return() -> isize { #[naked] pub fn naked_with_args_and_return(a: isize) -> isize { // CHECK-NEXT: {{.+}}: - // CHECK-NEXT: %a = alloca i{{[0-9]+}} + // CHECK-NEXT: %_1 = alloca i{{[0-9]+}} &a; // keep variable in an alloca // CHECK: ret i{{[0-9]+}} %{{[0-9]+}} a diff --git a/src/test/debuginfo/function-arguments.rs b/src/test/debuginfo/function-arguments.rs index 5cfd7d1f8f198..fb0bbbf371d8e 100644 --- a/src/test/debuginfo/function-arguments.rs +++ b/src/test/debuginfo/function-arguments.rs @@ -18,6 +18,10 @@ // gdb-check:$4 = 3000 // gdb-command:continue +// gdb-command:info args +// gdb-check:No arguments. +// gdb-command:continue + // === LLDB TESTS ================================================================================== // lldb-command:run @@ -38,7 +42,12 @@ // lldbr-check:(i64) b = 3000 // lldb-command:continue +// lldb-command:frame variable +// lldbg-check:(unsigned long) = 111 (unsigned long) = 222 +// lldbr-check:(unsigned long) = 111 (unsigned long) = 222 +// lldb-command:continue +#![feature(naked_functions)] #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] @@ -46,6 +55,7 @@ fn main() { fun(111102, true); nested(2000, 3000); + naked(111, 222); fn nested(a: i32, b: i64) -> (i32, i64) { zzz(); // #break @@ -59,4 +69,11 @@ fn fun(x: isize, y: bool) -> (isize, bool) { (x, y) } +#[naked] +fn naked(x: usize, y: usize) -> usize { + zzz(); // #break + + x + y +} + fn zzz() { () } From 5702e0289f7d19f0ea133d43da7dcd7cbfc5b557 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Mon, 6 Jul 2020 20:42:19 +0100 Subject: [PATCH 04/20] Only allow `repr(i128/u128)` on enum --- src/librustc_passes/check_attr.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_passes/check_attr.rs b/src/librustc_passes/check_attr.rs index ef84f251390e6..fee63b1ee524e 100644 --- a/src/librustc_passes/check_attr.rs +++ b/src/librustc_passes/check_attr.rs @@ -292,6 +292,8 @@ impl CheckAttrVisitor<'tcx> { | sym::u32 | sym::i64 | sym::u64 + | sym::i128 + | sym::u128 | sym::isize | sym::usize => { int_reprs += 1; From 97867bbe5cd09df7754864c826f58d3029f4422e Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Mon, 6 Jul 2020 21:04:54 +0100 Subject: [PATCH 05/20] Add UI test for issue 74082 --- src/test/ui/issues/issue-74082.rs | 9 +++++++++ src/test/ui/issues/issue-74082.stderr | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/test/ui/issues/issue-74082.rs create mode 100644 src/test/ui/issues/issue-74082.stderr diff --git a/src/test/ui/issues/issue-74082.rs b/src/test/ui/issues/issue-74082.rs new file mode 100644 index 0000000000000..982f8ef02538b --- /dev/null +++ b/src/test/ui/issues/issue-74082.rs @@ -0,0 +1,9 @@ +#![allow(dead_code)] + +#[repr(i128)] //~ ERROR: attribute should be applied to enum +struct Foo; + +#[repr(u128)] //~ ERROR: attribute should be applied to enum +struct Bar; + +fn main() {} diff --git a/src/test/ui/issues/issue-74082.stderr b/src/test/ui/issues/issue-74082.stderr new file mode 100644 index 0000000000000..08fe415513d0d --- /dev/null +++ b/src/test/ui/issues/issue-74082.stderr @@ -0,0 +1,19 @@ +error[E0517]: attribute should be applied to enum + --> $DIR/issue-74082.rs:3:8 + | +LL | #[repr(i128)] + | ^^^^ +LL | struct Foo; + | ----------- not an enum + +error[E0517]: attribute should be applied to enum + --> $DIR/issue-74082.rs:6:8 + | +LL | #[repr(u128)] + | ^^^^ +LL | struct Bar; + | ----------- not an enum + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0517`. From b50c13cc28b3c6c5968ec3f8cf0c1aa11e463d9f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 7 Jul 2020 13:53:46 -0700 Subject: [PATCH 06/20] Update books --- src/doc/book | 2 +- src/doc/embedded-book | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/book b/src/doc/book index 4e7c00bece154..84a31397b34f9 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 4e7c00bece1544d409312ec93467beb62b5bd0cb +Subproject commit 84a31397b34f9d405df44f2899ff17a4828dba18 diff --git a/src/doc/embedded-book b/src/doc/embedded-book index 616962ad0dd80..94d9ea8460bcb 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit 616962ad0dd80f34d8b802da038d0aed9dd691bb +Subproject commit 94d9ea8460bcbbbfef1877b47cb930260b5849a7 diff --git a/src/doc/reference b/src/doc/reference index 04d5d5d7ba624..0ea7bc494f128 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 04d5d5d7ba624b6f5016298451f3a63d557f3260 +Subproject commit 0ea7bc494f1289234d8800bb9185021e0ad946f0 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 6f94ccb48da6f..229c6945a26a5 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 6f94ccb48da6fa4ed0031290f21411cf789f7d5e +Subproject commit 229c6945a26a53a751ffa4f9cb418388c00029d3 From 32025fd76a2f95b339cc0cca8e779bebc06d7f70 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 24 May 2020 17:08:45 -0700 Subject: [PATCH 07/20] Update rust-installer to latest version This pulls in a fix for the install script on some tr(1) implementations, as well as an update to use `anyhow` instead of `failure` for error handling. --- Cargo.lock | 2 +- src/tools/rust-installer | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cedf44be85bda..2096a3dfff9ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1366,8 +1366,8 @@ checksum = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" name = "installer" version = "0.0.0" dependencies = [ + "anyhow", "clap", - "failure", "flate2", "lazy_static", "num_cpus", diff --git a/src/tools/rust-installer b/src/tools/rust-installer index 9f66c14c3f91a..d66f476b4d5e7 160000 --- a/src/tools/rust-installer +++ b/src/tools/rust-installer @@ -1 +1 @@ -Subproject commit 9f66c14c3f91a48a118c7817f434167b311c3515 +Subproject commit d66f476b4d5e7fdf1ec215c9ac16c923dc292324 From 653c0912628382388ceb8a3cf29e88dad35b98ac Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 3 Jul 2020 16:20:37 -0700 Subject: [PATCH 08/20] Add `read_exact_at` and `write_all_at` to WASI's `FileExt` This adds `read_exact_at` and `write_all_at` to WASI's `FileExt`, similar to the Unix versions of the same names. --- src/libstd/sys/wasi/ext/fs.rs | 94 +++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/src/libstd/sys/wasi/ext/fs.rs b/src/libstd/sys/wasi/ext/fs.rs index 6696efa8871c2..10ea4fd34bda3 100644 --- a/src/libstd/sys/wasi/ext/fs.rs +++ b/src/libstd/sys/wasi/ext/fs.rs @@ -27,6 +27,58 @@ pub trait FileExt { /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read_vectored fn read_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result; + /// Reads the exact number of byte required to fill `buf` from the given offset. + /// + /// The offset is relative to the start of the file and thus independent + /// from the current cursor. + /// + /// The current file cursor is not affected by this function. + /// + /// Similar to [`Read::read_exact`] but uses [`read_at`] instead of `read`. + /// + /// [`Read::read_exact`]: ../../../../std/io/trait.Read.html#method.read_exact + /// [`read_at`]: #tymethod.read_at + /// + /// # Errors + /// + /// If this function encounters an error of the kind + /// [`ErrorKind::Interrupted`] then the error is ignored and the operation + /// will continue. + /// + /// If this function encounters an "end of file" before completely filling + /// the buffer, it returns an error of the kind [`ErrorKind::UnexpectedEof`]. + /// The contents of `buf` are unspecified in this case. + /// + /// If any other read error is encountered then this function immediately + /// returns. The contents of `buf` are unspecified in this case. + /// + /// If this function returns an error, it is unspecified how many bytes it + /// has read, but it will never read more than would be necessary to + /// completely fill the buffer. + /// + /// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted + /// [`ErrorKind::UnexpectedEof`]: ../../../../std/io/enum.ErrorKind.html#variant.UnexpectedEof + #[stable(feature = "rw_exact_all_at", since = "1.33.0")] + fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> { + while !buf.is_empty() { + match self.read_at(buf, offset) { + Ok(0) => break, + Ok(n) => { + let tmp = buf; + buf = &mut tmp[n..]; + offset += n as u64; + } + Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} + Err(e) => return Err(e), + } + } + if !buf.is_empty() { + Err(io::Error::new(io::ErrorKind::UnexpectedEof, "failed to fill whole buffer")) + } else { + Ok(()) + } + } + /// Writes a number of bytes starting from a given offset. /// /// Returns the number of bytes written. @@ -45,6 +97,48 @@ pub trait FileExt { /// [`File::write`]: ../../../../std/fs/struct.File.html#method.write_vectored fn write_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result; + /// Attempts to write an entire buffer starting from a given offset. + /// + /// The offset is relative to the start of the file and thus independent + /// from the current cursor. + /// + /// The current file cursor is not affected by this function. + /// + /// This method will continuously call [`write_at`] until there is no more data + /// to be written or an error of non-[`ErrorKind::Interrupted`] kind is + /// returned. This method will not return until the entire buffer has been + /// successfully written or such an error occurs. The first error that is + /// not of [`ErrorKind::Interrupted`] kind generated from this method will be + /// returned. + /// + /// # Errors + /// + /// This function will return the first error of + /// non-[`ErrorKind::Interrupted`] kind that [`write_at`] returns. + /// + /// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted + /// [`write_at`]: #tymethod.write_at + #[stable(feature = "rw_exact_all_at", since = "1.33.0")] + fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> { + while !buf.is_empty() { + match self.write_at(buf, offset) { + Ok(0) => { + return Err(io::Error::new( + io::ErrorKind::WriteZero, + "failed to write whole buffer", + )); + } + Ok(n) => { + buf = &buf[n..]; + offset += n as u64 + } + Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {} + Err(e) => return Err(e), + } + } + Ok(()) + } + /// Returns the current position within the file. /// /// This corresponds to the `fd_tell` syscall and is similar to From 58fc61b79cd15fdafad6e15991553f5c33422ade Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 7 Jul 2020 15:56:07 -0700 Subject: [PATCH 09/20] Make WASI's FileExt's read_at/write_at consistent with other targets. Rename the existing read_at/write_at to read_vectored_at/write_vectored_at, for consistency with libstd's read_vectored/write_vectored. And, introduce new read_at/write_at functions which take a single buffer, similar to all other targets which provide these functions, so this will make it easier for applications to share code between WASI and other targets. Note that WASI's FileExt is currently unstable. --- src/libstd/sys/wasi/ext/fs.rs | 47 ++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/src/libstd/sys/wasi/ext/fs.rs b/src/libstd/sys/wasi/ext/fs.rs index 10ea4fd34bda3..f41c6626ccf12 100644 --- a/src/libstd/sys/wasi/ext/fs.rs +++ b/src/libstd/sys/wasi/ext/fs.rs @@ -12,6 +12,24 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner}; /// /// [`File`]: ../../../../std/fs/struct.File.html pub trait FileExt { + /// Reads a number of bytes starting from a given offset. + /// + /// Returns the number of bytes read. + /// + /// The offset is relative to the start of the file and thus independent + /// from the current cursor. + /// + /// The current file cursor is not affected by this function. + /// + /// Note that similar to [`File::read`], it is not an error to return with a + /// short read. + /// + /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read + fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { + let bufs = &mut [IoSliceMut::new(buf)]; + self.read_vectored_at(bufs, offset) + } + /// Reads a number of bytes starting from a given offset. /// /// Returns the number of bytes read. @@ -25,7 +43,7 @@ pub trait FileExt { /// return with a short read. /// /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read_vectored - fn read_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result; + fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result; /// Reads the exact number of byte required to fill `buf` from the given offset. /// @@ -79,6 +97,27 @@ pub trait FileExt { } } + /// Writes a number of bytes starting from a given offset. + /// + /// Returns the number of bytes written. + /// + /// The offset is relative to the start of the file and thus independent + /// from the current cursor. + /// + /// The current file cursor is not affected by this function. + /// + /// When writing beyond the end of the file, the file is appropriately + /// extended and the intermediate bytes are initialized with the value 0. + /// + /// Note that similar to [`File::write`], it is not an error to return a + /// short write. + /// + /// [`File::write`]: ../../../../std/fs/struct.File.html#write.v + fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { + let bufs = &[IoSlice::new(buf)]; + self.write_vectored_at(bufs, offset) + } + /// Writes a number of bytes starting from a given offset. /// /// Returns the number of bytes written. @@ -95,7 +134,7 @@ pub trait FileExt { /// short write. /// /// [`File::write`]: ../../../../std/fs/struct.File.html#method.write_vectored - fn write_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result; + fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result; /// Attempts to write an entire buffer starting from a given offset. /// @@ -199,11 +238,11 @@ pub trait FileExt { // FIXME: bind random_get maybe? - on crates.io for unix impl FileExt for fs::File { - fn read_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result { + fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result { self.as_inner().fd().pread(bufs, offset) } - fn write_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result { + fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result { self.as_inner().fd().pwrite(bufs, offset) } From 3c63fba03daedf014b75e12f32f4daec3598f9a3 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Tue, 7 Jul 2020 07:50:49 -0700 Subject: [PATCH 10/20] Correctly mark the ending span of a match arm Closes #74050 r? @matthewjasper --- src/librustc_parse/parser/expr.rs | 2 +- ....match_tuple.SimplifyCfg-initial.after.mir | 4 +- .../32bit/rustc.main.SimplifyArmIdentity.diff | 2 +- .../64bit/rustc.main.SimplifyArmIdentity.diff | 2 +- ...complicated_match.ElaborateDrops.after.mir | 44 +++++++++---------- ...icated_match.SimplifyCfg-initial.after.mir | 44 +++++++++---------- ...c.full_tested_match.PromoteTemps.after.mir | 12 ++--- ...full_tested_match2.PromoteTemps.before.mir | 12 ++--- .../rustc.main.PromoteTemps.before.mir | 24 +++++----- .../rustc.main.SimplifyCfg-initial.after.mir | 4 +- ...wrap.SimplifyCfg-elaborate-drops.after.mir | 2 +- ...tch_guard.CleanupNonCodegenStatements.diff | 4 +- .../32bit/rustc.main.SimplifyArmIdentity.diff | 2 +- .../64bit/rustc.main.SimplifyArmIdentity.diff | 2 +- .../rustc.id.SimplifyArmIdentity.diff | 2 +- .../rustc.id.SimplifyBranchSame.diff | 2 +- .../rustc.id_result.SimplifyArmIdentity.diff | 4 +- .../rustc.id_result.SimplifyBranchSame.diff | 4 +- ...c.{{impl}}-append.SimplifyArmIdentity.diff | 2 +- src/test/ui/match/issue-74050-end-span.rs | 13 ++++++ src/test/ui/match/issue-74050-end-span.stderr | 15 +++++++ 21 files changed, 115 insertions(+), 87 deletions(-) create mode 100644 src/test/ui/match/issue-74050-end-span.rs create mode 100644 src/test/ui/match/issue-74050-end-span.stderr diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index abb444933536f..876ce3ab2cb43 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -1790,7 +1790,7 @@ impl<'a> Parser<'a> { let require_comma = classify::expr_requires_semi_to_be_stmt(&expr) && self.token != token::CloseDelim(token::Brace); - let hi = self.token.span; + let hi = self.prev_token.span; if require_comma { let sm = self.sess.source_map(); diff --git a/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir b/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir index b84ca5df9964e..00942cd12b42c 100644 --- a/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir @@ -102,8 +102,8 @@ fn match_tuple(_1: (u32, bool, std::option::Option, u32)) -> u32 { _0 = BitXor(move _9, move _10); // scope 1 at $DIR/exponential-or.rs:8:83: 8:88 StorageDead(_10); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 StorageDead(_9); // scope 1 at $DIR/exponential-or.rs:8:87: 8:88 - StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:8:88: 8:89 - StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:8:88: 8:89 + StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 + StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:8:87: 8:88 goto -> bb10; // scope 0 at $DIR/exponential-or.rs:7:5: 10:6 } diff --git a/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff index e5b4a0328808f..1020fc965fe86 100644 --- a/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff @@ -137,7 +137,7 @@ StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 - StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:21: 3:22 + StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 diff --git a/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff index 0c2651dc3c68d..aa606ed22b6d0 100644 --- a/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff @@ -137,7 +137,7 @@ StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 - StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:21: 3:22 + StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:20: 3:21 StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir index c6832f21208d4..df6a247bb5ff6 100644 --- a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir +++ b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir @@ -61,7 +61,7 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // mir::Constant // + span: $DIR/match-arm-scopes.rs:16:77: 16:78 // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } - drop(_7) -> [return: bb19, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + drop(_7) -> [return: bb19, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 } bb6: { @@ -90,9 +90,9 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 } @@ -109,7 +109,7 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb12: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 @@ -118,9 +118,9 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb13: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 } @@ -150,14 +150,14 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 } bb17: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 @@ -166,17 +166,17 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb18: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb3; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 } bb19: { - StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 } @@ -188,7 +188,7 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // mir::Constant // + span: $DIR/match-arm-scopes.rs:17:41: 17:42 // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } - drop(_16) -> [return: bb22, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + drop(_16) -> [return: bb22, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 } bb21: { @@ -200,8 +200,8 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb22: { - StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 - StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 + StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 } diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir index 45f7e91d097c0..dadbc3668cb29 100644 --- a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir @@ -74,7 +74,7 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // mir::Constant // + span: $DIR/match-arm-scopes.rs:16:77: 16:78 // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } - drop(_7) -> [return: bb24, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + drop(_7) -> [return: bb24, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 } bb9: { @@ -110,9 +110,9 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 } @@ -129,7 +129,7 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb16: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 @@ -142,9 +142,9 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb17: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 falseEdge -> [real: bb3, imaginary: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 } @@ -181,14 +181,14 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 } bb22: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 @@ -201,17 +201,17 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb23: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 falseEdge -> [real: bb5, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 } bb24: { - StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 } @@ -223,7 +223,7 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { // mir::Constant // + span: $DIR/match-arm-scopes.rs:17:41: 17:42 // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } - drop(_16) -> [return: bb27, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + drop(_16) -> [return: bb27, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 } bb26: { @@ -235,8 +235,8 @@ fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { } bb27: { - StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 - StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 + StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 } diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir index d4a2afe295781..5ff4150d2ac1a 100644 --- a/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir +++ b/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir @@ -97,7 +97,7 @@ fn full_tested_match() -> () { } bb8: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37 FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:16:26: 16:27 FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:16:26: 16:27 StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 @@ -112,14 +112,14 @@ fn full_tested_match() -> () { // + span: $DIR/match_false_edges.rs:16:32: 16:33 // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:16:36: 16:37 - StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37 goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 } bb9: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:16:36: 16:37 goto -> bb4; // scope 0 at $DIR/match_false_edges.rs:16:20: 16:27 } @@ -136,7 +136,7 @@ fn full_tested_match() -> () { // + span: $DIR/match_false_edges.rs:17:21: 17:22 // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:17:25: 17:26 - StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:17:26: 17:27 + StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:17:25: 17:26 goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 } diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir index f1744a94fdc13..b79416fe31a41 100644 --- a/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir +++ b/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir @@ -62,7 +62,7 @@ fn full_tested_match2() -> () { // + span: $DIR/match_false_edges.rs:29:21: 29:22 // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:29:25: 29:26 - StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:29:26: 29:27 + StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:29:25: 29:26 goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 } @@ -89,7 +89,7 @@ fn full_tested_match2() -> () { } bb8: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37 FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:27:26: 27:27 FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:27:26: 27:27 StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:27:14: 27:15 @@ -104,14 +104,14 @@ fn full_tested_match2() -> () { // + span: $DIR/match_false_edges.rs:27:32: 27:33 // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:27:36: 27:37 - StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37 goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 } bb9: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:27:36: 27:37 falseEdge -> [real: bb4, imaginary: bb2]; // scope 0 at $DIR/match_false_edges.rs:27:20: 27:27 } diff --git a/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir index 4ab4c4d341e2f..5b449da93d493 100644 --- a/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir +++ b/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir @@ -70,7 +70,7 @@ fn main() -> () { // mir::Constant // + span: $DIR/match_false_edges.rs:39:15: 39:16 // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } - StorageDead(_14); // scope 0 at $DIR/match_false_edges.rs:39:16: 39:17 + StorageDead(_14); // scope 0 at $DIR/match_false_edges.rs:39:15: 39:16 goto -> bb15; // scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 } @@ -97,7 +97,7 @@ fn main() -> () { } bb8: { - StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33 FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:36:27: 36:28 FakeRead(ForGuardBinding, _7); // scope 0 at $DIR/match_false_edges.rs:36:27: 36:28 StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:36:14: 36:16 @@ -109,14 +109,14 @@ fn main() -> () { // mir::Constant // + span: $DIR/match_false_edges.rs:36:32: 36:33 // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33 goto -> bb15; // scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 } bb9: { - StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:36:32: 36:33 falseEdge -> [real: bb2, imaginary: bb2]; // scope 0 at $DIR/match_false_edges.rs:36:21: 36:28 } @@ -130,7 +130,7 @@ fn main() -> () { // mir::Constant // + span: $DIR/match_false_edges.rs:37:15: 37:16 // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } - StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:37:16: 37:17 + StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:37:15: 37:16 goto -> bb15; // scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 } @@ -156,7 +156,7 @@ fn main() -> () { } bb13: { - StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34 FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29 FakeRead(ForGuardBinding, _11); // scope 0 at $DIR/match_false_edges.rs:38:28: 38:29 StorageLive(_10); // scope 0 at $DIR/match_false_edges.rs:38:14: 38:15 @@ -168,14 +168,14 @@ fn main() -> () { // mir::Constant // + span: $DIR/match_false_edges.rs:38:33: 38:34 // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 - StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34 + StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34 goto -> bb15; // scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 } bb14: { - StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 - StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34 + StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:38:33: 38:34 falseEdge -> [real: bb4, imaginary: bb4]; // scope 0 at $DIR/match_false_edges.rs:38:20: 38:29 } diff --git a/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir index ef6c88d8005b3..16895942cb81b 100644 --- a/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir @@ -117,7 +117,7 @@ fn main() -> () { } bb10: { - StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:24: 13:25 + StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:23: 13:24 FakeRead(ForMatchGuard, _8); // scope 2 at $DIR/match_test.rs:13:18: 13:19 _3 = const 0_i32; // scope 2 at $DIR/match_test.rs:13:23: 13:24 // ty::Const @@ -130,7 +130,7 @@ fn main() -> () { } bb11: { - StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:24: 13:25 + StorageDead(_9); // scope 2 at $DIR/match_test.rs:13:23: 13:24 falseEdge -> [real: bb3, imaginary: bb6]; // scope 2 at $DIR/match_test.rs:13:18: 13:19 } diff --git a/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir index 2e8cfaea937d7..f3f2b68e53d5c 100644 --- a/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir @@ -43,7 +43,7 @@ fn unwrap(_1: std::option::Option) -> T { StorageLive(_3); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15 _3 = move ((_1 as Some).0: T); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15 _0 = move _3; // scope 1 at $DIR/no-drop-for-inactive-variant.rs:9:20: 9:21 - StorageDead(_3); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:21: 9:22 + StorageDead(_3); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:20: 9:21 _6 = discriminant(_1); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2 return; // scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:2: 12:2 } diff --git a/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff b/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff index 7fc209778703e..0822d8cc03c60 100644 --- a/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff +++ b/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff @@ -53,7 +53,7 @@ } bb5: { - StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:26: 8:27 + StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 - FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 - FakeRead(ForMatchGuard, _6); // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 @@ -73,7 +73,7 @@ } bb6: { - StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:26: 8:27 + StorageDead(_8); // scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26 goto -> bb1; // scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 } diff --git a/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff index 33a3403cada92..0de80f72a1e70 100644 --- a/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify-arm-identity/32bit/rustc.main.SimplifyArmIdentity.diff @@ -61,7 +61,7 @@ ((_2 as Foo).0: u8) = move _5; // scope 3 at $DIR/simplify-arm-identity.rs:20:24: 20:35 discriminant(_2) = 0; // scope 3 at $DIR/simplify-arm-identity.rs:20:24: 20:35 StorageDead(_5); // scope 3 at $DIR/simplify-arm-identity.rs:20:34: 20:35 - StorageDead(_4); // scope 1 at $DIR/simplify-arm-identity.rs:20:35: 20:36 + StorageDead(_4); // scope 1 at $DIR/simplify-arm-identity.rs:20:34: 20:35 goto -> bb4; // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6 } diff --git a/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff index 7e4fe1c2dcc4c..4fa0aff8fa0ef 100644 --- a/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify-arm-identity/64bit/rustc.main.SimplifyArmIdentity.diff @@ -61,7 +61,7 @@ ((_2 as Foo).0: u8) = move _5; // scope 3 at $DIR/simplify-arm-identity.rs:20:24: 20:35 discriminant(_2) = 0; // scope 3 at $DIR/simplify-arm-identity.rs:20:24: 20:35 StorageDead(_5); // scope 3 at $DIR/simplify-arm-identity.rs:20:34: 20:35 - StorageDead(_4); // scope 1 at $DIR/simplify-arm-identity.rs:20:35: 20:36 + StorageDead(_4); // scope 1 at $DIR/simplify-arm-identity.rs:20:34: 20:35 goto -> bb4; // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6 } diff --git a/src/test/mir-opt/simplify-arm/rustc.id.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm/rustc.id.SimplifyArmIdentity.diff index daae94e87f044..0cddcb061cfc8 100644 --- a/src/test/mir-opt/simplify-arm/rustc.id.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify-arm/rustc.id.SimplifyArmIdentity.diff @@ -33,7 +33,7 @@ ((_0 as Some).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 discriminant(_0) = 1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:11:26: 11:27 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:11:27: 11:28 + StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6 } diff --git a/src/test/mir-opt/simplify-arm/rustc.id.SimplifyBranchSame.diff b/src/test/mir-opt/simplify-arm/rustc.id.SimplifyBranchSame.diff index 15bd5e7c9f0b0..cd5962c682a5a 100644 --- a/src/test/mir-opt/simplify-arm/rustc.id.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify-arm/rustc.id.SimplifyBranchSame.diff @@ -33,7 +33,7 @@ ((_0 as Some).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 discriminant(_0) = 1; // scope 1 at $DIR/simplify-arm.rs:11:20: 11:27 StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:11:26: 11:27 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:11:27: 11:28 + StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:11:26: 11:27 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:10:5: 13:6 } diff --git a/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyArmIdentity.diff index 37273d1d6517b..642ccc1ab14b7 100644 --- a/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyArmIdentity.diff @@ -29,7 +29,7 @@ ((_0 as Err).0: i32) = move _6; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 discriminant(_0) = 1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 StorageDead(_6); // scope 2 at $DIR/simplify-arm.rs:19:24: 19:25 - StorageDead(_5); // scope 0 at $DIR/simplify-arm.rs:19:25: 19:26 + StorageDead(_5); // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6 } @@ -45,7 +45,7 @@ ((_0 as Ok).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:18:22: 18:23 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:18:23: 18:24 + StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6 } diff --git a/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyBranchSame.diff b/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyBranchSame.diff index f138d637435f8..95ce09a39ed50 100644 --- a/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify-arm/rustc.id_result.SimplifyBranchSame.diff @@ -29,7 +29,7 @@ ((_0 as Err).0: i32) = move _6; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 discriminant(_0) = 1; // scope 2 at $DIR/simplify-arm.rs:19:19: 19:25 StorageDead(_6); // scope 2 at $DIR/simplify-arm.rs:19:24: 19:25 - StorageDead(_5); // scope 0 at $DIR/simplify-arm.rs:19:25: 19:26 + StorageDead(_5); // scope 0 at $DIR/simplify-arm.rs:19:24: 19:25 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6 } @@ -45,7 +45,7 @@ ((_0 as Ok).0: u8) = move _4; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:18:18: 18:23 StorageDead(_4); // scope 1 at $DIR/simplify-arm.rs:18:22: 18:23 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:18:23: 18:24 + StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:18:22: 18:23 goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:17:5: 20:6 } diff --git a/src/test/mir-opt/simplify_try_if_let/rustc.{{impl}}-append.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try_if_let/rustc.{{impl}}-append.SimplifyArmIdentity.diff index aa416049f6613..4471f4d206ca2 100644 --- a/src/test/mir-opt/simplify_try_if_let/rustc.{{impl}}-append.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_try_if_let/rustc.{{impl}}-append.SimplifyArmIdentity.diff @@ -115,7 +115,7 @@ bb8: { StorageDead(_5); // scope 1 at $DIR/simplify_try_if_let.rs:31:13: 31:14 - StorageDead(_4); // scope 0 at $DIR/simplify_try_if_let.rs:32:9: 32:10 + StorageDead(_4); // scope 0 at $DIR/simplify_try_if_let.rs:31:13: 31:14 goto -> bb9; // scope 0 at $DIR/simplify_try_if_let.rs:21:9: 32:10 } diff --git a/src/test/ui/match/issue-74050-end-span.rs b/src/test/ui/match/issue-74050-end-span.rs new file mode 100644 index 0000000000000..cc81214e2701b --- /dev/null +++ b/src/test/ui/match/issue-74050-end-span.rs @@ -0,0 +1,13 @@ +fn main() { + let mut args = std::env::args_os(); + let _arg = match args.next() { + Some(arg) => { + match arg.to_str() { + //~^ ERROR `arg` does not live long enough + Some(s) => s, + None => return, + } + } + None => return, + }; +} diff --git a/src/test/ui/match/issue-74050-end-span.stderr b/src/test/ui/match/issue-74050-end-span.stderr new file mode 100644 index 0000000000000..d636a11a91cec --- /dev/null +++ b/src/test/ui/match/issue-74050-end-span.stderr @@ -0,0 +1,15 @@ +error[E0597]: `arg` does not live long enough + --> $DIR/issue-74050-end-span.rs:5:19 + | +LL | let _arg = match args.next() { + | ---- borrow later stored here +LL | Some(arg) => { +LL | match arg.to_str() { + | ^^^ borrowed value does not live long enough +... +LL | } + | - `arg` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. From 59f979fa06fed49e02606d4891b5b5e4fc545725 Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Thu, 2 Jul 2020 10:45:10 -0700 Subject: [PATCH 11/20] Fix cross-compilation of LLVM to aarch64 Windows targets When cross-compiling, the LLVM build system recurses to build tools that need to run on the host system. However, since we pass cmake defines to set the compiler and target, LLVM still compiles these tools for the target system, rather than the host. The tools then fail to execute during the LLVM build. This change sets defines for the tools that need to run on the host (llvm-nm, llvm-tablegen, and llvm-config), so that the LLVM build does not attempt to build them, and instead relies on the tools already built. If compiling with clang-cl, this change also adds the `--target` option to specify the target triple. MSVC compilers do not require this, since there is a separate compiler binary for cross-compilation. --- Cargo.lock | 4 ++-- src/bootstrap/native.rs | 31 +++++++++++++++++++++++-------- src/llvm-project | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cedf44be85bda..37928c4d5581a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,9 +404,9 @@ version = "0.1.0" [[package]] name = "cc" -version = "1.0.54" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" +checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe" dependencies = [ "jobserver", ] diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index cceb794165059..e8ec575ea3746 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -9,6 +9,7 @@ //! ensure that they're always in place if needed. use std::env; +use std::env::consts::EXE_EXTENSION; use std::ffi::OsString; use std::fs::{self, File}; use std::io; @@ -252,8 +253,14 @@ impl Step for Llvm { // FIXME: if the llvm root for the build triple is overridden then we // should use llvm-tblgen from there, also should verify that it // actually exists most of the time in normal installs of LLVM. - let host = builder.llvm_out(builder.config.build).join("bin/llvm-tblgen"); - cfg.define("CMAKE_CROSSCOMPILING", "True").define("LLVM_TABLEGEN", &host); + let host_bin = builder.llvm_out(builder.config.build).join("bin"); + cfg.define("CMAKE_CROSSCOMPILING", "True"); + cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION)); + cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); + cfg.define( + "LLVM_CONFIG_PATH", + host_bin.join("llvm-config").with_extension(EXE_EXTENSION), + ); if target.contains("netbsd") { cfg.define("CMAKE_SYSTEM_NAME", "NetBSD"); @@ -262,8 +269,6 @@ impl Step for Llvm { } else if target.contains("windows") { cfg.define("CMAKE_SYSTEM_NAME", "Windows"); } - - cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build")); } if let Some(ref suffix) = builder.config.llvm_version_suffix { @@ -431,6 +436,9 @@ fn configure_cmake( cflags.push_str(" -miphoneos-version-min=10.0"); } } + if builder.config.llvm_clang_cl.is_some() { + cflags.push_str(&format!(" --target={}", target)) + } cfg.define("CMAKE_C_FLAGS", cflags); let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" "); if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") { @@ -439,6 +447,9 @@ fn configure_cmake( if let Some(ref s) = builder.config.llvm_cxxflags { cxxflags.push_str(&format!(" {}", s)); } + if builder.config.llvm_clang_cl.is_some() { + cxxflags.push_str(&format!(" --target={}", target)) + } cfg.define("CMAKE_CXX_FLAGS", cxxflags); if let Some(ar) = builder.ar(target) { if ar.is_absolute() { @@ -484,7 +495,7 @@ impl Step for Lld { run.builder.ensure(Lld { target: run.target }); } - /// Compile LLVM for `target`. + /// Compile LLD for `target`. fn run(self, builder: &Builder<'_>) -> PathBuf { if builder.config.dry_run { return PathBuf::from("lld-out-dir-test-gen"); @@ -521,6 +532,7 @@ impl Step for Lld { // can't build on a system where your paths require `\` on Windows, but // there's probably a lot of reasons you can't do that other than this. let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper"); + cfg.out_dir(&out_dir) .profile("Release") .env("LLVM_CONFIG_REAL", &llvm_config) @@ -543,7 +555,10 @@ impl Step for Lld { if target != builder.config.build { cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build) .env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target) - .define("LLVM_TABLEGEN_EXE", llvm_config.with_file_name("llvm-tblgen")); + .define( + "LLVM_TABLEGEN_EXE", + llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION), + ); } // Explicitly set C++ standard, because upstream doesn't do so @@ -595,8 +610,8 @@ impl Step for TestHelpers { } // We may have found various cross-compilers a little differently due to our - // extra configuration, so inform gcc of these compilers. Note, though, that - // on MSVC we still need gcc's detection of env vars (ugh). + // extra configuration, so inform cc of these compilers. Note, though, that + // on MSVC we still need cc's detection of env vars (ugh). if !target.contains("msvc") { if let Some(ar) = builder.ar(target) { cfg.archiver(ar); diff --git a/src/llvm-project b/src/llvm-project index 6c040dd86ed62..d134a53927fa0 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 6c040dd86ed62d38e585279027486e6efc42fb36 +Subproject commit d134a53927fa033ae7e0f3e8ee872ff2dc71468d From 51b646e48791168c2086177a8a92764b63e3a692 Mon Sep 17 00:00:00 2001 From: Tom Eccles Date: Wed, 8 Jul 2020 19:23:51 +0100 Subject: [PATCH 12/20] ci: disabled: riscv: minimise docker overlays Suggested by @bjorn3 Every RUN command creates a new overlay on top of the image as of before the RUN command. Using fewer RUN commands prevents intermediate overlays (which in this case would have contained the entire Linux source tree). --- .../docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile b/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile index 40c02ba6510aa..a938899636a45 100644 --- a/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/disabled/riscv64gc-linux/Dockerfile @@ -40,9 +40,9 @@ RUN curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.16.tar.xz | tar cp linux.config linux-5.6.16/.config && \ cd /build/linux-5.6.16 && \ make olddefconfig && \ - make -j$(nproc) vmlinux -RUN cp linux-5.6.16/vmlinux /tmp -RUN rm -rf linux-5.6.16 + make -j$(nproc) vmlinux && \ + cp vmlinux /tmp && \ + rm -rf linux-5.6.16 # Compile an instance of busybox as this provides a lightweight system and init # binary which we will boot into. Only trick here is configuring busybox to From d9fec595e83423d7c35f0457a5c6a363fdaea02d Mon Sep 17 00:00:00 2001 From: Tom Eccles Date: Wed, 8 Jul 2020 21:57:57 +0100 Subject: [PATCH 13/20] ci: fix context for disabled docker images When the dockerfiles were moved into the host-x86_64 directory, paths for COPY commands were updated with the new host-x86_64/ prefix. This suggested that the intended context was src/ci/docker. However, the context for disabled docker images was src/ci/docker/host-x86_64. This broke the new paths and prevented src/ci/docker/scripts from being included in the context at all. This commit corrects this context allowing docker to find the files it needs for COPY commands. --- src/ci/docker/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 9bc61b56efbb2..c2ff62e74816d 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -119,11 +119,11 @@ elif [ -f "$docker_dir/disabled/$image/Dockerfile" ]; then exit 1 fi # Transform changes the context of disabled Dockerfiles to match the enabled ones - tar --transform 's#^./disabled/#./#' -C $docker_dir -c . | docker \ + tar --transform 's#disabled/#./#' -C $script_dir -c . | docker \ build \ --rm \ -t rust-ci \ - -f "$image/Dockerfile" \ + -f "host-$(uname -m)/$image/Dockerfile" \ - else echo Invalid image: $image From 7fb421bd77e37505045bef424b962a0bd9af6c4e Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Wed, 8 Jul 2020 23:28:16 +0000 Subject: [PATCH 14/20] linker: illumos ld does not support --eh-frame-hdr As of rust-lang/rust#73564, the --eh-frame-hdr flag is unconditionally passed to linkers on many platforms. The illumos link editor does not currently support this flag. The linker machinery in the Rust toolchain currently seems to use the (potentially cross-compiled) target to choose linker flags, rather than looking at what might be running on the build system. Disabling the flag for all illumos/Solaris targets seems like the best we can do for now without more serious surgery. --- src/librustc_codegen_ssa/back/linker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 54f55c806d035..3ee428bd25d0c 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -621,9 +621,9 @@ impl<'a> Linker for GccLinker<'a> { // Some versions of `gcc` add it implicitly, some (e.g. `musl-gcc`) don't, // so we just always add it. fn add_eh_frame_header(&mut self) { - // The condition here is "uses ELF" basically. if !self.sess.target.target.options.is_like_osx && !self.sess.target.target.options.is_like_windows + && !self.sess.target.target.options.is_like_solaris && self.sess.target.target.target_os != "uefi" { self.linker_arg("--eh-frame-hdr"); From 6864546049d8f41b0521ee7dc5dedac4850f6c88 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 9 Jul 2020 08:12:59 +0900 Subject: [PATCH 15/20] Add a help to use `in_band_lifetimes` in nightly --- src/librustc_resolve/late/diagnostics.rs | 11 ++++++++++ src/test/ui/error-codes/E0261.stderr | 4 ++++ .../feature-gate-in_band_lifetimes.stderr | 22 +++++++++++++++++++ ...ssociated_type_undeclared_lifetimes.stderr | 2 ++ ...ethod-call-lifetime-args-unresolved.stderr | 2 ++ src/test/ui/regions/regions-in-enums.stderr | 4 ++++ src/test/ui/regions/regions-in-structs.stderr | 4 ++++ .../ui/regions/regions-name-undeclared.stderr | 17 ++++++++++++++ src/test/ui/regions/regions-undeclared.stderr | 8 +++++++ .../where-lifetime-resolution.stderr | 4 ++++ 10 files changed, 78 insertions(+) diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index e469ca80c590a..bc97341243f27 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -1044,6 +1044,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { lifetime_ref ); err.span_label(lifetime_ref.span, "undeclared lifetime"); + let mut suggests_in_band = false; for missing in &self.missing_named_lifetime_spots { match missing { MissingLifetimeSpot::Generics(generics) => { @@ -1057,6 +1058,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { }) { (param.span.shrink_to_lo(), format!("{}, ", lifetime_ref)) } else { + suggests_in_band = true; (generics.span, format!("<{}>", lifetime_ref)) }; err.span_suggestion( @@ -1084,6 +1086,15 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { } } } + if nightly_options::is_nightly_build() + && !self.tcx.features().in_band_lifetimes + && suggests_in_band + { + err.help( + "if you want to use in-band lifetime bindings, \ + add `#![feature(in_band_lifetimes)]` to the crate attributes", + ); + } err.emit(); } diff --git a/src/test/ui/error-codes/E0261.stderr b/src/test/ui/error-codes/E0261.stderr index 0eab2dc0ee05f..f37e28d072db4 100644 --- a/src/test/ui/error-codes/E0261.stderr +++ b/src/test/ui/error-codes/E0261.stderr @@ -5,6 +5,8 @@ LL | fn foo(x: &'a str) { } | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/E0261.rs:5:9 @@ -13,6 +15,8 @@ LL | struct Foo { | - help: consider introducing lifetime `'a` here: `<'a>` LL | x: &'a str, | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors diff --git a/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr b/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr index bbf3ea8a89f23..71a41c61f0dc7 100644 --- a/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr +++ b/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr @@ -5,6 +5,8 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x } | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'x` here: `<'x>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'x` --> $DIR/feature-gate-in_band_lifetimes.rs:3:23 @@ -13,6 +15,8 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x } | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'x` here: `<'x>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/feature-gate-in_band_lifetimes.rs:15:12 @@ -28,6 +32,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn inner_2(&self) -> &'b u8 { | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> X<'b> { @@ -44,6 +49,8 @@ LL | impl X<'b> { | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'b` here: `<'b>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/feature-gate-in_band_lifetimes.rs:25:27 @@ -51,6 +58,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn inner_3(&self) -> &'b u8 { | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> X<'b> { @@ -67,6 +75,8 @@ LL | impl Y<&'a u8> { | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/feature-gate-in_band_lifetimes.rs:35:25 @@ -74,6 +84,7 @@ error[E0261]: use of undeclared lifetime name `'a` LL | fn inner(&self) -> &'a u8 { | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'a` here | LL | impl<'a> Y<&'a u8> { @@ -89,6 +100,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn any_lifetime() -> &'b u8; | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait MyTrait<'b, 'a> { @@ -104,6 +116,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8; | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait MyTrait<'b, 'a> { @@ -119,6 +132,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8; | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait MyTrait<'b, 'a> { @@ -135,6 +149,8 @@ LL | impl MyTrait<'a> for Y<&'a u8> { | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/feature-gate-in_band_lifetimes.rs:50:25 @@ -143,6 +159,8 @@ LL | impl MyTrait<'a> for Y<&'a u8> { | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/feature-gate-in_band_lifetimes.rs:53:31 @@ -150,6 +168,7 @@ error[E0261]: use of undeclared lifetime name `'a` LL | fn my_lifetime(&self) -> &'a u8 { self.0 } | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'a` here | LL | impl<'a> MyTrait<'a> for Y<&'a u8> { @@ -165,6 +184,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn any_lifetime() -> &'b u8 { &0 } | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> MyTrait<'a> for Y<&'a u8> { @@ -180,6 +200,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> MyTrait<'a> for Y<&'a u8> { @@ -195,6 +216,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> MyTrait<'a> for Y<&'a u8> { diff --git a/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr b/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr index fc2ce1cb866bb..0e0fcebd0427c 100644 --- a/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr +++ b/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr @@ -4,6 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | + Deref>; | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait Iterable<'b> { @@ -19,6 +20,7 @@ error[E0261]: use of undeclared lifetime name `'undeclared` LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; | ^^^^^^^^^^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'undeclared` here | LL | trait Iterable<'undeclared> { diff --git a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr index c9f235c4f7df7..ed8da3dcddf99 100644 --- a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -5,6 +5,8 @@ LL | fn main() { | - help: consider introducing lifetime `'a` here: `<'a>` LL | 0.clone::<'a>(); | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to previous error diff --git a/src/test/ui/regions/regions-in-enums.stderr b/src/test/ui/regions/regions-in-enums.stderr index 66537653291c7..c20612346dce1 100644 --- a/src/test/ui/regions/regions-in-enums.stderr +++ b/src/test/ui/regions/regions-in-enums.stderr @@ -5,6 +5,8 @@ LL | enum No0 { | - help: consider introducing lifetime `'foo` here: `<'foo>` LL | X5(&'foo usize) | ^^^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-in-enums.rs:17:9 @@ -13,6 +15,8 @@ LL | enum No1 { | - help: consider introducing lifetime `'a` here: `<'a>` LL | X6(&'a usize) | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-in-structs.stderr b/src/test/ui/regions/regions-in-structs.stderr index 5dfdc2ee93b43..e65eb6f40b8ff 100644 --- a/src/test/ui/regions/regions-in-structs.stderr +++ b/src/test/ui/regions/regions-in-structs.stderr @@ -5,6 +5,8 @@ LL | struct StructDecl { | - help: consider introducing lifetime `'a` here: `<'a>` LL | a: &'a isize, | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-in-structs.rs:11:9 @@ -14,6 +16,8 @@ LL | struct StructDecl { LL | a: &'a isize, LL | b: &'a isize, | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-name-undeclared.stderr b/src/test/ui/regions/regions-name-undeclared.stderr index eb19a30c52b97..abcc68a029348 100644 --- a/src/test/ui/regions/regions-name-undeclared.stderr +++ b/src/test/ui/regions/regions-name-undeclared.stderr @@ -4,6 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn m4(&self, arg: &'b isize) { } | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> Foo<'a> { @@ -19,6 +20,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn m5(&'b self) { } | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> Foo<'a> { @@ -34,6 +36,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn m6(&self, arg: Foo<'b>) { } | ^^ undeclared lifetime | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> Foo<'a> { @@ -50,6 +53,8 @@ LL | type X = Option<&'a isize>; | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:27:13 @@ -58,6 +63,8 @@ LL | enum E { | - help: consider introducing lifetime `'a` here: `<'a>` LL | E1(&'a isize) | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:30:13 @@ -66,6 +73,8 @@ LL | struct S { | - help: consider introducing lifetime `'a` here: `<'a>` LL | f: &'a isize | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:32:14 @@ -74,6 +83,8 @@ LL | fn f(a: &'a isize) { } | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:40:17 @@ -82,6 +93,8 @@ LL | fn fn_types(a: &'a isize, | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/regions-name-undeclared.rs:42:36 @@ -90,6 +103,7 @@ LL | ... &'b isize, | ^^ undeclared lifetime | = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, @@ -106,6 +120,7 @@ LL | ... &'b isize)>, | ^^ undeclared lifetime | = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, @@ -123,6 +138,8 @@ LL | fn fn_types(a: &'a isize, ... LL | c: &'a isize) | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 11 previous errors diff --git a/src/test/ui/regions/regions-undeclared.stderr b/src/test/ui/regions/regions-undeclared.stderr index 6bfde5524ac49..9dff312df48e9 100644 --- a/src/test/ui/regions/regions-undeclared.stderr +++ b/src/test/ui/regions/regions-undeclared.stderr @@ -11,6 +11,8 @@ LL | enum EnumDecl { | - help: consider introducing lifetime `'a` here: `<'a>` LL | Foo(&'a isize), | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:5:10 @@ -20,6 +22,8 @@ LL | enum EnumDecl { LL | Foo(&'a isize), LL | Bar(&'a isize), | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:8:15 @@ -28,6 +32,8 @@ LL | fn fnDecl(x: &'a isize, | - ^^ undeclared lifetime | | | help: consider introducing lifetime `'a` here: `<'a>` + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:9:15 @@ -36,6 +42,8 @@ LL | fn fnDecl(x: &'a isize, | - help: consider introducing lifetime `'a` here: `<'a>` LL | y: &'a isize) | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 5 previous errors diff --git a/src/test/ui/where-clauses/where-lifetime-resolution.stderr b/src/test/ui/where-clauses/where-lifetime-resolution.stderr index 6c52664154bbf..22b2d264516a2 100644 --- a/src/test/ui/where-clauses/where-lifetime-resolution.stderr +++ b/src/test/ui/where-clauses/where-lifetime-resolution.stderr @@ -6,6 +6,8 @@ LL | fn f() where LL | for<'a> dyn Trait1<'a>: Trait1<'a>, // OK LL | (dyn for<'a> Trait1<'a>): Trait1<'a>, | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/where-lifetime-resolution.rs:8:52 @@ -15,6 +17,8 @@ LL | fn f() where ... LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, | ^^ undeclared lifetime + | + = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors From a9b64766a47ce7a0ad6768b7a74bae7fa991576e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 10 Jul 2020 07:24:18 +0900 Subject: [PATCH 16/20] Tweak wording --- src/librustc_resolve/late/diagnostics.rs | 2 +- src/test/ui/error-codes/E0261.stderr | 4 +-- .../feature-gate-in_band_lifetimes.stderr | 32 +++++++++---------- ...ssociated_type_undeclared_lifetimes.stderr | 4 +-- ...ethod-call-lifetime-args-unresolved.stderr | 2 +- src/test/ui/regions/regions-in-enums.stderr | 4 +-- src/test/ui/regions/regions-in-structs.stderr | 4 +-- .../ui/regions/regions-name-undeclared.stderr | 22 ++++++------- src/test/ui/regions/regions-undeclared.stderr | 8 ++--- .../where-lifetime-resolution.stderr | 4 +-- 10 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index bc97341243f27..3537fb388d013 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -1091,7 +1091,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { && suggests_in_band { err.help( - "if you want to use in-band lifetime bindings, \ + "if you want to experiment with in-band lifetime bindings, \ add `#![feature(in_band_lifetimes)]` to the crate attributes", ); } diff --git a/src/test/ui/error-codes/E0261.stderr b/src/test/ui/error-codes/E0261.stderr index f37e28d072db4..33d74feead513 100644 --- a/src/test/ui/error-codes/E0261.stderr +++ b/src/test/ui/error-codes/E0261.stderr @@ -6,7 +6,7 @@ LL | fn foo(x: &'a str) { } | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/E0261.rs:5:9 @@ -16,7 +16,7 @@ LL | struct Foo { LL | x: &'a str, | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors diff --git a/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr b/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr index 71a41c61f0dc7..0f0406b8e17d8 100644 --- a/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr +++ b/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr @@ -6,7 +6,7 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x } | | | help: consider introducing lifetime `'x` here: `<'x>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'x` --> $DIR/feature-gate-in_band_lifetimes.rs:3:23 @@ -16,7 +16,7 @@ LL | fn foo(x: &'x u8) -> &'x u8 { x } | | | help: consider introducing lifetime `'x` here: `<'x>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/feature-gate-in_band_lifetimes.rs:15:12 @@ -32,7 +32,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn inner_2(&self) -> &'b u8 { | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> X<'b> { @@ -50,7 +50,7 @@ LL | impl X<'b> { | | | help: consider introducing lifetime `'b` here: `<'b>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/feature-gate-in_band_lifetimes.rs:25:27 @@ -58,7 +58,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn inner_3(&self) -> &'b u8 { | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> X<'b> { @@ -76,7 +76,7 @@ LL | impl Y<&'a u8> { | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/feature-gate-in_band_lifetimes.rs:35:25 @@ -84,7 +84,7 @@ error[E0261]: use of undeclared lifetime name `'a` LL | fn inner(&self) -> &'a u8 { | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'a` here | LL | impl<'a> Y<&'a u8> { @@ -100,7 +100,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn any_lifetime() -> &'b u8; | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait MyTrait<'b, 'a> { @@ -116,7 +116,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8; | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait MyTrait<'b, 'a> { @@ -132,7 +132,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8; | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait MyTrait<'b, 'a> { @@ -150,7 +150,7 @@ LL | impl MyTrait<'a> for Y<&'a u8> { | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/feature-gate-in_band_lifetimes.rs:50:25 @@ -160,7 +160,7 @@ LL | impl MyTrait<'a> for Y<&'a u8> { | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/feature-gate-in_band_lifetimes.rs:53:31 @@ -168,7 +168,7 @@ error[E0261]: use of undeclared lifetime name `'a` LL | fn my_lifetime(&self) -> &'a u8 { self.0 } | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'a` here | LL | impl<'a> MyTrait<'a> for Y<&'a u8> { @@ -184,7 +184,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn any_lifetime() -> &'b u8 { &0 } | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> MyTrait<'a> for Y<&'a u8> { @@ -200,7 +200,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> MyTrait<'a> for Y<&'a u8> { @@ -216,7 +216,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> MyTrait<'a> for Y<&'a u8> { diff --git a/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr b/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr index 0e0fcebd0427c..f164c0d07a3c4 100644 --- a/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr +++ b/src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr @@ -4,7 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | + Deref>; | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | trait Iterable<'b> { @@ -20,7 +20,7 @@ error[E0261]: use of undeclared lifetime name `'undeclared` LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>; | ^^^^^^^^^^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'undeclared` here | LL | trait Iterable<'undeclared> { diff --git a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr index ed8da3dcddf99..93c0384fcc266 100644 --- a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -6,7 +6,7 @@ LL | fn main() { LL | 0.clone::<'a>(); | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to previous error diff --git a/src/test/ui/regions/regions-in-enums.stderr b/src/test/ui/regions/regions-in-enums.stderr index c20612346dce1..d56c1fbd119c8 100644 --- a/src/test/ui/regions/regions-in-enums.stderr +++ b/src/test/ui/regions/regions-in-enums.stderr @@ -6,7 +6,7 @@ LL | enum No0 { LL | X5(&'foo usize) | ^^^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-in-enums.rs:17:9 @@ -16,7 +16,7 @@ LL | enum No1 { LL | X6(&'a usize) | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-in-structs.stderr b/src/test/ui/regions/regions-in-structs.stderr index e65eb6f40b8ff..2750149d09735 100644 --- a/src/test/ui/regions/regions-in-structs.stderr +++ b/src/test/ui/regions/regions-in-structs.stderr @@ -6,7 +6,7 @@ LL | struct StructDecl { LL | a: &'a isize, | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-in-structs.rs:11:9 @@ -17,7 +17,7 @@ LL | a: &'a isize, LL | b: &'a isize, | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-name-undeclared.stderr b/src/test/ui/regions/regions-name-undeclared.stderr index abcc68a029348..57d39d59c8b04 100644 --- a/src/test/ui/regions/regions-name-undeclared.stderr +++ b/src/test/ui/regions/regions-name-undeclared.stderr @@ -4,7 +4,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn m4(&self, arg: &'b isize) { } | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> Foo<'a> { @@ -20,7 +20,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn m5(&'b self) { } | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> Foo<'a> { @@ -36,7 +36,7 @@ error[E0261]: use of undeclared lifetime name `'b` LL | fn m6(&self, arg: Foo<'b>) { } | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b, 'a> Foo<'a> { @@ -54,7 +54,7 @@ LL | type X = Option<&'a isize>; | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:27:13 @@ -64,7 +64,7 @@ LL | enum E { LL | E1(&'a isize) | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:30:13 @@ -74,7 +74,7 @@ LL | struct S { LL | f: &'a isize | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:32:14 @@ -84,7 +84,7 @@ LL | fn f(a: &'a isize) { } | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:40:17 @@ -94,7 +94,7 @@ LL | fn fn_types(a: &'a isize, | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/regions-name-undeclared.rs:42:36 @@ -103,7 +103,7 @@ LL | ... &'b isize, | ^^ undeclared lifetime | = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, @@ -120,7 +120,7 @@ LL | ... &'b isize)>, | ^^ undeclared lifetime | = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | fn fn_types<'b>(a: &'a isize, @@ -139,7 +139,7 @@ LL | fn fn_types(a: &'a isize, LL | c: &'a isize) | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 11 previous errors diff --git a/src/test/ui/regions/regions-undeclared.stderr b/src/test/ui/regions/regions-undeclared.stderr index 9dff312df48e9..f3cae184ccde8 100644 --- a/src/test/ui/regions/regions-undeclared.stderr +++ b/src/test/ui/regions/regions-undeclared.stderr @@ -12,7 +12,7 @@ LL | enum EnumDecl { LL | Foo(&'a isize), | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:5:10 @@ -23,7 +23,7 @@ LL | Foo(&'a isize), LL | Bar(&'a isize), | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:8:15 @@ -33,7 +33,7 @@ LL | fn fnDecl(x: &'a isize, | | | help: consider introducing lifetime `'a` here: `<'a>` | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:9:15 @@ -43,7 +43,7 @@ LL | fn fnDecl(x: &'a isize, LL | y: &'a isize) | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 5 previous errors diff --git a/src/test/ui/where-clauses/where-lifetime-resolution.stderr b/src/test/ui/where-clauses/where-lifetime-resolution.stderr index 22b2d264516a2..a704fea282899 100644 --- a/src/test/ui/where-clauses/where-lifetime-resolution.stderr +++ b/src/test/ui/where-clauses/where-lifetime-resolution.stderr @@ -7,7 +7,7 @@ LL | for<'a> dyn Trait1<'a>: Trait1<'a>, // OK LL | (dyn for<'a> Trait1<'a>): Trait1<'a>, | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error[E0261]: use of undeclared lifetime name `'b` --> $DIR/where-lifetime-resolution.rs:8:52 @@ -18,7 +18,7 @@ LL | fn f() where LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, | ^^ undeclared lifetime | - = help: if you want to use in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes + = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 2 previous errors From 0a7d2970e5947e7a2940a32e6975817a389b0708 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 7 Jul 2020 14:13:03 +1000 Subject: [PATCH 17/20] Eliminate `rust_input`. It has a single call site and having it as a separate (higher-order!) function makes the code harder to read. --- src/librustdoc/lib.rs | 54 ++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 8e2dd77cc1155..b02880ab4d3de 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -471,7 +471,29 @@ fn main_options(options: config::Options) -> i32 { // but we can't crates the Handler ahead of time because it's not Send let diag_opts = (options.error_format, options.edition, options.debugging_options.clone()); let show_coverage = options.show_coverage; - rust_input(options, move |out| { + + // First, parse the crate and extract all relevant information. + info!("starting to run rustc"); + + // Interpret the input file as a rust source file, passing it through the + // compiler all the way through the analysis passes. The rustdoc output is + // then generated from the cleaned AST of the crate. This runs all the + // plug/cleaning passes. + let result = rustc_driver::catch_fatal_errors(move || { + let crate_name = options.crate_name.clone(); + let crate_version = options.crate_version.clone(); + let (mut krate, renderinfo, renderopts) = core::run_core(options); + + info!("finished with rustc"); + + if let Some(name) = crate_name { + krate.name = name + } + + krate.version = crate_version; + + let out = Output { krate, renderinfo, renderopts }; + if show_coverage { // if we ran coverage, bail early, we don't need to also generate docs at this point // (also we didn't load in any of the useful passes) @@ -491,36 +513,6 @@ fn main_options(options: config::Options) -> i32 { rustc_driver::EXIT_FAILURE } } - }) -} - -/// Interprets the input file as a rust source file, passing it through the -/// compiler all the way through the analysis passes. The rustdoc output is then -/// generated from the cleaned AST of the crate. -/// -/// This form of input will run all of the plug/cleaning passes -fn rust_input(options: config::Options, f: F) -> R -where - R: 'static + Send, - F: 'static + Send + FnOnce(Output) -> R, -{ - // First, parse the crate and extract all relevant information. - info!("starting to run rustc"); - - let result = rustc_driver::catch_fatal_errors(move || { - let crate_name = options.crate_name.clone(); - let crate_version = options.crate_version.clone(); - let (mut krate, renderinfo, renderopts) = core::run_core(options); - - info!("finished with rustc"); - - if let Some(name) = crate_name { - krate.name = name - } - - krate.version = crate_version; - - f(Output { krate, renderinfo, renderopts }) }); match result { From 1e8ec2db1d3d695958a8040fbb3491a4378ef7ae Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 7 Jul 2020 13:10:19 +1000 Subject: [PATCH 18/20] Add an explanatory comment to `scoped_thread`. --- src/librustc_interface/util.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index fe091e920627c..438b72b0b6176 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -102,6 +102,8 @@ impl Write for Sink { } } +/// Like a `thread::Builder::spawn` followed by a `join()`, but avoids the need +/// for `'static` bounds. #[cfg(not(parallel_compiler))] pub fn scoped_thread R + Send, R: Send>(cfg: thread::Builder, f: F) -> R { struct Ptr(*mut ()); From 4ad5de22d182578e846a6ccc69940e76a820381c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 7 Jul 2020 13:15:02 +1000 Subject: [PATCH 19/20] Tweak `spawn_thread_pool`. This makes the two versions (parallel and non-parallel) more similar to each other. --- src/librustc_interface/util.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 438b72b0b6176..dc82219b33286 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -142,7 +142,7 @@ pub fn spawn_thread_pool R + Send, R: Send>( crate::callbacks::setup_callbacks(); - scoped_thread(cfg, || { + let main_handler = move || { rustc_ast::with_session_globals(edition, || { ty::tls::GCX_PTR.set(&Lock::new(0), || { if let Some(stderr) = stderr { @@ -151,7 +151,9 @@ pub fn spawn_thread_pool R + Send, R: Send>( f() }) }) - }) + }; + + scoped_thread(cfg, main_handler) } #[cfg(parallel_compiler)] @@ -161,12 +163,9 @@ pub fn spawn_thread_pool R + Send, R: Send>( stderr: &Option>>>, f: F, ) -> R { - use rayon::{ThreadBuilder, ThreadPool, ThreadPoolBuilder}; - - let gcx_ptr = &Lock::new(0); crate::callbacks::setup_callbacks(); - let mut config = ThreadPoolBuilder::new() + let mut config = rayon::ThreadPoolBuilder::new() .thread_name(|_| "rustc".to_string()) .acquire_thread_handler(jobserver::acquire_thread) .release_thread_handler(jobserver::release_thread) @@ -177,7 +176,7 @@ pub fn spawn_thread_pool R + Send, R: Send>( config = config.stack_size(size); } - let with_pool = move |pool: &ThreadPool| pool.install(move || f()); + let with_pool = move |pool: &rayon::ThreadPool| pool.install(move || f()); rustc_ast::with_session_globals(edition, || { rustc_ast::SESSION_GLOBALS.with(|ast_session_globals| { @@ -190,10 +189,12 @@ pub fn spawn_thread_pool R + Send, R: Send>( let main_handler = move |thread: ThreadBuilder| { rustc_ast::SESSION_GLOBALS.set(ast_session_globals, || { rustc_span::SESSION_GLOBALS.set(span_session_globals, || { - if let Some(stderr) = stderr { - io::set_panic(Some(box Sink(stderr.clone()))); - } - ty::tls::GCX_PTR.set(gcx_ptr, || thread.run()) + ty::tls::GCX_PTR.set(&Lock::new(0), || { + if let Some(stderr) = stderr { + io::set_panic(Some(box Sink(stderr.clone()))); + } + thread.run() + }) }) }) }; From 059d6cfc7dff34af2dc6da8f21d576226ccc4920 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 7 Jul 2020 13:41:08 +1000 Subject: [PATCH 20/20] Change some function names. A couple of these are quite long, but they do a much better job of explaining what they do, which was non-obvious before. --- src/librustc_interface/interface.rs | 16 ++++++++-------- src/librustc_interface/util.rs | 4 ++-- src/librustdoc/core.rs | 2 +- src/librustdoc/lib.rs | 5 ++++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index f89be02099e8c..e50622a005379 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -159,10 +159,7 @@ pub struct Config { pub registry: Registry, } -pub fn run_compiler_in_existing_thread_pool( - config: Config, - f: impl FnOnce(&Compiler) -> R, -) -> R { +pub fn create_compiler_and_run(config: Config, f: impl FnOnce(&Compiler) -> R) -> R { let registry = &config.registry; let (sess, codegen_backend) = util::create_session( config.opts, @@ -204,17 +201,20 @@ pub fn run_compiler_in_existing_thread_pool( pub fn run_compiler(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R { log::trace!("run_compiler"); let stderr = config.stderr.take(); - util::spawn_thread_pool( + util::setup_callbacks_and_run_in_thread_pool_with_globals( config.opts.edition, config.opts.debugging_opts.threads, &stderr, - || run_compiler_in_existing_thread_pool(config, f), + || create_compiler_and_run(config, f), ) } -pub fn default_thread_pool(edition: edition::Edition, f: impl FnOnce() -> R + Send) -> R { +pub fn setup_callbacks_and_run_in_default_thread_pool_with_globals( + edition: edition::Edition, + f: impl FnOnce() -> R + Send, +) -> R { // the 1 here is duplicating code in config.opts.debugging_opts.threads // which also defaults to 1; it ultimately doesn't matter as the default // isn't threaded, and just ignores this parameter - util::spawn_thread_pool(edition, 1, &None, f) + util::setup_callbacks_and_run_in_thread_pool_with_globals(edition, 1, &None, f) } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index dc82219b33286..75767d6c9f904 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -128,7 +128,7 @@ pub fn scoped_thread R + Send, R: Send>(cfg: thread::Builder, f: } #[cfg(not(parallel_compiler))] -pub fn spawn_thread_pool R + Send, R: Send>( +pub fn setup_callbacks_and_run_in_thread_pool_with_globals R + Send, R: Send>( edition: Edition, _threads: usize, stderr: &Option>>>, @@ -157,7 +157,7 @@ pub fn spawn_thread_pool R + Send, R: Send>( } #[cfg(parallel_compiler)] -pub fn spawn_thread_pool R + Send, R: Send>( +pub fn setup_callbacks_and_run_in_thread_pool_with_globals R + Send, R: Send>( edition: Edition, threads: usize, stderr: &Option>>>, diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index db98ec5d0a72e..80cc5182bef32 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -376,7 +376,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt registry: rustc_driver::diagnostics_registry(), }; - interface::run_compiler_in_existing_thread_pool(config, |compiler| { + interface::create_compiler_and_run(config, |compiler| { compiler.enter(|queries| { let sess = compiler.session(); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index b02880ab4d3de..57151e2b20002 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -437,7 +437,10 @@ fn main_args(args: &[String]) -> i32 { Ok(opts) => opts, Err(code) => return code, }; - rustc_interface::interface::default_thread_pool(options.edition, move || main_options(options)) + rustc_interface::interface::setup_callbacks_and_run_in_default_thread_pool_with_globals( + options.edition, + move || main_options(options), + ) } fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> i32 {