about summary refs log tree commit diff
diff options
context:
space:
mode:
authorantoyo <antoyo@users.noreply.github.com>2022-08-27 12:09:37 -0400
committerGitHub <noreply@github.com>2022-08-27 12:09:37 -0400
commitb4626b3ca07c4fcdce1d96840567005e294e5ecc (patch)
tree3fb39322d5717e88333d80eb6ca4dd996f1688a0
parentb4eb2c30a262763d59711d285979facc95e1ba56 (diff)
parent61a7b96c800c7f0a338b3f8f4b5b1e89f82b1668 (diff)
downloadrust-b4626b3ca07c4fcdce1d96840567005e294e5ecc.tar.gz
rust-b4626b3ca07c4fcdce1d96840567005e294e5ecc.zip
Merge pull request #209 from rust-lang/2022-08-26_sync_from_rust
2022/08/26 sync from rust
-rw-r--r--example/alloc_system.rs2
-rw-r--r--example/mini_core.rs55
-rw-r--r--example/mini_core_hello_world.rs7
-rw-r--r--failing-ui-tests.txt10
-rw-r--r--patches/0024-core-Disable-portable-simd-test.patch23
-rw-r--r--rust-toolchain2
-rw-r--r--src/abi.rs2
-rw-r--r--src/allocator.rs2
-rw-r--r--src/archive.rs103
-rw-r--r--src/base.rs2
-rw-r--r--src/builder.rs21
-rw-r--r--src/callee.rs2
-rw-r--r--src/common.rs30
-rw-r--r--src/context.rs4
-rw-r--r--src/intrinsic/mod.rs10
-rw-r--r--src/intrinsic/simd.rs3
-rw-r--r--src/lib.rs20
-rw-r--r--src/mono_item.rs2
-rw-r--r--src/type_.rs13
-rw-r--r--src/type_of.rs2
-rwxr-xr-xtest.sh8
-rw-r--r--tests/run/array.rs2
-rw-r--r--tests/run/assign.rs2
-rw-r--r--tests/run/closure.rs2
-rw-r--r--tests/run/condition.rs2
-rw-r--r--tests/run/fun_ptr.rs2
-rw-r--r--tests/run/int_overflow.rs2
-rw-r--r--tests/run/mut_ref.rs2
-rw-r--r--tests/run/operations.rs2
-rw-r--r--tests/run/ptr_cast.rs2
30 files changed, 192 insertions, 149 deletions
diff --git a/example/alloc_system.rs b/example/alloc_system.rs
index 5f66ca67f2d..89661918d05 100644
--- a/example/alloc_system.rs
+++ b/example/alloc_system.rs
@@ -156,7 +156,7 @@ mod platform {
     struct Header(*mut u8);
     const HEAP_ZERO_MEMORY: DWORD = 0x00000008;
     unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header {
-        &mut *(ptr as *mut Header).offset(-1)
+        &mut *(ptr as *mut Header).sub(1)
     }
     unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 {
         let aligned = ptr.add(align - (ptr as usize & (align - 1)));
diff --git a/example/mini_core.rs b/example/mini_core.rs
index a8435287d9f..b23ecda35d3 100644
--- a/example/mini_core.rs
+++ b/example/mini_core.rs
@@ -1,6 +1,6 @@
 #![feature(
     no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
-    untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
+    decl_macro, rustc_attrs, transparent_unions, auto_traits,
     thread_local
 )]
 #![no_core]
@@ -39,14 +39,14 @@ impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut
 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
 // *mut T -> *mut U
 impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
-impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
+impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
 
 #[lang = "receiver"]
 pub trait Receiver {}
 
 impl<T: ?Sized> Receiver for &T {}
 impl<T: ?Sized> Receiver for &mut T {}
-impl<T: ?Sized> Receiver for Box<T> {}
+impl<T: ?Sized, A: Allocator> Receiver for Box<T, A> {}
 
 #[lang = "copy"]
 pub unsafe trait Copy {}
@@ -411,7 +411,15 @@ pub trait FnMut<Args>: FnOnce<Args> {
 
 #[lang = "panic"]
 #[track_caller]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
+    unsafe {
+        libc::puts("Panicking\n\0" as *const str as *const u8);
+        intrinsics::abort();
+    }
+}
+
+#[lang = "panic_no_unwind"]
+fn panic_no_unwind() -> ! {
     unsafe {
         libc::puts("Panicking\n\0" as *const str as *const u8);
         intrinsics::abort();
@@ -450,17 +458,32 @@ pub trait Deref {
 pub trait Allocator {
 }
 
+impl Allocator for () {}
+
 pub struct Global;
 
 impl Allocator for Global {}
 
+#[repr(transparent)]
+#[rustc_layout_scalar_valid_range_start(1)]
+#[rustc_nonnull_optimization_guaranteed]
+pub struct NonNull<T: ?Sized>(pub *const T);
+
+impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
+impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
+
+pub struct Unique<T: ?Sized> {
+    pub pointer: NonNull<T>,
+    pub _marker: PhantomData<T>,
+}
+
+impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
+impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
+
 #[lang = "owned_box"]
-pub struct Box<
-    T: ?Sized,
-    A: Allocator = Global,
->(*mut T, A);
+pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A);
 
-impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
+impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
 
 impl<T: ?Sized, A: Allocator> Drop for Box<T, A> {
     fn drop(&mut self) {
@@ -468,7 +491,7 @@ impl<T: ?Sized, A: Allocator> Drop for Box<T, A> {
     }
 }
 
-impl<T> Deref for Box<T> {
+impl<T: ?Sized, A: Allocator> Deref for Box<T, A> {
     type Target = T;
 
     fn deref(&self) -> &Self::Target {
@@ -482,8 +505,8 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
 }
 
 #[lang = "box_free"]
-unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: *mut T, alloc: A) {
-    libc::free(ptr as *mut u8);
+unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, _alloc: ()) {
+    libc::free(ptr.pointer.0 as *mut u8);
 }
 
 #[lang = "drop"]
@@ -505,16 +528,18 @@ pub union MaybeUninit<T> {
 }
 
 pub mod intrinsics {
+    use crate::Sized;
+
     extern "rust-intrinsic" {
         pub fn abort() -> !;
         pub fn size_of<T>() -> usize;
-        pub fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
+        pub fn size_of_val<T: ?Sized>(val: *const T) -> usize;
         pub fn min_align_of<T>() -> usize;
-        pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
+        pub fn min_align_of_val<T: ?Sized>(val: *const T) -> usize;
         pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
         pub fn transmute<T, U>(e: T) -> U;
         pub fn ctlz_nonzero<T>(x: T) -> T;
-        pub fn needs_drop<T>() -> bool;
+        pub fn needs_drop<T: ?Sized>() -> bool;
         pub fn bitreverse<T>(x: T) -> T;
         pub fn bswap<T>(x: T) -> T;
         pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs
index 69d591565ac..14fd9eeffa6 100644
--- a/example/mini_core_hello_world.rs
+++ b/example/mini_core_hello_world.rs
@@ -47,6 +47,11 @@ struct NoisyDrop {
     inner: NoisyDropInner,
 }
 
+struct NoisyDropUnsized {
+    inner: NoisyDropInner,
+    text: str,
+}
+
 struct NoisyDropInner;
 
 impl Drop for NoisyDrop {
@@ -184,7 +189,9 @@ fn main() {
         assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8);
 
         assert!(!intrinsics::needs_drop::<u8>());
+        assert!(!intrinsics::needs_drop::<[u8]>());
         assert!(intrinsics::needs_drop::<NoisyDrop>());
+        assert!(intrinsics::needs_drop::<NoisyDropUnsized>());
 
         Unique {
             pointer: 0 as *const &str,
diff --git a/failing-ui-tests.txt b/failing-ui-tests.txt
index 717d0d39331..0e34110a060 100644
--- a/failing-ui-tests.txt
+++ b/failing-ui-tests.txt
@@ -9,28 +9,28 @@ src/test/ui/allocator/xcrate-use.rs
 src/test/ui/allocator/xcrate-use2.rs
 src/test/ui/asm/may_unwind.rs
 src/test/ui/asm/x86_64/const.rs
+src/test/ui/asm/x86_64/issue-96797.rs
 src/test/ui/asm/x86_64/multiple-clobber-abi.rs
 src/test/ui/async-await/async-fn-size-moved-locals.rs
 src/test/ui/async-await/async-fn-size-uninit-locals.rs
-src/test/ui/backtrace.rs
 src/test/ui/cfg/cfg-panic.rs
 src/test/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs
 src/test/ui/functions-closures/parallel-codegen-closures.rs
 src/test/ui/generator/size-moved-locals.rs
-src/test/ui/issues/issue-32518.rs
+src/test/ui/issues/issue-40883.rs
 src/test/ui/issues/issue-47364.rs
-src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs
 src/test/ui/linkage-attr/linkage1.rs
 src/test/ui/lto/dylib-works.rs
-src/test/ui/mir/mir_heavy_promoted.rs
+src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs
+src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs
 src/test/ui/numbers-arithmetic/saturating-float-casts.rs
 src/test/ui/polymorphization/promoted-function.rs
+src/test/ui/process/nofile-limit.rs
 src/test/ui/runtime/rt-explody-panic-payloads.rs
 src/test/ui/sepcomp/sepcomp-cci.rs
 src/test/ui/sepcomp/sepcomp-extern.rs
 src/test/ui/sepcomp/sepcomp-fns-backwards.rs
 src/test/ui/sepcomp/sepcomp-fns.rs
-src/test/ui/sepcomp/sepcomp-lib.rs
 src/test/ui/sepcomp/sepcomp-statics.rs
 src/test/ui/simd/generics.rs
 src/test/ui/simd/intrinsic/float-math-pass.rs
diff --git a/patches/0024-core-Disable-portable-simd-test.patch b/patches/0024-core-Disable-portable-simd-test.patch
index d5fa1cec061..7ea0eebe6a1 100644
--- a/patches/0024-core-Disable-portable-simd-test.patch
+++ b/patches/0024-core-Disable-portable-simd-test.patch
@@ -1,25 +1,25 @@
-From b1ae000f6da1abd3b8e9b80c40bc11c89b8ae93c Mon Sep 17 00:00:00 2001
-From: bjorn3 <bjorn3@users.noreply.github.com>
-Date: Thu, 30 Dec 2021 16:54:40 +0100
-Subject: [PATCH] [core] Disable portable-simd test
+From f845df4056f5ba16b9f5bd703460c4ac40ea03b9 Mon Sep 17 00:00:00 2001
+From: Antoni Boucher <bouanto@zoho.com>
+Date: Fri, 26 Aug 2022 20:38:58 -0400
+Subject: [PATCH] Edit
 
 ---
- library/core/tests/lib.rs | 1 -
- 1 file changed, 1 deletion(-)
+ library/core/tests/lib.rs | 2 --
+ 1 file changed, 2 deletions(-)
 
 diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
-index 06c7be0..359e2e7 100644
+index 59510d3..179bf26 100644
 --- a/library/core/tests/lib.rs
 +++ b/library/core/tests/lib.rs
-@@ -75,7 +75,6 @@
- #![feature(never_type)]
+@@ -77,7 +77,6 @@
  #![feature(unwrap_infallible)]
  #![feature(result_into_ok_or_err)]
+ #![feature(pointer_byte_offsets)]
 -#![feature(portable_simd)]
  #![feature(ptr_metadata)]
  #![feature(once_cell)]
  #![feature(option_result_contains)]
-@@ -127,7 +126,6 @@ mod pin;
+@@ -135,7 +134,6 @@ mod pin;
  mod pin_macro;
  mod ptr;
  mod result;
@@ -27,3 +27,6 @@ index 06c7be0..359e2e7 100644
  mod slice;
  mod str;
  mod str_lossy;
+-- 
+2.26.2.7.g19db9cfb68.dirty
+
diff --git a/rust-toolchain b/rust-toolchain
index b20aeb979ad..775d9906bf4 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1,3 +1,3 @@
 [toolchain]
-channel = "nightly-2022-06-06"
+channel = "nightly-2022-08-26"
 components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
diff --git a/src/abi.rs b/src/abi.rs
index 2c796d0f69e..0ed3e1fbe93 100644
--- a/src/abi.rs
+++ b/src/abi.rs
@@ -1,6 +1,6 @@
 use gccjit::{ToLValue, ToRValue, Type};
 use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeMethods};
-use rustc_data_structures::stable_set::FxHashSet;
+use rustc_data_structures::fx::FxHashSet;
 use rustc_middle::bug;
 use rustc_middle::ty::Ty;
 use rustc_target::abi::call::{CastTarget, FnAbi, PassMode, Reg, RegKind};
diff --git a/src/allocator.rs b/src/allocator.rs
index 60985003a9e..11482c69d59 100644
--- a/src/allocator.rs
+++ b/src/allocator.rs
@@ -127,7 +127,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
 
     let name = OomStrategy::SYMBOL.to_string();
     let global = context.new_global(None, GlobalKind::Exported, i8, name);
-    let value = tcx.sess.opts.debugging_opts.oom.should_panic();
+    let value = tcx.sess.opts.unstable_opts.oom.should_panic();
     let value = context.new_rvalue_from_int(i8, value as i32);
     global.global_set_initializer_rvalue(value);
 }
diff --git a/src/archive.rs b/src/archive.rs
index fac532f3e9c..f863abdcc97 100644
--- a/src/archive.rs
+++ b/src/archive.rs
@@ -1,15 +1,13 @@
 use std::fs::File;
 use std::path::{Path, PathBuf};
 
-use rustc_codegen_ssa::back::archive::ArchiveBuilder;
+use rustc_codegen_ssa::back::archive::{ArchiveBuilder, ArchiveBuilderBuilder};
 use rustc_session::Session;
 
-use rustc_data_structures::temp_dir::MaybeTempDir;
 use rustc_session::cstore::DllImport;
 
 struct ArchiveConfig<'a> {
     sess: &'a Session,
-    dst: PathBuf,
     use_native_ar: bool,
     use_gnu_style_archive: bool,
 }
@@ -23,66 +21,44 @@ enum ArchiveEntry {
     File(PathBuf),
 }
 
-pub struct ArArchiveBuilder<'a> {
-    config: ArchiveConfig<'a>,
-    src_archives: Vec<(PathBuf, ar::Archive<File>)>,
-    // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at
-    // the end of an archive for linkers to not get confused.
-    entries: Vec<(String, ArchiveEntry)>,
-}
+pub struct ArArchiveBuilderBuilder;
 
-impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
-    fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self {
+impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
+    fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder<'a> + 'a> {
         let config = ArchiveConfig {
             sess,
-            dst: output.to_path_buf(),
             use_native_ar: false,
             // FIXME test for linux and System V derivatives instead
             use_gnu_style_archive: sess.target.options.archive_format == "gnu",
         };
 
-        let (src_archives, entries) = if let Some(input) = input {
-            let mut archive = ar::Archive::new(File::open(input).unwrap());
-            let mut entries = Vec::new();
-
-            let mut i = 0;
-            while let Some(entry) = archive.next_entry() {
-                let entry = entry.unwrap();
-                entries.push((
-                    String::from_utf8(entry.header().identifier().to_vec()).unwrap(),
-                    ArchiveEntry::FromArchive {
-                        archive_index: 0,
-                        entry_index: i,
-                    },
-                ));
-                i += 1;
-            }
-
-            (vec![(input.to_owned(), archive)], entries)
-        } else {
-            (vec![], Vec::new())
-        };
-
-        ArArchiveBuilder {
+        Box::new(ArArchiveBuilder {
             config,
-            src_archives,
-            entries,
-        }
+            src_archives: vec![],
+            entries: vec![],
+        })
     }
 
-    fn src_files(&mut self) -> Vec<String> {
-        self.entries.iter().map(|(name, _)| name.clone()).collect()
+    fn create_dll_import_lib(
+        &self,
+        _sess: &Session,
+        _lib_name: &str,
+        _dll_imports: &[DllImport],
+        _tmpdir: &Path,
+    ) -> PathBuf {
+        unimplemented!();
     }
+}
 
-    fn remove_file(&mut self, name: &str) {
-        let index = self
-            .entries
-            .iter()
-            .position(|(entry_name, _)| entry_name == name)
-            .expect("Tried to remove file not existing in src archive");
-        self.entries.remove(index);
-    }
+pub struct ArArchiveBuilder<'a> {
+    config: ArchiveConfig<'a>,
+    src_archives: Vec<(PathBuf, ar::Archive<File>)>,
+    // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at
+    // the end of an archive for linkers to not get confused.
+    entries: Vec<(String, ArchiveEntry)>,
+}
 
+impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
     fn add_file(&mut self, file: &Path) {
         self.entries.push((
             file.file_name().unwrap().to_str().unwrap().to_string(),
@@ -90,10 +66,11 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
         ));
     }
 
-    fn add_archive<F>(&mut self, archive_path: &Path, mut skip: F) -> std::io::Result<()>
-    where
-        F: FnMut(&str) -> bool + 'static,
-    {
+    fn add_archive(
+        &mut self,
+        archive_path: &Path,
+        mut skip: Box<dyn FnMut(&str) -> bool + 'static>,
+    ) -> std::io::Result<()> {
         let mut archive = ar::Archive::new(std::fs::File::open(&archive_path)?);
         let archive_index = self.src_archives.len();
 
@@ -113,7 +90,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
         Ok(())
     }
 
-    fn build(mut self) {
+    fn build(mut self: Box<Self>, output: &Path) -> bool {
         use std::process::Command;
 
         fn add_file_using_ar(archive: &Path, file: &Path) {
@@ -133,19 +110,21 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
         }
 
         let mut builder = if self.config.use_native_ar {
-            BuilderKind::NativeAr(&self.config.dst)
+            BuilderKind::NativeAr(output)
         } else if self.config.use_gnu_style_archive {
             BuilderKind::Gnu(ar::GnuBuilder::new(
-                File::create(&self.config.dst).unwrap(),
+                File::create(output).unwrap(),
                 self.entries
                     .iter()
                     .map(|(name, _)| name.as_bytes().to_vec())
                     .collect(),
             ))
         } else {
-            BuilderKind::Bsd(ar::Builder::new(File::create(&self.config.dst).unwrap()))
+            BuilderKind::Bsd(ar::Builder::new(File::create(output).unwrap()))
         };
 
+        let any_members = !self.entries.is_empty();
+
         // Add all files
         for (entry_name, entry) in self.entries.into_iter() {
             match entry {
@@ -198,17 +177,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
         std::mem::drop(builder);
 
         // Run ranlib to be able to link the archive
-        let status = std::process::Command::new("ranlib")
-            .arg(self.config.dst)
-            .status()
-            .expect("Couldn't run ranlib");
+        let status =
+            std::process::Command::new("ranlib").arg(output).status().expect("Couldn't run ranlib");
 
         if !status.success() {
             self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code()));
         }
-    }
 
-    fn inject_dll_import_lib(&mut self, _lib_name: &str, _dll_imports: &[DllImport], _tmpdir: &MaybeTempDir) {
-        unimplemented!();
+        any_members
     }
 }
diff --git a/src/base.rs b/src/base.rs
index 42194b526e6..8cc9581e842 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -121,7 +121,7 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_
         // NOTE: Rust relies on LLVM not doing TBAA (https://github.com/rust-lang/unsafe-code-guidelines/issues/292).
         context.add_command_line_option("-fno-strict-aliasing");
 
-        if tcx.sess.opts.debugging_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) {
+        if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) {
             context.add_command_line_option("-ffunction-sections");
             context.add_command_line_option("-fdata-sections");
         }
diff --git a/src/builder.rs b/src/builder.rs
index bcbaad39044..41df7e647b5 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -30,7 +30,7 @@ use rustc_codegen_ssa::traits::{
     OverflowOp,
     StaticBuilderMethods,
 };
-use rustc_data_structures::stable_set::FxHashSet;
+use rustc_data_structures::fx::FxHashSet;
 use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
 use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers, TyAndLayout};
 use rustc_span::Span;
@@ -820,16 +820,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
         // TODO(antoyo)
     }
 
-    fn type_metadata(&mut self, _function: RValue<'gcc>, _typeid: String) {
-        // Unsupported.
-    }
-
-    fn typeid_metadata(&mut self, _typeid: String) -> RValue<'gcc> {
-        // Unsupported.
-        self.context.new_rvalue_from_int(self.int_type, 0)
-    }
-
-
     fn store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> {
         self.store_with_flags(val, ptr, align, MemFlags::empty())
     }
@@ -1195,6 +1185,15 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
     fn atomic_cmpxchg(&mut self, dst: RValue<'gcc>, cmp: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering, failure_order: AtomicOrdering, weak: bool) -> RValue<'gcc> {
         let expected = self.current_func().new_local(None, cmp.get_type(), "expected");
         self.llbb().add_assignment(None, expected, cmp);
+        // NOTE: gcc doesn't support a failure memory model that is stronger than the success
+        // memory model.
+        let order =
+            if failure_order as i32 > order as i32 {
+                failure_order
+            }
+            else {
+                order
+            };
         let success = self.compare_exchange(dst, expected, src, order, failure_order, weak);
 
         let pair_type = self.cx.type_struct(&[src.get_type(), self.bool_type], false);
diff --git a/src/callee.rs b/src/callee.rs
index d7bbf1d34ef..be7d48b2279 100644
--- a/src/callee.rs
+++ b/src/callee.rs
@@ -2,7 +2,7 @@
 use gccjit::{FnAttribute, Visibility};
 use gccjit::{FunctionType, RValue};
 use rustc_codegen_ssa::traits::BaseTypeMethods;
-use rustc_middle::ty::{self, Instance, TypeFoldable};
+use rustc_middle::ty::{self, Instance, TypeVisitable};
 use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
 
 use crate::abi::FnAbiGccExt;
diff --git a/src/common.rs b/src/common.rs
index 9c55692dea1..1d44dc48668 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -9,10 +9,8 @@ use rustc_codegen_ssa::traits::{
     StaticMethods,
 };
 use rustc_middle::mir::Mutability;
-use rustc_middle::ty::ScalarInt;
 use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
 use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
-use rustc_span::Symbol;
 use rustc_target::abi::{self, HasDataLayout, Pointer, Size};
 
 use crate::consts::const_alloc_to_gcc;
@@ -125,12 +123,15 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
         self.context.new_rvalue_from_double(typ, val)
     }
 
-    fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) {
-        let s_str = s.as_str();
-        let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
-            self.global_string(s_str)
-        });
-        let len = s_str.len();
+    fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) {
+        let str_global = *self
+            .const_str_cache
+            .borrow_mut()
+            .raw_entry_mut()
+            .from_key(s)
+            .or_insert_with(|| (s.to_owned(), self.global_string(s)))
+            .1;
+        let len = s.len();
         let cs = self.const_ptrcast(str_global.get_address(None),
             self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self)),
         );
@@ -157,13 +158,13 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
         None
     }
 
+    fn zst_to_backend(&self, _ty: Type<'gcc>) -> RValue<'gcc> {
+        self.const_undef(self.type_ix(0))
+    }
+
     fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> {
         let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
         match cv {
-            Scalar::Int(ScalarInt::ZST) => {
-                assert_eq!(0, layout.size(self).bytes());
-                self.const_undef(self.type_ix(0))
-            }
             Scalar::Int(int) => {
                 let data = int.assert_bits(layout.size(self));
 
@@ -210,6 +211,11 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
                         GlobalAlloc::Function(fn_instance) => {
                             self.get_fn_addr(fn_instance)
                         },
+                        GlobalAlloc::VTable(ty, trait_ref) => {
+                            let alloc = self.tcx.global_alloc(self.tcx.vtable_allocation((ty, trait_ref))).unwrap_memory();
+                            let init = const_alloc_to_gcc(self, alloc);
+                            self.static_addr_of(init, alloc.inner().align, None)
+                        }
                         GlobalAlloc::Static(def_id) => {
                             assert!(self.tcx.is_static(def_id));
                             self.get_static(def_id).get_address(None)
diff --git a/src/context.rs b/src/context.rs
index 9879e31c2ea..2699559dc2a 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -13,7 +13,7 @@ use rustc_middle::mir::mono::CodegenUnit;
 use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
 use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, TyAndLayout, LayoutOfHelpers};
 use rustc_session::Session;
-use rustc_span::{Span, Symbol};
+use rustc_span::Span;
 use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
 use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
 
@@ -99,7 +99,7 @@ pub struct CodegenCx<'gcc, 'tcx> {
     pub global_lvalues: RefCell<FxHashMap<RValue<'gcc>, LValue<'gcc>>>,
 
     /// Cache of constant strings,
-    pub const_str_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,
+    pub const_str_cache: RefCell<FxHashMap<String, LValue<'gcc>>>,
 
     /// Cache of globals.
     pub globals: RefCell<FxHashMap<String, RValue<'gcc>>>,
diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs
index 1315edf0891..e3461b97973 100644
--- a/src/intrinsic/mod.rs
+++ b/src/intrinsic/mod.rs
@@ -356,6 +356,16 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
         self.context.new_rvalue_from_int(self.int_type, 0)
     }
 
+    fn type_checked_load(
+        &mut self,
+        _llvtable: Self::Value,
+        _vtable_byte_offset: u64,
+        _typeid: Self::Value,
+    ) -> Self::Value {
+        // Unsupported.
+        self.context.new_rvalue_from_int(self.int_type, 0)
+    }
+
     fn va_start(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> {
         unimplemented!();
     }
diff --git a/src/intrinsic/simd.rs b/src/intrinsic/simd.rs
index 9c2a1401a15..dbf6ee6d285 100644
--- a/src/intrinsic/simd.rs
+++ b/src/intrinsic/simd.rs
@@ -395,9 +395,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>,
         args: &[OperandRef<'tcx, RValue<'gcc>>],
     ) -> Result<RValue<'gcc>, ()> {
         macro_rules! emit_error {
-            ($msg: tt) => {
-                emit_error!($msg, )
-            };
             ($msg: tt, $($fmt: tt)*) => {
                 span_invalid_monomorphization_error(
                     bx.sess(), span,
diff --git a/src/lib.rs b/src/lib.rs
index b3cbf344ad1..e43ee5cf21d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,7 +6,14 @@
  * TODO(antoyo): remove the patches.
  */
 
-#![feature(rustc_private, decl_macro, associated_type_bounds, never_type, trusted_len)]
+#![feature(
+    rustc_private,
+    decl_macro,
+    associated_type_bounds,
+    never_type,
+    trusted_len,
+    hash_raw_entry
+)]
 #![allow(broken_intra_doc_links)]
 #![recursion_limit="256"]
 #![warn(rust_2018_idioms)]
@@ -128,15 +135,16 @@ impl CodegenBackend for GccCodegenBackend {
     fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorGuaranteed> {
         use rustc_codegen_ssa::back::link::link_binary;
 
-        link_binary::<crate::archive::ArArchiveBuilder<'_>>(
+        link_binary(
             sess,
+            &crate::archive::ArArchiveBuilderBuilder,
             &codegen_results,
             outputs,
         )
     }
 
-    fn target_features(&self, sess: &Session) -> Vec<Symbol> {
-        target_features(sess)
+    fn target_features(&self, sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
+        target_features(sess, allow_unstable)
     }
 }
 
@@ -293,12 +301,12 @@ pub fn target_cpu(sess: &Session) -> &str {
     }
 }
 
-pub fn target_features(sess: &Session) -> Vec<Symbol> {
+pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
     supported_target_features(sess)
         .iter()
         .filter_map(
             |&(feature, gate)| {
-                if sess.is_nightly_build() || gate.is_none() { Some(feature) } else { None }
+                if sess.is_nightly_build() || allow_unstable || gate.is_none() { Some(feature) } else { None }
             },
         )
         .filter(|_feature| {
diff --git a/src/mono_item.rs b/src/mono_item.rs
index d0d6b9b5bfe..ce439d339b6 100644
--- a/src/mono_item.rs
+++ b/src/mono_item.rs
@@ -4,7 +4,7 @@ use rustc_codegen_ssa::traits::PreDefineMethods;
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::mir::mono::{Linkage, Visibility};
-use rustc_middle::ty::{self, Instance, TypeFoldable};
+use rustc_middle::ty::{self, Instance, TypeVisitable};
 use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
 
 use crate::attributes;
diff --git a/src/type_.rs b/src/type_.rs
index b85aad7c00b..c97e9586005 100644
--- a/src/type_.rs
+++ b/src/type_.rs
@@ -1,7 +1,7 @@
 use std::convert::TryInto;
 
 use gccjit::{RValue, Struct, Type};
-use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods};
+use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, TypeMembershipMethods};
 use rustc_codegen_ssa::common::TypeKind;
 use rustc_middle::{bug, ty};
 use rustc_middle::ty::layout::TyAndLayout;
@@ -290,3 +290,14 @@ pub fn struct_fields<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout
 
     (result, packed)
 }
+
+impl<'gcc, 'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
+    fn set_type_metadata(&self, _function: RValue<'gcc>, _typeid: String) {
+        // Unsupported.
+    }
+
+    fn typeid_metadata(&self, _typeid: String) -> RValue<'gcc> {
+        // Unsupported.
+        self.context.new_rvalue_from_int(self.int_type, 0)
+    }
+}
diff --git a/src/type_of.rs b/src/type_of.rs
index c7aa4239c7f..29d394dbba4 100644
--- a/src/type_of.rs
+++ b/src/type_of.rs
@@ -3,7 +3,7 @@ use std::fmt::Write;
 use gccjit::{Struct, Type};
 use crate::rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods};
 use rustc_middle::bug;
-use rustc_middle::ty::{self, Ty, TypeFoldable};
+use rustc_middle::ty::{self, Ty, TypeVisitable};
 use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
 use rustc_middle::ty::print::with_no_trimmed_paths;
 use rustc_target::abi::{self, Abi, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants};
diff --git a/test.sh b/test.sh
index 06f608ad422..ed43c645bd2 100755
--- a/test.sh
+++ b/test.sh
@@ -321,12 +321,14 @@ EOF
     git checkout -- src/test/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed
 
     rm -r src/test/ui/{abi*,extern/,panic-runtime/,panics/,unsized-locals/,proc-macro/,threads-sendsync/,thinlto/,borrowck/,chalkify/bugs/,test*,*lto*.rs,consts/const-float-bits-reject-conv.rs,consts/issue-miri-1910.rs} || true
+    rm src/test/ui/mir/mir_heavy_promoted.rs # this tests is oom-killed in the CI.
     for test in $(rg --files-with-matches "catch_unwind|should_panic|thread|lto" src/test/ui); do
       rm $test
     done
     git checkout src/test/ui/lto/auxiliary/dylib.rs
     git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs
     git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs
+    git checkout src/test/ui/macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs
 
     RUSTC_ARGS="-Zpanic-abort-tests -Csymbol-mangling-version=v0 -Zcodegen-backend="$(pwd)"/../target/"$CHANNEL"/librustc_codegen_gcc."$dylib_ext" --sysroot "$(pwd)"/../build_sysroot/sysroot -Cpanic=abort"
 
@@ -338,7 +340,7 @@ EOF
         xargs -a ../failing-ui-tests.txt -d'\n' rm
     else
         # Removing all tests.
-        find src/test/ui -type f -name '*.rs' -exec rm {} \;
+        find src/test/ui -type f -name '*.rs' -not -path '*/auxiliary/*' -delete
         # Putting back only the failing ones.
         xargs -a ../failing-ui-tests.txt -d'\n' git checkout --
     fi
@@ -354,7 +356,7 @@ EOF
         count=$((count + 1))
         split -d -l $count -a 1 ui_tests ui_tests.split
         # Removing all tests.
-        find src/test/ui -type f -name '*.rs' -not -path "*/auxiliary/*" -exec rm {} \;
+        find src/test/ui -type f -name '*.rs' -not -path "*/auxiliary/*" -delete
         # Putting back only the ones we want to test.
         xargs -a "ui_tests.split$current_part" -d'\n' git checkout --
     fi
@@ -372,7 +374,7 @@ function test_successful_rustc() {
 }
 
 function clean_ui_tests() {
-    find rust/build/x86_64-unknown-linux-gnu/test/ui/ -name stamp -exec rm -rf {} \;
+    find rust/build/x86_64-unknown-linux-gnu/test/ui/ -name stamp -delete
 }
 
 function all() {
diff --git a/tests/run/array.rs b/tests/run/array.rs
index 8b621d8a353..c53d98340f0 100644
--- a/tests/run/array.rs
+++ b/tests/run/array.rs
@@ -79,7 +79,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         intrinsics::abort();
diff --git a/tests/run/assign.rs b/tests/run/assign.rs
index eb38a8a3835..b95a7b71415 100644
--- a/tests/run/assign.rs
+++ b/tests/run/assign.rs
@@ -64,7 +64,7 @@ mod intrinsics {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         libc::fflush(libc::stdout);
diff --git a/tests/run/closure.rs b/tests/run/closure.rs
index 7121a5f0d52..4d01d879dc1 100644
--- a/tests/run/closure.rs
+++ b/tests/run/closure.rs
@@ -177,7 +177,7 @@ impl Add for isize {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         intrinsics::abort();
diff --git a/tests/run/condition.rs b/tests/run/condition.rs
index 6a2e2d5bb11..38b3084cb6c 100644
--- a/tests/run/condition.rs
+++ b/tests/run/condition.rs
@@ -82,7 +82,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         intrinsics::abort();
diff --git a/tests/run/fun_ptr.rs b/tests/run/fun_ptr.rs
index a226fff79e5..995fc5ca5d2 100644
--- a/tests/run/fun_ptr.rs
+++ b/tests/run/fun_ptr.rs
@@ -76,7 +76,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         intrinsics::abort();
diff --git a/tests/run/int_overflow.rs b/tests/run/int_overflow.rs
index ea2c5add962..4ca62362539 100644
--- a/tests/run/int_overflow.rs
+++ b/tests/run/int_overflow.rs
@@ -62,7 +62,7 @@ mod intrinsics {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         // Panicking is expected iff overflow checking is enabled.
         #[cfg(debug_assertions)]
diff --git a/tests/run/mut_ref.rs b/tests/run/mut_ref.rs
index 52de20021f3..814bb1a612e 100644
--- a/tests/run/mut_ref.rs
+++ b/tests/run/mut_ref.rs
@@ -66,7 +66,7 @@ mod intrinsics {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         libc::fflush(libc::stdout);
diff --git a/tests/run/operations.rs b/tests/run/operations.rs
index e078b37b4ab..affe12067ff 100644
--- a/tests/run/operations.rs
+++ b/tests/run/operations.rs
@@ -72,7 +72,7 @@ mod intrinsics {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         libc::fflush(libc::stdout);
diff --git a/tests/run/ptr_cast.rs b/tests/run/ptr_cast.rs
index 6ac099ea145..08481739a7f 100644
--- a/tests/run/ptr_cast.rs
+++ b/tests/run/ptr_cast.rs
@@ -76,7 +76,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
 #[lang = "panic"]
 #[track_caller]
 #[no_mangle]
-pub fn panic(_msg: &str) -> ! {
+pub fn panic(_msg: &'static str) -> ! {
     unsafe {
         libc::puts("Panicking\0" as *const str as *const u8);
         intrinsics::abort();