summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr')
-rw-r--r--tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr b/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr
new file mode 100644
index 000000000..55047b426
--- /dev/null
+++ b/tests/ui/suggestions/object-unsafe-trait-should-use-self.stderr
@@ -0,0 +1,65 @@
+error: associated item referring to unboxed trait object for its own trait
+ --> $DIR/object-unsafe-trait-should-use-self.rs:3:13
+ |
+LL | trait A: Sized {
+ | - in this trait
+LL | fn f(a: A) -> A;
+ | ^ ^
+ |
+help: you might have meant to use `Self` to refer to the implementing type
+ |
+LL | fn f(a: Self) -> Self;
+ | ~~~~ ~~~~
+
+error[E0038]: the trait `A` cannot be made into an object
+ --> $DIR/object-unsafe-trait-should-use-self.rs:3:13
+ |
+LL | fn f(a: A) -> A;
+ | ^ `A` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/object-unsafe-trait-should-use-self.rs:2:10
+ |
+LL | trait A: Sized {
+ | - ^^^^^ ...because it requires `Self: Sized`
+ | |
+ | this trait cannot be made into an object...
+
+error: associated item referring to unboxed trait object for its own trait
+ --> $DIR/object-unsafe-trait-should-use-self.rs:8:13
+ |
+LL | trait B {
+ | - in this trait
+LL | fn f(a: B) -> B;
+ | ^ ^
+ |
+help: you might have meant to use `Self` to refer to the implementing type
+ |
+LL | fn f(a: Self) -> Self;
+ | ~~~~ ~~~~
+
+error[E0038]: the trait `B` cannot be made into an object
+ --> $DIR/object-unsafe-trait-should-use-self.rs:8:13
+ |
+LL | fn f(a: B) -> B;
+ | ^ `B` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/object-unsafe-trait-should-use-self.rs:8:8
+ |
+LL | trait B {
+ | - this trait cannot be made into an object...
+LL | fn f(a: B) -> B;
+ | ^ ...because associated function `f` has no `self` parameter
+help: consider turning `f` into a method by giving it a `&self` argument
+ |
+LL | fn f(&self, a: B) -> B;
+ | ++++++
+help: alternatively, consider constraining `f` so it does not apply to trait objects
+ |
+LL | fn f(a: B) -> B where Self: Sized;
+ | +++++++++++++++++
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0038`.