Skip to content

cargo check --message-format json regression of error span data on empty main.rs file #68808

Closed
@Veetaha

Description

@Veetaha

Problem
cargo check --message-format json returns invalid span data, particularly line_end and line_start are set to 0, though it is guaranteed to be 1-based.
This happens with a completly empty main.rs file.

Tested on the following cargo version:
cargo 1.42.0-nightly (9d32b7b01 2020-01-26)

Whilst on the stable version the returned span array is empty:
cargo 1.41.0 (626f0f40e 2019-12-03)

Steps

  1. Clone this repo
  2. Run rustup default nightly
  3. Run cargo check --message-format json > check.json

Now you can see invalid span in check.json file.

I've already created and formatted check-1.41.json and check-1.42.json files with the output of different cargo versions.
Here are the crutial differences 1.41 and 1.42

Context
The issue was initially reported at rust-analyzer project repo here.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions