diff options
| author | Michael Goulet <michael@errs.io> | 2023-08-08 20:13:57 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-08-28 01:05:34 +0000 |
| commit | f8e0dcbf5627d3e1a70a4d1d6bd1101d5b24f1e3 (patch) | |
| tree | 65c2cd2de13565424ae50713a79652957c2ed007 /tests/ui/impl-trait | |
| parent | 690bcc6619aad74d8c32a52c104d4f79fa2f6bf4 (diff) | |
| download | rust-f8e0dcbf5627d3e1a70a4d1d6bd1101d5b24f1e3.tar.gz rust-f8e0dcbf5627d3e1a70a4d1d6bd1101d5b24f1e3.zip | |
Better error message for object type with GAT
Diffstat (limited to 'tests/ui/impl-trait')
| -rw-r--r-- | tests/ui/impl-trait/in-trait/object-safety.rs | 2 | ||||
| -rw-r--r-- | tests/ui/impl-trait/in-trait/object-safety.stderr | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs index 6e02934363d..9a231e59b09 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.rs +++ b/tests/ui/impl-trait/in-trait/object-safety.rs @@ -19,5 +19,5 @@ fn main() { //~| ERROR the trait `Foo` cannot be made into an object let s = i.baz(); //~^ ERROR the trait `Foo` cannot be made into an object - //~| ERROR the trait bound `dyn Foo: Foo` + //~| ERROR the trait `Foo` cannot be made into an object } diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr index 1eb063a5fc2..0170dc5d0fc 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.stderr @@ -13,13 +13,20 @@ LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait -error[E0277]: the trait bound `dyn Foo: Foo` is not satisfied +error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety.rs:20:15 | LL | let s = i.baz(); - | ^^^ the trait `Foo` is not implemented for `dyn Foo` + | ^^^ `Foo` cannot be made into an object | - = help: the trait `Foo` is implemented for `u32` +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-safety.rs:7:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety.rs:20:13 @@ -54,5 +61,4 @@ LL | fn baz(&self) -> impl Debug; error: aborting due to 4 previous errors -Some errors have detailed explanations: E0038, E0277. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. |
