Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/librustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ crate-type = ["dylib"]
[dependencies]
serialize = { path = "../libserialize" }
syntax_pos = { path = "../libsyntax_pos" }
libc = "0.2"
8 changes: 6 additions & 2 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,12 @@ fn num_overlap(a_start: usize, a_end: usize, b_start: usize, b_end:usize, inclus
} else {
0
};
(b_start..b_end + extra).contains(a_start) ||
(a_start..a_end + extra).contains(b_start)
return range_contains(b_start..b_end + extra, a_start) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be simpler just to have the following? Maybe with a comment for clarity.

(b_start <= a_start && a_start < b_end + extra) ||
(a_start <= b_start && b_start < a_end + extra);

range_contains(a_start..a_end + extra, b_start);

fn range_contains<T: PartialOrd>(range: ::std::ops::Range<T>, item: T) -> bool {
(range.start <= item) && (item < range.end)
}
}
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)
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(custom_attribute)]
#![allow(unused_attributes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(range_contains)]
#![feature(libc)]

extern crate term;
extern crate libc;
Expand Down