Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type inference regression #112993

Closed
Greatness7 opened this issue Jun 24, 2023 · 2 comments · Fixed by #113007
Closed

Type inference regression #112993

Greatness7 opened this issue Jun 24, 2023 · 2 comments · Fixed by #113007
Assignees
Labels
C-bug Category: This is a bug. P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@Greatness7
Copy link

Greatness7 commented Jun 24, 2023

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

@Greatness7 Greatness7 added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Jun 24, 2023
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed regression-untriaged Untriaged performance or correctness regression. labels Jun 24, 2023
@chenyukang chenyukang self-assigned this Jun 24, 2023
@chenyukang
Copy link
Member

#112428
cc @compiler-errors

@compiler-errors
Copy link
Member

I can put up a fix for this. I suspected this might cause an issue but couldn't think how.

@compiler-errors compiler-errors self-assigned this Jun 24, 2023
@chenyukang chenyukang removed their assignment Jun 24, 2023
@workingjubilee workingjubilee added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 24, 2023
@bors bors closed this as completed in 75f6a7a Jun 25, 2023
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jul 7, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 7, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jul 7, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jul 8, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 8, 2023
…at-again, r=oli-obk

Structurally normalize again for byte string lit pat checking

We need to structurally normalize the pointee of a match scrutinee when trying to match byte string patterns -- we used[^1] to call `structurally_resolve_type`, which errors for type vars[^2], but lcnr added `try_structurally_resolve_type`[^3] in the mean time, which is the right thing to use here since it's totally opportunistic.

Fixes rust-lang/trait-system-refactor-initiative#38

[^1]: rust-lang#112428
[^2]: rust-lang#112993
[^3]: rust-lang#113086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants