diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-06-15 18:20:58 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-08-13 20:14:55 +0200 |
| commit | ec4d9101907bcb20cac7ff055fd1c1776292e0bf (patch) | |
| tree | d6ec7df5f72c677f19c30277e8cb50f812e2cb7d /src/librustdoc/doctest/make.rs | |
| parent | 475824d8110ffd67065609b0e00e28ad220d62b2 (diff) | |
| download | rust-ec4d9101907bcb20cac7ff055fd1c1776292e0bf.tar.gz rust-ec4d9101907bcb20cac7ff055fd1c1776292e0bf.zip | |
Correctly handle `internal_features` attribute
Diffstat (limited to 'src/librustdoc/doctest/make.rs')
| -rw-r--r-- | src/librustdoc/doctest/make.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index c67dc4525d2..aaa8cb5ccf7 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<AttrKind> } 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) } |
