Skip to content

-Znext-solver=globally failed to satisfy std::ops::Residual #119293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
numas13 opened this issue Dec 25, 2023 · 1 comment
Closed

-Znext-solver=globally failed to satisfy std::ops::Residual #119293

numas13 opened this issue Dec 25, 2023 · 1 comment
Assignees
Labels
C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Comments

@numas13
Copy link

numas13 commented Dec 25, 2023

I tried to compile crate syn (2.0.37/2.0.43/master) with -Znext-solver=globally and got errors:

error[E0284]: type annotations needed: cannot satisfy `<std::result::Result<restriction::Visibility, error::Error> as std::ops::Try>::Residual == <std::result::Result<_, error::Error> as std::ops::Try>::Residual`
   --> src/data.rs:166:56                                                                                 
    |                                                                                                                                                                                                               
166 |             let _visibility: Visibility = input.parse()?;
    |                                                        ^ cannot satisfy `<std::result::Result<restriction::Visibility, error::Error> as std::ops::Try>::Residual == <std::result::Result<_, error::Error> as s
td::ops::Try>::Residual`                                                        

This is short example to reproduce:

#![crate_type="lib"]

pub trait Trait: Sized {
    fn foo(_: &S) -> Result<Self, ()>;
}

impl Trait for () {
    fn foo(_: &S) -> Result<Self, ()> {
        Ok(())
    }
}

pub struct S;

impl S {
    pub fn baz<T: Trait>(&self) -> Result<T, ()> {
        T::foo(self)
    }

    pub fn call<T>(&self, f: fn(&S) -> Result<T, ()>) -> Result<T, ()> {
        f(self)
    }
}

fn bar(_: &S) -> Result<(), ()> {
    Ok(())
}

pub fn test(s: &S) -> Result<(), ()> {
    let _ = s.call(bar)?;
    Ok(s.baz()?)
}

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (bf8716f1c 2023-12-24)
binary: rustc
commit-hash: bf8716f1cd6416266807706bcae0ecb2e51c9d4a
commit-date: 2023-12-24
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
@numas13 numas13 added the C-bug Category: This is a bug. label Dec 25, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 25, 2023
@compiler-errors
Copy link
Member

This is fixed by #119106.

@compiler-errors compiler-errors added T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 25, 2023
@numas13 numas13 closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

No branches or pull requests

4 participants