summaryrefslogtreecommitdiffstats
path: root/tests/ui/object-safety
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:42 +0000
commitcec1877e180393eba0f6ddb0cf97bf3a791631c7 (patch)
tree47b4dac2a9dd9a40c30c251b4d4a72d7ccf77e9f /tests/ui/object-safety
parentAdding debian version 1.74.1+dfsg1-1. (diff)
downloadrustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.tar.xz
rustc-cec1877e180393eba0f6ddb0cf97bf3a791631c7.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/object-safety')
-rw-r--r--tests/ui/object-safety/assoc_type_bounds.rs4
-rw-r--r--tests/ui/object-safety/assoc_type_bounds.stderr4
-rw-r--r--tests/ui/object-safety/assoc_type_bounds2.rs4
-rw-r--r--tests/ui/object-safety/assoc_type_bounds2.stderr4
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed10
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs10
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr20
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_sized_others.rs4
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_sized_others.stderr4
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr2
-rw-r--r--tests/ui/object-safety/assoc_type_bounds_sized_used.stderr4
-rw-r--r--tests/ui/object-safety/issue-19538.stderr2
-rw-r--r--tests/ui/object-safety/object-safety-issue-22040.stderr1
-rw-r--r--tests/ui/object-safety/object-safety-no-static.curr.stderr1
-rw-r--r--tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr1
-rw-r--r--tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr8
16 files changed, 64 insertions, 19 deletions
diff --git a/tests/ui/object-safety/assoc_type_bounds.rs b/tests/ui/object-safety/assoc_type_bounds.rs
index 9abf7939c..8634ba626 100644
--- a/tests/ui/object-safety/assoc_type_bounds.rs
+++ b/tests/ui/object-safety/assoc_type_bounds.rs
@@ -7,7 +7,7 @@ trait Foo<T> {
trait Cake {}
impl Cake for () {}
-fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
-fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
+fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified
+fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified
fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds.stderr b/tests/ui/object-safety/assoc_type_bounds.stderr
index a1396dc3a..3d5482625 100644
--- a/tests/ui/object-safety/assoc_type_bounds.stderr
+++ b/tests/ui/object-safety/assoc_type_bounds.stderr
@@ -1,4 +1,4 @@
-error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+error[E0191]: the value of the associated type `Bar` in `Foo` must be specified
--> $DIR/assoc_type_bounds.rs:10:16
|
LL | type Bar
@@ -7,7 +7,7 @@ LL | type Bar
LL | fn foo(_: &dyn Foo<()>) {}
| ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>`
-error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+error[E0191]: the value of the associated type `Bar` in `Foo` must be specified
--> $DIR/assoc_type_bounds.rs:11:16
|
LL | type Bar
diff --git a/tests/ui/object-safety/assoc_type_bounds2.rs b/tests/ui/object-safety/assoc_type_bounds2.rs
index 0112123fd..f7dc2fb88 100644
--- a/tests/ui/object-safety/assoc_type_bounds2.rs
+++ b/tests/ui/object-safety/assoc_type_bounds2.rs
@@ -7,7 +7,7 @@ trait Foo<T> {
trait Cake {}
impl Cake for () {}
-fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
-fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified
+fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified
+fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified
fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds2.stderr b/tests/ui/object-safety/assoc_type_bounds2.stderr
index 7a3c0e02d..815747436 100644
--- a/tests/ui/object-safety/assoc_type_bounds2.stderr
+++ b/tests/ui/object-safety/assoc_type_bounds2.stderr
@@ -1,4 +1,4 @@
-error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+error[E0191]: the value of the associated type `Bar` in `Foo` must be specified
--> $DIR/assoc_type_bounds2.rs:10:16
|
LL | type Bar
@@ -7,7 +7,7 @@ LL | type Bar
LL | fn foo(_: &dyn Foo<()>) {}
| ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>`
-error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified
+error[E0191]: the value of the associated type `Bar` in `Foo` must be specified
--> $DIR/assoc_type_bounds2.rs:11:16
|
LL | type Bar
diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed
new file mode 100644
index 000000000..45c7e07a2
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.fixed
@@ -0,0 +1,10 @@
+// run-rustfix
+trait TraitWithAType {
+ type Item: ?Sized;
+}
+trait Trait {}
+struct A {}
+impl TraitWithAType for A {
+ type Item = dyn Trait; //~ ERROR E0277
+}
+fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs
new file mode 100644
index 000000000..c3e958f49
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.rs
@@ -0,0 +1,10 @@
+// run-rustfix
+trait TraitWithAType {
+ type Item;
+}
+trait Trait {}
+struct A {}
+impl TraitWithAType for A {
+ type Item = dyn Trait; //~ ERROR E0277
+}
+fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr
new file mode 100644
index 000000000..110e71507
--- /dev/null
+++ b/tests/ui/object-safety/assoc_type_bounds_implicit_sized.stderr
@@ -0,0 +1,20 @@
+error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time
+ --> $DIR/assoc_type_bounds_implicit_sized.rs:8:17
+ |
+LL | type Item = dyn Trait;
+ | ^^^^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `(dyn Trait + 'static)`
+note: required by a bound in `TraitWithAType::Item`
+ --> $DIR/assoc_type_bounds_implicit_sized.rs:3:5
+ |
+LL | type Item;
+ | ^^^^^^^^^^ required by this bound in `TraitWithAType::Item`
+help: consider relaxing the implicit `Sized` restriction
+ |
+LL | type Item: ?Sized;
+ | ++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.rs b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs
index 647b72a75..5b07bc92f 100644
--- a/tests/ui/object-safety/assoc_type_bounds_sized_others.rs
+++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs
@@ -10,7 +10,7 @@ trait Foo {
}
fn foo(_: &dyn Foo) {}
-//~^ ERROR the value of the associated type `Bop` (from trait `Foo`) must be specified
+//~^ ERROR the value of the associated type `Bop` in `Foo` must be specified
trait Bar {
type Bop;
@@ -20,6 +20,6 @@ trait Bar {
}
fn bar(_: &dyn Bar) {}
-//~^ ERROR the value of the associated type `Bop` (from trait `Bar`) must be specified
+//~^ ERROR the value of the associated type `Bop` in `Bar` must be specified
fn main() {}
diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr
index e4c44334b..5438faaaf 100644
--- a/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr
+++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr
@@ -1,4 +1,4 @@
-error[E0191]: the value of the associated type `Bop` (from trait `Foo`) must be specified
+error[E0191]: the value of the associated type `Bop` in `Foo` must be specified
--> $DIR/assoc_type_bounds_sized_others.rs:12:16
|
LL | type Bop;
@@ -7,7 +7,7 @@ LL | type Bop;
LL | fn foo(_: &dyn Foo) {}
| ^^^ help: specify the associated type: `Foo<Bop = Type>`
-error[E0191]: the value of the associated type `Bop` (from trait `Bar`) must be specified
+error[E0191]: the value of the associated type `Bop` in `Bar` must be specified
--> $DIR/assoc_type_bounds_sized_others.rs:22:16
|
LL | type Bop;
diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr
index d0a4179fe..659679e44 100644
--- a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr
+++ b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr
@@ -14,6 +14,7 @@ LL | fn foo(_: &dyn Foo<Bar = ()>) {}
| ^^^^^^^^ help: remove this bound
|
= note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`.
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: unnecessary associated type bound for not object safe associated type
--> $DIR/assoc_type_bounds_sized_unnecessary.rs:9:20
@@ -22,6 +23,7 @@ LL | fn foo(_: &dyn Foo<Bar = ()>) {}
| ^^^^^^^^ help: remove this bound
|
= note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`.
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: 3 warnings emitted
diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr
index 224d33fb2..b67a1244e 100644
--- a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr
+++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr
@@ -33,6 +33,10 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized`
LL - fn bop<T: Bop + ?Sized>() {
LL + fn bop<T: Bop>() {
|
+help: consider relaxing the implicit `Sized` restriction
+ |
+LL | type Bar: Default + ?Sized
+ | ++++++++
error: aborting due to 2 previous errors
diff --git a/tests/ui/object-safety/issue-19538.stderr b/tests/ui/object-safety/issue-19538.stderr
index 183245b23..31657501e 100644
--- a/tests/ui/object-safety/issue-19538.stderr
+++ b/tests/ui/object-safety/issue-19538.stderr
@@ -13,6 +13,7 @@ LL | fn foo<T>(&self, val: T);
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
= help: consider moving `foo` to another trait
+ = help: only type `Thing` implements the trait, consider using it directly instead
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-19538.rs:17:30
@@ -29,6 +30,7 @@ LL | fn foo<T>(&self, val: T);
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
= help: consider moving `foo` to another trait
+ = help: only type `Thing` implements the trait, consider using it directly instead
= note: required for the cast from `&mut Thing` to `&mut dyn Bar`
error: aborting due to 2 previous errors
diff --git a/tests/ui/object-safety/object-safety-issue-22040.stderr b/tests/ui/object-safety/object-safety-issue-22040.stderr
index 0262d5362..2e59d88bd 100644
--- a/tests/ui/object-safety/object-safety-issue-22040.stderr
+++ b/tests/ui/object-safety/object-safety-issue-22040.stderr
@@ -11,6 +11,7 @@ LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
+ = help: only type `SExpr<'x>` implements the trait, consider using it directly instead
error: aborting due to previous error
diff --git a/tests/ui/object-safety/object-safety-no-static.curr.stderr b/tests/ui/object-safety/object-safety-no-static.curr.stderr
index 1b025229e..b40470b45 100644
--- a/tests/ui/object-safety/object-safety-no-static.curr.stderr
+++ b/tests/ui/object-safety/object-safety-no-static.curr.stderr
@@ -11,6 +11,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
+ = help: only type `Bar` implements the trait, consider using it directly instead
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) {}
diff --git a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr
index befcef952..1eae9a9b9 100644
--- a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr
+++ b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr
@@ -11,6 +11,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
+ = help: only type `Bar` implements the trait, consider using it directly instead
= note: required for the cast from `Box<Bar>` to `Box<dyn Foo>`
help: consider turning `foo` into a method by giving it a `&self` argument
|
diff --git a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr
index 40429fe75..2d2bb27b8 100644
--- a/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr
+++ b/tests/ui/object-safety/object-safety-supertrait-mentions-GAT.stderr
@@ -1,17 +1,11 @@
error[E0311]: the parameter type `Self` may not live long enough
|
-note: the parameter type `Self` must be valid for the lifetime `'a` as defined here...
- --> $DIR/object-safety-supertrait-mentions-GAT.rs:9:26
- |
-LL | trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> {
- | ^^
- = help: consider adding an explicit lifetime bound `Self: 'a`...
- = note: ...so that the type `Self` will meet its required lifetime bounds...
note: ...that is required by this bound
--> $DIR/object-safety-supertrait-mentions-GAT.rs:6:15
|
LL | Self: 'a;
| ^^
+ = help: consider adding an explicit lifetime bound `Self: 'a`...
error: associated item referring to unboxed trait object for its own trait
--> $DIR/object-safety-supertrait-mentions-GAT.rs:10:20