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

span information is mistaken in the presence of combining characters #3260

Closed
msullivan opened this issue Aug 23, 2012 · 6 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-Unicode Area: Unicode

Comments

@msullivan
Copy link
Contributor

rustc reckons spans in terms of unicode code points, which causes problems when faced with combining characters. When the following code is compiled

fn main() {
    let s = ~"ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while true { break; }
    io::println(s);
    log(error, s);
}

rustc will produce the following screwed up diagnostic:

./nubs/utf8-combining.rs:2:45: 2:66 warning: denote infinite loops with loop { ... }
./nubs/utf8-combining.rs:2     let s = ~"ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while true { break; }
                                                                        ^~~~~~~~~~~~~~~~~~~~~

emacs tells me that the while loop starts in column 23. (Interestingly, emacs seems to split up the combining characters when it displays them, presumably for easier editing, but doesn't advance the column numbers.)

@graydon
Copy link
Contributor

graydon commented Aug 30, 2012

Yeah. Fixing this will have to wait on us binding to libICU in libstd, most likely. It's beyond the scope of the unicode-isms that libcore understands.

@sanxiyn
Copy link
Member

sanxiyn commented Feb 9, 2013

Apart from combining characters, "wide" characters should be considered to occupy 2 columns. See http://www.unicode.org/reports/tr11/ for details.

@msullivan
Copy link
Contributor Author

This seems to be fixed.

@felixc
Copy link
Contributor

felixc commented Feb 25, 2014

Apologies for reviving this, but I think there's either been a mistake, a regression, or I've completely misunderstood the bug.

When I compile

use std::io;

fn main() {
    let s = ~"ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while true { break; }
    io::println(s);
}

I get the a more or less equivalent diagnostic:

main.rs:4:46: 4:67 warning: denote infinite loops with loop { ... }, #[warn(while_true)] on by default
main.rs:4     let s = ~"ZͨA͑ͦ͒͋ͤ̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while true { break; }
                                                       ^~~~~~~~~~~~~~~~~~~~~

Crucially, the character span is still off; though it's now 46-67. Unless I'm missing something, it seems like this should be reopened?

@huonw
Copy link
Member

huonw commented Feb 25, 2014

It's open as #8706.

(The issue is we compute spans with codepoints, not graphemes.)

@felixc
Copy link
Contributor

felixc commented Feb 25, 2014

Ah; thank you! This FIXME sent me to the wrong place, then: https://github.com/mozilla/rust/blob/master/src/libsyntax/diagnostic.rs#L316

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
Do not modify original source code inside macro call
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jan 8, 2024
Check if tier 2 targets build in the nightly cron job

This PR adds a CI job that only runs nightly which will install Miri built from the latest commit, and try to build every Tier 2 without host tools target, as documented on https://doc.rust-lang.org/nightly/rustc/platform-support.html.

I'm not really excited about the idea of scraping the tier 2 without host tools list, but also keeping the list up-to-date by hand seems prone to forgetting to update it. And that update seems like the sort of manual maintenance we should automate.
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
Related changes:
- rust-lang#125910: Introduces a new
constant propagation pass which broke Kani coverage tests. For now,
disable this pass if coverage is enabled.
  - rust-lang#126410: Rename ConstOperands

Resolves rust-lang#3260
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 A-Unicode Area: Unicode
Projects
None yet
Development

No branches or pull requests

5 participants