Skip to content

Commit ec4d910

Browse files
Correctly handle internal_features attribute
1 parent 475824d commit ec4d910

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/librustdoc/doctest/make.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,19 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> Option<AttrKind>
465465
} else if attr_name == sym::no_std {
466466
Some(AttrKind::NoStd)
467467
} else if not_crate_attrs.contains(&attr_name) {
468-
Some(AttrKind::Attr)
468+
// There is one exception to these attributes:
469+
// `#![allow(internal_features)]`. If this attribute is used, we need to
470+
// consider it only as a crate-level attribute.
471+
if attr_name == sym::allow
472+
&& let Some(list) = attr.meta_item_list()
473+
&& list.iter().any(|sub_attr| {
474+
sub_attr.name_or_empty().as_str() == "internal_features"
475+
})
476+
{
477+
Some(AttrKind::CrateAttr)
478+
} else {
479+
Some(AttrKind::Attr)
480+
}
469481
} else {
470482
Some(AttrKind::CrateAttr)
471483
}

0 commit comments

Comments
 (0)