Skip to content

Inference regression on nightly #44998

Closed
Closed
@vickenty

Description

@vickenty

This works on stable and beta, fails to compile on nightly.

(Playground)

trait Make {
    fn make() -> Self;
}

impl Make for f64 {
    fn make() -> f64 {
        1.0
    }
}

fn make_value<T: Make>() -> T {
    T::make()
}

fn main() {
    let mut sum = 0.0;
    
    let val = make_value();
    sum += val;
    
    println!("{:}", sum);
}
error[E0282]: type annotations needed
  --> src/main.rs:18:9
   |
18 |     let val = make_value();
   |         ^^^
   |         |
   |         cannot infer type for `_`
   |         consider giving `val` a type

Versions tried:

rustc 1.20.0 (f3d6973f4 2017-08-27) - works
rustc 1.21.0-beta.3 (ea1fd7d42 2017-09-15) - works
rustc 1.22.0-nightly (185cc5f26 2017-10-02) - fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions