Skip to content

Type inference regression #112993

Closed
Closed
@Greatness7

Description

@Greatness7

This code previously compiled fine, but as of ~2 weeks ago it began to fail on nightly and has continued to do so since.

fn load<L>() -> Option<L> {
    todo!()
}

fn main() {
    while let Some(tag) = load() {
        match &tag {
            b"NAME" => {}
            b"DATA" => {}
            _ => {}
        }
    }
}
error[E0282]: type annotations needed
 --> src\main.rs:6:27
  |
6 |     while let Some(tag) = load() {
  |                           ^^^^ cannot infer type of the type parameter `L` declared on the function `load`
7 |         match &tag {
8 |             b"NAME" => {}
  |             ------- type must be known at this point
  |
help: consider specifying the generic argument
  |
6 |     while let Some(tag) = load::<L>() {
  |

Version it worked on

rustc 1.72.0-nightly (8b35c0bb0 2023-06-08)
binary: rustc
commit-hash: 8b35c0bb0f833c0077dc57006eb317edde2a2d1e
commit-date: 2023-06-08
host: x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.5

Version with regression

rustc 1.72.0-nightly (43062c43d 2023-06-09)
binary: rustc
commit-hash: 43062c43d2a63cf4e261c6eddc417575c4f3062f
commit-date: 2023-06-09
host: x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.5

p.s. Is the output of rustc --version --verbose suppose to be one day behind compared to the toolchain name? In any case, nightly-2023-06-09-x86_64-pc-windows-msvc was the last working version, nightly-2023-06-10-x86_64-pc-windows-msvc and onward trigger the error.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Labels

C-bugCategory: This is a bug.P-lowLow priorityregression-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