summaryrefslogtreecommitdiffstats
path: root/tests/ui/wf
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ui/wf/hir-wf-check-erase-regions.rs1
-rw-r--r--tests/ui/wf/hir-wf-check-erase-regions.stderr16
-rw-r--r--tests/ui/wf/issue-110157.rs1
-rw-r--r--tests/ui/wf/issue-110157.stderr25
-rw-r--r--tests/ui/wf/unnormalized-projection-guides-inference.rs24
-rw-r--r--tests/ui/wf/wf-const-type.rs1
-rw-r--r--tests/ui/wf/wf-const-type.stderr20
-rw-r--r--tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr3
-rw-r--r--tests/ui/wf/wf-convert-unsafe-trait-obj.stderr3
-rw-r--r--tests/ui/wf/wf-fn-where-clause.stderr18
-rw-r--r--tests/ui/wf/wf-impl-associated-type-region.stderr4
-rw-r--r--tests/ui/wf/wf-in-fn-type-static.stderr14
-rw-r--r--tests/ui/wf/wf-in-obj-type-static.stderr7
-rw-r--r--tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr8
-rw-r--r--tests/ui/wf/wf-static-type.rs1
-rw-r--r--tests/ui/wf/wf-static-type.stderr20
-rw-r--r--tests/ui/wf/wf-trait-associated-type-region.stderr11
-rw-r--r--tests/ui/wf/wf-unsafe-trait-obj-match.stderr10
18 files changed, 157 insertions, 30 deletions
diff --git a/tests/ui/wf/hir-wf-check-erase-regions.rs b/tests/ui/wf/hir-wf-check-erase-regions.rs
index 3855f2c35..2820d5f6d 100644
--- a/tests/ui/wf/hir-wf-check-erase-regions.rs
+++ b/tests/ui/wf/hir-wf-check-erase-regions.rs
@@ -5,6 +5,7 @@ pub struct Table<T, const N: usize>([Option<T>; N]);
impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> {
type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; //~ ERROR `&'a T` is not an iterator
+ //~^ ERROR `&'a T` is not an iterator
type Item = &'a T;
fn into_iter(self) -> Self::IntoIter { //~ ERROR `&'a T` is not an iterator
diff --git a/tests/ui/wf/hir-wf-check-erase-regions.stderr b/tests/ui/wf/hir-wf-check-erase-regions.stderr
index 2843983c7..eb0a8f8f6 100644
--- a/tests/ui/wf/hir-wf-check-erase-regions.stderr
+++ b/tests/ui/wf/hir-wf-check-erase-regions.stderr
@@ -11,7 +11,7 @@ note: required by a bound in `Flatten`
--> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL
error[E0277]: `&'a T` is not an iterator
- --> $DIR/hir-wf-check-erase-regions.rs:10:27
+ --> $DIR/hir-wf-check-erase-regions.rs:11:27
|
LL | fn into_iter(self) -> Self::IntoIter {
| ^^^^^^^^^^^^^^ `&'a T` is not an iterator
@@ -22,6 +22,18 @@ LL | fn into_iter(self) -> Self::IntoIter {
note: required by a bound in `Flatten`
--> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL
-error: aborting due to 2 previous errors
+error[E0277]: `&'a T` is not an iterator
+ --> $DIR/hir-wf-check-erase-regions.rs:7:21
+ |
+LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'a T` is not an iterator
+ |
+ = help: the trait `Iterator` is not implemented for `&'a T`
+ = help: the trait `Iterator` is implemented for `&mut I`
+ = note: required for `Flatten<std::slice::Iter<'a, T>>` to implement `Iterator`
+note: required by a bound in `std::iter::IntoIterator::IntoIter`
+ --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
+
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/wf/issue-110157.rs b/tests/ui/wf/issue-110157.rs
index 43a8ce72f..07e2c5d58 100644
--- a/tests/ui/wf/issue-110157.rs
+++ b/tests/ui/wf/issue-110157.rs
@@ -2,6 +2,7 @@ struct NeedsDropTypes<'tcx, F>(std::marker::PhantomData<&'tcx F>);
impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
//~^ ERROR type annotations needed
+//~| ERROR not all trait items implemented
where
F: Fn(&Missing) -> Result<I, ()>,
//~^ ERROR cannot find type `Missing` in this scope
diff --git a/tests/ui/wf/issue-110157.stderr b/tests/ui/wf/issue-110157.stderr
index 91d801e94..16bd34a6d 100644
--- a/tests/ui/wf/issue-110157.stderr
+++ b/tests/ui/wf/issue-110157.stderr
@@ -1,11 +1,11 @@
error[E0412]: cannot find type `Missing` in this scope
- --> $DIR/issue-110157.rs:6:12
+ --> $DIR/issue-110157.rs:7:12
|
LL | F: Fn(&Missing) -> Result<I, ()>,
| ^^^^^^^ not found in this scope
error[E0412]: cannot find type `Missing` in this scope
- --> $DIR/issue-110157.rs:8:24
+ --> $DIR/issue-110157.rs:9:24
|
LL | I: Iterator<Item = Missing>,
| ^^^^^^^ not found in this scope
@@ -26,7 +26,22 @@ LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
LL | I: Iterator<Item = Missing>,
| ------------------------ unsatisfied trait bound introduced here
-error: aborting due to 3 previous errors
+error[E0046]: not all trait items implemented, missing: `Item`, `next`
+ --> $DIR/issue-110157.rs:3:1
+ |
+LL | / impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
+LL | |
+LL | |
+LL | | where
+LL | | F: Fn(&Missing) -> Result<I, ()>,
+LL | |
+LL | | I: Iterator<Item = Missing>,
+ | |________________________________^ missing `Item`, `next` in implementation
+ |
+ = help: implement the missing item: `type Item = /* Type */;`
+ = help: implement the missing item: `fn next(&mut self) -> Option<<Self as Iterator>::Item> { todo!() }`
+
+error: aborting due to 4 previous errors
-Some errors have detailed explanations: E0283, E0412.
-For more information about an error, try `rustc --explain E0283`.
+Some errors have detailed explanations: E0046, E0283, E0412.
+For more information about an error, try `rustc --explain E0046`.
diff --git a/tests/ui/wf/unnormalized-projection-guides-inference.rs b/tests/ui/wf/unnormalized-projection-guides-inference.rs
new file mode 100644
index 000000000..ca2d6c2e8
--- /dev/null
+++ b/tests/ui/wf/unnormalized-projection-guides-inference.rs
@@ -0,0 +1,24 @@
+// The WF requirements of the *unnormalized* form of type annotations
+// can guide inference.
+// check-pass
+
+pub trait EqualTo {
+ type Ty;
+}
+impl<X> EqualTo for X {
+ type Ty = X;
+}
+
+trait MyTrait<U: EqualTo<Ty = Self>> {
+ type Out;
+}
+impl<T, U: EqualTo<Ty = T>> MyTrait<U> for T {
+ type Out = ();
+}
+
+fn main() {
+ let _: <_ as MyTrait<u8>>::Out;
+ // We shoud be able to infer a value for the inference variable above.
+ // The WF of the unnormalized projection requires `u8: EqualTo<Ty = _>`,
+ // which is sufficient to guide inference.
+}
diff --git a/tests/ui/wf/wf-const-type.rs b/tests/ui/wf/wf-const-type.rs
index df79aa267..64b0d9c8d 100644
--- a/tests/ui/wf/wf-const-type.rs
+++ b/tests/ui/wf/wf-const-type.rs
@@ -9,6 +9,7 @@ struct NotCopy;
const FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None };
//~^ ERROR E0277
+//~| ERROR E0277
fn main() { }
diff --git a/tests/ui/wf/wf-const-type.stderr b/tests/ui/wf/wf-const-type.stderr
index 617969720..039e90770 100644
--- a/tests/ui/wf/wf-const-type.stderr
+++ b/tests/ui/wf/wf-const-type.stderr
@@ -16,6 +16,24 @@ LL + #[derive(Copy)]
LL | struct NotCopy;
|
-error: aborting due to previous error
+error[E0277]: the trait bound `NotCopy: Copy` is not satisfied
+ --> $DIR/wf-const-type.rs:10:50
+ |
+LL | const FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None };
+ | ^^^^ the trait `Copy` is not implemented for `NotCopy`
+ |
+ = note: required for `Option<NotCopy>` to implement `Copy`
+note: required by a bound in `IsCopy`
+ --> $DIR/wf-const-type.rs:7:17
+ |
+LL | struct IsCopy<T:Copy> { t: T }
+ | ^^^^ required by this bound in `IsCopy`
+help: consider annotating `NotCopy` with `#[derive(Copy)]`
+ |
+LL + #[derive(Copy)]
+LL | struct NotCopy;
+ |
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr
index 40a25c7df..85f507336 100644
--- a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr
+++ b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr
@@ -11,6 +11,7 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: only type `S` implements the trait, consider using it directly instead
= note: required for the cast from `Box<S>` to `Box<dyn Trait>`
error[E0038]: the trait `Trait` cannot be made into an object
@@ -26,6 +27,7 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: only type `S` implements the trait, consider using it directly instead
= note: required for the cast from `Box<S>` to `Box<(dyn Trait + 'static)>`
error[E0038]: the trait `Trait` cannot be made into an object
@@ -41,6 +43,7 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: only type `S` implements the trait, consider using it directly instead
= note: required for the cast from `Box<S>` to `Box<dyn Trait>`
error: aborting due to 3 previous errors
diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr
index e2c71df2f..a2a196316 100644
--- a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr
+++ b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr
@@ -11,6 +11,7 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: only type `S` implements the trait, consider using it directly instead
= note: required for the cast from `&S` to `&dyn Trait`
error[E0038]: the trait `Trait` cannot be made into an object
@@ -26,6 +27,7 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: only type `S` implements the trait, consider using it directly instead
= note: required for the cast from `&S` to `&dyn Trait`
error[E0038]: the trait `Trait` cannot be made into an object
@@ -41,6 +43,7 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: only type `S` implements the trait, consider using it directly instead
= note: required for the cast from `&S` to `&dyn Trait`
error: aborting due to 3 previous errors
diff --git a/tests/ui/wf/wf-fn-where-clause.stderr b/tests/ui/wf/wf-fn-where-clause.stderr
index 2aec641e7..cd6c051fe 100644
--- a/tests/ui/wf/wf-fn-where-clause.stderr
+++ b/tests/ui/wf/wf-fn-where-clause.stderr
@@ -14,6 +14,15 @@ help: consider further restricting type parameter `U`
LL | fn foo<T,U>() where T: ExtraCopy<U>, U: std::marker::Copy
| ++++++++++++++++++++++
+error[E0038]: the trait `Copy` cannot be made into an object
+ --> $DIR/wf-fn-where-clause.rs:12:16
+ |
+LL | fn bar() where Vec<dyn Copy>:, {}
+ | ^^^^^^^^^^^^^ `Copy` cannot be made into an object
+ |
+ = note: the trait cannot be made into an object because it requires `Self: Sized`
+ = 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>
+
error[E0277]: the size for values of type `(dyn Copy + 'static)` cannot be known at compilation time
--> $DIR/wf-fn-where-clause.rs:12:16
|
@@ -34,15 +43,6 @@ LL | struct Vec<T> {
LL | t: T,
| - ...if indirection were used here: `Box<T>`
-error[E0038]: the trait `Copy` cannot be made into an object
- --> $DIR/wf-fn-where-clause.rs:12:16
- |
-LL | fn bar() where Vec<dyn Copy>:, {}
- | ^^^^^^^^^^^^^ `Copy` cannot be made into an object
- |
- = note: the trait cannot be made into an object because it requires `Self: Sized`
- = 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>
-
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0277.
diff --git a/tests/ui/wf/wf-impl-associated-type-region.stderr b/tests/ui/wf/wf-impl-associated-type-region.stderr
index b9d4857a3..e6fb81247 100644
--- a/tests/ui/wf/wf-impl-associated-type-region.stderr
+++ b/tests/ui/wf/wf-impl-associated-type-region.stderr
@@ -1,10 +1,12 @@
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/wf-impl-associated-type-region.rs:10:16
|
+LL | impl<'a, T> Foo<'a> for T {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
LL | type Bar = &'a T;
| ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | impl<'a, T: 'a> Foo<'a> for T {
| ++++
diff --git a/tests/ui/wf/wf-in-fn-type-static.stderr b/tests/ui/wf/wf-in-fn-type-static.stderr
index 73fbb9ca6..45ad9fba0 100644
--- a/tests/ui/wf/wf-in-fn-type-static.stderr
+++ b/tests/ui/wf/wf-in-fn-type-static.stderr
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/wf-in-fn-type-static.rs:13:8
|
LL | x: fn() -> &'static T
- | ^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^^^^^^^^^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the reference type `&'static T` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | struct Foo<T: 'static> {
| +++++++++
@@ -13,9 +16,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/wf-in-fn-type-static.rs:18:8
|
LL | x: fn(&'static T)
- | ^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^^^^^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the reference type `&'static T` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | struct Bar<T: 'static> {
| +++++++++
diff --git a/tests/ui/wf/wf-in-obj-type-static.stderr b/tests/ui/wf/wf-in-obj-type-static.stderr
index c3ad42dd5..4b9b18916 100644
--- a/tests/ui/wf/wf-in-obj-type-static.stderr
+++ b/tests/ui/wf/wf-in-obj-type-static.stderr
@@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/wf-in-obj-type-static.rs:14:8
|
LL | x: dyn Object<&'static T>
- | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the reference type `&'static T` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | struct Foo<T: 'static> {
| +++++++++
diff --git a/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr
index 4d4d8b2ab..e0cf42fd1 100644
--- a/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr
+++ b/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr
@@ -1,10 +1,12 @@
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:16
|
+LL | impl<'a, T> Trait<'a, T> for usize {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
LL | type Out = &'a fn(T);
| ^^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | impl<'a, T: 'a> Trait<'a, T> for usize {
| ++++
@@ -12,10 +14,12 @@ LL | impl<'a, T: 'a> Trait<'a, T> for usize {
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:16
|
+LL | impl<'a, T> Trait<'a, T> for u32 {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
LL | type Out = &'a dyn Baz<T>;
| ^^^^^^^^^^^^^^ ...so that the reference type `&'a (dyn Baz<T> + 'a)` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | impl<'a, T: 'a> Trait<'a, T> for u32 {
| ++++
diff --git a/tests/ui/wf/wf-static-type.rs b/tests/ui/wf/wf-static-type.rs
index 1c35e1daf..f454fe30e 100644
--- a/tests/ui/wf/wf-static-type.rs
+++ b/tests/ui/wf/wf-static-type.rs
@@ -9,6 +9,7 @@ struct NotCopy;
static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None };
//~^ ERROR E0277
+//~| ERROR E0277
fn main() { }
diff --git a/tests/ui/wf/wf-static-type.stderr b/tests/ui/wf/wf-static-type.stderr
index bb5a57834..65dae2601 100644
--- a/tests/ui/wf/wf-static-type.stderr
+++ b/tests/ui/wf/wf-static-type.stderr
@@ -16,6 +16,24 @@ LL + #[derive(Copy)]
LL | struct NotCopy;
|
-error: aborting due to previous error
+error[E0277]: the trait bound `NotCopy: Copy` is not satisfied
+ --> $DIR/wf-static-type.rs:10:51
+ |
+LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None };
+ | ^^^^ the trait `Copy` is not implemented for `NotCopy`
+ |
+ = note: required for `Option<NotCopy>` to implement `Copy`
+note: required by a bound in `IsCopy`
+ --> $DIR/wf-static-type.rs:7:17
+ |
+LL | struct IsCopy<T:Copy> { t: T }
+ | ^^^^ required by this bound in `IsCopy`
+help: consider annotating `NotCopy` with `#[derive(Copy)]`
+ |
+LL + #[derive(Copy)]
+LL | struct NotCopy;
+ |
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/wf/wf-trait-associated-type-region.stderr b/tests/ui/wf/wf-trait-associated-type-region.stderr
index 6e2cc8aba..ca7aeb55b 100644
--- a/tests/ui/wf/wf-trait-associated-type-region.stderr
+++ b/tests/ui/wf/wf-trait-associated-type-region.stderr
@@ -1,11 +1,16 @@
error[E0309]: the associated type `<Self as SomeTrait<'a>>::Type1` may not live long enough
--> $DIR/wf-trait-associated-type-region.rs:9:18
|
+LL | trait SomeTrait<'a> {
+ | -- the associated type `<Self as SomeTrait<'a>>::Type1` must be valid for the lifetime `'a` as defined here...
+LL | type Type1;
LL | type Type2 = &'a Self::Type1;
- | ^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^ ...so that the reference type `&'a <Self as SomeTrait<'a>>::Type1` does not outlive the data it points at
|
- = help: consider adding an explicit lifetime bound `<Self as SomeTrait<'a>>::Type1: 'a`...
- = note: ...so that the reference type `&'a <Self as SomeTrait<'a>>::Type1` does not outlive the data it points at
+help: consider adding an explicit lifetime bound
+ |
+LL | type Type2 = &'a Self::Type1 where <Self as SomeTrait<'a>>::Type1: 'a;
+ | ++++++++++++++++++++++++++++++++++++++++
error: aborting due to previous error
diff --git a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr
index 66504e440..a0279774a 100644
--- a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr
+++ b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr
@@ -11,6 +11,10 @@ LL | | }
|
= note: expected reference `&S`
found reference `&R`
+help: consider using a semicolon here, but this will discard any values in the match arms
+ |
+LL | };
+ | +
error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/wf-unsafe-trait-obj-match.rs:26:21
@@ -25,6 +29,9 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
+ S
+ R
= note: required for the cast from `&S` to `&dyn Trait`
error[E0038]: the trait `Trait` cannot be made into an object
@@ -44,6 +51,9 @@ LL | trait Trait: Sized {}
| ----- ^^^^^ ...because it requires `Self: Sized`
| |
| this trait cannot be made into an object...
+ = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead:
+ S
+ R
= note: required for the cast from `&R` to `&dyn Trait`
error: aborting due to 3 previous errors