diff options
| author | kwantam <kwantam@gmail.com> | 2015-04-14 15:52:37 -0400 |
|---|---|---|
| committer | kwantam <kwantam@gmail.com> | 2015-04-16 17:03:05 -0400 |
| commit | 29d1252e4d2126318d7f622505ed76dd1e8e4edc (patch) | |
| tree | 921b91ee89c9262e2223d666f26ffded1bcda26f /src/libsyntax | |
| parent | 288809c8f35d9b37f2e4f5c3ac168f56dbc3bbc4 (diff) | |
| download | rust-29d1252e4d2126318d7f622505ed76dd1e8e4edc.tar.gz rust-29d1252e4d2126318d7f622505ed76dd1e8e4edc.zip | |
deprecate Unicode functions that will be moved to crates.io
This patch 1. renames libunicode to librustc_unicode, 2. deprecates several pieces of libunicode (see below), and 3. removes references to deprecated functions from librustc_driver and libsyntax. This may change pretty-printed output from these modules in cases involving wide or combining characters used in filenames, identifiers, etc. The following functions are marked deprecated: 1. char.width() and str.width(): --> use unicode-width crate 2. str.graphemes() and str.grapheme_indices(): --> use unicode-segmentation crate 3. str.nfd_chars(), str.nfkd_chars(), str.nfc_chars(), str.nfkc_chars(), char.compose(), char.decompose_canonical(), char.decompose_compatible(), char.canonical_combining_class(): --> use unicode-normalization crate
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index f3715d765e3..8dd0cbda1ee 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -595,7 +595,7 @@ fn highlight_lines(err: &mut EmitterWriter, let mut s = String::new(); // Skip is the number of characters we need to skip because they are // part of the 'filename:line ' part of the previous line. - let skip = fm.name.width(false) + digits + 3; + let skip = fm.name.chars().count() + digits + 3; for _ in 0..skip { s.push(' '); } @@ -615,7 +615,7 @@ fn highlight_lines(err: &mut EmitterWriter, col += 8 - col%8; s.push('\t'); }, - c => for _ in 0..c.width(false).unwrap_or(0) { + _ => { col += 1; s.push(' '); }, @@ -627,7 +627,7 @@ fn highlight_lines(err: &mut EmitterWriter, let count = match lastc { // Most terminals have a tab stop every eight columns by default '\t' => 8 - col%8, - _ => lastc.width(false).unwrap_or(0), + _ => 1, }; col += count; s.extend(::std::iter::repeat('~').take(count)); @@ -638,7 +638,7 @@ fn highlight_lines(err: &mut EmitterWriter, if pos >= hi.col.to_usize() { break; } let count = match ch { '\t' => 8 - col%8, - _ => ch.width(false).unwrap_or(0), + _ => 1, }; col += count; s.extend(::std::iter::repeat('~').take(count)); @@ -664,6 +664,7 @@ fn highlight_lines(err: &mut EmitterWriter, /// than 6 lines), `end_highlight_lines` will print the first line, then /// dot dot dot, then last line, whereas `highlight_lines` prints the first /// six lines. +#[allow(deprecated)] fn end_highlight_lines(w: &mut EmitterWriter, cm: &codemap::CodeMap, sp: Span, @@ -694,7 +695,7 @@ fn end_highlight_lines(w: &mut EmitterWriter, } let last_line_start = format!("{}:{} ", fm.name, lines[lines.len()-1].line_index + 1); let hi = cm.lookup_char_pos(sp.hi); - let skip = last_line_start.width(false); + let skip = last_line_start.chars().count(); let mut s = String::new(); for _ in 0..skip { s.push(' '); @@ -710,9 +711,7 @@ fn end_highlight_lines(w: &mut EmitterWriter, // position. match ch { '\t' => s.push('\t'), - c => for _ in 0..c.width(false).unwrap_or(0) { - s.push(' '); - }, + _ => s.push(' '), } } } |
