@@ -2,55 +2,6 @@ use expect_test::expect;
2
2
3
3
use super :: { check, check_infer, check_no_mismatches, check_types} ;
4
4
5
- #[ test]
6
- fn infer_box ( ) {
7
- check_types (
8
- r#"
9
- //- /main.rs crate:main deps:std
10
- fn test() {
11
- let x = box 1;
12
- let t = (x, box x, box &1, box [1]);
13
- t;
14
- } //^ (Box<i32>, Box<Box<i32>>, Box<&i32>, Box<[i32; 1]>)
15
-
16
- //- /std.rs crate:std
17
- #[prelude_import] use prelude::*;
18
- mod prelude {}
19
-
20
- mod boxed {
21
- #[lang = "owned_box"]
22
- pub struct Box<T: ?Sized> {
23
- inner: *mut T,
24
- }
25
- }
26
- "# ,
27
- ) ;
28
- }
29
-
30
- #[ test]
31
- fn infer_box_with_allocator ( ) {
32
- check_types (
33
- r#"
34
- //- /main.rs crate:main deps:std
35
- fn test() {
36
- let x = box 1;
37
- let t = (x, box x, box &1, box [1]);
38
- t;
39
- } //^ (Box<i32, {unknown}>, Box<Box<i32, {unknown}>, {unknown}>, Box<&i32, {unknown}>, Box<[i32; 1], {unknown}>)
40
-
41
- //- /std.rs crate:std
42
- #[prelude_import] use prelude::*;
43
- mod boxed {
44
- #[lang = "owned_box"]
45
- pub struct Box<T: ?Sized, A: Allocator> {
46
- inner: *mut T,
47
- allocator: A,
48
- }
49
- }
50
- "# ,
51
- ) ;
52
- }
53
-
54
5
#[ test]
55
6
fn infer_adt_self ( ) {
56
7
check_types (
@@ -2763,8 +2714,8 @@ impl<T> [T] {
2763
2714
}
2764
2715
2765
2716
fn test() {
2766
- let vec = <[_]>::into_vec(box [1i32]);
2767
- let v: Vec<Box<dyn B>> = <[_]> :: into_vec(box [box Astruct] );
2717
+ let vec = <[_]>::into_vec(#[rustc_box] Box::new( [1i32]) );
2718
+ let v: Vec<Box<dyn B>> = <[_]> :: into_vec(#[rustc_box] Box::new([#[rustc_box] Box::new( Astruct)]) );
2768
2719
}
2769
2720
2770
2721
trait B{}
@@ -2774,20 +2725,20 @@ impl B for Astruct {}
2774
2725
expect ! [ [ r#"
2775
2726
604..608 'self': Box<[T], A>
2776
2727
637..669 '{ ... }': Vec<T, A>
2777
- 683..796 '{ ...t] ); }': ()
2728
+ 683..853 '{ ...]) ); }': ()
2778
2729
693..696 'vec': Vec<i32, Global>
2779
2730
699..714 '<[_]>::into_vec': fn into_vec<i32, Global>(Box<[i32], Global>) -> Vec<i32, Global>
2780
- 699..726 '<[_]>:...1i32] )': Vec<i32, Global>
2781
- 715..725 'box [ 1i32]': Box<[i32; 1], Global>
2782
- 719..725 '[1i32]': [i32; 1]
2783
- 720..724 '1i32': i32
2784
- 736..737 'v': Vec<Box<dyn B, Global>, Global>
2785
- 757..774 '<[_]> ...to_vec': fn into_vec<Box<dyn B, Global>, Global>(Box<[Box<dyn B, Global>], Global>) -> Vec<Box<dyn B, Global>, Global>
2786
- 757..793 '<[_]> ...ruct] )': Vec<Box<dyn B, Global>, Global>
2787
- 775..792 'box [b ...truct] ': Box<[Box<dyn B, Global>; 1], Global>
2788
- 779..792 '[box Astruct ]': [Box<dyn B, Global>; 1]
2789
- 780..791 'box Astruct ': Box<Astruct, Global>
2790
- 784..791 'Astruct': Astruct
2731
+ 699..745 '<[_]>:...i32]) )': Vec<i32, Global>
2732
+ 715..744 '#[rust... 1i32]) ': Box<[i32; 1], Global>
2733
+ 737..743 '[1i32]': [i32; 1]
2734
+ 738..742 '1i32': i32
2735
+ 755..756 'v': Vec<Box<dyn B, Global>, Global>
2736
+ 776..793 '<[_]> ...to_vec': fn into_vec<Box<dyn B, Global>, Global>(Box<[Box<dyn B, Global>], Global>) -> Vec<Box<dyn B, Global>, Global>
2737
+ 776..850 '<[_]> ...ct)]) )': Vec<Box<dyn B, Global>, Global>
2738
+ 794..849 '#[rust ...uct)]) ': Box<[Box<dyn B, Global>; 1], Global>
2739
+ 816..848 '[#[rus...ruct) ]': [Box<dyn B, Global>; 1]
2740
+ 817..847 '#[rust...truct) ': Box<Astruct, Global>
2741
+ 839..846 'Astruct': Astruct
2791
2742
"# ] ] ,
2792
2743
)
2793
2744
}
@@ -3649,3 +3600,15 @@ fn main() {
3649
3600
"# ,
3650
3601
) ;
3651
3602
}
3603
+
3604
+ #[ test]
3605
+ fn offset_of ( ) {
3606
+ check_types (
3607
+ r#"
3608
+ fn main() {
3609
+ builtin#offset_of((,), 0);
3610
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^ usize
3611
+ }
3612
+ "# ,
3613
+ ) ;
3614
+ }
0 commit comments