Skip to content

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

Closed
@numas13

Description

@numas13

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions