dont call type ascription 'cast'
This commit is contained in:
parent
9de7474830
commit
7cdd937bb8
9 changed files with 80 additions and 79 deletions
|
@ -827,10 +827,11 @@ impl<'a> Parser<'a> {
|
||||||
cast_expr: P<Expr>,
|
cast_expr: P<Expr>,
|
||||||
) -> PResult<'a, P<Expr>> {
|
) -> PResult<'a, P<Expr>> {
|
||||||
let span = cast_expr.span;
|
let span = cast_expr.span;
|
||||||
let maybe_ascription_span = if let ExprKind::Type(ascripted_expr, _) = &cast_expr.kind {
|
let (cast_kind, maybe_ascription_span) =
|
||||||
Some(ascripted_expr.span.shrink_to_hi().with_hi(span.hi()))
|
if let ExprKind::Type(ascripted_expr, _) = &cast_expr.kind {
|
||||||
|
("type ascription", Some(ascripted_expr.span.shrink_to_hi().with_hi(span.hi())))
|
||||||
} else {
|
} else {
|
||||||
None
|
("cast", None)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save the memory location of expr before parsing any following postfix operators.
|
// Save the memory location of expr before parsing any following postfix operators.
|
||||||
|
@ -844,7 +845,7 @@ impl<'a> Parser<'a> {
|
||||||
// If the resulting expression is not a cast, or has a different memory location, it is an illegal postfix operator.
|
// If the resulting expression is not a cast, or has a different memory location, it is an illegal postfix operator.
|
||||||
if !matches!(with_postfix.kind, ExprKind::Cast(_, _) | ExprKind::Type(_, _)) || changed {
|
if !matches!(with_postfix.kind, ExprKind::Cast(_, _) | ExprKind::Type(_, _)) || changed {
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"casts cannot be followed by {}",
|
"{cast_kind} cannot be followed by {}",
|
||||||
match with_postfix.kind {
|
match with_postfix.kind {
|
||||||
ExprKind::Index(_, _) => "indexing",
|
ExprKind::Index(_, _) => "indexing",
|
||||||
ExprKind::Try(_) => "`?`",
|
ExprKind::Try(_) => "`?`",
|
||||||
|
|
|
@ -8,16 +8,16 @@ use std::pin::Pin;
|
||||||
// errors and parse such that further code gives useful errors.
|
// errors and parse such that further code gives useful errors.
|
||||||
pub fn index_after_as_cast() {
|
pub fn index_after_as_cast() {
|
||||||
vec![1, 2, 3] as Vec<i32>[0];
|
vec![1, 2, 3] as Vec<i32>[0];
|
||||||
//~^ ERROR: casts cannot be followed by indexing
|
//~^ ERROR: cast cannot be followed by indexing
|
||||||
vec![1, 2, 3]: Vec<i32>[0];
|
vec![1, 2, 3]: Vec<i32>[0];
|
||||||
//~^ ERROR: casts cannot be followed by indexing
|
//~^ ERROR: type ascription cannot be followed by indexing
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index_after_cast_to_index() {
|
pub fn index_after_cast_to_index() {
|
||||||
(&[0]) as &[i32][0];
|
(&[0]) as &[i32][0];
|
||||||
//~^ ERROR: casts cannot be followed by indexing
|
//~^ ERROR: cast cannot be followed by indexing
|
||||||
(&[0i32]): &[i32; 1][0];
|
(&[0i32]): &[i32; 1][0];
|
||||||
//~^ ERROR: casts cannot be followed by indexing
|
//~^ ERROR: type ascription cannot be followed by indexing
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cast_after_cast() {
|
pub fn cast_after_cast() {
|
||||||
|
@ -37,89 +37,89 @@ pub fn cast_after_cast() {
|
||||||
|
|
||||||
pub fn cast_cast_method_call() {
|
pub fn cast_cast_method_call() {
|
||||||
let _ = 0i32: i32: i32.count_ones();
|
let _ = 0i32: i32: i32.count_ones();
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
let _ = 0 as i32: i32.count_ones();
|
let _ = 0 as i32: i32.count_ones();
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
let _ = 0i32: i32 as i32.count_ones();
|
let _ = 0i32: i32 as i32.count_ones();
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
let _ = 0 as i32 as i32.count_ones();
|
let _ = 0 as i32 as i32.count_ones();
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
let _ = 0i32: i32: i32 as u32 as i32.count_ones();
|
let _ = 0i32: i32: i32 as u32 as i32.count_ones();
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
let _ = 0i32: i32.count_ones(): u32;
|
let _ = 0i32: i32.count_ones(): u32;
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
let _ = 0 as i32.count_ones(): u32;
|
let _ = 0 as i32.count_ones(): u32;
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
let _ = 0i32: i32.count_ones() as u32;
|
let _ = 0i32: i32.count_ones() as u32;
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
let _ = 0 as i32.count_ones() as u32;
|
let _ = 0 as i32.count_ones() as u32;
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
let _ = 0i32: i32: i32.count_ones() as u32 as i32;
|
let _ = 0i32: i32: i32.count_ones() as u32 as i32;
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multiline_error() {
|
pub fn multiline_error() {
|
||||||
let _ = 0
|
let _ = 0
|
||||||
as i32
|
as i32
|
||||||
.count_ones();
|
.count_ones();
|
||||||
//~^^^ ERROR: casts cannot be followed by a method call
|
//~^^^ ERROR: cast cannot be followed by a method call
|
||||||
}
|
}
|
||||||
|
|
||||||
// this tests that the precedence for `!x as Y.Z` is still what we expect
|
// this tests that the precedence for `!x as Y.Z` is still what we expect
|
||||||
pub fn precedence() {
|
pub fn precedence() {
|
||||||
let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
|
let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
|
||||||
//~^ ERROR: casts cannot be followed by indexing
|
//~^ ERROR: cast cannot be followed by indexing
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn method_calls() {
|
pub fn method_calls() {
|
||||||
0 as i32.max(0);
|
0 as i32.max(0);
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
0: i32.max(0);
|
0: i32.max(0);
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn complex() {
|
pub fn complex() {
|
||||||
let _ = format!(
|
let _ = format!(
|
||||||
"{} and {}",
|
"{} and {}",
|
||||||
if true { 33 } else { 44 } as i32.max(0),
|
if true { 33 } else { 44 } as i32.max(0),
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
if true { 33 } else { 44 }: i32.max(0)
|
if true { 33 } else { 44 }: i32.max(0)
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn in_condition() {
|
pub fn in_condition() {
|
||||||
if 5u64 as i32.max(0) == 0 {
|
if 5u64 as i32.max(0) == 0 {
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
}
|
}
|
||||||
if 5u64: u64.max(0) == 0 {
|
if 5u64: u64.max(0) == 0 {
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inside_block() {
|
pub fn inside_block() {
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
5u64 as u32.max(0) == 0
|
5u64 as u32.max(0) == 0
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: cast cannot be followed by a method call
|
||||||
} else { false };
|
} else { false };
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
5u64: u64.max(0) == 0
|
5u64: u64.max(0) == 0
|
||||||
//~^ ERROR: casts cannot be followed by a method call
|
//~^ ERROR: type ascription cannot be followed by a method call
|
||||||
} else { false };
|
} else { false };
|
||||||
}
|
}
|
||||||
|
|
||||||
static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
|
static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
|
||||||
//~^ ERROR: casts cannot be followed by indexing
|
//~^ ERROR: cast cannot be followed by indexing
|
||||||
|
|
||||||
static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
|
static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
|
||||||
//~^ ERROR: casts cannot be followed by indexing
|
//~^ ERROR: type ascription cannot be followed by indexing
|
||||||
|
|
||||||
|
|
||||||
pub fn cast_then_try() -> Result<u64,u64> {
|
pub fn cast_then_try() -> Result<u64,u64> {
|
||||||
Err(0u64) as Result<u64,u64>?;
|
Err(0u64) as Result<u64,u64>?;
|
||||||
//~^ ERROR: casts cannot be followed by `?`
|
//~^ ERROR: cast cannot be followed by `?`
|
||||||
Err(0u64): Result<u64,u64>?;
|
Err(0u64): Result<u64,u64>?;
|
||||||
//~^ ERROR: casts cannot be followed by `?`
|
//~^ ERROR: type ascription cannot be followed by `?`
|
||||||
Ok(1)
|
Ok(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,17 +143,17 @@ pub fn cast_to_fn_should_work() {
|
||||||
pub fn parens_after_cast_error() {
|
pub fn parens_after_cast_error() {
|
||||||
let drop_ptr = drop as fn(u8);
|
let drop_ptr = drop as fn(u8);
|
||||||
drop as fn(u8)(0);
|
drop as fn(u8)(0);
|
||||||
//~^ ERROR: casts cannot be followed by a function call
|
//~^ ERROR: cast cannot be followed by a function call
|
||||||
drop_ptr: fn(u8)(0);
|
drop_ptr: fn(u8)(0);
|
||||||
//~^ ERROR: casts cannot be followed by a function call
|
//~^ ERROR: type ascription cannot be followed by a function call
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cast_then_await() {
|
pub async fn cast_then_await() {
|
||||||
Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
|
Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
|
||||||
//~^ ERROR: casts cannot be followed by `.await`
|
//~^ ERROR: cast cannot be followed by `.await`
|
||||||
|
|
||||||
Box::pin(noop()): Pin<Box<_>>.await;
|
Box::pin(noop()): Pin<Box<_>>.await;
|
||||||
//~^ ERROR: casts cannot be followed by `.await`
|
//~^ ERROR: type ascription cannot be followed by `.await`
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn noop() {}
|
pub async fn noop() {}
|
||||||
|
@ -167,5 +167,5 @@ pub fn struct_field() {
|
||||||
Foo::default() as Foo.bar;
|
Foo::default() as Foo.bar;
|
||||||
//~^ ERROR: cannot be followed by a field access
|
//~^ ERROR: cannot be followed by a field access
|
||||||
Foo::default(): Foo.bar;
|
Foo::default(): Foo.bar;
|
||||||
//~^ ERROR: cannot be followed by a field access
|
//~^ ERROR: type ascription cannot be followed by a field access
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: casts cannot be followed by indexing
|
error: cast cannot be followed by indexing
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:10:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:10:5
|
||||||
|
|
|
|
||||||
LL | vec![1, 2, 3] as Vec<i32>[0];
|
LL | vec![1, 2, 3] as Vec<i32>[0];
|
||||||
|
@ -9,7 +9,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (vec![1, 2, 3] as Vec<i32>)[0];
|
LL | (vec![1, 2, 3] as Vec<i32>)[0];
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by indexing
|
error: type ascription cannot be followed by indexing
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:12:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:12:5
|
||||||
|
|
|
|
||||||
LL | vec![1, 2, 3]: Vec<i32>[0];
|
LL | vec![1, 2, 3]: Vec<i32>[0];
|
||||||
|
@ -25,7 +25,7 @@ LL - vec![1, 2, 3]: Vec<i32>[0];
|
||||||
LL + vec![1, 2, 3][0];
|
LL + vec![1, 2, 3][0];
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by indexing
|
error: cast cannot be followed by indexing
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:17:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:17:5
|
||||||
|
|
|
|
||||||
LL | (&[0]) as &[i32][0];
|
LL | (&[0]) as &[i32][0];
|
||||||
|
@ -36,7 +36,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | ((&[0]) as &[i32])[0];
|
LL | ((&[0]) as &[i32])[0];
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by indexing
|
error: type ascription cannot be followed by indexing
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:19:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:19:5
|
||||||
|
|
|
|
||||||
LL | (&[0i32]): &[i32; 1][0];
|
LL | (&[0i32]): &[i32; 1][0];
|
||||||
|
@ -52,7 +52,7 @@ LL - (&[0i32]): &[i32; 1][0];
|
||||||
LL + (&[0i32])[0];
|
LL + (&[0i32])[0];
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:39:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:39:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0i32: i32: i32.count_ones();
|
LL | let _ = 0i32: i32: i32.count_ones();
|
||||||
|
@ -68,7 +68,7 @@ LL - let _ = 0i32: i32: i32.count_ones();
|
||||||
LL + let _ = 0i32: i32.count_ones();
|
LL + let _ = 0i32: i32.count_ones();
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:41:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:41:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0 as i32: i32.count_ones();
|
LL | let _ = 0 as i32: i32.count_ones();
|
||||||
|
@ -84,7 +84,7 @@ LL - let _ = 0 as i32: i32.count_ones();
|
||||||
LL + let _ = 0 as i32.count_ones();
|
LL + let _ = 0 as i32.count_ones();
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:43:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:43:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0i32: i32 as i32.count_ones();
|
LL | let _ = 0i32: i32 as i32.count_ones();
|
||||||
|
@ -95,7 +95,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | let _ = (0i32: i32 as i32).count_ones();
|
LL | let _ = (0i32: i32 as i32).count_ones();
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:45:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:45:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0 as i32 as i32.count_ones();
|
LL | let _ = 0 as i32 as i32.count_ones();
|
||||||
|
@ -106,7 +106,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | let _ = (0 as i32 as i32).count_ones();
|
LL | let _ = (0 as i32 as i32).count_ones();
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:47:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:47:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones();
|
LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones();
|
||||||
|
@ -117,7 +117,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | let _ = (0i32: i32: i32 as u32 as i32).count_ones();
|
LL | let _ = (0i32: i32: i32 as u32 as i32).count_ones();
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:49:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:49:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0i32: i32.count_ones(): u32;
|
LL | let _ = 0i32: i32.count_ones(): u32;
|
||||||
|
@ -133,7 +133,7 @@ LL - let _ = 0i32: i32.count_ones(): u32;
|
||||||
LL + let _ = 0i32.count_ones(): u32;
|
LL + let _ = 0i32.count_ones(): u32;
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:51:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:51:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0 as i32.count_ones(): u32;
|
LL | let _ = 0 as i32.count_ones(): u32;
|
||||||
|
@ -144,7 +144,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | let _ = (0 as i32).count_ones(): u32;
|
LL | let _ = (0 as i32).count_ones(): u32;
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:53:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:53:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0i32: i32.count_ones() as u32;
|
LL | let _ = 0i32: i32.count_ones() as u32;
|
||||||
|
@ -160,7 +160,7 @@ LL - let _ = 0i32: i32.count_ones() as u32;
|
||||||
LL + let _ = 0i32.count_ones() as u32;
|
LL + let _ = 0i32.count_ones() as u32;
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:55:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:55:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0 as i32.count_ones() as u32;
|
LL | let _ = 0 as i32.count_ones() as u32;
|
||||||
|
@ -171,7 +171,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | let _ = (0 as i32).count_ones() as u32;
|
LL | let _ = (0 as i32).count_ones() as u32;
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:57:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:57:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32;
|
LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32;
|
||||||
|
@ -187,7 +187,7 @@ LL - let _ = 0i32: i32: i32.count_ones() as u32 as i32;
|
||||||
LL + let _ = 0i32: i32.count_ones() as u32 as i32;
|
LL + let _ = 0i32: i32.count_ones() as u32 as i32;
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:62:13
|
--> $DIR/issue-35813-postfix-after-cast.rs:62:13
|
||||||
|
|
|
|
||||||
LL | let _ = 0
|
LL | let _ = 0
|
||||||
|
@ -201,7 +201,7 @@ LL ~ let _ = (0
|
||||||
LL ~ as i32)
|
LL ~ as i32)
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by indexing
|
error: cast cannot be followed by indexing
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:70:18
|
--> $DIR/issue-35813-postfix-after-cast.rs:70:18
|
||||||
|
|
|
|
||||||
LL | let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
|
LL | let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
|
||||||
|
@ -212,7 +212,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | let x: i32 = (&vec![1, 2, 3] as &Vec<i32>)[0];
|
LL | let x: i32 = (&vec![1, 2, 3] as &Vec<i32>)[0];
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:75:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:75:5
|
||||||
|
|
|
|
||||||
LL | 0 as i32.max(0);
|
LL | 0 as i32.max(0);
|
||||||
|
@ -223,7 +223,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (0 as i32).max(0);
|
LL | (0 as i32).max(0);
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:77:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:77:5
|
||||||
|
|
|
|
||||||
LL | 0: i32.max(0);
|
LL | 0: i32.max(0);
|
||||||
|
@ -239,7 +239,7 @@ LL - 0: i32.max(0);
|
||||||
LL + 0.max(0);
|
LL + 0.max(0);
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:92:8
|
--> $DIR/issue-35813-postfix-after-cast.rs:92:8
|
||||||
|
|
|
|
||||||
LL | if 5u64 as i32.max(0) == 0 {
|
LL | if 5u64 as i32.max(0) == 0 {
|
||||||
|
@ -250,7 +250,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | if (5u64 as i32).max(0) == 0 {
|
LL | if (5u64 as i32).max(0) == 0 {
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:95:8
|
--> $DIR/issue-35813-postfix-after-cast.rs:95:8
|
||||||
|
|
|
|
||||||
LL | if 5u64: u64.max(0) == 0 {
|
LL | if 5u64: u64.max(0) == 0 {
|
||||||
|
@ -266,7 +266,7 @@ LL - if 5u64: u64.max(0) == 0 {
|
||||||
LL + if 5u64.max(0) == 0 {
|
LL + if 5u64.max(0) == 0 {
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:102:9
|
--> $DIR/issue-35813-postfix-after-cast.rs:102:9
|
||||||
|
|
|
|
||||||
LL | 5u64 as u32.max(0) == 0
|
LL | 5u64 as u32.max(0) == 0
|
||||||
|
@ -277,7 +277,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (5u64 as u32).max(0) == 0
|
LL | (5u64 as u32).max(0) == 0
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:106:9
|
--> $DIR/issue-35813-postfix-after-cast.rs:106:9
|
||||||
|
|
|
|
||||||
LL | 5u64: u64.max(0) == 0
|
LL | 5u64: u64.max(0) == 0
|
||||||
|
@ -293,7 +293,7 @@ LL - 5u64: u64.max(0) == 0
|
||||||
LL + 5u64.max(0) == 0
|
LL + 5u64.max(0) == 0
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by indexing
|
error: cast cannot be followed by indexing
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:111:24
|
--> $DIR/issue-35813-postfix-after-cast.rs:111:24
|
||||||
|
|
|
|
||||||
LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
|
LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
|
||||||
|
@ -304,7 +304,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]);
|
LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]);
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by indexing
|
error: type ascription cannot be followed by indexing
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:114:25
|
--> $DIR/issue-35813-postfix-after-cast.rs:114:25
|
||||||
|
|
|
|
||||||
LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
|
LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
|
||||||
|
@ -320,7 +320,7 @@ LL - static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
|
||||||
LL + static bar2: &[i32] = &(&[1i32,2,3][0..1]);
|
LL + static bar2: &[i32] = &(&[1i32,2,3][0..1]);
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by `?`
|
error: cast cannot be followed by `?`
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:119:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:119:5
|
||||||
|
|
|
|
||||||
LL | Err(0u64) as Result<u64,u64>?;
|
LL | Err(0u64) as Result<u64,u64>?;
|
||||||
|
@ -331,7 +331,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (Err(0u64) as Result<u64,u64>)?;
|
LL | (Err(0u64) as Result<u64,u64>)?;
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by `?`
|
error: type ascription cannot be followed by `?`
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:121:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:121:5
|
||||||
|
|
|
|
||||||
LL | Err(0u64): Result<u64,u64>?;
|
LL | Err(0u64): Result<u64,u64>?;
|
||||||
|
@ -347,7 +347,7 @@ LL - Err(0u64): Result<u64,u64>?;
|
||||||
LL + Err(0u64)?;
|
LL + Err(0u64)?;
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a function call
|
error: cast cannot be followed by a function call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:145:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:145:5
|
||||||
|
|
|
|
||||||
LL | drop as fn(u8)(0);
|
LL | drop as fn(u8)(0);
|
||||||
|
@ -358,7 +358,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (drop as fn(u8))(0);
|
LL | (drop as fn(u8))(0);
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a function call
|
error: type ascription cannot be followed by a function call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:147:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:147:5
|
||||||
|
|
|
|
||||||
LL | drop_ptr: fn(u8)(0);
|
LL | drop_ptr: fn(u8)(0);
|
||||||
|
@ -374,7 +374,7 @@ LL - drop_ptr: fn(u8)(0);
|
||||||
LL + drop_ptr(0);
|
LL + drop_ptr(0);
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by `.await`
|
error: cast cannot be followed by `.await`
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:152:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:152:5
|
||||||
|
|
|
|
||||||
LL | Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
|
LL | Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
|
||||||
|
@ -385,7 +385,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await;
|
LL | (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await;
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by `.await`
|
error: type ascription cannot be followed by `.await`
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:155:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:155:5
|
||||||
|
|
|
|
||||||
LL | Box::pin(noop()): Pin<Box<_>>.await;
|
LL | Box::pin(noop()): Pin<Box<_>>.await;
|
||||||
|
@ -401,7 +401,7 @@ LL - Box::pin(noop()): Pin<Box<_>>.await;
|
||||||
LL + Box::pin(noop()).await;
|
LL + Box::pin(noop()).await;
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a field access
|
error: cast cannot be followed by a field access
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:167:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:167:5
|
||||||
|
|
|
|
||||||
LL | Foo::default() as Foo.bar;
|
LL | Foo::default() as Foo.bar;
|
||||||
|
@ -412,7 +412,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (Foo::default() as Foo).bar;
|
LL | (Foo::default() as Foo).bar;
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a field access
|
error: type ascription cannot be followed by a field access
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:169:5
|
--> $DIR/issue-35813-postfix-after-cast.rs:169:5
|
||||||
|
|
|
|
||||||
LL | Foo::default(): Foo.bar;
|
LL | Foo::default(): Foo.bar;
|
||||||
|
@ -428,7 +428,7 @@ LL - Foo::default(): Foo.bar;
|
||||||
LL + Foo::default().bar;
|
LL + Foo::default().bar;
|
||||||
|
|
|
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: cast cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:84:9
|
--> $DIR/issue-35813-postfix-after-cast.rs:84:9
|
||||||
|
|
|
|
||||||
LL | if true { 33 } else { 44 } as i32.max(0),
|
LL | if true { 33 } else { 44 } as i32.max(0),
|
||||||
|
@ -439,7 +439,7 @@ help: try surrounding the expression in parentheses
|
||||||
LL | (if true { 33 } else { 44 } as i32).max(0),
|
LL | (if true { 33 } else { 44 } as i32).max(0),
|
||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: casts cannot be followed by a method call
|
error: type ascription cannot be followed by a method call
|
||||||
--> $DIR/issue-35813-postfix-after-cast.rs:86:9
|
--> $DIR/issue-35813-postfix-after-cast.rs:86:9
|
||||||
|
|
|
|
||||||
LL | if true { 33 } else { 44 }: i32.max(0)
|
LL | if true { 33 } else { 44 }: i32.max(0)
|
||||||
|
|
|
@ -3,5 +3,5 @@ use std::collections::BTreeMap;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("{}", std::mem::size_of::<BTreeMap<u32, u32>>());
|
println!("{}", std::mem::size_of::<BTreeMap<u32, u32>>());
|
||||||
//~^ ERROR casts cannot be followed by a function call
|
//~^ ERROR type ascription cannot be followed by a function call
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,5 @@ use std::collections::BTreeMap;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
|
println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
|
||||||
//~^ ERROR casts cannot be followed by a function call
|
//~^ ERROR type ascription cannot be followed by a function call
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: casts cannot be followed by a function call
|
error: type ascription cannot be followed by a function call
|
||||||
--> $DIR/issue-54516.rs:5:20
|
--> $DIR/issue-54516.rs:5:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
|
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
fn main() {
|
fn main() {
|
||||||
let _: usize = std::mem::size_of::<u32>();
|
let _: usize = std::mem::size_of::<u32>();
|
||||||
//~^ ERROR casts cannot be followed by a function call
|
//~^ ERROR type ascription cannot be followed by a function call
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
fn main() {
|
fn main() {
|
||||||
let _: usize = std::mem:size_of::<u32>();
|
let _: usize = std::mem:size_of::<u32>();
|
||||||
//~^ ERROR casts cannot be followed by a function call
|
//~^ ERROR type ascription cannot be followed by a function call
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: casts cannot be followed by a function call
|
error: type ascription cannot be followed by a function call
|
||||||
--> $DIR/issue-60933.rs:3:20
|
--> $DIR/issue-60933.rs:3:20
|
||||||
|
|
|
|
||||||
LL | let _: usize = std::mem:size_of::<u32>();
|
LL | let _: usize = std::mem:size_of::<u32>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue