Skip to content

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

Closed
@joIivier

Description

@joIivier

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions