Skip to content

Specialized FnOnce impl compiles failed with a lengthy error message #58809

Open
@mzji

Description

@mzji

Playground Rustc version:

1.34.0-nightly 2019-02-27 7e001e5c6c7c090b4141

Code:

#![feature(unboxed_closures, fn_traits, specialization)]

use std::ops::{Deref, FnOnce};

struct Foo<T> {
    val: T,
}

default impl<'a, T> FnOnce<()> for &'a Foo<T> {
    type Output = &'a T;
    
    extern "rust-call" fn call_once(self, _args: ()) -> Self::Output {
        &self.val
    }
}

impl<'a, T: 'a, U: 'a> FnOnce<()> for &'a Foo<T> where T: Deref<Target = U> {
    type Output = &'a U;
    
    extern "rust-call" fn call_once(self, _args: ()) -> Self::Output {
        self.val.deref()
    }
}

fn main() {}

Error message:

   Compiling playground v0.0.1 (/playground)
error[E0275]: overflow evaluating the requirement `&Foo<_>: std::ops::FnOnce<()>`
  |
  = help: consider adding a `#![recursion_limit="128"]` attribute to your crate
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`
  = note: required because of the requirements on the impl of `std::ops::FnOnce<()>` for `&Foo<_>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0275`.
error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-specializationArea: Trait impl specializationC-enhancementCategory: An issue proposing an enhancement or a PR with one.F-specialization`#![feature(specialization)]`F-unboxed_closures`#![feature(unboxed_closures)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions