Skip to content

Some missing type inference in last nightly #44973

Closed
@leonardo-m

Description

@leonardo-m

The latest Nightly (rustc 1.22.0-nightly f1b5225 2017-10-01, Gnu64) doesn't perform type inference in many cases, an example:

fn foo(mut n: u32, k: u32) -> u64 {
    let mut res: u64 = 1;
    for i in 0 .. k {
        res *= n.into();
        n -= 1;
        res /= i.into();
    }
    res % 1000
}
fn main() {}

Gives:

error[E0283]: type annotations required: cannot resolve `u64: std::ops::MulAssign<_>`
 --> ...\test.rs:4:13
  |
4 |         res *= n.into();
  |             ^^

I have seen several other cases of missed type inference in this Nightly, with sum() and product() in code that compiles every day since months.

The Beta and the Nightly of one or two days before doesn't show this problem.

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