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-ui/intra-doc/errors.rs16
-rw-r--r--tests/rustdoc-ui/intra-doc/errors.stderr14
-rw-r--r--tests/rustdoc/reexport-macro.rs23
-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
17 files changed, 194 insertions, 18 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-ui/intra-doc/errors.rs b/tests/rustdoc-ui/intra-doc/errors.rs
index b29f7c29b5d..95dd2b98e03 100644
--- a/tests/rustdoc-ui/intra-doc/errors.rs
+++ b/tests/rustdoc-ui/intra-doc/errors.rs
@@ -103,3 +103,19 @@ pub trait T {
 macro_rules! m {
     () => {};
 }
+
+///[`TestEnum::Variant1::field_name`]
+//~^ ERROR unresolved link
+//~| NOTE variant `Variant1` has no such field
+pub enum TestEnum {
+    Variant1 {},
+    Variant2 { field_name: u64 },
+}
+
+///[`TestEnumNoFields::Variant1::field_name`]
+//~^ ERROR unresolved link
+//~| NOTE `Variant1` is a variant, not a module or type, and cannot have associated items
+pub enum TestEnumNoFields {
+    Variant1 (),
+    Variant2 {},
+}
diff --git a/tests/rustdoc-ui/intra-doc/errors.stderr b/tests/rustdoc-ui/intra-doc/errors.stderr
index 9a1896fb0cd..1b2416d7da7 100644
--- a/tests/rustdoc-ui/intra-doc/errors.stderr
+++ b/tests/rustdoc-ui/intra-doc/errors.stderr
@@ -142,6 +142,18 @@ error: unresolved link to `T::h`
 LL | /// [T::h!]
    |      ^^^^^ the trait `T` has no macro named `h`
 
+error: unresolved link to `TestEnum::Variant1::field_name`
+  --> $DIR/errors.rs:107:6
+   |
+LL | ///[`TestEnum::Variant1::field_name`]
+   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variant `Variant1` has no such field
+
+error: unresolved link to `TestEnumNoFields::Variant1::field_name`
+  --> $DIR/errors.rs:115:6
+   |
+LL | ///[`TestEnumNoFields::Variant1::field_name`]
+   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Variant1` is a variant, not a module or type, and cannot have associated items
+
 error: unresolved link to `m`
   --> $DIR/errors.rs:98:6
    |
@@ -153,5 +165,5 @@ help: to link to the macro, add an exclamation mark
 LL | /// [m!()]
    |       +
 
-error: aborting due to 20 previous errors
+error: aborting due to 22 previous errors
 
diff --git a/tests/rustdoc/reexport-macro.rs b/tests/rustdoc/reexport-macro.rs
new file mode 100644
index 00000000000..c4dec703aed
--- /dev/null
+++ b/tests/rustdoc/reexport-macro.rs
@@ -0,0 +1,23 @@
+// Ensure that macros are correctly reexported and that they get both the comment from the
+// `pub use` and from the macro.
+
+#![crate_name = "foo"]
+
+// @has 'foo/macro.foo.html'
+// @!has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y'
+// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'y'
+#[macro_use]
+mod my_module {
+    /// y
+    #[macro_export]
+    macro_rules! foo {
+        () => ();
+    }
+}
+
+// @has 'foo/another_mod/macro.bar.html'
+// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y'
+pub mod another_mod {
+    /// x
+    pub use crate::foo as bar;
+}
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