about summary refs log tree commit diff
path: root/src/libcore/iter
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-02-07 08:30:47 -0800
committerGitHub <noreply@github.com>2018-02-07 08:30:47 -0800
commitaee22556a97aac4b921efb806b26fbb60a6b8a92 (patch)
tree3f0ecfbabe72844da2e25a0d94c4cbeeb1095fb1 /src/libcore/iter
parent4f93357d3b8938dfe439329c43c1e4f919a70869 (diff)
parentfd3f2312a75bcc4c8121ad324a012c3b8befb61c (diff)
downloadrust-aee22556a97aac4b921efb806b26fbb60a6b8a92.tar.gz
rust-aee22556a97aac4b921efb806b26fbb60a6b8a92.zip
Rollup merge of #47613 - estebank:rustc_on_unimplemented, r=nikomatsakis
Add filtering options to `rustc_on_unimplemented`

- Add filtering options to `rustc_on_unimplemented` for local traits, filtering on `Self` and type arguments.
- Add a way to provide custom notes.
- Tweak binops text.
- Add filter to detect wether `Self` is local or belongs to another crate.
- Add filter to `Iterator` diagnostic for `&str`.

Partly addresses #44755 with a different syntax, as a first approach. Fixes #46216, fixes #37522, CC #34297, #46806.
Diffstat (limited to 'src/libcore/iter')
-rw-r--r--src/libcore/iter/iterator.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs
index 35cd7441c66..296fb8733ba 100644
--- a/src/libcore/iter/iterator.rs
+++ b/src/libcore/iter/iterator.rs
@@ -28,8 +28,13 @@ fn _assert_is_object_safe(_: &Iterator<Item=()>) {}
 /// [module-level documentation]: index.html
 /// [impl]: index.html#implementing-iterator
 #[stable(feature = "rust1", since = "1.0.0")]
-#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling \
-                            `.iter()` or a similar method"]
+#[rustc_on_unimplemented(
+    on(
+        _Self="&str",
+        label="`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`"
+    ),
+    label="`{Self}` is not an iterator; maybe try calling `.iter()` or a similar method"
+)]
 #[doc(spotlight)]
 pub trait Iterator {
     /// The type of the elements being iterated over.