Skip to content

Commit 3d363c3

Browse files
committed
Move is_complete to the module that uses it.
And make it non-`pub`.
1 parent 4288edb commit 3d363c3

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

compiler/rustc_parse/src/parser/attr.rs

-11
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,3 @@ impl<'a> Parser<'a> {
457457
Err(self.dcx().create_err(err))
458458
}
459459
}
460-
461-
/// The attributes are complete if all attributes are either a doc comment or a
462-
/// builtin attribute other than `cfg_attr`.
463-
pub fn is_complete(attrs: &[ast::Attribute]) -> bool {
464-
attrs.iter().all(|attr| {
465-
attr.is_doc_comment()
466-
|| attr.ident().is_some_and(|ident| {
467-
ident.name != sym::cfg_attr && rustc_feature::is_builtin_attr_name(ident.name)
468-
})
469-
})
470-
}

compiler/rustc_parse/src/parser/attr_wrapper.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'a> Parser<'a> {
201201
// tokens by definition).
202202
let needs_collection = matches!(force_collect, ForceCollect::Yes)
203203
// - Any of our outer attributes require tokens.
204-
|| !crate::parser::attr::is_complete(&attrs.attrs)
204+
|| !is_complete(&attrs.attrs)
205205
// - Our target supports custom inner attributes (custom
206206
// inner attribute invocation might require token capturing).
207207
|| R::SUPPORTS_CUSTOM_INNER_ATTRS
@@ -261,7 +261,7 @@ impl<'a> Parser<'a> {
261261
// outer and inner attributes. So this check is more precise than
262262
// the earlier `is_complete()` check, and we don't need to
263263
// check `R::SUPPORTS_CUSTOM_INNER_ATTRS`.)
264-
|| !crate::parser::attr::is_complete(ret.attrs())
264+
|| !is_complete(ret.attrs())
265265
// - We are in `capture_cfg` mode and there are `#[cfg]` or
266266
// `#[cfg_attr]` attributes. (During normal non-`capture_cfg`
267267
// parsing, we don't need any special capturing for those
@@ -457,6 +457,17 @@ fn make_attr_token_stream(
457457
AttrTokenStream::new(stack_top.inner)
458458
}
459459

460+
/// The attributes are complete if all attributes are either a doc comment or a
461+
/// builtin attribute other than `cfg_attr`.
462+
fn is_complete(attrs: &[ast::Attribute]) -> bool {
463+
attrs.iter().all(|attr| {
464+
attr.is_doc_comment()
465+
|| attr.ident().is_some_and(|ident| {
466+
ident.name != sym::cfg_attr && rustc_feature::is_builtin_attr_name(ident.name)
467+
})
468+
})
469+
}
470+
460471
// Some types are used a lot. Make sure they don't unintentionally get bigger.
461472
#[cfg(target_pointer_width = "64")]
462473
mod size_asserts {

0 commit comments

Comments
 (0)