about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff46
-rw-r--r--tests/mir-opt/sroa.rs9
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/Makefile35
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/main.rs5
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c1
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs16
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs10
-rw-r--r--tests/rustdoc/description.rs6
-rw-r--r--tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs13
-rw-r--r--tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr6
-rw-r--r--tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs9
-rw-r--r--tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr6
-rw-r--r--tests/ui/regions/regions-mock-codegen.rs8
16 files changed, 152 insertions, 21 deletions
diff --git a/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff
new file mode 100644
index 00000000000..9e33215f2b5
--- /dev/null
+++ b/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff
@@ -0,0 +1,46 @@
+- // MIR for `constant` before ScalarReplacementOfAggregates
++ // MIR for `constant` after ScalarReplacementOfAggregates
+  
+  fn constant() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/sroa.rs:+0:15: +0:15
+      let _1: (usize, u8);                 // in scope 0 at $DIR/sroa.rs:+2:9: +2:10
++     let _4: usize;                       // in scope 0 at $DIR/sroa.rs:+2:9: +2:10
++     let _5: u8;                          // in scope 0 at $DIR/sroa.rs:+2:9: +2:10
+      scope 1 {
+-         debug y => _1;                   // in scope 1 at $DIR/sroa.rs:+2:9: +2:10
++         debug y => (usize, u8){ .0 => _4, .1 => _5, }; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10
+          let _2: usize;                   // in scope 1 at $DIR/sroa.rs:+3:9: +3:10
+          scope 2 {
+              debug t => _2;               // in scope 2 at $DIR/sroa.rs:+3:9: +3:10
+              let _3: u8;                  // in scope 2 at $DIR/sroa.rs:+4:9: +4:10
+              scope 3 {
+                  debug u => _3;           // in scope 3 at $DIR/sroa.rs:+4:9: +4:10
+              }
+          }
+      }
+  
+      bb0: {
+-         StorageLive(_1);                 // scope 0 at $DIR/sroa.rs:+2:9: +2:10
++         StorageLive(_4);                 // scope 0 at $DIR/sroa.rs:+2:9: +2:10
++         StorageLive(_5);                 // scope 0 at $DIR/sroa.rs:+2:9: +2:10
++         nop;                             // scope 0 at $DIR/sroa.rs:+2:9: +2:10
+          _1 = const _;                    // scope 0 at $DIR/sroa.rs:+2:13: +2:14
++         _4 = move (_1.0: usize);         // scope 1 at $DIR/sroa.rs:+3:9: +3:10
++         _5 = move (_1.1: u8);            // scope 1 at $DIR/sroa.rs:+3:9: +3:10
+          StorageLive(_2);                 // scope 1 at $DIR/sroa.rs:+3:9: +3:10
+-         _2 = (_1.0: usize);              // scope 1 at $DIR/sroa.rs:+3:13: +3:16
++         _2 = _4;                         // scope 1 at $DIR/sroa.rs:+3:13: +3:16
+          StorageLive(_3);                 // scope 2 at $DIR/sroa.rs:+4:9: +4:10
+-         _3 = (_1.1: u8);                 // scope 2 at $DIR/sroa.rs:+4:13: +4:16
++         _3 = _5;                         // scope 2 at $DIR/sroa.rs:+4:13: +4:16
+          _0 = const ();                   // scope 0 at $DIR/sroa.rs:+0:15: +5:2
+          StorageDead(_3);                 // scope 2 at $DIR/sroa.rs:+5:1: +5:2
+          StorageDead(_2);                 // scope 1 at $DIR/sroa.rs:+5:1: +5:2
+-         StorageDead(_1);                 // scope 0 at $DIR/sroa.rs:+5:1: +5:2
++         StorageDead(_4);                 // scope 0 at $DIR/sroa.rs:+5:1: +5:2
++         StorageDead(_5);                 // scope 0 at $DIR/sroa.rs:+5:1: +5:2
++         nop;                             // scope 0 at $DIR/sroa.rs:+5:1: +5:2
+          return;                          // scope 0 at $DIR/sroa.rs:+5:2: +5:2
+      }
+  }
+  
diff --git a/tests/mir-opt/sroa.rs b/tests/mir-opt/sroa.rs
index 471aac9f9d8..b69de2e124e 100644
--- a/tests/mir-opt/sroa.rs
+++ b/tests/mir-opt/sroa.rs
@@ -87,6 +87,13 @@ fn ref_copies(x: &Foo) {
     let u = y.c;
 }
 
+fn constant() {
+    const U: (usize, u8) = (5, 9);
+    let y = U;
+    let t = y.0;
+    let u = y.1;
+}
+
 fn main() {
     dropping();
     enums(5);
@@ -96,6 +103,7 @@ fn main() {
     escaping();
     copies(Foo { a: 5, b: (), c: "a", d: Some(-4) });
     ref_copies(&Foo { a: 5, b: (), c: "a", d: Some(-4) });
+    constant();
 }
 
 // EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff
@@ -106,3 +114,4 @@ fn main() {
 // EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff
 // EMIT_MIR sroa.copies.ScalarReplacementOfAggregates.diff
 // EMIT_MIR sroa.ref_copies.ScalarReplacementOfAggregates.diff
+// EMIT_MIR sroa.constant.ScalarReplacementOfAggregates.diff
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
new file mode 100644
index 00000000000..62dc1b5f606
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
@@ -0,0 +1,35 @@
+-include ../../run-make-fulldeps/tools.mk
+
+# ignore-cross-compile
+# only-linux
+
+# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive.
+
+# We're using the llvm-nm instead of the system nm to ensure it is compatible
+# with the LLVM bitcode generated by rustc.
+NM = "$(LLVM_BIN_DIR)"/llvm-nm
+
+all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4)
+	# test cfg with packed bundle
+	$(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs
+	$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add
+	$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a"
+	$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a"
+	$(AR) t $(TMPDIR)/libmain.a | $(CGREP) -e "libnative_dep_1.o"
+	$(AR) t $(TMPDIR)/libmain.a | $(CGREP) -ev "libnative_dep_2.o"
+
+
+	# test bundle with whole_archive
+	$(RUSTC) rust_dep.rs --crate-type=rlib
+	$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_1"
+	$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_3"
+	$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_2"
+	$(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_4"
+
+	# Make sure compiler doesn't use files, that it shouldn't know about.
+	rm $(TMPDIR)/libnative_dep_1.a
+	rm $(TMPDIR)/libnative_dep_3.a
+
+	$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib --print link-args > $(TMPDIR)/link_args
+	cat $(TMPDIR)/link_args | $(CGREP) -ev "native_dep_3"
+	cat $(TMPDIR)/link_args | $(CGREP) -e "--whole-archive.*native_dep_1.*--whole-archive.*lnative_dep_2.*no-whole-archive.*lnative_dep_4"
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs
new file mode 100644
index 00000000000..8d2b8a2859c
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs
@@ -0,0 +1,5 @@
+extern crate rust_dep;
+
+pub fn main() {
+    rust_dep::rust_dep();
+}
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c
new file mode 100644
index 00000000000..07be8562c92
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c
@@ -0,0 +1 @@
+int native_f1() { return 1; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c
new file mode 100644
index 00000000000..a1b94e40dc0
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c
@@ -0,0 +1 @@
+int native_f2() { return 2; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c
new file mode 100644
index 00000000000..f81f397a4b1
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c
@@ -0,0 +1 @@
+int native_f3() { return 3; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c
new file mode 100644
index 00000000000..14d41d60b1f
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c
@@ -0,0 +1 @@
+int native_f4() { return 4; }
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
new file mode 100644
index 00000000000..abd846b6862
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
@@ -0,0 +1,16 @@
+#![feature(packed_bundled_libs)]
+
+#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")]
+extern "C" {}
+
+#[link(name = "native_dep_2", kind = "static", modifiers = "+whole-archive,-bundle")]
+extern "C" {}
+
+#[link(name = "native_dep_3", kind = "static", modifiers = "+bundle")]
+extern "C" {}
+
+#[link(name = "native_dep_4", kind = "static", modifiers = "-bundle")]
+extern "C" {}
+
+#[no_mangle]
+pub fn rust_dep() {}
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs
new file mode 100644
index 00000000000..506ca62a8a6
--- /dev/null
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs
@@ -0,0 +1,10 @@
+#![feature(link_cfg)]
+
+#[link(name = "native_dep_1", kind = "static", cfg(should_add))]
+extern "C" {}
+
+#[link(name = "native_dep_2", kind = "static", cfg(should_not_add))]
+extern "C" {}
+
+#[no_mangle]
+pub fn rust_dep() {}
diff --git a/tests/rustdoc/description.rs b/tests/rustdoc/description.rs
index 05ec4282208..43cd59ebd09 100644
--- a/tests/rustdoc/description.rs
+++ b/tests/rustdoc/description.rs
@@ -22,3 +22,9 @@ pub mod foo_mod {
 //   'Only paragraph.'
 /// Only paragraph.
 pub fn foo_fn() {}
+
+// @has 'foo/fn.bar_fn.html' '//meta[@name="description"]/@content' \
+//   'Description with intra-doc link to foo_fn and [nonexistent_item] and foo_fn.'
+#[allow(rustdoc::broken_intra_doc_links)]
+/// Description with intra-doc link to [foo_fn] and [nonexistent_item] and [foo_fn](self::foo_fn).
+pub fn bar_fn() {}
diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs
index 066048795c8..0ccd441cc64 100644
--- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs
+++ b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs
@@ -1,8 +1,11 @@
-// compile-flags: -Zunstable-options --crate-type rlib
+// gate-test-packed_bundled_libs
+
+// ignore-wasm32-bare
+// compile-flags: --crate-type rlib
+// error-pattern: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
 // build-fail
-// error-pattern: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs
 
-#[link(name = "mylib", kind = "static", modifiers = "+bundle,+whole-archive")]
-extern "C" { }
+#[link(name = "rust_test_helpers", kind = "static", modifiers = "+bundle,+whole-archive")]
+extern "C" {}
 
-fn main() { }
+fn main() {}
diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr
index 246efb8d627..8a9fed740b0 100644
--- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr
+++ b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr
@@ -1,6 +1,4 @@
-error: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs
+error: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
 
-error: could not find native static library `mylib`, perhaps an -L flag is missing?
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs
index 1d0768d99cf..18d4b52a34c 100644
--- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs
+++ b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs
@@ -1,7 +1,8 @@
-// Mixing +bundle and +whole-archive is not allowed
+// gate-test-packed_bundled_libs
 
-// compile-flags: -l static:+bundle,+whole-archive=mylib -Zunstable-options --crate-type rlib
+// ignore-wasm32-bare
+// compile-flags: -l static:+bundle,+whole-archive=rust_test_helpers --crate-type rlib
+// error-pattern: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
 // build-fail
-// error-pattern: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs
 
-fn main() { }
+fn main() {}
diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr
index 246efb8d627..8a9fed740b0 100644
--- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr
+++ b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr
@@ -1,6 +1,4 @@
-error: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs
+error: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
 
-error: could not find native static library `mylib`, perhaps an -L flag is missing?
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
diff --git a/tests/ui/regions/regions-mock-codegen.rs b/tests/ui/regions/regions-mock-codegen.rs
index 9d0ca76e409..d5c93f81fd8 100644
--- a/tests/ui/regions/regions-mock-codegen.rs
+++ b/tests/ui/regions/regions-mock-codegen.rs
@@ -22,15 +22,15 @@ struct Ccx {
     x: isize,
 }
 
-fn allocate(_bcx: &arena) -> &Bcx<'_> {
+fn allocate(_bcx: &arena) -> &mut Bcx<'_> {
     unsafe {
         let layout = Layout::new::<Bcx>();
         let ptr = Global.allocate(layout).unwrap_or_else(|_| handle_alloc_error(layout));
-        &*(ptr.as_ptr() as *const _)
+        &mut *ptr.as_ptr().cast()
     }
 }
 
-fn h<'a>(bcx: &'a Bcx<'a>) -> &'a Bcx<'a> {
+fn h<'a>(bcx: &'a Bcx<'a>) -> &'a mut Bcx<'a> {
     return allocate(bcx.fcx.arena);
 }
 
@@ -38,7 +38,7 @@ fn g(fcx: &Fcx) {
     let bcx = Bcx { fcx };
     let bcx2 = h(&bcx);
     unsafe {
-        Global.deallocate(NonNull::new_unchecked(bcx2 as *const _ as *mut _), Layout::new::<Bcx>());
+        Global.deallocate(NonNull::new_unchecked(bcx2 as *mut _ as *mut _), Layout::new::<Bcx>());
     }
 }