@@ -8,16 +8,16 @@ use std::pin::Pin;
8
8
// errors and parse such that further code gives useful errors.
9
9
pub fn index_after_as_cast ( ) {
10
10
vec ! [ 1 , 2 , 3 ] as Vec < i32 > [ 0 ] ;
11
- //~^ ERROR: casts cannot be followed by indexing
11
+ //~^ ERROR: cast cannot be followed by indexing
12
12
vec ! [ 1 , 2 , 3 ] : Vec <i32>[ 0 ] ;
13
- //~^ ERROR: casts cannot be followed by indexing
13
+ //~^ ERROR: type ascription cannot be followed by indexing
14
14
}
15
15
16
16
pub fn index_after_cast_to_index ( ) {
17
17
( & [ 0 ] ) as & [ i32 ] [ 0 ] ;
18
- //~^ ERROR: casts cannot be followed by indexing
18
+ //~^ ERROR: cast cannot be followed by indexing
19
19
( & [ 0i32 ] ) : & [ i32; 1 ] [ 0 ] ;
20
- //~^ ERROR: casts cannot be followed by indexing
20
+ //~^ ERROR: type ascription cannot be followed by indexing
21
21
}
22
22
23
23
pub fn cast_after_cast ( ) {
@@ -37,89 +37,89 @@ pub fn cast_after_cast() {
37
37
38
38
pub fn cast_cast_method_call ( ) {
39
39
let _ = 0i32 : i32 : i32. count_ones ( ) ;
40
- //~^ ERROR: casts cannot be followed by a method call
40
+ //~^ ERROR: type ascription cannot be followed by a method call
41
41
let _ = 0 as i32 : i32 . count_ones ( ) ;
42
- //~^ ERROR: casts cannot be followed by a method call
42
+ //~^ ERROR: type ascription cannot be followed by a method call
43
43
let _ = 0i32 : i32 as i32 . count_ones ( ) ;
44
- //~^ ERROR: casts cannot be followed by a method call
44
+ //~^ ERROR: cast cannot be followed by a method call
45
45
let _ = 0 as i32 as i32 . count_ones ( ) ;
46
- //~^ ERROR: casts cannot be followed by a method call
46
+ //~^ ERROR: cast cannot be followed by a method call
47
47
let _ = 0i32 : i32 : i32 as u32 as i32 . count_ones ( ) ;
48
- //~^ ERROR: casts cannot be followed by a method call
48
+ //~^ ERROR: cast cannot be followed by a method call
49
49
let _ = 0i32 : i32 . count_ones ( ) : u32 ;
50
- //~^ ERROR: casts cannot be followed by a method call
50
+ //~^ ERROR: type ascription cannot be followed by a method call
51
51
let _ = 0 as i32 . count_ones ( ) : u32 ;
52
- //~^ ERROR: casts cannot be followed by a method call
52
+ //~^ ERROR: cast cannot be followed by a method call
53
53
let _ = 0i32 : i32. count_ones ( ) as u32 ;
54
- //~^ ERROR: casts cannot be followed by a method call
54
+ //~^ ERROR: type ascription cannot be followed by a method call
55
55
let _ = 0 as i32 . count_ones ( ) as u32 ;
56
- //~^ ERROR: casts cannot be followed by a method call
56
+ //~^ ERROR: cast cannot be followed by a method call
57
57
let _ = 0i32 : i32 : i32. count_ones ( ) as u32 as i32 ;
58
- //~^ ERROR: casts cannot be followed by a method call
58
+ //~^ ERROR: type ascription cannot be followed by a method call
59
59
}
60
60
61
61
pub fn multiline_error ( ) {
62
62
let _ = 0
63
63
as i32
64
64
. count_ones ( ) ;
65
- //~^^^ ERROR: casts cannot be followed by a method call
65
+ //~^^^ ERROR: cast cannot be followed by a method call
66
66
}
67
67
68
68
// this tests that the precedence for `!x as Y.Z` is still what we expect
69
69
pub fn precedence ( ) {
70
70
let x: i32 = & vec ! [ 1 , 2 , 3 ] as & Vec < i32 > [ 0 ] ;
71
- //~^ ERROR: casts cannot be followed by indexing
71
+ //~^ ERROR: cast cannot be followed by indexing
72
72
}
73
73
74
74
pub fn method_calls ( ) {
75
75
0 as i32 . max ( 0 ) ;
76
- //~^ ERROR: casts cannot be followed by a method call
76
+ //~^ ERROR: cast cannot be followed by a method call
77
77
0 : i32. max ( 0 ) ;
78
- //~^ ERROR: casts cannot be followed by a method call
78
+ //~^ ERROR: type ascription cannot be followed by a method call
79
79
}
80
80
81
81
pub fn complex ( ) {
82
82
let _ = format ! (
83
83
"{} and {}" ,
84
84
if true { 33 } else { 44 } as i32 . max( 0 ) ,
85
- //~^ ERROR: casts cannot be followed by a method call
85
+ //~^ ERROR: cast cannot be followed by a method call
86
86
if true { 33 } else { 44 } : i32 . max( 0 )
87
- //~^ ERROR: casts cannot be followed by a method call
87
+ //~^ ERROR: type ascription cannot be followed by a method call
88
88
) ;
89
89
}
90
90
91
91
pub fn in_condition ( ) {
92
92
if 5u64 as i32 . max ( 0 ) == 0 {
93
- //~^ ERROR: casts cannot be followed by a method call
93
+ //~^ ERROR: cast cannot be followed by a method call
94
94
}
95
95
if 5u64 : u64. max ( 0 ) == 0 {
96
- //~^ ERROR: casts cannot be followed by a method call
96
+ //~^ ERROR: type ascription cannot be followed by a method call
97
97
}
98
98
}
99
99
100
100
pub fn inside_block ( ) {
101
101
let _ = if true {
102
102
5u64 as u32 . max ( 0 ) == 0
103
- //~^ ERROR: casts cannot be followed by a method call
103
+ //~^ ERROR: cast cannot be followed by a method call
104
104
} else { false } ;
105
105
let _ = if true {
106
106
5u64 : u64. max ( 0 ) == 0
107
- //~^ ERROR: casts cannot be followed by a method call
107
+ //~^ ERROR: type ascription cannot be followed by a method call
108
108
} else { false } ;
109
109
}
110
110
111
111
static bar: & [ i32 ] = & ( & [ 1 , 2 , 3 ] as & [ i32 ] [ 0 ..1 ] ) ;
112
- //~^ ERROR: casts cannot be followed by indexing
112
+ //~^ ERROR: cast cannot be followed by indexing
113
113
114
114
static bar2: & [ i32 ] = & ( & [ 1i32 , 2 , 3 ] : & [ i32; 3 ] [ 0 ..1 ] ) ;
115
- //~^ ERROR: casts cannot be followed by indexing
115
+ //~^ ERROR: type ascription cannot be followed by indexing
116
116
117
117
118
118
pub fn cast_then_try ( ) -> Result < u64 , u64 > {
119
119
Err ( 0u64 ) as Result < u64 , u64 > ?;
120
- //~^ ERROR: casts cannot be followed by `?`
120
+ //~^ ERROR: cast cannot be followed by `?`
121
121
Err ( 0u64 ) : Result <u64, u64>?;
122
- //~^ ERROR: casts cannot be followed by `?`
122
+ //~^ ERROR: type ascription cannot be followed by `?`
123
123
Ok ( 1 )
124
124
}
125
125
@@ -143,17 +143,17 @@ pub fn cast_to_fn_should_work() {
143
143
pub fn parens_after_cast_error ( ) {
144
144
let drop_ptr = drop as fn ( u8 ) ;
145
145
drop as fn ( u8 ) ( 0 ) ;
146
- //~^ ERROR: casts cannot be followed by a function call
146
+ //~^ ERROR: cast cannot be followed by a function call
147
147
drop_ptr : fn ( u8) ( 0 ) ;
148
- //~^ ERROR: casts cannot be followed by a function call
148
+ //~^ ERROR: type ascription cannot be followed by a function call
149
149
}
150
150
151
151
pub async fn cast_then_await ( ) {
152
152
Box :: pin ( noop ( ) ) as Pin < Box < dyn Future < Output = ( ) > > > . await ;
153
- //~^ ERROR: casts cannot be followed by `.await`
153
+ //~^ ERROR: cast cannot be followed by `.await`
154
154
155
155
Box :: pin ( noop ( ) ) : Pin <Box <_>>. await ;
156
- //~^ ERROR: casts cannot be followed by `.await`
156
+ //~^ ERROR: type ascription cannot be followed by `.await`
157
157
}
158
158
159
159
pub async fn noop ( ) { }
@@ -167,5 +167,5 @@ pub fn struct_field() {
167
167
Foo :: default ( ) as Foo . bar ;
168
168
//~^ ERROR: cannot be followed by a field access
169
169
Foo :: default ( ) : Foo . bar ;
170
- //~^ ERROR: cannot be followed by a field access
170
+ //~^ ERROR: type ascription cannot be followed by a field access
171
171
}
0 commit comments