Skip to content

Error span is in incorrect place due to Unicode fullwidth characters #45211

Closed
@hcpl

Description

@hcpl
$ rustc +nightly --version
rustc 1.22.0-nightly (d6d711dd8 2017-10-10)
$ uname -sri
Linux 4.2.0-42-generic x86_64

Code:

fn main() {
    let _ = ("こんにちは", 100i40);
}

rustc output:

error: invalid width `40` for integer literal
 --> main.rs:2:23
  |
2 |     let _ = ("こんにちは", 100i40);
  |                       ^^^^^^
  |
  = help: valid widths are 8, 16, 32, 64 and 128

error: aborting due to previous error

Activity

hcpl

hcpl commented on Oct 11, 2017

@hcpl
Author

GitHub renders fullwidth characters with width less than 2 monospace cells - the span actually starts under the last string char and ends under the 1 digit.

zackmdavis

zackmdavis commented on Oct 11, 2017

@zackmdavis
Member

possibly related to #44080?

hcpl

hcpl commented on Oct 11, 2017

@hcpl
Author

@zackmdavis yeah, totally. Also as revealed in #8706 this is likely the same issue which dates back to August 2013.
#21492 seems more appropriate than #8706 according to some comments there - and that should have been fixed by #21499 (as reported here).
Reverted by #24428 (info) => #8706 and #21492 still relevant (silly me, forgot looking at the latest comments in #8706).

Should I close it to decrease the noise/signal ratio or keep it to tell maintainers that this issue is persistent?

estebank

estebank commented on Oct 12, 2017

@estebank
Contributor

Just want to point out that the RLS, which is being distributed with the compiler, transitively depends on unicode-width due to a dependency on clap. I don't remember now if there was decision on avoiding depending on the external unicode-* crates that would allow the compiler to properly account for this. I think part of the discussions predates building rustc with cargo. @alexcrichton, if we don't mind adding that dependency, we can use the existing PRs previously fixing this to solve this once and for all. Thoughts?

added
A-diagnosticsArea: Messages for errors, warnings, and lints
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Oct 12, 2017
alexcrichton

alexcrichton commented on Oct 12, 2017

@alexcrichton
Member

Oh certainly, adding a dependency on unicode-width would be totally ok!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @alexcrichton@zackmdavis@estebank@hcpl

      Issue actions

        Error span is in incorrect place due to Unicode fullwidth characters · Issue #45211 · rust-lang/rust