From 1f11331894cb7543211660f4a9282755ac7c4ac7 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 7 Jun 2020 12:01:20 -0400 Subject: [PATCH 01/15] Add Item::is_fake for rustdoc I wasn't aware items _could_ be fake, so I think having a function mentioning it could be helpful. Also, I'd need to make this change for cross-crate intra-doc links anyway, so I figured it's better to make the refactor separate. --- src/librustdoc/clean/types.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 381238165274d..5c76c840b1ddd 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -85,9 +85,7 @@ pub struct Item { impl fmt::Debug for Item { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - let fake = MAX_DEF_ID.with(|m| { - m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false) - }); + let fake = self.is_fake(); let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id }; fmt.debug_struct("Item") @@ -238,6 +236,13 @@ impl Item { _ => false, } } + + /// See comments on next_def_id + pub fn is_fake(&self) -> bool { + MAX_DEF_ID.with(|m| { + m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false) + }) + } } #[derive(Clone, Debug)] From a1eeaddf3f7aad9e82196d338613593e4e000762 Mon Sep 17 00:00:00 2001 From: Nathan Corbyn Date: Mon, 8 Jun 2020 11:57:56 +0100 Subject: [PATCH 02/15] Resolve E0584 conflict --- src/librustc_error_codes/error_codes.rs | 1 + src/librustc_error_codes/error_codes/E0761.md | 25 +++++++++++++++++++ src/librustc_expand/module.rs | 2 +- src/test/ui/mod/mod_file_disambig.stderr | 4 +-- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 src/librustc_error_codes/error_codes/E0761.md diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 7abe75a375a0b..a5b896ab19a5b 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -438,6 +438,7 @@ E0752: include_str!("./error_codes/E0752.md"), E0753: include_str!("./error_codes/E0753.md"), E0754: include_str!("./error_codes/E0754.md"), E0760: include_str!("./error_codes/E0760.md"), +E0761: include_str!("./error_codes/E0761.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/src/librustc_error_codes/error_codes/E0761.md b/src/librustc_error_codes/error_codes/E0761.md new file mode 100644 index 0000000000000..e22ebcdc43190 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0761.md @@ -0,0 +1,25 @@ +Multiple candidate files were found for an out-of-line module. + +Erroneous code example: + +```rust +// file: ambiguous_module/mod.rs + +fn foo() {} +``` + +```rust +// file: ambiguous_module.rs + +fn foo() {} +``` + +```ignore (compile_fail not working here; see Issue #43707) +mod ambiguous_module; // error: file for module `ambiguous_module` + // found at both ambiguous_module.rs and + // ambiguous_module.rs/mod.rs + +fn main() {} +``` + +Please remove this ambiguity by deleting/renaming one of the candidate files. diff --git a/src/librustc_expand/module.rs b/src/librustc_expand/module.rs index 82215c7297ed6..535c1dbad04a9 100644 --- a/src/librustc_expand/module.rs +++ b/src/librustc_expand/module.rs @@ -291,7 +291,7 @@ pub fn default_submod_path<'a>( let mut err = struct_span_err!( sess.span_diagnostic, span, - E0584, + E0761, "file for module `{}` found at both {} and {}", mod_name, default_path_str, diff --git a/src/test/ui/mod/mod_file_disambig.stderr b/src/test/ui/mod/mod_file_disambig.stderr index 490633a3fb0ab..2cb99b7514277 100644 --- a/src/test/ui/mod/mod_file_disambig.stderr +++ b/src/test/ui/mod/mod_file_disambig.stderr @@ -1,4 +1,4 @@ -error[E0584]: file for module `mod_file_disambig_aux` found at both mod_file_disambig_aux.rs and mod_file_disambig_aux/mod.rs +error[E0761]: file for module `mod_file_disambig_aux` found at both mod_file_disambig_aux.rs and mod_file_disambig_aux/mod.rs --> $DIR/mod_file_disambig.rs:1:1 | LL | mod mod_file_disambig_aux; @@ -14,5 +14,5 @@ LL | assert_eq!(mod_file_aux::bar(), 10); error: aborting due to 2 previous errors -Some errors have detailed explanations: E0433, E0584. +Some errors have detailed explanations: E0433, E0761. For more information about an error, try `rustc --explain E0433`. From f615582d650d812fcdd41e3d4f03f8bb4f1b268a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 8 Jun 2020 13:02:23 +0200 Subject: [PATCH 03/15] Clean up E0647 explanation --- src/librustc_error_codes/error_codes/E0647.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_error_codes/error_codes/E0647.md b/src/librustc_error_codes/error_codes/E0647.md index 131db38c00d2e..8ca6e777f301d 100644 --- a/src/librustc_error_codes/error_codes/E0647.md +++ b/src/librustc_error_codes/error_codes/E0647.md @@ -1,4 +1,5 @@ -It is not possible to define `start` with a where clause. +The `start` function was defined with a where clause. + Erroneous code example: ```compile_fail,E0647 From 3aedfbecfd3eaf8a0d4174d2a42a91d3eac77c25 Mon Sep 17 00:00:00 2001 From: Nathan Corbyn Date: Mon, 8 Jun 2020 13:54:20 +0100 Subject: [PATCH 04/15] Enforce unwind invariants --- src/librustc_mir/transform/validate.rs | 60 ++++++++++++++++++-------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/src/librustc_mir/transform/validate.rs b/src/librustc_mir/transform/validate.rs index 1433d39abfbba..339b1469f1237 100644 --- a/src/librustc_mir/transform/validate.rs +++ b/src/librustc_mir/transform/validate.rs @@ -11,6 +11,11 @@ use rustc_middle::{ }; use rustc_span::def_id::DefId; +enum EdgeKind { + Unwind, + Other, +} + pub struct Validator { /// Describes at which point in the pipeline this validation is happening. pub when: String, @@ -49,8 +54,25 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); } - fn check_bb(&self, location: Location, bb: BasicBlock) { - if self.body.basic_blocks().get(bb).is_none() { + fn check_bb(&self, location: Location, bb: BasicBlock, edge_kind: EdgeKind) { + if let Some(bb) = self.body.basic_blocks().get(bb) { + let src = self.body.basic_blocks().get(location.block).unwrap(); + match (src.is_cleanup, bb.is_cleanup, edge_kind) { + // Non-cleanup blocks can jump to non-cleanup blocks along non-unwind edges + (false, false, EdgeKind::Other) + // Non-cleanup blocks can jump to cleanup blocks along unwind edges + | (false, true, EdgeKind::Unwind) + // Cleanup blocks can jump to cleanup blocks along unwind edges + | (true, true, EdgeKind::Unwind) => {} + // All other jumps are invalid + _ => { + self.fail( + location, + format!("encountered jump that does not respect unwind invariants {:?}", bb) + ) + } + } + } else { self.fail(location, format!("encountered jump to invalid basic block {:?}", bb)) } } @@ -92,7 +114,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { match &terminator.kind { TerminatorKind::Goto { target } => { - self.check_bb(location, *target); + self.check_bb(location, *target, EdgeKind::Other); } TerminatorKind::SwitchInt { targets, values, .. } => { if targets.len() != values.len() + 1 { @@ -106,19 +128,19 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ); } for target in targets { - self.check_bb(location, *target); + self.check_bb(location, *target, EdgeKind::Other); } } TerminatorKind::Drop { target, unwind, .. } => { - self.check_bb(location, *target); + self.check_bb(location, *target, EdgeKind::Other); if let Some(unwind) = unwind { - self.check_bb(location, *unwind); + self.check_bb(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::DropAndReplace { target, unwind, .. } => { - self.check_bb(location, *target); + self.check_bb(location, *target, EdgeKind::Other); if let Some(unwind) = unwind { - self.check_bb(location, *unwind); + self.check_bb(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::Call { func, destination, cleanup, .. } => { @@ -131,10 +153,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ), } if let Some((_, target)) = destination { - self.check_bb(location, *target); + self.check_bb(location, *target, EdgeKind::Other); } if let Some(cleanup) = cleanup { - self.check_bb(location, *cleanup); + self.check_bb(location, *cleanup, EdgeKind::Unwind); } } TerminatorKind::Assert { cond, target, cleanup, .. } => { @@ -148,30 +170,30 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ), ); } - self.check_bb(location, *target); + self.check_bb(location, *target, EdgeKind::Other); if let Some(cleanup) = cleanup { - self.check_bb(location, *cleanup); + self.check_bb(location, *cleanup, EdgeKind::Unwind); } } TerminatorKind::Yield { resume, drop, .. } => { - self.check_bb(location, *resume); + self.check_bb(location, *resume, EdgeKind::Other); if let Some(drop) = drop { - self.check_bb(location, *drop); + self.check_bb(location, *drop, EdgeKind::Other); } } TerminatorKind::FalseEdge { real_target, imaginary_target } => { - self.check_bb(location, *real_target); - self.check_bb(location, *imaginary_target); + self.check_bb(location, *real_target, EdgeKind::Other); + self.check_bb(location, *imaginary_target, EdgeKind::Other); } TerminatorKind::FalseUnwind { real_target, unwind } => { - self.check_bb(location, *real_target); + self.check_bb(location, *real_target, EdgeKind::Other); if let Some(unwind) = unwind { - self.check_bb(location, *unwind); + self.check_bb(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::InlineAsm { destination, .. } => { if let Some(destination) = destination { - self.check_bb(location, *destination); + self.check_bb(location, *destination, EdgeKind::Other); } } // Nothing to validate for these. From 4158bb0f0b06a3a47042ab5e5cbc70075bec8805 Mon Sep 17 00:00:00 2001 From: Nathan Corbyn Date: Mon, 8 Jun 2020 16:00:09 +0100 Subject: [PATCH 05/15] Relax cleanup to cleanup check --- src/librustc_mir/transform/validate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/transform/validate.rs b/src/librustc_mir/transform/validate.rs index 339b1469f1237..252ac2a00b292 100644 --- a/src/librustc_mir/transform/validate.rs +++ b/src/librustc_mir/transform/validate.rs @@ -62,8 +62,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { (false, false, EdgeKind::Other) // Non-cleanup blocks can jump to cleanup blocks along unwind edges | (false, true, EdgeKind::Unwind) - // Cleanup blocks can jump to cleanup blocks along unwind edges - | (true, true, EdgeKind::Unwind) => {} + // Cleanup blocks can jump to cleanup blocks along any edges + | (true, true, _) => {} // All other jumps are invalid _ => { self.fail( From 1c4fd22618730f63689d8dc36972bc2a56d46067 Mon Sep 17 00:00:00 2001 From: Nathan Corbyn Date: Mon, 8 Jun 2020 16:04:41 +0100 Subject: [PATCH 06/15] Strengthen cleanup to cleanup check --- src/librustc_mir/transform/validate.rs | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/librustc_mir/transform/validate.rs b/src/librustc_mir/transform/validate.rs index 252ac2a00b292..dda416b01a21f 100644 --- a/src/librustc_mir/transform/validate.rs +++ b/src/librustc_mir/transform/validate.rs @@ -13,7 +13,7 @@ use rustc_span::def_id::DefId; enum EdgeKind { Unwind, - Other, + Normal, } pub struct Validator { @@ -59,11 +59,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let src = self.body.basic_blocks().get(location.block).unwrap(); match (src.is_cleanup, bb.is_cleanup, edge_kind) { // Non-cleanup blocks can jump to non-cleanup blocks along non-unwind edges - (false, false, EdgeKind::Other) + (false, false, EdgeKind::Normal) // Non-cleanup blocks can jump to cleanup blocks along unwind edges | (false, true, EdgeKind::Unwind) - // Cleanup blocks can jump to cleanup blocks along any edges - | (true, true, _) => {} + // Cleanup blocks can jump to cleanup blocks along non-unwind edges + | (true, true, EdgeKind::Normal) => {} // All other jumps are invalid _ => { self.fail( @@ -114,7 +114,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { match &terminator.kind { TerminatorKind::Goto { target } => { - self.check_bb(location, *target, EdgeKind::Other); + self.check_bb(location, *target, EdgeKind::Normal); } TerminatorKind::SwitchInt { targets, values, .. } => { if targets.len() != values.len() + 1 { @@ -128,17 +128,17 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ); } for target in targets { - self.check_bb(location, *target, EdgeKind::Other); + self.check_bb(location, *target, EdgeKind::Normal); } } TerminatorKind::Drop { target, unwind, .. } => { - self.check_bb(location, *target, EdgeKind::Other); + self.check_bb(location, *target, EdgeKind::Normal); if let Some(unwind) = unwind { self.check_bb(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::DropAndReplace { target, unwind, .. } => { - self.check_bb(location, *target, EdgeKind::Other); + self.check_bb(location, *target, EdgeKind::Normal); if let Some(unwind) = unwind { self.check_bb(location, *unwind, EdgeKind::Unwind); } @@ -153,7 +153,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ), } if let Some((_, target)) = destination { - self.check_bb(location, *target, EdgeKind::Other); + self.check_bb(location, *target, EdgeKind::Normal); } if let Some(cleanup) = cleanup { self.check_bb(location, *cleanup, EdgeKind::Unwind); @@ -170,30 +170,30 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ), ); } - self.check_bb(location, *target, EdgeKind::Other); + self.check_bb(location, *target, EdgeKind::Normal); if let Some(cleanup) = cleanup { self.check_bb(location, *cleanup, EdgeKind::Unwind); } } TerminatorKind::Yield { resume, drop, .. } => { - self.check_bb(location, *resume, EdgeKind::Other); + self.check_bb(location, *resume, EdgeKind::Normal); if let Some(drop) = drop { - self.check_bb(location, *drop, EdgeKind::Other); + self.check_bb(location, *drop, EdgeKind::Normal); } } TerminatorKind::FalseEdge { real_target, imaginary_target } => { - self.check_bb(location, *real_target, EdgeKind::Other); - self.check_bb(location, *imaginary_target, EdgeKind::Other); + self.check_bb(location, *real_target, EdgeKind::Normal); + self.check_bb(location, *imaginary_target, EdgeKind::Normal); } TerminatorKind::FalseUnwind { real_target, unwind } => { - self.check_bb(location, *real_target, EdgeKind::Other); + self.check_bb(location, *real_target, EdgeKind::Normal); if let Some(unwind) = unwind { self.check_bb(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::InlineAsm { destination, .. } => { if let Some(destination) = destination { - self.check_bb(location, *destination, EdgeKind::Other); + self.check_bb(location, *destination, EdgeKind::Normal); } } // Nothing to validate for these. From 54fdb578c64dd5385760f83876bd16e8f54d3784 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Mon, 8 Jun 2020 19:13:46 +0300 Subject: [PATCH 07/15] Fix the typo (size of the size) --- src/libcore/slice/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index ff333f77334f7..4efb1db7a1a68 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -409,7 +409,7 @@ impl [T] { /// The returned range is half-open, which means that the end pointer /// points *one past* the last element of the slice. This way, an empty /// slice is represented by two equal pointers, and the difference between - /// the two pointers represents the size of the size. + /// the two pointers represents the size of the slice. /// /// See [`as_ptr`] for warnings on using these pointers. The end pointer /// requires extra caution, as it does not point to a valid element in the @@ -464,7 +464,7 @@ impl [T] { /// The returned range is half-open, which means that the end pointer /// points *one past* the last element of the slice. This way, an empty /// slice is represented by two equal pointers, and the difference between - /// the two pointers represents the size of the size. + /// the two pointers represents the size of the slice. /// /// See [`as_mut_ptr`] for warnings on using these pointers. The end /// pointer requires extra caution, as it does not point to a valid element From fd483c86db58b0407ce00c37e30659c7a230b0a6 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 8 Jun 2020 13:37:58 -0700 Subject: [PATCH 08/15] typo: awailable -> available --- src/doc/unstable-book/src/compiler-flags/report-time.md | 2 +- src/libtest/cli.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/unstable-book/src/compiler-flags/report-time.md b/src/doc/unstable-book/src/compiler-flags/report-time.md index ed4e9c6b56842..68265d8a9e810 100644 --- a/src/doc/unstable-book/src/compiler-flags/report-time.md +++ b/src/doc/unstable-book/src/compiler-flags/report-time.md @@ -22,7 +22,7 @@ Available options: ```sh --report-time [plain|colored] - Show execution time of each test. Awailable values: + Show execution time of each test. Available values: plain = do not colorize the execution time (default); colored = colorize output according to the `color` parameter value; diff --git a/src/libtest/cli.rs b/src/libtest/cli.rs index 0cec8050c279d..97a659f22d757 100644 --- a/src/libtest/cli.rs +++ b/src/libtest/cli.rs @@ -115,7 +115,7 @@ fn optgroups() -> getopts::Options { .optflagopt( "", "report-time", - "Show execution time of each test. Awailable values: + "Show execution time of each test. Available values: plain = do not colorize the execution time (default); colored = colorize output according to the `color` parameter value; From 5ceff6b96af9a21e044545b9e064433feccaf659 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 May 2020 10:36:32 +1000 Subject: [PATCH 09/15] Fix off-by-one error in `DroplessArena::alloc_raw`. This causes unnecessary calls to `grow` when the allocation would fit exactly in the remaining space. --- src/librustc_arena/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_arena/lib.rs b/src/librustc_arena/lib.rs index bbe80c26dcbf9..725850036bbbf 100644 --- a/src/librustc_arena/lib.rs +++ b/src/librustc_arena/lib.rs @@ -386,7 +386,7 @@ impl DroplessArena { self.align(align); let future_end = intrinsics::arith_offset(self.ptr.get(), bytes as isize); - if (future_end as *mut u8) >= self.end.get() { + if (future_end as *mut u8) > self.end.get() { self.grow(bytes); } From 7145b877511e2a38fbdea32a375e398371d1980b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 May 2020 11:03:33 +1000 Subject: [PATCH 10/15] Remove the `reserve_in_place` calls in `{Typed,Dropless}Arena::grow`. They are pointless. No reasonable allocator will be able to satisfy a `reserve_in_place` request that *doubles* the size of an allocation when dealing with allocations that are 4 KiB and larger. Just to be sure, I confirmed on Linux that the `reserve_in_place` calls never succeed. (Note however that the `reserve_in_place` call for `DroplessArena::grow` did occasionally succeed prior to the off-by-one fix in the previous commit, because we would sometimes do a `reserve_in_place` request for the chunk's current size, which would trivially succeed!) --- src/librustc_arena/lib.rs | 52 +++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/librustc_arena/lib.rs b/src/librustc_arena/lib.rs index 725850036bbbf..fbf68a5ca3531 100644 --- a/src/librustc_arena/lib.rs +++ b/src/librustc_arena/lib.rs @@ -216,26 +216,21 @@ impl TypedArena { #[cold] fn grow(&self, n: usize) { unsafe { - // We need the element size in to convert chunk sizes (ranging from + // We need the element size to convert chunk sizes (ranging from // PAGE to HUGE_PAGE bytes) to element counts. let elem_size = cmp::max(1, mem::size_of::()); let mut chunks = self.chunks.borrow_mut(); - let (chunk, mut new_capacity); + let mut new_capacity; if let Some(last_chunk) = chunks.last_mut() { let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize; - let currently_used_cap = used_bytes / mem::size_of::(); - last_chunk.entries = currently_used_cap; - if last_chunk.storage.reserve_in_place(currently_used_cap, n) { - self.end.set(last_chunk.end()); - return; - } else { - // If the previous chunk's capacity is less than HUGE_PAGE - // bytes, then this chunk will be least double the previous - // chunk's size. - new_capacity = last_chunk.storage.capacity(); - if new_capacity < HUGE_PAGE / elem_size { - new_capacity = new_capacity.checked_mul(2).unwrap(); - } + last_chunk.entries = used_bytes / mem::size_of::(); + + // If the previous chunk's capacity is less than HUGE_PAGE + // bytes, then this chunk will be least double the previous + // chunk's size. + new_capacity = last_chunk.storage.capacity(); + if new_capacity < HUGE_PAGE / elem_size { + new_capacity = new_capacity.checked_mul(2).unwrap(); } } else { new_capacity = PAGE / elem_size; @@ -243,7 +238,7 @@ impl TypedArena { // Also ensure that this chunk can fit `n`. new_capacity = cmp::max(n, new_capacity); - chunk = TypedArenaChunk::::new(new_capacity); + let chunk = TypedArenaChunk::::new(new_capacity); self.ptr.set(chunk.start()); self.end.set(chunk.end()); chunks.push(chunk); @@ -350,20 +345,17 @@ impl DroplessArena { fn grow(&self, needed_bytes: usize) { unsafe { let mut chunks = self.chunks.borrow_mut(); - let (chunk, mut new_capacity); + let mut new_capacity; if let Some(last_chunk) = chunks.last_mut() { - let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize; - if last_chunk.storage.reserve_in_place(used_bytes, needed_bytes) { - self.end.set(last_chunk.end()); - return; - } else { - // If the previous chunk's capacity is less than HUGE_PAGE - // bytes, then this chunk will be least double the previous - // chunk's size. - new_capacity = last_chunk.storage.capacity(); - if new_capacity < HUGE_PAGE { - new_capacity = new_capacity.checked_mul(2).unwrap(); - } + // There is no need to update `last_chunk.entries` because that + // field isn't used by `DroplessArena`. + + // If the previous chunk's capacity is less than HUGE_PAGE + // bytes, then this chunk will be least double the previous + // chunk's size. + new_capacity = last_chunk.storage.capacity(); + if new_capacity < HUGE_PAGE { + new_capacity = new_capacity.checked_mul(2).unwrap(); } } else { new_capacity = PAGE; @@ -371,7 +363,7 @@ impl DroplessArena { // Also ensure that this chunk can fit `needed_bytes`. new_capacity = cmp::max(needed_bytes, new_capacity); - chunk = TypedArenaChunk::::new(new_capacity); + let chunk = TypedArenaChunk::::new(new_capacity); self.ptr.set(chunk.start()); self.end.set(chunk.end()); chunks.push(chunk); From cb8bc8e05dbb96069d6c66145ac2f37cb16a618d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 May 2020 11:39:37 +1000 Subject: [PATCH 11/15] Remove `RawVec::reserve_in_place`. Also remove a now-unnecessary `placement` argument. --- src/liballoc/raw_vec.rs | 45 ++++++----------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 5b365f0387a9b..8a22f267bf296 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -9,7 +9,7 @@ use core::ptr::{NonNull, Unique}; use core::slice; use crate::alloc::{ - handle_alloc_error, AllocErr, + handle_alloc_error, AllocInit::{self, *}, AllocRef, Global, Layout, ReallocPlacement::{self, *}, @@ -302,39 +302,12 @@ impl RawVec { needed_extra_capacity: usize, ) -> Result<(), TryReserveError> { if self.needs_to_grow(used_capacity, needed_extra_capacity) { - self.grow_amortized(used_capacity, needed_extra_capacity, MayMove) + self.grow_amortized(used_capacity, needed_extra_capacity) } else { Ok(()) } } - /// Attempts to ensure that the buffer contains at least enough space to hold - /// `used_capacity + needed_extra_capacity` elements. If it doesn't already have - /// enough capacity, will reallocate in place enough space plus comfortable slack - /// space to get amortized `O(1)` behavior. Will limit this behaviour - /// if it would needlessly cause itself to panic. - /// - /// If `used_capacity` exceeds `self.capacity()`, this may fail to actually allocate - /// the requested space. This is not really unsafe, but the unsafe - /// code *you* write that relies on the behavior of this function may break. - /// - /// Returns `true` if the reallocation attempt has succeeded. - /// - /// # Panics - /// - /// * Panics if the requested capacity exceeds `usize::MAX` bytes. - /// * Panics on 32-bit platforms if the requested capacity exceeds - /// `isize::MAX` bytes. - pub fn reserve_in_place(&mut self, used_capacity: usize, needed_extra_capacity: usize) -> bool { - // This is more readable than putting this in one line: - // `!self.needs_to_grow(...) || self.grow(...).is_ok()` - if self.needs_to_grow(used_capacity, needed_extra_capacity) { - self.grow_amortized(used_capacity, needed_extra_capacity, InPlace).is_ok() - } else { - true - } - } - /// Ensures that the buffer contains at least enough space to hold /// `used_capacity + needed_extra_capacity` elements. If it doesn't already, /// will reallocate the minimum possible amount of memory necessary. @@ -423,11 +396,9 @@ impl RawVec { &mut self, used_capacity: usize, needed_extra_capacity: usize, - placement: ReallocPlacement, ) -> Result<(), TryReserveError> { // This is ensured by the calling contexts. debug_assert!(needed_extra_capacity > 0); - if mem::size_of::() == 0 { // Since we return a capacity of `usize::MAX` when `elem_size` is // 0, getting to here necessarily means the `RawVec` is overfull. @@ -461,7 +432,7 @@ impl RawVec { let new_layout = Layout::array::(cap); // `finish_grow` is non-generic over `T`. - let memory = finish_grow(new_layout, placement, self.current_memory(), &mut self.alloc)?; + let memory = finish_grow(new_layout, self.current_memory(), &mut self.alloc)?; self.set_memory(memory); Ok(()) } @@ -484,7 +455,7 @@ impl RawVec { let new_layout = Layout::array::(cap); // `finish_grow` is non-generic over `T`. - let memory = finish_grow(new_layout, MayMove, self.current_memory(), &mut self.alloc)?; + let memory = finish_grow(new_layout, self.current_memory(), &mut self.alloc)?; self.set_memory(memory); Ok(()) } @@ -518,7 +489,6 @@ impl RawVec { // much smaller than the number of `T` types.) fn finish_grow( new_layout: Result, - placement: ReallocPlacement, current_memory: Option<(NonNull, Layout)>, alloc: &mut A, ) -> Result @@ -532,12 +502,9 @@ where let memory = if let Some((ptr, old_layout)) = current_memory { debug_assert_eq!(old_layout.align(), new_layout.align()); - unsafe { alloc.grow(ptr, old_layout, new_layout.size(), placement, Uninitialized) } + unsafe { alloc.grow(ptr, old_layout, new_layout.size(), MayMove, Uninitialized) } } else { - match placement { - MayMove => alloc.alloc(new_layout, Uninitialized), - InPlace => Err(AllocErr), - } + alloc.alloc(new_layout, Uninitialized) } .map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })?; From c9cbe7e7eb37ec06a9c76a6b9ca4d342ff5a1128 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 20 May 2020 20:45:05 +1000 Subject: [PATCH 12/15] Rename some identifiers in `RawVec` and `libarena`. - Use `len` more consistently for the number of elements in a vector, because that's the usual name. - Use `additional` more consistently for the number of elements we want to add, because that's what `Vec::reserve()` uses. - Use `cap` consistently rather than `capacity`. - Plus a few other tweaks. This increases consistency and conciseness. --- src/liballoc/raw_vec.rs | 81 ++++++++++++++++----------------------- src/liballoc/vec.rs | 8 ++-- src/librustc_arena/lib.rs | 52 ++++++++++++------------- 3 files changed, 62 insertions(+), 79 deletions(-) diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 8a22f267bf296..805dbfe277584 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -235,13 +235,13 @@ impl RawVec { } } - /// Ensures that the buffer contains at least enough space to hold - /// `used_capacity + needed_extra_capacity` elements. If it doesn't already have - /// enough capacity, will reallocate enough space plus comfortable slack - /// space to get amortized `O(1)` behavior. Will limit this behavior - /// if it would needlessly cause itself to panic. + /// Ensures that the buffer contains at least enough space to hold `len + + /// additional` elements. If it doesn't already have enough capacity, will + /// reallocate enough space plus comfortable slack space to get amortized + /// `O(1)` behavior. Will limit this behavior if it would needlessly cause + /// itself to panic. /// - /// If `used_capacity` exceeds `self.capacity()`, this may fail to actually allocate + /// If `len` exceeds `self.capacity()`, this may fail to actually allocate /// the requested space. This is not really unsafe, but the unsafe /// code *you* write that relies on the behavior of this function may break. /// @@ -287,8 +287,8 @@ impl RawVec { /// # vector.push_all(&[1, 3, 5, 7, 9]); /// # } /// ``` - pub fn reserve(&mut self, used_capacity: usize, needed_extra_capacity: usize) { - match self.try_reserve(used_capacity, needed_extra_capacity) { + pub fn reserve(&mut self, len: usize, additional: usize) { + match self.try_reserve(len, additional) { Err(CapacityOverflow) => capacity_overflow(), Err(AllocError { layout, .. }) => handle_alloc_error(layout), Ok(()) => { /* yay */ } @@ -296,28 +296,23 @@ impl RawVec { } /// The same as `reserve`, but returns on errors instead of panicking or aborting. - pub fn try_reserve( - &mut self, - used_capacity: usize, - needed_extra_capacity: usize, - ) -> Result<(), TryReserveError> { - if self.needs_to_grow(used_capacity, needed_extra_capacity) { - self.grow_amortized(used_capacity, needed_extra_capacity) + pub fn try_reserve(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> { + if self.needs_to_grow(len, additional) { + self.grow_amortized(len, additional) } else { Ok(()) } } - /// Ensures that the buffer contains at least enough space to hold - /// `used_capacity + needed_extra_capacity` elements. If it doesn't already, - /// will reallocate the minimum possible amount of memory necessary. - /// Generally this will be exactly the amount of memory necessary, - /// but in principle the allocator is free to give back more than what - /// we asked for. + /// Ensures that the buffer contains at least enough space to hold `len + + /// additional` elements. If it doesn't already, will reallocate the + /// minimum possible amount of memory necessary. Generally this will be + /// exactly the amount of memory necessary, but in principle the allocator + /// is free to give back more than we asked for. /// - /// If `used_capacity` exceeds `self.capacity()`, this may fail to actually allocate - /// the requested space. This is not really unsafe, but the unsafe - /// code *you* write that relies on the behavior of this function may break. + /// If `len` exceeds `self.capacity()`, this may fail to actually allocate + /// the requested space. This is not really unsafe, but the unsafe code + /// *you* write that relies on the behavior of this function may break. /// /// # Panics /// @@ -328,8 +323,8 @@ impl RawVec { /// # Aborts /// /// Aborts on OOM. - pub fn reserve_exact(&mut self, used_capacity: usize, needed_extra_capacity: usize) { - match self.try_reserve_exact(used_capacity, needed_extra_capacity) { + pub fn reserve_exact(&mut self, len: usize, additional: usize) { + match self.try_reserve_exact(len, additional) { Err(CapacityOverflow) => capacity_overflow(), Err(AllocError { layout, .. }) => handle_alloc_error(layout), Ok(()) => { /* yay */ } @@ -339,14 +334,10 @@ impl RawVec { /// The same as `reserve_exact`, but returns on errors instead of panicking or aborting. pub fn try_reserve_exact( &mut self, - used_capacity: usize, - needed_extra_capacity: usize, + len: usize, + additional: usize, ) -> Result<(), TryReserveError> { - if self.needs_to_grow(used_capacity, needed_extra_capacity) { - self.grow_exact(used_capacity, needed_extra_capacity) - } else { - Ok(()) - } + if self.needs_to_grow(len, additional) { self.grow_exact(len, additional) } else { Ok(()) } } /// Shrinks the allocation down to the specified amount. If the given amount @@ -371,8 +362,8 @@ impl RawVec { impl RawVec { /// Returns if the buffer needs to grow to fulfill the needed extra capacity. /// Mainly used to make inlining reserve-calls possible without inlining `grow`. - fn needs_to_grow(&self, used_capacity: usize, needed_extra_capacity: usize) -> bool { - needed_extra_capacity > self.capacity().wrapping_sub(used_capacity) + fn needs_to_grow(&self, len: usize, additional: usize) -> bool { + additional > self.capacity().wrapping_sub(len) } fn capacity_from_bytes(excess: usize) -> usize { @@ -392,13 +383,10 @@ impl RawVec { // so that all of the code that depends on `T` is within it, while as much // of the code that doesn't depend on `T` as possible is in functions that // are non-generic over `T`. - fn grow_amortized( - &mut self, - used_capacity: usize, - needed_extra_capacity: usize, - ) -> Result<(), TryReserveError> { + fn grow_amortized(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> { // This is ensured by the calling contexts. - debug_assert!(needed_extra_capacity > 0); + debug_assert!(additional > 0); + if mem::size_of::() == 0 { // Since we return a capacity of `usize::MAX` when `elem_size` is // 0, getting to here necessarily means the `RawVec` is overfull. @@ -406,8 +394,7 @@ impl RawVec { } // Nothing we can really do about these checks, sadly. - let required_cap = - used_capacity.checked_add(needed_extra_capacity).ok_or(CapacityOverflow)?; + let required_cap = len.checked_add(additional).ok_or(CapacityOverflow)?; // This guarantees exponential growth. The doubling cannot overflow // because `cap <= isize::MAX` and the type of `cap` is `usize`. @@ -440,18 +427,14 @@ impl RawVec { // The constraints on this method are much the same as those on // `grow_amortized`, but this method is usually instantiated less often so // it's less critical. - fn grow_exact( - &mut self, - used_capacity: usize, - needed_extra_capacity: usize, - ) -> Result<(), TryReserveError> { + fn grow_exact(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> { if mem::size_of::() == 0 { // Since we return a capacity of `usize::MAX` when the type size is // 0, getting to here necessarily means the `RawVec` is overfull. return Err(CapacityOverflow); } - let cap = used_capacity.checked_add(needed_extra_capacity).ok_or(CapacityOverflow)?; + let cap = len.checked_add(additional).ok_or(CapacityOverflow)?; let new_layout = Layout::array::(cap); // `finish_grow` is non-generic over `T`. diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index af943ecfd4800..2226737757bc5 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -2977,12 +2977,12 @@ impl Drain<'_, T> { } /// Makes room for inserting more elements before the tail. - unsafe fn move_tail(&mut self, extra_capacity: usize) { + unsafe fn move_tail(&mut self, additional: usize) { let vec = self.vec.as_mut(); - let used_capacity = self.tail_start + self.tail_len; - vec.buf.reserve(used_capacity, extra_capacity); + let len = self.tail_start + self.tail_len; + vec.buf.reserve(len, additional); - let new_tail_start = self.tail_start + extra_capacity; + let new_tail_start = self.tail_start + additional; let src = vec.as_ptr().add(self.tail_start); let dst = vec.as_mut_ptr().add(new_tail_start); ptr::copy(src, dst, self.tail_len); diff --git a/src/librustc_arena/lib.rs b/src/librustc_arena/lib.rs index fbf68a5ca3531..4da336f8e288d 100644 --- a/src/librustc_arena/lib.rs +++ b/src/librustc_arena/lib.rs @@ -146,18 +146,18 @@ impl TypedArena { } #[inline] - fn can_allocate(&self, len: usize) -> bool { - let available_capacity_bytes = self.end.get() as usize - self.ptr.get() as usize; - let at_least_bytes = len.checked_mul(mem::size_of::()).unwrap(); - available_capacity_bytes >= at_least_bytes + fn can_allocate(&self, additional: usize) -> bool { + let available_bytes = self.end.get() as usize - self.ptr.get() as usize; + let additional_bytes = additional.checked_mul(mem::size_of::()).unwrap(); + available_bytes >= additional_bytes } /// Ensures there's enough space in the current chunk to fit `len` objects. #[inline] - fn ensure_capacity(&self, len: usize) { - if !self.can_allocate(len) { - self.grow(len); - debug_assert!(self.can_allocate(len)); + fn ensure_capacity(&self, additional: usize) { + if !self.can_allocate(additional) { + self.grow(additional); + debug_assert!(self.can_allocate(additional)); } } @@ -214,13 +214,13 @@ impl TypedArena { /// Grows the arena. #[inline(never)] #[cold] - fn grow(&self, n: usize) { + fn grow(&self, additional: usize) { unsafe { // We need the element size to convert chunk sizes (ranging from // PAGE to HUGE_PAGE bytes) to element counts. let elem_size = cmp::max(1, mem::size_of::()); let mut chunks = self.chunks.borrow_mut(); - let mut new_capacity; + let mut new_cap; if let Some(last_chunk) = chunks.last_mut() { let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize; last_chunk.entries = used_bytes / mem::size_of::(); @@ -228,17 +228,17 @@ impl TypedArena { // If the previous chunk's capacity is less than HUGE_PAGE // bytes, then this chunk will be least double the previous // chunk's size. - new_capacity = last_chunk.storage.capacity(); - if new_capacity < HUGE_PAGE / elem_size { - new_capacity = new_capacity.checked_mul(2).unwrap(); + new_cap = last_chunk.storage.capacity(); + if new_cap < HUGE_PAGE / elem_size { + new_cap = new_cap.checked_mul(2).unwrap(); } } else { - new_capacity = PAGE / elem_size; + new_cap = PAGE / elem_size; } - // Also ensure that this chunk can fit `n`. - new_capacity = cmp::max(n, new_capacity); + // Also ensure that this chunk can fit `additional`. + new_cap = cmp::max(additional, new_cap); - let chunk = TypedArenaChunk::::new(new_capacity); + let chunk = TypedArenaChunk::::new(new_cap); self.ptr.set(chunk.start()); self.end.set(chunk.end()); chunks.push(chunk); @@ -342,10 +342,10 @@ impl DroplessArena { #[inline(never)] #[cold] - fn grow(&self, needed_bytes: usize) { + fn grow(&self, additional: usize) { unsafe { let mut chunks = self.chunks.borrow_mut(); - let mut new_capacity; + let mut new_cap; if let Some(last_chunk) = chunks.last_mut() { // There is no need to update `last_chunk.entries` because that // field isn't used by `DroplessArena`. @@ -353,17 +353,17 @@ impl DroplessArena { // If the previous chunk's capacity is less than HUGE_PAGE // bytes, then this chunk will be least double the previous // chunk's size. - new_capacity = last_chunk.storage.capacity(); - if new_capacity < HUGE_PAGE { - new_capacity = new_capacity.checked_mul(2).unwrap(); + new_cap = last_chunk.storage.capacity(); + if new_cap < HUGE_PAGE { + new_cap = new_cap.checked_mul(2).unwrap(); } } else { - new_capacity = PAGE; + new_cap = PAGE; } - // Also ensure that this chunk can fit `needed_bytes`. - new_capacity = cmp::max(needed_bytes, new_capacity); + // Also ensure that this chunk can fit `additional`. + new_cap = cmp::max(additional, new_cap); - let chunk = TypedArenaChunk::::new(new_capacity); + let chunk = TypedArenaChunk::::new(new_cap); self.ptr.set(chunk.start()); self.end.set(chunk.end()); chunks.push(chunk); From aef6335c15209bb69990492104a83dbaeb15326b Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Tue, 9 Jun 2020 10:51:15 +0200 Subject: [PATCH 13/15] Add mailmap entry --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 9639c1174964c..15ca403456a4e 100644 --- a/.mailmap +++ b/.mailmap @@ -266,6 +266,7 @@ Tim Chevalier Tim JIANG Tim Joseph Dumol Torsten Weber +Trevor Spiteri Ty Overby Ulrik Sverdrup bluss Ulrik Sverdrup bluss From 039da0b83242e76ce84424e34f2aa38844bcf0bf Mon Sep 17 00:00:00 2001 From: Nathan Corbyn Date: Tue, 9 Jun 2020 11:14:41 +0100 Subject: [PATCH 14/15] Update comments --- src/librustc_error_codes/error_codes/E0583.md | 2 +- src/librustc_error_codes/error_codes/E0761.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0583.md b/src/librustc_error_codes/error_codes/E0583.md index 2dcbbf8855669..701900bb0cd4b 100644 --- a/src/librustc_error_codes/error_codes/E0583.md +++ b/src/librustc_error_codes/error_codes/E0583.md @@ -2,7 +2,7 @@ A file wasn't found for an out-of-line module. Erroneous code example: -```ignore (compile_fail not working here; see Issue #43707) +```compile_fail,E0583 mod file_that_doesnt_exist; // error: file not found for module fn main() {} diff --git a/src/librustc_error_codes/error_codes/E0761.md b/src/librustc_error_codes/error_codes/E0761.md index e22ebcdc43190..c01574e413cfa 100644 --- a/src/librustc_error_codes/error_codes/E0761.md +++ b/src/librustc_error_codes/error_codes/E0761.md @@ -14,7 +14,7 @@ fn foo() {} fn foo() {} ``` -```ignore (compile_fail not working here; see Issue #43707) +```ignore (multiple source files required for compile_fail) mod ambiguous_module; // error: file for module `ambiguous_module` // found at both ambiguous_module.rs and // ambiguous_module.rs/mod.rs From 9495ee21b740fc1a8bcec651c5f2135806a71b03 Mon Sep 17 00:00:00 2001 From: Nathan Corbyn Date: Tue, 9 Jun 2020 11:21:36 +0100 Subject: [PATCH 15/15] Address comments --- src/librustc_mir/transform/validate.rs | 45 +++++++++++++++----------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/librustc_mir/transform/validate.rs b/src/librustc_mir/transform/validate.rs index dda416b01a21f..8150c328316cb 100644 --- a/src/librustc_mir/transform/validate.rs +++ b/src/librustc_mir/transform/validate.rs @@ -11,6 +11,7 @@ use rustc_middle::{ }; use rustc_span::def_id::DefId; +#[derive(Copy, Clone, Debug)] enum EdgeKind { Unwind, Normal, @@ -54,7 +55,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); } - fn check_bb(&self, location: Location, bb: BasicBlock, edge_kind: EdgeKind) { + fn check_edge(&self, location: Location, bb: BasicBlock, edge_kind: EdgeKind) { if let Some(bb) = self.body.basic_blocks().get(bb) { let src = self.body.basic_blocks().get(location.block).unwrap(); match (src.is_cleanup, bb.is_cleanup, edge_kind) { @@ -68,7 +69,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { _ => { self.fail( location, - format!("encountered jump that does not respect unwind invariants {:?}", bb) + format!( + "{:?} edge to {:?} violates unwind invariants (cleanup {:?} -> {:?})", + edge_kind, + bb, + src.is_cleanup, + bb.is_cleanup, + ) ) } } @@ -114,7 +121,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { match &terminator.kind { TerminatorKind::Goto { target } => { - self.check_bb(location, *target, EdgeKind::Normal); + self.check_edge(location, *target, EdgeKind::Normal); } TerminatorKind::SwitchInt { targets, values, .. } => { if targets.len() != values.len() + 1 { @@ -128,19 +135,19 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ); } for target in targets { - self.check_bb(location, *target, EdgeKind::Normal); + self.check_edge(location, *target, EdgeKind::Normal); } } TerminatorKind::Drop { target, unwind, .. } => { - self.check_bb(location, *target, EdgeKind::Normal); + self.check_edge(location, *target, EdgeKind::Normal); if let Some(unwind) = unwind { - self.check_bb(location, *unwind, EdgeKind::Unwind); + self.check_edge(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::DropAndReplace { target, unwind, .. } => { - self.check_bb(location, *target, EdgeKind::Normal); + self.check_edge(location, *target, EdgeKind::Normal); if let Some(unwind) = unwind { - self.check_bb(location, *unwind, EdgeKind::Unwind); + self.check_edge(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::Call { func, destination, cleanup, .. } => { @@ -153,10 +160,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ), } if let Some((_, target)) = destination { - self.check_bb(location, *target, EdgeKind::Normal); + self.check_edge(location, *target, EdgeKind::Normal); } if let Some(cleanup) = cleanup { - self.check_bb(location, *cleanup, EdgeKind::Unwind); + self.check_edge(location, *cleanup, EdgeKind::Unwind); } } TerminatorKind::Assert { cond, target, cleanup, .. } => { @@ -170,30 +177,30 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ), ); } - self.check_bb(location, *target, EdgeKind::Normal); + self.check_edge(location, *target, EdgeKind::Normal); if let Some(cleanup) = cleanup { - self.check_bb(location, *cleanup, EdgeKind::Unwind); + self.check_edge(location, *cleanup, EdgeKind::Unwind); } } TerminatorKind::Yield { resume, drop, .. } => { - self.check_bb(location, *resume, EdgeKind::Normal); + self.check_edge(location, *resume, EdgeKind::Normal); if let Some(drop) = drop { - self.check_bb(location, *drop, EdgeKind::Normal); + self.check_edge(location, *drop, EdgeKind::Normal); } } TerminatorKind::FalseEdge { real_target, imaginary_target } => { - self.check_bb(location, *real_target, EdgeKind::Normal); - self.check_bb(location, *imaginary_target, EdgeKind::Normal); + self.check_edge(location, *real_target, EdgeKind::Normal); + self.check_edge(location, *imaginary_target, EdgeKind::Normal); } TerminatorKind::FalseUnwind { real_target, unwind } => { - self.check_bb(location, *real_target, EdgeKind::Normal); + self.check_edge(location, *real_target, EdgeKind::Normal); if let Some(unwind) = unwind { - self.check_bb(location, *unwind, EdgeKind::Unwind); + self.check_edge(location, *unwind, EdgeKind::Unwind); } } TerminatorKind::InlineAsm { destination, .. } => { if let Some(destination) = destination { - self.check_bb(location, *destination, EdgeKind::Normal); + self.check_edge(location, *destination, EdgeKind::Normal); } } // Nothing to validate for these.