Skip to content

bare_trait_objects suggestion JSON includes stray suggestion #102902

Closed
@ehuss

Description

@ehuss

Given the following code:

pub type T = Copy;

Running rustc foo.rs --error=format=json produces two machine-applicable suggestions. One of them is an empty span which has no effect. The relevant part of the JSON output is:

{
    "message": "use `dyn`",
    "code": null,
    "level": "help",
    "spans":
    [
        {
            "file_name": "foo.rs",
            "byte_start": 13,
            "byte_end": 13,
            "line_start": 1,
            "line_end": 1,
            "column_start": 14,
            "column_end": 14,
            "is_primary": true,
            "text":
            [
                {
                    "text": "pub type T = Copy;",
                    "highlight_start": 14,
                    "highlight_end": 14
                }
            ],
            "label": null,
            "suggested_replacement": "dyn ",
            "suggestion_applicability": "MachineApplicable",
            "expansion": null
        },
        {
            "file_name": "foo.rs",
            "byte_start": 17,
            "byte_end": 17,
            "line_start": 1,
            "line_end": 1,
            "column_start": 18,
            "column_end": 18,
            "is_primary": true,
            "text":
            [
                {
                    "text": "pub type T = Copy;",
                    "highlight_start": 18,
                    "highlight_end": 18
                }
            ],
            "label": null,
            "suggested_replacement": "",
            "suggestion_applicability": "MachineApplicable",
            "expansion": null
        }
    ],
    "children":
    [],
    "rendered": null
}

Notice that the second suggestion is an empty string for an empty span.

I expect this to not emit an empty span suggestion.

rustc 1.66.0-nightly (8b0c05d9a 2022-10-07)
binary: rustc
commit-hash: 8b0c05d9ad7121cdb97600f261bcd5f04c8db20d
commit-date: 2022-10-07
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions