From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../issues/issue-35813-postfix-after-cast.rs | 171 --------------------- 1 file changed, 171 deletions(-) delete mode 100644 src/test/ui/parser/issues/issue-35813-postfix-after-cast.rs (limited to 'src/test/ui/parser/issues/issue-35813-postfix-after-cast.rs') diff --git a/src/test/ui/parser/issues/issue-35813-postfix-after-cast.rs b/src/test/ui/parser/issues/issue-35813-postfix-after-cast.rs deleted file mode 100644 index 7bd4b3a16..000000000 --- a/src/test/ui/parser/issues/issue-35813-postfix-after-cast.rs +++ /dev/null @@ -1,171 +0,0 @@ -// edition:2018 -#![crate_type = "lib"] -#![feature(type_ascription)] -use std::future::Future; -use std::pin::Pin; - -// This tests the parser for "x as Y[z]". It errors, but we want to give useful -// errors and parse such that further code gives useful errors. -pub fn index_after_as_cast() { - vec![1, 2, 3] as Vec[0]; - //~^ ERROR: cast cannot be followed by indexing - vec![1, 2, 3]: Vec[0]; - //~^ ERROR: type ascription cannot be followed by indexing -} - -pub fn index_after_cast_to_index() { - (&[0]) as &[i32][0]; - //~^ ERROR: cast cannot be followed by indexing - (&[0i32]): &[i32; 1][0]; - //~^ ERROR: type ascription cannot be followed by indexing -} - -pub fn cast_after_cast() { - if 5u64 as i32 as u16 == 0u16 { - - } - if 5u64: u64: u64 == 0u64 { - - } - let _ = 5u64: u64: u64 as u8 as i8 == 9i8; - let _ = 0i32: i32: i32; - let _ = 0 as i32: i32; - let _ = 0i32: i32 as i32; - let _ = 0 as i32 as i32; - let _ = 0i32: i32: i32 as u32 as i32; -} - -pub fn cast_cast_method_call() { - let _ = 0i32: i32: i32.count_ones(); - //~^ ERROR: type ascription cannot be followed by a method call - let _ = 0 as i32: i32.count_ones(); - //~^ ERROR: type ascription cannot be followed by a method call - let _ = 0i32: i32 as i32.count_ones(); - //~^ ERROR: cast cannot be followed by a method call - let _ = 0 as i32 as i32.count_ones(); - //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32: i32 as u32 as i32.count_ones(); - //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32.count_ones(): u32; - //~^ ERROR: type ascription cannot be followed by a method call - let _ = 0 as i32.count_ones(): u32; - //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32.count_ones() as u32; - //~^ ERROR: type ascription cannot be followed by a method call - let _ = 0 as i32.count_ones() as u32; - //~^ ERROR: cast cannot be followed by a method call - let _ = 0i32: i32: i32.count_ones() as u32 as i32; - //~^ ERROR: type ascription cannot be followed by a method call -} - -pub fn multiline_error() { - let _ = 0 - as i32 - .count_ones(); - //~^^^ ERROR: cast cannot be followed by a method call -} - -// this tests that the precedence for `!x as Y.Z` is still what we expect -pub fn precedence() { - let x: i32 = &vec![1, 2, 3] as &Vec[0]; - //~^ ERROR: cast cannot be followed by indexing -} - -pub fn method_calls() { - 0 as i32.max(0); - //~^ ERROR: cast cannot be followed by a method call - 0: i32.max(0); - //~^ ERROR: type ascription cannot be followed by a method call -} - -pub fn complex() { - let _ = format!( - "{} and {}", - if true { 33 } else { 44 } as i32.max(0), - //~^ ERROR: cast cannot be followed by a method call - if true { 33 } else { 44 }: i32.max(0) - //~^ ERROR: type ascription cannot be followed by a method call - ); -} - -pub fn in_condition() { - if 5u64 as i32.max(0) == 0 { - //~^ ERROR: cast cannot be followed by a method call - } - if 5u64: u64.max(0) == 0 { - //~^ ERROR: type ascription cannot be followed by a method call - } -} - -pub fn inside_block() { - let _ = if true { - 5u64 as u32.max(0) == 0 - //~^ ERROR: cast cannot be followed by a method call - } else { false }; - let _ = if true { - 5u64: u64.max(0) == 0 - //~^ ERROR: type ascription cannot be followed by a method call - } else { false }; -} - -static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]); -//~^ ERROR: cast cannot be followed by indexing - -static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); -//~^ ERROR: type ascription cannot be followed by indexing - - -pub fn cast_then_try() -> Result { - Err(0u64) as Result?; - //~^ ERROR: cast cannot be followed by `?` - Err(0u64): Result?; - //~^ ERROR: type ascription cannot be followed by `?` - Ok(1) -} - - -pub fn cast_then_call() { - type F = fn(u8); - // type ascription won't actually do [unique drop fn type] -> fn(u8) casts. - let drop_ptr = drop as fn(u8); - drop as F(); - //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214] - drop_ptr: F(); - //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214] -} - -pub fn cast_to_fn_should_work() { - let drop_ptr = drop as fn(u8); - drop as fn(u8); - drop_ptr: fn(u8); -} - -pub fn parens_after_cast_error() { - let drop_ptr = drop as fn(u8); - drop as fn(u8)(0); - //~^ ERROR: cast cannot be followed by a function call - drop_ptr: fn(u8)(0); - //~^ ERROR: type ascription cannot be followed by a function call -} - -pub async fn cast_then_await() { - Box::pin(noop()) as Pin>>.await; - //~^ ERROR: cast cannot be followed by `.await` - - Box::pin(noop()): Pin>.await; - //~^ ERROR: type ascription cannot be followed by `.await` -} - -pub async fn noop() {} - -#[derive(Default)] -pub struct Foo { - pub bar: u32, -} - -pub fn struct_field() { - Foo::default() as Foo.bar; - //~^ ERROR: cannot be followed by a field access - Foo::default(): Foo.bar; - //~^ ERROR: type ascription cannot be followed by a field access -} -- cgit v1.2.3