diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/type/ascription | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/type/ascription')
-rw-r--r-- | src/test/ui/type/ascription/issue-34255-1.rs | 15 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-34255-1.stderr | 41 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-47666.fixed | 4 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-47666.rs | 4 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-47666.stderr | 16 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-54516.fixed | 7 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-54516.rs | 7 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-54516.stderr | 12 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-60933.fixed | 5 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-60933.rs | 5 | ||||
-rw-r--r-- | src/test/ui/type/ascription/issue-60933.stderr | 12 |
11 files changed, 128 insertions, 0 deletions
diff --git a/src/test/ui/type/ascription/issue-34255-1.rs b/src/test/ui/type/ascription/issue-34255-1.rs new file mode 100644 index 000000000..44b47cc4e --- /dev/null +++ b/src/test/ui/type/ascription/issue-34255-1.rs @@ -0,0 +1,15 @@ +struct Reactor { + input_cells: Vec<usize>, +} + +impl Reactor { + pub fn new() -> Self { + input_cells: Vec::new() + //~^ ERROR cannot find value `input_cells` in this scope + //~| ERROR parenthesized type parameters may only be used with a `Fn` trait + //~| ERROR missing generics for struct `Vec` + } +} + +// This case isn't currently being handled gracefully, including for completeness. +fn main() {} diff --git a/src/test/ui/type/ascription/issue-34255-1.stderr b/src/test/ui/type/ascription/issue-34255-1.stderr new file mode 100644 index 000000000..6819d14bb --- /dev/null +++ b/src/test/ui/type/ascription/issue-34255-1.stderr @@ -0,0 +1,41 @@ +error[E0425]: cannot find value `input_cells` in this scope + --> $DIR/issue-34255-1.rs:7:9 + | +LL | input_cells: Vec::new() + | ^^^^^^^^^^^ a field by this name exists in `Self` + | +help: you might have meant to write a `struct` literal + | +LL ~ pub fn new() -> Self { SomeStruct { +LL | input_cells: Vec::new() + ... +LL | +LL ~ }} + | + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-34255-1.rs:7:27 + | +LL | input_cells: Vec::new() + | ^^^^^ only `Fn` traits may use parentheses + +error[E0107]: missing generics for struct `Vec` + --> $DIR/issue-34255-1.rs:7:22 + | +LL | input_cells: Vec::new() + | ^^^ expected at least 1 generic argument + | +note: struct defined here, with at least 1 generic parameter: `T` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + | +LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { + | ^^^ - +help: add missing generic argument + | +LL | input_cells: Vec<T>::new() + | ~~~~~~ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0107, E0214, E0425. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/type/ascription/issue-47666.fixed b/src/test/ui/type/ascription/issue-47666.fixed new file mode 100644 index 000000000..c4db74755 --- /dev/null +++ b/src/test/ui/type/ascription/issue-47666.fixed @@ -0,0 +1,4 @@ +// run-rustfix +fn main() { + let _ = Option::Some(vec![0, 1]); //~ ERROR expected type, found +} diff --git a/src/test/ui/type/ascription/issue-47666.rs b/src/test/ui/type/ascription/issue-47666.rs new file mode 100644 index 000000000..c67202e21 --- /dev/null +++ b/src/test/ui/type/ascription/issue-47666.rs @@ -0,0 +1,4 @@ +// run-rustfix +fn main() { + let _ = Option:Some(vec![0, 1]); //~ ERROR expected type, found +} diff --git a/src/test/ui/type/ascription/issue-47666.stderr b/src/test/ui/type/ascription/issue-47666.stderr new file mode 100644 index 000000000..0f90fce3a --- /dev/null +++ b/src/test/ui/type/ascription/issue-47666.stderr @@ -0,0 +1,16 @@ +error: expected type, found `<[_]>::into_vec(#[rustc_box] ::alloc::boxed::Box::new([0, 1]))` + --> $DIR/issue-47666.rs:3:25 + | +LL | let _ = Option:Some(vec![0, 1]); + | - ^^^^^^^^^^ + | | | + | | expected type + | | in this macro invocation + | | this macro call doesn't expand to a type + | help: maybe write a path separator here: `::` + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: this error originates in the macro `$crate::__rust_force_expr` which comes from the expansion of the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/type/ascription/issue-54516.fixed b/src/test/ui/type/ascription/issue-54516.fixed new file mode 100644 index 000000000..f78268894 --- /dev/null +++ b/src/test/ui/type/ascription/issue-54516.fixed @@ -0,0 +1,7 @@ +// run-rustfix +use std::collections::BTreeMap; + +fn main() { + println!("{}", std::mem::size_of::<BTreeMap<u32, u32>>()); + //~^ ERROR type ascription cannot be followed by a function call +} diff --git a/src/test/ui/type/ascription/issue-54516.rs b/src/test/ui/type/ascription/issue-54516.rs new file mode 100644 index 000000000..1f34e6943 --- /dev/null +++ b/src/test/ui/type/ascription/issue-54516.rs @@ -0,0 +1,7 @@ +// run-rustfix +use std::collections::BTreeMap; + +fn main() { + println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>()); + //~^ ERROR type ascription cannot be followed by a function call +} diff --git a/src/test/ui/type/ascription/issue-54516.stderr b/src/test/ui/type/ascription/issue-54516.stderr new file mode 100644 index 000000000..1ab9093e5 --- /dev/null +++ b/src/test/ui/type/ascription/issue-54516.stderr @@ -0,0 +1,12 @@ +error: type ascription cannot be followed by a function call + --> $DIR/issue-54516.rs:5:20 + | +LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>()); + | ^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: maybe write a path separator here: `::` + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + +error: aborting due to previous error + diff --git a/src/test/ui/type/ascription/issue-60933.fixed b/src/test/ui/type/ascription/issue-60933.fixed new file mode 100644 index 000000000..3e8be3875 --- /dev/null +++ b/src/test/ui/type/ascription/issue-60933.fixed @@ -0,0 +1,5 @@ +// run-rustfix +fn main() { + let _: usize = std::mem::size_of::<u32>(); + //~^ ERROR type ascription cannot be followed by a function call +} diff --git a/src/test/ui/type/ascription/issue-60933.rs b/src/test/ui/type/ascription/issue-60933.rs new file mode 100644 index 000000000..2a4ad7bdc --- /dev/null +++ b/src/test/ui/type/ascription/issue-60933.rs @@ -0,0 +1,5 @@ +// run-rustfix +fn main() { + let _: usize = std::mem:size_of::<u32>(); + //~^ ERROR type ascription cannot be followed by a function call +} diff --git a/src/test/ui/type/ascription/issue-60933.stderr b/src/test/ui/type/ascription/issue-60933.stderr new file mode 100644 index 000000000..0b7f8edf6 --- /dev/null +++ b/src/test/ui/type/ascription/issue-60933.stderr @@ -0,0 +1,12 @@ +error: type ascription cannot be followed by a function call + --> $DIR/issue-60933.rs:3:20 + | +LL | let _: usize = std::mem:size_of::<u32>(); + | ^^^^^^^^-^^^^^^^^^^^^^^ + | | + | help: maybe write a path separator here: `::` + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + +error: aborting due to previous error + |