diff options
| author | Michael Goulet <michael@errs.io> | 2024-07-17 15:56:16 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-07-17 15:57:38 -0400 |
| commit | 3716a3fd3104915b9663a335fa92222ae3e179de (patch) | |
| tree | 84cfafed32ea7e6284f3caec826b28e650b67882 /tests/ui/variance | |
| parent | 3de0a7c716daab58bdb6551b0d0af6a466486639 (diff) | |
| download | rust-3716a3fd3104915b9663a335fa92222ae3e179de.tar.gz rust-3716a3fd3104915b9663a335fa92222ae3e179de.zip | |
Mention that type parameters are used recursively
Diffstat (limited to 'tests/ui/variance')
| -rw-r--r-- | tests/ui/variance/variance-unused-type-param.rs | 2 | ||||
| -rw-r--r-- | tests/ui/variance/variance-unused-type-param.stderr | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/tests/ui/variance/variance-unused-type-param.rs b/tests/ui/variance/variance-unused-type-param.rs index d1114064364..7e35f59fd84 100644 --- a/tests/ui/variance/variance-unused-type-param.rs +++ b/tests/ui/variance/variance-unused-type-param.rs @@ -11,8 +11,8 @@ enum SomeEnum<A> { Nothing } // Here T might *appear* used, but in fact it isn't. enum ListCell<T> { -//~^ ERROR parameter `T` is never used Cons(Box<ListCell<T>>), + //~^ ERROR parameter `T` is only used recursively Nil } diff --git a/tests/ui/variance/variance-unused-type-param.stderr b/tests/ui/variance/variance-unused-type-param.stderr index 3011b7bd18f..212db564ac4 100644 --- a/tests/ui/variance/variance-unused-type-param.stderr +++ b/tests/ui/variance/variance-unused-type-param.stderr @@ -16,14 +16,16 @@ LL | enum SomeEnum<A> { Nothing } = help: consider removing `A`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `A` to be a const parameter, use `const A: /* Type */` instead -error[E0392]: type parameter `T` is never used - --> $DIR/variance-unused-type-param.rs:13:15 +error: type parameter `T` is only used recursively + --> $DIR/variance-unused-type-param.rs:14:23 | LL | enum ListCell<T> { - | ^ unused type parameter + | - type parameter must be used non-recursively in the definition +LL | Cons(Box<ListCell<T>>), + | ^ | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead + = note: all type parameters must be used in a non-recursive way in order to constrain its variance error[E0392]: type parameter `T` is never used --> $DIR/variance-unused-type-param.rs:19:19 |
