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

manual_assert must not duplicate ending ";" inside impl #12505

Closed
matthiaskrgr opened this issue Mar 18, 2024 · 1 comment · Fixed by #12536
Closed

manual_assert must not duplicate ending ";" inside impl #12505

matthiaskrgr opened this issue Mar 18, 2024 · 1 comment · Fixed by #12536
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 18, 2024

Summary

looks like a simple off-by-one error; the span is just outside of the ; but then we add the new expr with ANOTHER ; resulting in ;; and rustc doesnt like that :D

Reproducer

I tried this code:

//@ build-pass

// issue 122301 - currently the only way to supress
// const eval and codegen of code conditional on some other const
#![allow(clippy::all)]
#![warn(clippy::manual_assert)]


struct Foo<T, const N: usize>(T);

impl<T, const N: usize> Foo<T, N> {
    const BAR: () = if N == 0 {
        panic!()
    };
}


fn main() {

}

I expected to see this happen:
build pass
Instead, this happened:

error: non-item in item list
  --> src/main.rs:12:42
   |
11 | impl<T, const N: usize> Foo<T, N> {
   |                                   - item list starts here
12 |     const BAR: () = assert!(!(N == 0), );;
   |                                          ^ non-item starts here
13 | }
   | - item list ends here

Version

rustc 1.79.0-nightly (3cdcdaf31 2024-03-18)
binary: rustc
commit-hash: 3cdcdaf31b45f8045164aae9604573d23091970b
commit-date: 2024-03-18
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Additional Labels

No response

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Mar 18, 2024
@matthiaskrgr matthiaskrgr changed the title manual_assert must not duplicate ending ";" manual_assert must not duplicate ending ";" inside impl Mar 18, 2024
@samueltardieu
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants