Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/traits.rs')
-rw-r--r--crates/hir-ty/src/tests/traits.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs
index db14addaf1..879c69c758 100644
--- a/crates/hir-ty/src/tests/traits.rs
+++ b/crates/hir-ty/src/tests/traits.rs
@@ -4553,3 +4553,58 @@ fn foo() {
"#,
);
}
+
+#[test]
+fn auto_trait_bound() {
+ check_types(
+ r#"
+//- minicore: sized
+auto trait Send {}
+impl<T> !Send for *const T {}
+
+struct Yes;
+trait IsSend { const IS_SEND: Yes; }
+impl<T: Send> IsSend for T { const IS_SEND: Yes = Yes; }
+
+struct Struct<T>(T);
+enum Enum<T> { A, B(T) }
+union Union<T> { t: T }
+
+#[lang = "phantom_data"]
+struct PhantomData<T: ?Sized>;
+
+fn f<T: Send, U>() {
+ T::IS_SEND;
+ //^^^^^^^^^^Yes
+ U::IS_SEND;
+ //^^^^^^^^^^{unknown}
+ <*const T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^{unknown}
+ Struct::<T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^Yes
+ Struct::<U>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^Yes
+ Struct::<*const T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^^Yes
+ Enum::<T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^Yes
+ Enum::<U>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^Yes
+ Enum::<*const T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^^^^^^Yes
+ Union::<T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^Yes
+ Union::<U>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^Yes
+ Union::<*const T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^Yes
+ PhantomData::<T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^^^^^^Yes
+ PhantomData::<U>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^^^^^^{unknown}
+ PhantomData::<*const T>::IS_SEND;
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown}
+}
+"#,
+ );
+}