summaryrefslogtreecommitdiffstats
path: root/tests/ui/duplicate
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/duplicate
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/duplicate')
-rw-r--r--tests/ui/duplicate/dupe-symbols-1.rs14
-rw-r--r--tests/ui/duplicate/dupe-symbols-1.stderr8
-rw-r--r--tests/ui/duplicate/dupe-symbols-2.rs18
-rw-r--r--tests/ui/duplicate/dupe-symbols-2.stderr8
-rw-r--r--tests/ui/duplicate/dupe-symbols-3.rs14
-rw-r--r--tests/ui/duplicate/dupe-symbols-3.stderr8
-rw-r--r--tests/ui/duplicate/dupe-symbols-4.rs24
-rw-r--r--tests/ui/duplicate/dupe-symbols-4.stderr8
-rw-r--r--tests/ui/duplicate/dupe-symbols-5.rs13
-rw-r--r--tests/ui/duplicate/dupe-symbols-5.stderr8
-rw-r--r--tests/ui/duplicate/dupe-symbols-6.rs11
-rw-r--r--tests/ui/duplicate/dupe-symbols-6.stderr8
-rw-r--r--tests/ui/duplicate/dupe-symbols-7.rs12
-rw-r--r--tests/ui/duplicate/dupe-symbols-7.stderr10
-rw-r--r--tests/ui/duplicate/dupe-symbols-8.rs12
-rw-r--r--tests/ui/duplicate/dupe-symbols-8.stderr10
-rw-r--r--tests/ui/duplicate/duplicate-check-macro-exports.rs6
-rw-r--r--tests/ui/duplicate/duplicate-check-macro-exports.stderr18
-rw-r--r--tests/ui/duplicate/duplicate-parameter.rs5
-rw-r--r--tests/ui/duplicate/duplicate-parameter.stderr9
-rw-r--r--tests/ui/duplicate/duplicate-type-parameter.rs29
-rw-r--r--tests/ui/duplicate/duplicate-type-parameter.stderr66
22 files changed, 319 insertions, 0 deletions
diff --git a/tests/ui/duplicate/dupe-symbols-1.rs b/tests/ui/duplicate/dupe-symbols-1.rs
new file mode 100644
index 000000000..28e329b56
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-1.rs
@@ -0,0 +1,14 @@
+// build-fail
+
+//
+#![crate_type="rlib"]
+#![allow(warnings)]
+
+#[export_name="fail"]
+pub fn a() {
+}
+
+#[export_name="fail"]
+pub fn b() {
+//~^ symbol `fail` is already defined
+}
diff --git a/tests/ui/duplicate/dupe-symbols-1.stderr b/tests/ui/duplicate/dupe-symbols-1.stderr
new file mode 100644
index 000000000..933ed5e89
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-1.stderr
@@ -0,0 +1,8 @@
+error: symbol `fail` is already defined
+ --> $DIR/dupe-symbols-1.rs:12:1
+ |
+LL | pub fn b() {
+ | ^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/dupe-symbols-2.rs b/tests/ui/duplicate/dupe-symbols-2.rs
new file mode 100644
index 000000000..e303a790b
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-2.rs
@@ -0,0 +1,18 @@
+// build-fail
+
+//
+#![crate_type="rlib"]
+#![allow(warnings)]
+
+pub mod a {
+ #[no_mangle]
+ pub extern "C" fn fail() {
+ }
+}
+
+pub mod b {
+ #[no_mangle]
+ pub extern "C" fn fail() {
+ //~^ symbol `fail` is already defined
+ }
+}
diff --git a/tests/ui/duplicate/dupe-symbols-2.stderr b/tests/ui/duplicate/dupe-symbols-2.stderr
new file mode 100644
index 000000000..b132eae4b
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-2.stderr
@@ -0,0 +1,8 @@
+error: symbol `fail` is already defined
+ --> $DIR/dupe-symbols-2.rs:15:5
+ |
+LL | pub extern "C" fn fail() {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/dupe-symbols-3.rs b/tests/ui/duplicate/dupe-symbols-3.rs
new file mode 100644
index 000000000..1af2fe98e
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-3.rs
@@ -0,0 +1,14 @@
+// build-fail
+
+//
+#![crate_type="rlib"]
+#![allow(warnings)]
+
+#[export_name="fail"]
+pub fn a() {
+}
+
+#[no_mangle]
+pub fn fail() {
+//~^ symbol `fail` is already defined
+}
diff --git a/tests/ui/duplicate/dupe-symbols-3.stderr b/tests/ui/duplicate/dupe-symbols-3.stderr
new file mode 100644
index 000000000..6300b4908
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-3.stderr
@@ -0,0 +1,8 @@
+error: symbol `fail` is already defined
+ --> $DIR/dupe-symbols-3.rs:12:1
+ |
+LL | pub fn fail() {
+ | ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/dupe-symbols-4.rs b/tests/ui/duplicate/dupe-symbols-4.rs
new file mode 100644
index 000000000..de6610c3e
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-4.rs
@@ -0,0 +1,24 @@
+// build-fail
+
+//
+// error-pattern: symbol `fail` is already defined
+#![crate_type="rlib"]
+#![allow(warnings)]
+
+
+pub trait A {
+ fn fail(self);
+}
+
+struct B;
+struct C;
+
+impl A for B {
+ #[no_mangle]
+ fn fail(self) {}
+}
+
+impl A for C {
+ #[no_mangle]
+ fn fail(self) {}
+}
diff --git a/tests/ui/duplicate/dupe-symbols-4.stderr b/tests/ui/duplicate/dupe-symbols-4.stderr
new file mode 100644
index 000000000..1407a4883
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-4.stderr
@@ -0,0 +1,8 @@
+error: symbol `fail` is already defined
+ --> $DIR/dupe-symbols-4.rs:23:5
+ |
+LL | fn fail(self) {}
+ | ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/dupe-symbols-5.rs b/tests/ui/duplicate/dupe-symbols-5.rs
new file mode 100644
index 000000000..ea801cef6
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-5.rs
@@ -0,0 +1,13 @@
+// build-fail
+
+//
+#![crate_type="rlib"]
+#![allow(warnings)]
+
+#[export_name="fail"]
+static HELLO: u8 = 0;
+
+#[export_name="fail"]
+pub fn b() {
+//~^ symbol `fail` is already defined
+}
diff --git a/tests/ui/duplicate/dupe-symbols-5.stderr b/tests/ui/duplicate/dupe-symbols-5.stderr
new file mode 100644
index 000000000..558f868a0
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-5.stderr
@@ -0,0 +1,8 @@
+error: symbol `fail` is already defined
+ --> $DIR/dupe-symbols-5.rs:11:1
+ |
+LL | pub fn b() {
+ | ^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/dupe-symbols-6.rs b/tests/ui/duplicate/dupe-symbols-6.rs
new file mode 100644
index 000000000..018f4bb7f
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-6.rs
@@ -0,0 +1,11 @@
+// build-fail
+
+#![crate_type="rlib"]
+#![allow(warnings)]
+
+#[export_name="fail"]
+static HELLO: u8 = 0;
+
+#[export_name="fail"]
+static HELLO_TWICE: u16 = 0;
+//~^ symbol `fail` is already defined
diff --git a/tests/ui/duplicate/dupe-symbols-6.stderr b/tests/ui/duplicate/dupe-symbols-6.stderr
new file mode 100644
index 000000000..6692a63dc
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-6.stderr
@@ -0,0 +1,8 @@
+error: symbol `fail` is already defined
+ --> $DIR/dupe-symbols-6.rs:10:1
+ |
+LL | static HELLO_TWICE: u16 = 0;
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/dupe-symbols-7.rs b/tests/ui/duplicate/dupe-symbols-7.rs
new file mode 100644
index 000000000..633ca4c31
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-7.rs
@@ -0,0 +1,12 @@
+// build-fail
+
+//
+// error-pattern: entry symbol `main` declared multiple times
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+#![allow(warnings)]
+
+#[no_mangle]
+fn main(){}
diff --git a/tests/ui/duplicate/dupe-symbols-7.stderr b/tests/ui/duplicate/dupe-symbols-7.stderr
new file mode 100644
index 000000000..1455f0e75
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-7.stderr
@@ -0,0 +1,10 @@
+error: entry symbol `main` declared multiple times
+ --> $DIR/dupe-symbols-7.rs:12:1
+ |
+LL | fn main(){}
+ | ^^^^^^^^^
+ |
+ = help: did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/dupe-symbols-8.rs b/tests/ui/duplicate/dupe-symbols-8.rs
new file mode 100644
index 000000000..ce7fa24a9
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-8.rs
@@ -0,0 +1,12 @@
+// build-fail
+// error-pattern: entry symbol `main` declared multiple times
+//
+// See #67946.
+
+#![allow(warnings)]
+fn main() {
+ extern "Rust" {
+ fn main();
+ }
+ unsafe { main(); }
+}
diff --git a/tests/ui/duplicate/dupe-symbols-8.stderr b/tests/ui/duplicate/dupe-symbols-8.stderr
new file mode 100644
index 000000000..8d6a79e12
--- /dev/null
+++ b/tests/ui/duplicate/dupe-symbols-8.stderr
@@ -0,0 +1,10 @@
+error: entry symbol `main` declared multiple times
+ --> $DIR/dupe-symbols-8.rs:7:1
+ |
+LL | fn main() {
+ | ^^^^^^^^^
+ |
+ = help: did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead
+
+error: aborting due to previous error
+
diff --git a/tests/ui/duplicate/duplicate-check-macro-exports.rs b/tests/ui/duplicate/duplicate-check-macro-exports.rs
new file mode 100644
index 000000000..9ba28acfd
--- /dev/null
+++ b/tests/ui/duplicate/duplicate-check-macro-exports.rs
@@ -0,0 +1,6 @@
+pub use std::panic;
+
+#[macro_export]
+macro_rules! panic { () => {} } //~ ERROR the name `panic` is defined multiple times
+
+fn main() {}
diff --git a/tests/ui/duplicate/duplicate-check-macro-exports.stderr b/tests/ui/duplicate/duplicate-check-macro-exports.stderr
new file mode 100644
index 000000000..ba723b38b
--- /dev/null
+++ b/tests/ui/duplicate/duplicate-check-macro-exports.stderr
@@ -0,0 +1,18 @@
+error[E0255]: the name `panic` is defined multiple times
+ --> $DIR/duplicate-check-macro-exports.rs:4:1
+ |
+LL | pub use std::panic;
+ | ---------- previous import of the macro `panic` here
+...
+LL | macro_rules! panic { () => {} }
+ | ^^^^^^^^^^^^^^^^^^ `panic` redefined here
+ |
+ = note: `panic` must be defined only once in the macro namespace of this module
+help: you can use `as` to change the binding name of the import
+ |
+LL | pub use std::panic as other_panic;
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0255`.
diff --git a/tests/ui/duplicate/duplicate-parameter.rs b/tests/ui/duplicate/duplicate-parameter.rs
new file mode 100644
index 000000000..e5b21bbcd
--- /dev/null
+++ b/tests/ui/duplicate/duplicate-parameter.rs
@@ -0,0 +1,5 @@
+fn f(a: isize, a: isize) {}
+//~^ ERROR identifier `a` is bound more than once in this parameter list
+
+fn main() {
+}
diff --git a/tests/ui/duplicate/duplicate-parameter.stderr b/tests/ui/duplicate/duplicate-parameter.stderr
new file mode 100644
index 000000000..f3ef0bcf3
--- /dev/null
+++ b/tests/ui/duplicate/duplicate-parameter.stderr
@@ -0,0 +1,9 @@
+error[E0415]: identifier `a` is bound more than once in this parameter list
+ --> $DIR/duplicate-parameter.rs:1:16
+ |
+LL | fn f(a: isize, a: isize) {}
+ | ^ used as parameter more than once
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0415`.
diff --git a/tests/ui/duplicate/duplicate-type-parameter.rs b/tests/ui/duplicate/duplicate-type-parameter.rs
new file mode 100644
index 000000000..2751b3c8d
--- /dev/null
+++ b/tests/ui/duplicate/duplicate-type-parameter.rs
@@ -0,0 +1,29 @@
+type Foo<T,T> = Option<T>;
+//~^ ERROR the name `T` is already used
+
+struct Bar<T,T>(T);
+//~^ ERROR the name `T` is already used
+
+struct Baz<T,T> {
+//~^ ERROR the name `T` is already used
+ x: T,
+}
+
+enum Boo<T,T> {
+//~^ ERROR the name `T` is already used
+ A(T),
+ B,
+}
+
+fn quux<T,T>(x: T) {}
+//~^ ERROR the name `T` is already used
+
+trait Qux<T,T> {}
+//~^ ERROR the name `T` is already used
+
+impl<T,T> Qux<T,T> for Option<T> {}
+//~^ ERROR the name `T` is already used
+//~^^ ERROR the type parameter `T` is not constrained
+
+fn main() {
+}
diff --git a/tests/ui/duplicate/duplicate-type-parameter.stderr b/tests/ui/duplicate/duplicate-type-parameter.stderr
new file mode 100644
index 000000000..628f898d5
--- /dev/null
+++ b/tests/ui/duplicate/duplicate-type-parameter.stderr
@@ -0,0 +1,66 @@
+error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
+ --> $DIR/duplicate-type-parameter.rs:1:12
+ |
+LL | type Foo<T,T> = Option<T>;
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
+ --> $DIR/duplicate-type-parameter.rs:4:14
+ |
+LL | struct Bar<T,T>(T);
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
+ --> $DIR/duplicate-type-parameter.rs:7:14
+ |
+LL | struct Baz<T,T> {
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
+ --> $DIR/duplicate-type-parameter.rs:12:12
+ |
+LL | enum Boo<T,T> {
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
+ --> $DIR/duplicate-type-parameter.rs:18:11
+ |
+LL | fn quux<T,T>(x: T) {}
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
+ --> $DIR/duplicate-type-parameter.rs:21:13
+ |
+LL | trait Qux<T,T> {}
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters
+ --> $DIR/duplicate-type-parameter.rs:24:8
+ |
+LL | impl<T,T> Qux<T,T> for Option<T> {}
+ | - ^ already used
+ | |
+ | first use of `T`
+
+error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/duplicate-type-parameter.rs:24:8
+ |
+LL | impl<T,T> Qux<T,T> for Option<T> {}
+ | ^ unconstrained type parameter
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0207, E0403.
+For more information about an error, try `rustc --explain E0207`.