{"record":{"id":"faa3e8ca525e2b27","repo":"pola-rs/polars","slug":"activate-feature","errorCode":null,"errorMessage":"activate '{}' feature","messagePattern":"activate '(.+?)' feature","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-error/src/lib.rs","lineNumber":677,"sourceCode":"}\n\n#[inline]\n#[cold]\n#[must_use]\npub fn to_compute_err(err: impl Display) -> PolarsError {\n    PolarsError::ComputeError(err.to_string().into())\n}\n\n#[macro_export]\nmacro_rules! feature_gated {\n    ($($feature:literal);*, $content:expr) => {{\n        #[cfg(all($(feature = $feature),*))]\n        {\n            $content\n        }\n        #[cfg(not(all($(feature = $feature),*)))]\n        {\n            panic!(\"activate '{}' feature\", concat!($($feature, \", \"),*))\n        }\n    }};\n}\n\n// Not public, referenced by macros only.\n#[doc(hidden)]\npub mod __private {\n    #[doc(hidden)]\n    #[inline]\n    #[cold]\n    #[must_use]\n    pub const fn must_use(error: crate::PolarsError) -> crate::PolarsError {\n        error\n    }\n\n    pub const fn has_brace(s: &str) -> bool {\n        let bytes = s.as_bytes();\n        let mut i: usize = 0;","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-error/src/lib.rs#L659-L695","documentation":"This is the implementation of polars' feature-gating macro (feature_gated!-style). It compiles the gated content only when ALL listed cargo features are enabled; otherwise it emits panic!(\"activate '{}' feature\", ...). The panic text is a template — the actual message names the missing features. It means a code path was reached that requires cargo features the build does not have.","triggerScenarios":"Calling any polars API wrapped in this macro (e.g. dtype-specific or algorithm-specific functionality) without the corresponding cargo feature(s) enabled.","commonSituations":"Default-features-off builds; picking features piecemeal from docs; a dependency enabling a polars API path but not the matching feature; upgrading polars where features were split or renamed.","solutions":["Read the full panic message to get the exact feature list requested","Add the named features to the polars dependency in Cargo.toml","Check unified feature resolution with `cargo tree -e features` — a crate with default-features = false may be stripping what you enabled","If the feature cannot be enabled (e.g. size constraints), route around the gated API at runtime by branching on your own configuration before calling it"],"exampleFix":"// before\npolars = { version = \"0.46\", default-features = false, features = [\"lazy\"] }\n// after\npolars = { version = \"0.46\", default-features = false, features = [\"lazy\", \"dtype-u8\", \"dtype-i8\"] }","handlingStrategy":"validation","validationCode":"// build-time check\nfn main() {\n    // the panic message names the missing features; ensure them in Cargo.toml\n}\n// or gate your own code:\n#[cfg(not(feature = \"polars/dtype-duration\"))]\ncompile_error!(\"enable required polars features\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a single canonical polars feature list for the workspace","Audit `cargo tree -e features` in CI for feature unification surprises","Read the full panic message — it lists exactly which features to enable"],"tags":["rust","feature-flags","polars","macro"],"backgroundTag":"feature-not-enabled","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}