Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
86334c7
remove unnecessary intermediate vector from `copy`
nikomatsakis Dec 3, 2017
a0f0392
rename `copy` to `dfs` and make it customizable
nikomatsakis Dec 3, 2017
cd564d2
only propagate ClosureRegionRequirements if non-trivial
nikomatsakis Dec 3, 2017
6193c5c
translate `Verify`s into `TypeTest`s and check them
nikomatsakis Dec 3, 2017
fad3d1d
dfs.rs: rustfmt
nikomatsakis Dec 5, 2017
1c57468
move `type_check` out of `transform` and into the `nll` module
nikomatsakis Dec 3, 2017
ebd086b
move `LivenessResults` from `nll` into `liveness` analysis
nikomatsakis Dec 3, 2017
4a940b3
move `flow_in_progress` into `dataflow` and document it
nikomatsakis Dec 3, 2017
47c1921
move some parts of liveness to happen during type checking
nikomatsakis Dec 3, 2017
02e6525
mild refactors of the control flow (no functional changes)
nikomatsakis Dec 4, 2017
154cd94
rework region flags: 'static can be erased too
nikomatsakis Dec 4, 2017
c7cfa23
thread through an implicit region body of the fn body
nikomatsakis Dec 4, 2017
5804637
permit `ClosureOutlivesRequirement` to constrain regions or types
nikomatsakis Dec 4, 2017
85e1d47
propagate type tests from closure to closure creators
nikomatsakis Dec 4, 2017
3a5842a
add a new RegionKind variant: ReClosureBound
nikomatsakis Dec 5, 2017
3fcb13a
handle projections with regions
nikomatsakis Dec 5, 2017
e9824c5
impose inputs/ouputs on MIR after the fact
nikomatsakis Dec 6, 2017
a118afe
add a test regarding relating closure and fn generics
nikomatsakis Dec 6, 2017
0d6bd42
make `blame_span` deterministic
nikomatsakis Dec 6, 2017
0f8ef0c
more concise debug output when dumping the value of a region
nikomatsakis Dec 6, 2017
4f43c5b
stop dumping DefPath into "failed type test" errors
nikomatsakis Dec 15, 2017
03bfb0f
tweak comment on `TypeTest` to be more accurate
nikomatsakis Dec 19, 2017
3c56c36
fix comment on `check_type_tests`
nikomatsakis Dec 19, 2017
3d826e5
remove dead `is_foo_free_region` helpers
nikomatsakis Dec 19, 2017
1816ede
be specific about what kind of normalization we mean
nikomatsakis Dec 19, 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
more concise debug output when dumping the value of a region
  • Loading branch information
nikomatsakis committed Dec 15, 2017
commit 0f8ef0ca1a298619001998fcb5c329159db206c7
63 changes: 56 additions & 7 deletions src/librustc_mir/borrow_check/nll/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ impl RegionValues {
// FIXME. We could optimize this by improving
// `BitMatrix::merge` so it does not always merge an entire
// row.
debug!("add_universal_regions_outlived_by(from_region={:?}, to_region={:?})",
from_region, to_region);
debug!(
"add_universal_regions_outlived_by(from_region={:?}, to_region={:?})",
from_region,
to_region
);
let mut changed = false;
for elem in self.elements.all_universal_region_indices() {
if self.contains(from_region, elem) {
Expand Down Expand Up @@ -269,24 +272,70 @@ impl RegionValues {
let mut result = String::new();
result.push_str("{");

for (index, element) in self.elements_contained_in(r).enumerate() {
if index > 0 {
result.push_str(", ");
}
// Set to Some(l1, l2) when we have observed all the locations
// from l1..=l2 (inclusive) but not yet printed them. This
// gets extended if we then see l3 where l3 is the successor
// to l2.
let mut open_location: Option<(Location, Location)> = None;

let mut sep = "";
let mut push_sep = |s: &mut String| {
s.push_str(sep);
sep = ", ";
};

for element in self.elements_contained_in(r) {
match element {
RegionElement::Location(l) => {
result.push_str(&format!("{:?}", l));
if let Some((location1, location2)) = open_location {
if location2.block == l.block
&& location2.statement_index == l.statement_index - 1
{
open_location = Some((location1, l));
continue;
}

push_sep(&mut result);
Self::push_location_range(&mut result, location1, location2);
}

open_location = Some((l, l));
}

RegionElement::UniversalRegion(fr) => {
if let Some((location1, location2)) = open_location {
push_sep(&mut result);
Self::push_location_range(&mut result, location1, location2);
open_location = None;
}

push_sep(&mut result);
result.push_str(&format!("{:?}", fr));
}
}
}

if let Some((location1, location2)) = open_location {
push_sep(&mut result);
Self::push_location_range(&mut result, location1, location2);
}

result.push_str("}");

result
}

fn push_location_range(str: &mut String, location1: Location, location2: Location) {
if location1 == location2 {
str.push_str(&format!("{:?}", location1));
} else {
assert_eq!(location1.block, location2.block);
str.push_str(&format!(
"{:?}[{}..={}]",
location1.block,
location1.statement_index,
location2.statement_index
));
}
}
}
18 changes: 9 additions & 9 deletions src/test/mir-opt/nll/named-lifetimes-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ fn main() {
// | '_#4r | Local | ['_#4r]
// |
// | Inferred Region Values
// | '_#0r | {'_#0r, bb0[0], bb0[1]}
// | '_#1r | {'_#1r, bb0[0], bb0[1]}
// | '_#2r | {'_#2r, bb0[0], bb0[1]}
// | '_#3r | {'_#3r, bb0[0], bb0[1]}
// | '_#4r | {'_#4r, bb0[0], bb0[1]}
// | '_#5r | {'_#1r, bb0[0], bb0[1]}
// | '_#6r | {'_#2r, bb0[0], bb0[1]}
// | '_#7r | {'_#1r, bb0[0], bb0[1]}
// | '_#8r | {'_#3r, bb0[0], bb0[1]}
// | '_#0r | {'_#0r, bb0[0..=1]}
// | '_#1r | {'_#1r, bb0[0..=1]}
// | '_#2r | {'_#2r, bb0[0..=1]}
// | '_#3r | {'_#3r, bb0[0..=1]}
// | '_#4r | {'_#4r, bb0[0..=1]}
// | '_#5r | {'_#1r, bb0[0..=1]}
// | '_#6r | {'_#2r, bb0[0..=1]}
// | '_#7r | {'_#1r, bb0[0..=1]}
// | '_#8r | {'_#3r, bb0[0..=1]}
// |
// ...
// fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/test/mir-opt/nll/reborrow-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ fn main() {

// END RUST SOURCE
// START rustc.main.nll.0.mir
// | '_#7r | {bb0[6], bb0[7], bb0[8], bb0[9], bb0[10], bb0[11], bb0[12], bb0[13], bb0[14]}
// | '_#7r | {bb0[6..=14]}
// ...
// | '_#9r | {bb0[11], bb0[12], bb0[13], bb0[14]}
// | '_#9r | {bb0[11..=14]}
// ...
// let _2: &'_#7r mut i32;
// ...
Expand Down
4 changes: 2 additions & 2 deletions src/test/mir-opt/nll/region-liveness-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fn main() {

// END RUST SOURCE
// START rustc.main.nll.0.mir
// | '_#2r | {bb2[0], bb2[1], bb3[0], bb3[1]}
// | '_#3r | {bb2[1], bb3[0], bb3[1]}
// | '_#2r | {bb2[0..=1], bb3[0..=1]}
// | '_#3r | {bb2[1], bb3[0..=1]}
// ...
// let _2: &'_#3r usize;
// END rustc.main.nll.0.mir
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/nll/region-liveness-drop-may-dangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ unsafe impl<#[may_dangle] T> Drop for Wrap<T> {

// END RUST SOURCE
// START rustc.main.nll.0.mir
// | '_#6r | {bb2[3], bb2[4], bb2[5], bb3[0], bb3[1]}
// | '_#6r | {bb2[3..=5], bb3[0..=1]}
// ...
// let _2: Wrap<&'_#6r usize>;
// END rustc.main.nll.0.mir
2 changes: 1 addition & 1 deletion src/test/mir-opt/nll/region-liveness-drop-no-may-dangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<T> Drop for Wrap<T> {

// END RUST SOURCE
// START rustc.main.nll.0.mir
// | '_#6r | {bb2[3], bb2[4], bb2[5], bb3[0], bb3[1], bb3[2], bb4[0], bb5[0], bb5[1], bb5[2], bb6[0], bb7[0], bb7[1], bb8[0]}
// | '_#6r | {bb2[3..=5], bb3[0..=2], bb4[0], bb5[0..=2], bb6[0], bb7[0..=1], bb8[0]}
// ...
// let _2: Wrap<&'_#6r usize>;
// END rustc.main.nll.0.mir
6 changes: 3 additions & 3 deletions src/test/mir-opt/nll/region-liveness-two-disjoint-uses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ fn main() {

// END RUST SOURCE
// START rustc.main.nll.0.mir
// | '_#2r | {bb2[0], bb2[1], bb3[0], bb3[1]}
// | '_#2r | {bb2[0..=1], bb3[0..=1]}
// ...
// | '_#4r | {bb8[1], bb8[2], bb8[3], bb8[4]}
// | '_#5r | {bb2[1], bb3[0], bb3[1], bb8[2], bb8[3], bb8[4]}
// | '_#4r | {bb8[1..=4]}
// | '_#5r | {bb2[1], bb3[0..=1], bb8[2..=4]}
// ...
// let mut _2: &'_#5r usize;
// ...
Expand Down
6 changes: 3 additions & 3 deletions src/test/mir-opt/nll/region-subtyping-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ fn main() {

// END RUST SOURCE
// START rustc.main.nll.0.mir
// | '_#2r | {bb2[0], bb2[1], bb2[2], bb2[3], bb2[4], bb2[5], bb2[6], bb3[0], bb3[1]}
// | '_#3r | {bb2[1], bb2[2], bb2[3], bb2[4], bb2[5], bb2[6], bb3[0], bb3[1]}
// | '_#4r | {bb2[5], bb2[6], bb3[0], bb3[1]}
// | '_#2r | {bb2[0..=6], bb3[0..=1]}
// | '_#3r | {bb2[1..=6], bb3[0..=1]}
// | '_#4r | {bb2[5..=6], bb3[0..=1]}
// END rustc.main.nll.0.mir
// START rustc.main.nll.0.mir
// let _2: &'_#3r usize;
Expand Down