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

assert!(); without arguments breaks compilation with unclear error message (no file name, line info) #55547

Closed
joIivier opened this issue Oct 31, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@joIivier
Copy link

joIivier commented Oct 31, 2018

I forgot a lone debug_assert!(); without any arguments given to the macro. This was in one of the modules of my code (not lib.rs). The consequences are quite painful:
The compilation fails with:

Compiling common v0.1.0 ([PROJECT_FOLDER]/server/common)
       Fresh trust-dns-resolver v0.9.1
     Running `rustc --crate-name common common/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=ed2951e164923260 -C extra-filename=-ed2951e164923260 --out-dir [PROJECT_FOLDER]/server/target/debug/deps -C incremental=[PROJECT_FOLDER]/server/target/debug/incremental -L dependency=[PROJECT_FOLDER]/server/target/debug/deps --extern chrono=[PROJECT_FOLDER]/server/target/debug/deps/libchrono-2a34936974216bbe.rlib --extern postgres_derive=[PROJECT_FOLDER]/server/target/debug/deps/libpostgres_derive-105c95cb7f81b919.so --extern postgres=[PROJECT_FOLDER]/server/target/debug/deps/libpostgres-e0f1a258f5f96310.rlib --extern rand=[PROJECT_FOLDER]/server/target/debug/deps/librand-29a12d49764c391a.rlib --extern serde=[PROJECT_FOLDER]/server/target/debug/deps/libserde-47086ec69add4c66.rlib --extern serde_derive=[PROJECT_FOLDER]/server/target/debug/deps/libserde_derive-d6a05fd64d058694.so --extern serde_json=[PROJECT_FOLDER]/server/target/debug/deps/libserde_json-ceb058322f4f1956.rlib --extern toml=[PROJECT_FOLDER]/server/target/debug/deps/libtoml-817bfdd57b367d83.rlib`
       Fresh actix v0.7.4
       Fresh actix-web v0.7.8
error: expected expression, found `<eof>`

error: aborting due to previous error

error: Could not compile `common`.

Caused by:
  process didn't exit successfully: `rustc --crate-name common common/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=ed2951e164923260 -C extra-filename=-ed2951e164923260 --out-dir [PROJECT_FOLDER]/server/target/debug/deps -C incremental=[PROJECT_FOLDER]/server/target/debug/incremental -L dependency=[PROJECT_FOLDER]/server/target/debug/deps --extern chrono=[PROJECT_FOLDER]/server/target/debug/deps/libchrono-2a34936974216bbe.rlib --extern postgres_derive=[PROJECT_FOLDER]/server/target/debug/deps/libpostgres_derive-105c95cb7f81b919.so --extern postgres=[PROJECT_FOLDER]/server/target/debug/deps/libpostgres-e0f1a258f5f96310.rlib --extern rand=[PROJECT_FOLDER]/server/target/debug/deps/librand-29a12d49764c391a.rlib --extern serde=[PROJECT_FOLDER]/server/target/debug/deps/libserde-47086ec69add4c66.rlib --extern serde_derive=[PROJECT_FOLDER]/server/target/debug/deps/libserde_derive-d6a05fd64d058694.so --extern serde_json=[PROJECT_FOLDER]/server/target/debug/deps/libserde_json-ceb058322f4f1956.rlib --extern toml=[PROJECT_FOLDER]/server/target/debug/deps/libtoml-817bfdd57b367d83.rlib` (exit code: 1)

So the issue is that I expected an error message indicating the file where my wrong macro call was made and the line number. Instead I got this error message with no location information nor any reference to a macro. I had to comment/uncomment all my new modules/functions/lines to find my incorrect macro call.

I could reproduce the issue with assert!();, but not with format!(); the later gives a useful error message ([rustc] requires at least a format string argument). So this must affect only some macros.

Meta

rustc --version --verbose rustc 1.30.0 (da5f414c2 2018-10-24) binary: rustc commit-hash: da5f414c2c0bfe5198934493f04c676e2b23ff2e commit-date: 2018-10-24 host: x86_64-unknown-linux-gnu release: 1.30.0 LLVM version: 8.0

@joIivier joIivier changed the title assert!(); without arguments breaks parser with unclear error message (no file name, line info) assert!(); without arguments breaks compilation with unclear error message (no file name, line info) Oct 31, 2018
@estebank
Copy link
Contributor

Can you check your code against nightly? I believe this might have been fixed by #55292.

@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 31, 2018
@zackmdavis
Copy link
Member

still an issue on nightly: playground link

euclio added a commit to euclio/rust that referenced this issue Dec 4, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants