about summary refs log tree commit diff
path: root/tests/ui/modules
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-11 07:35:19 +0200
committerGitHub <noreply@github.com>2025-07-11 07:35:19 +0200
commit66799d0b83df8ef34df210ba454b59fce53fd1e9 (patch)
tree4d5703b8d224e0d654c41b81edd9eb7fed76be7d /tests/ui/modules
parent3d6eb225e26448b09fdec1ba7222f3e7174c6ac2 (diff)
parent259512e3b6a920b1e1eb6034fbc738e7b9815337 (diff)
downloadrust-66799d0b83df8ef34df210ba454b59fce53fd1e9.tar.gz
rust-66799d0b83df8ef34df210ba454b59fce53fd1e9.zip
Rollup merge of #143303 - Kivooeo:tf28, r=tgross35
`tests/ui`: A New Order [28/28] FINAL PART

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? ``@tgross35``
Diffstat (limited to 'tests/ui/modules')
-rw-r--r--tests/ui/modules/module-qualified-paths-basic.rs20
-rw-r--r--tests/ui/modules/module-use-nested-groups.rs34
-rw-r--r--tests/ui/modules/primitive-type-module-deprecated-paths.rs13
-rw-r--r--tests/ui/modules/use-keyword-reexport-type-alias.rs25
4 files changed, 92 insertions, 0 deletions
diff --git a/tests/ui/modules/module-qualified-paths-basic.rs b/tests/ui/modules/module-qualified-paths-basic.rs
new file mode 100644
index 00000000000..c02f6060caa
--- /dev/null
+++ b/tests/ui/modules/module-qualified-paths-basic.rs
@@ -0,0 +1,20 @@
+//! Checks that functions from different modules are accessible via their fully-qualified paths.
+
+//@ run-pass
+
+mod foo {
+    pub fn x() -> isize {
+        return 1;
+    }
+}
+
+mod bar {
+    pub fn y() -> isize {
+        return 1;
+    }
+}
+
+pub fn main() {
+    foo::x();
+    bar::y();
+}
diff --git a/tests/ui/modules/module-use-nested-groups.rs b/tests/ui/modules/module-use-nested-groups.rs
new file mode 100644
index 00000000000..84d1f9141a8
--- /dev/null
+++ b/tests/ui/modules/module-use-nested-groups.rs
@@ -0,0 +1,34 @@
+//! Checks complex `use` syntax and availability of types across nested modules.
+
+//@ run-pass
+
+mod a {
+    pub enum B {}
+
+    pub mod d {
+        pub enum E {}
+        pub enum F {}
+
+        pub mod g {
+            pub enum H {}
+            pub enum I {}
+        }
+    }
+}
+
+// Test every possible part of the syntax
+use a::{B, d::{self, *, g::H}};
+
+// Test a more common use case
+use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
+
+fn main() {
+    let _: B;
+    let _: E;
+    let _: F;
+    let _: H;
+    let _: d::g::I;
+
+    let _: Arc<AtomicBool>;
+    let _: Ordering;
+}
diff --git a/tests/ui/modules/primitive-type-module-deprecated-paths.rs b/tests/ui/modules/primitive-type-module-deprecated-paths.rs
new file mode 100644
index 00000000000..5c9d2a616b3
--- /dev/null
+++ b/tests/ui/modules/primitive-type-module-deprecated-paths.rs
@@ -0,0 +1,13 @@
+//! Make sure the module level constants are still there and accessible even after
+//! the corresponding associated constants have been added, and later stabilized.
+
+//@ run-pass
+
+#![allow(deprecated, deprecated_in_future)]
+use std::{f32, u16};
+
+fn main() {
+    let _ = u16::MAX;
+    let _ = f32::EPSILON;
+    let _ = std::f64::MANTISSA_DIGITS;
+}
diff --git a/tests/ui/modules/use-keyword-reexport-type-alias.rs b/tests/ui/modules/use-keyword-reexport-type-alias.rs
new file mode 100644
index 00000000000..c62bd9687ae
--- /dev/null
+++ b/tests/ui/modules/use-keyword-reexport-type-alias.rs
@@ -0,0 +1,25 @@
+//! Checks module re-exports, aliasing with `pub use`,
+//! and calling private methods via `Self` in an impl block.
+
+//@ run-pass
+
+#![allow(unused_variables)]
+pub struct A;
+
+mod test {
+    pub use self::A as B;
+    pub use super::A;
+}
+
+impl A {
+    fn f() {}
+    fn g() {
+        Self::f()
+    }
+}
+
+fn main() {
+    let a: A = test::A;
+    let b: A = test::B;
+    let c: () = A::g();
+}