From ec4d9101907bcb20cac7ff055fd1c1776292e0bf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 15 Jun 2024 18:20:58 +0200 Subject: [PATCH] Correctly handle `internal_features` attribute --- src/librustdoc/doctest/make.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index c67dc4525d2c..aaa8cb5ccf7d 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -465,7 +465,19 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> Option } else if attr_name == sym::no_std { Some(AttrKind::NoStd) } else if not_crate_attrs.contains(&attr_name) { - Some(AttrKind::Attr) + // There is one exception to these attributes: + // `#![allow(internal_features)]`. If this attribute is used, we need to + // consider it only as a crate-level attribute. + if attr_name == sym::allow + && let Some(list) = attr.meta_item_list() + && list.iter().any(|sub_attr| { + sub_attr.name_or_empty().as_str() == "internal_features" + }) + { + Some(AttrKind::CrateAttr) + } else { + Some(AttrKind::Attr) + } } else { Some(AttrKind::CrateAttr) }