Skip to content

Nightly shows confusing diagnostics mentioning ZeroablePrimitive without apparent reason #161882

Closed

Description

@Kixunil

I tried to convince the compiler to accept my use of ? operator via basically trait MaybeFallible where MyError: From<Self>, which I now suspect is impossible. Trying the new trait solver, I got weird errors about ZeroablePrimitive which I have never mentioned in the code nor did I mention NonZero anywhere. This may be related to the new solver, so cc #160895 but I'm not sure.

Code

I tried this code:

use std::convert::Infallible;

trait MaybeFallible {
    type Error: MaybeError;
    fn try_do_it(&self) -> Result<(), Self::Error>;
}

trait MaybeError: Sized + From<Infallible> + Into2<MyError> + where MyError: From<Self> /* ensures ? works */ {
    type ComposeWithOther<Other: MaybeError>: MaybeError + From<Self> + From<Other> where MyError: From<Other>, MyError: From<Self>;
}

impl MaybeError for Infallible {
    type ComposeWithOther<Other: MaybeError> = Other where MyError: From<Other>, MyError: From<Self>;
}

impl MaybeError for MyError {
    type ComposeWithOther<Other: MaybeError> = MyError where MyError: From<Other>, MyError: From<Self>;
}

fn compose<A: MaybeFallible, B: MaybeFallible>(a: A, b: B) -> Result<(), <A::Error as MaybeError>::ComposeWithOther<B::Error>> where <A::Error as MaybeError>::ComposeWithOther<B::Error>: From<B::Error> {
    a.try_do_it()?;
    b.try_do_it()?;
    Ok(())
}
    
struct MyError;

impl From<Infallible> for MyError {
    fn from(x: Infallible) -> Self {
        match x {}
    }
}

trait Into2<T: Sized + From<Self>>: Sized {}
impl<T, U: From<T>> Into2<U> for T {}

I expected to see this happen: no mentions of unrelated traits such as ZeroablePrimitive; any errors are only related to what I wrote.

Instead, this happened:

error[E0277]: the trait bound `MyError: ZeroablePrimitive` is not satisfied
  --> src/lib.rs:20:188
   |
20 | ... as MaybeError>::ComposeWithOther<B::Error>: From<B::Error> {
   |                                                 ^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the nightly-only, unstable trait `ZeroablePrimitive` is not implemented for `MyError`
  --> src/lib.rs:26:1

Version it worked on

It most recently worked on: 1.98.0

Version with regression

rustc --version --verbose:

1.100.0-nightly

(2026-08-26 bff8e12ff5e6bcd53dfb)

These are the versions currently on playground.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Activity

  1. added
    C-bugCategory: This is a bug.
    regression-untriagedUntriaged performance or correctness regression.
    on Aug 27, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    and removed
    regression-untriagedUntriaged performance or correctness regression.
    on Aug 27, 2026
  3. apiraino commented on Aug 28, 2026

    @apiraino
    Contributor

    As expected, the bisection leads to #160619 where the new trait solver has been enabled on nightly.
    Labelling accordingly.

    @rustbot label +wg-trait-system-refactor

  4. deleted a comment from rustbot on Aug 28, 2026
  5. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Sep 3, 2026
  6. LorrensP-2158466 commented on Sep 3, 2026

    @LorrensP-2158466
    Contributor

    A bit more reduced:

    use std::convert::Infallible;
    
    struct MyError;
    
    trait MaybeFallible {
        type Error: MaybeError;
    }
    
    trait MaybeError: Sized + From<Infallible>
    where
        MyError: From<Self>,
    {
        type ComposeWithOther: MaybeError + From<Self>;
    }
    
    fn compose<A: MaybeFallible, B: MaybeFallible>() -> Result<(), MyError>
    where
        <A::Error as MaybeError>::ComposeWithOther: From<B>,
    {
        todo!()
    }
  7. LorrensP-2158466 commented on Sep 3, 2026

    @LorrensP-2158466
    Contributor

    Even more with treereduce-rust (though idk if this is too far):

    use std::convert::Infallible;
    
    struct MyError;
    
    trait MaybeFallible {
        type Error: MaybeError;
    }
    
    trait MaybeError: Sized + From<Infallible>
    where
        MyError: From<Self>,
    {
        type ComposeWithOther: MaybeError + From<Self>;
    }
    
    fn compose<A: MaybeFallible, B: MaybeFallible>() -> Result<(), MyError>
    where
        <A::Error as MaybeError>::ComposeWithOther: From<B>,
    {
        todo!()
    }
  8. added this to the 1.100.0 milestone on Sep 25, 2026
  9. added 3 commits that reference this issue on Oct 9, 2026
    82f381f
    ebb9ae9
    cea8afc
  10. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 9, 2026
  11. added a commit that references this issue on Oct 9, 2026
    7763d17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-mediumMedium priorityWG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions