about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/attributes/malformed-reprs.rs14
-rw-r--r--tests/ui/attributes/malformed-reprs.stderr43
-rw-r--r--tests/ui/loop-match/panic-in-const.rs22
-rw-r--r--tests/ui/loop-match/panic-in-const.stderr9
-rw-r--r--tests/ui/process/core-run-destroy.rs2
-rw-r--r--tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed17
-rw-r--r--tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs17
-rw-r--r--tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.stderr58
8 files changed, 181 insertions, 1 deletions
diff --git a/tests/ui/attributes/malformed-reprs.rs b/tests/ui/attributes/malformed-reprs.rs
new file mode 100644
index 00000000000..4f99239d21b
--- /dev/null
+++ b/tests/ui/attributes/malformed-reprs.rs
@@ -0,0 +1,14 @@
+// Tests a few different invalid repr attributes
+
+// This is a regression test for https://github.com/rust-lang/rust/issues/143522
+#![repr]
+//~^ ERROR malformed `repr` attribute input [E0539]
+//~| ERROR `repr` attribute cannot be used at crate level
+
+// This is a regression test for https://github.com/rust-lang/rust/issues/143479
+#[repr(align(0))]
+//~^ ERROR invalid `repr(align)` attribute: not a power of two
+//~| ERROR unsupported representation for zero-variant enum [E0084]
+enum Foo {}
+
+fn main() {}
diff --git a/tests/ui/attributes/malformed-reprs.stderr b/tests/ui/attributes/malformed-reprs.stderr
new file mode 100644
index 00000000000..c39c98dde31
--- /dev/null
+++ b/tests/ui/attributes/malformed-reprs.stderr
@@ -0,0 +1,43 @@
+error[E0539]: malformed `repr` attribute input
+  --> $DIR/malformed-reprs.rs:4:1
+   |
+LL | #![repr]
+   | ^^^^^^^^
+   | |
+   | expected this to be a list
+   | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]`
+
+error[E0589]: invalid `repr(align)` attribute: not a power of two
+  --> $DIR/malformed-reprs.rs:9:14
+   |
+LL | #[repr(align(0))]
+   |              ^
+
+error: `repr` attribute cannot be used at crate level
+  --> $DIR/malformed-reprs.rs:4:1
+   |
+LL | #![repr]
+   | ^^^^^^^^
+...
+LL | enum Foo {}
+   |      --- the inner attribute doesn't annotate this enum
+   |
+help: perhaps you meant to use an outer attribute
+   |
+LL - #![repr]
+LL + #[repr]
+   |
+
+error[E0084]: unsupported representation for zero-variant enum
+  --> $DIR/malformed-reprs.rs:9:1
+   |
+LL | #[repr(align(0))]
+   | ^^^^^^^^^^^^^^^^^
+...
+LL | enum Foo {}
+   | -------- zero-variant enum
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0084, E0539, E0589.
+For more information about an error, try `rustc --explain E0084`.
diff --git a/tests/ui/loop-match/panic-in-const.rs b/tests/ui/loop-match/panic-in-const.rs
new file mode 100644
index 00000000000..2ae67445496
--- /dev/null
+++ b/tests/ui/loop-match/panic-in-const.rs
@@ -0,0 +1,22 @@
+#![allow(incomplete_features)]
+#![feature(loop_match)]
+#![crate_type = "lib"]
+
+const CONST_THAT_PANICS: u8 = panic!("diverge!");
+//~^ ERROR: evaluation panicked: diverge!
+
+fn test(mut state: u8) {
+    #[loop_match]
+    loop {
+        state = 'blk: {
+            match state {
+                0 => {
+                    #[const_continue]
+                    break 'blk CONST_THAT_PANICS;
+                }
+
+                _ => unreachable!(),
+            }
+        }
+    }
+}
diff --git a/tests/ui/loop-match/panic-in-const.stderr b/tests/ui/loop-match/panic-in-const.stderr
new file mode 100644
index 00000000000..b6ed3177883
--- /dev/null
+++ b/tests/ui/loop-match/panic-in-const.stderr
@@ -0,0 +1,9 @@
+error[E0080]: evaluation panicked: diverge!
+  --> $DIR/panic-in-const.rs:5:31
+   |
+LL | const CONST_THAT_PANICS: u8 = panic!("diverge!");
+   |                               ^^^^^^^^^^^^^^^^^^ evaluation of `CONST_THAT_PANICS` failed here
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/process/core-run-destroy.rs b/tests/ui/process/core-run-destroy.rs
index b4815c9dfbb..f4be54da8fe 100644
--- a/tests/ui/process/core-run-destroy.rs
+++ b/tests/ui/process/core-run-destroy.rs
@@ -37,7 +37,7 @@ pub fn sleeper() -> Child {
 pub fn sleeper() -> Child {
     // There's a `timeout` command on windows, but it doesn't like having
     // its output piped, so instead just ping ourselves a few times with
-    // gaps in between so we're sure this process is alive for awhile
+    // gaps in between so we're sure this process is alive for a while
     t!(Command::new("ping").arg("127.0.0.1").arg("-n").arg("1000").spawn())
 }
 
diff --git a/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed
new file mode 100644
index 00000000000..95fd920dec2
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed
@@ -0,0 +1,17 @@
+//@ run-rustfix
+
+struct S;
+trait Trait {
+    fn foo() {}
+}
+impl Trait for &S {}
+impl Trait for &mut S {}
+fn main() {
+    let _ = <&str>::from("value");
+    //~^ ERROR the trait bound `str: From<_>` is not satisfied
+    //~| ERROR the size for values of type `str` cannot be known at compilation time
+    let _ = <&mut S>::foo();
+    //~^ ERROR the trait bound `S: Trait` is not satisfied
+    let _ = <&S>::foo();
+    //~^ ERROR the trait bound `S: Trait` is not satisfied
+}
diff --git a/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs
new file mode 100644
index 00000000000..f79d2465062
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs
@@ -0,0 +1,17 @@
+//@ run-rustfix
+
+struct S;
+trait Trait {
+    fn foo() {}
+}
+impl Trait for &S {}
+impl Trait for &mut S {}
+fn main() {
+    let _ = &str::from("value");
+    //~^ ERROR the trait bound `str: From<_>` is not satisfied
+    //~| ERROR the size for values of type `str` cannot be known at compilation time
+    let _ = &mut S::foo();
+    //~^ ERROR the trait bound `S: Trait` is not satisfied
+    let _ = &S::foo();
+    //~^ ERROR the trait bound `S: Trait` is not satisfied
+}
diff --git a/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.stderr b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.stderr
new file mode 100644
index 00000000000..ac96ec76da7
--- /dev/null
+++ b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.stderr
@@ -0,0 +1,58 @@
+error[E0277]: the trait bound `str: From<_>` is not satisfied
+  --> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14
+   |
+LL |     let _ = &str::from("value");
+   |              ^^^ the trait `From<_>` is not implemented for `str`
+   |
+   = help: the following other types implement trait `From<T>`:
+             `String` implements `From<&String>`
+             `String` implements `From<&mut str>`
+             `String` implements `From<&str>`
+             `String` implements `From<Box<str>>`
+             `String` implements `From<Cow<'_, str>>`
+             `String` implements `From<char>`
+help: you likely meant to call the associated function `from` for type `&str`, but the code as written calls associated function `from` on type `str`
+   |
+LL |     let _ = <&str>::from("value");
+   |             +    +
+
+error[E0277]: the trait bound `S: Trait` is not satisfied
+  --> $DIR/dont-suggest-borrowing-existing-borrow.rs:13:18
+   |
+LL |     let _ = &mut S::foo();
+   |                  ^ the trait `Trait` is not implemented for `S`
+   |
+   = help: the following other types implement trait `Trait`:
+             &S
+             &mut S
+help: you likely meant to call the associated function `foo` for type `&mut S`, but the code as written calls associated function `foo` on type `S`
+   |
+LL |     let _ = <&mut S>::foo();
+   |             +      +
+
+error[E0277]: the trait bound `S: Trait` is not satisfied
+  --> $DIR/dont-suggest-borrowing-existing-borrow.rs:15:14
+   |
+LL |     let _ = &S::foo();
+   |              ^ the trait `Trait` is not implemented for `S`
+   |
+   = help: the following other types implement trait `Trait`:
+             &S
+             &mut S
+help: you likely meant to call the associated function `foo` for type `&S`, but the code as written calls associated function `foo` on type `S`
+   |
+LL |     let _ = <&S>::foo();
+   |             +  +
+
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14
+   |
+LL |     let _ = &str::from("value");
+   |              ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `str`
+   = note: the return type of a function must have a statically known size
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0277`.