1//! Non-API `ATTRIB` / `SET_ATTRIB` usage lint.
2//!
3//! - MXL304: Warns on calls to, or declarations of, R's `ATTRIB` and
4//! `SET_ATTRIB` (and their `_unchecked` forms). Neither is part of R's API:
5//! `R CMD check` on R >= 4.6 reports a package whose shared object references
6//! them. miniextendr-api only declares them behind its `nonapi` feature, so
7//! this rule mainly catches a crate that declares the symbol itself in an
8//! `extern` block to get around that.
910use crate::crate_index::CrateIndex;
11use crate::diagnostic::Diagnostic;
12use crate::lint_code::LintCode;
1314pub fn check(index: &CrateIndex, diagnostics: &mut Vec<Diagnostic>) {
15for (path, data) in &index.file_data {
16for (fn_name, line) in &data.nonapi_attrib_calls {
17 diagnostics.push(
18 Diagnostic::new(
19 LintCode::MXL304,
20 path,
21*line,
22::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}()` is not part of R\'s API; `R CMD check` (R >= 4.6) reports packages that reference it.",
fn_name))
})format!(
23"`{fn_name}()` is not part of R's API; `R CMD check` (R >= 4.6) \
24 reports packages that reference it.",
25 ),
26 )
27 .with_help(
28"Use `SexpExt::has_attributes()` to test for attributes, \
29 `SexpExt::is_identical()` for R's `identical()`, \
30 `SexpExt::get_attr()` / `set_attr()` for one attribute, and \
31 `DUPLICATE_ATTRIB` / `SHALLOW_DUPLICATE_ATTRIB` to copy all of them. \
32 Suppress an intentional site with `// mxl::allow(MXL304)`.",
33 ),
34 );
35 }
36 }
37}