GitoxideLabs/gitoxide · info

this impl is needed to allow passing a known valid partial…

Error message

this impl is needed to allow passing a known valid partial path as parameter

What it means

This is not a real runtime error: it is a `From<Infallible>` impl on the `gix-ref` general-store find error enum whose body calls `unreachable!()`. It exists only so callers can pass anything convertible to a `&PartialNameRef` (including infallible conversions like `&str`) to `Handle::try_find`. Since `Infallible` can never be instantiated, the panic branch is unreachable by construction.

Solutions

  1. Do nothing; this error can never be produced at runtime.
  2. If you see this panic, file a bug against gix-ref — it indicates a broken internal invariant.
  3. If your own code fails to compile due to a missing `From` bound, use the same `From<Infallible>` trick for infallible conversions.
Defensive patterns

Strategy: validation

Type guard

fn is_real_error(err: &gix_ref::store::handle::find::Error) -> bool { !matches!(err, _ /* Infallible branch is uninhabitable */) }

Prevention

When it happens

Trigger: Never triggered at runtime. The only way to reach it is a library-internal bug that manufactures an `Infallible` value, or directly calling `Error::from(Infallible)` in test code with a `match _ {}` workaround.

Common situations: Developers may encounter this line while reading or debugging the ref lookup code, or when a generic caller fails to compile because the `Error: From<E>` bound is not satisfied — the impl exists to satisfy that bound.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/0a748742a5b8f7dc. Report an issue: GitHub.

Appendix: source

Thrown at gix-ref/src/store/general/handle/find.rs:18

use crate::{PartialNameRef, Reference, store};

mod error {
    use std::convert::Infallible;

    /// The error returned by [`crate::file::Store::find_loose()`].
    #[derive(Debug, thiserror::Error)]
    #[expect(missing_docs)]
    pub enum Error {
        #[error("An error occurred while finding a reference in the loose file database")]
        Loose(#[from] crate::file::find::Error),
        #[error("The ref name or path is not a valid ref name")]
        RefnameValidation(#[from] crate::name::Error),
    }

    impl From<Infallible> for Error {
        fn from(_: Infallible) -> Self {
            unreachable!("this impl is needed to allow passing a known valid partial path as parameter")
        }
    }
}

pub use error::Error;

use crate::store::handle;

impl store::Handle {
    /// TODO: actually implement this with handling of the packed buffer.
    pub fn try_find<'a, Name, E>(&self, partial: Name) -> Result<Option<Reference>, Error>
    where
        Name: TryInto<&'a PartialNameRef, Error = E>,
        Error: From<E>,
    {
        let _name = partial.try_into()?;
        match &self.state {
            handle::State::Loose { .. } => {

View on GitHub (pinned to e73179060b)