diff options
52 files changed, 426 insertions, 122 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index a5c7d4c8e20..10da2f803af 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -185,7 +185,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // No question return true; } - // Compare layout + if caller_abi.layout.size != callee_abi.layout.size + || caller_abi.layout.align.abi != callee_abi.layout.align.abi + { + // This cannot go well... + // FIXME: What about unsized types? + return false; + } + // The rest *should* be okay, but we are extra conservative. match (caller_abi.layout.abi, callee_abi.layout.abi) { // Different valid ranges are okay (once we enforce validity, // that will take care to make it UB to leave the range, just diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 54c2daf9ac2..665b07c9f89 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -4,6 +4,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_index::bit_set::BitSet; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::interpret::Scalar; +use rustc_middle::mir::visit::NonUseContext::VarDebugInfo; use rustc_middle::mir::visit::{PlaceContext, Visitor}; use rustc_middle::mir::{ traversal, AggregateKind, BasicBlock, BinOp, Body, BorrowKind, Local, Location, MirPass, @@ -302,9 +303,17 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { self.super_projection_elem(local, proj_base, elem, context, location); } - fn visit_place(&mut self, place: &Place<'tcx>, _: PlaceContext, _: Location) { + fn visit_place(&mut self, place: &Place<'tcx>, cntxt: PlaceContext, location: Location) { // Set off any `bug!`s in the type computation code let _ = place.ty(&self.body.local_decls, self.tcx); + + if self.mir_phase >= MirPhase::Derefered + && place.projection.len() > 1 + && cntxt != PlaceContext::NonUse(VarDebugInfo) + && place.projection[1..].contains(&ProjectionElem::Deref) + { + self.fail(location, format!("{:?}, has deref at the wrong place", place)); + } } fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 71cea005cf8..b09d39996f4 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -172,12 +172,14 @@ pub enum MirPhase { /// terminator means that the auto-generated drop glue will be invoked. Also, `Copy` operands /// are allowed for non-`Copy` types. DropsLowered = 3, + /// After this projections may only contain deref projections as the first element. + Derefered = 4, /// Beginning with this phase, the following variant is disallowed: /// * [`Rvalue::Aggregate`] for any `AggregateKind` except `Array` /// /// And the following variant is allowed: /// * [`StatementKind::SetDiscriminant`] - Deaggregated = 4, + Deaggregated = 5, /// Before this phase, generators are in the "source code" form, featuring `yield` statements /// and such. With this phase change, they are transformed into a proper state machine. Running /// optimizations before this change can be potentially dangerous because the source code is to @@ -191,8 +193,8 @@ pub enum MirPhase { /// Beginning with this phase, the following variants are disallowed: /// * [`TerminatorKind::Yield`](terminator::TerminatorKind::Yield) /// * [`TerminatorKind::GeneratorDrop`](terminator::TerminatorKind::GeneratorDrop) - GeneratorsLowered = 5, - Optimized = 6, + GeneratorsLowered = 6, + Optimized = 7, } impl MirPhase { diff --git a/compiler/rustc_mir_transform/src/deref_separator.rs b/compiler/rustc_mir_transform/src/deref_separator.rs index 57a95a67df7..bfb3ad1be27 100644 --- a/compiler/rustc_mir_transform/src/deref_separator.rs +++ b/compiler/rustc_mir_transform/src/deref_separator.rs @@ -1,9 +1,11 @@ use crate::MirPass; use rustc_index::vec::IndexVec; use rustc_middle::mir::patch::MirPatch; +use rustc_middle::mir::visit::NonUseContext::VarDebugInfo; use rustc_middle::mir::visit::{MutVisitor, PlaceContext}; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; + pub struct Derefer; pub struct DerefChecker<'tcx> { @@ -17,63 +19,68 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> { self.tcx } - fn visit_place(&mut self, place: &mut Place<'tcx>, _: PlaceContext, loc: Location) { - let mut place_local = place.local; - let mut last_len = 0; - let mut last_deref_idx = 0; + fn visit_place(&mut self, place: &mut Place<'tcx>, cntxt: PlaceContext, loc: Location) { + if !place.projection.is_empty() + && cntxt != PlaceContext::NonUse(VarDebugInfo) + && place.projection[1..].contains(&ProjectionElem::Deref) + { + let mut place_local = place.local; + let mut last_len = 0; + let mut last_deref_idx = 0; - let mut prev_temp: Option<Local> = None; + let mut prev_temp: Option<Local> = None; - for (idx, (p_ref, p_elem)) in place.iter_projections().enumerate() { - if p_elem == ProjectionElem::Deref && !p_ref.projection.is_empty() { - last_deref_idx = idx; - } - } - - for (idx, (p_ref, p_elem)) in place.iter_projections().enumerate() { - if p_elem == ProjectionElem::Deref && !p_ref.projection.is_empty() { - let ty = p_ref.ty(&self.local_decls, self.tcx).ty; - let temp = self.patcher.new_local_with_info( - ty, - self.local_decls[p_ref.local].source_info.span, - Some(Box::new(LocalInfo::DerefTemp)), - ); - - self.patcher.add_statement(loc, StatementKind::StorageLive(temp)); - - // We are adding current p_ref's projections to our - // temp value, excluding projections we already covered. - let deref_place = Place::from(place_local) - .project_deeper(&p_ref.projection[last_len..], self.tcx); - - self.patcher.add_assign( - loc, - Place::from(temp), - Rvalue::Use(Operand::Move(deref_place)), - ); - place_local = temp; - last_len = p_ref.projection.len(); - - // Change `Place` only if we are actually at the Place's last deref - if idx == last_deref_idx { - let temp_place = - Place::from(temp).project_deeper(&place.projection[idx..], self.tcx); - *place = temp_place; + for (idx, elem) in place.projection[0..].iter().enumerate() { + if *elem == ProjectionElem::Deref { + last_deref_idx = idx; } - - // We are destroying the previous temp since it's no longer used. - if let Some(prev_temp) = prev_temp { - self.patcher.add_statement(loc, StatementKind::StorageDead(prev_temp)); + } + for (idx, (p_ref, p_elem)) in place.iter_projections().enumerate() { + if !p_ref.projection.is_empty() && p_elem == ProjectionElem::Deref { + let ty = p_ref.ty(&self.local_decls, self.tcx).ty; + let temp = self.patcher.new_local_with_info( + ty, + self.local_decls[p_ref.local].source_info.span, + Some(Box::new(LocalInfo::DerefTemp)), + ); + + self.patcher.add_statement(loc, StatementKind::StorageLive(temp)); + + // We are adding current p_ref's projections to our + // temp value, excluding projections we already covered. + let deref_place = Place::from(place_local) + .project_deeper(&p_ref.projection[last_len..], self.tcx); + + self.patcher.add_assign( + loc, + Place::from(temp), + Rvalue::Use(Operand::Move(deref_place)), + ); + place_local = temp; + last_len = p_ref.projection.len(); + + // Change `Place` only if we are actually at the Place's last deref + if idx == last_deref_idx { + let temp_place = + Place::from(temp).project_deeper(&place.projection[idx..], self.tcx); + *place = temp_place; + } + + // We are destroying the previous temp since it's no longer used. + if let Some(prev_temp) = prev_temp { + self.patcher.add_statement(loc, StatementKind::StorageDead(prev_temp)); + } + + prev_temp = Some(temp); } - - prev_temp = Some(temp); } - } - // Since we won't be able to reach final temp, we destroy it outside the loop. - if let Some(prev_temp) = prev_temp { - let last_loc = Location { block: loc.block, statement_index: loc.statement_index + 1 }; - self.patcher.add_statement(last_loc, StatementKind::StorageDead(prev_temp)); + // Since we won't be able to reach final temp, we destroy it outside the loop. + if let Some(prev_temp) = prev_temp { + let last_loc = + Location { block: loc.block, statement_index: loc.statement_index + 1 }; + self.patcher.add_statement(last_loc, StatementKind::StorageDead(prev_temp)); + } } } } @@ -92,5 +99,6 @@ pub fn deref_finder<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { impl<'tcx> MirPass<'tcx> for Derefer { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { deref_finder(tcx, body); + body.phase = MirPhase::Derefered; } } diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index 4a3505ca3ff..9eb77f60213 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -49,6 +49,7 @@ //! For generators with state 1 (returned) and state 2 (poisoned) it does nothing. //! Otherwise it drops all the values in scope at the last suspension point. +use crate::deref_separator::deref_finder; use crate::simplify; use crate::util::expand_aggregate; use crate::MirPass; @@ -1368,6 +1369,9 @@ impl<'tcx> MirPass<'tcx> for StateTransform { // Create the Generator::resume function create_generator_resume_function(tcx, transform, body, can_return); + + // Run derefer to fix Derefs that are not in the first place + deref_finder(tcx, body); } } diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 66fb01bd464..9526c0acc66 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -1,5 +1,5 @@ //! Inlining pass for MIR functions - +use crate::deref_separator::deref_finder; use rustc_attr::InlineAttr; use rustc_index::bit_set::BitSet; use rustc_index::vec::Idx; @@ -53,6 +53,7 @@ impl<'tcx> MirPass<'tcx> for Inline { debug!("running simplify cfg on {:?}", body.source); CfgSimplifier::new(body).simplify(); remove_dead_blocks(tcx, body); + deref_finder(tcx, body); } } } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index e99347206fe..6720399aacb 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -996,35 +996,24 @@ impl<'a> Parser<'a> { fn parse_item_foreign_mod( &mut self, attrs: &mut Vec<Attribute>, - unsafety: Unsafe, + mut unsafety: Unsafe, ) -> PResult<'a, ItemInfo> { - let sp_start = self.prev_token.span; let abi = self.parse_abi(); // ABI? - match self.parse_item_list(attrs, |p| p.parse_foreign_item(ForceCollect::No)) { - Ok(items) => { - let module = ast::ForeignMod { unsafety, abi, items }; - Ok((Ident::empty(), ItemKind::ForeignMod(module))) - } - Err(mut err) => { - let current_qual_sp = self.prev_token.span; - let current_qual_sp = current_qual_sp.to(sp_start); - if let Ok(current_qual) = self.span_to_snippet(current_qual_sp) { - // FIXME(davidtwco): avoid depending on the error message text - if err.message[0].0.expect_str() == "expected `{`, found keyword `unsafe`" { - let invalid_qual_sp = self.token.uninterpolated_span(); - let invalid_qual = self.span_to_snippet(invalid_qual_sp).unwrap(); - - err.span_suggestion( - current_qual_sp.to(invalid_qual_sp), - &format!("`{}` must come before `{}`", invalid_qual, current_qual), - format!("{} {}", invalid_qual, current_qual), - Applicability::MachineApplicable, - ).note("keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`"); - } - } - Err(err) - } + if unsafety == Unsafe::No + && self.token.is_keyword(kw::Unsafe) + && self.look_ahead(1, |t| t.kind == token::OpenDelim(Delimiter::Brace)) + { + let mut err = self.expect(&token::OpenDelim(Delimiter::Brace)).unwrap_err(); + err.emit(); + unsafety = Unsafe::Yes(self.token.span); + self.eat_keyword(kw::Unsafe); } + let module = ast::ForeignMod { + unsafety, + abi, + items: self.parse_item_list(attrs, |p| p.parse_foreign_item(ForceCollect::No))?, + }; + Ok((Ident::empty(), ItemKind::ForeignMod(module))) } /// Parses a foreign item (one in an `extern { ... }` block). diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 09854336599..7499e5efdee 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -105,12 +105,6 @@ pub(super) fn check_fn<'a, 'tcx>( DUMMY_SP, param_env, )); - // HACK(oli-obk): we rewrite the declared return type, too, so that we don't end up inferring all - // unconstrained RPIT to have `()` as their hidden type. This would happen because further down we - // compare the ret_coercion with declared_ret_ty, and anything uninferred would be inferred to the - // opaque type itself. That again would cause writeback to assume we have a recursive call site - // and do the sadly stabilized fallback to `()`. - let declared_ret_ty = ret_ty; fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(ret_ty))); fcx.ret_type_span = Some(decl.output.span()); @@ -254,7 +248,12 @@ pub(super) fn check_fn<'a, 'tcx>( fcx.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::DynReturnFn, span }); debug!("actual_return_ty replaced with {:?}", actual_return_ty); } - fcx.demand_suptype(span, declared_ret_ty, actual_return_ty); + + // HACK(oli-obk, compiler-errors): We should be comparing this against + // `declared_ret_ty`, but then anything uninferred would be inferred to + // the opaque type itself. That again would cause writeback to assume + // we have a recursive call site and do the sadly stabilized fallback to `()`. + fcx.demand_suptype(span, ret_ty, actual_return_ty); // Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !` if let Some(panic_impl_did) = tcx.lang_items().panic_impl() diff --git a/library/alloc/src/collections/vec_deque/iter.rs b/library/alloc/src/collections/vec_deque/iter.rs index 19198ab3aa1..e696d7ed636 100644 --- a/library/alloc/src/collections/vec_deque/iter.rs +++ b/library/alloc/src/collections/vec_deque/iter.rs @@ -13,9 +13,15 @@ use super::{count, wrap_index, RingSlices}; /// [`iter`]: super::VecDeque::iter #[stable(feature = "rust1", since = "1.0.0")] pub struct Iter<'a, T: 'a> { - pub(crate) ring: &'a [MaybeUninit<T>], - pub(crate) tail: usize, - pub(crate) head: usize, + ring: &'a [MaybeUninit<T>], + tail: usize, + head: usize, +} + +impl<'a, T> Iter<'a, T> { + pub(super) fn new(ring: &'a [MaybeUninit<T>], tail: usize, head: usize) -> Self { + Iter { ring, tail, head } + } } #[stable(feature = "collection_debug", since = "1.17.0")] diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 04900ead579..e28a94386c7 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -1013,7 +1013,7 @@ impl<T, A: Allocator> VecDeque<T, A> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn iter(&self) -> Iter<'_, T> { - Iter { tail: self.tail, head: self.head, ring: unsafe { self.buffer_as_slice() } } + Iter::new(unsafe { self.buffer_as_slice() }, self.tail, self.head) } /// Returns a front-to-back iterator that returns mutable references. @@ -1192,12 +1192,8 @@ impl<T, A: Allocator> VecDeque<T, A> { R: RangeBounds<usize>, { let (tail, head) = self.range_tail_head(range); - Iter { - tail, - head, - // The shared reference we have in &self is maintained in the '_ of Iter. - ring: unsafe { self.buffer_as_slice() }, - } + // The shared reference we have in &self is maintained in the '_ of Iter. + Iter::new(unsafe { self.buffer_as_slice() }, tail, head) } /// Creates an iterator that covers the specified mutable range in the deque. @@ -1313,16 +1309,15 @@ impl<T, A: Allocator> VecDeque<T, A> { self.head = drain_tail; let deque = NonNull::from(&mut *self); - let iter = Iter { - tail: drain_tail, - head: drain_head, + unsafe { // Crucially, we only create shared references from `self` here and read from // it. We do not write to `self` nor reborrow to a mutable reference. // Hence the raw pointer we created above, for `deque`, remains valid. - ring: unsafe { self.buffer_as_slice() }, - }; + let ring = self.buffer_as_slice(); + let iter = Iter::new(ring, drain_tail, drain_head); - unsafe { Drain::new(drain_head, head, iter, deque) } + Drain::new(drain_head, head, iter, deque) + } } /// Clears the deque, removing all values. diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index 73b75ea4d83..ed398b56612 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -604,9 +604,14 @@ use crate::string; #[cfg(not(no_global_oom_handling))] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] +#[inline] pub fn format(args: Arguments<'_>) -> string::String { - let capacity = args.estimated_capacity(); - let mut output = string::String::with_capacity(capacity); - output.write_fmt(args).expect("a formatting trait implementation returned an error"); - output + fn format_inner(args: Arguments<'_>) -> string::String { + let capacity = args.estimated_capacity(); + let mut output = string::String::with_capacity(capacity); + output.write_fmt(args).expect("a formatting trait implementation returned an error"); + output + } + + args.as_str().map_or_else(|| format_inner(args), crate::borrow::ToOwned::to_owned) } diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/source-script.js index aaac878d3a3..58c036e0b3c 100644 --- a/src/librustdoc/html/static/js/source-script.js +++ b/src/librustdoc/html/static/js/source-script.js @@ -205,6 +205,10 @@ const handleSourceHighlight = (function() { return ev => { let cur_line_id = parseInt(ev.target.id, 10); + // It can happen when clicking not on a line number span. + if (isNaN(cur_line_id)) { + return; + } ev.preventDefault(); if (ev.shiftKey && prev_line_id) { diff --git a/src/test/mir-opt/derefer_inline_test.main.Derefer.diff b/src/test/mir-opt/derefer_inline_test.main.Derefer.diff new file mode 100644 index 00000000000..e131adae2b6 --- /dev/null +++ b/src/test/mir-opt/derefer_inline_test.main.Derefer.diff @@ -0,0 +1,69 @@ +- // MIR for `main` before Derefer ++ // MIR for `main` after Derefer + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/derefer_inline_test.rs:9:11: 9:11 + let _1: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + let mut _2: usize; // in scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + let mut _3: usize; // in scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + let mut _4: *mut u8; // in scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + let mut _5: std::boxed::Box<std::boxed::Box<u32>>; // in scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + let mut _6: (); // in scope 0 at $DIR/derefer_inline_test.rs:10:11: 10:12 + scope 1 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + _2 = SizeOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:10:5: 10:12 + _3 = AlignOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:10:5: 10:12 + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/derefer_inline_test.rs:10:5: 10:12 + // mir::Constant + // + span: $DIR/derefer_inline_test.rs:10:5: 10:12 + // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageLive(_5); // scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + _5 = ShallowInitBox(move _4, std::boxed::Box<u32>); // scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + (*_5) = f() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/derefer_inline_test.rs:10:9: 10:12 + // mir::Constant + // + span: $DIR/derefer_inline_test.rs:10:9: 10:10 + // + literal: Const { ty: fn() -> Box<u32> {f}, val: Value(Scalar(<ZST>)) } + } + + bb2: { + _1 = move _5; // scope 0 at $DIR/derefer_inline_test.rs:10:5: 10:12 + goto -> bb3; // scope 0 at $DIR/derefer_inline_test.rs:10:11: 10:12 + } + + bb3: { + StorageDead(_5); // scope 0 at $DIR/derefer_inline_test.rs:10:11: 10:12 + drop(_1) -> [return: bb4, unwind: bb6]; // scope 0 at $DIR/derefer_inline_test.rs:10:12: 10:13 + } + + bb4: { + StorageDead(_1); // scope 0 at $DIR/derefer_inline_test.rs:10:12: 10:13 + _0 = const (); // scope 0 at $DIR/derefer_inline_test.rs:9:11: 11:2 + return; // scope 0 at $DIR/derefer_inline_test.rs:11:2: 11:2 + } + + bb5 (cleanup): { + goto -> bb8; // scope 0 at $DIR/derefer_inline_test.rs:10:11: 10:12 + } + + bb6 (cleanup): { + resume; // scope 0 at $DIR/derefer_inline_test.rs:9:1: 11:2 + } + + bb7 (cleanup): { + _6 = alloc::alloc::box_free::<Box<u32>, std::alloc::Global>(move (_5.0: std::ptr::Unique<std::boxed::Box<u32>>), move (_5.1: std::alloc::Global)) -> bb6; // scope 0 at $DIR/derefer_inline_test.rs:10:11: 10:12 + // mir::Constant + // + span: $DIR/derefer_inline_test.rs:10:11: 10:12 + // + literal: Const { ty: unsafe fn(Unique<Box<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Box<u32>, std::alloc::Global>}, val: Value(Scalar(<ZST>)) } + } + + bb8 (cleanup): { + goto -> bb7; // scope 0 at $DIR/derefer_inline_test.rs:10:11: 10:12 + } + } + diff --git a/src/test/mir-opt/derefer_inline_test.rs b/src/test/mir-opt/derefer_inline_test.rs new file mode 100644 index 00000000000..191a8cbbef4 --- /dev/null +++ b/src/test/mir-opt/derefer_inline_test.rs @@ -0,0 +1,11 @@ +// EMIT_MIR derefer_inline_test.main.Derefer.diff +// ignore-wasm32 compiled with panic=abort by default + +#![feature(box_syntax)] +#[inline] +fn f() -> Box<u32> { + box 0 +} +fn main() { + box f(); +} diff --git a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff index 953d7b85c5b..d1ab29b8a21 100644 --- a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -57,6 +57,10 @@ StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:34:24: 34:25 StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:35:1: 35:2 return; // scope 0 at $DIR/dyn-trait.rs:35:2: 35:2 ++ } ++ ++ bb3 (cleanup): { ++ resume; // scope 0 at $DIR/dyn-trait.rs:32:1: 35:2 } } diff --git a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff index 93bba58825d..0c44c3ada0f 100644 --- a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -32,6 +32,10 @@ + StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:21:21: 21:22 StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:27:15: 27:16 return; // scope 0 at $DIR/dyn-trait.rs:28:2: 28:2 ++ } ++ ++ bb2 (cleanup): { ++ resume; // scope 0 at $DIR/dyn-trait.rs:26:1: 28:2 } } diff --git a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir index b2745a17e97..ade6ccfc7f1 100644 --- a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir @@ -41,4 +41,8 @@ fn bar() -> bool { StorageDead(_1); // scope 0 at $DIR/inline-any-operand.rs:13:1: 13:2 return; // scope 0 at $DIR/inline-any-operand.rs:13:2: 13:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/inline-any-operand.rs:10:1: 13:2 + } } diff --git a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir index 4d6cdafd12d..66fc5fa80ea 100644 --- a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -46,4 +46,8 @@ fn foo(_1: T, _2: i32) -> i32 { StorageDead(_3); // scope 0 at $DIR/inline-closure.rs:13:1: 13:2 return; // scope 0 at $DIR/inline-closure.rs:13:2: 13:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/inline-closure.rs:10:1: 13:2 + } } diff --git a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index 45281302f92..7bb17dab061 100644 --- a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -53,4 +53,8 @@ fn foo(_1: T, _2: &i32) -> i32 { StorageDead(_3); // scope 0 at $DIR/inline-closure-borrows-arg.rs:17:1: 17:2 return; // scope 0 at $DIR/inline-closure-borrows-arg.rs:17:2: 17:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/inline-closure-borrows-arg.rs:11:1: 17:2 + } } diff --git a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index 75e37092ff3..c6b49b66dc5 100644 --- a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -66,4 +66,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) { StorageDead(_3); // scope 0 at $DIR/inline-closure-captures.rs:13:1: 13:2 return; // scope 0 at $DIR/inline-closure-captures.rs:13:2: 13:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/inline-closure-captures.rs:10:1: 13:2 + } } diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff index 77eb326cd82..fd9a540ca16 100644 --- a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff @@ -19,6 +19,10 @@ StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:24:18: 24:19 _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:23:37: 25:2 return; // scope 0 at $DIR/inline-compatibility.rs:25:2: 25:2 ++ } ++ ++ bb1 (cleanup): { ++ resume; // scope 0 at $DIR/inline-compatibility.rs:23:1: 25:2 } } diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff index a32db48715c..e7db7aa382f 100644 --- a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff @@ -19,6 +19,10 @@ StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:13:21: 13:22 _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:12:40: 14:2 return; // scope 0 at $DIR/inline-compatibility.rs:14:2: 14:2 ++ } ++ ++ bb1 (cleanup): { ++ resume; // scope 0 at $DIR/inline-compatibility.rs:12:1: 14:2 } } diff --git a/src/test/mir-opt/inline/inline_cycle.one.Inline.diff b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff index b6615739a21..b732e7cdb9b 100644 --- a/src/test/mir-opt/inline/inline_cycle.one.Inline.diff +++ b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff @@ -22,6 +22,10 @@ StorageDead(_1); // scope 0 at $DIR/inline-cycle.rs:14:24: 14:25 _0 = const (); // scope 0 at $DIR/inline-cycle.rs:13:10: 15:2 return; // scope 0 at $DIR/inline-cycle.rs:15:2: 15:2 ++ } ++ ++ bb2 (cleanup): { ++ resume; // scope 0 at $DIR/inline-cycle.rs:13:1: 15:2 } } diff --git a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff index 4e461562004..eac5bf8edec 100644 --- a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff +++ b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff @@ -41,6 +41,10 @@ StorageDead(_1); // scope 0 at $DIR/inline-cycle.rs:49:12: 49:13 _0 = const (); // scope 0 at $DIR/inline-cycle.rs:48:10: 50:2 return; // scope 0 at $DIR/inline-cycle.rs:50:2: 50:2 ++ } ++ ++ bb2 (cleanup): { ++ resume; // scope 0 at $DIR/inline-cycle.rs:48:1: 50:2 } } diff --git a/src/test/mir-opt/inline/inline_diverging.f.Inline.diff b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff index eb579b53b6c..ff25c5b4bc3 100644 --- a/src/test/mir-opt/inline/inline_diverging.f.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff @@ -19,6 +19,10 @@ + + bb1: { + goto -> bb1; // scope 1 at $DIR/inline-diverging.rs:39:5: 39:12 ++ } ++ ++ bb2 (cleanup): { ++ resume; // scope 0 at $DIR/inline-diverging.rs:7:1: 9:2 } } diff --git a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff index 3ce823a0e33..da55260e284 100644 --- a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff @@ -44,6 +44,10 @@ + // mir::Constant + // + span: $SRC_DIR/std/src/panic.rs:LL:COL + // + literal: Const { ty: &str, val: Value(Slice(..)) } ++ } ++ ++ bb3 (cleanup): { ++ resume; // scope 0 at $DIR/inline-diverging.rs:12:1: 18:2 } } diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff index 647c27d11e5..0a19daa5045 100644 --- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -52,6 +52,10 @@ + + bb1: { + goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:39:5: 39:12 ++ } ++ ++ bb2 (cleanup): { ++ resume; // scope 0 at $DIR/inline-diverging.rs:21:1: 23:2 } } diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index 48432c1ddd8..3e1c4a46701 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -30,6 +30,9 @@ + let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:15:9: 15:9 + let _11: bool; // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7 + let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 + } bb0: { @@ -73,7 +76,10 @@ + StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 + StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 + StorageLive(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46 -+ _12 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ StorageLive(_13); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ _13 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ _12 = discriminant((*_13)); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ StorageDead(_13); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 + switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 } @@ -118,7 +124,10 @@ + Deinit(_1); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 + ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 + discriminant(_1) = 0; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 -+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 3; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 ++ StorageLive(_14); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 ++ _14 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 ++ discriminant((*_14)) = 3; // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 ++ StorageDead(_14); // scope 6 at $DIR/inline-generator.rs:15:11: 15:39 + goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:11: 15:39 + } + @@ -129,7 +138,10 @@ + Deinit(_1); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 + ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 + discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 -+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ StorageLive(_15); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ _15 = move (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ discriminant((*_15)) = 1; // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 ++ StorageDead(_15); // scope 6 at $DIR/inline-generator.rs:15:41: 15:41 + goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:41: 15:41 + } + diff --git a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff index 916244f1f6a..65891cbb660 100644 --- a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -39,6 +39,10 @@ StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:53:30: 53:31 _0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:50:18: 54:2 return; // scope 0 at $DIR/inline-instruction-set.rs:54:2: 54:2 ++ } ++ ++ bb3 (cleanup): { ++ resume; // scope 0 at $DIR/inline-instruction-set.rs:50:1: 54:2 } } diff --git a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff index 8907bae9177..20e1d0ae4d5 100644 --- a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -41,6 +41,10 @@ StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:46:30: 46:31 _0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:41:14: 47:2 return; // scope 0 at $DIR/inline-instruction-set.rs:47:2: 47:2 ++ } ++ ++ bb3 (cleanup): { ++ resume; // scope 0 at $DIR/inline-instruction-set.rs:41:1: 47:2 } } diff --git a/src/test/mir-opt/inline/inline_options.main.Inline.after.mir b/src/test/mir-opt/inline/inline_options.main.Inline.after.mir index 9fd08f141dc..eca76df576b 100644 --- a/src/test/mir-opt/inline/inline_options.main.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_options.main.Inline.after.mir @@ -52,4 +52,8 @@ fn main() -> () { _0 = const (); // scope 0 at $DIR/inline-options.rs:8:11: 11:2 return; // scope 0 at $DIR/inline-options.rs:11:2: 11:2 } + + bb5 (cleanup): { + resume; // scope 0 at $DIR/inline-options.rs:8:1: 11:2 + } } diff --git a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir index 1aa859484f6..2d85ff9a0cb 100644 --- a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir @@ -69,4 +69,8 @@ fn bar() -> bool { StorageDead(_4); // scope 0 at $DIR/inline-retag.rs:13:1: 13:2 return; // scope 0 at $DIR/inline-retag.rs:13:2: 13:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/inline-retag.rs:10:1: 13:2 + } } diff --git a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff index a7e0a52f743..7170cd40572 100644 --- a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff +++ b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff @@ -21,6 +21,10 @@ + _0 = (*_2); // scope 1 at $SRC_DIR/core/src/clone.rs:LL:COL StorageDead(_2); // scope 0 at $DIR/inline-shims.rs:6:13: 6:14 return; // scope 0 at $DIR/inline-shims.rs:7:2: 7:2 ++ } ++ ++ bb1 (cleanup): { ++ resume; // scope 0 at $DIR/inline-shims.rs:5:1: 7:2 } } diff --git a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff index b6d5f51c173..aa55c90fcfb 100644 --- a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff +++ b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff @@ -51,6 +51,10 @@ + + bb3: { + drop((((*_5) as Some).0: B)) -> bb2; // scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL ++ } ++ ++ bb4 (cleanup): { ++ resume; // scope 0 at $DIR/inline-shims.rs:10:1: 13:2 } } diff --git a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff index 97ff6f75f24..8e93baf6a70 100644 --- a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff @@ -23,6 +23,10 @@ _0 = const (); // scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 StorageDead(_1); // scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 return; // scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 ++ } ++ ++ bb1 (cleanup): { ++ resume; // scope 0 at $DIR/inline-specialization.rs:4:1: 6:2 } } diff --git a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir index 9d8818e657e..64375b6edc9 100644 --- a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -29,4 +29,8 @@ fn test2(_1: &dyn X) -> bool { StorageDead(_2); // scope 0 at $DIR/inline-trait-method_2.rs:5:11: 5:12 return; // scope 0 at $DIR/inline-trait-method_2.rs:6:2: 6:2 } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/inline-trait-method_2.rs:4:1: 6:2 + } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir index e9c02cf2c67..56a23cde0c7 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir @@ -27,4 +27,8 @@ fn a(_1: &mut [T]) -> &mut [T] { StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:4:1: 4:2 return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:4:2: 4:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:2:1: 4:2 + } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index a18ff0e35fe..0bb3445a2d0 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -35,4 +35,8 @@ fn b(_1: &mut Box<T>) -> &mut T { StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:9:1: 9:2 return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:9:2: 9:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:7:1: 9:2 + } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir index 23f33daaa57..326b2ad71c0 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir @@ -19,4 +19,8 @@ fn c(_1: &[T]) -> &[T] { StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:14:1: 14:2 return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:14:2: 14:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:12:1: 14:2 + } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir index d079ba59ffc..c22852b99f4 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -23,4 +23,8 @@ fn d(_1: &Box<T>) -> &T { StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:19:1: 19:2 return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:19:2: 19:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:17:1: 19:2 + } } diff --git a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index b9ddbacc0e7..7c3048a69af 100644 --- a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -39,4 +39,8 @@ fn main() -> () { StorageDead(_1); // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:7:1: 7:2 return; // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:7:2: 7:2 } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:4:1: 7:2 + } } diff --git a/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff b/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff index 5131e2f088d..447fe654c0c 100644 --- a/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff +++ b/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff @@ -96,5 +96,9 @@ _10 = discriminant(_7); // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19 switchInt(move _10) -> [0_isize: bb3, otherwise: bb2]; // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19 } + + bb5 (cleanup): { + resume; // scope 0 at $DIR/remove_storage_markers.rs:6:1: 11:2 + } } diff --git a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff index 714136a9e24..44eda308bdf 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff @@ -22,6 +22,10 @@ StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:4:12: 4:13 - nop; // scope 0 at $DIR/remove_unneeded_drops.rs:3:17: 5:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:5:2: 5:2 +- } +- +- bb2 (cleanup): { +- resume; // scope 0 at $DIR/remove_unneeded_drops.rs:3:1: 5:2 } } diff --git a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff index 3dca9f3e1b1..85de00e7001 100644 --- a/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff +++ b/src/test/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff @@ -22,6 +22,10 @@ StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:14:12: 14:13 - nop; // scope 0 at $DIR/remove_unneeded_drops.rs:13:36: 15:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:15:2: 15:2 +- } +- +- bb2 (cleanup): { +- resume; // scope 0 at $DIR/remove_unneeded_drops.rs:13:1: 15:2 } } diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff index 5da2ad1a27d..d2dbfbe1093 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff @@ -85,5 +85,9 @@ bb4: { return; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 } + + bb5 (cleanup): { + resume; // scope 0 at $DIR/simplify-arm.rs:35:1: 41:2 + } } diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff index 528828ad075..a993ea73665 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff @@ -85,5 +85,9 @@ bb4: { return; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2 } + + bb5 (cleanup): { + resume; // scope 0 at $DIR/simplify-arm.rs:35:1: 41:2 + } } diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml index ad7080c39b8..509739c9f29 100644 --- a/src/test/rustdoc-gui/source-code-page.goml +++ b/src/test/rustdoc-gui/source-code-page.goml @@ -2,9 +2,9 @@ goto: file://|DOC_PATH|/src/test_docs/lib.rs.html // Check that we can click on the line number. click: ".line-numbers > span:nth-child(4)" // This is the span for line 4. -// Unfortunately, "#4" isn't a valid query selector, so we have to go around that limitation -// by instead getting the nth span. -assert-attribute: (".line-numbers > span:nth-child(4)", {"class": "line-highlighted"}) +// Ensure that the page URL was updated. +assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH) +assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) // We now check that the good spans are highlighted goto: file://|DOC_PATH|/src/test_docs/lib.rs.html#4-6 assert-attribute-false: (".line-numbers > span:nth-child(3)", {"class": "line-highlighted"}) @@ -17,3 +17,13 @@ compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y")) // Assert that the line numbers text is aligned to the right. assert-css: (".line-numbers", {"text-align": "right"}) + +// Now let's check that clicking on something else than the line number doesn't +// do anything (and certainly not add a `#NaN` to the URL!). +show-text: true +goto: file://|DOC_PATH|/src/test_docs/lib.rs.html +// We use this assert-position to know where we will click. +assert-position: ("//*[@id='1']", {"x": 104, "y": 103}) +// We click on the left of the "1" span but still in the "line-number" `<pre>`. +click: (103, 103) +assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) diff --git a/src/test/ui/impl-trait/rpit-not-sized.rs b/src/test/ui/impl-trait/rpit-not-sized.rs new file mode 100644 index 00000000000..bd25940780a --- /dev/null +++ b/src/test/ui/impl-trait/rpit-not-sized.rs @@ -0,0 +1,6 @@ +fn foo() -> impl ?Sized { + //~^ ERROR the size for values of type `impl ?Sized` cannot be known at compilation time + () +} + +fn main() {} diff --git a/src/test/ui/impl-trait/rpit-not-sized.stderr b/src/test/ui/impl-trait/rpit-not-sized.stderr new file mode 100644 index 00000000000..608c94fc072 --- /dev/null +++ b/src/test/ui/impl-trait/rpit-not-sized.stderr @@ -0,0 +1,12 @@ +error[E0277]: the size for values of type `impl ?Sized` cannot be known at compilation time + --> $DIR/rpit-not-sized.rs:1:13 + | +LL | fn foo() -> impl ?Sized { + | ^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `impl ?Sized` + = note: the return type of a function must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/parser/issues/issue-19398.stderr b/src/test/ui/parser/issues/issue-19398.stderr index bbd85374b4b..1da00960adf 100644 --- a/src/test/ui/parser/issues/issue-19398.stderr +++ b/src/test/ui/parser/issues/issue-19398.stderr @@ -4,15 +4,10 @@ error: expected `{`, found keyword `unsafe` LL | trait T { | - while parsing this item list starting here LL | extern "Rust" unsafe fn foo(); - | --------------^^^^^^ - | | | - | | expected `{` - | help: `unsafe` must come before `extern "Rust"`: `unsafe extern "Rust"` + | ^^^^^^ expected `{` LL | LL | } | - the item list ends here - | - = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` error: aborting due to previous error diff --git a/src/test/ui/parser/unsafe-foreign-mod-2.rs b/src/test/ui/parser/unsafe-foreign-mod-2.rs new file mode 100644 index 00000000000..77856fb6734 --- /dev/null +++ b/src/test/ui/parser/unsafe-foreign-mod-2.rs @@ -0,0 +1,8 @@ +extern "C" unsafe { + //~^ ERROR expected `{`, found keyword `unsafe` + //~| ERROR extern block cannot be declared unsafe + unsafe fn foo(); + //~^ ERROR functions in `extern` blocks cannot have qualifiers +} + +fn main() {} diff --git a/src/test/ui/parser/unsafe-foreign-mod-2.stderr b/src/test/ui/parser/unsafe-foreign-mod-2.stderr new file mode 100644 index 00000000000..7cc2de141ae --- /dev/null +++ b/src/test/ui/parser/unsafe-foreign-mod-2.stderr @@ -0,0 +1,28 @@ +error: expected `{`, found keyword `unsafe` + --> $DIR/unsafe-foreign-mod-2.rs:1:12 + | +LL | extern "C" unsafe { + | ^^^^^^ expected `{` + +error: extern block cannot be declared unsafe + --> $DIR/unsafe-foreign-mod-2.rs:1:12 + | +LL | extern "C" unsafe { + | ^^^^^^ + +error: functions in `extern` blocks cannot have qualifiers + --> $DIR/unsafe-foreign-mod-2.rs:4:15 + | +LL | extern "C" unsafe { + | ----------------- in this `extern` block +... +LL | unsafe fn foo(); + | ^^^ + | +help: remove the qualifiers + | +LL | fn foo(); + | ~~ + +error: aborting due to 3 previous errors + |
