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/typeck/typeck_type_placeholder_item_help.rs | |
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/typeck/typeck_type_placeholder_item_help.rs')
-rw-r--r-- | src/test/ui/typeck/typeck_type_placeholder_item_help.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/typeck/typeck_type_placeholder_item_help.rs b/src/test/ui/typeck/typeck_type_placeholder_item_help.rs new file mode 100644 index 000000000..c459d8c3c --- /dev/null +++ b/src/test/ui/typeck/typeck_type_placeholder_item_help.rs @@ -0,0 +1,33 @@ +// This test checks that it proper item type will be suggested when +// using the `_` type placeholder. + +fn test1() -> _ { Some(42) } +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + +const TEST2: _ = 42u32; +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + +const TEST3: _ = Some(42); +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + +const TEST4: fn() -> _ = 42; +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +//~| ERROR the placeholder `_` is not allowed within types on item signatures for constant items + +trait Test5 { + const TEST5: _ = 42; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +} + +struct Test6; + +impl Test6 { + const TEST6: _ = 13; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +} + +pub fn main() { + let _: Option<usize> = test1(); + let _: f64 = test1(); + let _: Option<i32> = test1(); +} |