about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run-make/multiline-args-value/cfg-frontmatter.stderr (renamed from tests/run-make/multiline-args-value/cfg.stderr)0
-rw-r--r--tests/run-make/multiline-args-value/cfg-shebang.stderr3
-rw-r--r--tests/run-make/multiline-args-value/check-cfg-frontmatter.stderr (renamed from tests/run-make/multiline-args-value/check-cfg.stderr)0
-rw-r--r--tests/run-make/multiline-args-value/check-cfg-shebang.stderr6
-rw-r--r--tests/run-make/multiline-args-value/rmake.rs31
-rw-r--r--tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr4
-rw-r--r--tests/ui/traits/bound/suggest-complex-bound-on-method.fixed23
-rw-r--r--tests/ui/traits/bound/suggest-complex-bound-on-method.rs23
-rw-r--r--tests/ui/traits/bound/suggest-complex-bound-on-method.stderr22
9 files changed, 101 insertions, 11 deletions
diff --git a/tests/run-make/multiline-args-value/cfg.stderr b/tests/run-make/multiline-args-value/cfg-frontmatter.stderr
index 9b06f84be48..9b06f84be48 100644
--- a/tests/run-make/multiline-args-value/cfg.stderr
+++ b/tests/run-make/multiline-args-value/cfg-frontmatter.stderr
diff --git a/tests/run-make/multiline-args-value/cfg-shebang.stderr b/tests/run-make/multiline-args-value/cfg-shebang.stderr
new file mode 100644
index 00000000000..09baf3b5123
--- /dev/null
+++ b/tests/run-make/multiline-args-value/cfg-shebang.stderr
@@ -0,0 +1,3 @@
+error: invalid `--cfg` argument: `#!/usr/bin/shebang
+       key` (expected `key` or `key="value"`)
+
diff --git a/tests/run-make/multiline-args-value/check-cfg.stderr b/tests/run-make/multiline-args-value/check-cfg-frontmatter.stderr
index 4a499cc0a1e..4a499cc0a1e 100644
--- a/tests/run-make/multiline-args-value/check-cfg.stderr
+++ b/tests/run-make/multiline-args-value/check-cfg-frontmatter.stderr
diff --git a/tests/run-make/multiline-args-value/check-cfg-shebang.stderr b/tests/run-make/multiline-args-value/check-cfg-shebang.stderr
new file mode 100644
index 00000000000..5bf18dc2b14
--- /dev/null
+++ b/tests/run-make/multiline-args-value/check-cfg-shebang.stderr
@@ -0,0 +1,6 @@
+error: invalid `--check-cfg` argument: `#!/usr/bin/shebang
+       cfg(key)`
+  |
+  = note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
+  = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
+
diff --git a/tests/run-make/multiline-args-value/rmake.rs b/tests/run-make/multiline-args-value/rmake.rs
index 825cbd158c0..3964cbbc1e6 100644
--- a/tests/run-make/multiline-args-value/rmake.rs
+++ b/tests/run-make/multiline-args-value/rmake.rs
@@ -1,15 +1,14 @@
 use run_make_support::{cwd, diff, rustc};
 
-fn test_and_compare(flag: &str, val: &str) {
+fn test_and_compare(test_name: &str, flag: &str, val: &str) {
     let mut cmd = rustc();
 
-    let output =
-        cmd.input("").arg("--crate-type=lib").arg(&format!("--{flag}")).arg(val).run_fail();
+    let output = cmd.input("").arg("--crate-type=lib").arg(flag).arg(val).run_fail();
 
     assert_eq!(output.stdout_utf8(), "");
     diff()
-        .expected_file(format!("{flag}.stderr"))
-        .actual_text("output", output.stderr_utf8())
+        .expected_file(format!("{test_name}.stderr"))
+        .actual_text("stderr", output.stderr_utf8())
         .run();
 }
 
@@ -17,7 +16,8 @@ fn main() {
     // Verify that frontmatter isn't allowed in `--cfg` arguments.
     // https://github.com/rust-lang/rust/issues/146130
     test_and_compare(
-        "cfg",
+        "cfg-frontmatter",
+        "--cfg",
         r#"---
 ---
 key"#,
@@ -26,9 +26,26 @@ key"#,
     // Verify that frontmatter isn't allowed in `--check-cfg` arguments.
     // https://github.com/rust-lang/rust/issues/146130
     test_and_compare(
-        "check-cfg",
+        "check-cfg-frontmatter",
+        "--check-cfg",
         r#"---
 ---
 cfg(key)"#,
     );
+
+    // Verify that shebang isn't allowed in `--cfg` arguments.
+    test_and_compare(
+        "cfg-shebang",
+        "--cfg",
+        r#"#!/usr/bin/shebang
+key"#,
+    );
+
+    // Verify that shebang isn't allowed in `--check-cfg` arguments.
+    test_and_compare(
+        "check-cfg-shebang",
+        "--check-cfg",
+        r#"#!/usr/bin/shebang
+cfg(key)"#,
+    );
 }
diff --git a/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr b/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr
index 12de4f1dc30..cf5b55a0ce2 100644
--- a/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr
+++ b/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr
@@ -21,10 +21,6 @@ LL |         [0u8; std::mem::size_of::<Self::A>()] == Self::P;
    |                                               ^^ no implementation for `[u8; std::mem::size_of::<Self::A>()] == <Self as T>::A`
    |
    = help: the trait `PartialEq<<Self as T>::A>` is not implemented for `[u8; std::mem::size_of::<Self::A>()]`
-help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
-   |
-LL | pub trait T where [u8; std::mem::size_of::<Self::A>()]: PartialEq<<Self as T>::A> {
-   |             +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/traits/bound/suggest-complex-bound-on-method.fixed b/tests/ui/traits/bound/suggest-complex-bound-on-method.fixed
new file mode 100644
index 00000000000..719835af0a9
--- /dev/null
+++ b/tests/ui/traits/bound/suggest-complex-bound-on-method.fixed
@@ -0,0 +1,23 @@
+//@ run-rustfix
+#![allow(dead_code)]
+struct Application;
+// https://github.com/rust-lang/rust/issues/144734
+trait Trait {
+    type Error: std::error::Error;
+
+    fn run(&self) -> Result<(), Self::Error>;
+}
+
+#[derive(Debug)]
+enum ApplicationError {
+    Quit,
+}
+
+impl Application {
+    fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> {
+        t.run()?; //~ ERROR E0277
+        Ok(())
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/traits/bound/suggest-complex-bound-on-method.rs b/tests/ui/traits/bound/suggest-complex-bound-on-method.rs
new file mode 100644
index 00000000000..39cec571242
--- /dev/null
+++ b/tests/ui/traits/bound/suggest-complex-bound-on-method.rs
@@ -0,0 +1,23 @@
+//@ run-rustfix
+#![allow(dead_code)]
+struct Application;
+// https://github.com/rust-lang/rust/issues/144734
+trait Trait {
+    type Error: std::error::Error;
+
+    fn run(&self) -> Result<(), Self::Error>;
+}
+
+#[derive(Debug)]
+enum ApplicationError {
+    Quit,
+}
+
+impl Application {
+    fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> {
+        t.run()?; //~ ERROR E0277
+        Ok(())
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/traits/bound/suggest-complex-bound-on-method.stderr b/tests/ui/traits/bound/suggest-complex-bound-on-method.stderr
new file mode 100644
index 00000000000..ac45f049541
--- /dev/null
+++ b/tests/ui/traits/bound/suggest-complex-bound-on-method.stderr
@@ -0,0 +1,22 @@
+error[E0277]: `?` couldn't convert the error to `ApplicationError`
+  --> $DIR/suggest-complex-bound-on-method.rs:18:16
+   |
+LL |         t.run()?;
+   |           -----^ the trait `From<<T as Trait>::Error>` is not implemented for `ApplicationError`
+   |           |
+   |           this can't be annotated with `?` because it has type `Result<_, <T as Trait>::Error>`
+   |
+note: `ApplicationError` needs to implement `From<<T as Trait>::Error>`
+  --> $DIR/suggest-complex-bound-on-method.rs:12:1
+   |
+LL | enum ApplicationError {
+   | ^^^^^^^^^^^^^^^^^^^^^
+   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
+help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
+   |
+LL |     fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> {
+   |                                                                     +++++++++++++++++++++++++++++++++++++++++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.