rust-lang/rust-analyzer · error

attempted to deserialize value that cannot set `PERSIST` to

Error message

attempted to deserialize value that cannot set `PERSIST` to false

What it means

The mirror `unimplemented!()` sentinel in `Configuration::deserialize` for `SyntaxContext`: since `PERSIST = false`, no serialized form of this struct should ever exist, so deserialization is never expected to be exercised. The panic fires when the deserializer is asked to materialize a `SyntaxContextData` from persisted data, which indicates the persisted stream and the current configuration disagree.

Source

Thrown at crates/span/src/hygiene.rs:129

        const DEBUG_NAME: &'static str = "SyntaxContextData";
        const REVISIONS: std::num::NonZeroUsize = std::num::NonZeroUsize::MAX;
        const PERSIST: bool = false;

        type Fields<'a> = SyntaxContextData;
        type Struct<'a> = SyntaxContext;

        fn serialize<S>(_: &Self::Fields<'_>, _: S) -> Result<S::Ok, S::Error>
        where
            S: zalsa_::serde::Serializer,
        {
            unimplemented!("attempted to serialize value that set `PERSIST` to false")
        }

        fn deserialize<'de, D>(_: D) -> Result<Self::Fields<'static>, D::Error>
        where
            D: zalsa_::serde::Deserializer<'de>,
        {
            unimplemented!("attempted to deserialize value that cannot set `PERSIST` to false");
        }
    }

    impl SyntaxContext {
        pub fn ingredient(zalsa: &zalsa_::Zalsa) -> &zalsa_struct_::IngredientImpl<Self> {
            static CACHE: zalsa_::IngredientCache<zalsa_struct_::IngredientImpl<SyntaxContext>> =
                zalsa_::IngredientCache::new();

            // SAFETY: The ingredient at offset 0 in `JarImpl<SyntaxContext>` has type
            // `IngredientImpl<SyntaxContext>`.
            unsafe { CACHE.get_or_create::<zalsa_struct_::JarImpl<SyntaxContext>, 0>(zalsa) }
        }
    }
    impl zalsa_::AsId for SyntaxContext {
        fn as_id(&self) -> salsa::Id {
            self.as_salsa_id().expect("`SyntaxContext::as_id()` called on a root `SyntaxContext`")
        }
    }

View on GitHub (pinned to e8f7e90aa3)

Solutions

  1. Check whether a stale on-disk database (written when the type was persistent) is being opened; clear/regenerate the salsa database
  2. Ensure no dependent struct marks `SyntaxContext` as persistable while its own configuration sets PERSIST=false
  3. Implement a reconstructing deserializer (e.g. map all contexts to the root context) if the type must round-trip
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/span/src/hygiene.rs:129 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rust-lang/rust-analyzer@e8f7e90aa3 (2026-09-03). Data as JSON: /api/errors/357dafac8ac5858a. Report an issue: GitHub.