Move is_complete
to the module that uses it.
And make it non-`pub`.
This commit is contained in:
parent
4288edb219
commit
3d363c3d99
2 changed files with 13 additions and 13 deletions
|
@ -457,14 +457,3 @@ impl<'a> Parser<'a> {
|
||||||
Err(self.dcx().create_err(err))
|
Err(self.dcx().create_err(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The attributes are complete if all attributes are either a doc comment or a
|
|
||||||
/// builtin attribute other than `cfg_attr`.
|
|
||||||
pub fn is_complete(attrs: &[ast::Attribute]) -> bool {
|
|
||||||
attrs.iter().all(|attr| {
|
|
||||||
attr.is_doc_comment()
|
|
||||||
|| attr.ident().is_some_and(|ident| {
|
|
||||||
ident.name != sym::cfg_attr && rustc_feature::is_builtin_attr_name(ident.name)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ impl<'a> Parser<'a> {
|
||||||
// tokens by definition).
|
// tokens by definition).
|
||||||
let needs_collection = matches!(force_collect, ForceCollect::Yes)
|
let needs_collection = matches!(force_collect, ForceCollect::Yes)
|
||||||
// - Any of our outer attributes require tokens.
|
// - Any of our outer attributes require tokens.
|
||||||
|| !crate::parser::attr::is_complete(&attrs.attrs)
|
|| !is_complete(&attrs.attrs)
|
||||||
// - Our target supports custom inner attributes (custom
|
// - Our target supports custom inner attributes (custom
|
||||||
// inner attribute invocation might require token capturing).
|
// inner attribute invocation might require token capturing).
|
||||||
|| R::SUPPORTS_CUSTOM_INNER_ATTRS
|
|| R::SUPPORTS_CUSTOM_INNER_ATTRS
|
||||||
|
@ -261,7 +261,7 @@ impl<'a> Parser<'a> {
|
||||||
// outer and inner attributes. So this check is more precise than
|
// outer and inner attributes. So this check is more precise than
|
||||||
// the earlier `is_complete()` check, and we don't need to
|
// the earlier `is_complete()` check, and we don't need to
|
||||||
// check `R::SUPPORTS_CUSTOM_INNER_ATTRS`.)
|
// check `R::SUPPORTS_CUSTOM_INNER_ATTRS`.)
|
||||||
|| !crate::parser::attr::is_complete(ret.attrs())
|
|| !is_complete(ret.attrs())
|
||||||
// - We are in `capture_cfg` mode and there are `#[cfg]` or
|
// - We are in `capture_cfg` mode and there are `#[cfg]` or
|
||||||
// `#[cfg_attr]` attributes. (During normal non-`capture_cfg`
|
// `#[cfg_attr]` attributes. (During normal non-`capture_cfg`
|
||||||
// parsing, we don't need any special capturing for those
|
// parsing, we don't need any special capturing for those
|
||||||
|
@ -457,6 +457,17 @@ fn make_attr_token_stream(
|
||||||
AttrTokenStream::new(stack_top.inner)
|
AttrTokenStream::new(stack_top.inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The attributes are complete if all attributes are either a doc comment or a
|
||||||
|
/// builtin attribute other than `cfg_attr`.
|
||||||
|
fn is_complete(attrs: &[ast::Attribute]) -> bool {
|
||||||
|
attrs.iter().all(|attr| {
|
||||||
|
attr.is_doc_comment()
|
||||||
|
|| attr.ident().is_some_and(|ident| {
|
||||||
|
ident.name != sym::cfg_attr && rustc_feature::is_builtin_attr_name(ident.name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Some types are used a lot. Make sure they don't unintentionally get bigger.
|
// Some types are used a lot. Make sure they don't unintentionally get bigger.
|
||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
mod size_asserts {
|
mod size_asserts {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue