about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-12-31 22:57:51 +0000
committerbors <bors@rust-lang.org>2021-12-31 22:57:51 +0000
commit4d2e0fd96ccbb9ade41f1a3f07b14b7437f8e4ef (patch)
treeae02e3e70631489b0ee454b28b13242f8ecdc4ea /src/test
parentcfa3fe5af339e724209b25715282adae0c61628f (diff)
parent2da54c729ecd3ad6a4557ccc6b4f9e6ef8632ae2 (diff)
Auto merge of #92465 - matthiaskrgr:rollup-yuary84, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90383 (Extend check for UnsafeCell in consts to cover unions)
 - #91375 (config.rs: Add support for a per-target default_linker option.)
 - #91480 (rustdoc: use smaller number of colors to distinguish items)
 - #92338 (Add try_reserve and  try_reserve_exact for OsString)
 - #92405 (Add a couple needs-asm-support headers to tests)
 - #92435 (Sync rustc_codegen_cranelift)
 - #92440 (Fix mobile toggles position)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
-rw-r--r--src/test/incremental/hashes/inline_asm.rs1
-rw-r--r--src/test/incremental/issue-72386.rs1
-rw-r--r--src/test/rustdoc-gui/anchors.goml2
-rw-r--r--src/test/rustdoc-gui/font-weight.goml4
-rw-r--r--src/test/rustdoc-gui/toggle-docs-mobile.goml10
-rw-r--r--src/test/rustdoc/assoc-item-cast.rs3
-rw-r--r--src/test/rustdoc/trait-impl-items-links-and-anchors.rs7
-rw-r--r--src/test/ui/consts/invalid-union.32bit.stderr24
-rw-r--r--src/test/ui/consts/invalid-union.64bit.stderr24
-rw-r--r--src/test/ui/consts/invalid-union.rs44
10 files changed, 111 insertions, 9 deletions
diff --git a/src/test/incremental/hashes/inline_asm.rs b/src/test/incremental/hashes/inline_asm.rs
index a5d53258a7b..1ddb345e566 100644
--- a/src/test/incremental/hashes/inline_asm.rs
+++ b/src/test/incremental/hashes/inline_asm.rs
@@ -8,6 +8,7 @@
 // build-pass (FIXME(62277): could be check-pass?)
 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
 // compile-flags: -Z query-dep-graph
+// needs-asm-support
 // [cfail1]compile-flags: -Zincremental-ignore-spans
 // [cfail2]compile-flags: -Zincremental-ignore-spans
 // [cfail3]compile-flags: -Zincremental-ignore-spans
diff --git a/src/test/incremental/issue-72386.rs b/src/test/incremental/issue-72386.rs
index be624faad04..5917152e1bc 100644
--- a/src/test/incremental/issue-72386.rs
+++ b/src/test/incremental/issue-72386.rs
@@ -1,4 +1,5 @@
 // revisions: rpass1 cfail1 rpass3
+// needs-asm-support
 // only-x86_64
 // Regression test for issue #72386
 // Checks that we don't ICE when switching to an invalid register
diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml
index 2216b3f1c97..ca60be72cea 100644
--- a/src/test/rustdoc-gui/anchors.goml
+++ b/src/test/rustdoc-gui/anchors.goml
@@ -12,7 +12,7 @@ reload:
 
 assert-css: ("#toggle-all-docs", {"color": "rgb(0, 0, 0)"})
 assert-css: (".fqn .in-band a:nth-of-type(1)", {"color": "rgb(0, 0, 0)"})
-assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgb(173, 68, 142)"})
+assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgb(173, 55, 138)"})
 assert-css: (".srclink", {"color": "rgb(0, 0, 0)"})
 assert-css: (".srclink", {"color": "rgb(0, 0, 0)"})
 
diff --git a/src/test/rustdoc-gui/font-weight.goml b/src/test/rustdoc-gui/font-weight.goml
index c9117e2c101..a64ac8b422f 100644
--- a/src/test/rustdoc-gui/font-weight.goml
+++ b/src/test/rustdoc-gui/font-weight.goml
@@ -37,8 +37,8 @@ assert-css: (
     {"font-weight": "400"},
 )
 
-assert-count: (".methods .type", 1)
-assert-css: (".methods .type", {"font-weight": "600"})
+assert-count: (".methods .associatedtype", 1)
+assert-css: (".methods .associatedtype", {"font-weight": "600"})
 assert-count: (".methods .constant", 1)
 assert-css: (".methods .constant", {"font-weight": "600"})
 assert-css: (".methods .method", {"font-weight": "600"})
diff --git a/src/test/rustdoc-gui/toggle-docs-mobile.goml b/src/test/rustdoc-gui/toggle-docs-mobile.goml
index 471d88701d4..b370dd012fa 100644
--- a/src/test/rustdoc-gui/toggle-docs-mobile.goml
+++ b/src/test/rustdoc-gui/toggle-docs-mobile.goml
@@ -9,6 +9,16 @@ assert-attribute: (".top-doc", {"open": ""})
 click: (3, 280)
 assert-attribute: (".top-doc", {"open": ""})
 
+// Assert the position of the toggle on the top doc block.
+assert-position: (".top-doc summary::before", {"x": 4})
+// Assert the position of the toggle on the impl block.
+assert-position: ("#implementations + details > summary::before", {"x": 4})
+// Assert the position of the toggle on a method.
+assert-position: (
+    "#trait-implementations-list .impl-items .method-toggle > summary::before",
+    {"x": 4},
+)
+
 // Now we do the same but with a little bigger width
 size: (600, 600)
 assert-attribute: (".top-doc", {"open": ""})
diff --git a/src/test/rustdoc/assoc-item-cast.rs b/src/test/rustdoc/assoc-item-cast.rs
index 273fc62aa17..a409d64131a 100644
--- a/src/test/rustdoc/assoc-item-cast.rs
+++ b/src/test/rustdoc/assoc-item-cast.rs
@@ -1,6 +1,5 @@
 #![crate_name = "foo"]
 
-
 pub trait Expression {
     type SqlType;
 }
@@ -11,5 +10,5 @@ pub trait AsExpression<T> {
 }
 
 // @has foo/type.AsExprOf.html
-// @has - '//*[@class="rust typedef"]' 'type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;'
+// @has - '//pre[@class="rust typedef"]' 'type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;'
 pub type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;
diff --git a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs
index 4d25835bf08..db9adb4838e 100644
--- a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs
+++ b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs
@@ -6,9 +6,8 @@ pub trait MyTrait {
     fn defaulted_override(&self) {}
 }
 
-
 impl MyTrait for String {
-    // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-1"]//a[@class="type"]/@href' #associatedtype.Assoc
+    // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-1"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc
     // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-1"]//a[@class="anchor"]/@href' #associatedtype.Assoc-1
     type Assoc = ();
     // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-1"]//a[@class="constant"]/@href' #associatedconstant.VALUE
@@ -23,7 +22,7 @@ impl MyTrait for String {
 }
 
 impl MyTrait for Vec<u8> {
-    // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-2"]//a[@class="type"]/@href' #associatedtype.Assoc
+    // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-2"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc
     // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-2"]//a[@class="anchor"]/@href' #associatedtype.Assoc-2
     type Assoc = ();
     // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-2"]//a[@class="constant"]/@href' #associatedconstant.VALUE
@@ -39,7 +38,7 @@ impl MyTrait for Vec<u8> {
 
 impl MyTrait for MyStruct {
     // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3
-    // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="type"]/@href' trait.MyTrait.html#associatedtype.Assoc
+    // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="associatedtype"]/@href' trait.MyTrait.html#associatedtype.Assoc
     // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc
     type Assoc = bool;
     // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3
diff --git a/src/test/ui/consts/invalid-union.32bit.stderr b/src/test/ui/consts/invalid-union.32bit.stderr
new file mode 100644
index 00000000000..c8f9e570467
--- /dev/null
+++ b/src/test/ui/consts/invalid-union.32bit.stderr
@@ -0,0 +1,24 @@
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/invalid-union.rs:41:1
+   |
+LL | fn main() {
+   | ^^^^^^^^^ type validation failed at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
+   |
+   = 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.
+   = note: the raw bytes of the constant (size: 4, align: 4) {
+               ╾─alloc7──╼                                     │ ╾──╼
+           }
+
+error: erroneous constant used
+  --> $DIR/invalid-union.rs:42:25
+   |
+LL |     let _: &'static _ = &C;
+   |                         ^^ referenced constant has errors
+   |
+   = note: `#[deny(const_err)]` on by default
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/invalid-union.64bit.stderr b/src/test/ui/consts/invalid-union.64bit.stderr
new file mode 100644
index 00000000000..2ca54ccf9a0
--- /dev/null
+++ b/src/test/ui/consts/invalid-union.64bit.stderr
@@ -0,0 +1,24 @@
+error[E0080]: it is undefined behavior to use this value
+  --> $DIR/invalid-union.rs:41:1
+   |
+LL | fn main() {
+   | ^^^^^^^^^ type validation failed at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
+   |
+   = 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.
+   = note: the raw bytes of the constant (size: 8, align: 8) {
+               ╾───────alloc7────────╼                         │ ╾──────╼
+           }
+
+error: erroneous constant used
+  --> $DIR/invalid-union.rs:42:25
+   |
+LL |     let _: &'static _ = &C;
+   |                         ^^ referenced constant has errors
+   |
+   = note: `#[deny(const_err)]` on by default
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/invalid-union.rs b/src/test/ui/consts/invalid-union.rs
new file mode 100644
index 00000000000..1d5cc978a9e
--- /dev/null
+++ b/src/test/ui/consts/invalid-union.rs
@@ -0,0 +1,44 @@
+// Check that constants with interior mutability inside unions are rejected
+// during validation.
+//
+// Note that this test case relies on undefined behaviour to construct a
+// constant with interior mutability that is "invisible" to the static checks.
+// If for some reason this approach no longer works, it is should be fine to
+// remove the test case.
+//
+// build-fail
+// stderr-per-bitwidth
+#![feature(const_mut_refs)]
+#![feature(const_ptr_offset)]
+#![feature(untagged_unions)]
+use std::cell::Cell;
+
+#[repr(C)]
+struct S {
+    x: u32,
+    y: E,
+}
+
+#[repr(u32)]
+enum E {
+    A,
+    B(U)
+}
+
+union U {
+    cell: Cell<u32>,
+}
+
+const C: S = {
+    let s = S { x: 0, y: E::A };
+    // Go through an &u32 reference which is definitely not allowed to mutate anything.
+    let p = &s.x as *const u32 as *mut u32;
+    // Change enum tag to E::B.
+    unsafe { *p.add(1) = 1 };
+    s
+};
+
+fn main() { //~ ERROR it is undefined behavior to use this value
+    let _: &'static _ = &C; //~ ERROR erroneous constant used
+    //~^ WARN this was previously accepted
+}