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

println!() with no trailing semicolon causes an error #3204

Closed
GrigorenkoPV opened this issue May 28, 2024 · 0 comments · Fixed by #3209
Closed

println!() with no trailing semicolon causes an error #3204

GrigorenkoPV opened this issue May 28, 2024 · 0 comments · Fixed by #3209
Labels
[C] Bug This is a bug. Something isn't working.

Comments

@GrigorenkoPV
Copy link
Contributor

I tried this code:

fn main() {
    println!()
}

using the following command line invocation:

kani test.rs

with Kani version: 0.51.0

I expected to see this happen: all is ok

Instead, this happened:

error: macro expansion ends with an incomplete expression: expected expression
 --> test.rs:2:5
  |
2 |     println!()
  |     ^^^^^^^^^^ expected expression
  |
  = note: the macro call doesn't expand to an expression, but it can expand to a statement
help: add `;` to interpret the expansion as a statement
  |
2 |     println!();
  |               +

error: aborting due to 1 previous error
@GrigorenkoPV GrigorenkoPV added the [C] Bug This is a bug. Something isn't working. label May 28, 2024
This was referenced May 28, 2024
zhassan-aws pushed a commit that referenced this issue May 29, 2024
GitHub closed the previous PR (#3205) after I renamed a branch, hooray.

Change the implementation of `println!` & `eprintln!` with no arguments
to call `print!("\n")`
& `eprint!("\n")` respectively instead of producing no tokens. This is
what std does. [^println][^eprintln]

 
[^println]:
https://github.com/rust-lang/rust/blob/8c127df75fde3d5ad8ef9af664962a7676288b52/library/std/src/macros.rs#L140
[^eprintln]:
https://github.com/rust-lang/rust/blob/8c127df75fde3d5ad8ef9af664962a7676288b52/library/std/src/macros.rs#L218

Resolves #3204.

A test included, as per
#3205 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant