Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8a64cf7
Fix suggestion span error with a line containing non-ASCIIs
sinkuu Feb 25, 2017
edf5dc6
Box docs: no allocation is done for ZSTs.
Mar 9, 2017
4eeede3
fix emscripten test detection
TimNN Mar 4, 2017
da6e7c8
Distinguish the ways `CStr::from_bytes_with_nul` can fail
tbu- Mar 9, 2017
57c989c
Fix botched member variable rename
shepmaster Mar 4, 2017
3e2390f
Restore creating the channel-rust-$channel-date.txt files
shepmaster Mar 3, 2017
58ff4f6
rustbuild: expose LLVM_PARALLEL_LINK_JOBS
Mar 5, 2017
8062cfb
Implement placement-in protocol for and `VecDeque`
Mar 9, 2017
4078b25
Clean up rustdoc css
GuillaumeGomez Mar 9, 2017
a8cacd3
travis: Attempt to debug sccache failures
alexcrichton Mar 7, 2017
ac2bc7c
Point to enclosing block/fn on nested unsafe
estebank Jan 20, 2017
a07c9a2
Export attributes in save-analysis data
jonasbb Feb 14, 2017
203d227
Store attributes as strings
jonasbb Feb 23, 2017
db35604
Move remove_docs_from_attrs into lowering step
jonasbb Mar 2, 2017
4ca9c97
Remove ability for plugins to register a MIR pass
nagisa Mar 3, 2017
0a55c8e
Support armhf abi on 64-bit ARM cpus
infinity0 Mar 6, 2017
7b0dd7b
Fix incorrect span label formatting
estebank Mar 6, 2017
5afe784
Expect macro defs in save-analysis and add expn info to spans for att…
Mar 7, 2017
5c8aa74
rustc: Exit quickly on only `--emit dep-info`
alexcrichton Mar 7, 2017
9a84611
travis: Fuchsia builder
petrhosek Feb 17, 2017
83814fd
OsString::shrink_to_fit.
Mar 10, 2017
384ee48
Clarify docs in `VecDeque::resize`
DirkyJerky Mar 10, 2017
dcfc7ee
travis: Remove compiling OpenSSL through homebrew
alexcrichton Mar 10, 2017
c65996e
Don't put Cargo into the rustc workspace
alexcrichton Mar 6, 2017
d335c0a
Rollup merge of #39202 - estebank:nested-unsafe, r=jonathandturner
alexcrichton Mar 10, 2017
3b7a534
Rollup merge of #39820 - jonasbb:export-attributes, r=nrc
alexcrichton Mar 10, 2017
b92073d
Rollup merge of #39918 - petrhosek:fuchsia-ci, r=alexcrichton
alexcrichton Mar 10, 2017
da994cd
Rollup merge of #40092 - sinkuu:fix_suggestion_index, r=pnkfelix
alexcrichton Mar 10, 2017
37265d8
Rollup merge of #40225 - shepmaster:restore-build-date-file, r=alexcr…
alexcrichton Mar 10, 2017
5377eab
Rollup merge of #40239 - nagisa:death-to-plugins, r=nikomatsakis
alexcrichton Mar 10, 2017
5c715de
Rollup merge of #40259 - TimNN:fix-emscripten-tests, r=alexcrichton
alexcrichton Mar 10, 2017
0ce745b
Rollup merge of #40261 - infinity0:patch-1, r=alexcrichton
alexcrichton Mar 10, 2017
416889f
Rollup merge of #40277 - rkruppe:llvm-parallel-link-jobs, r=alexcrichton
alexcrichton Mar 10, 2017
dcc24b1
Rollup merge of #40278 - GuillaumeGomez:css-cleanup, r=frewsxcv
alexcrichton Mar 10, 2017
c253eb2
Rollup merge of #40287 - estebank:label-overlap, r=nrc
alexcrichton Mar 10, 2017
ac1bbf7
Rollup merge of #40297 - alexcrichton:fix-submodules, r=brson
alexcrichton Mar 10, 2017
755877d
Rollup merge of #40311 - nrc:save-proc-macro-attr, r=jseyfried
alexcrichton Mar 10, 2017
c1c3b09
Rollup merge of #40324 - alexcrichton:sccache-errors, r=aturon
alexcrichton Mar 10, 2017
2b1d1bb
Rollup merge of #40336 - alexcrichton:fast-dep-info, r=nrc
alexcrichton Mar 10, 2017
8f02dc2
Rollup merge of #40379 - clarcharr:box_docs, r=brson
alexcrichton Mar 10, 2017
d0da85d
Rollup merge of #40386 - tbu-:pr_display_frombyteswithnulerror, r=ale…
alexcrichton Mar 10, 2017
dcf4182
Rollup merge of #40389 - F001:placementVecDeque, r=nagisa
alexcrichton Mar 10, 2017
f4b4e09
Rollup merge of #40410 - clarcharr:os_string_shrink_to_fit, r=alexcri…
alexcrichton Mar 10, 2017
b32393c
Rollup merge of #40423 - DirkyJerky:patch-2, r=BurntSushi
alexcrichton Mar 10, 2017
d03b6b3
Rollup merge of #40424 - alexcrichton:faster-travis-osx, r=brson
alexcrichton Mar 10, 2017
3493d91
Test fixes and rebase conflicts
alexcrichton Mar 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix incorrect span label formatting
  • Loading branch information
estebank authored and alexcrichton committed Mar 10, 2017
commit 7b0dd7bdb80768684195f0175d2feecaefd1f2ac
62 changes: 34 additions & 28 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,39 +358,45 @@ impl EmitterWriter {
let mut annotations_position = vec![];
let mut line_len = 0;
let mut p = 0;
let mut ann_iter = annotations.iter().peekable();
while let Some(annotation) = ann_iter.next() {
let peek = ann_iter.peek();
if let Some(next) = peek {
if overlaps(next, annotation) && !annotation.is_line() && !next.is_line()
for (i, annotation) in annotations.iter().enumerate() {
for (j, next) in annotations.iter().enumerate() {
if overlaps(next, annotation, 0) // This label overlaps with another one and both
&& !annotation.is_line() // take space (they have text and are not
&& !next.is_line() // multiline lines).
&& annotation.has_label()
&& j > i
&& p == 0 // We're currently on the first line, move the label one line down
{
// This annotation needs a new line in the output.
p += 1;
break;
}
}
annotations_position.push((p, annotation));
if let Some(next) = peek {
let l = if let Some(ref label) = next.label {
label.len() + 2
} else {
0
};
if (overlaps(next, annotation) // Do not allow two labels to be in the same line
|| next.end_col + l > annotation.start_col) // if they overlap including
// padding, to avoid situations like:
//
// fn foo(x: u32) {
// -------^------
// | |
// fn_spanx_span
//
&& !annotation.is_line() // Do not add a new line if this annotation or the
&& !next.is_line() // next are vertical line placeholders.
&& annotation.has_label() // Both labels must have some text, otherwise
&& next.has_label() // they are not overlapping.
{
p += 1;
for (j, next) in annotations.iter().enumerate() {
if j > i {
let l = if let Some(ref label) = next.label {
label.len() + 2
} else {
0
};
if overlaps(next, annotation, l) // Do not allow two labels to be in the same
// line if they overlap including padding, to
// avoid situations like:
//
// fn foo(x: u32) {
// -------^------
// | |
// fn_spanx_span
//
&& !annotation.is_line() // Do not add a new line if this annotation
&& !next.is_line() // or the next are vertical line placeholders.
&& annotation.has_label() // Both labels must have some text, otherwise
&& next.has_label() // they are not overlapping.
{
p += 1;
break;
}
}
}
if line_len < p {
Expand Down Expand Up @@ -1088,8 +1094,8 @@ fn num_overlap(a_start: usize, a_end: usize, b_start: usize, b_end:usize, inclus
(b_start..b_end + extra).contains(a_start) ||
(a_start..a_end + extra).contains(b_start)
}
fn overlaps(a1: &Annotation, a2: &Annotation) -> bool {
num_overlap(a1.start_col, a1.end_col, a2.start_col, a2.end_col, false)
fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
num_overlap(a1.start_col, a1.end_col + padding, a2.start_col, a2.end_col, false)
}

fn emit_to_destination(rendered_buffer: &Vec<Vec<StyledString>>,
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/span/issue-40157.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main () {
{println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });}
}
14 changes: 14 additions & 0 deletions src/test/ui/span/issue-40157.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: `foo` does not live long enough
--> $DIR/issue-40157.rs:12:64
|
12 | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });}
| ----------------------------------------------------------^-------------
| | | |
| | | `foo` dropped here while still borrowed
| | borrow occurs here
| borrowed value needs to live until here
|
= note: this error originates in a macro outside of the current crate

error: aborting due to previous error