From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/parser/default.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/ui/parser/default.rs (limited to 'tests/ui/parser/default.rs') diff --git a/tests/ui/parser/default.rs b/tests/ui/parser/default.rs new file mode 100644 index 000000000..52338c1f1 --- /dev/null +++ b/tests/ui/parser/default.rs @@ -0,0 +1,28 @@ +// Test successful and unsuccessful parsing of the `default` contextual keyword + +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +trait Foo { + fn foo() -> T; +} + +impl Foo for u8 { + default fn foo() -> T { + T::default() + } +} + +impl Foo for u16 { + pub default fn foo() -> T { //~ ERROR unnecessary visibility qualifier + T::default() + } +} + +impl Foo for u32 { //~ ERROR not all trait items implemented, missing: `foo` + default pub fn foo() -> T { T::default() } + //~^ ERROR `default` is not followed by an item + //~| ERROR non-item in item list +} + +fn main() {} -- cgit v1.2.3