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

Tuple pattern failure causes panic in Rust Analyzer debug build #17585

Closed
ShoyuVanilla opened this issue Jul 12, 2024 · 6 comments · Fixed by #17649
Closed

Tuple pattern failure causes panic in Rust Analyzer debug build #17585

ShoyuVanilla opened this issue Jul 12, 2024 · 6 comments · Fixed by #17649
Assignees
Labels
A-diagnostics diagnostics / error reporting A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@ShoyuVanilla
Copy link
Member

ShoyuVanilla commented Jul 12, 2024

Edit: At first, I thought that this was regression between lastest release and HEAD, but this happens debug but not on release profile 🤔

rust-analyzer version: HEAD of master branch, ffbc5ad993d5cd2f3b8bcf9a511165470944ab91

rustc version: rustc 1.79.0 (129f3b996 2024-06-10)

code snippet to reproduce:

fn main() {
    let (_, _, _, ..) = (true, 42);
}

Running rust-analyzer diagnostics on the following code in ffbc5ad993d5cd2f3b8bcf9a511165470944ab91 with debug profile panics with following;

thread 'BIG_STACK_THREAD' panicked at crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:507:9:
internal error: entered unreachable code: uncaught type error: pattern <write_variant_name unsupported>(_ : Bool, _ : Int(I32), _ : {error}) has inconsistent arity (expected arity <= 2)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

while running it on the same revision with release profile works just fine;

2024-07-12T21:39:03.778314Z ERROR hir_ty::diagnostics::match_check::pat_analysis: uncaught type error: pattern <write_variant_name unsupported>(_ : Bool, _ : Int(I32), _ : {error}) has inconsistent arity (expected arity <=
2)
Diagnostic { code: RustcHardError("E0308"), message: "expected (bool, i32), found (bool, i32, {unknown})", range: FileRange { file_id: FileId(11), range: 20..33 }, severity: Error, unused: false, experimental: true, fixes:
None, main_node: None }

diagnostic scan complete

Error: diagnostic error detected
@ShoyuVanilla ShoyuVanilla added the C-bug Category: bug label Jul 12, 2024
@ShoyuVanilla
Copy link
Member Author

ShoyuVanilla commented Jul 12, 2024

I'll try bisect some hours later this happens between debug and release profiles 🤔

@ShoyuVanilla ShoyuVanilla changed the title Tuple pattern failure causes panic in Rust Analyzer Tuple pattern failure causes panic in Rust Analyzer debug build Jul 12, 2024
@lnicola
Copy link
Member

lnicola commented Jul 13, 2024

We panic on some errors in development builds.

@lnicola lnicola added A-diagnostics diagnostics / error reporting A-ty type system / type inference / traits / method resolution labels Jul 13, 2024
@ShoyuVanilla
Copy link
Member Author

Oh, I see. I'll dig into this more.
@rustbot claim

@lnicola
Copy link
Member

lnicola commented Jul 13, 2024

The code that calls bug is in rustc_pattern_analysis, which isn't robust to type errors. In other places we try to ignore them, see #17534.

@ShoyuVanilla
Copy link
Member Author

The code that calls bug is in rustc_pattern_analysis, which isn't robust to type errors.

That's sad 😢

@Veykril
Copy link
Member

Veykril commented Jul 13, 2024

We are already doing mismatch checks for match exhaustiveness checking, we are probably not doing the same for checking let statements?

@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label Jul 16, 2024
@bors bors closed this as completed in 8d489e2 Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants