* Improve documentation
* Add a test to ensure that spotlighted traits from dependencies are taken into account as expected
-/// Checks that one attribute is `doc`. For example:
+/// Checks for the existence of `hidden` in the attribute below if `flag` is `sym::hidden`:
-/// ```text
-/// #[doc(spotlight)]
+/// ```
+/// #[doc(hidden)]
+/// pub fn foo() {}
-/// This function has to exists because it runs on `hir::Attributes` whereas the other runs on
-/// `clean::Attributes`.
+/// This function exists because it runs on `hir::Attributes` whereas the other is a
+/// `clean::Attributes` method.
crate fn has_doc_flag(attrs: Attributes<'_>, flag: Symbol) -> bool {
attrs.iter().any(|attr| {
attr.has_name(sym::doc)
crate fn has_doc_flag(attrs: Attributes<'_>, flag: Symbol) -> bool {
attrs.iter().any(|attr| {
attr.has_name(sym::doc)
// Propagate a trait method's documentation to all implementors of the
// trait.
if let clean::TraitItem(ref t) = *item.kind {
self.cache.traits.entry(item.def_id).or_insert_with(|| clean::TraitWithExtraInfo {
trait_: t.clone(),
// Propagate a trait method's documentation to all implementors of the
// trait.
if let clean::TraitItem(ref t) = *item.kind {
self.cache.traits.entry(item.def_id).or_insert_with(|| clean::TraitWithExtraInfo {
trait_: t.clone(),
- is_spotlight: clean::utils::has_doc_flag(
- tcx.get_attrs(item.def_id),
- sym::spotlight,
- ),
+ is_spotlight: item.attrs.has_doc_flag(sym::spotlight),
--- /dev/null
+#![crate_name = "foo"]
+
+use std::iter::Iterator;
+
+// @has foo/struct.Odd.html
+// @has - '//h4[@id="method.new"]//span[@class="notable-traits"]//code/span' 'impl Iterator for Odd'
+pub struct Odd {
+ current: usize,
+}
+
+impl Odd {
+ pub fn new() -> Odd {
+ Odd { current: 1 }
+ }
+}
+
+impl Iterator for Odd {
+ type Item = usize;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ self.current += 2;
+ Some(self.current - 2)
+ }
+}