summaryrefslogtreecommitdiffstats
path: root/tests/ui/errors
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/errors
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/errors')
-rw-r--r--tests/ui/errors/auxiliary/remapped_dep.rs4
-rw-r--r--tests/ui/errors/issue-104621-extern-bad-file.rs8
-rw-r--r--tests/ui/errors/issue-104621-extern-bad-file.stderr21
-rw-r--r--tests/ui/errors/issue-104621-extern-not-file.rs4
-rw-r--r--tests/ui/errors/issue-104621-extern-not-file.stderr8
-rw-r--r--tests/ui/errors/issue-89280-emitter-overflow-splice-lines.rs10
-rw-r--r--tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr23
-rw-r--r--tests/ui/errors/issue-99572-impl-trait-on-pointer.rs25
-rw-r--r--tests/ui/errors/issue-99572-impl-trait-on-pointer.stderr31
-rw-r--r--tests/ui/errors/remap-path-prefix-reverse.local-self.stderr14
-rw-r--r--tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr14
-rw-r--r--tests/ui/errors/remap-path-prefix-reverse.rs17
-rw-r--r--tests/ui/errors/remap-path-prefix.rs17
-rw-r--r--tests/ui/errors/remap-path-prefix.stderr9
14 files changed, 205 insertions, 0 deletions
diff --git a/tests/ui/errors/auxiliary/remapped_dep.rs b/tests/ui/errors/auxiliary/remapped_dep.rs
new file mode 100644
index 000000000..f9bb7bf89
--- /dev/null
+++ b/tests/ui/errors/auxiliary/remapped_dep.rs
@@ -0,0 +1,4 @@
+// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux
+// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
+
+pub struct SomeStruct {} // This line should be show as part of the error.
diff --git a/tests/ui/errors/issue-104621-extern-bad-file.rs b/tests/ui/errors/issue-104621-extern-bad-file.rs
new file mode 100644
index 000000000..3f13d6052
--- /dev/null
+++ b/tests/ui/errors/issue-104621-extern-bad-file.rs
@@ -0,0 +1,8 @@
+// compile-flags: --extern foo={{src-base}}/errors/issue-104621-extern-bad-file.rs
+// only-linux
+
+extern crate foo;
+//~^ ERROR extern location for foo is of an unknown type
+//~| ERROR file name should be lib*.rlib or lib*.so
+//~| ERROR can't find crate for `foo` [E0463]
+fn main() {}
diff --git a/tests/ui/errors/issue-104621-extern-bad-file.stderr b/tests/ui/errors/issue-104621-extern-bad-file.stderr
new file mode 100644
index 000000000..b8500ad0e
--- /dev/null
+++ b/tests/ui/errors/issue-104621-extern-bad-file.stderr
@@ -0,0 +1,21 @@
+error: extern location for foo is of an unknown type: $DIR/issue-104621-extern-bad-file.rs
+ --> $DIR/issue-104621-extern-bad-file.rs:4:1
+ |
+LL | extern crate foo;
+ | ^^^^^^^^^^^^^^^^^
+
+error: file name should be lib*.rlib or lib*.so
+ --> $DIR/issue-104621-extern-bad-file.rs:4:1
+ |
+LL | extern crate foo;
+ | ^^^^^^^^^^^^^^^^^
+
+error[E0463]: can't find crate for `foo`
+ --> $DIR/issue-104621-extern-bad-file.rs:4:1
+ |
+LL | extern crate foo;
+ | ^^^^^^^^^^^^^^^^^ can't find crate
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0463`.
diff --git a/tests/ui/errors/issue-104621-extern-not-file.rs b/tests/ui/errors/issue-104621-extern-not-file.rs
new file mode 100644
index 000000000..899e45a30
--- /dev/null
+++ b/tests/ui/errors/issue-104621-extern-not-file.rs
@@ -0,0 +1,4 @@
+// compile-flags: --extern foo=.
+
+extern crate foo; //~ ERROR extern location for foo is not a file: .
+fn main() {}
diff --git a/tests/ui/errors/issue-104621-extern-not-file.stderr b/tests/ui/errors/issue-104621-extern-not-file.stderr
new file mode 100644
index 000000000..5aaf97413
--- /dev/null
+++ b/tests/ui/errors/issue-104621-extern-not-file.stderr
@@ -0,0 +1,8 @@
+error: extern location for foo is not a file: .
+ --> $DIR/issue-104621-extern-not-file.rs:3:1
+ |
+LL | extern crate foo;
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.rs b/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.rs
new file mode 100644
index 000000000..a1c7af128
--- /dev/null
+++ b/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.rs
@@ -0,0 +1,10 @@
+// check-pass
+
+trait X {
+ fn test(x: u32, (
+//~^ WARN anonymous parameters are deprecated and will be removed in the next edition
+//~^^ WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
+ )) {}
+}
+
+fn main() {}
diff --git a/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr b/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr
new file mode 100644
index 000000000..08eb8cfac
--- /dev/null
+++ b/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr
@@ -0,0 +1,23 @@
+warning: anonymous parameters are deprecated and will be removed in the next edition
+ --> $DIR/issue-89280-emitter-overflow-splice-lines.rs:4:21
+ |
+LL | fn test(x: u32, (
+ | _____________________^
+LL | |
+LL | |
+LL | | )) {}
+ | |_____^
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
+ = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
+ = note: `#[warn(anonymous_parameters)]` on by default
+help: try naming the parameter or explicitly ignoring it
+ |
+LL ~ fn test(x: u32, _: (
+LL +
+LL +
+LL ~ )) {}
+ |
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/errors/issue-99572-impl-trait-on-pointer.rs b/tests/ui/errors/issue-99572-impl-trait-on-pointer.rs
new file mode 100644
index 000000000..272c6bd3f
--- /dev/null
+++ b/tests/ui/errors/issue-99572-impl-trait-on-pointer.rs
@@ -0,0 +1,25 @@
+// Emit additional suggestion to correct the trait implementation
+// on a pointer
+use std::{fmt, marker};
+
+struct LocalType;
+
+impl fmt::Display for *mut LocalType {
+//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
+//~| NOTE impl doesn't use only types from inside the current crate
+//~| NOTE `*mut LocalType` is not defined in the current crate because raw pointers are always foreign
+//~| NOTE define and implement a trait or new type instead
+//~| HELP consider introducing a new wrapper type
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "This not compile")
+ }
+}
+
+impl<T> marker::Copy for *mut T {
+//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
+//~| NOTE impl doesn't use only types from inside the current crate
+//~| NOTE `*mut T` is not defined in the current crate because raw pointers are always foreign
+//~| NOTE define and implement a trait or new type instead
+}
+
+fn main() {}
diff --git a/tests/ui/errors/issue-99572-impl-trait-on-pointer.stderr b/tests/ui/errors/issue-99572-impl-trait-on-pointer.stderr
new file mode 100644
index 000000000..78d7a47de
--- /dev/null
+++ b/tests/ui/errors/issue-99572-impl-trait-on-pointer.stderr
@@ -0,0 +1,31 @@
+error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
+ --> $DIR/issue-99572-impl-trait-on-pointer.rs:7:1
+ |
+LL | impl fmt::Display for *mut LocalType {
+ | ^^^^^^^^^^^^^^^^^^^^^^--------------
+ | | |
+ | | `*mut LocalType` is not defined in the current crate because raw pointers are always foreign
+ | impl doesn't use only types from inside the current crate
+ |
+ = note: define and implement a trait or new type instead
+help: consider introducing a new wrapper type
+ |
+LL + struct WrapperType(*mut LocalType);
+LL +
+LL ~ impl fmt::Display for WrapperType {
+ |
+
+error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
+ --> $DIR/issue-99572-impl-trait-on-pointer.rs:18:1
+ |
+LL | impl<T> marker::Copy for *mut T {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^------
+ | | |
+ | | `*mut T` is not defined in the current crate because raw pointers are always foreign
+ | impl doesn't use only types from inside the current crate
+ |
+ = note: define and implement a trait or new type instead
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0117`.
diff --git a/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr
new file mode 100644
index 000000000..51e3b776c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr
@@ -0,0 +1,14 @@
+error[E0423]: expected value, found struct `remapped_dep::SomeStruct`
+ --> $DIR/remap-path-prefix-reverse.rs:16:13
+ |
+LL | let _ = remapped_dep::SomeStruct; // ~ERROR E0423
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}`
+ |
+ ::: remapped-aux/remapped_dep.rs:4:1
+ |
+LL | pub struct SomeStruct {} // This line should be show as part of the error.
+ | --------------------- `remapped_dep::SomeStruct` defined here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr
new file mode 100644
index 000000000..51e3b776c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr
@@ -0,0 +1,14 @@
+error[E0423]: expected value, found struct `remapped_dep::SomeStruct`
+ --> $DIR/remap-path-prefix-reverse.rs:16:13
+ |
+LL | let _ = remapped_dep::SomeStruct; // ~ERROR E0423
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}`
+ |
+ ::: remapped-aux/remapped_dep.rs:4:1
+ |
+LL | pub struct SomeStruct {} // This line should be show as part of the error.
+ | --------------------- `remapped_dep::SomeStruct` defined here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0423`.
diff --git a/tests/ui/errors/remap-path-prefix-reverse.rs b/tests/ui/errors/remap-path-prefix-reverse.rs
new file mode 100644
index 000000000..71c80063c
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix-reverse.rs
@@ -0,0 +1,17 @@
+// aux-build:remapped_dep.rs
+// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux
+
+// revisions: local-self remapped-self
+// [local-self] no-remap-src-base: The hack should work regardless of remapping.
+// [remapped-self] remap-src-base
+
+// Verify that the expected source code is shown.
+// error-pattern: pub struct SomeStruct {} // This line should be show
+
+extern crate remapped_dep;
+
+fn main() {
+ // The actual error is irrelevant. The important part it that is should show
+ // a snippet of the dependency's source.
+ let _ = remapped_dep::SomeStruct; // ~ERROR E0423
+}
diff --git a/tests/ui/errors/remap-path-prefix.rs b/tests/ui/errors/remap-path-prefix.rs
new file mode 100644
index 000000000..393b8e22f
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix.rs
@@ -0,0 +1,17 @@
+// compile-flags: --remap-path-prefix={{src-base}}=remapped
+// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
+
+// The remapped paths are not normalized by compiletest.
+// normalize-stderr-test: "\\(errors)" -> "/$1"
+
+// The remapped paths aren't recognized by compiletest, so we
+// cannot use line-specific patterns.
+// error-pattern: E0425
+
+fn main() {
+ // We cannot actually put an ERROR marker here because
+ // the file name in the error message is not what the
+ // test framework expects (since the filename gets remapped).
+ // We still test the expected error in the stderr file.
+ ferris
+}
diff --git a/tests/ui/errors/remap-path-prefix.stderr b/tests/ui/errors/remap-path-prefix.stderr
new file mode 100644
index 000000000..62dbd4b88
--- /dev/null
+++ b/tests/ui/errors/remap-path-prefix.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `ferris` in this scope
+ --> remapped/errors/remap-path-prefix.rs:16:5
+ |
+LL | ferris
+ | ^^^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.