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

Off-by-one in suggested fix for typos in macro names #47418

Closed
Vlad-Shcherbina opened this issue Jan 13, 2018 · 0 comments
Closed

Off-by-one in suggested fix for typos in macro names #47418

Vlad-Shcherbina opened this issue Jan 13, 2018 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.

Comments

@Vlad-Shcherbina
Copy link

Consider the following program:

fn main() {
    panec!()
}

Relevant part of the rustc .\src\main.rs --error-format=json output:

"spans": [
    {
        "file_name": ".\\src\\main.rs",
        "byte_start": 16,
        "byte_end": 21,
        "line_start": 2,
        "line_end": 2,
        "column_start": 5,
        "column_end": 10,
        "is_primary": true,
        "text": [
            {
                "text": "    panec!()",
                "highlight_start": 5,
                "highlight_end": 10
            }
        ],
        "label": null,
        "suggested_replacement": "panic!",
        "expansion": null
    }
],

So it suggests to replace fragment "panec" with "panic!", which results in extra exclamation point.


> rustc --version --verbose
rustc 1.25.0-nightly (61452e506 2018-01-09)
binary: rustc
commit-hash: 61452e506f0c88861cccaeea4ced3419bdb3cbe0
commit-date: 2018-01-09
host: x86_64-pc-windows-msvc
release: 1.25.0-nightly
LLVM version: 4.0
@nrc nrc added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. labels Jan 13, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 16, 2018
…suggestion, r=estebank

Don't include bang in macro replacement suggestion

When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code.

I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang.

Instead, just remove the bang from the suggested replacement.

Fixes rust-lang#47418

r? @estebank
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 16, 2018
…suggestion, r=estebank

Don't include bang in macro replacement suggestion

When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code.

I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang.

Instead, just remove the bang from the suggested replacement.

Fixes rust-lang#47418

r? @estebank
kennytm added a commit to kennytm/rust that referenced this issue Jan 17, 2018
…suggestion, r=estebank

Don't include bang in macro replacement suggestion

When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code.

I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang.

Instead, just remove the bang from the suggested replacement.

Fixes rust-lang#47418

r? @estebank
kennytm added a commit to kennytm/rust that referenced this issue Jan 17, 2018
…suggestion, r=estebank

Don't include bang in macro replacement suggestion

When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code.

I originally tried to extend the span to be replaced by 1 byte in rust-lang#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang.

Instead, just remove the bang from the suggested replacement.

Fixes rust-lang#47418

r? @estebank
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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants