Skip to main content

Module crate_index

Module crate_index 

Source
Expand description

Shared crate index built from a single parse pass over all source files.

All lint rules operate on this index rather than re-parsing files.

Re-exportsΒ§

use std::collections::HashMap; πŸ”’
use std::collections::HashSet; πŸ”’
use std::fmt; πŸ”’
use std::fs; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use syn::Item; πŸ”’
use syn::ext::IdentExt; πŸ”’
use syn::spanned::Spanned; πŸ”’
use syn::visit; πŸ”’
use syn::visit::Visit; πŸ”’
use crate::crate_root::CrateRoot; πŸ”’
use crate::description; πŸ”’
use crate::description::Description; πŸ”’
use crate::helpers::extract_cfg_attrs; πŸ”’
use crate::helpers::extract_path_attr; πŸ”’
use crate::helpers::extract_roxygen_tags; πŸ”’
use crate::helpers::has_derive; πŸ”’
use crate::helpers::has_miniextendr_attr; πŸ”’
use crate::helpers::impl_type_name; πŸ”’
use crate::helpers::is_altrep_struct; πŸ”’
use crate::helpers::parse_miniextendr_impl_attrs; πŸ”’

StructsΒ§

AttributedTraitImpl
CrateIndex
Shared parsed state for all lint rules.
FileData
HandBuilt πŸ”’
The types a file builds ExternalPtrs of itself (MXL121), in any item:
ImplMethodEntry
Per-method data collected during the crate-index pass for impl-method lint rules.
IndexError
Why CrateIndex::build failed, with the source files it had found.
InherentImpl
An inherent #[miniextendr] impl block, for the rules that look at a type across all its impl blocks (MXL121).
LintItem
ModDir πŸ”’
Where the mod declarations of one scope resolve, tracked as rustc does (rustc_expand::module).

EnumsΒ§

LintKind
MethodReceiverKind
Receiver kind for an impl method, mirroring ReceiverKind in miniextendr-macros.

ConstantsΒ§

INTO_SEXP_CALLS πŸ”’
into_sexp call spellings that build a fresh, unprotected SEXP.
NONAPI_ATTRIB_FNS πŸ”’
R’s non-API attribute-pairlist accessors. R CMD check (R >= 4.6) reports them.
RAW_R_EVAL_FNS πŸ”’
R entry points that run R code, or R’s interrupt handling, and longjmp out on an R error or a pending interrupt.
RETURN_WRAPPERS πŸ”’
The return wrappers collect_returned_types looks through. Keep in sync with the macro’s return vocabulary: the visibility markers (type_inspect::peel_return_visibility), the boundary containers and the class markers (return_wrap::resolve / marker_system), and ExternalPtr.
RF_ERROR_PATTERNS πŸ”’
Patterns that indicate direct Rf_error/Rf_errorcall calls in user code.

FunctionsΒ§

block_lines πŸ”’
The 1-based lines of block’s { and }.
called_idents πŸ”’
The whole identifiers in code that a ( follows (after optional whitespace): the names of the functions it calls or declares. DUPLICATE_ATTRIB( yields DUPLICATE_ATTRIB, never ATTRIB.
collect_active_cargo_features πŸ”’
Collect the set of active Cargo features from CARGO_FEATURE_* env vars. Feature names are normalized: CARGO_FEATURE_FOO_BAR β†’ "foo-bar".
collect_doc_pkg_links πŸ”’
Record the pkg::topic links in the docs of a #[miniextendr] item and, for an impl block, of its methods.
collect_items_recursive πŸ”’
Recursively collect all lint-relevant information from parsed items.
collect_returned_types πŸ”’
Add to out the type ty hands to R as a class object: its last path segment, self_type for Self, through the RETURN_WRAPPERS. Other names (i32, String, …) are added too; they match no class.
collect_rs_files_from_module_tree πŸ”’
Collect Rust source files by walking the module tree from the crate root, following mod child; declarations and respecting #[cfg(feature = "...")] gates via CARGO_FEATURE_* environment variables.
detect_receiver_kind πŸ”’
Detect the receiver kind from a method signature.
discover_mod_declarations πŸ”’
Walk parsed items looking for mod child; declarations and recurse.
eval_cfg_str πŸ”’
Try to evaluate a single cfg string like cfg(feature = "foo").
extract_feature_name πŸ”’
Extract the feature name from a string like feature="foo".
extract_param_names πŸ”’
Extract named parameter names (and their 1-based line numbers) from a function signature.
extract_return_type_str πŸ”’
Stringify a syn::ReturnType to a compact token string.
has_constructor_attr πŸ”’
Returns true when the attribute list contains #[miniextendr(constructor)] or #[miniextendr(r6(constructor))] / #[miniextendr(s3(constructor))] etc.
header_allows πŸ”’
Whether // mxl::allow(<code>) is on an item’s header: its lines first_line..=line (1-based: attributes, doc comments and the item’s own first line) or the line above them.
is_cfg_active πŸ”’
Evaluate whether a set of #[cfg(...)] attributes is active given the current features.
is_external_ptr_new πŸ”’
Whether path ends in ExternalPtr::new or ExternalPtr::new_unchecked, with or without a turbofish.
is_suppressed πŸ”’
Check if a lint code is suppressed via // mxl::allow(MXL...) comment.
line_has_allow πŸ”’
Check if a single line contains // mxl::allow(...) matching the given code.
parse_file πŸ”’
path_type_name πŸ”’
The type path names: its last segment, self_type for Self.
scan_ffi_unchecked_calls πŸ”’
Scan raw source text for sys::*_unchecked() calls.
scan_nonapi_attrib_calls πŸ”’
Scan raw source text for calls to, or declarations of, ATTRIB / SET_ATTRIB and their _unchecked forms.
scan_raw_r_eval_calls πŸ”’
Scan the FileData::miniextendr_bodies for calls to Rf_eval, R_forceAndCall, Rf_applyClosure and R_CheckUserInterrupt, and their _unchecked forms, through any path (sys::Rf_eval(, miniextendr_api::sys::Rf_eval(, an imported Rf_eval().
scan_rf_error_calls πŸ”’
Scan raw source text for direct Rf_error/Rf_errorcall calls.
scan_vec_into_sexp_calls πŸ”’
Scan raw source text for into_sexp() / into_sexp_unchecked() calls that appear inside a vec! or &[...] literal β€” the use-after-free idiom (#307, #1025).
self_handle_ty πŸ”’
The handle ty names over Self: "ExternalPtr" for ExternalPtr<Self>, "ExternalPtrRef" / "ExternalPtrMut" for the views (ExternalPtrRef<'_, Self>), matched on the last path segment with a Self type argument.
walk_module_file πŸ”’
Recursively walk a module file, following mod declarations.