about summary refs log tree commit diff
path: root/tests/ui/entry-point
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/entry-point
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'tests/ui/entry-point')
-rw-r--r--tests/ui/entry-point/auxiliary/main_functions.rs1
-rw-r--r--tests/ui/entry-point/imported_main_conflict.rs7
-rw-r--r--tests/ui/entry-point/imported_main_conflict.stderr19
-rw-r--r--tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs11
-rw-r--r--tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr11
-rw-r--r--tests/ui/entry-point/imported_main_const_forbidden.rs6
-rw-r--r--tests/ui/entry-point/imported_main_const_forbidden.stderr11
-rw-r--r--tests/ui/entry-point/imported_main_from_extern_crate.rs7
-rw-r--r--tests/ui/entry-point/imported_main_from_inner_mod.rs9
-rw-r--r--tests/ui/entry-point/imported_main_unused_not_trigger_feature_gate.rs11
10 files changed, 93 insertions, 0 deletions
diff --git a/tests/ui/entry-point/auxiliary/main_functions.rs b/tests/ui/entry-point/auxiliary/main_functions.rs
new file mode 100644
index 00000000000..cc7992a42c1
--- /dev/null
+++ b/tests/ui/entry-point/auxiliary/main_functions.rs
@@ -0,0 +1 @@
+pub fn boilerplate() {}
diff --git a/tests/ui/entry-point/imported_main_conflict.rs b/tests/ui/entry-point/imported_main_conflict.rs
new file mode 100644
index 00000000000..e8c70b06513
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_conflict.rs
@@ -0,0 +1,7 @@
+#![feature(imported_main)]
+//~^ ERROR `main` is ambiguous
+mod m1 { pub(crate) fn main() {} }
+mod m2 { pub(crate) fn main() {} }
+
+use m1::*;
+use m2::*;
diff --git a/tests/ui/entry-point/imported_main_conflict.stderr b/tests/ui/entry-point/imported_main_conflict.stderr
new file mode 100644
index 00000000000..8fadd0e19b3
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_conflict.stderr
@@ -0,0 +1,19 @@
+error[E0659]: `main` is ambiguous
+   |
+   = note: ambiguous because of multiple glob imports of a name in the same module
+note: `main` could refer to the function imported here
+  --> $DIR/imported_main_conflict.rs:6:5
+   |
+LL | use m1::*;
+   |     ^^^^^
+   = help: consider adding an explicit import of `main` to disambiguate
+note: `main` could also refer to the function imported here
+  --> $DIR/imported_main_conflict.rs:7:5
+   |
+LL | use m2::*;
+   |     ^^^^^
+   = help: consider adding an explicit import of `main` to disambiguate
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
diff --git a/tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs b/tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs
new file mode 100644
index 00000000000..405d6e2a9f5
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs
@@ -0,0 +1,11 @@
+#![feature(imported_main)]
+#![feature(type_alias_impl_trait)]
+#![allow(incomplete_features)]
+pub mod foo {
+    type MainFn = impl Fn();
+
+    fn bar() {}
+    pub const BAR: MainFn = bar;
+}
+
+use foo::BAR as main; //~ ERROR `main` function not found in crate
diff --git a/tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr b/tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr
new file mode 100644
index 00000000000..fabb6ffb02f
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr
@@ -0,0 +1,11 @@
+error[E0601]: `main` function not found in crate `imported_main_const_fn_item_type_forbidden`
+  --> $DIR/imported_main_const_fn_item_type_forbidden.rs:11:22
+   |
+LL | use foo::BAR as main;
+   |     ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_fn_item_type_forbidden.rs`
+   |     |
+   |     non-function item at `crate::main` is found
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0601`.
diff --git a/tests/ui/entry-point/imported_main_const_forbidden.rs b/tests/ui/entry-point/imported_main_const_forbidden.rs
new file mode 100644
index 00000000000..1508280c0fa
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_const_forbidden.rs
@@ -0,0 +1,6 @@
+#![feature(imported_main)]
+pub mod foo {
+    pub const BAR: usize = 42;
+}
+
+use foo::BAR as main; //~ ERROR `main` function not found in crate
diff --git a/tests/ui/entry-point/imported_main_const_forbidden.stderr b/tests/ui/entry-point/imported_main_const_forbidden.stderr
new file mode 100644
index 00000000000..9d8b40dc3c9
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_const_forbidden.stderr
@@ -0,0 +1,11 @@
+error[E0601]: `main` function not found in crate `imported_main_const_forbidden`
+  --> $DIR/imported_main_const_forbidden.rs:6:22
+   |
+LL | use foo::BAR as main;
+   |     ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_forbidden.rs`
+   |     |
+   |     non-function item at `crate::main` is found
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0601`.
diff --git a/tests/ui/entry-point/imported_main_from_extern_crate.rs b/tests/ui/entry-point/imported_main_from_extern_crate.rs
new file mode 100644
index 00000000000..4fddfc44ac6
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_from_extern_crate.rs
@@ -0,0 +1,7 @@
+// run-pass
+// aux-build:main_functions.rs
+
+#![feature(imported_main)]
+
+extern crate main_functions;
+pub use main_functions::boilerplate as main;
diff --git a/tests/ui/entry-point/imported_main_from_inner_mod.rs b/tests/ui/entry-point/imported_main_from_inner_mod.rs
new file mode 100644
index 00000000000..45750072a7f
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_from_inner_mod.rs
@@ -0,0 +1,9 @@
+// run-pass
+#![feature(imported_main)]
+
+pub mod foo {
+    pub fn bar() {
+        println!("Hello world!");
+    }
+}
+use foo::bar as main;
diff --git a/tests/ui/entry-point/imported_main_unused_not_trigger_feature_gate.rs b/tests/ui/entry-point/imported_main_unused_not_trigger_feature_gate.rs
new file mode 100644
index 00000000000..4762fbb7c59
--- /dev/null
+++ b/tests/ui/entry-point/imported_main_unused_not_trigger_feature_gate.rs
@@ -0,0 +1,11 @@
+// check-pass
+#![feature(rustc_attrs)]
+
+#[rustc_main]
+fn actual_main() {}
+
+mod foo {
+    pub(crate) fn something() {}
+}
+
+use foo::something as main;