Skip to content

Type inference regression from 1.14.0 to 1.15.0 #41194

Closed
@jethrogb

Description

@jethrogb

This code:

struct S {
    v: Vec<(u32, Vec<u32>)>,
}

impl S {
    pub fn remove(&mut self, i: u32) -> Option<std::vec::Drain<u32>> {
        self.v.get_mut(i as _ /*usize*/).map(|&mut (_, ref mut v2)| {
            v2.drain(..)
        })
    }
}

stopped compiling in 1.15.0 with:

error: the type of this value must be known in this context
 --> src/main.rs:8:16
  |
8 |             v2.drain(..)
  |                ^^^^^

If you change the cast on line 7 to the concrete type usize, it compiles fine on 1.15.0 (and later)

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions