Skip to content

Commit c0adb26

Browse files
committed
Add diagnostic::on_unimplemented for no iterator in repetition
1 parent a1ddcab commit c0adb26

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

src/runtime.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ impl BitOr<HasIterator<true>> for HasIterator<true> {
4949
}
5050

5151
#[doc(hidden)]
52+
#[diagnostic::on_unimplemented(
53+
message = "repetition contains no interpolated value that is an iterator",
54+
label = "none of the values interpolated inside this repetition are iterable"
55+
)]
5256
pub trait CheckHasIterator: Sized {
5357
fn check(self) {}
5458
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error[E0277]: the trait bound `HasIterator<false>: CheckHasIterator` is not satisfied
1+
error[E0277]: repetition contains no interpolated value that is an iterator
22
--> tests/ui/does-not-have-iter-interpolated-dup.rs:8:5
33
|
44
8 | quote!(#(#nonrep #nonrep)*);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ none of the values interpolated inside this repetition are iterable
66
|
7+
= help: the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
78
= help: the trait `CheckHasIterator` is implemented for `HasIterator<true>`
89
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error[E0277]: the trait bound `HasIterator<false>: CheckHasIterator` is not satisfied
1+
error[E0277]: repetition contains no interpolated value that is an iterator
22
--> tests/ui/does-not-have-iter-interpolated.rs:8:5
33
|
44
8 | quote!(#(#nonrep)*);
5-
| ^^^^^^^^^^^^^^^^^^^ the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
5+
| ^^^^^^^^^^^^^^^^^^^ none of the values interpolated inside this repetition are iterable
66
|
7+
= help: the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
78
= help: the trait `CheckHasIterator` is implemented for `HasIterator<true>`
89
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error[E0277]: the trait bound `HasIterator<false>: CheckHasIterator` is not satisfied
1+
error[E0277]: repetition contains no interpolated value that is an iterator
22
--> tests/ui/does-not-have-iter-separated.rs:4:5
33
|
44
4 | quote!(#(a b),*);
5-
| ^^^^^^^^^^^^^^^^ the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
5+
| ^^^^^^^^^^^^^^^^ none of the values interpolated inside this repetition are iterable
66
|
7+
= help: the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
78
= help: the trait `CheckHasIterator` is implemented for `HasIterator<true>`
89
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)

tests/ui/does-not-have-iter.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
error[E0277]: the trait bound `HasIterator<false>: CheckHasIterator` is not satisfied
1+
error[E0277]: repetition contains no interpolated value that is an iterator
22
--> tests/ui/does-not-have-iter.rs:4:5
33
|
44
4 | quote!(#(a b)*);
5-
| ^^^^^^^^^^^^^^^ the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
5+
| ^^^^^^^^^^^^^^^ none of the values interpolated inside this repetition are iterable
66
|
7+
= help: the trait `CheckHasIterator` is not implemented for `HasIterator<false>`
78
= help: the trait `CheckHasIterator` is implemented for `HasIterator<true>`
89
= note: this error originates in the macro `$crate::quote_token_with_context` which comes from the expansion of the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)