File tree Expand file tree Collapse file tree 5 files changed +34
-4
lines changed
test/library-tests/type-inference Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,20 @@ final class RangeFromToExpr extends RangeExpr {
46
46
}
47
47
}
48
48
49
+ /**
50
+ * A range-full expression. For example:
51
+ * ```rust
52
+ * let x = ..;
53
+ * ```
54
+ */
55
+ final class RangeFullExpr extends RangeExpr {
56
+ RangeFullExpr ( ) {
57
+ this .getOperatorName ( ) = ".." and
58
+ not this .hasStart ( ) and
59
+ not this .hasEnd ( )
60
+ }
61
+ }
62
+
49
63
/**
50
64
* A range-inclusive expression. For example:
51
65
* ```rust
Original file line number Diff line number Diff line change @@ -94,6 +94,16 @@ class RangeToStruct extends Struct {
94
94
StructField getEnd ( ) { result = this .getStructField ( "end" ) }
95
95
}
96
96
97
+ /**
98
+ * The [`RangeFull` struct][1].
99
+ *
100
+ * [1]: https://doc.rust-lang.org/core/ops/struct.RangeFull.html
101
+ */
102
+ class RangeFullStruct extends Struct {
103
+ pragma [ nomagic]
104
+ RangeFullStruct ( ) { this .getCanonicalPath ( ) = "core::ops::range::RangeFull" }
105
+ }
106
+
97
107
/**
98
108
* The [`RangeInclusive` struct][1].
99
109
*
Original file line number Diff line number Diff line change @@ -385,6 +385,9 @@ private module CertainTypeInference {
385
385
or
386
386
result = inferLogicalOperationType ( n , path )
387
387
or
388
+ result = inferRangeExprType ( n ) and
389
+ path .isEmpty ( )
390
+ or
388
391
result = inferTupleRootType ( n ) and
389
392
path .isEmpty ( )
390
393
or
@@ -463,6 +466,9 @@ private Struct getRangeType(RangeExpr re) {
463
466
re instanceof RangeToExpr and
464
467
result instanceof RangeToStruct
465
468
or
469
+ re instanceof RangeFullExpr and
470
+ result instanceof RangeFullStruct
471
+ or
466
472
re instanceof RangeFromToExpr and
467
473
result instanceof RangeStruct
468
474
or
@@ -2402,9 +2408,6 @@ private module Cached {
2402
2408
or
2403
2409
result = inferAwaitExprType ( n , path )
2404
2410
or
2405
- result = inferRangeExprType ( n ) and
2406
- path .isEmpty ( )
2407
- or
2408
2411
result = inferIndexExprType ( n , path )
2409
2412
or
2410
2413
result = inferForLoopExprType ( n , path )
Original file line number Diff line number Diff line change @@ -2332,7 +2332,7 @@ mod loops {
2332
2332
for u in [ 0u8 ..10 ] { } // $ type=u:Range type=u:Idx.u8
2333
2333
let range = 0 ..10 ; // $ type=range:Range type=range:Idx.i32
2334
2334
for i in range { } // $ type=i:i32
2335
- let range_full = ..; // $ MISSING: type=range_full:RangeFull
2335
+ let range_full = ..; // $ type=range_full:RangeFull
2336
2336
for i in & [ 1i64 , 2i64 , 3i64 ] [ range_full] { } // $ target=index MISSING: type=i:&T.i64
2337
2337
2338
2338
let range1 = // $ type=range1:Range type=range1:Idx.u16
Original file line number Diff line number Diff line change @@ -4367,13 +4367,16 @@ inferType
4367
4367
| main.rs:2334:13:2334:13 | i | | {EXTERNAL LOCATION} | i32 |
4368
4368
| main.rs:2334:18:2334:22 | range | | {EXTERNAL LOCATION} | Range |
4369
4369
| main.rs:2334:18:2334:22 | range | Idx | {EXTERNAL LOCATION} | i32 |
4370
+ | main.rs:2335:13:2335:22 | range_full | | {EXTERNAL LOCATION} | RangeFull |
4371
+ | main.rs:2335:26:2335:27 | .. | | {EXTERNAL LOCATION} | RangeFull |
4370
4372
| main.rs:2336:13:2336:13 | i | | {EXTERNAL LOCATION} | Item |
4371
4373
| main.rs:2336:18:2336:48 | &... | | file://:0:0:0:0 | & |
4372
4374
| main.rs:2336:19:2336:36 | [...] | | file://:0:0:0:0 | [] |
4373
4375
| main.rs:2336:19:2336:36 | [...] | [T;...] | {EXTERNAL LOCATION} | i64 |
4374
4376
| main.rs:2336:20:2336:23 | 1i64 | | {EXTERNAL LOCATION} | i64 |
4375
4377
| main.rs:2336:26:2336:29 | 2i64 | | {EXTERNAL LOCATION} | i64 |
4376
4378
| main.rs:2336:32:2336:35 | 3i64 | | {EXTERNAL LOCATION} | i64 |
4379
+ | main.rs:2336:38:2336:47 | range_full | | {EXTERNAL LOCATION} | RangeFull |
4377
4380
| main.rs:2338:13:2338:18 | range1 | | {EXTERNAL LOCATION} | Range |
4378
4381
| main.rs:2338:13:2338:18 | range1 | Idx | {EXTERNAL LOCATION} | u16 |
4379
4382
| main.rs:2339:9:2342:9 | ...::Range {...} | | {EXTERNAL LOCATION} | Range |
You can’t perform that action at this time.
0 commit comments