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

Apply De Morgan's Law misses precedence of operations #17185

Closed
l4l opened this issue May 4, 2024 · 1 comment · Fixed by #17187
Closed

Apply De Morgan's Law misses precedence of operations #17185

l4l opened this issue May 4, 2024 · 1 comment · Fixed by #17187
Assignees
Labels
C-bug Category: bug

Comments

@l4l
Copy link

l4l commented May 4, 2024

Assist apply_demorgan for a && !(a && b) pointed at second operation produces a && !a || !b which is incorrect because the precedence of || is missed. Or more formally as a test:

#[test]
fn demorgan_keep_pars_for_op_precedence1() {
    check_assist(
        apply_demorgan,
        "fn f() { (a && !(b &&$0 c); }",
        "fn f() { (a && (!b || !c); }",
    );
}

Related #15239.


rust-analyzer version: rust-analyzer 1.76.0 (07dca48 2024-02-04)

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

editor or extension: helix

@l4l l4l added the C-bug Category: bug label May 4, 2024
@roife
Copy link
Contributor

roife commented May 5, 2024

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
2 participants