]> git.lizzy.rs Git - rust.git/blob - crates/hir_ty/src/tests/display_source_code.rs
Merge #9007
[rust.git] / crates / hir_ty / src / tests / display_source_code.rs
1 use super::check_types_source_code;
2
3 #[test]
4 fn qualify_path_to_submodule() {
5     check_types_source_code(
6         r#"
7 mod foo {
8     pub struct Foo;
9 }
10
11 fn bar() {
12     let foo: foo::Foo = foo::Foo;
13     foo
14 }  //^ foo::Foo
15
16 "#,
17     );
18 }
19
20 #[test]
21 fn omit_default_type_parameters() {
22     check_types_source_code(
23         r#"
24 struct Foo<T = u8> { t: T }
25 fn main() {
26     let foo = Foo { t: 5u8 };
27     foo;
28 }  //^ Foo
29 "#,
30     );
31
32     check_types_source_code(
33         r#"
34 struct Foo<K, T = u8> { k: K, t: T }
35 fn main() {
36     let foo = Foo { k: 400, t: 5u8 };
37     foo;
38 }   //^ Foo<i32>
39 "#,
40     );
41 }
42
43 #[test]
44 fn render_raw_ptr_impl_ty() {
45     check_types_source_code(
46         r#"
47 trait Sized {}
48 trait Unpin {}
49 fn foo() -> *const (impl Unpin + Sized) { loop {} }
50 fn main() {
51     let foo = foo();
52     foo;
53 }   //^ *const (impl Unpin + Sized)
54 "#,
55     );
56 }