1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Crate-level Rust attribute formatting for generated binding crates.
//!
//! Kept apart from the IR-shaped helpers in [`super::shared`]: these functions manipulate
//! attribute *text*, not IR, and re-export through `shared` so existing call paths hold.
use HashSet;
/// Format extra clippy allows for insertion into generated Rust binding files.
///
/// Accepts bare lint names (`"single_match"`) or `clippy::`-prefixed names
/// (`"clippy::single_match"`); both forms are normalised to the `clippy::` prefix.
///
/// Returns `None` when `extras` is empty — callers must skip emission entirely in
/// that case so output is byte-identical to the no-config baseline.
///
/// Returns `Some(attr)` where `attr` is the inner content of an `allow(...)` call,
/// e.g. `"allow(clippy::single_match, clippy::collapsible_match)"`. Pass this
/// directly to [`crate::codegen::builder::RustFileBuilder::add_inner_attribute`]
/// or format it into a raw `#![allow(...)]` attribute string.
///
/// `already_emitted` is the attribute text emitted above this call (each backend's
/// default allow block). Lints already present there are filtered out so the extra
/// block never re-allows a lint — a duplicate would trip clippy's
/// `duplicated_attributes` lint under `-D warnings`. Returns `None` when nothing new
/// remains, so callers skip emission entirely.
/// Format per-crate `crate_attributes` config entries for splicing into a generated
/// crate's `lib.rs`, one inner attribute per entry, in configured order.
///
/// Entries are raw attribute *bodies* (e.g. `recursion_limit = "256"`), not full
/// `#![...]` syntax — the same convention as [`format_extra_clippy_allows`]. Unlike
/// that function, entries are **not** merged into a single attribute: each one is a
/// distinct, unrelated attribute (`recursion_limit`, `feature(...)`, `warn(...)`, ...),
/// so merging them would be meaningless.
///
/// Well-formedness (non-empty, single-line, valid leading attribute path, not already
/// wrapped in `#![...]`) is validated once at config-resolve time — see
/// `crate::core::config::new_config::NewAlefConfig::resolve`. This function assumes
/// already-validated input and only trims incidental whitespace, matching the
/// historical behavior of `format_extra_clippy_allows`.
///
/// Returns an empty `Vec` when `attributes` is empty — callers must skip emission
/// entirely in that case so output is byte-identical to the no-config baseline.
/// Collect the `clippy::<lint>` tokens present in already-emitted attribute text,
/// used to de-duplicate extra clippy allows against a backend's default allow block.