From f48a5dcf8f2427d15b8e8df51b610dbc3448816e Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 27 Mar 2019 16:37:50 -0400 Subject: [PATCH 01/11] Document std::fs::File close behavior ignoring errors --- src/libstd/fs.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index dfff44b88ea78..06d8ee99b64d1 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -21,7 +21,10 @@ use crate::time::SystemTime; /// it was opened with. Files also implement [`Seek`] to alter the logical cursor /// that the file contains internally. /// -/// Files are automatically closed when they go out of scope. +/// Files are automatically closed when they go out of scope. All errors are +/// ignored due to complications with correctly handling them. For instance, an +/// error in closing a file could mean that closing failed, or that the file had +/// an error before closing that was only unearthed by closing the file. /// /// # Examples /// From d8a6b632e3571fb3cbf113e39a7c8b8481be9495 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 30 Mar 2019 12:57:23 +0100 Subject: [PATCH 02/11] update stdsimd --- src/stdsimd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdsimd b/src/stdsimd index 12bdc2ed6b326..2792b45c97588 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 12bdc2ed6b32653866d02b42f0885d9cd8bd295e +Subproject commit 2792b45c975880038240d477adb0d66f760ac048 From b6ebe1bd9e4f6692c390326bca0ef06c24255719 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Mon, 1 Apr 2019 22:34:57 -0400 Subject: [PATCH 03/11] Document using `sync_all` --- src/libstd/fs.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 06d8ee99b64d1..99dd0d8eeeb0e 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -21,10 +21,9 @@ use crate::time::SystemTime; /// it was opened with. Files also implement [`Seek`] to alter the logical cursor /// that the file contains internally. /// -/// Files are automatically closed when they go out of scope. All errors are -/// ignored due to complications with correctly handling them. For instance, an -/// error in closing a file could mean that closing failed, or that the file had -/// an error before closing that was only unearthed by closing the file. +/// Files are automatically closed when they go out of scope. Errors detected +/// on closing are ignored by the implementation of `Drop`. Use the method +/// `sync_all` if these errors must be manually handled. /// /// # Examples /// From 76e82d6f52431b4877bbdc6413480680d9956967 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Tue, 2 Apr 2019 22:26:11 -0400 Subject: [PATCH 04/11] Link to sync_all --- src/libstd/fs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 99dd0d8eeeb0e..034564250c3a5 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -23,7 +23,7 @@ use crate::time::SystemTime; /// /// Files are automatically closed when they go out of scope. Errors detected /// on closing are ignored by the implementation of `Drop`. Use the method -/// `sync_all` if these errors must be manually handled. +/// [`sync_all`] if these errors must be manually handled. /// /// # Examples /// @@ -86,6 +86,7 @@ use crate::time::SystemTime; /// [`Read`]: ../io/trait.Read.html /// [`Write`]: ../io/trait.Write.html /// [`BufReader`]: ../io/struct.BufReader.html +/// [`sync_all`]: struct.File.html#method.sync_all #[stable(feature = "rust1", since = "1.0.0")] pub struct File { inner: fs_imp::File, From 5e3b1fceb0821da86689d688688b75ed6a7cc813 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 30 Mar 2019 12:55:20 +0100 Subject: [PATCH 05/11] update miri --- src/tools/miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri b/src/tools/miri index 72b4ee0381dec..ac61d29351124 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 72b4ee0381decf609204e5548c1f5e79bdfb18b7 +Subproject commit ac61d2935112474ff6c6d2ac3daf485adf5b5df8 From 087999ef586a980c06d5820d3d256b3251103d3a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 31 Mar 2019 16:18:45 +0200 Subject: [PATCH 06/11] try to fix rand feature flags --- Cargo.lock | 24 +---------------------- src/tools/rustc-workspace-hack/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7007017078e6..35e33e1609492 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2054,18 +2054,6 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.6.1" @@ -2093,14 +2081,6 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand_core" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand_core" version = "0.3.0" @@ -2560,7 +2540,7 @@ version = "1.0.0" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4205,10 +4185,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum racer 2.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "37c88638777cc178684cf648ca0e1dad56646ce105b8593dfe665c436300adc3" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" -"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" "checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a" "checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a" -"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" diff --git a/src/tools/rustc-workspace-hack/Cargo.toml b/src/tools/rustc-workspace-hack/Cargo.toml index 1aba52bafbbc7..d51841cd65075 100644 --- a/src/tools/rustc-workspace-hack/Cargo.toml +++ b/src/tools/rustc-workspace-hack/Cargo.toml @@ -57,7 +57,7 @@ features = [ [dependencies] curl-sys = { version = "0.4.13", features = ["http2", "libnghttp2-sys"], optional = true } parking_lot = { version = "0.7", features = ['nightly'] } -rand = { version = "0.5.5", features = ["i128_support"] } +rand = { version = "0.6.1", features = ["i128_support"] } serde = { version = "1.0.82", features = ['derive'] } serde_json = { version = "1.0.31", features = ["raw_value"] } smallvec = { version = "0.6", features = ['union', 'may_dangle'] } From c75a5a214b4cb59b8417714bab2d9452c53b354b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 3 Apr 2019 14:05:45 +0100 Subject: [PATCH 07/11] update miri --- src/tools/miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri b/src/tools/miri index ac61d29351124..82f9a0173011b 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit ac61d2935112474ff6c6d2ac3daf485adf5b5df8 +Subproject commit 82f9a0173011b96411d315b332754ee6b35cf00f From c2e0d7f1eb25bd9b4a8eaa7990cd0fd3a8c416bb Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 3 Apr 2019 15:44:49 -0700 Subject: [PATCH 08/11] Never return uninhabited values at all Functions with uninhabited return values are already marked `noreturn`, but we were still generating return instructions for this. When running with `-C passes=lint`, LLVM prints: Unusual: Return statement in function with noreturn attribute The LLVM manual makes a stronger statement about `noreturn` though: > This produces undefined behavior at runtime if the function ever does dynamically return. We now emit an `abort` anywhere that would have tried to return an uninhabited value. --- src/librustc_codegen_ssa/mir/block.rs | 7 ++++++ src/test/codegen/noreturn-uninhabited.rs | 32 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/test/codegen/noreturn-uninhabited.rs diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 53e8f7ed88b4e..aaa0be20412f2 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -238,6 +238,13 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } } + if self.fn_ty.ret.layout.abi.is_uninhabited() { + // Functions with uninhabited return values are marked `noreturn`, + // so we should make sure that we never actually do. + bx.abort(); + bx.unreachable(); + return; + } let llval = match self.fn_ty.ret.mode { PassMode::Ignore(IgnoreMode::Zst) | PassMode::Indirect(..) => { bx.ret_void(); diff --git a/src/test/codegen/noreturn-uninhabited.rs b/src/test/codegen/noreturn-uninhabited.rs new file mode 100644 index 0000000000000..1b65da9f2877a --- /dev/null +++ b/src/test/codegen/noreturn-uninhabited.rs @@ -0,0 +1,32 @@ +// compile-flags: -g -C no-prepopulate-passes +// ignore-tidy-linelength + +#![crate_type = "lib"] + +#[derive(Clone, Copy)] +pub enum EmptyEnum {} + +#[no_mangle] +pub fn empty(x: &EmptyEnum) -> EmptyEnum { + // CHECK: @empty({{.*}}) unnamed_addr #0 + // CHECK-NOT: ret void + // CHECK: call void @llvm.trap() + // CHECK: unreachable + *x +} + +pub struct Foo(String, EmptyEnum); + +#[no_mangle] +pub fn foo(x: String, y: &EmptyEnum) -> Foo { + // CHECK: @foo({{.*}}) unnamed_addr #0 + // CHECK-NOT: ret %Foo + // CHECK: call void @llvm.trap() + // CHECK: unreachable + Foo(x, *y) +} + +// CHECK: attributes #0 = {{{.*}} noreturn {{.*}}} + +// CHECK: DISubprogram(name: "empty", {{.*}} DIFlagNoReturn +// CHECK: DISubprogram(name: "foo", {{.*}} DIFlagNoReturn From a969d409874f91e197a1cd336a368f02d8a3ce47 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Wed, 3 Apr 2019 23:21:10 -0400 Subject: [PATCH 09/11] File: Add documentation about dropping to sync_all --- src/libstd/fs.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 034564250c3a5..c0d4dfc892794 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -394,9 +394,13 @@ impl File { /// Attempts to sync all OS-internal metadata to disk. /// - /// This function will attempt to ensure that all in-core data reaches the + /// This function will attempt to ensure that all in-memory data reaches the /// filesystem before returning. /// + /// This can be used to handle errors that would otherwise only be caught + /// when the `File` is closed. Dropping a file will ignore errors in + /// synchronizing this in-memory data. + /// /// # Examples /// /// ```no_run From 4c9c2cf160ef7b79ef8c664628262c5fa8cc9cab Mon Sep 17 00:00:00 2001 From: lzutao Date: Thu, 4 Apr 2019 12:20:53 +0700 Subject: [PATCH 10/11] Add description for -Os and -Oz in rustc.1 --- src/doc/man/rustc.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/man/rustc.1 b/src/doc/man/rustc.1 index 8f611063dbe5d..1b5e305cddc2d 100644 --- a/src/doc/man/rustc.1 +++ b/src/doc/man/rustc.1 @@ -261,7 +261,7 @@ full debug info with variable and type information. .RE .TP \fBopt\-level\fR=\fIVAL\fR -Optimize with possible levels 0\[en]3 +Optimize with possible levels 0\[en]3, s (optimize for size), or z (for minimal size) .SH ENVIRONMENT From 42d652ecd6709b756d95fc42615b166aacd2ea07 Mon Sep 17 00:00:00 2001 From: CrLF0710 Date: Thu, 4 Apr 2019 14:15:51 +0800 Subject: [PATCH 11/11] Disable stack probing for gnux32. --- src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs b/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs index 0b2d7aacc4ddf..73151b194de42 100644 --- a/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs +++ b/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs @@ -5,7 +5,8 @@ pub fn target() -> TargetResult { base.cpu = "x86-64".to_string(); base.max_atomic_width = Some(64); base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mx32".to_string()); - base.stack_probes = true; + // BUG: temporarily workaround #59674 + base.stack_probes = false; base.has_elf_tls = false; // BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI // breaks code gen. See LLVM bug 36743