{"id":"63581b6cfeac23bc","repo":"rust-lang/rust","slug":"this-deprecation-is-always-in-effect-since","errorCode":null,"errorMessage":"this deprecation is always in effect; {since:?}","messagePattern":"this deprecation is always in effect; (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_middle/src/middle/stability.rs","lineNumber":181,"sourceCode":"            diag.subdiagnostic(sub);\n        }\n        diag\n    }\n}\n\nfn deprecated_since_kind(is_in_effect: bool, since: DeprecatedSince) -> DeprecatedSinceKind {\n    if is_in_effect {\n        DeprecatedSinceKind::InEffect\n    } else {\n        match since {\n            DeprecatedSince::RustcVersion(version) => {\n                DeprecatedSinceKind::InVersion(version.to_string())\n            }\n            DeprecatedSince::Future => DeprecatedSinceKind::InFuture,\n            DeprecatedSince::NonStandard(_)\n            | DeprecatedSince::Unspecified\n            | DeprecatedSince::Err => {\n                unreachable!(\"this deprecation is always in effect; {since:?}\")\n            }\n        }\n    }\n}\n\npub fn early_report_macro_deprecation(\n    lint_buffer: &mut LintBuffer,\n    depr: &Deprecation,\n    suggestion_span: Span,\n    node_id: NodeId,\n    path: String,\n) {\n    if suggestion_span.in_derive_expansion() {\n        return;\n    }\n\n    let is_in_effect = depr.is_in_effect();\n    let suggestion = depr.suggestion;","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_middle/src/middle/stability.rs#L163-L199","documentation":"This `unreachable!` fires in `deprecated_since_kind` when a deprecation's `since` field is `NonStandard`, `Unspecified`, or `Err` yet `is_in_effect` returned `false`. Those three `DeprecatedSince` variants *mean* the deprecation is always in effect, so the function should have taken the `DeprecatedSinceKind::InEffect` branch at stability.rs:171 and never reached the match on `since`. Hitting it indicates a contradictory `Deprecation` value — the `since` field and `is_in_effect()` disagree — produced upstream by stability-attribute decoding/HIR processing.","triggerScenarios":"Decoding a `#[deprecated(since = ...)]` attribute whose `since` value resolves to `NonStandard(s)`, `Unspecified`, or `Err` while `Deprecation::is_in_effect()` simultaneously returns false. Concretely: a corrupted rmeta/crate metadata block for a stability attribute, a hand-constructed `Deprecation` struct in tests/fuzzers, or a regression in `rustc_ast::decode` / the stability query that miscomputes `is_in_effect`.","commonSituations":"Fuzzing the compiler with malformed `#[deprecated]` attributes; cross-version rmeta incompatibilities after a stability-query refactor; crates built with mismatched std/core stability metadata; custom rustc forks that altered `DeprecatedSince` encoding.","solutions":["Inspect the offending crate's `#[deprecated(since = \"...\")]` attribute and supply a valid SemVer/RustcVersion string or remove the attribute.","If reproducing from metadata, force a clean rebuild (`cargo clean`) to regenerate rmeta so stale stability data does not survive a toolchain change.","File an ICE report against rustc including the attribute text and the `since` value from the panic message; this path is meant to be unreachable.","For rustc hackers: audit the function populating `Deprecation.since` to ensure it sets `is_in_effect=true` for NonStandard/Unspecified/Err."],"exampleFix":"// before\n#[deprecated(since = \"??\", note = \"x\")]\n// (decodes to DeprecatedSince::Err with is_in_effect == false → unreachable!)\n\n// after\n#[deprecated(since = \"1.65.0\", note = \"x\")]","handlingStrategy":"validation","validationCode":"// deprecated_since_kind is unreachable when is_in_effect == false AND since is\n// NonStandard | Unspecified | Err. Reject that combination before relying on it.\nfn deprecation_kind_safe(is_in_effect: bool, since: &DeprecatedSince) -> bool {\n    if is_in_effect {\n        return true; // any `since` is fine\n    }\n    matches!(\n        since,\n        DeprecatedSince::RustcVersion(_) | DeprecatedSince::Future\n    )\n}\n\nif !deprecation_kind_safe(is_in_effect, &since) {\n    // Either force is_in_effect=true, or repair `since` to a concrete version.\n    return Err(\"deprecation not in effect and `since` carries no version\");\n}","typeGuard":null,"tryCatchPattern":"let kind = std::panic::catch_unwind(|| deprecated_since_kind(is_in_effect, since.clone()));\nmatch kind {\n    Ok(k) => /* use k */,\n    Err(_) => /* fall back to treating the item as deprecated-now */,\n}","preventionTips":["When authoring #[deprecated] attributes, always supply a concrete `since` version instead of leaving it unspecified.","Before querying deprecation status, confirm `is_in_effect`; the unspecified/Err/Future variants are only reachable on the not-yet-in-effect path with a real version or Future marker.","Do not synthesize DeprecatedSince::Err or NonStandard values in tooling that later flows into this function; remap them to a real version first.","If you consume deprecation metadata from an external source, normalize it to RustcVersion(_) or Future before passing it downstream."],"tags":["rustc","stability","deprecation","internal","compiler-ice"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}