summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const_constructor/const_constructor_qpath.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/consts/const_constructor/const_constructor_qpath.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/consts/const_constructor/const_constructor_qpath.rs')
-rw-r--r--src/test/ui/consts/const_constructor/const_constructor_qpath.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/ui/consts/const_constructor/const_constructor_qpath.rs b/src/test/ui/consts/const_constructor/const_constructor_qpath.rs
new file mode 100644
index 000000000..7c55f470f
--- /dev/null
+++ b/src/test/ui/consts/const_constructor/const_constructor_qpath.rs
@@ -0,0 +1,37 @@
+// run-pass
+
+trait ConstDefault {
+ const DEFAULT: Self;
+}
+
+#[derive(PartialEq)]
+enum E {
+ V(i32),
+ W(usize),
+}
+
+impl ConstDefault for E {
+ const DEFAULT: Self = Self::V(23);
+}
+
+impl ConstDefault for Option<i32> {
+ const DEFAULT: Self = Self::Some(23);
+}
+
+impl E {
+ const NON_DEFAULT: Self = Self::W(12);
+ const fn local_fn() -> Self {
+ Self::V(23)
+ }
+}
+
+const fn explicit_qpath() -> E {
+ let _x = <Option<usize>>::Some(23);
+ <E>::W(12)
+}
+
+fn main() {
+ assert!(E::DEFAULT == E::local_fn());
+ assert!(Option::DEFAULT == Some(23));
+ assert!(E::NON_DEFAULT == explicit_qpath());
+}