Skip to main content

miniextendr_lint/rules/
export_attrs.rs

1//! Export attribute redundancy checks.
2//!
3//! - MXL203: `internal` + `noexport` redundancy.
4
5use crate::crate_index::CrateIndex;
6use crate::diagnostic::Diagnostic;
7use crate::lint_code::LintCode;
8
9pub fn check(index: &CrateIndex, diagnostics: &mut Vec<Diagnostic>) {
10    for (path, data) in &index.file_data {
11        for (name, (has_internal, has_noexport, line)) in &data.export_control {
12            if *has_internal && *has_noexport {
13                diagnostics.push(
14                    Diagnostic::new(
15                        LintCode::MXL203,
16                        path,
17                        *line,
18                        format!(
19                            "`{}` has both `internal` and `noexport`. \
20                             `internal` already suppresses @export (and adds @keywords internal), \
21                             making `noexport` redundant.",
22                            name,
23                        ),
24                    )
25                    .with_help("Remove `noexport` and keep only `internal`."),
26                );
27            }
28        }
29    }
30}