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/invalid-self-argument/bare-fn-start.rs | 6 ++++++ tests/ui/invalid-self-argument/bare-fn-start.stderr | 10 ++++++++++ tests/ui/invalid-self-argument/bare-fn.rs | 5 +++++ tests/ui/invalid-self-argument/bare-fn.stderr | 8 ++++++++ tests/ui/invalid-self-argument/trait-fn.rs | 11 +++++++++++ tests/ui/invalid-self-argument/trait-fn.stderr | 8 ++++++++ 6 files changed, 48 insertions(+) create mode 100644 tests/ui/invalid-self-argument/bare-fn-start.rs create mode 100644 tests/ui/invalid-self-argument/bare-fn-start.stderr create mode 100644 tests/ui/invalid-self-argument/bare-fn.rs create mode 100644 tests/ui/invalid-self-argument/bare-fn.stderr create mode 100644 tests/ui/invalid-self-argument/trait-fn.rs create mode 100644 tests/ui/invalid-self-argument/trait-fn.stderr (limited to 'tests/ui/invalid-self-argument') diff --git a/tests/ui/invalid-self-argument/bare-fn-start.rs b/tests/ui/invalid-self-argument/bare-fn-start.rs new file mode 100644 index 000000000..7c580bc5a --- /dev/null +++ b/tests/ui/invalid-self-argument/bare-fn-start.rs @@ -0,0 +1,6 @@ +fn a(&self) { } +//~^ ERROR `self` parameter is only allowed in associated functions +//~| NOTE not semantically valid as function parameter +//~| NOTE associated functions are those in `impl` or `trait` definitions + +fn main() { } diff --git a/tests/ui/invalid-self-argument/bare-fn-start.stderr b/tests/ui/invalid-self-argument/bare-fn-start.stderr new file mode 100644 index 000000000..37753e61f --- /dev/null +++ b/tests/ui/invalid-self-argument/bare-fn-start.stderr @@ -0,0 +1,10 @@ +error: `self` parameter is only allowed in associated functions + --> $DIR/bare-fn-start.rs:1:6 + | +LL | fn a(&self) { } + | ^^^^^ not semantically valid as function parameter + | + = note: associated functions are those in `impl` or `trait` definitions + +error: aborting due to previous error + diff --git a/tests/ui/invalid-self-argument/bare-fn.rs b/tests/ui/invalid-self-argument/bare-fn.rs new file mode 100644 index 000000000..342bdc31a --- /dev/null +++ b/tests/ui/invalid-self-argument/bare-fn.rs @@ -0,0 +1,5 @@ +fn b(foo: u32, &mut self) { } +//~^ ERROR unexpected `self` parameter in function +//~| NOTE must be the first parameter of an associated function + +fn main() { } diff --git a/tests/ui/invalid-self-argument/bare-fn.stderr b/tests/ui/invalid-self-argument/bare-fn.stderr new file mode 100644 index 000000000..ff2217b5e --- /dev/null +++ b/tests/ui/invalid-self-argument/bare-fn.stderr @@ -0,0 +1,8 @@ +error: unexpected `self` parameter in function + --> $DIR/bare-fn.rs:1:16 + | +LL | fn b(foo: u32, &mut self) { } + | ^^^^^^^^^ must be the first parameter of an associated function + +error: aborting due to previous error + diff --git a/tests/ui/invalid-self-argument/trait-fn.rs b/tests/ui/invalid-self-argument/trait-fn.rs new file mode 100644 index 000000000..5ccea5895 --- /dev/null +++ b/tests/ui/invalid-self-argument/trait-fn.rs @@ -0,0 +1,11 @@ +struct Foo {} + +impl Foo { + fn c(foo: u32, self) {} + //~^ ERROR unexpected `self` parameter in function + //~| NOTE must be the first parameter of an associated function + + fn good(&mut self, foo: u32) {} +} + +fn main() { } diff --git a/tests/ui/invalid-self-argument/trait-fn.stderr b/tests/ui/invalid-self-argument/trait-fn.stderr new file mode 100644 index 000000000..b9887af96 --- /dev/null +++ b/tests/ui/invalid-self-argument/trait-fn.stderr @@ -0,0 +1,8 @@ +error: unexpected `self` parameter in function + --> $DIR/trait-fn.rs:4:20 + | +LL | fn c(foo: u32, self) {} + | ^^^^ must be the first parameter of an associated function + +error: aborting due to previous error + -- cgit v1.2.3