Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/simple.rs')
-rw-r--r--crates/hir-ty/src/tests/simple.rs94
1 files changed, 93 insertions, 1 deletions
diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs
index 98503452d3..3ea21f8265 100644
--- a/crates/hir-ty/src/tests/simple.rs
+++ b/crates/hir-ty/src/tests/simple.rs
@@ -2152,10 +2152,11 @@ async fn main() {
let z: core::ops::ControlFlow<(), _> = try { () };
let w = const { 92 };
let t = 'a: { 92 };
+ let u = try bikeshed core::ops::ControlFlow<(), _> { () };
}
"#,
expect![[r#"
- 16..193 '{ ...2 }; }': ()
+ 16..256 '{ ...) }; }': ()
26..27 'x': i32
30..43 'unsafe { 92 }': i32
39..41 '92': i32
@@ -2176,6 +2177,13 @@ async fn main() {
176..177 't': i32
180..190 ''a: { 92 }': i32
186..188 '92': i32
+ 200..201 'u': ControlFlow<(), ()>
+ 204..253 'try bi...{ () }': ControlFlow<(), ()>
+ 204..253 'try bi...{ () }': fn from_output<ControlFlow<(), ()>>(<ControlFlow<(), ()> as Try>::Output) -> ControlFlow<(), ()>
+ 204..253 'try bi...{ () }': ControlFlow<(), ()>
+ 204..253 'try bi...{ () }': ControlFlow<(), ()>
+ 204..253 'try bi...{ () }': ControlFlow<(), ()>
+ 249..251 '()': ()
"#]],
)
}
@@ -3860,6 +3868,8 @@ fn main() {
208..209 'c': u8
213..214 'a': A
213..221 'a.into()': [u8; 2]
+ 33..34 '2': usize
+ 111..112 '3': usize
"#]],
);
}
@@ -4053,6 +4063,88 @@ fn foo() {
248..282 'LazyLo..._LOCK)': &'? [u32; _]
264..281 '&VALUE...Y_LOCK': &'? LazyLock<[u32; _]>
265..281 'VALUES...Y_LOCK': LazyLock<[u32; _]>
+ 197..202 '{ 0 }': usize
+ 199..200 '0': usize
+ "#]],
+ );
+}
+
+#[test]
+fn include_bytes_len_mismatch() {
+ check_no_mismatches(
+ r#"
+//- minicore: include_bytes
+static S: &[u8; 158] = include_bytes!("/foo/bar/baz.txt");
+ "#,
+ );
+}
+
+#[test]
+fn proc_macros_are_functions_inside_defining_crate_and_macros_outside() {
+ check_types(
+ r#"
+//- /pm.rs crate:pm
+#![crate_type = "proc-macro"]
+
+#[proc_macro_attribute]
+pub fn proc_macro() {}
+
+fn foo() {
+ proc_macro;
+ // ^^^^^^^^^^ fn proc_macro()
+}
+
+mod bar {
+ use super::proc_macro;
+
+ fn baz() {
+ super::proc_macro;
+ // ^^^^^^^^^^^^^^^^^ fn proc_macro()
+ proc_macro;
+ // ^^^^^^^^^^ fn proc_macro()
+ }
+}
+
+//- /lib.rs crate:lib deps:pm
+fn foo() {
+ pm::proc_macro;
+ // ^^^^^^^^^^^^^^ {unknown}
+}
+ "#,
+ );
+}
+
+#[test]
+fn signature_inference() {
+ check_infer(
+ r#"
+trait Trait<const A: u8> {}
+struct S<T: Trait<2>, const C: f32 = 0.0>
+where
+ (): Trait<2>
+{
+ field: [(); { C as usize }],
+ field2: *mut S<T, 5.0>
+}
+
+struct S2<const C: u16>;
+
+type Alias = S2<0>;
+impl S2<0> {}
+enum E {
+ V(S2<0>) = 0,
+}
+union U {
+ field: S2<0>
+}
+ "#,
+ expect![[r#"
+ 242..243 '0': isize
+ 46..47 '2': i32
+ 65..68 '0.0': f32
+ 90..91 '2': i32
+ 200..201 '0': i32
+ 212..213 '0': i32
"#]],
);
}