aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/display_source_code.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests/display_source_code.rs')
-rw-r--r--crates/hir_ty/src/tests/display_source_code.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/display_source_code.rs b/crates/hir_ty/src/tests/display_source_code.rs
new file mode 100644
index 000000000..b502135d8
--- /dev/null
+++ b/crates/hir_ty/src/tests/display_source_code.rs
@@ -0,0 +1,41 @@
1use super::check_types_source_code;
2
3#[test]
4fn qualify_path_to_submodule() {
5 check_types_source_code(
6 r#"
7mod foo {
8 pub struct Foo;
9}
10
11fn bar() {
12 let foo: foo::Foo = foo::Foo;
13 foo
14} //^ foo::Foo
15
16"#,
17 );
18}
19
20#[test]
21fn omit_default_type_parameters() {
22 check_types_source_code(
23 r#"
24struct Foo<T = u8> { t: T }
25fn main() {
26 let foo = Foo { t: 5u8 };
27 foo;
28} //^ Foo
29"#,
30 );
31
32 check_types_source_code(
33 r#"
34struct Foo<K, T = u8> { k: K, t: T }
35fn main() {
36 let foo = Foo { k: 400, t: 5u8 };
37 foo;
38} //^ Foo<i32>
39"#,
40 );
41}