{"record":{"id":"62c9b12f907267cf","repo":"gfx-rs/wgpu","slug":"earlier-check-of-enabled-backend-features-should","errorCode":null,"errorMessage":"Earlier check of `enabled_backend_features` should have prevented getting here!","messagePattern":"Earlier check of `enabled_backend_features` should have prevented getting here!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu/src/api/instance.rs","lineNumber":100,"sourceCode":"\n            if is_only_available_backend || (requested_webgpu && support_webgpu) {\n                return Self {\n                    inner: crate::backend::ContextWebGpu::new(desc).into(),\n                };\n            }\n        }\n\n        #[cfg(wgpu_core)]\n        {\n            return Self {\n                inner: crate::backend::ContextWgpuCore::new(desc).into(),\n            };\n        }\n\n        // Silence unused variable warnings without adding _ to the parameter name (which shows up in docs).\n        let _ = desc;\n\n        unreachable!(\n            \"Earlier check of `enabled_backend_features` should have prevented getting here!\"\n        );\n    }\n\n    /// Returns which backends can be picked for the current build configuration.\n    ///\n    /// The returned set depends on a combination of target platform and enabled features.\n    /// This does *not* do any runtime checks and is exclusively based on compile time information.\n    ///\n    /// `InstanceDescriptor::backends` does not need to be a subset of this,\n    /// but any backend that is not in this set, will not be picked.\n    pub const fn enabled_backend_features() -> Backends {\n        let mut backends = Backends::empty();\n        // `.set` and `|=` don't work in a `const` context.\n        if cfg!(noop) {\n            backends = backends.union(Backends::NOOP);\n        }\n        if cfg!(vulkan) {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu/src/api/instance.rs#L82-L118","documentation":"`Instance::new` in the wgpu crate enumerates compiled-in backends (Vulkan, Metal, DX12, GL, WebGPU) and creates the first available one. If no backend was compiled in or all backends failed to initialize, this final unreachable! fires — it is supposed to be prevented by an earlier check of `enabled_backend_features`, so hitting it indicates either a no-backend build or a wgpu bug.","triggerScenarios":"Calling `Instance::new(&desc)` in a build where no graphics backend feature is enabled (or all enabled backends fail their runtime guards), so backend enumeration falls through to the terminal unreachable!.","commonSituations":"Building for a platform/target with all backend cargo features disabled; compiling with `default-features = false` and forgetting to add a backend feature; WebGPU builds where the browser environment lacks WebGPU but backends were filtered out earlier than expected.","solutions":["Enable at least one backend feature in Cargo.toml, e.g. `wgpu = { version = \"...\", features = [\"vulkan\"] }` or restore `default-features = false, features = [\"wgsl\", \"vulkan\", \"metal\", \"dx12\", \"gl\"]`","Check the target platform supports an enabled backend and that runtime prerequisites (drivers, Vulkan loader) are present","Call `Instance::enabled_backends()` / check available backends before creating an instance and handle the empty case gracefully","Update wgpu — if backends are enabled and available yet this still fires, it is a bug; file an issue"],"exampleFix":"// before\nwgpu = { version = \"26\", default-features = false, features = [\"wgsl\"] } // no backend\n// after\nwgpu = { version = \"26\", default-features = false, features = [\"wgsl\", \"vulkan\"] }","handlingStrategy":"validation","validationCode":"let backends = Instance::enabled_backends();\nif backends.is_empty() {\n    eprintln!(\"no wgpu backend compiled in — enable a backend cargo feature\");\n    std::process::exit(1);\n}","typeGuard":"fn has_backend() -> bool {\n    !wgpu::Instance::enabled_backends().is_empty()\n}","tryCatchPattern":null,"preventionTips":["Never build with default-features=false without adding at least one backend feature","Check enabled_backends() at startup before creating an Instance","Verify driver/loader prerequisites exist on the target platform","Use feature-gated fallbacks (e.g. GL) for headless or minimal environments"],"tags":["wgpu","instance","no-backend","build-configuration","panic"],"backgroundTag":"no-backend-compiled-in","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}