about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2024-10-04 05:07:56 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2024-10-04 05:07:56 +0000
commit7014ae87dfcf17f57c42a23af11dac6778842b2a (patch)
tree8b90ccd54ba3df4b892a2187cdb84711da28fe53 /tests
parentd19bd66a4e88116af18a1f5a6ab4ffe2f5bd1956 (diff)
parent7067e4aee45c18cfa1c6af3bf79bd097684fb294 (diff)
downloadrust-7014ae87dfcf17f57c42a23af11dac6778842b2a.tar.gz
rust-7014ae87dfcf17f57c42a23af11dac6778842b2a.zip
Merge from rustc
Diffstat (limited to 'tests')
-rw-r--r--tests/codegen/binary-heap-peek-mut-pop-no-panic.rs13
-rw-r--r--tests/crashes/125881.rs8
-rw-r--r--tests/crashes/126377.rs29
-rw-r--r--tests/crashes/130413.rs17
-rw-r--r--tests/run-make/checksum-freshness/expected.d6
-rw-r--r--tests/run-make/checksum-freshness/foo.rs5
-rw-r--r--tests/run-make/checksum-freshness/lib.rs7
-rw-r--r--tests/run-make/checksum-freshness/rmake.rs9
-rw-r--r--tests/ui/attributes/rustc_confusables_std_cases.rs4
-rw-r--r--tests/ui/attributes/rustc_confusables_std_cases.stderr13
-rw-r--r--tests/ui/methods/dont-suggest-import-on-deref-err.rs13
-rw-r--r--tests/ui/methods/dont-suggest-import-on-deref-err.stderr12
-rw-r--r--tests/ui/pattern/at-in-struct-patterns.rs14
-rw-r--r--tests/ui/pattern/at-in-struct-patterns.stderr69
-rw-r--r--tests/ui/transmutability/assoc-bound.rs25
-rw-r--r--tests/ui/transmutability/assoc-bound.stderr31
16 files changed, 220 insertions, 55 deletions
diff --git a/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs
new file mode 100644
index 00000000000..9cf4f210e52
--- /dev/null
+++ b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs
@@ -0,0 +1,13 @@
+//@ compile-flags: -O
+//@ ignore-debug
+#![crate_type = "lib"]
+
+use std::collections::binary_heap::PeekMut;
+
+// CHECK-LABEL: @peek_mut_pop
+#[no_mangle]
+pub fn peek_mut_pop(peek_mut: PeekMut<u32>) -> u32 {
+    // CHECK-NOT: panic
+    // CHECK-NOT: unwrap_failed
+    PeekMut::pop(peek_mut)
+}
diff --git a/tests/crashes/125881.rs b/tests/crashes/125881.rs
deleted file mode 100644
index a38f1891b61..00000000000
--- a/tests/crashes/125881.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-//@ known-bug: rust-lang/rust#125881
-#![crate_type = "lib"]
-#![feature(transmutability)]
-#![feature(unboxed_closures,effects)]
-
-const fn test() -> impl std::mem::TransmuteFrom() {
-    || {}
-}
diff --git a/tests/crashes/126377.rs b/tests/crashes/126377.rs
deleted file mode 100644
index f6727bcc0a4..00000000000
--- a/tests/crashes/126377.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-//@ known-bug: rust-lang/rust#126377
-
-#![feature(effects)]
-#![feature(generic_const_exprs)]
-
-mod assert {
-    use std::mem::{Assume, TransmuteFrom};
-
-    pub fn is_transmutable<
-        Src,
-        Dst,
-        const ASSUME_ALIGNMENT: bool,
-        const ASSUME_LIFETIMES: bool,
-        const ASSUME_SAFETY: bool,
-        const ASSUME_VALIDITY: bool,
-    >()
-    where
-        Dst: TransmuteFrom<
-            Src,
-            {  }
-        >,
-    {}
-}
-
-const fn from_options() -> Assume {
-    #[repr(C)] struct Src;
-    #[repr(C)] struct Dst;
-    assert::is_transmutable::<Src, Dst, {0u8}, false, false, false>();
-}
diff --git a/tests/crashes/130413.rs b/tests/crashes/130413.rs
deleted file mode 100644
index 08435ac6450..00000000000
--- a/tests/crashes/130413.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-//@ known-bug: #130413
-
-#![feature(transmutability)]
-trait Aaa {
-    type Y;
-}
-
-trait Bbb {
-    type B: std::mem::TransmuteFrom<()>;
-}
-
-impl<T> Bbb for T
-where
-    T: Aaa,
-{
-    type B = T::Y;
-}
diff --git a/tests/run-make/checksum-freshness/expected.d b/tests/run-make/checksum-freshness/expected.d
new file mode 100644
index 00000000000..51467af53a2
--- /dev/null
+++ b/tests/run-make/checksum-freshness/expected.d
@@ -0,0 +1,6 @@
+lib.d: lib.rs foo.rs
+
+lib.rs:
+foo.rs:
+# checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 lib.rs
+# checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119 foo.rs
diff --git a/tests/run-make/checksum-freshness/foo.rs b/tests/run-make/checksum-freshness/foo.rs
new file mode 100644
index 00000000000..d3ef768f187
--- /dev/null
+++ b/tests/run-make/checksum-freshness/foo.rs
@@ -0,0 +1,5 @@
+// This is another file, just to prove we can handle two of them
+
+pub fn subtract(a: i32, b: i32) -> i32 {
+    a - b
+}
diff --git a/tests/run-make/checksum-freshness/lib.rs b/tests/run-make/checksum-freshness/lib.rs
new file mode 100644
index 00000000000..7bc6757959b
--- /dev/null
+++ b/tests/run-make/checksum-freshness/lib.rs
@@ -0,0 +1,7 @@
+// A basic library to be used in tests with no real purpose.
+
+mod foo;
+
+pub fn sum(a: i32, b: i32) -> i32 {
+    a + b
+}
diff --git a/tests/run-make/checksum-freshness/rmake.rs b/tests/run-make/checksum-freshness/rmake.rs
new file mode 100644
index 00000000000..071db6b145b
--- /dev/null
+++ b/tests/run-make/checksum-freshness/rmake.rs
@@ -0,0 +1,9 @@
+use run_make_support::{rfs, rustc};
+
+fn main() {
+    rustc().input("lib.rs").arg("-Zchecksum-hash-algorithm=blake3").emit("dep-info").run();
+    let make_file_contents = rfs::read_to_string("lib.d");
+    let expected_contents = rfs::read_to_string("expected.d");
+    assert_eq!(make_file_contents, expected_contents);
+    assert!(!expected_contents.is_empty());
+}
diff --git a/tests/ui/attributes/rustc_confusables_std_cases.rs b/tests/ui/attributes/rustc_confusables_std_cases.rs
index d9121695950..4f6baea26df 100644
--- a/tests/ui/attributes/rustc_confusables_std_cases.rs
+++ b/tests/ui/attributes/rustc_confusables_std_cases.rs
@@ -23,4 +23,8 @@ fn main() {
     //~^ HELP you might have meant to use `push_str`
     String::new().append(""); //~ ERROR E0599
     //~^ HELP you might have meant to use `push_str`
+    let mut buffer = String::new();
+    let stdin = std::io::stdin();
+    stdin.get_line(&mut buffer).unwrap(); //~ ERROR E0599
+    //~^ HELP you might have meant to use `read_line`
 }
diff --git a/tests/ui/attributes/rustc_confusables_std_cases.stderr b/tests/ui/attributes/rustc_confusables_std_cases.stderr
index f4b6947ccd9..7bf96241ca7 100644
--- a/tests/ui/attributes/rustc_confusables_std_cases.stderr
+++ b/tests/ui/attributes/rustc_confusables_std_cases.stderr
@@ -106,7 +106,18 @@ help: you might have meant to use `push_str`
 LL |     String::new().push_str("");
    |                   ~~~~~~~~
 
-error: aborting due to 8 previous errors
+error[E0599]: no method named `get_line` found for struct `Stdin` in the current scope
+  --> $DIR/rustc_confusables_std_cases.rs:28:11
+   |
+LL |     stdin.get_line(&mut buffer).unwrap();
+   |           ^^^^^^^^ method not found in `Stdin`
+   |
+help: you might have meant to use `read_line`
+   |
+LL |     stdin.read_line(&mut buffer).unwrap();
+   |           ~~~~~~~~~
+
+error: aborting due to 9 previous errors
 
 Some errors have detailed explanations: E0308, E0599.
 For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/methods/dont-suggest-import-on-deref-err.rs b/tests/ui/methods/dont-suggest-import-on-deref-err.rs
new file mode 100644
index 00000000000..c24ab791982
--- /dev/null
+++ b/tests/ui/methods/dont-suggest-import-on-deref-err.rs
@@ -0,0 +1,13 @@
+use std::clone::Clone;
+use std::ops::Deref;
+
+#[derive(Clone)]
+pub struct Foo {}
+
+impl Deref for Foo {}
+//~^ ERROR not all trait items implemented
+
+pub fn main() {
+    let f = Foo {};
+    let _ = f.clone();
+}
diff --git a/tests/ui/methods/dont-suggest-import-on-deref-err.stderr b/tests/ui/methods/dont-suggest-import-on-deref-err.stderr
new file mode 100644
index 00000000000..20a63ff375d
--- /dev/null
+++ b/tests/ui/methods/dont-suggest-import-on-deref-err.stderr
@@ -0,0 +1,12 @@
+error[E0046]: not all trait items implemented, missing: `Target`, `deref`
+  --> $DIR/dont-suggest-import-on-deref-err.rs:7:1
+   |
+LL | impl Deref for Foo {}
+   | ^^^^^^^^^^^^^^^^^^ missing `Target`, `deref` in implementation
+   |
+   = help: implement the missing item: `type Target = /* Type */;`
+   = help: implement the missing item: `fn deref(&self) -> &<Self as Deref>::Target { todo!() }`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/pattern/at-in-struct-patterns.rs b/tests/ui/pattern/at-in-struct-patterns.rs
new file mode 100644
index 00000000000..e8fad61f317
--- /dev/null
+++ b/tests/ui/pattern/at-in-struct-patterns.rs
@@ -0,0 +1,14 @@
+struct Foo {
+    field1: u8,
+    field2: u8,
+}
+
+fn main() {
+    let foo = Foo { field1: 1, field2: 2 };
+    let Foo { var @ field1, .. } = foo; //~ ERROR Unexpected `@` in struct pattern
+    dbg!(var); //~ ERROR cannot find value `var` in this scope
+    let Foo { field1: _, bar @ .. } = foo; //~ ERROR `@ ..` is not supported in struct patterns
+    let Foo { bar @ .. } = foo; //~ ERROR `@ ..` is not supported in struct patterns
+    let Foo { @ } = foo; //~ ERROR expected identifier, found `@`
+    let Foo { @ .. } = foo; //~ ERROR expected identifier, found `@`
+}
diff --git a/tests/ui/pattern/at-in-struct-patterns.stderr b/tests/ui/pattern/at-in-struct-patterns.stderr
new file mode 100644
index 00000000000..ff75edfe681
--- /dev/null
+++ b/tests/ui/pattern/at-in-struct-patterns.stderr
@@ -0,0 +1,69 @@
+error: Unexpected `@` in struct pattern
+  --> $DIR/at-in-struct-patterns.rs:8:15
+   |
+LL |     let Foo { var @ field1, .. } = foo;
+   |         ---   ^^^^^
+   |         |
+   |         while parsing the fields for this pattern
+   |
+   = note: struct patterns use `field: pattern` syntax to bind to fields
+   = help: consider replacing `new_name @ field_name` with `field_name: new_name` if that is what you intended
+
+error: `@ ..` is not supported in struct patterns
+  --> $DIR/at-in-struct-patterns.rs:10:26
+   |
+LL |     let Foo { field1: _, bar @ .. } = foo;
+   |         ---              ^^^^^^^^
+   |         |
+   |         while parsing the fields for this pattern
+   |
+help: bind to each field separately or, if you don't need them, just remove `bar @`
+   |
+LL -     let Foo { field1: _, bar @ .. } = foo;
+LL +     let Foo { field1: _, .. } = foo;
+   |
+
+error: `@ ..` is not supported in struct patterns
+  --> $DIR/at-in-struct-patterns.rs:11:15
+   |
+LL |     let Foo { bar @ .. } = foo;
+   |         ---   ^^^^^^^^
+   |         |
+   |         while parsing the fields for this pattern
+   |
+help: bind to each field separately or, if you don't need them, just remove `bar @`
+   |
+LL -     let Foo { bar @ .. } = foo;
+LL +     let Foo { .. } = foo;
+   |
+
+error: expected identifier, found `@`
+  --> $DIR/at-in-struct-patterns.rs:12:15
+   |
+LL |     let Foo { @ } = foo;
+   |         ---   ^ expected identifier
+   |         |
+   |         while parsing the fields for this pattern
+
+error: expected identifier, found `@`
+  --> $DIR/at-in-struct-patterns.rs:13:15
+   |
+LL |     let Foo { @ .. } = foo;
+   |         ---   ^ expected identifier
+   |         |
+   |         while parsing the fields for this pattern
+
+error[E0425]: cannot find value `var` in this scope
+  --> $DIR/at-in-struct-patterns.rs:9:10
+   |
+LL |     dbg!(var);
+   |          ^^^ not found in this scope
+   |
+help: consider importing this function
+   |
+LL + use std::env::var;
+   |
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/transmutability/assoc-bound.rs b/tests/ui/transmutability/assoc-bound.rs
new file mode 100644
index 00000000000..e8a20b45cde
--- /dev/null
+++ b/tests/ui/transmutability/assoc-bound.rs
@@ -0,0 +1,25 @@
+#![crate_type = "lib"]
+#![feature(transmutability)]
+
+trait A {
+    type AssocA;
+}
+
+trait B {
+    type AssocB: std::mem::TransmuteFrom<()>;
+}
+
+impl<T> B for (T, u8)
+where
+    T: A,
+{
+    type AssocB = T::AssocA; //~ERROR: the trait bound `<T as A>::AssocA: TransmuteFrom<(), Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not satisfied [E0277]
+}
+
+
+impl<T> B for (T, u16)
+where
+    for<'a> &'a i32: A,
+{
+    type AssocB = <&'static i32 as A>::AssocA; //~ERROR: `()` cannot be safely transmuted into `<&i32 as A>::AssocA`
+}
diff --git a/tests/ui/transmutability/assoc-bound.stderr b/tests/ui/transmutability/assoc-bound.stderr
new file mode 100644
index 00000000000..08d90894396
--- /dev/null
+++ b/tests/ui/transmutability/assoc-bound.stderr
@@ -0,0 +1,31 @@
+error[E0277]: the trait bound `<T as A>::AssocA: TransmuteFrom<(), Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not satisfied
+  --> $DIR/assoc-bound.rs:16:19
+   |
+LL |     type AssocB = T::AssocA;
+   |                   ^^^^^^^^^ the trait `TransmuteFrom<(), Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `<T as A>::AssocA`
+   |
+note: required by a bound in `B::AssocB`
+  --> $DIR/assoc-bound.rs:9:18
+   |
+LL |     type AssocB: std::mem::TransmuteFrom<()>;
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `B::AssocB`
+help: consider further restricting the associated type
+   |
+LL |     T: A, <T as A>::AssocA: TransmuteFrom<(), Assume { alignment: false, lifetimes: false, safety: false, validity: false }>
+   |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error[E0277]: `()` cannot be safely transmuted into `<&i32 as A>::AssocA`
+  --> $DIR/assoc-bound.rs:24:19
+   |
+LL |     type AssocB = <&'static i32 as A>::AssocA;
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `<&i32 as A>::AssocA` has an unknown layout
+   |
+note: required by a bound in `B::AssocB`
+  --> $DIR/assoc-bound.rs:9:18
+   |
+LL |     type AssocB: std::mem::TransmuteFrom<()>;
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `B::AssocB`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.