Skip to content

Commit

Permalink
rustdoc: add error messages to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
megakorre committed Mar 30, 2023
1 parent 4d571a9 commit df556a3
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 60 deletions.
55 changes: 34 additions & 21 deletions tests/rustdoc-ui/issue-105742.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,49 @@
use std::ops::Index;

pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
//~^ERROR
//~|ERROR
//~|ERROR
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~| the trait `SVec` cannot be made into an object
//~| `SVec` cannot be made into an object
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
let _ = s;
}

pub trait SVec: Index<
<Self as SVec>::Item,
//~^ERROR
//~|ERROR
//~|ERROR
//~|ERROR
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
Output = <Index<<Self as SVec>::Item,
//~^ERROR
//~|ERROR
//~|ERROR
//~|ERROR
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
Output = <Self as SVec>::Item> as SVec>::Item,
//~^ERROR
//~|ERROR
//~|ERROR
//~|ERROR
//~|ERROR
//~|ERROR
//~|ERROR
//~|ERROR
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~| expected 1 lifetime argument
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| expected 1 generic argument
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
//~| missing generics for associated type `SVec::Item`
> {
type Item<'a, T>;

fn len(&self) -> <Self as SVec>::Item;
//~^ERROR
//~|ERROR
//~^ expected 1 lifetime argument
//~| missing generics for associated type `SVec::Item`
//~| expected 1 generic argument
//~| missing generics for associated type `SVec::Item`
}
79 changes: 40 additions & 39 deletions tests/rustdoc-ui/issue-105742.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:12:21
--> $DIR/issue-105742.rs:15:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -15,13 +15,13 @@ LL | <Self as SVec>::Item<'a>,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:12:21
--> $DIR/issue-105742.rs:15:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -31,13 +31,13 @@ LL | <Self as SVec>::Item<T>,
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:17:37
--> $DIR/issue-105742.rs:22:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -47,13 +47,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:17:37
--> $DIR/issue-105742.rs:22:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -63,13 +63,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:30
--> $DIR/issue-105742.rs:29:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -79,13 +79,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:30
--> $DIR/issue-105742.rs:29:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -95,13 +95,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:46
--> $DIR/issue-105742.rs:29:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -111,13 +111,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:46
--> $DIR/issue-105742.rs:29:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -133,7 +133,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -149,7 +149,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -159,13 +159,13 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) {
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:12:21
--> $DIR/issue-105742.rs:15:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -175,13 +175,13 @@ LL | <Self as SVec>::Item<'a>,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:12:21
--> $DIR/issue-105742.rs:15:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -191,13 +191,13 @@ LL | <Self as SVec>::Item<T>,
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:17:37
--> $DIR/issue-105742.rs:22:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -207,13 +207,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:17:37
--> $DIR/issue-105742.rs:22:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -223,13 +223,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:30
--> $DIR/issue-105742.rs:29:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -239,13 +239,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:30
--> $DIR/issue-105742.rs:29:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -255,13 +255,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:46
--> $DIR/issue-105742.rs:29:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -271,13 +271,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:22:46
--> $DIR/issue-105742.rs:29:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand All @@ -293,7 +293,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` 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/issue-105742.rs:11:17
--> $DIR/issue-105742.rs:14:17
|
LL | pub trait SVec: Index<
| ____________----__^
Expand All @@ -307,6 +307,7 @@ LL | |/ Output = <Index<<Self as SVec>::Item,
LL | ||
LL | ||
LL | ||
... ||
LL | ||
LL | || Output = <Self as SVec>::Item> as SVec>::Item,
| ||_________________________________________________^ ...because it uses `Self` as a type parameter
Expand All @@ -316,13 +317,13 @@ LL | | > {
| |__^ ...because it uses `Self` as a type parameter

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:34:38
--> $DIR/issue-105742.rs:45:38
|
LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ --
Expand All @@ -332,13 +333,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>;
| ++++

error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:34:38
--> $DIR/issue-105742.rs:45:38
|
LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:32:10
--> $DIR/issue-105742.rs:43:10
|
LL | type Item<'a, T>;
| ^^^^ -
Expand Down

0 comments on commit df556a3

Please sign in to comment.