diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index cc1c439f3bd94..9a5e3724bfc44 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -93,7 +93,7 @@ impl SuppressRegionErrors { pub fn when_nll_is_enabled(tcx: TyCtxt<'_, '_, '_>) -> Self { match tcx.borrowck_mode() { // If we're on AST or Migrate mode, report AST region errors - BorrowckMode::Ast | BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, + BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, // If we're on MIR or Compare mode, don't report AST region errors as they should // be reported by NLL diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 55c4b0e54b822..19b819e55971e 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -437,7 +437,6 @@ pub enum PrintRequest { #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum BorrowckMode { - Ast, Mir, Compare, Migrate, @@ -448,7 +447,6 @@ impl BorrowckMode { /// on the AST borrow check if the MIR-based one errors. pub fn migrate(self) -> bool { match self { - BorrowckMode::Ast => false, BorrowckMode::Compare => false, BorrowckMode::Mir => false, BorrowckMode::Migrate => true, @@ -458,21 +456,11 @@ impl BorrowckMode { /// Should we emit the AST-based borrow checker errors? pub fn use_ast(self) -> bool { match self { - BorrowckMode::Ast => true, BorrowckMode::Compare => true, BorrowckMode::Mir => false, BorrowckMode::Migrate => false, } } - /// Should we emit the MIR-based borrow checker errors? - pub fn use_mir(self) -> bool { - match self { - BorrowckMode::Ast => false, - BorrowckMode::Compare => true, - BorrowckMode::Mir => true, - BorrowckMode::Migrate => true, - } - } } pub enum Input { @@ -604,7 +592,7 @@ impl Default for Options { incremental: None, debugging_opts: basic_debugging_options(), prints: Vec::new(), - borrowck_mode: BorrowckMode::Ast, + borrowck_mode: BorrowckMode::Migrate, cg: basic_codegen_options(), error_format: ErrorOutputType::default(), externs: Externs(BTreeMap::new()), @@ -2250,10 +2238,9 @@ pub fn build_session_options_and_crate_config( })); let borrowck_mode = match debugging_opts.borrowck.as_ref().map(|s| &s[..]) { - None | Some("ast") => BorrowckMode::Ast, + None | Some("migrate") => BorrowckMode::Migrate, Some("mir") => BorrowckMode::Mir, Some("compare") => BorrowckMode::Compare, - Some("migrate") => BorrowckMode::Migrate, Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)), }; diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b705968ce8aed..4a02325693c14 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -68,7 +68,6 @@ use rustc_target::spec::abi; use syntax::ast; use syntax::attr; use syntax::source_map::MultiSpan; -use syntax::edition::Edition; use syntax::feature_gate; use syntax::symbol::{Symbol, keywords, InternedString}; use syntax_pos::Span; @@ -1472,21 +1471,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// because that method has a narrower effect that can be toggled /// off via a separate `-Z` flag, at least for the short term. pub fn allow_bind_by_move_patterns_with_guards(self) -> bool { - self.features().bind_by_move_pattern_guards && self.use_mir_borrowck() + self.features().bind_by_move_pattern_guards } /// If true, we should use a naive AST walk to determine if match /// guard could perform bad mutations (or mutable-borrows). pub fn check_for_mutation_in_guard_via_ast_walk(self) -> bool { - // If someone requests the feature, then be a little more - // careful and ensure that MIR-borrowck is enabled (which can - // happen via edition selection, via `feature(nll)`, or via an - // appropriate `-Z` flag) before disabling the mutation check. - if self.allow_bind_by_move_patterns_with_guards() { - return false; - } - - return true; + !self.allow_bind_by_move_patterns_with_guards() } /// If true, we should use the AST-based borrowck (we may *also* use @@ -1495,12 +1486,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.borrowck_mode().use_ast() } - /// If true, we should use the MIR-based borrowck (we may *also* use - /// the AST-based borrowck). - pub fn use_mir_borrowck(self) -> bool { - self.borrowck_mode().use_mir() - } - /// If true, we should use the MIR-based borrow check, but also /// fall back on the AST borrow check if the MIR-based one errors. pub fn migrate_borrowck(self) -> bool { @@ -1517,23 +1502,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// statements (which simulate the maximal effect of executing the /// patterns in a match arm). pub fn emit_read_for_match(&self) -> bool { - self.use_mir_borrowck() && !self.sess.opts.debugging_opts.nll_dont_emit_read_for_match - } - - /// If true, pattern variables for use in guards on match arms - /// will be bound as references to the data, and occurrences of - /// those variables in the guard expression will implicitly - /// dereference those bindings. (See rust-lang/rust#27282.) - pub fn all_pat_vars_are_implicit_refs_within_guards(self) -> bool { - self.borrowck_mode().use_mir() - } - - /// If true, we should enable two-phase borrows checks. This is - /// done with either: `-Ztwo-phase-borrows`, `#![feature(nll)]`, - /// or by opting into an edition after 2015. - pub fn two_phase_borrows(self) -> bool { - self.sess.rust_2018() || self.features().nll || - self.sess.opts.debugging_opts.two_phase_borrows + !self.sess.opts.debugging_opts.nll_dont_emit_read_for_match } /// What mode(s) of borrowck should we run? AST? MIR? both? @@ -1541,14 +1510,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn borrowck_mode(&self) -> BorrowckMode { // Here are the main constraints we need to deal with: // - // 1. An opts.borrowck_mode of `BorrowckMode::Ast` is + // 1. An opts.borrowck_mode of `BorrowckMode::Migrate` is // synonymous with no `-Z borrowck=...` flag at all. - // (This is arguably a historical accident.) - // - // 2. `BorrowckMode::Migrate` is the limited migration to - // NLL that we are deploying with the 2018 edition. // - // 3. We want to allow developers on the Nightly channel + // 2. We want to allow developers on the Nightly channel // to opt back into the "hard error" mode for NLL, // (which they can do via specifying `#![feature(nll)]` // explicitly in their crate). @@ -1561,24 +1526,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // a user's attempt to specify `-Z borrowck=compare`, which // we arguably do not need anymore and should remove.) // - // * Otherwise, if no `-Z borrowck=...` flag was given (or - // if `borrowck=ast` was specified), then use the default - // as required by the edition. + // * Otherwise, if no `-Z borrowck=...` then use migrate mode // // * Otherwise, use the behavior requested via `-Z borrowck=...` if self.features().nll { return BorrowckMode::Mir; } - match self.sess.opts.borrowck_mode { - mode @ BorrowckMode::Mir | - mode @ BorrowckMode::Compare | - mode @ BorrowckMode::Migrate => mode, - - BorrowckMode::Ast => match self.sess.edition() { - Edition::Edition2015 => BorrowckMode::Ast, - Edition::Edition2018 => BorrowckMode::Migrate, - }, - } + self.sess.opts.borrowck_mode } #[inline] diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index da065f9e05d9e..3bf59f8532fe9 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -49,8 +49,6 @@ pub mod gather_loans; pub mod move_data; -mod unused; - #[derive(Clone, Copy)] pub struct LoanDataFlowOperator; @@ -139,10 +137,6 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId) check_loans::check_loans(&mut bccx, &loan_dfcx, &flowed_moves, &all_loans, body); } - if !tcx.use_mir_borrowck() { - unused::check(&mut bccx, body); - } - Lrc::new(BorrowCheckResult { used_mut_nodes: bccx.used_mut_nodes.into_inner(), signalled_any_error: bccx.signalled_any_error.into_inner(), diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs deleted file mode 100644 index 60a9c18e95ee9..0000000000000 --- a/src/librustc_borrowck/borrowck/unused.rs +++ /dev/null @@ -1,116 +0,0 @@ -use rustc::hir::intravisit::{Visitor, NestedVisitorMap}; -use rustc::hir::{self, HirId}; -use rustc::lint::builtin::UNUSED_MUT; -use rustc::ty; -use rustc::util::nodemap::{FxHashMap, FxHashSet}; -use errors::Applicability; -use std::slice; -use syntax::ptr::P; - -use crate::borrowck::BorrowckCtxt; - -pub fn check<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: &'tcx hir::Body) { - let mut used_mut = bccx.used_mut_nodes.borrow().clone(); - UsedMutFinder { - bccx, - set: &mut used_mut, - }.visit_expr(&body.value); - let mut cx = UnusedMutCx { bccx, used_mut }; - for arg in body.arguments.iter() { - cx.check_unused_mut_pat(slice::from_ref(&arg.pat)); - } - cx.visit_expr(&body.value); -} - -struct UsedMutFinder<'a, 'tcx: 'a> { - bccx: &'a BorrowckCtxt<'a, 'tcx>, - set: &'a mut FxHashSet, -} - -struct UnusedMutCx<'a, 'tcx: 'a> { - bccx: &'a BorrowckCtxt<'a, 'tcx>, - used_mut: FxHashSet, -} - -impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { - fn check_unused_mut_pat(&self, pats: &[P]) { - let tcx = self.bccx.tcx; - let mut mutables: FxHashMap<_, Vec<_>> = Default::default(); - for p in pats { - p.each_binding(|_, hir_id, span, ident| { - // Skip anything that looks like `_foo` - if ident.as_str().starts_with("_") { - return; - } - - // Skip anything that looks like `&foo` or `&mut foo`, only look - // for by-value bindings - if let Some(&bm) = self.bccx.tables.pat_binding_modes().get(hir_id) { - match bm { - ty::BindByValue(hir::MutMutable) => {} - _ => return, - } - - mutables.entry(ident.name).or_default().push((hir_id, span)); - } else { - tcx.sess.delay_span_bug(span, "missing binding mode"); - } - }); - } - - for (_name, ids) in mutables { - // If any id for this name was used mutably then consider them all - // ok, so move on to the next - if ids.iter().any(|&(ref hir_id, _)| self.used_mut.contains(hir_id)) { - continue; - } - - let (hir_id, span) = ids[0]; - if span.compiler_desugaring_kind().is_some() { - // If the `mut` arises as part of a desugaring, we should ignore it. - continue; - } - - // Ok, every name wasn't used mutably, so issue a warning that this - // didn't need to be mutable. - let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); - tcx.struct_span_lint_hir(UNUSED_MUT, - hir_id, - span, - "variable does not need to be mutable") - .span_suggestion_short( - mut_span, - "remove this `mut`", - String::new(), - Applicability::MachineApplicable, - ) - .emit(); - } - } -} - -impl<'a, 'tcx> Visitor<'tcx> for UnusedMutCx<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir()) - } - - fn visit_arm(&mut self, arm: &hir::Arm) { - self.check_unused_mut_pat(&arm.pats) - } - - fn visit_local(&mut self, local: &hir::Local) { - self.check_unused_mut_pat(slice::from_ref(&local.pat)); - } -} - -impl<'a, 'tcx> Visitor<'tcx> for UsedMutFinder<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.bccx.tcx.hir()) - } - - fn visit_nested_body(&mut self, id: hir::BodyId) { - let def_id = self.bccx.tcx.hir().body_owner_def_id(id); - self.set.extend(self.bccx.tcx.borrowck(def_id).used_mut_nodes.iter().cloned()); - self.visit_body(self.bccx.tcx.hir().body(id)); - } -} diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index cbef7a7f6c481..f808adb47eac9 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -303,9 +303,8 @@ impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> { /// allowed to be split into separate Reservation and /// Activation phases. fn allow_two_phase_borrow(&self, kind: mir::BorrowKind) -> bool { - self.tcx.two_phase_borrows() - && (kind.allows_two_phase_borrow() - || self.tcx.sess.opts.debugging_opts.two_phase_beyond_autoref) + kind.allows_two_phase_borrow() + || self.tcx.sess.opts.debugging_opts.two_phase_beyond_autoref } /// If this is a two-phase borrow, then we will record it diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 0bdf44c2ae049..f8993f9f8b169 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -70,37 +70,28 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC let input_mir = tcx.mir_validated(def_id); debug!("run query mir_borrowck: {}", tcx.item_path_str(def_id)); - let mut return_early; - - // Return early if we are not supposed to use MIR borrow checker for this function. - return_early = !tcx.has_attr(def_id, "rustc_mir") && !tcx.use_mir_borrowck(); - + // We are not borrow checking the automatically generated struct constructors + // because we want to accept structs such as this (taken from the `linked-hash-map` + // crate): + // ```rust + // struct Qey(Q); + // ``` + // MIR of this struct constructor looks something like this: + // ```rust + // fn Qey(_1: Q) -> Qey{ + // let mut _0: Qey; // return place + // + // bb0: { + // (_0.0: Q) = move _1; // bb0[0]: scope 0 at src/main.rs:1:1: 1:26 + // return; // bb0[1]: scope 0 at src/main.rs:1:1: 1:26 + // } + // } + // ``` + // The problem here is that `(_0.0: Q) = move _1;` is valid only if `Q` is + // of statically known size, which is not known to be true because of the + // `Q: ?Sized` constraint. However, it is true because the constructor can be + // called only when `Q` is of statically known size. if tcx.is_struct_constructor(def_id) { - // We are not borrow checking the automatically generated struct constructors - // because we want to accept structs such as this (taken from the `linked-hash-map` - // crate): - // ```rust - // struct Qey(Q); - // ``` - // MIR of this struct constructor looks something like this: - // ```rust - // fn Qey(_1: Q) -> Qey{ - // let mut _0: Qey; // return place - // - // bb0: { - // (_0.0: Q) = move _1; // bb0[0]: scope 0 at src/main.rs:1:1: 1:26 - // return; // bb0[1]: scope 0 at src/main.rs:1:1: 1:26 - // } - // } - // ``` - // The problem here is that `(_0.0: Q) = move _1;` is valid only if `Q` is - // of statically known size, which is not known to be true because of the - // `Q: ?Sized` constraint. However, it is true because the constructor can be - // called only when `Q` is of statically known size. - return_early = true; - } - - if return_early { return BorrowCheckResult { closure_requirements: None, used_mut_upvars: SmallVec::new(), @@ -1382,10 +1373,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { span: Span, flow_state: &Flows<'cx, 'gcx, 'tcx>, ) { - if !self.infcx.tcx.two_phase_borrows() { - return; - } - // Two-phase borrow support: For each activation that is newly // generated at this statement, check if it interferes with // another borrow. diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index aafbff3577647..52cfb835a0622 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -479,10 +479,6 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { &mut self, location: Location, ) { - if !self.tcx.two_phase_borrows() { - return; - } - // Two-phase borrow support: For each activation that is newly // generated at this statement, check if it interferes with // another borrow. diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 5b444ab9690ca..f4bf1314dc409 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -2676,9 +2676,8 @@ impl MirPass for TypeckMir { let def_id = src.def_id(); debug!("run_pass: {:?}", def_id); - // When NLL is enabled, the borrow checker runs the typeck - // itself, so we don't need this MIR pass anymore. - if tcx.use_mir_borrowck() { + // FIXME: We don't need this MIR pass anymore. + if true { return; } diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index 9e0bb93c33a5d..6d4c4b06d9112 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -15,9 +15,8 @@ pub(super) fn allow_two_phase_borrow<'a, 'tcx, 'gcx: 'tcx>( tcx: &TyCtxt<'a, 'gcx, 'tcx>, kind: BorrowKind ) -> bool { - tcx.two_phase_borrows() - && (kind.allows_two_phase_borrow() - || tcx.sess.opts.debugging_opts.two_phase_beyond_autoref) + kind.allows_two_phase_borrow() + || tcx.sess.opts.debugging_opts.two_phase_beyond_autoref } /// Control for the path borrow checking code diff --git a/src/librustc_mir/build/expr/as_place.rs b/src/librustc_mir/build/expr/as_place.rs index 20b95c363f5f7..dc5fb8bc580b3 100644 --- a/src/librustc_mir/build/expr/as_place.rs +++ b/src/librustc_mir/build/expr/as_place.rs @@ -112,11 +112,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } ExprKind::SelfRef => block.and(Place::Base(PlaceBase::Local(Local::new(1)))), ExprKind::VarRef { id } => { - let place = if this.is_bound_var_in_guard(id) && this - .hir - .tcx() - .all_pat_vars_are_implicit_refs_within_guards() - { + let place = if this.is_bound_var_in_guard(id) { let index = this.var_local_id(id, RefWithinGuard); Place::Base(PlaceBase::Local(index)).deref() } else { diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index d3731e7c1274e..93ca299a624fa 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -1419,26 +1419,22 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // the reference that we create for the arm. // * So we eagerly create the reference for the arm and then take a // reference to that. - let tcx = self.hir.tcx(); - let autoref = tcx.all_pat_vars_are_implicit_refs_within_guards(); if let Some(guard) = guard { - if autoref { - self.bind_matched_candidate_for_guard( - block, - &candidate.bindings, - ); - let guard_frame = GuardFrame { - locals: candidate - .bindings - .iter() - .map(|b| GuardFrameLocal::new(b.var_id, b.binding_mode)) - .collect(), - }; - debug!("Entering guard building context: {:?}", guard_frame); - self.guard_context.push(guard_frame); - } else { - self.bind_matched_candidate_for_arm_body(block, &candidate.bindings); - } + let tcx = self.hir.tcx(); + + self.bind_matched_candidate_for_guard( + block, + &candidate.bindings, + ); + let guard_frame = GuardFrame { + locals: candidate + .bindings + .iter() + .map(|b| GuardFrameLocal::new(b.var_id, b.binding_mode)) + .collect(), + }; + debug!("Entering guard building context: {:?}", guard_frame); + self.guard_context.push(guard_frame); let re_erased = tcx.types.re_erased; let scrutinee_source_info = self.source_info(scrutinee_span); @@ -1464,13 +1460,11 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { let source_info = self.source_info(guard.span); let guard_end = self.source_info(tcx.sess.source_map().end_point(guard.span)); let cond = unpack!(block = self.as_local_operand(block, guard)); - if autoref { - let guard_frame = self.guard_context.pop().unwrap(); - debug!( - "Exiting guard building context with locals: {:?}", - guard_frame - ); - } + let guard_frame = self.guard_context.pop().unwrap(); + debug!( + "Exiting guard building context with locals: {:?}", + guard_frame + ); for &(_, temp) in fake_borrows { self.cfg.push(block, Statement { @@ -1520,28 +1514,26 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ), ); - if autoref { - let by_value_bindings = candidate.bindings.iter().filter(|binding| { - if let BindingMode::ByValue = binding.binding_mode { true } else { false } - }); - // Read all of the by reference bindings to ensure that the - // place they refer to can't be modified by the guard. - for binding in by_value_bindings.clone() { - let local_id = self.var_local_id(binding.var_id, RefWithinGuard); + let by_value_bindings = candidate.bindings.iter().filter(|binding| { + if let BindingMode::ByValue = binding.binding_mode { true } else { false } + }); + // Read all of the by reference bindings to ensure that the + // place they refer to can't be modified by the guard. + for binding in by_value_bindings.clone() { + let local_id = self.var_local_id(binding.var_id, RefWithinGuard); let place = Place::Base(PlaceBase::Local(local_id)); - self.cfg.push( - block, - Statement { - source_info: guard_end, - kind: StatementKind::FakeRead(FakeReadCause::ForGuardBinding, place), - }, - ); - } - self.bind_matched_candidate_for_arm_body( - post_guard_block, - by_value_bindings, + self.cfg.push( + block, + Statement { + source_info: guard_end, + kind: StatementKind::FakeRead(FakeReadCause::ForGuardBinding, place), + }, ); } + self.bind_matched_candidate_for_arm_body( + post_guard_block, + by_value_bindings, + ); self.cfg.terminate( post_guard_block, @@ -1598,8 +1590,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } } - // Only called when all_pat_vars_are_implicit_refs_within_guards, - // and thus all code/comments assume we are in that context. fn bind_matched_candidate_for_guard( &mut self, block: BasicBlock, @@ -1733,7 +1723,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { }))), }; let for_arm_body = self.local_decls.push(local.clone()); - let locals = if has_guard.0 && tcx.all_pat_vars_are_implicit_refs_within_guards() { + let locals = if has_guard.0 { let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> { // This variable isn't mutated but has a name, so has to be // immutable to avoid the unused mut lint. diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs index e1b66312da2d3..fb72e6dd4d361 100644 --- a/src/librustc_mir/diagnostics.rs +++ b/src/librustc_mir/diagnostics.rs @@ -877,12 +877,14 @@ https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html "##, E0383: r##" +#### Note: this error code is no longer emitted by the compiler. + This error occurs when an attempt is made to partially reinitialize a structure that is currently uninitialized. For example, this can happen when a drop has taken place: -```compile_fail,E0383 +```compile_fail struct Foo { a: u32, } @@ -966,10 +968,12 @@ y.set(2); "##,*/ E0387: r##" +#### Note: this error code is no longer emitted by the compiler. + This error occurs when an attempt is made to mutate or mutably reference data that a closure has captured immutably. Examples of this error are shown below: -```compile_fail,E0387 +```compile_fail // Accepts a function or a closure that captures its environment immutably. // Closures passed to foo will not be able to mutate their closed-over state. fn foo(f: F) { } @@ -1026,13 +1030,15 @@ E0388 was removed and is no longer issued. "##, E0389: r##" +#### Note: this error code is no longer emitted by the compiler. + An attempt was made to mutate data using a non-mutable reference. This commonly occurs when attempting to assign to a non-mutable reference of a mutable reference (`&(&mut T)`). Example of erroneous code: -```compile_fail,E0389 +```compile_fail struct FancyNum { num: u8, } @@ -1202,6 +1208,7 @@ A variable was borrowed as mutable more than once. Erroneous code example: let mut i = 0; let mut x = &mut i; let mut a = &mut i; +x; // error: cannot borrow `i` as mutable more than once at a time ``` @@ -1220,35 +1227,33 @@ let mut i = 0; let a = &i; // ok! let b = &i; // still ok! let c = &i; // still ok! +b; +a; ``` "##, E0500: r##" -A borrowed variable was used in another closure. Example of erroneous code: +A borrowed variable was used by a closure. Example of erroneous code: ```compile_fail fn you_know_nothing(jon_snow: &mut i32) { - let nights_watch = || { - *jon_snow = 2; - }; + let nights_watch = &jon_snow; let starks = || { *jon_snow = 3; // error: closure requires unique access to `jon_snow` // but it is already borrowed }; + println!("{}", nights_watch); } ``` -In here, `jon_snow` is already borrowed by the `nights_watch` closure, so it +In here, `jon_snow` is already borrowed by the `nights_watch` reference, so it cannot be borrowed by the `starks` closure at the same time. To fix this issue, -you can put the closure in its own scope: +you can create the closure after the borrow has ended: ``` fn you_know_nothing(jon_snow: &mut i32) { - { - let nights_watch = || { - *jon_snow = 2; - }; - } // At this point, `jon_snow` is free. + let nights_watch = &jon_snow; + println!("{}", nights_watch); let starks = || { *jon_snow = 3; }; @@ -1261,12 +1266,10 @@ closures: ``` fn you_know_nothing(jon_snow: &mut i32) { let mut jon_copy = jon_snow.clone(); - let nights_watch = || { - jon_copy = 2; - }; let starks = || { *jon_snow = 3; }; + println!("{}", jon_copy); } ``` "##, @@ -1293,26 +1296,27 @@ fn outside_closure(x: &mut i32) { } fn foo(a: &mut i32) { - let bar = || { + let mut bar = || { inside_closure(a) }; outside_closure(a); // error: cannot borrow `*a` as mutable because previous // closure requires unique access. + bar(); } ``` -To fix this error, you can place the closure in its own scope: +To fix this error, you can place finish using the closure in its own scope: ``` fn inside_closure(x: &mut i32) {} fn outside_closure(x: &mut i32) {} fn foo(a: &mut i32) { - { - let bar = || { - inside_closure(a) - }; - } // borrow on `a` ends. + let mut bar = || { + inside_closure(a) + }; + bar(); + // borrow on `a` ends. outside_closure(a); // ok! } ``` @@ -1324,7 +1328,7 @@ fn inside_closure(x: &mut i32) {} fn outside_closure(x: &mut i32) {} fn foo(a: &mut i32) { - let bar = |s: &mut i32| { + let mut bar = |s: &mut i32| { inside_closure(s) }; outside_closure(a); @@ -1340,9 +1344,10 @@ fn outside_closure(x: &mut i32) {} fn foo(a: &mut i32) { outside_closure(a); - let bar = || { + let mut bar = || { inside_closure(a) }; + bar(); } ``` "##, @@ -1359,6 +1364,7 @@ fn foo(a: &mut i32) { let ref y = a; // a is borrowed as immutable. bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed // as immutable + println!("{}", y); } ``` @@ -1370,6 +1376,7 @@ fn bar(x: &mut i32) {} fn foo(a: &mut i32) { bar(a); let ref y = a; // ok! + println!("{}", y); } ``` @@ -1385,11 +1392,11 @@ Example of erroneous code: ```compile_fail,E0503 fn main() { let mut value = 3; - // Create a mutable borrow of `value`. This borrow - // lives until the end of this function. - let _borrow = &mut value; + // Create a mutable borrow of `value`. + let borrow = &mut value; let _sum = value + 1; // error: cannot use `value` because // it was mutably borrowed + println!("{}", borrow); } ``` @@ -1397,16 +1404,14 @@ In this example, `value` is mutably borrowed by `borrow` and cannot be used to calculate `sum`. This is not possible because this would violate Rust's mutability rules. -You can fix this error by limiting the scope of the borrow: +You can fix this error by finishing using the borrow before the next use of +the value: ``` fn main() { let mut value = 3; - // By creating a new block, you can limit the scope - // of the reference. - { - let _borrow = &mut value; // Use `_borrow` inside this block. - } + let borrow = &mut value; + println!("{}", borrow); // The block has ended and with it the borrow. // You can now use `value` again. let _sum = value + 1; @@ -1422,10 +1427,11 @@ fn main() { let value_cloned = value.clone(); // The mutable borrow is a reference to `value` and // not to `value_cloned`... - let _borrow = &mut value; + let borrow = &mut value; // ... which means we can still use `value_cloned`, let _sum = value_cloned + 1; // even though the borrow only ends here. + println!("{}", borrow); } ``` @@ -1434,12 +1440,14 @@ http://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html "##, E0504: r##" +#### Note: this error code is no longer emitted by the compiler. + This error occurs when an attempt is made to move a borrowed variable into a closure. Example of erroneous code: -```compile_fail,E0504 +```compile_fail struct FancyNum { num: u8, } @@ -1577,9 +1585,10 @@ fn eat(val: &Value) {} fn main() { let x = Value{}; - let _ref_to_val: &Value = &x; + + let ref_to_val: &Value = &x; eat(&x); // pass by reference, if it's possible - borrow(_ref_to_val); + borrow(ref_to_val); } ``` @@ -1594,11 +1603,11 @@ fn eat(val: Value) {} fn main() { let x = Value{}; - { - let _ref_to_val: &Value = &x; - borrow(_ref_to_val); - } - eat(x); // release borrow and then move it. + + let ref_to_val: &Value = &x; + borrow(ref_to_val); + // ref_to_val is no longer used. + eat(x); } ``` @@ -1614,9 +1623,9 @@ fn eat(val: Value) {} fn main() { let x = Value{}; - let _ref_to_val: &Value = &x; + let ref_to_val: &Value = &x; eat(x); // it will be copied here. - borrow(_ref_to_val); + borrow(ref_to_val); } ``` @@ -2053,11 +2062,13 @@ fn get_owned_iterator() -> IntoIter { "##, E0595: r##" +#### Note: this error code is no longer emitted by the compiler. + Closures cannot mutate immutable captured variables. Erroneous code example: -```compile_fail,E0595 +```compile_fail,E0594 let x = 3; // error: closure cannot assign to immutable local variable `x` let mut c = || { x += 1 }; ``` @@ -2090,8 +2101,7 @@ let y = &mut x; // ok! "##, E0597: r##" -This error occurs because a borrow was made inside a variable which has a -greater lifetime than the borrowed one. +This error occurs because a value was dropped while it was still borrowed Example of erroneous code: @@ -2101,23 +2111,28 @@ struct Foo<'a> { } let mut x = Foo { x: None }; -let y = 0; -x.x = Some(&y); // error: `y` does not live long enough +{ + let y = 0; + x.x = Some(&y); // error: `y` does not live long enough +} +println!("{:?}", x.x); ``` -In here, `x` is created before `y` and therefore has a greater lifetime. Always -keep in mind that values in a scope are dropped in the opposite order they are -created. So to fix the previous example, just make the `y` lifetime greater than -the `x`'s one: +In here, `y` is dropped at the end of the inner scope, but it is borrowed by +`x` until the `println`. To fix the previous example, just remove the scope +so that `y` isn't dropped until after the println ``` struct Foo<'a> { x: Option<&'a u32>, } -let y = 0; let mut x = Foo { x: None }; + +let y = 0; x.x = Some(&y); + +println!("{:?}", x.x); ``` "##, diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 41babc1ad12ef..2b2885dd94857 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -571,7 +571,7 @@ fn check_legality_of_move_bindings( let mut err = struct_span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard"); err.span_label(p.span, "moves value into pattern guard"); - if cx.tcx.sess.opts.unstable_features.is_nightly_build() && cx.tcx.use_mir_borrowck() { + if cx.tcx.sess.opts.unstable_features.is_nightly_build() { err.help("add #![feature(bind_by_move_pattern_guards)] to the \ crate attributes to enable"); } @@ -655,9 +655,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { let mut err = struct_span_err!(self.cx.tcx.sess, span, E0301, "cannot mutably borrow in a pattern guard"); err.span_label(span, "borrowed mutably in pattern guard"); - if self.cx.tcx.sess.opts.unstable_features.is_nightly_build() && - self.cx.tcx.use_mir_borrowck() - { + if self.cx.tcx.sess.opts.unstable_features.is_nightly_build() { err.help("add #![feature(bind_by_move_pattern_guards)] to the \ crate attributes to enable"); } diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index fd694ddbbd19f..e334e27cc8556 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -40,7 +40,7 @@ impl Origin { pub fn should_emit_errors(self, mode: BorrowckMode) -> bool { match self { Origin::Ast => mode.use_ast(), - Origin::Mir => mode.use_mir(), + Origin::Mir => true, } } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 279e2089f5d71..a2ba03414d9bf 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -443,9 +443,7 @@ declare_features! ( (active, custom_inner_attributes, "1.30.0", Some(54726), None), // Allow mixing of bind-by-move in patterns and references to - // those identifiers in guards, *if* we are using MIR-borrowck - // (aka NLL). Essentially this means you need to be using the - // 2018 edition or later. + // those identifiers in guards. (active, bind_by_move_pattern_guards, "1.30.0", Some(15287), None), // Allows `impl Trait` in bindings (`let`, `const`, `static`). diff --git a/src/test/incremental/feature_gate.rs b/src/test/incremental/feature_gate.rs index d36044ec92bd6..5317a9962f47a 100644 --- a/src/test/incremental/feature_gate.rs +++ b/src/test/incremental/feature_gate.rs @@ -4,10 +4,10 @@ // compile-flags: -Z query-dep-graph #![feature(rustc_attrs)] -#![cfg_attr(rpass1, feature(nll))] +#![cfg_attr(rpass1, feature(abi_unadjusted))] fn main() { - let mut v = vec![1]; - v.push(v[0]); - //[cfail2]~^ ERROR cannot borrow } + +extern "unadjusted" fn foo() {} +//[cfail2]~^ ERROR: unadjusted ABI is an implementation detail and perma-unstable diff --git a/src/test/mir-opt/match_test.rs b/src/test/mir-opt/match_test.rs index 3f248f3d41a64..a5317f98ef188 100644 --- a/src/test/mir-opt/match_test.rs +++ b/src/test/mir-opt/match_test.rs @@ -60,9 +60,11 @@ fn main() { // goto -> bb16; // } // bb12: { -// StorageLive(_8); -// _8 = _2; -// switchInt(move _8) -> [false: bb6, otherwise: bb11]; +// _8 = &shallow _1; +// StorageLive(_9); +// _9 = _2; +// FakeRead(ForMatchGuard, _8); +// switchInt(move _9) -> [false: bb6, otherwise: bb11]; // } // bb13: { // _3 = const 1i32; @@ -77,7 +79,7 @@ fn main() { // goto -> bb16; // } // bb16: { -// StorageDead(_8); +// StorageDead(_9); // _0 = (); // StorageDead(_2); // StorageDead(_1); diff --git a/src/test/run-fail/borrowck-local-borrow.rs b/src/test/run-fail/borrowck-local-borrow.rs index cb17a6305624b..d07f76b6252dc 100644 --- a/src/test/run-fail/borrowck-local-borrow.rs +++ b/src/test/run-fail/borrowck-local-borrow.rs @@ -1,6 +1,6 @@ // error-pattern:panic 1 -// revisions: ast mir +// revisions: migrate mir //[mir]compile-flags: -Z borrowck=mir fn main() { diff --git a/src/test/run-pass/asm-in-moved.rs b/src/test/run-pass/asm-in-moved.rs index dc73f83a940e0..8726db355551b 100644 --- a/src/test/run-pass/asm-in-moved.rs +++ b/src/test/run-pass/asm-in-moved.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] #![allow(dead_code)] diff --git a/src/test/run-pass/asm-out-assign.rs b/src/test/run-pass/asm-out-assign.rs index d0978cc834297..5c46cb92c6b10 100644 --- a/src/test/run-pass/asm-out-assign.rs +++ b/src/test/run-pass/asm-out-assign.rs @@ -1,6 +1,3 @@ -// revisions ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs b/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs index 25ef48d0d5ce3..72bf43da95e57 100644 --- a/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs +++ b/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs @@ -2,9 +2,6 @@ #![allow(dead_code)] // Test taken from #45641 (https://github.com/rust-lang/rust/issues/45641) -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static mut Y: u32 = 0; unsafe fn should_ok() { diff --git a/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs b/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs index 0487c179e3688..adc7dfd541f48 100644 --- a/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs +++ b/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs @@ -1,6 +1,4 @@ // run-pass -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir // Test file taken from issue 45129 (https://github.com/rust-lang/rust/issues/45129) diff --git a/src/test/run-pass/borrowck/two-phase-baseline.rs b/src/test/run-pass/borrowck/two-phase-baseline.rs index aa8d18312941a..994dc823dfc0c 100644 --- a/src/test/run-pass/borrowck/two-phase-baseline.rs +++ b/src/test/run-pass/borrowck/two-phase-baseline.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Z borrowck=mir -Z two-phase-borrows // This is the "goto example" for why we want two phase borrows. diff --git a/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs b/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs index 9759223a1ba4e..0b20e1945e6f2 100644 --- a/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs +++ b/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs @@ -1,8 +1,4 @@ // run-pass -// revisions: lxl nll -//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows - -#![cfg_attr(nll, feature(nll))] fn main() { let mut a = 0; diff --git a/src/test/run-pass/drop/dynamic-drop.rs b/src/test/run-pass/drop/dynamic-drop.rs index 97e4cded80b9a..399b577dccb2f 100644 --- a/src/test/run-pass/drop/dynamic-drop.rs +++ b/src/test/run-pass/drop/dynamic-drop.rs @@ -1,8 +1,6 @@ // run-pass #![allow(unused_assignments)] #![allow(unused_variables)] -// revisions:lexical nll -#![cfg_attr(nll, feature(nll))] // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/run-pass/generator/yield-subtype.rs b/src/test/run-pass/generator/yield-subtype.rs index c38524857b4a2..fe88d424dd165 100644 --- a/src/test/run-pass/generator/yield-subtype.rs +++ b/src/test/run-pass/generator/yield-subtype.rs @@ -2,9 +2,6 @@ #![allow(dead_code)] #![allow(dead_code)] -// revisions:lexical nll -#![cfg_attr(nll, feature(nll))] - #![feature(generators)] fn bar<'a>() { diff --git a/src/test/run-pass/impl-trait/example-calendar.rs b/src/test/run-pass/impl-trait/example-calendar.rs index cd3d48f1a03b2..968e9b7d34ab7 100644 --- a/src/test/run-pass/impl-trait/example-calendar.rs +++ b/src/test/run-pass/impl-trait/example-calendar.rs @@ -1,8 +1,5 @@ // run-pass -// revisions: normal nll -//[nll] compile-flags:-Zborrowck=mir - #![feature(fn_traits, step_trait, unboxed_closures, diff --git a/src/test/run-pass/issues/issue-26996.rs b/src/test/run-pass/issues/issue-26996.rs index 8c5d2441780a1..04382be27d7a5 100644 --- a/src/test/run-pass/issues/issue-26996.rs +++ b/src/test/run-pass/issues/issue-26996.rs @@ -2,9 +2,9 @@ // This test is bogus (i.e., should be compile-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For -// now: just ignore it under nll +// now: just ignore it // -// ignore-compare-mode-nll +// ignore-test // This test is checking that the write to `c.0` (which has been moved out of) // won't overwrite the state in `c2`. diff --git a/src/test/run-pass/issues/issue-27021.rs b/src/test/run-pass/issues/issue-27021.rs index ecb065b196400..3055137545082 100644 --- a/src/test/run-pass/issues/issue-27021.rs +++ b/src/test/run-pass/issues/issue-27021.rs @@ -2,9 +2,9 @@ // This test is bogus (i.e., should be compile-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For -// now: just ignore it under nll +// now: just ignore it // -// ignore-compare-mode-nll +// ignore-test // These are variants of issue-26996.rs. In all cases we are writing // into a record field that has been moved out of, and ensuring that diff --git a/src/test/run-pass/issues/issue-49298.rs b/src/test/run-pass/issues/issue-49298.rs index 56443f410205e..697a160b4ecb4 100644 --- a/src/test/run-pass/issues/issue-49298.rs +++ b/src/test/run-pass/issues/issue-49298.rs @@ -4,9 +4,9 @@ // This test is bogus (i.e., should be compile-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For -// now: just ignore it under nll +// now: just ignore it // -// ignore-compare-mode-nll +// ignore-test // This test is checking that the space allocated for `x.1` does not // overlap with `y`. (The reason why such a thing happened at one diff --git a/src/test/ui-fulldeps/dropck_tarena_cycle_checked.stderr b/src/test/ui-fulldeps/dropck_tarena_cycle_checked.stderr index 34d026e957d6f..e695117cd332c 100644 --- a/src/test/ui-fulldeps/dropck_tarena_cycle_checked.stderr +++ b/src/test/ui-fulldeps/dropck_tarena_cycle_checked.stderr @@ -1,12 +1,13 @@ error[E0597]: `arena` does not live long enough - --> $DIR/dropck_tarena_cycle_checked.rs:116:8 + --> $DIR/dropck_tarena_cycle_checked.rs:116:7 | LL | f(&arena); - | ^^^^^ borrowed value does not live long enough + | ^^^^^^ borrowed value does not live long enough LL | } //~^ ERROR `arena` does not live long enough - | - `arena` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `arena` dropped here while still borrowed + | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `arena::TypedArena` error: aborting due to previous error diff --git a/src/test/ui-fulldeps/dropck_tarena_unsound_drop.stderr b/src/test/ui-fulldeps/dropck_tarena_unsound_drop.stderr index 47754da8b78d9..7bc3bc2cfb643 100644 --- a/src/test/ui-fulldeps/dropck_tarena_unsound_drop.stderr +++ b/src/test/ui-fulldeps/dropck_tarena_unsound_drop.stderr @@ -1,12 +1,13 @@ error[E0597]: `arena` does not live long enough - --> $DIR/dropck_tarena_unsound_drop.rs:41:8 + --> $DIR/dropck_tarena_unsound_drop.rs:41:7 | LL | f(&arena); - | ^^^^^ borrowed value does not live long enough + | ^^^^^^ borrowed value does not live long enough LL | } //~^ ERROR `arena` does not live long enough - | - `arena` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `arena` dropped here while still borrowed + | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `arena::TypedArena` error: aborting due to previous error diff --git a/src/test/ui/E0501.ast.stderr b/src/test/ui/E0501.ast.stderr deleted file mode 100644 index e0bd7a08d7f5b..0000000000000 --- a/src/test/ui/E0501.ast.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access - --> $DIR/E0501.rs:18:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - previous borrow occurs due to use of `a` in closure -LL | }; -LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - | ^ borrow occurs here -... -LL | } - | - borrow from closure ends here - -error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access - --> $DIR/E0501.rs:21:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - previous borrow occurs due to use of `a` in closure -... -LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access - | ^ borrow occurs here -... -LL | } - | - borrow from closure ends here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/E0501.mir.stderr b/src/test/ui/E0501.mir.stderr deleted file mode 100644 index 1d0102d100e4d..0000000000000 --- a/src/test/ui/E0501.mir.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access - --> $DIR/E0501.rs:18:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - first borrow occurs due to use of `a` in closure -LL | }; -LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - | ^ second borrow occurs here -... -LL | drop(bar); - | --- first borrow later used here - -error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access - --> $DIR/E0501.rs:21:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - first borrow occurs due to use of `a` in closure -... -LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access - | ^ second borrow occurs here -... -LL | drop(bar); - | --- first borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/E0501.rs b/src/test/ui/E0501.rs index a710e23a67049..3e39d9a63c59d 100644 --- a/src/test/ui/E0501.rs +++ b/src/test/ui/E0501.rs @@ -1,7 +1,3 @@ -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn inside_closure(x: &mut i32) { } @@ -15,11 +11,11 @@ fn foo(a: &mut i32) { let bar = || { inside_closure(a) }; - outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - //[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access + outside_closure_1(a); + //~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access - //[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access + outside_closure_2(a); + //~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access drop(bar); } diff --git a/src/test/ui/E0501.ast.nll.stderr b/src/test/ui/E0501.stderr similarity index 75% rename from src/test/ui/E0501.ast.nll.stderr rename to src/test/ui/E0501.stderr index 1d0102d100e4d..53d98d7e13fee 100644 --- a/src/test/ui/E0501.ast.nll.stderr +++ b/src/test/ui/E0501.stderr @@ -1,26 +1,26 @@ error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access - --> $DIR/E0501.rs:18:23 + --> $DIR/E0501.rs:14:23 | LL | let bar = || { | -- closure construction occurs here LL | inside_closure(a) | - first borrow occurs due to use of `a` in closure LL | }; -LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access +LL | outside_closure_1(a); | ^ second borrow occurs here ... LL | drop(bar); | --- first borrow later used here error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access - --> $DIR/E0501.rs:21:23 + --> $DIR/E0501.rs:17:23 | LL | let bar = || { | -- closure construction occurs here LL | inside_closure(a) | - first borrow occurs due to use of `a` in closure ... -LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access +LL | outside_closure_2(a); | ^ second borrow occurs here ... LL | drop(bar); diff --git a/src/test/ui/E0506.ast.stderr b/src/test/ui/E0506.ast.stderr deleted file mode 100644 index d459dcdc21994..0000000000000 --- a/src/test/ui/E0506.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `fancy_num` because it is borrowed - --> $DIR/E0506.rs:11:5 - | -LL | let fancy_ref = &fancy_num; - | --------- borrow of `fancy_num` occurs here -LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/E0506.mir.stderr b/src/test/ui/E0506.mir.stderr deleted file mode 100644 index b66c1d129a79a..0000000000000 --- a/src/test/ui/E0506.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `fancy_num` because it is borrowed - --> $DIR/E0506.rs:11:5 - | -LL | let fancy_ref = &fancy_num; - | ---------- borrow of `fancy_num` occurs here -LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here -... -LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); - | ------------- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/E0506.rs b/src/test/ui/E0506.rs index 04aaa008b5a2e..062a44a52bb8b 100644 --- a/src/test/ui/E0506.rs +++ b/src/test/ui/E0506.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct FancyNum { num: u8, } @@ -8,8 +5,7 @@ struct FancyNum { fn main() { let mut fancy_num = FancyNum { num: 5 }; let fancy_ref = &fancy_num; - fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 - //[mir]~^ ERROR [E0506] + fancy_num = FancyNum { num: 6 }; //~ ERROR [E0506] println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); } diff --git a/src/test/ui/E0506.ast.nll.stderr b/src/test/ui/E0506.stderr similarity index 85% rename from src/test/ui/E0506.ast.nll.stderr rename to src/test/ui/E0506.stderr index b66c1d129a79a..96432e346faa7 100644 --- a/src/test/ui/E0506.ast.nll.stderr +++ b/src/test/ui/E0506.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `fancy_num` because it is borrowed - --> $DIR/E0506.rs:11:5 + --> $DIR/E0506.rs:8:5 | LL | let fancy_ref = &fancy_num; | ---------- borrow of `fancy_num` occurs here -LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 +LL | fancy_num = FancyNum { num: 6 }; //~ ERROR [E0506] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here -... +LL | LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); | ------------- borrow later used here diff --git a/src/test/ui/E0508-fail.ast.nll.stderr b/src/test/ui/E0508-fail.ast.nll.stderr deleted file mode 100644 index 4cc1cf89d6cb9..0000000000000 --- a/src/test/ui/E0508-fail.ast.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508-fail.rs:8:18 - | -LL | let _value = array[0]; //[ast]~ ERROR [E0508] - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508-fail.ast.stderr b/src/test/ui/E0508-fail.ast.stderr deleted file mode 100644 index 57959c96f63ec..0000000000000 --- a/src/test/ui/E0508-fail.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508-fail.rs:8:18 - | -LL | let _value = array[0]; //[ast]~ ERROR [E0508] - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider using a reference instead: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508-fail.mir.stderr b/src/test/ui/E0508-fail.mir.stderr deleted file mode 100644 index 4cc1cf89d6cb9..0000000000000 --- a/src/test/ui/E0508-fail.mir.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508-fail.rs:8:18 - | -LL | let _value = array[0]; //[ast]~ ERROR [E0508] - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508-fail.rs b/src/test/ui/E0508-fail.rs index 20eac6cd3519f..072c3d66183e3 100644 --- a/src/test/ui/E0508-fail.rs +++ b/src/test/ui/E0508-fail.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct NonCopy; fn main() { let array = [NonCopy; 1]; - let _value = array[0]; //[ast]~ ERROR [E0508] - //[mir]~^ ERROR [E0508] + let _value = array[0]; //~ ERROR [E0508] } diff --git a/src/test/ui/E0508.nll.stderr b/src/test/ui/E0508-fail.stderr similarity index 93% rename from src/test/ui/E0508.nll.stderr rename to src/test/ui/E0508-fail.stderr index 82fdce2112ecf..e4be96797e69b 100644 --- a/src/test/ui/E0508.nll.stderr +++ b/src/test/ui/E0508-fail.stderr @@ -1,5 +1,5 @@ error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508.rs:5:18 + --> $DIR/E0508-fail.rs:5:18 | LL | let _value = array[0]; //~ ERROR [E0508] | ^^^^^^^^ diff --git a/src/test/ui/E0508.ast.stderr b/src/test/ui/E0508.ast.stderr deleted file mode 100644 index 5878b795b771c..0000000000000 --- a/src/test/ui/E0508.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508.rs:18:18 - | -LL | let _value = array[0]; //[ast]~ ERROR [E0508] - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider using a reference instead: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508.mir.stderr b/src/test/ui/E0508.mir.stderr deleted file mode 100644 index 5878b795b771c..0000000000000 --- a/src/test/ui/E0508.mir.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508.rs:18:18 - | -LL | let _value = array[0]; //[ast]~ ERROR [E0508] - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider using a reference instead: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508.stderr b/src/test/ui/E0508.stderr index 1e7b4071d5d79..82fdce2112ecf 100644 --- a/src/test/ui/E0508.stderr +++ b/src/test/ui/E0508.stderr @@ -5,7 +5,7 @@ LL | let _value = array[0]; //~ ERROR [E0508] | ^^^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&array[0]` + | help: consider borrowing here: `&array[0]` error: aborting due to previous error diff --git a/src/test/ui/E0594.ast.stderr b/src/test/ui/E0594.ast.stderr deleted file mode 100644 index 4eb9ba133ae55..0000000000000 --- a/src/test/ui/E0594.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0594]: cannot assign to immutable static item - --> $DIR/E0594.rs:7:5 - | -LL | NUM = 20; //[ast]~ ERROR E0594 - | ^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/E0594.mir.stderr b/src/test/ui/E0594.mir.stderr deleted file mode 100644 index 54681a29b81bc..0000000000000 --- a/src/test/ui/E0594.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0594]: cannot assign to immutable static item `NUM` - --> $DIR/E0594.rs:7:5 - | -LL | NUM = 20; //[ast]~ ERROR E0594 - | ^^^^^^^^ cannot assign - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/E0594.rs b/src/test/ui/E0594.rs index a8ca2fe61613a..8b0cae7e17b30 100644 --- a/src/test/ui/E0594.rs +++ b/src/test/ui/E0594.rs @@ -1,9 +1,5 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static NUM: i32 = 18; fn main() { - NUM = 20; //[ast]~ ERROR E0594 - //[mir]~^ ERROR cannot assign to immutable static item `NUM` + NUM = 20; //~ ERROR cannot assign to immutable static item `NUM` } diff --git a/src/test/ui/E0594.ast.nll.stderr b/src/test/ui/E0594.stderr similarity index 67% rename from src/test/ui/E0594.ast.nll.stderr rename to src/test/ui/E0594.stderr index 54681a29b81bc..6c3582302e975 100644 --- a/src/test/ui/E0594.ast.nll.stderr +++ b/src/test/ui/E0594.stderr @@ -1,7 +1,7 @@ error[E0594]: cannot assign to immutable static item `NUM` - --> $DIR/E0594.rs:7:5 + --> $DIR/E0594.rs:4:5 | -LL | NUM = 20; //[ast]~ ERROR E0594 +LL | NUM = 20; //~ ERROR cannot assign to immutable static item `NUM` | ^^^^^^^^ cannot assign error: aborting due to previous error diff --git a/src/test/ui/E0596.ast.stderr b/src/test/ui/E0596.ast.stderr deleted file mode 100644 index 6e65cc855e7f1..0000000000000 --- a/src/test/ui/E0596.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/E0596.rs:6:18 - | -LL | let x = 1; - | - help: make this binding mutable: `mut x` -LL | let y = &mut x; //[ast]~ ERROR [E0596] - | ^ cannot borrow mutably - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/E0596.mir.stderr b/src/test/ui/E0596.mir.stderr deleted file mode 100644 index e5da6649f5aaf..0000000000000 --- a/src/test/ui/E0596.mir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/E0596.rs:6:13 - | -LL | let x = 1; - | - help: consider changing this to be mutable: `mut x` -LL | let y = &mut x; //[ast]~ ERROR [E0596] - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/E0596.rs b/src/test/ui/E0596.rs index 3ea2d64a404c7..9e2f5ee763639 100644 --- a/src/test/ui/E0596.rs +++ b/src/test/ui/E0596.rs @@ -1,8 +1,4 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let x = 1; - let y = &mut x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let y = &mut x; //~ ERROR [E0596] } diff --git a/src/test/ui/E0596.ast.nll.stderr b/src/test/ui/E0596.stderr similarity index 81% rename from src/test/ui/E0596.ast.nll.stderr rename to src/test/ui/E0596.stderr index e5da6649f5aaf..9f7803d89eb15 100644 --- a/src/test/ui/E0596.ast.nll.stderr +++ b/src/test/ui/E0596.stderr @@ -1,9 +1,9 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/E0596.rs:6:13 + --> $DIR/E0596.rs:3:13 | LL | let x = 1; | - help: consider changing this to be mutable: `mut x` -LL | let y = &mut x; //[ast]~ ERROR [E0596] +LL | let y = &mut x; //~ ERROR [E0596] | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/access-mode-in-closures.nll.stderr b/src/test/ui/access-mode-in-closures.nll.stderr deleted file mode 100644 index 0c9a62351d20d..0000000000000 --- a/src/test/ui/access-mode-in-closures.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/access-mode-in-closures.rs:8:15 - | -LL | match *s { S(v) => v } //~ ERROR cannot move out - | ^^ - data moved here - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `s` - | -note: move occurs because `v` has type `std::vec::Vec`, which does not implement the `Copy` trait - --> $DIR/access-mode-in-closures.rs:8:22 - | -LL | match *s { S(v) => v } //~ ERROR cannot move out - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/access-mode-in-closures.stderr b/src/test/ui/access-mode-in-closures.stderr index 0423c713531f7..0c9a62351d20d 100644 --- a/src/test/ui/access-mode-in-closures.stderr +++ b/src/test/ui/access-mode-in-closures.stderr @@ -2,9 +2,16 @@ error[E0507]: cannot move out of borrowed content --> $DIR/access-mode-in-closures.rs:8:15 | LL | match *s { S(v) => v } //~ ERROR cannot move out - | ^^ - hint: to prevent move, use `ref v` or `ref mut v` + | ^^ - data moved here | | | cannot move out of borrowed content + | help: consider removing the `*`: `s` + | +note: move occurs because `v` has type `std::vec::Vec`, which does not implement the `Copy` trait + --> $DIR/access-mode-in-closures.rs:8:22 + | +LL | match *s { S(v) => v } //~ ERROR cannot move out + | ^ error: aborting due to previous error diff --git a/src/test/ui/asm/asm-out-assign-imm.nll.stderr b/src/test/ui/asm/asm-out-assign-imm.nll.stderr deleted file mode 100644 index ac38218b8492f..0000000000000 --- a/src/test/ui/asm/asm-out-assign-imm.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/asm-out-assign-imm.rs:24:34 - | -LL | let x: isize; - | - help: make this binding mutable: `mut x` -LL | x = 1; - | ----- first assignment to `x` -... -LL | asm!("mov $1, $0" : "=r"(x) : "r"(5)); - | ^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/asm/asm-out-assign-imm.stderr b/src/test/ui/asm/asm-out-assign-imm.stderr index 98f2f68a8f3c1..ac38218b8492f 100644 --- a/src/test/ui/asm/asm-out-assign-imm.stderr +++ b/src/test/ui/asm/asm-out-assign-imm.stderr @@ -1,6 +1,8 @@ error[E0384]: cannot assign twice to immutable variable `x` --> $DIR/asm-out-assign-imm.rs:24:34 | +LL | let x: isize; + | - help: make this binding mutable: `mut x` LL | x = 1; | ----- first assignment to `x` ... diff --git a/src/test/ui/asm/asm-out-read-uninit.mir.stderr b/src/test/ui/asm/asm-out-read-uninit.mir.stderr deleted file mode 100644 index cf74298be4a5d..0000000000000 --- a/src/test/ui/asm/asm-out-read-uninit.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/asm-out-read-uninit.rs:25:43 - | -LL | asm!("mov $1, $0" : "=r"(x) : "r"(x)); - | ^ use of possibly uninitialized `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/asm/asm-out-read-uninit.rs b/src/test/ui/asm/asm-out-read-uninit.rs index 44dd0503c3bbf..003f1fc5bb62b 100644 --- a/src/test/ui/asm/asm-out-read-uninit.rs +++ b/src/test/ui/asm/asm-out-read-uninit.rs @@ -8,9 +8,6 @@ // ignore-mips // ignore-mips64 -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] fn foo(x: isize) { println!("{}", x); } @@ -23,8 +20,7 @@ pub fn main() { let x: isize; unsafe { asm!("mov $1, $0" : "=r"(x) : "r"(x)); - //[ast]~^ ERROR use of possibly uninitialized variable: `x` - //[mir]~^^ ERROR use of possibly uninitialized variable: `x` + //~^ ERROR use of possibly uninitialized variable: `x` } foo(x); } diff --git a/src/test/ui/asm/asm-out-read-uninit.ast.stderr b/src/test/ui/asm/asm-out-read-uninit.stderr similarity index 88% rename from src/test/ui/asm/asm-out-read-uninit.ast.stderr rename to src/test/ui/asm/asm-out-read-uninit.stderr index cf74298be4a5d..6d0445d4b7a61 100644 --- a/src/test/ui/asm/asm-out-read-uninit.ast.stderr +++ b/src/test/ui/asm/asm-out-read-uninit.stderr @@ -1,5 +1,5 @@ error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/asm-out-read-uninit.rs:25:43 + --> $DIR/asm-out-read-uninit.rs:22:43 | LL | asm!("mov $1, $0" : "=r"(x) : "r"(x)); | ^ use of possibly uninitialized `x` diff --git a/src/test/ui/assign-imm-local-twice.ast.nll.stderr b/src/test/ui/assign-imm-local-twice.ast.nll.stderr deleted file mode 100644 index 311a83a76f933..0000000000000 --- a/src/test/ui/assign-imm-local-twice.ast.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/assign-imm-local-twice.rs:11:5 - | -LL | let v: isize; - | - help: make this binding mutable: `mut v` -... -LL | v = 1; //[ast]~ NOTE first assignment - | ----- first assignment to `v` -... -LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/assign-imm-local-twice.ast.stderr b/src/test/ui/assign-imm-local-twice.ast.stderr deleted file mode 100644 index d57acb2c62154..0000000000000 --- a/src/test/ui/assign-imm-local-twice.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/assign-imm-local-twice.rs:11:5 - | -LL | v = 1; //[ast]~ NOTE first assignment - | ----- first assignment to `v` -... -LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/assign-imm-local-twice.rs b/src/test/ui/assign-imm-local-twice.rs index de966a17857c6..c1c9bf62819af 100644 --- a/src/test/ui/assign-imm-local-twice.rs +++ b/src/test/ui/assign-imm-local-twice.rs @@ -1,17 +1,11 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { let v: isize; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut v - v = 1; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment + //~^ HELP make this binding mutable + //~| SUGGESTION mut v + v = 1; //~ NOTE first assignment println!("v={}", v); - v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + v = 2; //~ ERROR cannot assign twice to immutable variable + //~| NOTE cannot assign twice to immutable println!("v={}", v); } diff --git a/src/test/ui/assign-imm-local-twice.mir.stderr b/src/test/ui/assign-imm-local-twice.stderr similarity index 66% rename from src/test/ui/assign-imm-local-twice.mir.stderr rename to src/test/ui/assign-imm-local-twice.stderr index 311a83a76f933..6ea8c0fb50454 100644 --- a/src/test/ui/assign-imm-local-twice.mir.stderr +++ b/src/test/ui/assign-imm-local-twice.stderr @@ -1,13 +1,13 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/assign-imm-local-twice.rs:11:5 + --> $DIR/assign-imm-local-twice.rs:7:5 | LL | let v: isize; | - help: make this binding mutable: `mut v` ... -LL | v = 1; //[ast]~ NOTE first assignment +LL | v = 1; //~ NOTE first assignment | ----- first assignment to `v` -... -LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable +LL | println!("v={}", v); +LL | v = 2; //~ ERROR cannot assign twice to immutable variable | ^^^^^ cannot assign twice to immutable variable error: aborting due to previous error diff --git a/src/test/ui/associated-types/associated-types-outlives.nll.stderr b/src/test/ui/associated-types/associated-types-outlives.nll.stderr deleted file mode 100644 index c58dc314e8a9d..0000000000000 --- a/src/test/ui/associated-types/associated-types-outlives.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/associated-types-outlives.rs:22:14 - | -LL | 's: loop { y = denormalise(&x); break } - | -- borrow of `x` occurs here -LL | drop(x); //~ ERROR cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here -LL | return f(y); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/associated-types/associated-types-outlives.stderr b/src/test/ui/associated-types/associated-types-outlives.stderr index 4cf3e473cf192..c58dc314e8a9d 100644 --- a/src/test/ui/associated-types/associated-types-outlives.stderr +++ b/src/test/ui/associated-types/associated-types-outlives.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/associated-types-outlives.rs:22:14 | LL | 's: loop { y = denormalise(&x); break } - | - borrow of `x` occurs here + | -- borrow of `x` occurs here LL | drop(x); //~ ERROR cannot move out of `x` because it is borrowed | ^ move out of `x` occurs here +LL | return f(y); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/augmented-assignments.nll.stderr b/src/test/ui/augmented-assignments.nll.stderr deleted file mode 100644 index 33c94d6e3a59e..0000000000000 --- a/src/test/ui/augmented-assignments.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/augmented-assignments.rs:16:5 - | -LL | x //~ error: use of moved value: `x` - | - - | | - | _____borrow of `x` occurs here - | | -LL | | //~^ value used here after move -LL | | += -LL | | x; //~ value moved here - | | ^ - | | | - | |_____move out of `x` occurs here - | borrow later used here - -error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/augmented-assignments.rs:21:5 - | -LL | let y = Int(2); - | - help: consider changing this to be mutable: `mut y` -... -LL | y //~ error: cannot borrow immutable local variable `y` as mutable - | ^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -Some errors occurred: E0505, E0596. -For more information about an error, try `rustc --explain E0505`. diff --git a/src/test/ui/augmented-assignments.rs b/src/test/ui/augmented-assignments.rs index eea15eae879e6..cda4e2c32d00b 100644 --- a/src/test/ui/augmented-assignments.rs +++ b/src/test/ui/augmented-assignments.rs @@ -10,16 +10,19 @@ impl AddAssign for Int { fn main() { let mut x = Int(1); - x //~ error: use of moved value: `x` - //~^ value used here after move + x + //~^ borrow later used here + //~| NOTE borrow of `x` occurs here += - x; //~ value moved here + x; + //~^ ERROR cannot move out of `x` because it is borrowed + //~| move out of `x` occurs here let y = Int(2); - //~^ HELP make this binding mutable + //~^ HELP consider changing this to be mutable //~| SUGGESTION mut y - y //~ error: cannot borrow immutable local variable `y` as mutable - //~| cannot borrow + y //~ ERROR cannot borrow `y` as mutable, as it is not declared as mutable + //~| cannot borrow as mutable += Int(1); } diff --git a/src/test/ui/augmented-assignments.stderr b/src/test/ui/augmented-assignments.stderr index 73de315e542a2..50fe95f6b6f6e 100644 --- a/src/test/ui/augmented-assignments.stderr +++ b/src/test/ui/augmented-assignments.stderr @@ -1,24 +1,30 @@ -error[E0596]: cannot borrow immutable local variable `y` as mutable - --> $DIR/augmented-assignments.rs:21:5 +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/augmented-assignments.rs:17:5 | -LL | let y = Int(2); - | - help: make this binding mutable: `mut y` -... -LL | y //~ error: cannot borrow immutable local variable `y` as mutable - | ^ cannot borrow mutably +LL | x + | - + | | + | _____borrow of `x` occurs here + | | +LL | | //~^ borrow later used here +LL | | //~| NOTE borrow of `x` occurs here +LL | | += +LL | | x; + | | ^ + | | | + | |_____move out of `x` occurs here + | borrow later used here -error[E0382]: use of moved value: `x` - --> $DIR/augmented-assignments.rs:13:5 +error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable + --> $DIR/augmented-assignments.rs:24:5 | -LL | x //~ error: use of moved value: `x` - | ^ value used here after move +LL | let y = Int(2); + | - help: consider changing this to be mutable: `mut y` ... -LL | x; //~ value moved here - | - value moved here - | - = note: move occurs because `x` has type `Int`, which does not implement the `Copy` trait +LL | y //~ ERROR cannot borrow `y` as mutable, as it is not declared as mutable + | ^ cannot borrow as mutable error: aborting due to 2 previous errors -Some errors occurred: E0382, E0596. -For more information about an error, try `rustc --explain E0382`. +Some errors occurred: E0505, E0596. +For more information about an error, try `rustc --explain E0505`. diff --git a/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr b/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr deleted file mode 100644 index 5f8b7007f304c..0000000000000 --- a/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/bind-by-move-no-guards.rs:8:14 - | -LL | Some(z) if z.recv().unwrap() => { panic!() }, - | ^ moves value into pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr b/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr index 2af2b0d660efa..5f8b7007f304c 100644 --- a/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr +++ b/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr @@ -3,6 +3,8 @@ error[E0008]: cannot bind by-move into a pattern guard | LL | Some(z) if z.recv().unwrap() => { panic!() }, | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/binop/binop-consume-args.nll.stderr b/src/test/ui/binop/binop-consume-args.nll.stderr deleted file mode 100644 index 59b5aba93cad4..0000000000000 --- a/src/test/ui/binop/binop-consume-args.nll.stderr +++ /dev/null @@ -1,253 +0,0 @@ -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:7:10 - | -LL | fn add, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs + rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:8:10 - | -LL | fn add, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs + rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:13:10 - | -LL | fn sub, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs - rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:14:10 - | -LL | fn sub, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs - rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:19:10 - | -LL | fn mul, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs * rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:20:10 - | -LL | fn mul, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs * rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:25:10 - | -LL | fn div, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs / rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:26:10 - | -LL | fn div, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs / rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:31:10 - | -LL | fn rem, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs % rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:32:10 - | -LL | fn rem, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs % rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:37:10 - | -LL | fn bitand, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs & rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:38:10 - | -LL | fn bitand, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs & rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:43:10 - | -LL | fn bitor, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs | rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:44:10 - | -LL | fn bitor, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs | rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:49:10 - | -LL | fn bitxor, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs ^ rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:50:10 - | -LL | fn bitxor, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs ^ rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:55:10 - | -LL | fn shl, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs << rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:56:10 - | -LL | fn shl, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs << rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:61:10 - | -LL | fn shr, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs >> rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:62:10 - | -LL | fn shr, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs >> rhs; - | --- value moved here -LL | drop(lhs); //~ ERROR use of moved value: `lhs` -LL | drop(rhs); //~ ERROR use of moved value: `rhs` - | ^^^ value used here after move - -error: aborting due to 20 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/binop/binop-consume-args.stderr b/src/test/ui/binop/binop-consume-args.stderr index 0b5d2200b9ffc..59b5aba93cad4 100644 --- a/src/test/ui/binop/binop-consume-args.stderr +++ b/src/test/ui/binop/binop-consume-args.stderr @@ -1,212 +1,252 @@ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:7:10 | +LL | fn add, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs + rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:8:10 | +LL | fn add, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs + rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:13:10 | +LL | fn sub, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs - rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:14:10 | +LL | fn sub, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs - rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:19:10 | +LL | fn mul, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs * rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:20:10 | +LL | fn mul, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs * rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:25:10 | +LL | fn div, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs / rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:26:10 | +LL | fn div, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs / rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:31:10 | +LL | fn rem, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs % rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:32:10 | +LL | fn rem, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs % rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:37:10 | +LL | fn bitand, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs & rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:38:10 | +LL | fn bitand, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs & rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:43:10 | +LL | fn bitor, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs | rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:44:10 | +LL | fn bitor, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs | rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:49:10 | +LL | fn bitxor, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs ^ rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:50:10 | +LL | fn bitxor, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs ^ rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:55:10 | +LL | fn shl, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs << rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:56:10 | +LL | fn shl, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs << rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:61:10 | +LL | fn shr, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs >> rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:62:10 | +LL | fn shr, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs >> rhs; | --- value moved here LL | drop(lhs); //~ ERROR use of moved value: `lhs` LL | drop(rhs); //~ ERROR use of moved value: `rhs` | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error: aborting due to 20 previous errors diff --git a/src/test/ui/binop/binop-move-semantics.nll.stderr b/src/test/ui/binop/binop-move-semantics.nll.stderr deleted file mode 100644 index 7c84e8833a9e6..0000000000000 --- a/src/test/ui/binop/binop-move-semantics.nll.stderr +++ /dev/null @@ -1,95 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/binop-move-semantics.rs:8:5 - | -LL | fn double_move>(x: T) { - | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | x - | - value moved here -LL | + -LL | x; //~ ERROR: use of moved value - | ^ value used here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/binop-move-semantics.rs:14:5 - | -LL | fn move_then_borrow + Clone>(x: T) { - | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | x - | - value moved here -LL | + -LL | x.clone(); //~ ERROR: use of moved value - | ^ value borrowed here after move - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/binop-move-semantics.rs:21:5 - | -LL | let m = &x; - | -- borrow of `x` occurs here -... -LL | x //~ ERROR: cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here -... -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/binop-move-semantics.rs:23:5 - | -LL | let n = &mut y; - | ------ borrow of `y` occurs here -... -LL | y; //~ ERROR: cannot move out of `y` because it is borrowed - | ^ move out of `y` occurs here -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0507]: cannot move out of borrowed content - --> $DIR/binop-move-semantics.rs:30:5 - | -LL | *m //~ ERROR: cannot move out of borrowed content - | ^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/binop-move-semantics.rs:32:5 - | -LL | *n; //~ ERROR: cannot move out of borrowed content - | ^^ cannot move out of borrowed content - -error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable - --> $DIR/binop-move-semantics.rs:54:5 - | -LL | &mut f - | ------ - | | - | _____mutable borrow occurs here - | | -LL | | + -LL | | &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable - | | ^- - | |_____|| - | |mutable borrow later used here - | immutable borrow occurs here - -error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable - --> $DIR/binop-move-semantics.rs:62:5 - | -LL | &f - | -- - | | - | _____immutable borrow occurs here - | | -LL | | + -LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable - | | ^^^^^- - | |_____|____| - | | immutable borrow later used here - | mutable borrow occurs here - -error: aborting due to 8 previous errors - -Some errors occurred: E0382, E0502, E0505, E0507. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/binop/binop-move-semantics.rs b/src/test/ui/binop/binop-move-semantics.rs index 2bcf16f8ba88c..17dec59404201 100644 --- a/src/test/ui/binop/binop-move-semantics.rs +++ b/src/test/ui/binop/binop-move-semantics.rs @@ -11,7 +11,7 @@ fn double_move>(x: T) { fn move_then_borrow + Clone>(x: T) { x + - x.clone(); //~ ERROR: use of moved value + x.clone(); //~ ERROR: borrow of moved value } fn move_borrowed>(x: T, mut y: T) { diff --git a/src/test/ui/binop/binop-move-semantics.stderr b/src/test/ui/binop/binop-move-semantics.stderr index b1dc70d379d40..2b0c3c927ba50 100644 --- a/src/test/ui/binop/binop-move-semantics.stderr +++ b/src/test/ui/binop/binop-move-semantics.stderr @@ -1,42 +1,51 @@ error[E0382]: use of moved value: `x` --> $DIR/binop-move-semantics.rs:8:5 | +LL | fn double_move>(x: T) { + | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | x | - value moved here LL | + LL | x; //~ ERROR: use of moved value | ^ value used here after move - | - = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/binop-move-semantics.rs:14:5 | +LL | fn move_then_borrow + Clone>(x: T) { + | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | x | - value moved here LL | + -LL | x.clone(); //~ ERROR: use of moved value - | ^ value used here after move - | - = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait +LL | x.clone(); //~ ERROR: borrow of moved value + | ^ value borrowed here after move error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/binop-move-semantics.rs:21:5 | LL | let m = &x; - | - borrow of `x` occurs here + | -- borrow of `x` occurs here ... LL | x //~ ERROR: cannot move out of `x` because it is borrowed | ^ move out of `x` occurs here +... +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/binop-move-semantics.rs:23:5 | LL | let n = &mut y; - | - borrow of `y` occurs here + | ------ borrow of `y` occurs here ... LL | y; //~ ERROR: cannot move out of `y` because it is borrowed | ^ move out of `y` occurs here +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0507]: cannot move out of borrowed content --> $DIR/binop-move-semantics.rs:30:5 @@ -51,28 +60,34 @@ LL | *n; //~ ERROR: cannot move out of borrowed content | ^^ cannot move out of borrowed content error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable - --> $DIR/binop-move-semantics.rs:54:6 + --> $DIR/binop-move-semantics.rs:54:5 | -LL | &mut f - | - mutable borrow occurs here -LL | + -LL | &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable - | ^ - | | - | immutable borrow occurs here - | mutable borrow ends here +LL | &mut f + | ------ + | | + | _____mutable borrow occurs here + | | +LL | | + +LL | | &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable + | | ^- + | |_____|| + | |mutable borrow later used here + | immutable borrow occurs here error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable - --> $DIR/binop-move-semantics.rs:62:10 + --> $DIR/binop-move-semantics.rs:62:5 | -LL | &f - | - immutable borrow occurs here -LL | + -LL | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable - | ^ - | | - | mutable borrow occurs here - | immutable borrow ends here +LL | &f + | -- + | | + | _____immutable borrow occurs here + | | +LL | | + +LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable + | | ^^^^^- + | |_____|____| + | | immutable borrow later used here + | mutable borrow occurs here error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/assign_mutable_fields.nll.stderr b/src/test/ui/borrowck/assign_mutable_fields.nll.stderr deleted file mode 100644 index 35101df4e0a6e..0000000000000 --- a/src/test/ui/borrowck/assign_mutable_fields.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/assign_mutable_fields.rs:9:5 - | -LL | x.0 = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/assign_mutable_fields.rs:17:5 - | -LL | x.0 = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/assign_mutable_fields.rs b/src/test/ui/borrowck/assign_mutable_fields.rs index 85d6f3b74c02f..b60726d0c8b38 100644 --- a/src/test/ui/borrowck/assign_mutable_fields.rs +++ b/src/test/ui/borrowck/assign_mutable_fields.rs @@ -1,22 +1,22 @@ -// Currently, we permit you to assign to individual fields of a mut -// var, but we do not permit you to use the complete var afterwards. +// Currently, we do permit you to assign to individual fields of an +// uninitialized var. // We hope to fix this at some point. // // FIXME(#54987) fn assign_both_fields_and_use() { let mut x: (u32, u32); - x.0 = 1; + x.0 = 1; //~ ERROR x.1 = 22; - drop(x.0); //~ ERROR - drop(x.1); //~ ERROR + drop(x.0); + drop(x.1); } fn assign_both_fields_the_use_var() { let mut x: (u32, u32); - x.0 = 1; + x.0 = 1; //~ ERROR x.1 = 22; - drop(x); //~ ERROR + drop(x); } fn main() { } diff --git a/src/test/ui/borrowck/assign_mutable_fields.stderr b/src/test/ui/borrowck/assign_mutable_fields.stderr index 9024e7cf01cb4..9f3ca03d3c526 100644 --- a/src/test/ui/borrowck/assign_mutable_fields.stderr +++ b/src/test/ui/borrowck/assign_mutable_fields.stderr @@ -1,21 +1,15 @@ -error[E0381]: use of possibly uninitialized variable: `x.0` - --> $DIR/assign_mutable_fields.rs:11:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/assign_mutable_fields.rs:9:5 | -LL | drop(x.0); //~ ERROR - | ^^^ use of possibly uninitialized `x.0` +LL | x.0 = 1; //~ ERROR + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x.1` - --> $DIR/assign_mutable_fields.rs:12:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/assign_mutable_fields.rs:17:5 | -LL | drop(x.1); //~ ERROR - | ^^^ use of possibly uninitialized `x.1` +LL | x.0 = 1; //~ ERROR + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/assign_mutable_fields.rs:19:10 - | -LL | drop(x); //~ ERROR - | ^ use of possibly uninitialized `x` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.nll.stderr b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.nll.stderr deleted file mode 100644 index 9174a6976113b..0000000000000 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.nll.stderr +++ /dev/null @@ -1,76 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:15:27 - | -LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:15:24 - | -LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign - | ^^^^^^^^^ - -error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:18:31 - | -LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:18:24 - | -LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^ - -error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:21:55 - | -LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:21:52 - | -LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign - | ^^^^^^^^^ - -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:27:32 - | -LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:27:24 - | -LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign - | ^^^^^^^^^^^^^^ - -error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:30:36 - | -LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:30:24 - | -LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^^^^^^ - -error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:33:65 - | -LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:33:57 - | -LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign - | ^^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr index 505604ab597d4..9174a6976113b 100644 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr +++ b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr @@ -1,72 +1,70 @@ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:15:27 | LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign - | ^^^^^^ + | ^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:15:24 | LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign | ^^^^^^^^^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:18:36 +error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:18:31 | LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:18:24 | LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:21:55 | LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign - | ^^^^^^ + | ^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:21:52 | LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign | ^^^^^^^^^ -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:27:32 | LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign - | ^^^^^^ + | ^^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:27:24 | LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign | ^^^^^^^^^^^^^^ -error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable - --> $DIR/borrow-immutable-upvar-mutation.rs:30:41 +error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:30:36 | LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:30:24 | LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^^^^ -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:33:65 | LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign - | ^^^^^^ + | ^^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:33:57 | LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign @@ -74,5 +72,5 @@ LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }) error: aborting due to 6 previous errors -Some errors occurred: E0387, E0594, E0596. -For more information about an error, try `rustc --explain E0387`. +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr b/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr deleted file mode 100644 index 72a29b864a4f1..0000000000000 --- a/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr +++ /dev/null @@ -1,65 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:12:13 - | -LL | let r = &x.0; - | ---- borrow of `x.0` occurs here -LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here -LL | -LL | r.use_ref(); - | - borrow later used here - -error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:18:13 - | -LL | let a = &x.0; - | ---- immutable borrow occurs here -LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as - | ^^^^^^^^ mutable borrow occurs here -LL | a.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:23:13 - | -LL | let a = &mut x.0; - | -------- first mutable borrow occurs here -LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time - | ^^^^^^^^ second mutable borrow occurs here -LL | a.use_ref(); - | - first borrow later used here - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:28:13 - | -LL | let r = &x.0; - | ---- borrow of `x.0` occurs here -LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here -LL | r.use_ref(); - | - borrow later used here - -error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:33:13 - | -LL | let a = &x.0; - | ---- immutable borrow occurs here -LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as - | ^^^^^^^^ mutable borrow occurs here -LL | a.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:38:13 - | -LL | let a = &mut x.0; - | -------- first mutable borrow occurs here -LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time - | ^^^^^^^^ second mutable borrow occurs here -LL | a.use_mut(); - | - first borrow later used here - -error: aborting due to 6 previous errors - -Some errors occurred: E0499, E0502, E0505. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrow-tuple-fields.stderr b/src/test/ui/borrowck/borrow-tuple-fields.stderr index a62e7287e683f..72a29b864a4f1 100644 --- a/src/test/ui/borrowck/borrow-tuple-fields.stderr +++ b/src/test/ui/borrowck/borrow-tuple-fields.stderr @@ -1,62 +1,63 @@ error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:12:9 + --> $DIR/borrow-tuple-fields.rs:12:13 | LL | let r = &x.0; - | --- borrow of `x.0` occurs here + | ---- borrow of `x.0` occurs here LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here + | ^ move out of `x` occurs here +LL | +LL | r.use_ref(); + | - borrow later used here error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:18:18 + --> $DIR/borrow-tuple-fields.rs:18:13 | LL | let a = &x.0; - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^^ mutable borrow occurs here +LL | a.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:23:18 + --> $DIR/borrow-tuple-fields.rs:23:13 | LL | let a = &mut x.0; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time - | ^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^ second mutable borrow occurs here +LL | a.use_ref(); + | - first borrow later used here error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:28:9 + --> $DIR/borrow-tuple-fields.rs:28:13 | LL | let r = &x.0; - | --- borrow of `x.0` occurs here + | ---- borrow of `x.0` occurs here LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here + | ^ move out of `x` occurs here +LL | r.use_ref(); + | - borrow later used here error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:33:18 + --> $DIR/borrow-tuple-fields.rs:33:13 | LL | let a = &x.0; - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^^ mutable borrow occurs here +LL | a.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:38:18 + --> $DIR/borrow-tuple-fields.rs:38:13 | LL | let a = &mut x.0; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time - | ^^^ second mutable borrow occurs here + | ^^^^^^^^ second mutable borrow occurs here LL | a.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error: aborting due to 6 previous errors diff --git a/src/test/ui/borrowck/borrowck-access-permissions.ast.nll.stderr b/src/test/ui/borrowck/borrowck-access-permissions.ast.nll.stderr deleted file mode 100644 index 0d771a55d5995..0000000000000 --- a/src/test/ui/borrowck/borrowck-access-permissions.ast.nll.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:12:19 - | -LL | let x = 1; - | - help: consider changing this to be mutable: `mut x` -... -LL | let _y1 = &mut x; //[ast]~ ERROR [E0596] - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable static item `static_x` as mutable - --> $DIR/borrowck-access-permissions.rs:18:19 - | -LL | let _y1 = &mut static_x; //[ast]~ ERROR [E0596] - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:27:19 - | -LL | let box_x = Box::new(1); - | ----- help: consider changing this to be mutable: `mut box_x` -... -LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] - | ^^^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:36:19 - | -LL | let ref_x = &x; - | -- help: consider changing this to be a mutable reference: `&mut x` -... -LL | let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] - | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer - --> $DIR/borrowck-access-permissions.rs:46:23 - | -LL | let ptr_x : *const _ = &x; - | -- help: consider changing this to be a mutable pointer: `&mut x` -... -LL | let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] - | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:56:18 - | -LL | let foo_ref = &foo; - | ---- help: consider changing this to be a mutable reference: `&mut foo` -LL | let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] - | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-access-permissions.ast.stderr b/src/test/ui/borrowck/borrowck-access-permissions.ast.stderr deleted file mode 100644 index 4b0e261b17461..0000000000000 --- a/src/test/ui/borrowck/borrowck-access-permissions.ast.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/borrowck-access-permissions.rs:12:24 - | -LL | let x = 1; - | - help: make this binding mutable: `mut x` -... -LL | let _y1 = &mut x; //[ast]~ ERROR [E0596] - | ^ cannot borrow mutably - -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/borrowck-access-permissions.rs:18:24 - | -LL | let _y1 = &mut static_x; //[ast]~ ERROR [E0596] - | ^^^^^^^^ - -error[E0596]: cannot borrow immutable `Box` content `*box_x` as mutable - --> $DIR/borrowck-access-permissions.rs:27:24 - | -LL | let box_x = Box::new(1); - | ----- help: make this binding mutable: `mut box_x` -... -LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable borrowed content `*ref_x` as mutable - --> $DIR/borrowck-access-permissions.rs:36:24 - | -LL | let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable dereference of raw pointer `*ptr_x` as mutable - --> $DIR/borrowck-access-permissions.rs:46:28 - | -LL | let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] - | ^^^^^^ cannot borrow as mutable - -error[E0389]: cannot borrow data mutably in a `&` reference - --> $DIR/borrowck-access-permissions.rs:56:23 - | -LL | let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] - | ^^^^^^^^^^ assignment into an immutable reference - -error: aborting due to 6 previous errors - -Some errors occurred: E0389, E0596. -For more information about an error, try `rustc --explain E0389`. diff --git a/src/test/ui/borrowck/borrowck-access-permissions.rs b/src/test/ui/borrowck/borrowck-access-permissions.rs index 993742f427e03..469ad508b0e77 100644 --- a/src/test/ui/borrowck/borrowck-access-permissions.rs +++ b/src/test/ui/borrowck/borrowck-access-permissions.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static static_x : i32 = 1; static mut static_x_mut : i32 = 1; @@ -9,14 +6,12 @@ fn main() { let mut x_mut = 1; { // borrow of local - let _y1 = &mut x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut x; //~ ERROR [E0596] let _y2 = &mut x_mut; // No error } { // borrow of static - let _y1 = &mut static_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut static_x; //~ ERROR [E0596] unsafe { let _y2 = &mut static_x_mut; } // No error } @@ -24,8 +19,7 @@ fn main() { let box_x = Box::new(1); let mut box_x_mut = Box::new(1); - let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut *box_x; //~ ERROR [E0596] let _y2 = &mut *box_x_mut; // No error } @@ -33,8 +27,7 @@ fn main() { let ref_x = &x; let ref_x_mut = &mut x_mut; - let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut *ref_x; //~ ERROR [E0596] let _y2 = &mut *ref_x_mut; // No error } @@ -43,8 +36,7 @@ fn main() { let ptr_mut_x : *mut _ = &mut x_mut; unsafe { - let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut *ptr_x; //~ ERROR [E0596] let _y2 = &mut *ptr_mut_x; // No error } } @@ -53,8 +45,6 @@ fn main() { struct Foo<'a> { f: &'a mut i32, g: &'a i32 }; let mut foo = Foo { f: &mut x_mut, g: &x }; let foo_ref = &foo; - let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] - //[mir]~^ ERROR [E0596] - // FIXME: Wrong error in MIR + let _y = &mut *foo_ref.f; //~ ERROR [E0596] } } diff --git a/src/test/ui/borrowck/borrowck-access-permissions.mir.stderr b/src/test/ui/borrowck/borrowck-access-permissions.stderr similarity index 73% rename from src/test/ui/borrowck/borrowck-access-permissions.mir.stderr rename to src/test/ui/borrowck/borrowck-access-permissions.stderr index 0d771a55d5995..0e4112f53c89c 100644 --- a/src/test/ui/borrowck/borrowck-access-permissions.mir.stderr +++ b/src/test/ui/borrowck/borrowck-access-permissions.stderr @@ -1,51 +1,51 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:12:19 + --> $DIR/borrowck-access-permissions.rs:9:19 | LL | let x = 1; | - help: consider changing this to be mutable: `mut x` ... -LL | let _y1 = &mut x; //[ast]~ ERROR [E0596] +LL | let _y1 = &mut x; //~ ERROR [E0596] | ^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow immutable static item `static_x` as mutable - --> $DIR/borrowck-access-permissions.rs:18:19 + --> $DIR/borrowck-access-permissions.rs:14:19 | -LL | let _y1 = &mut static_x; //[ast]~ ERROR [E0596] +LL | let _y1 = &mut static_x; //~ ERROR [E0596] | ^^^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:27:19 + --> $DIR/borrowck-access-permissions.rs:22:19 | LL | let box_x = Box::new(1); | ----- help: consider changing this to be mutable: `mut box_x` ... -LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] +LL | let _y1 = &mut *box_x; //~ ERROR [E0596] | ^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:36:19 + --> $DIR/borrowck-access-permissions.rs:30:19 | LL | let ref_x = &x; | -- help: consider changing this to be a mutable reference: `&mut x` ... -LL | let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] +LL | let _y1 = &mut *ref_x; //~ ERROR [E0596] | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer - --> $DIR/borrowck-access-permissions.rs:46:23 + --> $DIR/borrowck-access-permissions.rs:39:23 | LL | let ptr_x : *const _ = &x; | -- help: consider changing this to be a mutable pointer: `&mut x` ... -LL | let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] +LL | let _y1 = &mut *ptr_x; //~ ERROR [E0596] | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:56:18 + --> $DIR/borrowck-access-permissions.rs:48:18 | LL | let foo_ref = &foo; | ---- help: consider changing this to be a mutable reference: `&mut foo` -LL | let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] +LL | let _y = &mut *foo_ref.f; //~ ERROR [E0596] | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 6 previous errors diff --git a/src/test/ui/borrowck/borrowck-and-init.nll.stderr b/src/test/ui/borrowck/borrowck-and-init.nll.stderr deleted file mode 100644 index b4b02cf208ae7..0000000000000 --- a/src/test/ui/borrowck/borrowck-and-init.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `i` - --> $DIR/borrowck-and-init.rs:5:20 - | -LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` - | ^ use of possibly uninitialized `i` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-and-init.rs b/src/test/ui/borrowck/borrowck-and-init.rs index ff076c55cad24..4427e25186103 100644 --- a/src/test/ui/borrowck/borrowck-and-init.rs +++ b/src/test/ui/borrowck/borrowck-and-init.rs @@ -2,5 +2,5 @@ fn main() { let i: isize; println!("{}", false && { i = 5; true }); - println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i` } diff --git a/src/test/ui/borrowck/borrowck-and-init.stderr b/src/test/ui/borrowck/borrowck-and-init.stderr index 42b658871dfaa..afdec6662a185 100644 --- a/src/test/ui/borrowck/borrowck-and-init.stderr +++ b/src/test/ui/borrowck/borrowck-and-init.stderr @@ -1,7 +1,7 @@ -error[E0381]: use of possibly uninitialized variable: `i` +error[E0381]: borrow of possibly uninitialized variable: `i` --> $DIR/borrowck-and-init.rs:5:20 | -LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` +LL | println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i` | ^ use of possibly uninitialized `i` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr deleted file mode 100644 index 43c74988f9ea5..0000000000000 --- a/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-struct.rs:29:11 - | -LL | Y(ref mut a, _) => a - | --------- first mutable borrow occurs here -... -LL | Y(ref mut b, _) => b //~ ERROR cannot borrow - | ^^^^^^^^^ second mutable borrow occurs here -... -LL | *a += 1; - | ------- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr b/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr index 9c36a9fe875f5..43c74988f9ea5 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr @@ -7,8 +7,8 @@ LL | Y(ref mut a, _) => a LL | Y(ref mut b, _) => b //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *a += 1; + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr deleted file mode 100644 index 15859040f060a..0000000000000 --- a/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-tuple.rs:27:10 - | -LL | (ref mut a, _) => a - | --------- first mutable borrow occurs here -... -LL | (ref mut b, _) => b //~ ERROR cannot borrow - | ^^^^^^^^^ second mutable borrow occurs here -... -LL | *a += 1; - | ------- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr b/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr index 4b823f396afc5..15859040f060a 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr @@ -7,8 +7,8 @@ LL | (ref mut a, _) => a LL | (ref mut b, _) => b //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *a += 1; + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr deleted file mode 100644 index 2f4cf7dd800e1..0000000000000 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -warning[E0503]: cannot use `y` because it was mutably borrowed - --> $DIR/borrowck-anon-fields-variant.rs:17:7 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here -... -LL | Foo::Y(_, ref mut b) => b, - | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` -... -LL | *a += 1; - | ------- borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error[E0503]: cannot use `y` because it was mutably borrowed - --> $DIR/borrowck-anon-fields-variant.rs:34:7 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here -... -LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` -... -LL | *a += 1; - | ------- borrow later used here - -error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-variant.rs:34:14 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- first mutable borrow occurs here -... -LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow - | ^^^^^^^^^ second mutable borrow occurs here -... -LL | *a += 1; - | ------- first borrow later used here - -error: aborting due to 2 previous errors - -Some errors occurred: E0499, E0503. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.rs b/src/test/ui/borrowck/borrowck-anon-fields-variant.rs index c27435608c4a4..695809f58c551 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.rs +++ b/src/test/ui/borrowck/borrowck-anon-fields-variant.rs @@ -1,6 +1,3 @@ -// Tests that we are able to distinguish when loans borrow different -// anonymous fields of an enum variant vs the same anonymous field. - enum Foo { X, Y(usize, usize) } @@ -13,8 +10,14 @@ fn distinct_variant() { Foo::X => panic!() }; + // While `a` and `b` are disjoint, borrowck doesn't know that `a` is not + // also used for the discriminant of `Foo`, which it would be if `a` was a + // reference. let b = match y { Foo::Y(_, ref mut b) => b, + //~^ WARNING cannot use `y` + //~| WARNING this error has been downgraded to a warning + //~| WARNING this warning will become a hard error in the future Foo::X => panic!() }; @@ -31,7 +34,8 @@ fn same_variant() { }; let b = match y { - Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow + Foo::Y(ref mut b, _) => b, //~ ERROR cannot use `y` + //~| ERROR cannot borrow `y.0` as mutable Foo::X => panic!() }; diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr b/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr index 1e94cdebaec6a..0903f6350b7ae 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr @@ -1,15 +1,43 @@ +warning[E0503]: cannot use `y` because it was mutably borrowed + --> $DIR/borrowck-anon-fields-variant.rs:17:7 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- borrow of `y.0` occurs here +... +LL | Foo::Y(_, ref mut b) => b, + | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` +... +LL | *a += 1; + | ------- borrow later used here + | + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + +error[E0503]: cannot use `y` because it was mutably borrowed + --> $DIR/borrowck-anon-fields-variant.rs:37:7 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- borrow of `y.0` occurs here +... +LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot use `y` + | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` +... +LL | *a += 1; + | ------- borrow later used here + error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-variant.rs:34:14 + --> $DIR/borrowck-anon-fields-variant.rs:37:14 | LL | Foo::Y(ref mut a, _) => a, | --------- first mutable borrow occurs here ... -LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow +LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot use `y` | ^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *a += 1; + | ------- first borrow later used here -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0499`. +Some errors occurred: E0499, E0503. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-argument.nll.stderr b/src/test/ui/borrowck/borrowck-argument.nll.stderr deleted file mode 100644 index 9e7f0930ee57d..0000000000000 --- a/src/test/ui/borrowck/borrowck-argument.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:10:5 - | -LL | fn func(arg: S) { - | --- help: consider changing this to be mutable: `mut arg` -LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument - | ^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:15:9 - | -LL | fn method(&self, arg: S) { - | --- help: consider changing this to be mutable: `mut arg` -LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument - | ^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:21:9 - | -LL | fn default(&self, arg: S) { - | --- help: consider changing this to be mutable: `mut arg` -LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument - | ^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:32:17 - | -LL | (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument - | --- ^^^ cannot borrow as mutable - | | - | help: consider changing this to be mutable: `mut arg` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-argument.rs b/src/test/ui/borrowck/borrowck-argument.rs index e1f1adec8380c..5d776d4fca475 100644 --- a/src/test/ui/borrowck/borrowck-argument.rs +++ b/src/test/ui/borrowck/borrowck-argument.rs @@ -7,18 +7,18 @@ impl S { } fn func(arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument + arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } impl S { fn method(&self, arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument + arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } } trait T { fn default(&self, arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument + arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } } @@ -29,5 +29,6 @@ fn main() { func(s); s.method(s); s.default(s); - (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument + (|arg: S| { arg.mutate() })(s); + //~^ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/borrowck/borrowck-argument.stderr b/src/test/ui/borrowck/borrowck-argument.stderr index fa82b1c00cc7f..94e1775c1aaee 100644 --- a/src/test/ui/borrowck/borrowck-argument.stderr +++ b/src/test/ui/borrowck/borrowck-argument.stderr @@ -1,34 +1,34 @@ -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:10:5 | LL | fn func(arg: S) { - | --- help: make this binding mutable: `mut arg` -LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument - | ^^^ cannot borrow mutably + | --- help: consider changing this to be mutable: `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable + | ^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:15:9 | LL | fn method(&self, arg: S) { - | --- help: make this binding mutable: `mut arg` -LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument - | ^^^ cannot borrow mutably + | --- help: consider changing this to be mutable: `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable + | ^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:21:9 | LL | fn default(&self, arg: S) { - | --- help: make this binding mutable: `mut arg` -LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument - | ^^^ cannot borrow mutably + | --- help: consider changing this to be mutable: `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable + | ^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:32:17 | -LL | (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument - | --- ^^^ cannot borrow mutably +LL | (|arg: S| { arg.mutate() })(s); + | --- ^^^ cannot borrow as mutable | | - | help: make this binding mutable: `mut arg` + | help: consider changing this to be mutable: `mut arg` error: aborting due to 4 previous errors diff --git a/src/test/ui/borrowck/borrowck-asm.ast.stderr b/src/test/ui/borrowck/borrowck-asm.ast.stderr deleted file mode 100644 index 73eb08b59b069..0000000000000 --- a/src/test/ui/borrowck/borrowck-asm.ast.stderr +++ /dev/null @@ -1,76 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:27:13 - | -LL | asm!("nop" : : "r"(x)); - | - value moved here -LL | } -LL | let z = x; //[ast]~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-asm.rs:35:32 - | -LL | let y = &mut x; - | - borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use - | ^ use of borrowed `x` - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:44:31 - | -LL | let x = 3; - | - first assignment to `x` -LL | unsafe { -LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - | ^ cannot assign twice to immutable variable - -error[E0506]: cannot assign to `a` because it is borrowed - --> $DIR/borrowck-asm.rs:50:31 - | -LL | let b = &*a; - | -- borrow of `a` occurs here -LL | unsafe { -LL | asm!("nop" : "=r"(a)); //[ast]~ ERROR cannot assign to `a` because it is borrowed - | ^ assignment to borrowed `a` occurs here - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:60:31 - | -LL | let x = 3; - | - first assignment to `x` -LL | unsafe { -LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - | ^ cannot assign twice to immutable variable - -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:68:32 - | -LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable - | ^ use of possibly uninitialized `x` - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:77:31 - | -LL | let y = &*x; - | -- borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - | ^ assignment to borrowed `x` occurs here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:86:40 - | -LL | asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait - -error: aborting due to 8 previous errors - -Some errors occurred: E0381, E0382, E0384, E0503, E0506. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-asm.mir.stderr b/src/test/ui/borrowck/borrowck-asm.mir.stderr deleted file mode 100644 index 86e4832b3873c..0000000000000 --- a/src/test/ui/borrowck/borrowck-asm.mir.stderr +++ /dev/null @@ -1,81 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:27:17 - | -LL | let x = &mut 0isize; - | - move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait -LL | unsafe { -LL | asm!("nop" : : "r"(x)); - | - value moved here -LL | } -LL | let z = x; //[ast]~ ERROR use of moved value: `x` - | ^ value used here after move - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-asm.rs:35:32 - | -LL | let y = &mut x; - | ------ borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use - | ^ use of borrowed `x` -... -LL | let z = y; - | - borrow later used here - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:44:31 - | -LL | let x = 3; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | unsafe { -LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - | ^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:60:31 - | -LL | let x = 3; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | unsafe { -LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - | ^ cannot assign twice to immutable variable - -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:68:32 - | -LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable - | ^ use of possibly uninitialized `x` - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:77:31 - | -LL | let y = &*x; - | --- borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - | ^ assignment to borrowed `x` occurs here -... -LL | let z = y; - | - borrow later used here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:86:40 - | -LL | let x = &mut 2; - | - move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait -LL | unsafe { -LL | asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value - | - ^ value used here after move - | | - | value moved here - -error: aborting due to 7 previous errors - -Some errors occurred: E0381, E0382, E0384, E0503, E0506. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-asm.rs b/src/test/ui/borrowck/borrowck-asm.rs index 560c87c8d7220..9c9cc04baafee 100644 --- a/src/test/ui/borrowck/borrowck-asm.rs +++ b/src/test/ui/borrowck/borrowck-asm.rs @@ -6,9 +6,6 @@ // ignore-sparc // ignore-sparc64 -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] #[cfg(any(target_arch = "x86", @@ -24,16 +21,14 @@ mod test_cases { unsafe { asm!("nop" : : "r"(x)); } - let z = x; //[ast]~ ERROR use of moved value: `x` - //[mir]~^ ERROR use of moved value: `x` + let z = x; //~ ERROR use of moved value: `x` } fn in_is_read() { let mut x = 3; let y = &mut x; unsafe { - asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use - //[mir]~^ ERROR cannot use + asm!("nop" : : "r"(x)); //~ ERROR cannot use } let z = y; } @@ -41,14 +36,12 @@ mod test_cases { fn out_is_assign() { let x = 3; unsafe { - asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - //[mir]~^ ERROR cannot assign twice + asm!("nop" : "=r"(x)); //~ ERROR cannot assign twice } let mut a = &mut 3; let b = &*a; unsafe { - asm!("nop" : "=r"(a)); //[ast]~ ERROR cannot assign to `a` because it is borrowed - // No MIR error, this is a shallow write. + asm!("nop" : "=r"(a)); // OK, Shallow write to `a` } let c = b; let d = *a; @@ -57,16 +50,14 @@ mod test_cases { fn rw_is_assign() { let x = 3; unsafe { - asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - //[mir]~^ ERROR cannot assign twice + asm!("nop" : "+r"(x)); //~ ERROR cannot assign twice } } fn indirect_is_not_init() { let x: i32; unsafe { - asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable - //[mir]~^ ERROR use of possibly uninitialized variable + asm!("nop" : "=*r"(x)); //~ ERROR use of possibly uninitialized variable } } @@ -74,8 +65,7 @@ mod test_cases { let mut x = &mut 3; let y = &*x; unsafe { - asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + asm!("nop" : "+r"(x)); //~ ERROR cannot assign to `x` because it is borrowed } let z = y; } @@ -83,8 +73,7 @@ mod test_cases { fn two_moves() { let x = &mut 2; unsafe { - asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value - //[mir]~^ ERROR use of moved value + asm!("nop" : : "r"(x), "r"(x) ); //~ ERROR use of moved value } } } diff --git a/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr b/src/test/ui/borrowck/borrowck-asm.stderr similarity index 74% rename from src/test/ui/borrowck/borrowck-asm.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-asm.stderr index 86e4832b3873c..3720f90b61f58 100644 --- a/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-asm.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:27:17 + --> $DIR/borrowck-asm.rs:24:17 | LL | let x = &mut 0isize; | - move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait @@ -7,23 +7,23 @@ LL | unsafe { LL | asm!("nop" : : "r"(x)); | - value moved here LL | } -LL | let z = x; //[ast]~ ERROR use of moved value: `x` +LL | let z = x; //~ ERROR use of moved value: `x` | ^ value used here after move error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-asm.rs:35:32 + --> $DIR/borrowck-asm.rs:31:32 | LL | let y = &mut x; | ------ borrow of `x` occurs here LL | unsafe { -LL | asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use +LL | asm!("nop" : : "r"(x)); //~ ERROR cannot use | ^ use of borrowed `x` -... +LL | } LL | let z = y; | - borrow later used here error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:44:31 + --> $DIR/borrowck-asm.rs:39:31 | LL | let x = 3; | - @@ -31,11 +31,11 @@ LL | let x = 3; | first assignment to `x` | help: make this binding mutable: `mut x` LL | unsafe { -LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice +LL | asm!("nop" : "=r"(x)); //~ ERROR cannot assign twice | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:60:31 + --> $DIR/borrowck-asm.rs:53:31 | LL | let x = 3; | - @@ -43,34 +43,34 @@ LL | let x = 3; | first assignment to `x` | help: make this binding mutable: `mut x` LL | unsafe { -LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice +LL | asm!("nop" : "+r"(x)); //~ ERROR cannot assign twice | ^ cannot assign twice to immutable variable error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:68:32 + --> $DIR/borrowck-asm.rs:60:32 | -LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable +LL | asm!("nop" : "=*r"(x)); //~ ERROR use of possibly uninitialized variable | ^ use of possibly uninitialized `x` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:77:31 + --> $DIR/borrowck-asm.rs:68:31 | LL | let y = &*x; | --- borrow of `x` occurs here LL | unsafe { -LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed +LL | asm!("nop" : "+r"(x)); //~ ERROR cannot assign to `x` because it is borrowed | ^ assignment to borrowed `x` occurs here -... +LL | } LL | let z = y; | - borrow later used here error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:86:40 + --> $DIR/borrowck-asm.rs:76:40 | LL | let x = &mut 2; | - move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait LL | unsafe { -LL | asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value +LL | asm!("nop" : : "r"(x), "r"(x) ); //~ ERROR use of moved value | - ^ value used here after move | | | value moved here diff --git a/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr b/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr deleted file mode 100644 index 71f36c2b045a8..0000000000000 --- a/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-assign-comp-idx.rs:12:5 - | -LL | let q: &isize = &p[0]; - | - immutable borrow occurs here -LL | -LL | p[0] = 5; //~ ERROR cannot borrow - | ^ mutable borrow occurs here -LL | -LL | println!("{}", *q); - | -- immutable borrow later used here - -error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-assign-comp-idx.rs:27:9 - | -LL | borrow( - | ------ immutable borrow later used by call -LL | &p, - | -- immutable borrow occurs here -LL | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable - | ^^ - second borrow occurs due to use of `p` in closure - | | - | mutable borrow occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr b/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr index 9997aa4190e3f..71f36c2b045a8 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr +++ b/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr @@ -6,19 +6,20 @@ LL | let q: &isize = &p[0]; LL | LL | p[0] = 5; //~ ERROR cannot borrow | ^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here +LL | +LL | println!("{}", *q); + | -- immutable borrow later used here error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable --> $DIR/borrowck-assign-comp-idx.rs:27:9 | +LL | borrow( + | ------ immutable borrow later used by call LL | &p, - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable - | ^^ - - immutable borrow ends here - | | | - | | borrow occurs due to use of `p` in closure + | ^^ - second borrow occurs due to use of `p` in closure + | | | mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-assign-comp.ast.stderr b/src/test/ui/borrowck/borrowck-assign-comp.ast.stderr deleted file mode 100644 index 735c168d7df10..0000000000000 --- a/src/test/ui/borrowck/borrowck-assign-comp.ast.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0506]: cannot assign to `p.x` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:13:5 - | -LL | let q = &p; - | - borrow of `p.x` occurs here -... -LL | p.x = 5; //[ast]~ ERROR cannot assign to `p.x` - | ^^^^^^^ assignment to borrowed `p.x` occurs here - -error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:24:5 - | -LL | let q = &p.y; - | --- borrow of `p` occurs here -LL | p = Point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here - -error[E0506]: cannot assign to `p.y` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:36:5 - | -LL | let q = &p.y; - | --- borrow of `p.y` occurs here -LL | p.y = 5; //[ast]~ ERROR cannot assign to `p.y` - | ^^^^^^^ assignment to borrowed `p.y` occurs here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-assign-comp.mir.stderr b/src/test/ui/borrowck/borrowck-assign-comp.mir.stderr deleted file mode 100644 index c204248d81a27..0000000000000 --- a/src/test/ui/borrowck/borrowck-assign-comp.mir.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0506]: cannot assign to `p.x` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:13:5 - | -LL | let q = &p; - | -- borrow of `p.x` occurs here -... -LL | p.x = 5; //[ast]~ ERROR cannot assign to `p.x` - | ^^^^^^^ assignment to borrowed `p.x` occurs here -LL | //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed -LL | q.x; - | --- borrow later used here - -error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:24:5 - | -LL | let q = &p.y; - | ---- borrow of `p` occurs here -LL | p = Point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here -... -LL | *q; // stretch loan - | -- borrow later used here - -error[E0506]: cannot assign to `p.y` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:36:5 - | -LL | let q = &p.y; - | ---- borrow of `p.y` occurs here -LL | p.y = 5; //[ast]~ ERROR cannot assign to `p.y` - | ^^^^^^^ assignment to borrowed `p.y` occurs here -LL | //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed -LL | *q; - | -- borrow later used here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-assign-comp.rs b/src/test/ui/borrowck/borrowck-assign-comp.rs index 0cacc3882d800..98bb2d85ad7c1 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp.rs +++ b/src/test/ui/borrowck/borrowck-assign-comp.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct Point { x: isize, y: isize } fn a() { @@ -10,8 +7,7 @@ fn a() { // This assignment is illegal because the field x is not // inherently mutable; since `p` was made immutable, `p.x` is now // immutable. Otherwise the type of &_q.x (&isize) would be wrong. - p.x = 5; //[ast]~ ERROR cannot assign to `p.x` - //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed + p.x = 5; //~ ERROR cannot assign to `p.x` because it is borrowed q.x; } @@ -21,8 +17,7 @@ fn c() { let mut p = Point {x: 3, y: 4}; let q = &p.y; - p = Point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` - //[mir]~^ ERROR cannot assign to `p` because it is borrowed + p = Point {x: 5, y: 7};//~ ERROR cannot assign to `p` because it is borrowed p.x; // silence warning *q; // stretch loan } @@ -33,8 +28,7 @@ fn d() { let mut p = Point {x: 3, y: 4}; let q = &p.y; - p.y = 5; //[ast]~ ERROR cannot assign to `p.y` - //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed + p.y = 5; //~ ERROR cannot assign to `p.y` because it is borrowed *q; } diff --git a/src/test/ui/borrowck/borrowck-assign-comp.ast.nll.stderr b/src/test/ui/borrowck/borrowck-assign-comp.stderr similarity index 65% rename from src/test/ui/borrowck/borrowck-assign-comp.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-assign-comp.stderr index c204248d81a27..725fa057c026b 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-assign-comp.stderr @@ -1,34 +1,32 @@ error[E0506]: cannot assign to `p.x` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:13:5 + --> $DIR/borrowck-assign-comp.rs:10:5 | LL | let q = &p; | -- borrow of `p.x` occurs here ... -LL | p.x = 5; //[ast]~ ERROR cannot assign to `p.x` +LL | p.x = 5; //~ ERROR cannot assign to `p.x` because it is borrowed | ^^^^^^^ assignment to borrowed `p.x` occurs here -LL | //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed LL | q.x; | --- borrow later used here error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:24:5 + --> $DIR/borrowck-assign-comp.rs:20:5 | LL | let q = &p.y; | ---- borrow of `p` occurs here -LL | p = Point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` +LL | p = Point {x: 5, y: 7};//~ ERROR cannot assign to `p` because it is borrowed | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here -... +LL | p.x; // silence warning LL | *q; // stretch loan | -- borrow later used here error[E0506]: cannot assign to `p.y` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:36:5 + --> $DIR/borrowck-assign-comp.rs:31:5 | LL | let q = &p.y; | ---- borrow of `p.y` occurs here -LL | p.y = 5; //[ast]~ ERROR cannot assign to `p.y` +LL | p.y = 5; //~ ERROR cannot assign to `p.y` because it is borrowed | ^^^^^^^ assignment to borrowed `p.y` occurs here -LL | //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed LL | *q; | -- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr deleted file mode 100644 index 469199d69b91e..0000000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference - --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5 - | -LL | fn a(s: &S) { - | -- help: consider changing this to be a mutable reference: `&mut S<'_>` -LL | *s.pointer += 1; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference - --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 - | -LL | fn c(s: & &mut S) { - | -------- help: consider changing this to be a mutable reference: `&mut &mut S<'_>` -LL | *s.pointer += 1; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr index 76e7ee841f827..469199d69b91e 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr +++ b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr @@ -1,19 +1,19 @@ -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5 | LL | fn a(s: &S) { - | -- use `&mut S` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut S<'_>` LL | *s.pointer += 1; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^ assignment into an immutable reference + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 | LL | fn c(s: & &mut S) { - | -------- use `&mut &mut S` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&mut &mut S<'_>` LL | *s.pointer += 1; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^ assignment into an immutable reference + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr deleted file mode 100644 index 8e3e9d41f8c0e..0000000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed - --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here -LL | *y.pointer += 1; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^ use of borrowed `y` -LL | *z.pointer += 1; - | --------------- borrow later used here - -error[E0506]: cannot assign to `*y.pointer` because it is borrowed - --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here -LL | *z.pointer += 1; - | --------------- borrow later used here - -error: aborting due to 2 previous errors - -Some errors occurred: E0503, E0506. -For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs index 98080d47c647b..f7aee2b8a939a 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs +++ b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs @@ -15,7 +15,9 @@ fn main() { { let mut y = S { pointer: &mut x }; let z = copy_borrowed_ptr(&mut y); - *y.pointer += 1; //~ ERROR cannot assign + *y.pointer += 1; + //~^ ERROR cannot use `*y.pointer` + //~| ERROR cannot assign to `*y.pointer` *z.pointer += 1; } } diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr index d4639581223de..96a559f49f0f7 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr +++ b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr @@ -1,11 +1,26 @@ +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed + --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 + | +LL | let z = copy_borrowed_ptr(&mut y); + | ------ borrow of `y` occurs here +LL | *y.pointer += 1; + | ^^^^^^^^^^^^^^^ use of borrowed `y` +... +LL | *z.pointer += 1; + | --------------- borrow later used here + error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 | LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; //~ ERROR cannot assign + | ------ borrow of `*y.pointer` occurs here +LL | *y.pointer += 1; | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here +... +LL | *z.pointer += 1; + | --------------- borrow later used here -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0506`. +Some errors occurred: E0503, E0506. +For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.ast.stderr deleted file mode 100644 index 4111f55d9f2b2..0000000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0594]: cannot assign to immutable static item - --> $DIR/borrowck-assign-to-constants.rs:8:5 - | -LL | foo = 6; //[ast]~ ERROR cannot assign to immutable static item - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.mir.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.mir.stderr deleted file mode 100644 index 0a30a490a643b..0000000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0594]: cannot assign to immutable static item `foo` - --> $DIR/borrowck-assign-to-constants.rs:8:5 - | -LL | foo = 6; //[ast]~ ERROR cannot assign to immutable static item - | ^^^^^^^ cannot assign - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.rs b/src/test/ui/borrowck/borrowck-assign-to-constants.rs index 768b2a5f7438e..5881dccf61ab3 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.rs +++ b/src/test/ui/borrowck/borrowck-assign-to-constants.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static foo: isize = 5; fn main() { // assigning to various global constants - foo = 6; //[ast]~ ERROR cannot assign to immutable static item - //[mir]~^ ERROR cannot assign to immutable static item `foo` + foo = 6; //~ ERROR cannot assign to immutable static item `foo` } diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.nll.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.stderr similarity index 62% rename from src/test/ui/borrowck/borrowck-assign-to-constants.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-assign-to-constants.stderr index 0a30a490a643b..87c28da120f44 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-assign-to-constants.stderr @@ -1,7 +1,7 @@ error[E0594]: cannot assign to immutable static item `foo` - --> $DIR/borrowck-assign-to-constants.rs:8:5 + --> $DIR/borrowck-assign-to-constants.rs:5:5 | -LL | foo = 6; //[ast]~ ERROR cannot assign to immutable static item +LL | foo = 6; //~ ERROR cannot assign to immutable static item `foo` | ^^^^^^^ cannot assign error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr b/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr deleted file mode 100644 index 53aaa4a2957e9..0000000000000 --- a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:15:5 - | -LL | let x = Foo { x: 3 }; - | - help: consider changing this to be mutable: `mut x` -LL | x.printme(); //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr b/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr index b48473a884c2f..53aaa4a2957e9 100644 --- a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr +++ b/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:15:5 | LL | let x = Foo { x: 3 }; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.printme(); //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr b/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr deleted file mode 100644 index 9e62534c6718a..0000000000000 --- a/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-autoref-3261.rs:15:9 - | -LL | (&mut x).with( - | -------- ---- first borrow later used by call - | | - | first mutable borrow occurs here -LL | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time - | ^^^^^ second mutable borrow occurs here -... -LL | x = X(Either::Left((0, 0))); - | - second borrow occurs due to use of `x` in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-autoref-3261.stderr b/src/test/ui/borrowck/borrowck-autoref-3261.stderr index 7a5430ac15c37..9e62534c6718a 100644 --- a/src/test/ui/borrowck/borrowck-autoref-3261.stderr +++ b/src/test/ui/borrowck/borrowck-autoref-3261.stderr @@ -2,15 +2,14 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-autoref-3261.rs:15:9 | LL | (&mut x).with( - | - first mutable borrow occurs here + | -------- ---- first borrow later used by call + | | + | first mutable borrow occurs here LL | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time | ^^^^^ second mutable borrow occurs here ... LL | x = X(Either::Left((0, 0))); - | - borrow occurs due to use of `x` in closure -... -LL | }) - | - first borrow ends here + | - second borrow occurs due to use of `x` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr deleted file mode 100644 index 1732628d40f83..0000000000000 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:25:17 - | -LL | add( - | --- immutable borrow later used by call -LL | &*a, - | --- immutable borrow occurs here -LL | rewrite(&mut a)); //~ ERROR cannot borrow - | ^^^^^^ mutable borrow occurs here - -error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:32:17 - | -LL | add( - | --- immutable borrow later used by call -LL | &*a, - | --- immutable borrow occurs here -LL | rewrite(&mut a)); //~ ERROR cannot borrow - | ^^^^^^ mutable borrow occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr index 165530d270af9..1732628d40f83 100644 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr +++ b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr @@ -1,22 +1,22 @@ -error[E0502]: cannot borrow `a` as mutable because `*a` is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:25:22 +error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:25:17 | +LL | add( + | --- immutable borrow later used by call LL | &*a, - | -- immutable borrow occurs here + | --- immutable borrow occurs here LL | rewrite(&mut a)); //~ ERROR cannot borrow - | ^ - immutable borrow ends here - | | - | mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here -error[E0502]: cannot borrow `a` as mutable because `*a` is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:32:22 +error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:32:17 | +LL | add( + | --- immutable borrow later used by call LL | &*a, - | -- immutable borrow occurs here + | --- immutable borrow occurs here LL | rewrite(&mut a)); //~ ERROR cannot borrow - | ^ - immutable borrow ends here - | | - | mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr deleted file mode 100644 index 117567cba192b..0000000000000 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/borrowck-bad-nested-calls-move.rs:25:9 - | -LL | add( - | --- borrow later used by call -LL | &*a, - | --- borrow of `*a` occurs here -LL | a); //~ ERROR cannot move - | ^ move out of `a` occurs here - -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/borrowck-bad-nested-calls-move.rs:32:9 - | -LL | add( - | --- borrow later used by call -LL | &*a, - | --- borrow of `*a` occurs here -LL | a); //~ ERROR cannot move - | ^ move out of `a` occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr index b2c680f39521e..117567cba192b 100644 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr +++ b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr @@ -1,16 +1,20 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:25:9 | +LL | add( + | --- borrow later used by call LL | &*a, - | -- borrow of `*a` occurs here + | --- borrow of `*a` occurs here LL | a); //~ ERROR cannot move | ^ move out of `a` occurs here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:32:9 | +LL | add( + | --- borrow later used by call LL | &*a, - | -- borrow of `*a` occurs here + | --- borrow of `*a` occurs here LL | a); //~ ERROR cannot move | ^ move out of `a` occurs here diff --git a/src/test/ui/borrowck/borrowck-block-unint.nll.stderr b/src/test/ui/borrowck/borrowck-block-unint.nll.stderr deleted file mode 100644 index ea17fafc93908..0000000000000 --- a/src/test/ui/borrowck/borrowck-block-unint.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-block-unint.rs:4:11 - | -LL | force(|| { //~ ERROR capture of possibly uninitialized variable: `x` - | ^^ use of possibly uninitialized `x` -LL | println!("{}", x); - | - borrow occurs due to use in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-block-unint.rs b/src/test/ui/borrowck/borrowck-block-unint.rs index 3c6e9cb5578b4..1fed2d503bd35 100644 --- a/src/test/ui/borrowck/borrowck-block-unint.rs +++ b/src/test/ui/borrowck/borrowck-block-unint.rs @@ -1,7 +1,7 @@ fn force(f: F) where F: FnOnce() { f(); } fn main() { let x: isize; - force(|| { //~ ERROR capture of possibly uninitialized variable: `x` + force(|| { //~ ERROR borrow of possibly uninitialized variable: `x` println!("{}", x); }); } diff --git a/src/test/ui/borrowck/borrowck-block-unint.stderr b/src/test/ui/borrowck/borrowck-block-unint.stderr index 6e7af76fc2e89..d29b08f887261 100644 --- a/src/test/ui/borrowck/borrowck-block-unint.stderr +++ b/src/test/ui/borrowck/borrowck-block-unint.stderr @@ -1,8 +1,10 @@ -error[E0381]: capture of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-block-unint.rs:4:11 | -LL | force(|| { //~ ERROR capture of possibly uninitialized variable: `x` +LL | force(|| { //~ ERROR borrow of possibly uninitialized variable: `x` | ^^ use of possibly uninitialized `x` +LL | println!("{}", x); + | - borrow occurs due to use in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr deleted file mode 100644 index d1377fd439a4f..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:18:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:25:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:32:17 - | -LL | let bar1 = &foo.bar1; - | --------- immutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:62:21 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | match *foo { -LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} - | ^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:71:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^ immutable borrow occurs here -LL | let _foo2 = &*foo; //~ ERROR cannot borrow -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:72:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow -LL | let _foo2 = &*foo; //~ ERROR cannot borrow - | ^^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:79:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:86:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:93:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:100:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:121:16 - | -LL | let foo = make_foo(); - | --- help: consider changing this to be mutable: `mut foo` -LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error: aborting due to 11 previous errors - -Some errors occurred: E0499, E0502, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs index 1435837bf3bae..353e4e9f75e6c 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs +++ b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs @@ -43,15 +43,17 @@ fn borrow_same_field_twice_imm_imm() { fn borrow_both_fields_mut() { let mut foo = make_foo(); let bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar2; //~ ERROR cannot borrow + let _bar2 = &mut foo.bar2; *bar1; } fn borrow_both_mut_pattern() { let mut foo = make_foo(); match *foo { - Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} - //~^ ERROR cannot borrow + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => { + *_bar1; + *_bar2; + } } } @@ -112,8 +114,7 @@ fn borrow_imm_and_base_imm() { fn borrow_mut_and_imm() { let mut foo = make_foo(); let bar1 = &mut foo.bar1; - let _foo1 = &foo.bar2; //~ ERROR cannot borrow - *bar1; + let _foo1 = &foo.bar2; } fn borrow_mut_from_imm() { @@ -125,7 +126,7 @@ fn borrow_mut_from_imm() { fn borrow_long_path_both_mut() { let mut foo = make_foo(); let bar1 = &mut foo.bar1.int1; - let foo1 = &mut foo.bar2.int2; //~ ERROR cannot borrow + let foo1 = &mut foo.bar2.int2; *bar1; *foo1; } diff --git a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr index e116cb70c1c31..50d75af68bf25 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr @@ -1,168 +1,116 @@ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:18:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:18:17 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:25:18 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:25:17 | LL | let bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here + | ------------- mutable borrow occurs here LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ immutable borrow occurs here + | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:32:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:32:17 | LL | let bar1 = &foo.bar1; - | -------- immutable borrow occurs here + | --------- immutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here - -error[E0499]: cannot borrow `foo` (via `foo.bar2`) as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:46:22 - | -LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here (via `foo.bar1`) -LL | let _bar2 = &mut foo.bar2; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`) -LL | *bar1; -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `foo` (via `foo.bar2`) as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:53:42 - | -LL | Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} - | ------------- ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`) - | | - | first mutable borrow occurs here (via `foo.bar1`) -LL | //~^ ERROR cannot borrow -LL | } - | - first borrow ends here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:62:21 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:64:21 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | match *foo { LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} | ^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *bar1; + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:71:18 +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:73:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &*foo; //~ ERROR cannot borrow +LL | *bar1; + | ----- mutable borrow later used here -error[E0502]: cannot borrow `*foo` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:72:18 +error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:74:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow LL | let _foo2 = &*foo; //~ ERROR cannot borrow - | ^^^^ immutable borrow occurs here + | ^^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:79:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:81:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:86:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:88:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^ second mutable borrow occurs here + | ^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:93:22 +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:95:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0502]: cannot borrow `*foo` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:100:22 +error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:102:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^ mutable borrow occurs here -LL | *bar1; -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `foo` (via `foo.bar2`) as immutable because `foo` is also borrowed as mutable (via `foo.bar1`) - --> $DIR/borrowck-borrow-from-owned-ptr.rs:115:18 - | -LL | let bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here (via `foo.bar1`) -LL | let _foo1 = &foo.bar2; //~ ERROR cannot borrow - | ^^^^^^^^ immutable borrow of `foo.bar2` -- which overlaps with `foo.bar1` -- occurs here + | ^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- immutable borrow later used here -error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:121:21 +error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:122:16 | LL | let foo = make_foo(); - | --- help: make this binding mutable: `mut foo` + | --- help: consider changing this to be mutable: `mut foo` LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0499]: cannot borrow `foo` (via `foo.bar2.int2`) as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:128:21 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here (via `foo.bar1.int1`) -LL | let foo1 = &mut foo.bar2.int2; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2.int2`) -... -LL | } - | - first borrow ends here + | ^^^^^^^^^^^^^ cannot borrow as mutable -error: aborting due to 15 previous errors +error: aborting due to 11 previous errors Some errors occurred: E0499, E0502, E0596. For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr deleted file mode 100644 index f53cb32a5679e..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:18:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:25:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:32:17 - | -LL | let bar1 = &foo.bar1; - | --------- immutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:61:21 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | match foo { -LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} // - | ^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:70:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^ immutable borrow occurs here -LL | let _foo2 = &foo; //~ ERROR cannot borrow -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:71:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow -LL | let _foo2 = &foo; //~ ERROR cannot borrow - | ^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:78:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:85:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo2 = &mut foo; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:92:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:99:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo2 = &mut foo; //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:120:16 - | -LL | let foo = make_foo(); - | --- help: consider changing this to be mutable: `mut foo` -LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error: aborting due to 11 previous errors - -Some errors occurred: E0499, E0502, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr index 2c446dfee44b2..f53cb32a5679e 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr @@ -1,122 +1,114 @@ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:18:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:18:17 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:25:18 + --> $DIR/borrowck-borrow-from-stack-variable.rs:25:17 | LL | let bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here + | ------------- mutable borrow occurs here LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ immutable borrow occurs here + | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:32:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:32:17 | LL | let bar1 = &foo.bar1; - | -------- immutable borrow occurs here + | --------- immutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:61:21 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | match foo { LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} // | ^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *bar1; + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:70:18 +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:70:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &foo; //~ ERROR cannot borrow +LL | *bar1; + | ----- mutable borrow later used here -error[E0502]: cannot borrow `foo` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:71:18 +error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:71:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow LL | let _foo2 = &foo; //~ ERROR cannot borrow - | ^^^ immutable borrow occurs here + | ^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:78:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:78:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:85:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:85:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo2 = &mut foo; //~ ERROR cannot borrow - | ^^^ second mutable borrow occurs here + | ^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:92:22 +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:92:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0502]: cannot borrow `foo` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:99:22 +error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:99:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo2 = &mut foo; //~ ERROR cannot borrow - | ^^^ mutable borrow occurs here + | ^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:120:21 +error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:120:16 | LL | let foo = make_foo(); - | --- help: make this binding mutable: `mut foo` + | --- help: consider changing this to be mutable: `mut foo` LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^ cannot borrow as mutable error: aborting due to 11 previous errors diff --git a/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr deleted file mode 100644 index 52bc3e9829674..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/borrowck-borrow-from-temporary.rs:10:5 - | -LL | let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough - | ---------- temporary value created here -LL | x - | ^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs b/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs index e7ca1a90f8c93..92f3ffd57a17d 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs +++ b/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs @@ -6,8 +6,8 @@ fn id(x: T) -> T { x } struct Foo(isize); fn foo<'a>() -> &'a isize { - let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough - x + let &Foo(ref x) = &id(Foo(3)); + x //~ ERROR cannot return value referencing temporary value } pub fn main() { diff --git a/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr b/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr index 0726e3d5d5e60..61d42a54543ba 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr @@ -1,18 +1,11 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-borrow-from-temporary.rs:9:24 +error[E0515]: cannot return value referencing temporary value + --> $DIR/borrowck-borrow-from-temporary.rs:10:5 | -LL | let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^ temporary value does not live long enough -LL | x -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 8:8... - --> $DIR/borrowck-borrow-from-temporary.rs:8:8 - | -LL | fn foo<'a>() -> &'a isize { - | ^^ +LL | let &Foo(ref x) = &id(Foo(3)); + | ---------- temporary value created here +LL | x //~ ERROR cannot return value referencing temporary value + | ^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr deleted file mode 100644 index 7d7e305a31f31..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable - --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5 - | -LL | let a: Box<_> = box A; - | - help: consider changing this to be mutable: `mut a` -LL | a.foo(); - | ^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs index 8d528182c0d35..bc820ee9f9141 100644 --- a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs +++ b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs @@ -10,5 +10,5 @@ impl A { pub fn main() { let a: Box<_> = box A; a.foo(); - //~^ ERROR cannot borrow immutable `Box` content `*a` as mutable + //~^ ERROR cannot borrow `*a` as mutable, as `a` is not declared as mutable [E0596] } diff --git a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr index 2c989b2957617..7d7e305a31f31 100644 --- a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow immutable `Box` content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5 | LL | let a: Box<_> = box A; - | - help: make this binding mutable: `mut a` + | - help: consider changing this to be mutable: `mut a` LL | a.foo(); | ^ cannot borrow as mutable diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr deleted file mode 100644 index 82b9449de5071..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0594]: cannot assign to `**t1` which is behind a `&` reference - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 - | -LL | let t1 = t0; - | -- help: consider changing this to be a mutable reference: `&mut &mut isize` -LL | let p: &isize = &**t0; -LL | **t1 = 22; //~ ERROR cannot assign - | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written - -error[E0502]: cannot borrow `**t0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:21 - | -LL | let t1 = &mut *t0; - | -------- mutable borrow occurs here -LL | let p: &isize = &**t0; //~ ERROR cannot borrow - | ^^^^^ immutable borrow occurs here -LL | **t1 = 22; - | --------- mutable borrow later used here - -error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:26 - | -LL | fn foo4(t0: & &mut isize) { - | ------------ help: consider changing this to be a mutable reference: `&mut &mut isize` -LL | let x: &mut isize = &mut **t0; //~ ERROR cannot borrow - | ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 3 previous errors - -Some errors occurred: E0502, E0594, E0596. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr index ff2969f53480c..82b9449de5071 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -1,29 +1,31 @@ -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `**t1` which is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 | +LL | let t1 = t0; + | -- help: consider changing this to be a mutable reference: `&mut &mut isize` +LL | let p: &isize = &**t0; LL | **t1 = 22; //~ ERROR cannot assign - | ^^^^^^^^^ assignment into an immutable reference + | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written -error[E0502]: cannot borrow `**t0` as immutable because `*t0` is also borrowed as mutable - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:22 +error[E0502]: cannot borrow `**t0` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:21 | LL | let t1 = &mut *t0; - | --- mutable borrow occurs here + | -------- mutable borrow occurs here LL | let p: &isize = &**t0; //~ ERROR cannot borrow - | ^^^^ immutable borrow occurs here + | ^^^^^ immutable borrow occurs here LL | **t1 = 22; -LL | } - | - mutable borrow ends here + | --------- mutable borrow later used here -error[E0389]: cannot borrow data mutably in a `&` reference - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:31 +error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:26 | LL | fn foo4(t0: & &mut isize) { - | ------------ use `&mut &mut isize` here to make mutable + | ------------ help: consider changing this to be a mutable reference: `&mut &mut isize` LL | let x: &mut isize = &mut **t0; //~ ERROR cannot borrow - | ^^^^ assignment into an immutable reference + | ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 3 previous errors -Some errors occurred: E0389, E0502. -For more information about an error, try `rustc --explain E0389`. +Some errors occurred: E0502, E0594, E0596. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr deleted file mode 100644 index c329fc9e91083..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/borrowck-borrow-mut-object-twice.rs:13:5 - | -LL | let y = x.f1(); - | - first mutable borrow occurs here -LL | x.f2(); //~ ERROR cannot borrow `*x` as mutable - | ^ second mutable borrow occurs here -LL | y.use_ref(); - | - first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr index abfce9857f7c1..c329fc9e91083 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr @@ -6,8 +6,7 @@ LL | let y = x.f1(); LL | x.f2(); //~ ERROR cannot borrow `*x` as mutable | ^ second mutable borrow occurs here LL | y.use_ref(); -LL | } - | - first borrow ends here + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr deleted file mode 100644 index ecb013b7a1603..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr +++ /dev/null @@ -1,88 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:47:19 - | -LL | let __isize = &mut x.y; //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:51:19 - | -LL | let __isize = &mut x.y; //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:59:5 - | -LL | &mut x.y //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:63:5 - | -LL | &mut x.y //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:67:5 - | -LL | x.y = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:71:5 - | -LL | x.y = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:75:5 - | -LL | x.y = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:83:5 - | -LL | x.set(0, 0); //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:87:5 - | -LL | x.set(0, 0); //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:95:5 - | -LL | x.y_mut() //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:99:5 - | -LL | x.y_mut() //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:103:6 - | -LL | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:107:6 - | -LL | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:111:6 - | -LL | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error: aborting due to 14 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr index c6f9c655a11dc..ecb013b7a1603 100644 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr @@ -1,82 +1,82 @@ -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:47:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:47:19 | LL | let __isize = &mut x.y; //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:51:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:51:19 | LL | let __isize = &mut x.y; //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:59:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:59:5 | LL | &mut x.y //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:63:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:63:5 | LL | &mut x.y //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:67:5 | LL | x.y = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:71:5 | LL | x.y = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:75:5 | LL | x.y = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:83:5 | LL | x.set(0, 0); //~ ERROR cannot borrow | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:87:5 | LL | x.set(0, 0); //~ ERROR cannot borrow | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:95:5 | LL | x.y_mut() //~ ERROR cannot borrow | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:99:5 | LL | x.y_mut() //~ ERROR cannot borrow | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:103:6 | LL | *x.y_mut() = 3; //~ ERROR cannot borrow | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:107:6 | LL | *x.y_mut() = 3; //~ ERROR cannot borrow | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:111:6 | LL | *x.y_mut() = 3; //~ ERROR cannot borrow diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.nll.stderr deleted file mode 100644 index 1c3131806be2d..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.nll.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:23:19 - | -LL | let __isize = &mut *x; //~ ERROR cannot borrow - | ^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:27:19 - | -LL | let __isize = &mut *x; //~ ERROR cannot borrow - | ^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:35:5 - | -LL | &mut **x //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:39:5 - | -LL | &mut **x //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref.rs:43:5 - | -LL | *x = 3; //~ ERROR cannot assign - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref.rs:47:5 - | -LL | **x = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref.rs:51:5 - | -LL | **x = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot assign - -error: aborting due to 7 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr index 41e7cc210c8f5..1c3131806be2d 100644 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr @@ -1,44 +1,44 @@ -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:23:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:23:19 | LL | let __isize = &mut *x; //~ ERROR cannot borrow - | ^^ cannot borrow as mutable + | ^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:27:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:27:19 | LL | let __isize = &mut *x; //~ ERROR cannot borrow - | ^^ cannot borrow as mutable + | ^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:35:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:35:5 | LL | &mut **x //~ ERROR cannot borrow - | ^^^ cannot borrow as mutable + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:39:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:39:5 | LL | &mut **x //~ ERROR cannot borrow - | ^^^ cannot borrow as mutable + | ^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-deref.rs:43:5 | LL | *x = 3; //~ ERROR cannot assign - | ^^^^^^ cannot borrow as mutable + | ^^^^^^ cannot assign -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-deref.rs:47:5 | LL | **x = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-deref.rs:51:5 | LL | **x = 3; //~ ERROR cannot assign - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ cannot assign error: aborting due to 7 previous errors diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr deleted file mode 100644 index 97dc59c954385..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:20:20 - | -LL | let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -LL | x.x[0]; - | ------ borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs index 6e943ffabe3e3..e384aacb71845 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs @@ -17,6 +17,6 @@ fn defer<'r>(x: &'r [&'r str]) -> Defer<'r> { } fn main() { - let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR borrowed value does not live long enough + let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR temporary value dropped while borrowed x.x[0]; } diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr index b94926951192a..610378c4759f9 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr @@ -1,17 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:20:20 | -LL | let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use LL | x.x[0]; -LL | } - | - temporary value needs to live until here + | ------ borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr deleted file mode 100644 index d6e599d1abf93..0000000000000 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-borrowed-uniq-rvalue.rs:10:28 - | -LL | buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | buggy_map.insert(43, &*tmp); - | --------- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs index 88bd106d6f35e..a78c66f47cd14 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; fn main() { let tmp: Box<_>; let mut buggy_map: HashMap = HashMap::new(); - buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough + buggy_map.insert(42, &*Box::new(1)); //~ ERROR temporary value dropped while borrowed // but it is ok if we use a temporary tmp = box 2; diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr index bf4674035ead2..1039c501767d1 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-borrowed-uniq-rvalue.rs:10:27 +error[E0716]: temporary value dropped while borrowed + --> $DIR/borrowck-borrowed-uniq-rvalue.rs:10:28 | -LL | buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^^ - borrowed value dropped here while still borrowed - | | - | borrowed value does not live long enough +LL | buggy_map.insert(42, &*Box::new(1)); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | + | creates a temporary which is freed while still in use ... -LL | } - | - borrowed value needs to live until here +LL | buggy_map.insert(43, &*tmp); + | --------- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.ast.stderr b/src/test/ui/borrowck/borrowck-box-insensitivity.ast.stderr deleted file mode 100644 index 236064da3e8b6..0000000000000 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.ast.stderr +++ /dev/null @@ -1,165 +0,0 @@ -error[E0382]: use of moved value: `a` - --> $DIR/borrowck-box-insensitivity.rs:37:9 - | -LL | let _x = a.x; - | -- value moved here -LL | //[ast]~^ value moved here -LL | let _y = a.y; //[ast]~ ERROR use of moved - | ^^ value used here after move - | - = note: move occurs because `a.x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `a` - --> $DIR/borrowck-box-insensitivity.rs:46:9 - | -LL | let _x = a.x; - | -- value moved here -LL | //[ast]~^ value moved here -LL | let _y = a.y; //[ast]~ ERROR use of moved - | ^^ value used here after move - | - = note: move occurs because `a.x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `a` - --> $DIR/borrowck-box-insensitivity.rs:55:15 - | -LL | let _x = a.x; - | -- value moved here -LL | //[ast]~^ value moved here -LL | let _y = &a.y; //[ast]~ ERROR use of moved - | ^^^ value used here after move - | - = note: move occurs because `a.x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:63:9 - | -LL | let _x = &a.x; - | --- borrow of `a.x` occurs here -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0503]: cannot use `a.y` because it was mutably borrowed - --> $DIR/borrowck-box-insensitivity.rs:71:9 - | -LL | let _x = &mut a.x; - | --- borrow of `a.x` occurs here -LL | let _y = a.y; //[ast]~ ERROR cannot use - | ^^ use of borrowed `a.x` - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:77:9 - | -LL | let _x = &mut a.x; - | --- borrow of `a.x` occurs here -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0502]: cannot borrow `a` (via `a.y`) as immutable because `a` is also borrowed as mutable (via `a.x`) - --> $DIR/borrowck-box-insensitivity.rs:85:15 - | -LL | let _x = &mut a.x; - | --- mutable borrow occurs here (via `a.x`) -LL | let _y = &a.y; //[ast]~ ERROR cannot borrow - | ^^^ immutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `a` (via `a.y`) as mutable because `a` is also borrowed as immutable (via `a.x`) - --> $DIR/borrowck-box-insensitivity.rs:92:19 - | -LL | let _x = &a.x; - | --- immutable borrow occurs here (via `a.x`) -LL | let _y = &mut a.y; //[ast]~ ERROR cannot borrow - | ^^^ mutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here -... -LL | } - | - immutable borrow ends here - -error[E0382]: use of collaterally moved value: `a.y` - --> $DIR/borrowck-box-insensitivity.rs:100:9 - | -LL | let _x = a.x.x; - | -- value moved here -LL | //[ast]~^ value moved here -LL | let _y = a.y; //[ast]~ ERROR use of collaterally moved - | ^^ value used here after move - | - = note: move occurs because `a.x.x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of collaterally moved value: `a.y` - --> $DIR/borrowck-box-insensitivity.rs:108:9 - | -LL | let _x = a.x.x; - | -- value moved here -LL | //[ast]~^ value moved here -LL | let _y = a.y; //[ast]~ ERROR use of collaterally moved - | ^^ value used here after move - | - = note: move occurs because `a.x.x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of collaterally moved value: `a.y` - --> $DIR/borrowck-box-insensitivity.rs:116:15 - | -LL | let _x = a.x.x; - | -- value moved here -LL | //[ast]~^ value moved here -LL | let _y = &a.y; //[ast]~ ERROR use of collaterally moved - | ^^^ value used here after move - | - = note: move occurs because `a.x.x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:124:9 - | -LL | let _x = &a.x.x; - | ----- borrow of `a.x.x` occurs here -LL | //[ast]~^ borrow of `a.x.x` occurs here -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0503]: cannot use `a.y` because it was mutably borrowed - --> $DIR/borrowck-box-insensitivity.rs:132:9 - | -LL | let _x = &mut a.x.x; - | ----- borrow of `a.x.x` occurs here -LL | let _y = a.y; //[ast]~ ERROR cannot use - | ^^ use of borrowed `a.x.x` - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:138:9 - | -LL | let _x = &mut a.x.x; - | ----- borrow of `a.x.x` occurs here -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0502]: cannot borrow `a.y` as immutable because `a.x.x` is also borrowed as mutable - --> $DIR/borrowck-box-insensitivity.rs:147:15 - | -LL | let _x = &mut a.x.x; - | ----- mutable borrow occurs here -LL | //[ast]~^ mutable borrow occurs here -LL | let _y = &a.y; //[ast]~ ERROR cannot borrow - | ^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `a.y` as mutable because `a.x.x` is also borrowed as immutable - --> $DIR/borrowck-box-insensitivity.rs:155:19 - | -LL | let _x = &a.x.x; - | ----- immutable borrow occurs here -LL | //[ast]~^ immutable borrow occurs here -LL | let _y = &mut a.y; //[ast]~ ERROR cannot borrow - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error: aborting due to 16 previous errors - -Some errors occurred: E0382, E0502, E0503, E0505. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.mir.stderr b/src/test/ui/borrowck/borrowck-box-insensitivity.mir.stderr deleted file mode 100644 index 171e992e8a628..0000000000000 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/borrowck-box-insensitivity.rs:160:1 - | -LL | / fn main() { //[mir]~ ERROR compilation successful -LL | | copy_after_move(); -LL | | move_after_move(); -LL | | borrow_after_move(); -... | -LL | | mut_borrow_after_borrow_nested(); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.nll.stderr b/src/test/ui/borrowck/borrowck-box-insensitivity.nll.stderr deleted file mode 100644 index 0e380e90e7591..0000000000000 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/borrowck-box-insensitivity.rs:160:1 - | -LL | / fn main() { -LL | | copy_after_move(); -LL | | move_after_move(); -LL | | borrow_after_move(); -... | -LL | | mut_borrow_after_borrow_nested(); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.rs b/src/test/ui/borrowck/borrowck-box-sensitivity.rs similarity index 54% rename from src/test/ui/borrowck/borrowck-box-insensitivity.rs rename to src/test/ui/borrowck/borrowck-box-sensitivity.rs index e72048d0ea4bc..e5591f500380b 100644 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.rs +++ b/src/test/ui/borrowck/borrowck-box-sensitivity.rs @@ -1,14 +1,9 @@ -// This test is an artifact of the old policy that `Box` should not -// be treated specially by the AST-borrowck. -// -// NLL goes back to treating `Box` specially (namely, knowing that -// it uniquely owns the data it holds). See rust-lang/rfcs#130. - -// revisions: ast mir -//[ast] compile-flags: -Z borrowck=ast -//[mir] compile-flags: -Z borrowck=mir -// ignore-compare-mode-nll -#![feature(box_syntax, rustc_attrs)] +// Test that `Box` is treated specially by borrow checking. This is the case +// because NLL reverted the deicision in rust-lang/rfcs#130. + +// run-pass + +#![feature(box_syntax)] struct A { x: Box, @@ -33,131 +28,101 @@ struct D { fn copy_after_move() { let a: Box<_> = box A { x: box 0, y: 1 }; let _x = a.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of moved - //[ast]~^ move occurs because `a.x` has type `std::boxed::Box` - //[ast]~| value used here after move + let _y = a.y; } fn move_after_move() { let a: Box<_> = box B { x: box 0, y: box 1 }; let _x = a.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of moved - //[ast]~^ move occurs because `a.x` has type `std::boxed::Box` - //[ast]~| value used here after move + let _y = a.y; } fn borrow_after_move() { let a: Box<_> = box A { x: box 0, y: 1 }; let _x = a.x; - //[ast]~^ value moved here - let _y = &a.y; //[ast]~ ERROR use of moved - //[ast]~^ move occurs because `a.x` has type `std::boxed::Box` - //[ast]~| value used here after move + let _y = &a.y; } fn move_after_borrow() { let a: Box<_> = box B { x: box 0, y: box 1 }; let _x = &a.x; let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_imm(_x); } fn copy_after_mut_borrow() { let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &mut a.x; - let _y = a.y; //[ast]~ ERROR cannot use + let _y = a.y; use_mut(_x); } fn move_after_mut_borrow() { let mut a: Box<_> = box B { x: box 0, y: box 1 }; let _x = &mut a.x; let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_mut(_x); } fn borrow_after_mut_borrow() { let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &mut a.x; - let _y = &a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ immutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here + let _y = &a.y; use_mut(_x); } fn mut_borrow_after_borrow() { let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &a.x; - let _y = &mut a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ mutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here + let _y = &mut a.y; use_imm(_x); } fn copy_after_move_nested() { let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = a.x.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of collaterally moved - //[ast]~| value used here after move + let _y = a.y; } fn move_after_move_nested() { let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = a.x.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of collaterally moved - //[ast]~| value used here after move + let _y = a.y; } fn borrow_after_move_nested() { let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = a.x.x; - //[ast]~^ value moved here - let _y = &a.y; //[ast]~ ERROR use of collaterally moved - //[ast]~| value used here after move + let _y = &a.y; } fn move_after_borrow_nested() { let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = &a.x.x; - //[ast]~^ borrow of `a.x.x` occurs here let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_imm(_x); } fn copy_after_mut_borrow_nested() { let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &mut a.x.x; - let _y = a.y; //[ast]~ ERROR cannot use + let _y = a.y; use_mut(_x); } fn move_after_mut_borrow_nested() { let mut a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = &mut a.x.x; let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_mut(_x); } fn borrow_after_mut_borrow_nested() { let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &mut a.x.x; - //[ast]~^ mutable borrow occurs here - let _y = &a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ immutable borrow occurs here + let _y = &a.y; use_mut(_x); } fn mut_borrow_after_borrow_nested() { let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &a.x.x; - //[ast]~^ immutable borrow occurs here - let _y = &mut a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ mutable borrow occurs here + let _y = &mut a.y; use_imm(_x); } -#[rustc_error] -fn main() { //[mir]~ ERROR compilation successful + +fn main() { copy_after_move(); move_after_move(); borrow_after_move(); diff --git a/src/test/ui/borrowck/borrowck-break-uninit-2.nll.stderr b/src/test/ui/borrowck/borrowck-break-uninit-2.nll.stderr deleted file mode 100644 index 177a27387728e..0000000000000 --- a/src/test/ui/borrowck/borrowck-break-uninit-2.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-break-uninit-2.rs:9:20 - | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - | ^ use of possibly uninitialized `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-break-uninit-2.rs b/src/test/ui/borrowck/borrowck-break-uninit-2.rs index 95ccb2e1b931c..dad5325cb8750 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit-2.rs +++ b/src/test/ui/borrowck/borrowck-break-uninit-2.rs @@ -6,7 +6,7 @@ fn foo() -> isize { x = 0; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` return 17; } diff --git a/src/test/ui/borrowck/borrowck-break-uninit-2.stderr b/src/test/ui/borrowck/borrowck-break-uninit-2.stderr index e574c0ff8a85b..eaba43440cd45 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit-2.stderr +++ b/src/test/ui/borrowck/borrowck-break-uninit-2.stderr @@ -1,7 +1,7 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-break-uninit-2.rs:9:20 | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` +LL | println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` | ^ use of possibly uninitialized `x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-break-uninit.nll.stderr b/src/test/ui/borrowck/borrowck-break-uninit.nll.stderr deleted file mode 100644 index 64d1e629fecdb..0000000000000 --- a/src/test/ui/borrowck/borrowck-break-uninit.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-break-uninit.rs:9:20 - | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - | ^ use of possibly uninitialized `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-break-uninit.rs b/src/test/ui/borrowck/borrowck-break-uninit.rs index 827637cfb956f..9af02b387d8b0 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit.rs +++ b/src/test/ui/borrowck/borrowck-break-uninit.rs @@ -6,7 +6,7 @@ fn foo() -> isize { x = 0; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` return 17; } diff --git a/src/test/ui/borrowck/borrowck-break-uninit.stderr b/src/test/ui/borrowck/borrowck-break-uninit.stderr index 1a853c35d00e0..c9a1951da2293 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit.stderr +++ b/src/test/ui/borrowck/borrowck-break-uninit.stderr @@ -1,7 +1,7 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-break-uninit.rs:9:20 | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` +LL | println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` | ^ use of possibly uninitialized `x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.stderr deleted file mode 100644 index 363889c684626..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.stderr +++ /dev/null @@ -1,96 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:21:14 - | -LL | let c1 = || x = 4; - | -- - previous borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - | ^^ - borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:29:14 - | -LL | let c1 = || set(&mut x); - | -- - previous borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` - | ^^ - borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:37:14 - | -LL | let c1 = || set(&mut x); - | -- - previous borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - | ^^ - borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:45:5 - | -LL | let c2 = || x * 5; - | -- borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign - | ^^^^^ assignment to borrowed `x` occurs here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:53:5 - | -LL | let c1 = || get(&x); - | -- borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign - | ^^^^^ assignment to borrowed `x` occurs here - -error[E0506]: cannot assign to `*x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:61:5 - | -LL | let c1 = || get(&*x); - | -- borrow of `*x` occurs here -LL | *x = 5; //[ast]~ ERROR cannot assign to `*x` - | ^^^^^^ assignment to borrowed `*x` occurs here - -error[E0506]: cannot assign to `*x.f` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:73:5 - | -LL | let c1 = || get(&*x.f); - | -- borrow of `*x.f` occurs here -LL | *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` - | ^^^^^^^^ assignment to borrowed `*x.f` occurs here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-mut-and-imm.rs:85:14 - | -LL | let c1 = || get(&*x.f); - | -- - previous borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable - | ^^ - borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error: aborting due to 8 previous errors - -Some errors occurred: E0502, E0506. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr deleted file mode 100644 index ed3d1ff38ec77..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:21:14 - | -LL | let c1 = || x = 4; - | -- - first borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - | ^^ - second borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable -LL | drop(c1); - | -- mutable borrow later used here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:29:14 - | -LL | let c1 = || set(&mut x); - | -- - first borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` - | ^^ - second borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable -LL | drop(c1); - | -- mutable borrow later used here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:37:14 - | -LL | let c1 = || set(&mut x); - | -- - first borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - | ^^ - second borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable -LL | drop(c1); - | -- mutable borrow later used here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:45:5 - | -LL | let c2 = || x * 5; - | -- - borrow occurs due to use in closure - | | - | borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign - | ^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed -LL | drop(c2); - | -- borrow later used here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:53:5 - | -LL | let c1 = || get(&x); - | -- - borrow occurs due to use in closure - | | - | borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign - | ^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed -LL | drop(c1); - | -- borrow later used here - -error[E0506]: cannot assign to `*x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:61:5 - | -LL | let c1 = || get(&*x); - | -- - borrow occurs due to use in closure - | | - | borrow of `*x` occurs here -LL | *x = 5; //[ast]~ ERROR cannot assign to `*x` - | ^^^^^^ assignment to borrowed `*x` occurs here -LL | //[mir]~^ ERROR cannot assign to `*x` because it is borrowed -LL | drop(c1); - | -- borrow later used here - -error[E0506]: cannot assign to `*x.f` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:73:5 - | -LL | let c1 = || get(&*x.f); - | -- - borrow occurs due to use in closure - | | - | borrow of `*x.f` occurs here -LL | *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` - | ^^^^^^^^ assignment to borrowed `*x.f` occurs here -LL | //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed -LL | drop(c1); - | -- borrow later used here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-mut-and-imm.rs:85:14 - | -LL | let c1 = || get(&*x.f); - | -- - first borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable - | ^^ - second borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable -LL | drop(c1); - | -- immutable borrow later used here - -error: aborting due to 8 previous errors - -Some errors occurred: E0502, E0506. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs index 3a802bcbb3e42..2dc405ffcd4c0 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs +++ b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs @@ -1,10 +1,6 @@ // Tests that two closures cannot simultaneously have mutable // and immutable access to the variable. Issue #6801. -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] fn get(x: &isize) -> isize { @@ -18,48 +14,48 @@ fn set(x: &mut isize) { fn a() { let mut x = 3; let c1 = || x = 4; - let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + let c2 = || x * 5; + //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable drop(c1); } fn b() { let mut x = 3; let c1 = || set(&mut x); - let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + let c2 = || get(&x); + //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable drop(c1); } fn c() { let mut x = 3; let c1 = || set(&mut x); - let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + let c2 = || x * 5; + //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable drop(c1); } fn d() { let mut x = 3; let c2 = || x * 5; - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = 5; + //~^ ERROR cannot assign to `x` because it is borrowed drop(c2); } fn e() { let mut x = 3; let c1 = || get(&x); - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = 5; + //~^ ERROR cannot assign to `x` because it is borrowed drop(c1); } fn f() { let mut x: Box<_> = box 3; let c1 = || get(&*x); - *x = 5; //[ast]~ ERROR cannot assign to `*x` - //[mir]~^ ERROR cannot assign to `*x` because it is borrowed + *x = 5; + //~^ ERROR cannot assign to `*x` because it is borrowed drop(c1); } @@ -70,8 +66,8 @@ fn g() { let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); - *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` - //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed + *x.f = 5; + //~^ ERROR cannot assign to `*x.f` because it is borrowed drop(c1); } @@ -82,8 +78,8 @@ fn h() { let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); - let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable - //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + let c2 = || *x.f = 5; + //~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable drop(c1); } diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.stderr similarity index 67% rename from src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-closures-mut-and-imm.stderr index ed3d1ff38ec77..bb6e54aa950cf 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.stderr @@ -1,112 +1,112 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:21:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:17:14 | LL | let c1 = || x = 4; | -- - first borrow occurs due to use of `x` in closure | | | mutable borrow occurs here -LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` +LL | let c2 = || x * 5; | ^^ - second borrow occurs due to use of `x` in closure | | | immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:29:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:25:14 | LL | let c1 = || set(&mut x); | -- - first borrow occurs due to use of `x` in closure | | | mutable borrow occurs here -LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` +LL | let c2 = || get(&x); | ^^ - second borrow occurs due to use of `x` in closure | | | immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:37:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:33:14 | LL | let c1 = || set(&mut x); | -- - first borrow occurs due to use of `x` in closure | | | mutable borrow occurs here -LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` +LL | let c2 = || x * 5; | ^^ - second borrow occurs due to use of `x` in closure | | | immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); | -- mutable borrow later used here error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:45:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:41:5 | LL | let c2 = || x * 5; | -- - borrow occurs due to use in closure | | | borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign +LL | x = 5; | ^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | //~^ ERROR cannot assign to `x` because it is borrowed LL | drop(c2); | -- borrow later used here error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:53:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:49:5 | LL | let c1 = || get(&x); | -- - borrow occurs due to use in closure | | | borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign +LL | x = 5; | ^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | //~^ ERROR cannot assign to `x` because it is borrowed LL | drop(c1); | -- borrow later used here error[E0506]: cannot assign to `*x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:61:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:57:5 | LL | let c1 = || get(&*x); | -- - borrow occurs due to use in closure | | | borrow of `*x` occurs here -LL | *x = 5; //[ast]~ ERROR cannot assign to `*x` +LL | *x = 5; | ^^^^^^ assignment to borrowed `*x` occurs here -LL | //[mir]~^ ERROR cannot assign to `*x` because it is borrowed +LL | //~^ ERROR cannot assign to `*x` because it is borrowed LL | drop(c1); | -- borrow later used here error[E0506]: cannot assign to `*x.f` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:73:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:69:5 | LL | let c1 = || get(&*x.f); | -- - borrow occurs due to use in closure | | | borrow of `*x.f` occurs here -LL | *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` +LL | *x.f = 5; | ^^^^^^^^ assignment to borrowed `*x.f` occurs here -LL | //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed +LL | //~^ ERROR cannot assign to `*x.f` because it is borrowed LL | drop(c1); | -- borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-mut-and-imm.rs:85:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:81:14 | LL | let c1 = || get(&*x.f); | -- - first borrow occurs due to use of `x` in closure | | | immutable borrow occurs here -LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable +LL | let c2 = || *x.f = 5; | ^^ - second borrow occurs due to use of `x` in closure | | | mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable +LL | //~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable LL | drop(c1); | -- immutable borrow later used here diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr deleted file mode 100644 index 8123e17ce9da2..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:13:25 - | -LL | let mut c1 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:15:25 - | -LL | let mut c2 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable - -error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-mut-of-imm.rs:15:18 - | -LL | let mut c1 = || set(&mut *x); - | -- - first borrow occurs due to use of `x` in closure - | | - | first closure is constructed here -LL | //~^ ERROR cannot borrow -LL | let mut c2 = || set(&mut *x); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second closure is constructed here -... -LL | c2(); c1(); - | -- first borrow later used here - -error: aborting due to 3 previous errors - -Some errors occurred: E0524, E0596. -For more information about an error, try `rustc --explain E0524`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr index f529247b1b6f6..8123e17ce9da2 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr @@ -1,30 +1,30 @@ +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-closures-mut-of-imm.rs:13:25 + | +LL | let mut c1 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-closures-mut-of-imm.rs:15:25 + | +LL | let mut c2 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable + error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-mut-of-imm.rs:15:18 | LL | let mut c1 = || set(&mut *x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first closure is constructed here LL | //~^ ERROR cannot borrow LL | let mut c2 = || set(&mut *x); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second closure is constructed here ... -LL | } - | - borrow from first closure ends here - -error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:13:30 - | -LL | let mut c1 = || set(&mut *x); - | ^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:15:30 - | -LL | let mut c2 = || set(&mut *x); - | ^^ cannot borrow as mutable +LL | c2(); c1(); + | -- first borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr deleted file mode 100644 index 18f95f232cdd3..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-mut-of-mut.rs:14:18 - | -LL | let mut c1 = || set(&mut *x); - | -- - first borrow occurs due to use of `x` in closure - | | - | first closure is constructed here -LL | let mut c2 = || set(&mut *x); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second closure is constructed here -LL | //~^ ERROR two closures require unique access to `x` at the same time -LL | c2(); c1(); - | -- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0524`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr index 2c5587710a154..18f95f232cdd3 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr @@ -2,16 +2,16 @@ error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-mut-of-mut.rs:14:18 | LL | let mut c1 = || set(&mut *x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first closure is constructed here LL | let mut c2 = || set(&mut *x); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second closure is constructed here -... -LL | } - | - borrow from first closure ends here +LL | //~^ ERROR two closures require unique access to `x` at the same time +LL | c2(); c1(); + | -- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr deleted file mode 100644 index d3d11e8451cf8..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:16:24 - | -LL | let c1 = to_fn_mut(|| x = 4); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:27:24 - | -LL | let c1 = to_fn_mut(|| set(&mut x)); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:34:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:41:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | //~^ ERROR cannot borrow `x` as mutable more than once -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:53:24 - | -LL | let c1 = to_fn_mut(|| set(&mut *x.f)); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut *x.f)); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | //~^ ERROR cannot borrow `x` as mutable more than once -LL | c1; - | -- first borrow later used here - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr index cb8f5b4366bfd..d3d11e8451cf8 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr +++ b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr @@ -2,76 +2,73 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:16:24 | LL | let c1 = to_fn_mut(|| x = 4); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here LL | c1; -LL | } - | - first borrow ends here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:27:24 | LL | let c1 = to_fn_mut(|| set(&mut x)); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here LL | c1; -LL | } - | - first borrow ends here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:34:24 | LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here LL | c1; -LL | } - | - first borrow ends here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:41:24 | LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... -LL | } - | - first borrow ends here +LL | //~^ ERROR cannot borrow `x` as mutable more than once +LL | c1; + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:53:24 | LL | let c1 = to_fn_mut(|| set(&mut *x.f)); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| set(&mut *x.f)); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... -LL | } - | - first borrow ends here +LL | //~^ ERROR cannot borrow `x` as mutable more than once +LL | c1; + | -- first borrow later used here error: aborting due to 5 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr b/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr deleted file mode 100644 index 80e042fc8fc45..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `this.x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-unique-imm.rs:11:9 - | -LL | let p = &this.x; - | ------- immutable borrow occurs here -LL | &mut this.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^ mutable borrow occurs here -LL | p.use_ref(); - | - immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr b/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr index 1b661b70d7f5b..80e042fc8fc45 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr +++ b/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr @@ -1,13 +1,12 @@ error[E0502]: cannot borrow `this.x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-unique-imm.rs:11:14 + --> $DIR/borrowck-closures-unique-imm.rs:11:9 | LL | let p = &this.x; - | ------ immutable borrow occurs here + | ------- immutable borrow occurs here LL | &mut this.x; //~ ERROR cannot borrow - | ^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^ mutable borrow occurs here LL | p.use_ref(); -LL | }; - | - immutable borrow ends here + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr b/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr deleted file mode 100644 index d6082734451f2..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr +++ /dev/null @@ -1,54 +0,0 @@ -error[E0500]: closure requires unique access to `x` but it is already borrowed - --> $DIR/borrowck-closures-unique.rs:26:14 - | -LL | let c1 = || get(x); - | -- - first borrow occurs due to use of `x` in closure - | | - | borrow occurs here -LL | let c2 = || set(x); //~ ERROR closure requires unique access to `x` - | ^^ - second borrow occurs due to use of `x` in closure - | | - | closure construction occurs here -LL | c1; - | -- first borrow later used here - -error[E0500]: closure requires unique access to `x` but it is already borrowed - --> $DIR/borrowck-closures-unique.rs:32:14 - | -LL | let c1 = || get(x); - | -- - first borrow occurs due to use of `x` in closure - | | - | borrow occurs here -LL | let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x` - | ^^ - second borrow occurs due to use of `x` in closure - | | - | closure construction occurs here -LL | c1; - | -- first borrow later used here - -error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-unique.rs:38:14 - | -LL | let c1 = || set(x); - | -- - first borrow occurs due to use of `x` in closure - | | - | first closure is constructed here -LL | let c2 = || set(x); //~ ERROR two closures require unique access to `x` at the same time - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second closure is constructed here -LL | c1; - | -- first borrow later used here - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/borrowck-closures-unique.rs:47:38 - | -LL | fn e(x: &'static mut isize) { - | - help: consider changing this to be mutable: `mut x` -LL | let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument - | ^^^^^ cannot assign - -error: aborting due to 4 previous errors - -Some errors occurred: E0500, E0524, E0594. -For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-closures-unique.rs b/src/test/ui/borrowck/borrowck-closures-unique.rs index a4655ebba116e..67f91dfa8420e 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique.rs +++ b/src/test/ui/borrowck/borrowck-closures-unique.rs @@ -39,17 +39,14 @@ fn d(x: &mut isize) { c1; } -// This test was originally encoded in the form shown as `fn f` below. -// However, since MIR-borrowck and thus NLL takes more control-flow information -// into account, it was necessary to change the test in order to witness the -// same (expected) error under both AST-borrowck and NLL. fn e(x: &'static mut isize) { - let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument + let c1 = |y: &'static mut isize| x = y; + //~^ ERROR cannot assign to `x`, as it is not declared as mutable c1; } fn f(x: &'static mut isize) { - let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable argument + let c1 = || x = panic!(); // OK assignment is unreachable. c1; } diff --git a/src/test/ui/borrowck/borrowck-closures-unique.stderr b/src/test/ui/borrowck/borrowck-closures-unique.stderr index 94181ad2400d7..dd607431c86cb 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique.stderr +++ b/src/test/ui/borrowck/borrowck-closures-unique.stderr @@ -2,68 +2,53 @@ error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/borrowck-closures-unique.rs:26:14 | LL | let c1 = || get(x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | borrow occurs here LL | let c2 = || set(x); //~ ERROR closure requires unique access to `x` - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | closure construction occurs here LL | c1; -LL | } - | - borrow ends here + | -- first borrow later used here error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/borrowck-closures-unique.rs:32:14 | LL | let c1 = || get(x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | borrow occurs here LL | let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x` - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | closure construction occurs here LL | c1; -LL | } - | - borrow ends here + | -- first borrow later used here error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-unique.rs:38:14 | LL | let c1 = || set(x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first closure is constructed here LL | let c2 = || set(x); //~ ERROR two closures require unique access to `x` at the same time - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second closure is constructed here LL | c1; -LL | } - | - borrow from first closure ends here + | -- first borrow later used here -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/borrowck-closures-unique.rs:47:14 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/borrowck-closures-unique.rs:43:38 | -LL | let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x //~ ERROR closure cannot assign to immutable argument - | ^ - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/borrowck-closures-unique.rs:52:14 - | -LL | let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable argument - | ^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x //~ ERROR closure cannot assign to immutable argument - | ^ +LL | fn e(x: &'static mut isize) { + | - help: consider changing this to be mutable: `mut x` +LL | let c1 = |y: &'static mut isize| x = y; + | ^^^^^ cannot assign -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors occurred: E0500, E0524, E0595. +Some errors occurred: E0500, E0524, E0594. For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr b/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr deleted file mode 100644 index 4501e28a18816..0000000000000 --- a/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-use-after-free.rs:22:8 - | -LL | let mut test = |foo: &Foo| { - | ----------- mutable borrow occurs here -LL | ptr = box Foo { x: ptr.x + 1 }; - | --- first borrow occurs due to use of `ptr` in closure -LL | }; -LL | test(&*ptr); //~ ERROR cannot borrow `*ptr` - | ---- ^^^^^ immutable borrow occurs here - | | - | mutable borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr b/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr index b41a4a0c6768c..4501e28a18816 100644 --- a/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr +++ b/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr @@ -1,15 +1,15 @@ -error[E0502]: cannot borrow `*ptr` as immutable because `ptr` is also borrowed as mutable - --> $DIR/borrowck-closures-use-after-free.rs:22:9 +error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-use-after-free.rs:22:8 | LL | let mut test = |foo: &Foo| { | ----------- mutable borrow occurs here LL | ptr = box Foo { x: ptr.x + 1 }; - | --- previous borrow occurs due to use of `ptr` in closure + | --- first borrow occurs due to use of `ptr` in closure LL | }; LL | test(&*ptr); //~ ERROR cannot borrow `*ptr` - | ^^^^ immutable borrow occurs here -LL | } - | - mutable borrow ends here + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-consume-unsize-vec.nll.stderr b/src/test/ui/borrowck/borrowck-consume-unsize-vec.nll.stderr deleted file mode 100644 index ea7683a91adfe..0000000000000 --- a/src/test/ui/borrowck/borrowck-consume-unsize-vec.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `b` - --> $DIR/borrowck-consume-unsize-vec.rs:8:13 - | -LL | fn foo(b: Box<[i32;5]>) { - | - move occurs because `b` has type `std::boxed::Box<[i32; 5]>`, which does not implement the `Copy` trait -LL | consume(b); - | - value moved here -LL | consume(b); //~ ERROR use of moved value - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr index 2fc2248000f3d..ea7683a91adfe 100644 --- a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr +++ b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `b` --> $DIR/borrowck-consume-unsize-vec.rs:8:13 | +LL | fn foo(b: Box<[i32;5]>) { + | - move occurs because `b` has type `std::boxed::Box<[i32; 5]>`, which does not implement the `Copy` trait LL | consume(b); | - value moved here LL | consume(b); //~ ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `b` has type `std::boxed::Box<[i32; 5]>`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.nll.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.nll.stderr deleted file mode 100644 index 15cf359326be9..0000000000000 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `b` - --> $DIR/borrowck-consume-upcast-box.rs:10:13 - | -LL | fn foo(b: Box) { - | - move occurs because `b` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | consume(b); - | - value moved here -LL | consume(b); //~ ERROR use of moved value - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr index aef1671342ef4..15cf359326be9 100644 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr +++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `b` --> $DIR/borrowck-consume-upcast-box.rs:10:13 | +LL | fn foo(b: Box) { + | - move occurs because `b` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | consume(b); | - value moved here LL | consume(b); //~ ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `b` has type `std::boxed::Box<(dyn Foo + std::marker::Send + 'static)>`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr deleted file mode 100644 index 278929eedb008..0000000000000 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr +++ /dev/null @@ -1,246 +0,0 @@ -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:43:9 - | -LL | let x = f.x(); - | - borrow of `f` occurs here -LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - | ^^^ use of borrowed `f` - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:51:9 - | -LL | let x = g.x(); - | - borrow of `g` occurs here -LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - | ^^^ use of borrowed `g` - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:59:9 - | -LL | let x = &mut h.0; - | --- borrow of `h.0` occurs here -LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - | ^^^ use of borrowed `h.0` - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:68:20 - | -LL | let x = e.x(); - | - borrow of `e` occurs here -LL | match e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `e` - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:78:9 - | -LL | let x = &mut u.a; - | --- borrow of `u.a` occurs here -LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - | ^^^ use of borrowed `u.a` - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:86:9 - | -LL | let x = f.x(); - | - borrow of `*f` occurs here -LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - | ^^^ use of borrowed `*f` - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:94:9 - | -LL | let x = g.x(); - | - borrow of `*g` occurs here -LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - | ^^^ use of borrowed `*g` - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:102:9 - | -LL | let x = &mut h.0; - | --- borrow of `h.0` occurs here -LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - | ^^^ use of borrowed `h.0` - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:111:20 - | -LL | let x = e.x(); - | - borrow of `*e` occurs here -LL | match *e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `*e` - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:121:9 - | -LL | let x = &mut u.a; - | --- borrow of `u.a` occurs here -LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - | ^^^ use of borrowed `u.a` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:130:15 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -LL | match v { -LL | &[x, _, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:136:18 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, x, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:142:25 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, _, .., x, _] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:148:28 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, _, .., _, x] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:160:15 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -LL | match v { -LL | &[x..] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:166:18 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, x..] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:172:15 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:178:18 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0502]: cannot borrow `e.0` as immutable because `e` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:192:18 - | -LL | let x = &mut e; - | - mutable borrow occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `e.x` as immutable because `e` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:197:23 - | -LL | let x = &mut e; - | - mutable borrow occurs here -... -LL | E::B { x: ref bx } => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:211:22 - | -LL | let x = &mut s; - | - mutable borrow occurs here -LL | match s { -LL | S { y: (ref y0, _), .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:218:28 - | -LL | let x = &mut s; - | - mutable borrow occurs here -... -LL | S { x: F { y: ref x0, .. }, .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0503]: cannot use `v[..].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -LL | v[0].y; - | ^^^^^^ use of borrowed `v` - -error[E0499]: cannot borrow `**x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:285:18 - | -LL | let y = &mut x; - | - first mutable borrow occurs here -LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - | ^ second mutable borrow occurs here -... -LL | }; - | - first borrow ends here - -error[E0499]: cannot borrow `**x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:296:25 - | -LL | let y = &mut x; - | - first mutable borrow occurs here -LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:307:22 - | -LL | drop(x); - | - value moved here -LL | drop(x); //[ast]~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait - -error: aborting due to 26 previous errors - -Some errors occurred: E0382, E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr deleted file mode 100644 index 279548f870fd0..0000000000000 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr +++ /dev/null @@ -1,377 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:285:13 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - | ^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time -LL | *y = 1; - | ------ first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:296:20 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - | ^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time -LL | *y = 1; - | ------ first borrow later used here - -error: captured variable cannot escape `FnMut` closure body - --> $DIR/borrowck-describe-lvalue.rs:294:16 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | / || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body -LL | | let y = &mut x; -LL | | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time -LL | | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time -LL | | *y = 1; -LL | | drop(y); -LL | | } - | |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body - | - = note: `FnMut` closures only have access to their captured variables while they are executing... - = note: ...therefore, they cannot allow references to captured variables to escape - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:43:9 - | -LL | let x = f.x(); - | - borrow of `f` occurs here -LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - | ^^^ use of borrowed `f` -LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:51:9 - | -LL | let x = g.x(); - | - borrow of `g` occurs here -LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - | ^^^ use of borrowed `g` -LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:59:9 - | -LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here -LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - | ^^^ use of borrowed `h.0` -LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:68:20 - | -LL | let x = e.x(); - | - borrow of `e` occurs here -LL | match e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:78:9 - | -LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - | ^^^ use of borrowed `u.a` -LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:86:9 - | -LL | let x = f.x(); - | - borrow of `*f` occurs here -LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - | ^^^ use of borrowed `*f` -LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:94:9 - | -LL | let x = g.x(); - | - borrow of `*g` occurs here -LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - | ^^^ use of borrowed `*g` -LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:102:9 - | -LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here -LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - | ^^^ use of borrowed `h.0` -LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:111:20 - | -LL | let x = e.x(); - | - borrow of `*e` occurs here -LL | match *e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `*e` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:121:9 - | -LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - | ^^^ use of borrowed `u.a` -LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:130:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { -LL | &[x, _, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:136:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:142:25 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, _, .., x, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:148:28 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, _, .., _, x] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:160:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { -LL | &[x..] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:166:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x..] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:172:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:178:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:192:13 - | -LL | let x = &mut e; - | ------ borrow of `e` occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^^^^^^^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - -error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:192:18 - | -LL | let x = &mut e; - | ------ mutable borrow occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:197:23 - | -LL | let x = &mut e; - | ------ mutable borrow occurs here -... -LL | E::B { x: ref bx } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:211:22 - | -LL | let x = &mut s; - | ------ mutable borrow occurs here -LL | match s { -LL | S { y: (ref y0, _), .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:218:28 - | -LL | let x = &mut s; - | ------ mutable borrow occurs here -... -LL | S { x: F { y: ref x0, .. }, .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0503]: cannot use `*v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | v[0].y; - | ^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[_].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | v[0].y; - | ^^^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:273:24 - | -LL | let x = &mut v; - | ------ mutable borrow occurs here -LL | match v { -LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:235:29 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p: &'a u8 = &*block.current; - | ^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:250:33 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p : *const u8 = &*(*block).current; - | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:307:22 - | -LL | drop(x); - | - value moved here -LL | drop(x); //[ast]~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait - -error: aborting due to 32 previous errors - -Some errors occurred: E0382, E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.rs b/src/test/ui/borrowck/borrowck-describe-lvalue.rs index eb622ac10addf..c8dbf4e691816 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.rs +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.rs @@ -1,6 +1,4 @@ // ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir #![feature(slice_patterns)] @@ -40,24 +38,21 @@ fn main() { { let mut f = Foo { x: 22 }; let x = f.x(); - f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed + f.x; //~ ERROR cannot use `f.x` because it was mutably borrowed drop(x); } // Local and field from tuple-struct { let mut g = Bar(22); let x = g.x(); - g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed + g.0; //~ ERROR cannot use `g.0` because it was mutably borrowed drop(x); } // Local and field from tuple { let mut h = (22, 23); let x = &mut h.0; - h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed + h.0; //~ ERROR cannot use `h.0` because it was mutably borrowed drop(x); } // Local and field from enum @@ -65,9 +60,7 @@ fn main() { let mut e = Baz::X(2); let x = e.x(); match e { - Baz::X(value) => value - //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed + Baz::X(value) => value //~ ERROR cannot use `e.0` because it was mutably borrowed }; drop(x); } @@ -75,32 +68,28 @@ fn main() { unsafe { let mut u = U { b: 0 }; let x = &mut u.a; - u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed + u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed drop(x); } // Deref and field from struct { let mut f = Box::new(Foo { x: 22 }); let x = f.x(); - f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed + f.x; //~ ERROR cannot use `f.x` because it was mutably borrowed drop(x); } // Deref and field from tuple-struct { let mut g = Box::new(Bar(22)); let x = g.x(); - g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed + g.0; //~ ERROR cannot use `g.0` because it was mutably borrowed drop(x); } // Deref and field from tuple { let mut h = Box::new((22, 23)); let x = &mut h.0; - h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed + h.0; //~ ERROR cannot use `h.0` because it was mutably borrowed drop(x); } // Deref and field from enum @@ -109,8 +98,7 @@ fn main() { let x = e.x(); match *e { Baz::X(value) => value - //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed + //~^ ERROR cannot use `e.0` because it was mutably borrowed }; drop(x); } @@ -118,8 +106,7 @@ fn main() { unsafe { let mut u = Box::new(U { b: 0 }); let x = &mut u.a; - u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed + u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed drop(x); } // Constant index @@ -128,26 +115,22 @@ fn main() { let x = &mut v; match v { &[x, _, .., _, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, x, .., _, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, _, .., x, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, _, .., _, x] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } drop(x); @@ -158,26 +141,22 @@ fn main() { let x = &mut v; match v { &[x..] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, x..] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[x.., _] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, x.., _] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } drop(x); @@ -190,13 +169,11 @@ fn main() { let x = &mut e; match e { E::A(ref ax) => - //[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable - //[mir]~| ERROR cannot use `e` because it was mutably borrowed + //~^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable + //~| ERROR cannot use `e` because it was mutably borrowed println!("e.ax: {:?}", ax), E::B { x: ref bx } => - //[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable println!("e.bx: {:?}", bx), } drop(x); @@ -209,15 +186,13 @@ fn main() { let x = &mut s; match s { S { y: (ref y0, _), .. } => - //[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable println!("y0: {:?}", y0), _ => panic!("other case"), } match s { S { x: F { y: ref x0, .. }, .. } => - //[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable println!("x0: {:?}", x0), _ => panic!("other case"), } @@ -233,8 +208,10 @@ fn main() { fn bump<'a>(mut block: &mut Block<'a>) { let x = &mut block; let p: &'a u8 = &*block.current; - //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable - // No errors in AST because of issue rust#38899 + //~^ WARNING cannot borrow `*block.current` as immutable because it is also borrowed as mutable + //~| this error has been downgraded + //~| this warning will become a hard error in the future + // Warning because of issue rust#38899 drop(x); } } @@ -248,8 +225,10 @@ fn main() { unsafe fn bump2(mut block: *mut Block2) { let x = &mut block; let p : *const u8 = &*(*block).current; - //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable - // No errors in AST because of issue rust#38899 + //~^ WARNING cannot borrow `*block.current` as immutable because it is also borrowed as mutable + //~| this error has been downgraded + //~| this warning will become a hard error in the future + // Warning because of issue rust#38899 drop(x); } } @@ -259,9 +238,8 @@ fn main() { let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; let x = &mut v; v[0].y; - //[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[_].y` because it was mutably borrowed - //[mir]~| ERROR cannot use `*v` because it was mutably borrowed + //~^ ERROR cannot use `v[_].y` because it was mutably borrowed + //~| ERROR cannot use `*v` because it was mutably borrowed drop(x); } // Field of constant index @@ -271,8 +249,7 @@ fn main() { let x = &mut v; match v { &[_, F {x: ref xf, ..}] => println!("{}", xf), - //[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - // No errors in AST + //~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable _ => panic!("other case") } drop(x); @@ -282,8 +259,7 @@ fn main() { let mut x = 0; || { let y = &mut x; - &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time + &mut x; //~ ERROR cannot borrow `x` as mutable more than once at a time *y = 1; }; } @@ -291,10 +267,9 @@ fn main() { { let mut x = 0; || { - || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body + || { //~ ERROR captured variable cannot escape `FnMut` closure body let y = &mut x; - &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time + &mut x; //~ ERROR cannot borrow `x` as mutable more than once at a time *y = 1; drop(y); } @@ -304,8 +279,7 @@ fn main() { fn foo(x: Vec) { let c = || { drop(x); - drop(x); //[ast]~ ERROR use of moved value: `x` - //[mir]~^ ERROR use of moved value: `x` + drop(x); //~ ERROR use of moved value: `x` }; c(); } diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.stderr similarity index 76% rename from src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-describe-lvalue.stderr index 24467faa90ca9..d696c867c1abd 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.stderr @@ -1,34 +1,31 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:285:13 + --> $DIR/borrowck-describe-lvalue.rs:262:13 | LL | let y = &mut x; | ------ first mutable borrow occurs here -LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time +LL | &mut x; //~ ERROR cannot borrow `x` as mutable more than once at a time | ^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; | ------ first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:296:20 + --> $DIR/borrowck-describe-lvalue.rs:272:20 | LL | let y = &mut x; | ------ first mutable borrow occurs here -LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time +LL | &mut x; //~ ERROR cannot borrow `x` as mutable more than once at a time | ^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; | ------ first borrow later used here error: captured variable cannot escape `FnMut` closure body - --> $DIR/borrowck-describe-lvalue.rs:294:16 + --> $DIR/borrowck-describe-lvalue.rs:270:16 | LL | || { | - inferred to be a `FnMut` closure -LL | / || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body +LL | / || { //~ ERROR captured variable cannot escape `FnMut` closure body LL | | let y = &mut x; -LL | | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time -LL | | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time +LL | | &mut x; //~ ERROR cannot borrow `x` as mutable more than once at a time LL | | *y = 1; LL | | drop(y); LL | | } @@ -38,96 +35,89 @@ LL | | } = note: ...therefore, they cannot allow references to captured variables to escape error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:43:9 + --> $DIR/borrowck-describe-lvalue.rs:41:9 | LL | let x = f.x(); | - borrow of `f` occurs here -LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed +LL | f.x; //~ ERROR cannot use `f.x` because it was mutably borrowed | ^^^ use of borrowed `f` -LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:51:9 + --> $DIR/borrowck-describe-lvalue.rs:48:9 | LL | let x = g.x(); | - borrow of `g` occurs here -LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed +LL | g.0; //~ ERROR cannot use `g.0` because it was mutably borrowed | ^^^ use of borrowed `g` -LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:59:9 + --> $DIR/borrowck-describe-lvalue.rs:55:9 | LL | let x = &mut h.0; | -------- borrow of `h.0` occurs here -LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed +LL | h.0; //~ ERROR cannot use `h.0` because it was mutably borrowed | ^^^ use of borrowed `h.0` -LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:68:20 + --> $DIR/borrowck-describe-lvalue.rs:63:20 | LL | let x = e.x(); | - borrow of `e` occurs here LL | match e { -LL | Baz::X(value) => value +LL | Baz::X(value) => value //~ ERROR cannot use `e.0` because it was mutably borrowed | ^^^^^ use of borrowed `e` -... +LL | }; LL | drop(x); | - borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:78:9 + --> $DIR/borrowck-describe-lvalue.rs:71:9 | LL | let x = &mut u.a; | -------- borrow of `u.a` occurs here -LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed +LL | u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed | ^^^ use of borrowed `u.a` -LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:86:9 + --> $DIR/borrowck-describe-lvalue.rs:78:9 | LL | let x = f.x(); | - borrow of `*f` occurs here -LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed +LL | f.x; //~ ERROR cannot use `f.x` because it was mutably borrowed | ^^^ use of borrowed `*f` -LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:94:9 + --> $DIR/borrowck-describe-lvalue.rs:85:9 | LL | let x = g.x(); | - borrow of `*g` occurs here -LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed +LL | g.0; //~ ERROR cannot use `g.0` because it was mutably borrowed | ^^^ use of borrowed `*g` -LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:102:9 + --> $DIR/borrowck-describe-lvalue.rs:92:9 | LL | let x = &mut h.0; | -------- borrow of `h.0` occurs here -LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed +LL | h.0; //~ ERROR cannot use `h.0` because it was mutably borrowed | ^^^ use of borrowed `h.0` -LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:111:20 + --> $DIR/borrowck-describe-lvalue.rs:100:20 | LL | let x = e.x(); | - borrow of `*e` occurs here @@ -139,18 +129,17 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:121:9 + --> $DIR/borrowck-describe-lvalue.rs:109:9 | LL | let x = &mut u.a; | -------- borrow of `u.a` occurs here -LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed +LL | u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed | ^^^ use of borrowed `u.a` -LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:130:15 + --> $DIR/borrowck-describe-lvalue.rs:117:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -162,7 +151,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:136:18 + --> $DIR/borrowck-describe-lvalue.rs:122:18 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -174,7 +163,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:142:25 + --> $DIR/borrowck-describe-lvalue.rs:127:25 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -186,7 +175,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:148:28 + --> $DIR/borrowck-describe-lvalue.rs:132:28 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -198,7 +187,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:160:15 + --> $DIR/borrowck-describe-lvalue.rs:143:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -210,7 +199,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:166:18 + --> $DIR/borrowck-describe-lvalue.rs:148:18 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -222,7 +211,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:172:15 + --> $DIR/borrowck-describe-lvalue.rs:153:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -234,7 +223,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:178:18 + --> $DIR/borrowck-describe-lvalue.rs:158:18 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -246,7 +235,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:192:13 + --> $DIR/borrowck-describe-lvalue.rs:171:13 | LL | let x = &mut e; | ------ borrow of `e` occurs here @@ -258,7 +247,7 @@ LL | drop(x); | - borrow later used here error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:192:18 + --> $DIR/borrowck-describe-lvalue.rs:171:18 | LL | let x = &mut e; | ------ mutable borrow occurs here @@ -270,7 +259,7 @@ LL | drop(x); | - mutable borrow later used here error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:197:23 + --> $DIR/borrowck-describe-lvalue.rs:175:23 | LL | let x = &mut e; | ------ mutable borrow occurs here @@ -282,7 +271,7 @@ LL | drop(x); | - mutable borrow later used here error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:211:22 + --> $DIR/borrowck-describe-lvalue.rs:188:22 | LL | let x = &mut s; | ------ mutable borrow occurs here @@ -294,7 +283,7 @@ LL | drop(x); | - mutable borrow later used here error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:218:28 + --> $DIR/borrowck-describe-lvalue.rs:194:28 | LL | let x = &mut s; | ------ mutable borrow occurs here @@ -306,7 +295,7 @@ LL | drop(x); | - mutable borrow later used here error[E0503]: cannot use `*v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 + --> $DIR/borrowck-describe-lvalue.rs:240:9 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -317,7 +306,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[_].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 + --> $DIR/borrowck-describe-lvalue.rs:240:9 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -328,7 +317,7 @@ LL | drop(x); | - borrow later used here error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:273:24 + --> $DIR/borrowck-describe-lvalue.rs:251:24 | LL | let x = &mut v; | ------ mutable borrow occurs here @@ -340,7 +329,7 @@ LL | drop(x); | - mutable borrow later used here warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:235:29 + --> $DIR/borrowck-describe-lvalue.rs:210:29 | LL | let x = &mut block; | ---------- mutable borrow occurs here @@ -354,7 +343,7 @@ LL | drop(x); = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:250:33 + --> $DIR/borrowck-describe-lvalue.rs:227:33 | LL | let x = &mut block; | ---------- mutable borrow occurs here @@ -368,11 +357,11 @@ LL | drop(x); = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:307:22 + --> $DIR/borrowck-describe-lvalue.rs:282:22 | LL | drop(x); | - value moved here -LL | drop(x); //[ast]~ ERROR use of moved value: `x` +LL | drop(x); //~ ERROR use of moved value: `x` | ^ value used here after move | = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr deleted file mode 100644 index 3195120cba281..0000000000000 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function - --> $DIR/borrowck-escaping-closure-error-1.rs:13:11 - | -LL | spawn(|| books.push(4)); - | ^^ ----- `books` is borrowed here - | | - | may outlive borrowed value `books` - | -note: function requires argument type to outlive `'static` - --> $DIR/borrowck-escaping-closure-error-1.rs:13:5 - | -LL | spawn(|| books.push(4)); - | ^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword - | -LL | spawn(move || books.push(4)); - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr index 16ba61d9972c4..3195120cba281 100644 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr +++ b/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr @@ -5,6 +5,12 @@ LL | spawn(|| books.push(4)); | ^^ ----- `books` is borrowed here | | | may outlive borrowed value `books` + | +note: function requires argument type to outlive `'static` + --> $DIR/borrowck-escaping-closure-error-1.rs:13:5 + | +LL | spawn(|| books.push(4)); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword | LL | spawn(move || books.push(4)); diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr deleted file mode 100644 index 3227aa9bb6829..0000000000000 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function - --> $DIR/borrowck-escaping-closure-error-2.rs:11:14 - | -LL | Box::new(|| books.push(4)) - | ^^ ----- `books` is borrowed here - | | - | may outlive borrowed value `books` - | -note: closure is returned here - --> $DIR/borrowck-escaping-closure-error-2.rs:11:5 - | -LL | Box::new(|| books.push(4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword - | -LL | Box::new(move || books.push(4)) - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr index 960f65da5f0b2..3227aa9bb6829 100644 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr +++ b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr @@ -5,6 +5,12 @@ LL | Box::new(|| books.push(4)) | ^^ ----- `books` is borrowed here | | | may outlive borrowed value `books` + | +note: closure is returned here + --> $DIR/borrowck-escaping-closure-error-2.rs:11:5 + | +LL | Box::new(|| books.push(4)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword | LL | Box::new(move || books.push(4)) diff --git a/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr b/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr deleted file mode 100644 index 25a9a11204430..0000000000000 --- a/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr +++ /dev/null @@ -1,132 +0,0 @@ -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:8:10 - | -LL | drop(x.b); - | --- value moved here -LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` - | ^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:14:10 - | -LL | let y = A { a: 3, .. x }; - | ---------------- value moved here -LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` - | ^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:20:13 - | -LL | drop(x.b); - | --- value moved here -LL | let p = &x.b; //~ ERROR use of moved value: `x.b` - | ^^^^ value borrowed here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:27:13 - | -LL | let _y = A { a: 3, .. x }; - | ---------------- value moved here -LL | let p = &x.b; //~ ERROR use of moved value: `x.b` - | ^^^^ value borrowed here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `x.b` because it is borrowed - --> $DIR/borrowck-field-sensitivity.rs:34:10 - | -LL | let p = &x.b; - | ---- borrow of `x.b` occurs here -LL | drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed - | ^^^ move out of `x.b` occurs here -LL | drop(**p); - | --- borrow later used here - -error[E0505]: cannot move out of `x.b` because it is borrowed - --> $DIR/borrowck-field-sensitivity.rs:41:14 - | -LL | let p = &x.b; - | ---- borrow of `x.b` occurs here -LL | let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed - | ^^^^^^^^^^^^^^^^ move out of `x.b` occurs here -LL | drop(**p); - | --- borrow later used here - -error[E0499]: cannot borrow `x.a` as mutable more than once at a time - --> $DIR/borrowck-field-sensitivity.rs:48:13 - | -LL | let p = &mut x.a; - | -------- first mutable borrow occurs here -LL | let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time - | ^^^^^^^^ second mutable borrow occurs here -LL | drop(*p); - | -- first borrow later used here - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:56:10 - | -LL | drop(x.b); - | --- value moved here -LL | drop(x.b); //~ ERROR use of moved value: `x.b` - | ^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:62:10 - | -LL | let _y = A { a: 3, .. x }; - | ---------------- value moved here -LL | drop(x.b); //~ ERROR use of moved value: `x.b` - | ^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:68:14 - | -LL | drop(x.b); - | --- value moved here -LL | let _z = A { a: 3, .. x }; //~ ERROR use of moved value: `x.b` - | ^^^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:74:14 - | -LL | let _y = A { a: 3, .. x }; - | ---------------- value moved here -LL | let _z = A { a: 4, .. x }; //~ ERROR use of moved value: `x.b` - | ^^^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/borrowck-field-sensitivity.rs:81:5 - | -LL | x.a = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/borrowck-field-sensitivity.rs:87:5 - | -LL | x.a = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/borrowck-field-sensitivity.rs:94:5 - | -LL | x.b = box 1; - | ^^^ use of possibly uninitialized `x` - -error: aborting due to 14 previous errors - -Some errors occurred: E0381, E0382, E0499, E0505. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-field-sensitivity.rs b/src/test/ui/borrowck/borrowck-field-sensitivity.rs index 1e9e6d68a518a..88f74d1ed3300 100644 --- a/src/test/ui/borrowck/borrowck-field-sensitivity.rs +++ b/src/test/ui/borrowck/borrowck-field-sensitivity.rs @@ -5,26 +5,26 @@ struct A { a: isize, b: Box } fn deref_after_move() { let x = A { a: 1, b: box 2 }; drop(x.b); - drop(*x.b); //~ ERROR use of moved value: `*x.b` + drop(*x.b); //~ ERROR use of moved value: `x.b` } fn deref_after_fu_move() { let x = A { a: 1, b: box 2 }; let y = A { a: 3, .. x }; - drop(*x.b); //~ ERROR use of moved value: `*x.b` + drop(*x.b); //~ ERROR use of moved value: `x.b` } fn borrow_after_move() { let x = A { a: 1, b: box 2 }; drop(x.b); - let p = &x.b; //~ ERROR use of moved value: `x.b` + let p = &x.b; //~ ERROR borrow of moved value: `x.b` drop(**p); } fn borrow_after_fu_move() { let x = A { a: 1, b: box 2 }; let _y = A { a: 3, .. x }; - let p = &x.b; //~ ERROR use of moved value: `x.b` + let p = &x.b; //~ ERROR borrow of moved value: `x.b` drop(**p); } @@ -78,21 +78,21 @@ fn fu_move_after_fu_move() { fn copy_after_field_assign_after_uninit() { let mut x: A; - x.a = 1; - drop(x.a); //~ ERROR use of possibly uninitialized variable: `x.a` + x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + drop(x.a); } fn borrow_after_field_assign_after_uninit() { let mut x: A; - x.a = 1; - let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a` + x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + let p = &x.a; drop(*p); } fn move_after_field_assign_after_uninit() { let mut x: A; - x.b = box 1; - drop(x.b); //~ ERROR use of possibly uninitialized variable: `x.b` + x.b = box 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + drop(x.b); } fn main() { diff --git a/src/test/ui/borrowck/borrowck-field-sensitivity.stderr b/src/test/ui/borrowck/borrowck-field-sensitivity.stderr index bfab5cbe536dd..258023f8c5821 100644 --- a/src/test/ui/borrowck/borrowck-field-sensitivity.stderr +++ b/src/test/ui/borrowck/borrowck-field-sensitivity.stderr @@ -1,40 +1,40 @@ -error[E0382]: use of moved value: `*x.b` +error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:8:10 | LL | drop(x.b); | --- value moved here -LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` +LL | drop(*x.b); //~ ERROR use of moved value: `x.b` | ^^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `*x.b` +error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:14:10 | LL | let y = A { a: 3, .. x }; - | - value moved here -LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` + | ---------------- value moved here +LL | drop(*x.b); //~ ERROR use of moved value: `x.b` | ^^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:20:14 +error[E0382]: borrow of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:20:13 | LL | drop(x.b); | --- value moved here -LL | let p = &x.b; //~ ERROR use of moved value: `x.b` - | ^^^ value used here after move +LL | let p = &x.b; //~ ERROR borrow of moved value: `x.b` + | ^^^^ value borrowed here after move | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:27:14 +error[E0382]: borrow of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:27:13 | LL | let _y = A { a: 3, .. x }; - | - value moved here -LL | let p = &x.b; //~ ERROR use of moved value: `x.b` - | ^^^ value used here after move + | ---------------- value moved here +LL | let p = &x.b; //~ ERROR borrow of moved value: `x.b` + | ^^^^ value borrowed here after move | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait @@ -42,28 +42,31 @@ error[E0505]: cannot move out of `x.b` because it is borrowed --> $DIR/borrowck-field-sensitivity.rs:34:10 | LL | let p = &x.b; - | --- borrow of `x.b` occurs here + | ---- borrow of `x.b` occurs here LL | drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed | ^^^ move out of `x.b` occurs here +LL | drop(**p); + | --- borrow later used here error[E0505]: cannot move out of `x.b` because it is borrowed - --> $DIR/borrowck-field-sensitivity.rs:41:27 + --> $DIR/borrowck-field-sensitivity.rs:41:14 | LL | let p = &x.b; - | --- borrow of `x.b` occurs here + | ---- borrow of `x.b` occurs here LL | let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed - | ^ move out of `x.b` occurs here + | ^^^^^^^^^^^^^^^^ move out of `x.b` occurs here +LL | drop(**p); + | --- borrow later used here error[E0499]: cannot borrow `x.a` as mutable more than once at a time - --> $DIR/borrowck-field-sensitivity.rs:48:18 + --> $DIR/borrowck-field-sensitivity.rs:48:13 | LL | let p = &mut x.a; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time - | ^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^ second mutable borrow occurs here +LL | drop(*p); + | -- first borrow later used here error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:56:10 @@ -79,49 +82,49 @@ error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:62:10 | LL | let _y = A { a: 3, .. x }; - | - value moved here + | ---------------- value moved here LL | drop(x.b); //~ ERROR use of moved value: `x.b` | ^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:68:27 + --> $DIR/borrowck-field-sensitivity.rs:68:14 | LL | drop(x.b); | --- value moved here LL | let _z = A { a: 3, .. x }; //~ ERROR use of moved value: `x.b` - | ^ value used here after move + | ^^^^^^^^^^^^^^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:74:27 + --> $DIR/borrowck-field-sensitivity.rs:74:14 | LL | let _y = A { a: 3, .. x }; - | - value moved here + | ---------------- value moved here LL | let _z = A { a: 4, .. x }; //~ ERROR use of moved value: `x.b` - | ^ value used here after move + | ^^^^^^^^^^^^^^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait -error[E0381]: use of possibly uninitialized variable: `x.a` - --> $DIR/borrowck-field-sensitivity.rs:82:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:81:5 | -LL | drop(x.a); //~ ERROR use of possibly uninitialized variable: `x.a` - | ^^^ use of possibly uninitialized `x.a` +LL | x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x.a` - --> $DIR/borrowck-field-sensitivity.rs:88:14 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:87:5 | -LL | let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a` - | ^^^ use of possibly uninitialized `x.a` +LL | x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:95:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:94:5 | -LL | drop(x.b); //~ ERROR use of possibly uninitialized variable: `x.b` - | ^^^ use of possibly uninitialized `x.b` +LL | x.b = box 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + | ^^^ use of possibly uninitialized `x` error: aborting due to 14 previous errors diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-a.mir.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-a.mir.stderr deleted file mode 100644 index 6a5c5047fb237..0000000000000 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-fn-in-const-a.rs:9:16 - | -LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] - | ^^ cannot move out of borrowed content - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-a.rs b/src/test/ui/borrowck/borrowck-fn-in-const-a.rs index 17663a30ca76d..faa56cc7f2a82 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.rs +++ b/src/test/ui/borrowck/borrowck-fn-in-const-a.rs @@ -1,13 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Check that we check fns appearing in constant declarations. // Issue #22382. const MOVE: fn(&String) -> String = { fn broken(x: &String) -> String { - return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] - //[mir]~^ ERROR [E0507] + return *x //~ ERROR cannot move out of borrowed content [E0507] } broken }; diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-a.stderr similarity index 64% rename from src/test/ui/borrowck/borrowck-fn-in-const-a.ast.stderr rename to src/test/ui/borrowck/borrowck-fn-in-const-a.stderr index 6a5c5047fb237..7ea2876c7dc56 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.stderr +++ b/src/test/ui/borrowck/borrowck-fn-in-const-a.stderr @@ -1,7 +1,7 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-fn-in-const-a.rs:9:16 + --> $DIR/borrowck-fn-in-const-a.rs:6:16 | -LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] +LL | return *x //~ ERROR cannot move out of borrowed content [E0507] | ^^ cannot move out of borrowed content error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr deleted file mode 100644 index 7d8618e16d974..0000000000000 --- a/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0713]: borrow may still be in use when destructor runs - --> $DIR/borrowck-fn-in-const-c.rs:17:16 - | -LL | return &local.inner; //~ ERROR does not live long enough - | ^^^^^^^^^^^^ returning this value requires that `local.inner` is borrowed for `'static` -LL | } - | - here, drop of `local` needs exclusive access to `local.inner`, because the type `DropString` implements the `Drop` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-c.rs b/src/test/ui/borrowck/borrowck-fn-in-const-c.rs index d0a2e5b037df4..c638cd08bc9ae 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-c.rs +++ b/src/test/ui/borrowck/borrowck-fn-in-const-c.rs @@ -14,7 +14,7 @@ impl Drop for DropString { const LOCAL_REF: fn() -> &'static str = { fn broken() -> &'static str { let local = DropString { inner: format!("Some local string") }; - return &local.inner; //~ ERROR does not live long enough + return &local.inner; //~ borrow may still be in use when destructor runs } broken }; diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr index f6e7e99393c8c..15fd18001cf2d 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr +++ b/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr @@ -1,13 +1,11 @@ -error[E0597]: `local.inner` does not live long enough - --> $DIR/borrowck-fn-in-const-c.rs:17:17 +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/borrowck-fn-in-const-c.rs:17:16 | -LL | return &local.inner; //~ ERROR does not live long enough - | ^^^^^^^^^^^ borrowed value does not live long enough +LL | return &local.inner; //~ borrow may still be in use when destructor runs + | ^^^^^^^^^^^^ returning this value requires that `local.inner` is borrowed for `'static` LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - here, drop of `local` needs exclusive access to `local.inner`, because the type `DropString` implements the `Drop` trait error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr deleted file mode 100644 index 8ba6a07b3d2d4..0000000000000 --- a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:15 - | -LL | for &a in x.iter() { //~ ERROR cannot move out - | -- ^^^^^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `a` - | -note: move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:10 - | -LL | for &a in x.iter() { //~ ERROR cannot move out - | ^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:15 - | -LL | for &a in &f.a { //~ ERROR cannot move out - | -- ^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `a` - | -note: move occurs because `a` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:10 - | -LL | for &a in &f.a { //~ ERROR cannot move out - | ^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15 - | -LL | for &a in x.iter() { //~ ERROR cannot move out - | -- ^^^^^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `a` - | -note: move occurs because `a` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10 - | -LL | for &a in x.iter() { //~ ERROR cannot move out - | ^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr index 1a7e2cb69632c..8ba6a07b3d2d4 100644 --- a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr +++ b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr @@ -1,29 +1,47 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:9 + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:15 | LL | for &a in x.iter() { //~ ERROR cannot move out - | ^- + | -- ^^^^^^^^ cannot move out of borrowed content | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of borrowed content + | |data moved here + | help: consider removing the `&`: `a` + | +note: move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:10 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | ^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:9 + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:15 | LL | for &a in &f.a { //~ ERROR cannot move out - | ^- + | -- ^^^^ cannot move out of borrowed content | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of borrowed content + | |data moved here + | help: consider removing the `&`: `a` + | +note: move occurs because `a` has type `std::boxed::Box`, which does not implement the `Copy` trait + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:10 + | +LL | for &a in &f.a { //~ ERROR cannot move out + | ^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:9 + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15 | LL | for &a in x.iter() { //~ ERROR cannot move out - | ^- + | -- ^^^^^^^^ cannot move out of borrowed content | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of borrowed content + | |data moved here + | help: consider removing the `&`: `a` + | +note: move occurs because `a` has type `std::boxed::Box`, which does not implement the `Copy` trait + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | ^ error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr deleted file mode 100644 index 32ca24ba6ec43..0000000000000 --- a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-for-loop-head-linkage.rs:7:9 - | -LL | for &x in &vector { - | ------- - | | - | immutable borrow occurs here - | immutable borrow later used here -LL | let cap = vector.capacity(); -LL | vector.extend(repeat(0)); //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here - -error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-for-loop-head-linkage.rs:8:9 - | -LL | for &x in &vector { - | ------- - | | - | immutable borrow occurs here - | immutable borrow later used here -... -LL | vector[1] = 5; //~ ERROR cannot borrow - | ^^^^^^ mutable borrow occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr index 85008948a1c0f..32ca24ba6ec43 100644 --- a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr +++ b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr @@ -2,22 +2,22 @@ error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as i --> $DIR/borrowck-for-loop-head-linkage.rs:7:9 | LL | for &x in &vector { - | ------ - | | | - | | immutable borrow ends here - | immutable borrow occurs here + | ------- + | | + | immutable borrow occurs here + | immutable borrow later used here LL | let cap = vector.capacity(); LL | vector.extend(repeat(0)); //~ ERROR cannot borrow - | ^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable --> $DIR/borrowck-for-loop-head-linkage.rs:8:9 | LL | for &x in &vector { - | ------ - | | | - | | immutable borrow ends here - | immutable borrow occurs here + | ------- + | | + | immutable borrow occurs here + | immutable borrow later used here ... LL | vector[1] = 5; //~ ERROR cannot borrow | ^^^^^^ mutable borrow occurs here diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr deleted file mode 100644 index 618edf57bb26e..0000000000000 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `_a` because it is borrowed - --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:9:9 - | -LL | let b = &mut _a; - | -- borrow of `_a` occurs here -... -LL | _a = 4; //[ast]~ ERROR cannot assign to `_a` - | ^^^^^^ assignment to borrowed `_a` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr deleted file mode 100644 index d3708b5cf2bbb..0000000000000 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `_a` because it is borrowed - --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:9:9 - | -LL | let b = &mut _a; - | ------- borrow of `_a` occurs here -... -LL | _a = 4; //[ast]~ ERROR cannot assign to `_a` - | ^^^^^^ assignment to borrowed `_a` occurs here -... -LL | drop(b); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs index 334d2e008b956..97107c2e30f00 100644 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs +++ b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs @@ -1,13 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let mut _a = 3; let b = &mut _a; { let c = &*b; - _a = 4; //[ast]~ ERROR cannot assign to `_a` - //[mir]~^ ERROR cannot assign to `_a` because it is borrowed + _a = 4; //~ ERROR cannot assign to `_a` because it is borrowed drop(c); } drop(b); diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr similarity index 72% rename from src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr index d3708b5cf2bbb..5efb6648e2d87 100644 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr @@ -1,10 +1,10 @@ error[E0506]: cannot assign to `_a` because it is borrowed - --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:9:9 + --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:6:9 | LL | let b = &mut _a; | ------- borrow of `_a` occurs here ... -LL | _a = 4; //[ast]~ ERROR cannot assign to `_a` +LL | _a = 4; //~ ERROR cannot assign to `_a` because it is borrowed | ^^^^^^ assignment to borrowed `_a` occurs here ... LL | drop(b); diff --git a/src/test/ui/borrowck/borrowck-in-static.nll.stderr b/src/test/ui/borrowck/borrowck-in-static.nll.stderr deleted file mode 100644 index ff094ecf70746..0000000000000 --- a/src/test/ui/borrowck/borrowck-in-static.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/borrowck-in-static.rs:5:17 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable - | ^ cannot move out of captured variable in an `Fn` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-in-static.rs b/src/test/ui/borrowck/borrowck-in-static.rs index c08f4138bfb39..43bb652a024ff 100644 --- a/src/test/ui/borrowck/borrowck-in-static.rs +++ b/src/test/ui/borrowck/borrowck-in-static.rs @@ -2,7 +2,7 @@ static FN : &'static (Fn() -> (BoxBox>) + Sync) = &|| { let x = Box::new(0); - Box::new(|| x) //~ ERROR cannot move out of captured outer variable + Box::new(|| x) //~ ERROR cannot move out of captured variable in an `Fn` closure }; fn main() { diff --git a/src/test/ui/borrowck/borrowck-in-static.stderr b/src/test/ui/borrowck/borrowck-in-static.stderr index 400f3cd1c3e78..c4e8af9716bcd 100644 --- a/src/test/ui/borrowck/borrowck-in-static.stderr +++ b/src/test/ui/borrowck/borrowck-in-static.stderr @@ -1,10 +1,10 @@ -error[E0507]: cannot move out of captured outer variable in an `Fn` closure +error[E0507]: cannot move out of captured variable in an `Fn` closure --> $DIR/borrowck-in-static.rs:5:17 | LL | let x = Box::new(0); | - captured outer variable -LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable - | ^ cannot move out of captured outer variable in an `Fn` closure +LL | Box::new(|| x) //~ ERROR cannot move out of captured variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr deleted file mode 100644 index 35649b1bb2a50..0000000000000 --- a/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `origin` - --> $DIR/borrowck-init-in-fru.rs:12:5 - | -LL | origin = Point { x: 10, ..origin }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `origin.y` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.ast.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.ast.stderr deleted file mode 100644 index 3ba01098766dc..0000000000000 --- a/src/test/ui/borrowck/borrowck-init-in-fru.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `origin.y` - --> $DIR/borrowck-init-in-fru.rs:12:31 - | -LL | origin = Point { x: 10, ..origin }; - | ^^^^^^ use of possibly uninitialized `origin.y` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.rs b/src/test/ui/borrowck/borrowck-init-in-fru.rs index 9a06c7ab77286..6da3098dc9336 100644 --- a/src/test/ui/borrowck/borrowck-init-in-fru.rs +++ b/src/test/ui/borrowck/borrowck-init-in-fru.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #[derive(Clone)] struct Point { x: isize, @@ -10,7 +7,6 @@ struct Point { fn main() { let mut origin: Point; origin = Point { x: 10, ..origin }; - //[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381] - //[mir]~^^ ERROR [E0381] + //~^ ERROR use of possibly uninitialized variable: `origin` [E0381] origin.clone(); } diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.stderr similarity index 88% rename from src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr rename to src/test/ui/borrowck/borrowck-init-in-fru.stderr index 35649b1bb2a50..fe55bc2fd95c0 100644 --- a/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr +++ b/src/test/ui/borrowck/borrowck-init-in-fru.stderr @@ -1,5 +1,5 @@ error[E0381]: use of possibly uninitialized variable: `origin` - --> $DIR/borrowck-init-in-fru.rs:12:5 + --> $DIR/borrowck-init-in-fru.rs:9:5 | LL | origin = Point { x: 10, ..origin }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `origin.y` diff --git a/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr b/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr deleted file mode 100644 index b99d5e813c7c2..0000000000000 --- a/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0501]: cannot borrow `*f` as mutable because previous closure requires unique access - --> $DIR/borrowck-insert-during-each.rs:16:3 - | -LL | f.foo( - | ^ --- first borrow later used by call - | ___| - | | -LL | | |a| { //~ ERROR closure requires unique access to `f` - | | --- closure construction occurs here -LL | | f.n.insert(*a); - | | - first borrow occurs due to use of `f` in closure -LL | | }) - | |__________^ second borrow occurs here - -error[E0500]: closure requires unique access to `f` but it is already borrowed - --> $DIR/borrowck-insert-during-each.rs:17:9 - | -LL | f.foo( - | - --- first borrow later used by call - | | - | borrow occurs here -LL | |a| { //~ ERROR closure requires unique access to `f` - | ^^^ closure construction occurs here -LL | f.n.insert(*a); - | - second borrow occurs due to use of `f` in closure - -error: aborting due to 2 previous errors - -Some errors occurred: E0500, E0501. -For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-insert-during-each.rs b/src/test/ui/borrowck/borrowck-insert-during-each.rs index 025da4d613dbb..df967e6118932 100644 --- a/src/test/ui/borrowck/borrowck-insert-during-each.rs +++ b/src/test/ui/borrowck/borrowck-insert-during-each.rs @@ -13,7 +13,8 @@ impl Foo { } fn bar(f: &mut Foo) { - f.foo( + f.foo( + //~^ ERROR cannot borrow `*f` as mutable |a| { //~ ERROR closure requires unique access to `f` f.n.insert(*a); }) diff --git a/src/test/ui/borrowck/borrowck-insert-during-each.stderr b/src/test/ui/borrowck/borrowck-insert-during-each.stderr index 021b5b27ae702..e17f3f2b9c058 100644 --- a/src/test/ui/borrowck/borrowck-insert-during-each.stderr +++ b/src/test/ui/borrowck/borrowck-insert-during-each.stderr @@ -1,15 +1,32 @@ -error[E0500]: closure requires unique access to `f` but `*f` is already borrowed - --> $DIR/borrowck-insert-during-each.rs:17:9 +error[E0501]: cannot borrow `*f` as mutable because previous closure requires unique access + --> $DIR/borrowck-insert-during-each.rs:16:5 | -LL | f.foo( - | - borrow occurs here +LL | f.foo( + | ^ --- first borrow later used by call + | _____| + | | +LL | | //~^ ERROR cannot borrow `*f` as mutable +LL | | |a| { //~ ERROR closure requires unique access to `f` + | | --- closure construction occurs here +LL | | f.n.insert(*a); + | | - first borrow occurs due to use of `f` in closure +LL | | }) + | |__________^ second borrow occurs here + +error[E0500]: closure requires unique access to `f` but it is already borrowed + --> $DIR/borrowck-insert-during-each.rs:18:9 + | +LL | f.foo( + | - --- first borrow later used by call + | | + | borrow occurs here +LL | //~^ ERROR cannot borrow `*f` as mutable LL | |a| { //~ ERROR closure requires unique access to `f` | ^^^ closure construction occurs here LL | f.n.insert(*a); - | - borrow occurs due to use of `f` in closure -LL | }) - | - borrow ends here + | - second borrow occurs due to use of `f` in closure -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0500`. +Some errors occurred: E0500, E0501. +For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-issue-14498.ast.stderr b/src/test/ui/borrowck/borrowck-issue-14498.ast.stderr deleted file mode 100644 index 59249dadcb0a6..0000000000000 --- a/src/test/ui/borrowck/borrowck-issue-14498.ast.stderr +++ /dev/null @@ -1,82 +0,0 @@ -error[E0389]: cannot assign to data in a `&` reference - --> $DIR/borrowck-issue-14498.rs:19:5 - | -LL | ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference - | ^^^^^^^^ assignment into an immutable reference - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:29:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:40:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:51:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:62:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:73:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:84:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:95:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:106:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error: aborting due to 9 previous errors - -Some errors occurred: E0389, E0506. -For more information about an error, try `rustc --explain E0389`. diff --git a/src/test/ui/borrowck/borrowck-issue-14498.mir.stderr b/src/test/ui/borrowck/borrowck-issue-14498.mir.stderr deleted file mode 100644 index 81610536c52b8..0000000000000 --- a/src/test/ui/borrowck/borrowck-issue-14498.mir.stderr +++ /dev/null @@ -1,108 +0,0 @@ -error[E0594]: cannot assign to `***p` which is behind a `&` reference - --> $DIR/borrowck-issue-14498.rs:19:5 - | -LL | let p = &y; - | -- help: consider changing this to be a mutable reference: `&mut y` -LL | ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference - | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:29:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:40:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:51:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:62:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:73:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:84:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:95:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:106:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed -LL | drop(p); - | - borrow later used here - -error: aborting due to 9 previous errors - -Some errors occurred: E0506, E0594. -For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-issue-14498.rs b/src/test/ui/borrowck/borrowck-issue-14498.rs index da62c5a950731..e8c9019264fe7 100644 --- a/src/test/ui/borrowck/borrowck-issue-14498.rs +++ b/src/test/ui/borrowck/borrowck-issue-14498.rs @@ -4,9 +4,6 @@ // Also includes tests of the errors reported when the Box in question // is immutable (#14270). -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] struct A { a: isize } @@ -16,8 +13,7 @@ fn indirect_write_to_imm_box() { let mut x: isize = 1; let y: Box<_> = box &mut x; let p = &y; - ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference - //[mir]~^ ERROR cannot assign to `***p` + ***p = 2; //~ ERROR cannot assign to `***p` drop(p); } @@ -26,8 +22,7 @@ fn borrow_in_var_from_var() { let mut y: Box<_> = box &mut x; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -37,8 +32,7 @@ fn borrow_in_var_from_var_via_imm_box() { let y: Box<_> = box &mut x; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -48,8 +42,7 @@ fn borrow_in_var_from_field() { let mut y: Box<_> = box &mut x.a; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -59,8 +52,7 @@ fn borrow_in_var_from_field_via_imm_box() { let y: Box<_> = box &mut x.a; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -70,8 +62,7 @@ fn borrow_in_field_from_var() { let mut y = B { a: box &mut x }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -81,8 +72,7 @@ fn borrow_in_field_from_var_via_imm_box() { let y = B { a: box &mut x }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -92,8 +82,7 @@ fn borrow_in_field_from_field() { let mut y = B { a: box &mut x.a }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -103,8 +92,7 @@ fn borrow_in_field_from_field_via_imm_box() { let y = B { a: box &mut x.a }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } diff --git a/src/test/ui/borrowck/borrowck-issue-14498.ast.nll.stderr b/src/test/ui/borrowck/borrowck-issue-14498.stderr similarity index 61% rename from src/test/ui/borrowck/borrowck-issue-14498.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-issue-14498.stderr index 81610536c52b8..3ac58d339c6fd 100644 --- a/src/test/ui/borrowck/borrowck-issue-14498.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-issue-14498.stderr @@ -1,104 +1,96 @@ error[E0594]: cannot assign to `***p` which is behind a `&` reference - --> $DIR/borrowck-issue-14498.rs:19:5 + --> $DIR/borrowck-issue-14498.rs:16:5 | LL | let p = &y; | -- help: consider changing this to be a mutable reference: `&mut y` -LL | ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference +LL | ***p = 2; //~ ERROR cannot assign to `***p` | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:29:5 + --> $DIR/borrowck-issue-14498.rs:25:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed +LL | **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:40:5 + --> $DIR/borrowck-issue-14498.rs:35:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed +LL | **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:51:5 + --> $DIR/borrowck-issue-14498.rs:45:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed +LL | **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:62:5 + --> $DIR/borrowck-issue-14498.rs:55:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; -LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed +LL | **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:73:5 + --> $DIR/borrowck-issue-14498.rs:65:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed +LL | **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:84:5 + --> $DIR/borrowck-issue-14498.rs:75:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed +LL | **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:95:5 + --> $DIR/borrowck-issue-14498.rs:85:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed +LL | **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:106:5 + --> $DIR/borrowck-issue-14498.rs:95:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; -LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed +LL | **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed LL | drop(p); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-issue-2657-1.nll.stderr b/src/test/ui/borrowck/borrowck-issue-2657-1.nll.stderr deleted file mode 100644 index 3da8d8f8c4757..0000000000000 --- a/src/test/ui/borrowck/borrowck-issue-2657-1.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-issue-2657-1.rs:9:18 - | -LL | Some(ref _y) => { - | ------ borrow of `x.0` occurs here -LL | let _a = x; //~ ERROR cannot move - | ^ move out of `x` occurs here -LL | _y.use_ref(); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-issue-2657-1.stderr b/src/test/ui/borrowck/borrowck-issue-2657-1.stderr index 7663822094d86..3da8d8f8c4757 100644 --- a/src/test/ui/borrowck/borrowck-issue-2657-1.stderr +++ b/src/test/ui/borrowck/borrowck-issue-2657-1.stderr @@ -1,10 +1,12 @@ error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-issue-2657-1.rs:9:13 + --> $DIR/borrowck-issue-2657-1.rs:9:18 | LL | Some(ref _y) => { | ------ borrow of `x.0` occurs here LL | let _a = x; //~ ERROR cannot move - | ^^ move out of `x` occurs here + | ^ move out of `x` occurs here +LL | _y.use_ref(); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr b/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr deleted file mode 100644 index 061c458f73e58..0000000000000 --- a/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-issue-2657-2.rs:7:18 - | -LL | let _b = *y; //~ ERROR cannot move out - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `y` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-issue-2657-2.stderr b/src/test/ui/borrowck/borrowck-issue-2657-2.stderr index 7e718786caa37..061c458f73e58 100644 --- a/src/test/ui/borrowck/borrowck-issue-2657-2.stderr +++ b/src/test/ui/borrowck/borrowck-issue-2657-2.stderr @@ -5,7 +5,7 @@ LL | let _b = *y; //~ ERROR cannot move out | ^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*y` + | help: consider removing the `*`: `y` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr deleted file mode 100644 index 0c99edeb1a455..0000000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-lend-flow-if.rs:29:16 - | -LL | _w = &v; - | -- immutable borrow occurs here -LL | } -LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^^^^^^ mutable borrow occurs here -LL | _w.use_ref(); - | -- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-if.stderr b/src/test/ui/borrowck/borrowck-lend-flow-if.stderr index d1b6bb0c7c96c..0c99edeb1a455 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-if.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-if.stderr @@ -1,14 +1,13 @@ -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-if.rs:29:21 +error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-lend-flow-if.rs:29:16 | LL | _w = &v; - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | } LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^ mutable borrow occurs here + | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr deleted file mode 100644 index 1844d8275999d..0000000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr +++ /dev/null @@ -1,93 +0,0 @@ -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:35:17 - | -LL | let mut x = &mut v; - | - mutable borrow occurs here -... -LL | borrow(&*v); //[ast]~ ERROR cannot borrow - | ^^ immutable borrow occurs here -LL | } -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:45:17 - | -LL | let mut x = &mut v; - | - mutable borrow occurs here -LL | for _ in 0..3 { -LL | borrow(&*v); //[ast]~ ERROR cannot borrow - | ^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:57:25 - | -LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | _x = &v; - | - immutable borrow occurs here -LL | } -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:69:25 - | -LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | _x = &v; - | - immutable borrow occurs here -LL | } -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:86:21 - | -LL | _x = &v; - | - immutable borrow occurs here -... -LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:100:21 - | -LL | _x = &v; - | - immutable borrow occurs here -... -LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow - | ^^ mutable borrow occurs here -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:109:17 - | -LL | borrow(&*v); //[ast]~ ERROR cannot borrow - | ^^ immutable borrow occurs here -... -LL | x = &mut v; //[ast]~ ERROR cannot borrow - | - mutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/borrowck-lend-flow-loop.rs:112:22 - | -LL | x = &mut v; //[ast]~ ERROR cannot borrow - | ^ mutable borrow starts here in previous iteration of loop -... -LL | } - | - mutable borrow ends here - -error: aborting due to 8 previous errors - -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.rs b/src/test/ui/borrowck/borrowck-lend-flow-loop.rs index 7008e5cef4b75..b650df91ca23c 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.rs +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.rs @@ -1,19 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// Note: the borrowck analysis was originally a flow-insensitive pass -// over the AST. Therefore, some of these (AST) errors are marked as -// spurious and are corrected by the flow-sensitive (NLL) analysis. -// The others are either genuine or would require more advanced -// changes. The latter cases are noted. - #![feature(box_syntax)] fn borrow(_v: &isize) {} @@ -26,13 +10,13 @@ fn inc(v: &mut Box) { } fn loop_overarching_alias_mut() { - // In this instance, the borrow encompasses the entire loop. + // In this instance, the borrow ends on the line before the loop let mut v: Box<_> = box 3; let mut x = &mut v; **x += 1; loop { - borrow(&*v); //[ast]~ ERROR cannot borrow + borrow(&*v); // OK } } @@ -42,38 +26,37 @@ fn block_overarching_alias_mut() { let mut v: Box<_> = box 3; let mut x = &mut v; for _ in 0..3 { - borrow(&*v); //[ast]~ ERROR cannot borrow - //[nll]~^ ERROR cannot borrow + borrow(&*v); //~ ERROR cannot borrow } *x = box 5; } fn loop_aliased_mut() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; let mut _x = &w; loop { - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK _x = &v; } } fn while_aliased_mut() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; let mut _x = &w; while cond() { - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK _x = &v; } } fn loop_aliased_mut_break() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; @@ -83,11 +66,11 @@ fn loop_aliased_mut_break() { _x = &v; break; } - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK } fn while_aliased_mut_break() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; @@ -97,7 +80,7 @@ fn while_aliased_mut_break() { _x = &v; break; } - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK } fn while_aliased_mut_cond(cond: bool, cond2: bool) { @@ -106,10 +89,9 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) { let mut x = &mut w; while cond { **x += 1; - borrow(&*v); //[ast]~ ERROR cannot borrow - //[nll]~^ ERROR cannot borrow + borrow(&*v); //~ ERROR cannot borrow if cond2 { - x = &mut v; //[ast]~ ERROR cannot borrow + x = &mut v; // OK } } } diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.stderr similarity index 72% rename from src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr rename to src/test/ui/borrowck/borrowck-lend-flow-loop.stderr index 396fd6ffa0c6b..6e6701ad3eac7 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.stderr @@ -1,24 +1,24 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:45:16 + --> $DIR/borrowck-lend-flow-loop.rs:29:16 | LL | let mut x = &mut v; | ------ mutable borrow occurs here LL | for _ in 0..3 { -LL | borrow(&*v); //[ast]~ ERROR cannot borrow +LL | borrow(&*v); //~ ERROR cannot borrow | ^^^ immutable borrow occurs here -... +LL | } LL | *x = box 5; | -- mutable borrow later used here error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:109:16 + --> $DIR/borrowck-lend-flow-loop.rs:92:16 | LL | **x += 1; | -------- mutable borrow later used here -LL | borrow(&*v); //[ast]~ ERROR cannot borrow +LL | borrow(&*v); //~ ERROR cannot borrow | ^^^ immutable borrow occurs here -... -LL | x = &mut v; //[ast]~ ERROR cannot borrow +LL | if cond2 { +LL | x = &mut v; // OK | ------ mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.ast.stderr deleted file mode 100644 index 23eb814788f65..0000000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-lend-flow-match.rs:18:13 - | -LL | Some(ref r) => { - | ----- borrow of `x` occurs here -LL | x = Some(1); //[ast]~ ERROR cannot assign - | ^^^^^^^^^^^ assignment to borrowed `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.mir.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.mir.stderr deleted file mode 100644 index 02289e0f4ec98..0000000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-lend-flow-match.rs:18:13 - | -LL | Some(ref r) => { - | ----- borrow of `x` occurs here -LL | x = Some(1); //[ast]~ ERROR cannot assign - | ^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed -LL | drop(r); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.rs b/src/test/ui/borrowck/borrowck-lend-flow-match.rs index 4cd2a239b4e78..9737bc7695d10 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.rs +++ b/src/test/ui/borrowck/borrowck-lend-flow-match.rs @@ -1,11 +1,5 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![allow(unused_variables)] -#![allow(unused_assignments)] - fn separate_arms() { - // Here both arms perform assignments, but only is illegal. + // Here both arms perform assignments, but only one is illegal. let mut x = None; match x { @@ -15,12 +9,10 @@ fn separate_arms() { x = Some(0); } Some(ref r) => { - x = Some(1); //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = Some(1); //~ ERROR cannot assign to `x` because it is borrowed drop(r); } } - x.clone(); // just to prevent liveness warnings } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.stderr similarity index 68% rename from src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-lend-flow-match.stderr index 02289e0f4ec98..a4851f7221b17 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-match.stderr @@ -1,11 +1,10 @@ error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-lend-flow-match.rs:18:13 + --> $DIR/borrowck-lend-flow-match.rs:12:13 | LL | Some(ref r) => { | ----- borrow of `x` occurs here -LL | x = Some(1); //[ast]~ ERROR cannot assign +LL | x = Some(1); //~ ERROR cannot assign to `x` because it is borrowed | ^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed LL | drop(r); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr deleted file mode 100644 index ae3313597a3e4..0000000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-lend-flow.rs:24:16 - | -LL | let _w = &v; - | -- immutable borrow occurs here -LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^^^^^^ mutable borrow occurs here -LL | _w.use_ref(); - | -- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow.stderr b/src/test/ui/borrowck/borrowck-lend-flow.stderr index d9080d0055391..ae3313597a3e4 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow.stderr @@ -1,13 +1,12 @@ -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow.rs:24:21 +error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-lend-flow.rs:24:16 | LL | let _w = &v; - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | borrow_mut(&mut *v); //~ ERROR cannot borrow - | ^^ mutable borrow occurs here + | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.nll.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.nll.stderr deleted file mode 100644 index 4497cfb71d19a..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:14:19 - | -LL | let w = &v; - | -- borrow of `v` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `v` occurs here -LL | println!("v={}", *v); - | - move occurs due to use in closure -... -LL | w.use_ref(); - | - borrow later used here - -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 - | -LL | let w = &v; - | -- borrow of `v` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `v` occurs here -LL | println!("v={}", *v); - | - move occurs due to use in closure -... -LL | w.use_ref(); - | - borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs index 29a20473f4847..9fa46563fdf80 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs +++ b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs @@ -12,8 +12,8 @@ fn box_imm() { let v: Box<_> = box 3; let w = &v; thread::spawn(move|| { + //~^ ERROR cannot move out of `v` because it is borrowed println!("v={}", *v); - //~^ ERROR cannot move `v` into closure }); w.use_ref(); } @@ -22,8 +22,8 @@ fn box_imm_explicit() { let v: Box<_> = box 3; let w = &v; thread::spawn(move|| { + //~^ ERROR cannot move println!("v={}", *v); - //~^ ERROR cannot move }); w.use_ref(); } diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr index b170635b4b997..e64a1547cd209 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr +++ b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr @@ -1,21 +1,31 @@ -error[E0504]: cannot move `v` into closure because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:15:27 +error[E0505]: cannot move out of `v` because it is borrowed + --> $DIR/borrowck-loan-blocks-move-cc.rs:14:19 | LL | let w = &v; - | - borrow of `v` occurs here + | -- borrow of `v` occurs here LL | thread::spawn(move|| { + | ^^^^^^ move out of `v` occurs here +LL | //~^ ERROR cannot move out of `v` because it is borrowed LL | println!("v={}", *v); - | ^ move into closure occurs here + | - move occurs due to use in closure +LL | }); +LL | w.use_ref(); + | - borrow later used here -error[E0504]: cannot move `v` into closure because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:25:27 +error[E0505]: cannot move out of `v` because it is borrowed + --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 | LL | let w = &v; - | - borrow of `v` occurs here + | -- borrow of `v` occurs here LL | thread::spawn(move|| { + | ^^^^^^ move out of `v` occurs here +LL | //~^ ERROR cannot move LL | println!("v={}", *v); - | ^ move into closure occurs here + | - move occurs due to use in closure +LL | }); +LL | w.use_ref(); + | - borrow later used here error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0504`. +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move.nll.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move.nll.stderr deleted file mode 100644 index 450102f0c6622..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/borrowck-loan-blocks-move.rs:11:10 - | -LL | let w = &v; - | -- borrow of `v` occurs here -LL | take(v); //~ ERROR cannot move out of `v` because it is borrowed - | ^ move out of `v` occurs here -LL | w.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr index ba6e34c2ec826..450102f0c6622 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr +++ b/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/borrowck-loan-blocks-move.rs:11:10 | LL | let w = &v; - | - borrow of `v` occurs here + | -- borrow of `v` occurs here LL | take(v); //~ ERROR cannot move out of `v` because it is borrowed | ^ move out of `v` occurs here +LL | w.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr deleted file mode 100644 index 281a8103f9778..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-loan-blocks-mut-uniq.rs:10:12 - | -LL | borrow(&*v, - | ------ --- immutable borrow occurs here - | | - | immutable borrow later used by call -LL | |w| { //~ ERROR cannot borrow `v` as mutable - | ^^^ mutable borrow occurs here -LL | v = box 4; - | - second borrow occurs due to use of `v` in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr index 6aa2d5d189d25..281a8103f9778 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr +++ b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr @@ -1,15 +1,14 @@ -error[E0502]: cannot borrow `v` as mutable because `*v` is also borrowed as immutable +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-blocks-mut-uniq.rs:10:12 | LL | borrow(&*v, - | -- immutable borrow occurs here + | ------ --- immutable borrow occurs here + | | + | immutable borrow later used by call LL | |w| { //~ ERROR cannot borrow `v` as mutable | ^^^ mutable borrow occurs here LL | v = box 4; - | - borrow occurs due to use of `v` in closure -... -LL | }) - | - immutable borrow ends here + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.nll.stderr b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.nll.stderr deleted file mode 100644 index 095ae7f56b22e..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/borrowck-loan-in-overloaded-op.rs:21:20 - | -LL | let x = Foo(box 3); - | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait -LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur - | - ^ value borrowed here after move - | | - | value moved here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs index 464f01ca74c82..1baa94edfbe58 100644 --- a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs +++ b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs @@ -19,5 +19,5 @@ impl Add for Foo { fn main() { let x = Foo(box 3); let _y = {x} + x.clone(); // the `{x}` forces a move to occur - //~^ ERROR use of moved value: `x` + //~^ ERROR borrow of moved value: `x` } diff --git a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr index b6147aae8da5a..095ae7f56b22e 100644 --- a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr +++ b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/borrowck-loan-in-overloaded-op.rs:21:20 | +LL | let x = Foo(box 3); + | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur - | - ^ value used here after move + | - ^ value borrowed here after move | | | value moved here - | - = note: move occurs because `x` has type `Foo`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr b/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr deleted file mode 100644 index 6984575890308..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `*s` because it is borrowed - --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:16:5 - | -LL | let alias: &'static mut String = s; - | ------------------- - borrow of `*s` occurs here - | | - | type annotation requires that `*s` is borrowed for `'static` -... -LL | *s = String::new(); //~ ERROR cannot assign - | ^^ assignment to borrowed `*s` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr b/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr index eceb923e776b7..6984575890308 100644 --- a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr +++ b/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr @@ -2,10 +2,12 @@ error[E0506]: cannot assign to `*s` because it is borrowed --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:16:5 | LL | let alias: &'static mut String = s; - | - borrow of `*s` occurs here + | ------------------- - borrow of `*s` occurs here + | | + | type annotation requires that `*s` is borrowed for `'static` ... LL | *s = String::new(); //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^^^^ assignment to borrowed `*s` occurs here + | ^^ assignment to borrowed `*s` occurs here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr deleted file mode 100644 index 421af61ff78c3..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0503]: cannot use `p` because it was mutably borrowed - --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:38:5 - | -LL | let q = &mut p; - | ------ borrow of `p` occurs here -LL | -LL | p + 3; //~ ERROR cannot use `p` - | ^ use of borrowed `p` -... -LL | *q + 3; // OK to use the new alias `q` - | -- borrow later used here - -error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:39:5 - | -LL | let q = &mut p; - | ------ mutable borrow occurs here -... -LL | p.times(3); //~ ERROR cannot borrow `p` - | ^ immutable borrow occurs here -LL | -LL | *q + 3; // OK to use the new alias `q` - | -- mutable borrow later used here - -error: aborting due to 2 previous errors - -Some errors occurred: E0502, E0503. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr index b4f7a9af666f4..421af61ff78c3 100644 --- a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr +++ b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr @@ -2,22 +2,25 @@ error[E0503]: cannot use `p` because it was mutably borrowed --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:38:5 | LL | let q = &mut p; - | - borrow of `p` occurs here + | ------ borrow of `p` occurs here LL | LL | p + 3; //~ ERROR cannot use `p` | ^ use of borrowed `p` +... +LL | *q + 3; // OK to use the new alias `q` + | -- borrow later used here error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:39:5 | LL | let q = &mut p; - | - mutable borrow occurs here + | ------ mutable borrow occurs here ... LL | p.times(3); //~ ERROR cannot borrow `p` | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here +LL | +LL | *q + 3; // OK to use the new alias `q` + | -- mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr deleted file mode 100644 index bded4d1e0a3b3..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-loan-rcvr.rs:23:14 - | -LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable - | - ------ ^^ mutable borrow occurs here - | | | - | | immutable borrow later used by call - | immutable borrow occurs here -LL | p.x = 10; - | - second borrow occurs due to use of `p` in closure - -error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-loan-rcvr.rs:34:5 - | -LL | let l = &mut p; - | ------ mutable borrow occurs here -LL | p.impurem(); //~ ERROR cannot borrow - | ^ immutable borrow occurs here -LL | -LL | l.x += 1; - | -------- mutable borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr.stderr index eb0bbec0bc772..bded4d1e0a3b3 100644 --- a/src/test/ui/borrowck/borrowck-loan-rcvr.stderr +++ b/src/test/ui/borrowck/borrowck-loan-rcvr.stderr @@ -2,24 +2,23 @@ error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immuta --> $DIR/borrowck-loan-rcvr.rs:23:14 | LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable - | - ^^ mutable borrow occurs here - | | + | - ------ ^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call | immutable borrow occurs here LL | p.x = 10; - | - borrow occurs due to use of `p` in closure -LL | }) - | - immutable borrow ends here + | - second borrow occurs due to use of `p` in closure error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable --> $DIR/borrowck-loan-rcvr.rs:34:5 | LL | let l = &mut p; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | p.impurem(); //~ ERROR cannot borrow | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here +LL | +LL | l.x += 1; + | -------- mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr b/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr deleted file mode 100644 index be48f217ef19b..0000000000000 --- a/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-loan-vec-content.rs:18:9 - | -LL | takes_imm_elt( - | ------------- immutable borrow later used by call -LL | &v[0], - | - immutable borrow occurs here -LL | || { //~ ERROR cannot borrow `v` as mutable - | ^^ mutable borrow occurs here -LL | v[1] = 4; - | - second borrow occurs due to use of `v` in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-vec-content.stderr b/src/test/ui/borrowck/borrowck-loan-vec-content.stderr index 6a565ff2f10d4..be48f217ef19b 100644 --- a/src/test/ui/borrowck/borrowck-loan-vec-content.stderr +++ b/src/test/ui/borrowck/borrowck-loan-vec-content.stderr @@ -1,14 +1,14 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-vec-content.rs:18:9 | +LL | takes_imm_elt( + | ------------- immutable borrow later used by call LL | &v[0], | - immutable borrow occurs here LL | || { //~ ERROR cannot borrow `v` as mutable | ^^ mutable borrow occurs here LL | v[1] = 4; - | - borrow occurs due to use of `v` in closure -LL | }) - | - immutable borrow ends here + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr deleted file mode 100644 index 6eda8a439baa4..0000000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/borrowck-local-borrow-outlives-fn.rs:5:6 - | -LL | &x - | ^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr deleted file mode 100644 index df89e85ebe201..0000000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0515]: cannot return reference to function parameter `x` - --> $DIR/borrowck-local-borrow-outlives-fn.rs:5:5 - | -LL | &x - | ^^ returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs index 6137ac914ddfb..b6eebd4e3256f 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs +++ b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn cplusplus_mode(x: isize) -> &'static isize { &x - //[ast]~^ ERROR `x` does not live long enough [E0597] - //[mir]~^^ ERROR cannot return reference to function parameter `x` [E0515] + //~^ ERROR cannot return reference to function parameter `x` [E0515] } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.stderr similarity index 83% rename from src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.stderr index df89e85ebe201..9d19de211a5e0 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.stderr @@ -1,5 +1,5 @@ error[E0515]: cannot return reference to function parameter `x` - --> $DIR/borrowck-local-borrow-outlives-fn.rs:5:5 + --> $DIR/borrowck-local-borrow-outlives-fn.rs:2:5 | LL | &x | ^^ returns a reference to data owned by the current function diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr deleted file mode 100644 index 89a0e6cd8290c..0000000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `z.1` does not live long enough - --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:6:20 - | -LL | *x = Some(&mut z.1); - | ^^^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr deleted file mode 100644 index ac9e73fadec06..0000000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `z.1` does not live long enough - --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:6:15 - | -LL | *x = Some(&mut z.1); - | ----------^^^^^^^^- - | | | - | | borrowed value does not live long enough - | assignment requires that `z.1` is borrowed for `'static` -... -LL | } - | - `z.1` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs index 9ead465eadab7..ffb2da280232f 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs +++ b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs @@ -1,11 +1,7 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) { let mut z = (0, 0); *x = Some(&mut z.1); - //[ast]~^ ERROR `z.1` does not live long enough [E0597] - //[mir]~^^ ERROR `z.1` does not live long enough [E0597] + //~^ ERROR `z.1` does not live long enough [E0597] panic!("catch me for a dangling pointer!") } diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr similarity index 86% rename from src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr index ac9e73fadec06..6ea6951ad9665 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr @@ -1,5 +1,5 @@ error[E0597]: `z.1` does not live long enough - --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:6:15 + --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:3:15 | LL | *x = Some(&mut z.1); | ----------^^^^^^^^- diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr b/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr deleted file mode 100644 index cfbbef93f1f99..0000000000000 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0503]: cannot use `(foo as Foo::A).0` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:15:16 - | -LL | let p = &mut foo; - | --- borrow of `foo` occurs here -... -LL | Foo::A(x) => x //[ast]~ ERROR [E0503] - | ^ use of borrowed `foo` - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:26:9 - | -LL | let r = &mut x; - | - borrow of `x` occurs here -LL | let _ = match x { -LL | x => x + 1, //[ast]~ ERROR [E0503] - | ^ use of borrowed `x` - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:28:9 - | -LL | let r = &mut x; - | - borrow of `x` occurs here -... -LL | y => y + 2, //[ast]~ ERROR [E0503] - | ^ use of borrowed `x` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr b/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr deleted file mode 100644 index b2b82fba5b064..0000000000000 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error[E0503]: cannot use `foo` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:13:9 - | -LL | let p = &mut foo; - | -------- borrow of `foo` occurs here -LL | let _ = match foo { -LL | Foo::B => 1, //[mir]~ ERROR [E0503] - | ^^^^^^ use of borrowed `foo` -... -LL | drop(p); - | - borrow later used here - -error[E0503]: cannot use `foo.0` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:15:16 - | -LL | let p = &mut foo; - | -------- borrow of `foo` occurs here -... -LL | Foo::A(x) => x //[ast]~ ERROR [E0503] - | ^ use of borrowed `foo` -... -LL | drop(p); - | - borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:26:9 - | -LL | let r = &mut x; - | ------ borrow of `x` occurs here -LL | let _ = match x { -LL | x => x + 1, //[ast]~ ERROR [E0503] - | ^ use of borrowed `x` -... -LL | drop(r); - | - borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:28:9 - | -LL | let r = &mut x; - | ------ borrow of `x` occurs here -... -LL | y => y + 2, //[ast]~ ERROR [E0503] - | ^ use of borrowed `x` -... -LL | drop(r); - | - borrow later used here - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.rs b/src/test/ui/borrowck/borrowck-match-already-borrowed.rs index 7f4cdbd0e7c59..c766e6c108086 100644 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.rs +++ b/src/test/ui/borrowck/borrowck-match-already-borrowed.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - enum Foo { A(i32), B @@ -10,10 +7,9 @@ fn match_enum() { let mut foo = Foo::B; let p = &mut foo; let _ = match foo { - Foo::B => 1, //[mir]~ ERROR [E0503] + Foo::B => 1, //~ ERROR [E0503] _ => 2, - Foo::A(x) => x //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] + Foo::A(x) => x //~ ERROR [E0503] }; drop(p); } @@ -23,10 +19,8 @@ fn main() { let mut x = 1; let r = &mut x; let _ = match x { - x => x + 1, //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] - y => y + 2, //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] + x => x + 1, //~ ERROR [E0503] + y => y + 2, //~ ERROR [E0503] }; drop(r); } diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr b/src/test/ui/borrowck/borrowck-match-already-borrowed.stderr similarity index 73% rename from src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-match-already-borrowed.stderr index b2b82fba5b064..c96005032bf2d 100644 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-match-already-borrowed.stderr @@ -1,48 +1,48 @@ error[E0503]: cannot use `foo` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:13:9 + --> $DIR/borrowck-match-already-borrowed.rs:10:9 | LL | let p = &mut foo; | -------- borrow of `foo` occurs here LL | let _ = match foo { -LL | Foo::B => 1, //[mir]~ ERROR [E0503] +LL | Foo::B => 1, //~ ERROR [E0503] | ^^^^^^ use of borrowed `foo` ... LL | drop(p); | - borrow later used here error[E0503]: cannot use `foo.0` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:15:16 + --> $DIR/borrowck-match-already-borrowed.rs:12:16 | LL | let p = &mut foo; | -------- borrow of `foo` occurs here ... -LL | Foo::A(x) => x //[ast]~ ERROR [E0503] +LL | Foo::A(x) => x //~ ERROR [E0503] | ^ use of borrowed `foo` -... +LL | }; LL | drop(p); | - borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:26:9 + --> $DIR/borrowck-match-already-borrowed.rs:22:9 | LL | let r = &mut x; | ------ borrow of `x` occurs here LL | let _ = match x { -LL | x => x + 1, //[ast]~ ERROR [E0503] +LL | x => x + 1, //~ ERROR [E0503] | ^ use of borrowed `x` ... LL | drop(r); | - borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:28:9 + --> $DIR/borrowck-match-already-borrowed.rs:23:9 | LL | let r = &mut x; | ------ borrow of `x` occurs here ... -LL | y => y + 2, //[ast]~ ERROR [E0503] +LL | y => y + 2, //~ ERROR [E0503] | ^ use of borrowed `x` -... +LL | }; LL | drop(r); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.stderr deleted file mode 100644 index e7bd9dfee12f4..0000000000000 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:17:13 - | -LL | x => { - | - first assignment to `x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:24:13 - | -LL | E::Foo(x) => { - | - first assignment to `x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:31:13 - | -LL | S { bar: x } => { - | - first assignment to `x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 - | -LL | (x,) => { - | - first assignment to `x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:45:13 - | -LL | [x,_,_] => { - | - first assignment to `x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.stderr deleted file mode 100644 index cd88d69323895..0000000000000 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:17:13 - | -LL | x => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:24:13 - | -LL | E::Foo(x) => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:31:13 - | -LL | S { bar: x } => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 - | -LL | (x,) => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:45:13 - | -LL | [x,_,_] => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs index 2c9c41ca10e09..064bf69ae7900 100644 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs +++ b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Test that immutable pattern bindings cannot be reassigned. enum E { @@ -14,36 +11,31 @@ struct S { pub fn main() { match 1 { x => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match E::Foo(1) { E::Foo(x) => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match (S { bar: 1 }) { S { bar: x } => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match (1,) { (x,) => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match [1,2,3] { [x,_,_] => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } } diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr similarity index 71% rename from src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr index cd88d69323895..dc20bb77644e2 100644 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr @@ -1,56 +1,56 @@ error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:17:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:14:13 | LL | x => { | - | | | first assignment to `x` | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` +LL | x += 1; //~ ERROR [E0384] | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:24:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:20:13 | LL | E::Foo(x) => { | - | | | first assignment to `x` | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` +LL | x += 1; //~ ERROR [E0384] | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:31:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:26:13 | LL | S { bar: x } => { | - | | | first assignment to `x` | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` +LL | x += 1; //~ ERROR [E0384] | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:32:13 | LL | (x,) => { | - | | | first assignment to `x` | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` +LL | x += 1; //~ ERROR [E0384] | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:45:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 | LL | [x,_,_] => { | - | | | first assignment to `x` | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` +LL | x += 1; //~ ERROR [E0384] | ^^^^^^ cannot assign twice to immutable variable error: aborting due to 5 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-by-capture.nll.stderr b/src/test/ui/borrowck/borrowck-move-by-capture.nll.stderr deleted file mode 100644 index b8a0117441779..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-by-capture.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/borrowck-move-by-capture.rs:9:29 - | -LL | let bar: Box<_> = box 3; - | --- captured outer variable -LL | let _g = to_fn_mut(|| { -LL | let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of captured variable in an `FnMut` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-by-capture.stderr b/src/test/ui/borrowck/borrowck-move-by-capture.stderr index 9c485fb48ca74..b8a0117441779 100644 --- a/src/test/ui/borrowck/borrowck-move-by-capture.stderr +++ b/src/test/ui/borrowck/borrowck-move-by-capture.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of captured outer variable in an `FnMut` closure +error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/borrowck-move-by-capture.rs:9:29 | LL | let bar: Box<_> = box 3; | --- captured outer variable LL | let _g = to_fn_mut(|| { LL | let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of - | ^^^^^^^^^^^^^^^^ cannot move out of captured outer variable in an `FnMut` closure + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of captured variable in an `FnMut` closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr b/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr deleted file mode 100644 index 9386278886f6b..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-error-with-note.rs:11:11 - | -LL | match *f { //~ ERROR cannot move out of - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `f` -LL | //~| cannot move out -LL | Foo::Foo1(num1, - | ---- data moved here -LL | num2) => (), - | ---- ...and here -LL | Foo::Foo2(num) => (), - | --- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-move-error-with-note.rs:13:19 - | -LL | Foo::Foo1(num1, - | ^^^^ -LL | num2) => (), - | ^^^^ -LL | Foo::Foo2(num) => (), - | ^^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-error-with-note.rs:29:11 - | -LL | match (S {f: "foo".to_string(), g: "bar".to_string()}) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here -... -LL | f: _s, - | -- data moved here -LL | g: _t - | -- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-move-error-with-note.rs:32:16 - | -LL | f: _s, - | ^^ -LL | g: _t - | ^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-error-with-note.rs:47:11 - | -LL | match a.a { //~ ERROR cannot move out of - | ^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&a.a` -LL | //~| cannot move out -LL | n => { - | - data moved here - | -note: move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-error-with-note.rs:49:9 - | -LL | n => { - | ^ - -error: aborting due to 3 previous errors - -Some errors occurred: E0507, E0509. -For more information about an error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.rs b/src/test/ui/borrowck/borrowck-move-error-with-note.rs index d2dab2eacca42..b21f13a983c6b 100644 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.rs +++ b/src/test/ui/borrowck/borrowck-move-error-with-note.rs @@ -27,8 +27,9 @@ impl Drop for S { fn move_in_match() { match (S {f: "foo".to_string(), g: "bar".to_string()}) { - S { //~ ERROR cannot move out of type `S`, which implements the `Drop` trait + //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait //~| cannot move out of here + S { f: _s, g: _t } => {} diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr index 07009b42e4da1..e729023889e73 100644 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr +++ b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr @@ -2,35 +2,64 @@ error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-move-error-with-note.rs:11:11 | LL | match *f { //~ ERROR cannot move out of - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `f` LL | //~| cannot move out LL | Foo::Foo1(num1, - | ---- hint: to prevent move, use `ref num1` or `ref mut num1` + | ---- data moved here LL | num2) => (), - | ---- ...and here (use `ref num2` or `ref mut num2`) + | ---- ...and here LL | Foo::Foo2(num) => (), - | --- ...and here (use `ref num` or `ref mut num`) + | --- ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-move-error-with-note.rs:13:19 + | +LL | Foo::Foo1(num1, + | ^^^^ +LL | num2) => (), + | ^^^^ +LL | Foo::Foo2(num) => (), + | ^^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-error-with-note.rs:30:9 - | -LL | / S { //~ ERROR cannot move out of type `S`, which implements the `Drop` trait -LL | | //~| cannot move out of here -LL | | f: _s, - | | -- hint: to prevent move, use `ref _s` or `ref mut _s` -LL | | g: _t - | | -- ...and here (use `ref _t` or `ref mut _t`) -LL | | } => {} - | |_________^ cannot move out of here + --> $DIR/borrowck-move-error-with-note.rs:29:11 + | +LL | match (S {f: "foo".to_string(), g: "bar".to_string()}) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here +... +LL | f: _s, + | -- data moved here +LL | g: _t + | -- ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-move-error-with-note.rs:33:16 + | +LL | f: _s, + | ^^ +LL | g: _t + | ^^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-error-with-note.rs:47:11 + --> $DIR/borrowck-move-error-with-note.rs:48:11 | LL | match a.a { //~ ERROR cannot move out of - | ^ cannot move out of borrowed content + | ^^^ + | | + | cannot move out of borrowed content + | help: consider borrowing here: `&a.a` LL | //~| cannot move out LL | n => { - | - hint: to prevent move, use `ref n` or `ref mut n` + | - data moved here + | +note: move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-error-with-note.rs:50:9 + | +LL | n => { + | ^ error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.nll.stderr b/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.nll.stderr deleted file mode 100644 index b7fa2247e32f7..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `*a` because it is borrowed - --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:12:13 - | -LL | let b = &a; - | -- borrow of `a` occurs here -LL | -LL | let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed - | ^^ move out of `*a` occurs here -LL | b.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr b/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr index 2ed888051f61e..b7fa2247e32f7 100644 --- a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr +++ b/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr @@ -1,11 +1,13 @@ error[E0505]: cannot move out of `*a` because it is borrowed - --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:12:9 + --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:12:13 | LL | let b = &a; - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | LL | let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed - | ^ move out of `*a` occurs here + | ^^ move out of `*a` occurs here +LL | b.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr deleted file mode 100644 index 5b78465795362..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of dereference of raw pointer - --> $DIR/borrowck-move-from-unsafe-ptr.rs:2:13 - | -LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer - | ^^ - | | - | cannot move out of dereference of raw pointer - | help: consider removing the `*`: `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr index 62a522600388d..5b78465795362 100644 --- a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr @@ -5,7 +5,7 @@ LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer | ^^ | | | cannot move out of dereference of raw pointer - | help: consider using a reference instead: `&*x` + | help: consider removing the `*`: `x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr deleted file mode 100644 index c18fce9f4fd55..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:13 - | -LL | fn arg_item(&_x: &String) {} - | ^-- - | || - | |data moved here - | cannot move out of borrowed content - | help: consider removing the `&`: `_x` - | -note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:14 - | -LL | fn arg_item(&_x: &String) {} - | ^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:11 - | -LL | with(|&_x| ()) - | ^-- - | || - | |data moved here - | cannot move out of borrowed content - | help: consider removing the `&`: `_x` - | -note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:12 - | -LL | with(|&_x| ()) - | ^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:15 - | -LL | let &_x = &"hi".to_string(); - | --- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `_x` - | -note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:10 - | -LL | let &_x = &"hi".to_string(); - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.stderr b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.stderr deleted file mode 100644 index 019ed96661fc2..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:13 - | -LL | fn arg_item(&_x: &String) {} - | ^-- - | || - | |hint: to prevent move, use `ref _x` or `ref mut _x` - | cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:11 - | -LL | with(|&_x| ()) - | ^-- - | || - | |hint: to prevent move, use `ref _x` or `ref mut _x` - | cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:9 - | -LL | let &_x = &"hi".to_string(); - | ^-- - | || - | |hint: to prevent move, use `ref _x` or `ref mut _x` - | cannot move out of borrowed content - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs index c63f4f60bef48..f4f402dd96ab6 100644 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs +++ b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs @@ -1,22 +1,16 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn with(f: F) where F: FnOnce(&String) {} fn arg_item(&_x: &String) {} - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] fn arg_closure() { with(|&_x| ()) - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] } fn let_pat() { let &_x = &"hi".to_string(); - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] } pub fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.mir.stderr b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.stderr similarity index 82% rename from src/test/ui/borrowck/borrowck-move-in-irrefut-pat.mir.stderr rename to src/test/ui/borrowck/borrowck-move-in-irrefut-pat.stderr index c18fce9f4fd55..d38c05ca36ef8 100644 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.mir.stderr +++ b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:13 + --> $DIR/borrowck-move-in-irrefut-pat.rs:3:13 | LL | fn arg_item(&_x: &String) {} | ^-- @@ -9,13 +9,13 @@ LL | fn arg_item(&_x: &String) {} | help: consider removing the `&`: `_x` | note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:14 + --> $DIR/borrowck-move-in-irrefut-pat.rs:3:14 | LL | fn arg_item(&_x: &String) {} | ^^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:11 + --> $DIR/borrowck-move-in-irrefut-pat.rs:7:11 | LL | with(|&_x| ()) | ^-- @@ -25,13 +25,13 @@ LL | with(|&_x| ()) | help: consider removing the `&`: `_x` | note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:12 + --> $DIR/borrowck-move-in-irrefut-pat.rs:7:12 | LL | with(|&_x| ()) | ^^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:15 + --> $DIR/borrowck-move-in-irrefut-pat.rs:12:15 | LL | let &_x = &"hi".to_string(); | --- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content @@ -40,7 +40,7 @@ LL | let &_x = &"hi".to_string(); | help: consider removing the `&`: `_x` | note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:10 + --> $DIR/borrowck-move-in-irrefut-pat.rs:12:10 | LL | let &_x = &"hi".to_string(); | ^^ diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr deleted file mode 100644 index 0789926563ce7..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0382]: use of moved value: `t` - --> $DIR/borrowck-move-moved-value-into-closure.rs:14:12 - | -LL | let t: Box<_> = box 3; - | - move occurs because `t` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | -LL | call_f(move|| { *t + 1 }); - | ------ - variable moved due to use in closure - | | - | value moved into closure here -LL | call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value - | ^^^^^^ - use occurs due to use in closure - | | - | value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.stderr deleted file mode 100644 index 308dac8329294..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: capture of moved value: `t` - --> $DIR/borrowck-move-moved-value-into-closure.rs:14:22 - | -LL | call_f(move|| { *t + 1 }); - | ------ value moved (into closure) here -LL | call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value - | ^ value captured here after move - | - = note: move occurs because `t` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs index 271553370e3fb..233d0a733e316 100644 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs +++ b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] fn call_f isize>(f: F) -> isize { @@ -11,6 +8,5 @@ fn main() { let t: Box<_> = box 3; call_f(move|| { *t + 1 }); - call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value - //[mir]~^ ERROR use of moved value + call_f(move|| { *t + 1 }); //~ ERROR use of moved value } diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.mir.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.stderr similarity index 81% rename from src/test/ui/borrowck/borrowck-move-moved-value-into-closure.mir.stderr rename to src/test/ui/borrowck/borrowck-move-moved-value-into-closure.stderr index 0789926563ce7..222e62c6db576 100644 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.mir.stderr +++ b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `t` - --> $DIR/borrowck-move-moved-value-into-closure.rs:14:12 + --> $DIR/borrowck-move-moved-value-into-closure.rs:11:12 | LL | let t: Box<_> = box 3; | - move occurs because `t` has type `std::boxed::Box`, which does not implement the `Copy` trait @@ -8,7 +8,7 @@ LL | call_f(move|| { *t + 1 }); | ------ - variable moved due to use in closure | | | value moved into closure here -LL | call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value +LL | call_f(move|| { *t + 1 }); //~ ERROR use of moved value | ^^^^^^ - use occurs due to use in closure | | | value used here after move diff --git a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-move-mut-base-ptr.nll.stderr deleted file mode 100644 index ce6433d5a527f..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `t0` because it is borrowed - --> $DIR/borrowck-move-mut-base-ptr.rs:10:14 - | -LL | let p: &isize = &*t0; // Freezes `*t0` - | ---- borrow of `*t0` occurs here -LL | let t1 = t0; //~ ERROR cannot move out of `t0` - | ^^ move out of `t0` occurs here -LL | *t1 = 22; -LL | p.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr b/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr index 224bf0fded875..ce6433d5a527f 100644 --- a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr @@ -1,10 +1,13 @@ error[E0505]: cannot move out of `t0` because it is borrowed - --> $DIR/borrowck-move-mut-base-ptr.rs:10:9 + --> $DIR/borrowck-move-mut-base-ptr.rs:10:14 | LL | let p: &isize = &*t0; // Freezes `*t0` - | --- borrow of `*t0` occurs here + | ---- borrow of `*t0` occurs here LL | let t1 = t0; //~ ERROR cannot move out of `t0` - | ^^ move out of `t0` occurs here + | ^^ move out of `t0` occurs here +LL | *t1 = 22; +LL | p.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array.mir.stderr deleted file mode 100644 index f866ff9e9bae1..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-from-array.mir.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:10:14 - | -LL | let [_, _x] = a; - | -- value moved here -LL | let [.., _y] = a; //[ast]~ ERROR [E0382] - | ^^ value used here after move - | - = note: move occurs because `a[..]` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:17:10 - | -LL | let [_x, _] = a; - | -- value moved here -LL | let [_y..] = a; //[ast]~ ERROR [E0382] - | ^^ value used here after move - | - = note: move occurs because `a[..]` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.rs b/src/test/ui/borrowck/borrowck-move-out-from-array.rs index 503e7b99525eb..856b03edd2d72 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array.rs +++ b/src/test/ui/borrowck/borrowck-move-out-from-array.rs @@ -1,21 +1,16 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] #![feature(slice_patterns)] fn move_out_from_begin_and_end() { let a = [box 1, box 2]; let [_, _x] = a; - let [.., _y] = a; //[ast]~ ERROR [E0382] - //[mir]~^ ERROR [E0382] + let [.., _y] = a; //~ ERROR [E0382] } fn move_out_by_const_index_and_subslice() { let a = [box 1, box 2]; let [_x, _] = a; - let [_y..] = a; //[ast]~ ERROR [E0382] - //[mir]~^ ERROR [E0382] + let [_y..] = a; //~ ERROR [E0382] } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr similarity index 77% rename from src/test/ui/borrowck/borrowck-move-out-from-array.ast.stderr rename to src/test/ui/borrowck/borrowck-move-out-from-array.stderr index f866ff9e9bae1..dab2990509eaa 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array.ast.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr @@ -1,19 +1,19 @@ error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:10:14 + --> $DIR/borrowck-move-out-from-array.rs:7:14 | LL | let [_, _x] = a; | -- value moved here -LL | let [.., _y] = a; //[ast]~ ERROR [E0382] +LL | let [.., _y] = a; //~ ERROR [E0382] | ^^ value used here after move | = note: move occurs because `a[..]` has type `std::boxed::Box`, which does not implement the `Copy` trait error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:17:10 + --> $DIR/borrowck-move-out-from-array.rs:13:10 | LL | let [_x, _] = a; | -- value moved here -LL | let [_y..] = a; //[ast]~ ERROR [E0382] +LL | let [_y..] = a; //~ ERROR [E0382] | ^^ value used here after move | = note: move occurs because `a[..]` has type `std::boxed::Box`, which does not implement the `Copy` trait diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr deleted file mode 100644 index e55898aca5c06..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:7:14 - | -LL | let _x = Rc::new(vec![1, 2]).into_iter(); - | ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr deleted file mode 100644 index 81afb104c9d4d..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of an `Rc` - --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:7:14 - | -LL | let _x = Rc::new(vec![1, 2]).into_iter(); - | ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs index 5ced89478dc9c..0b9e7102cd54f 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::rc::Rc; pub fn main() { let _x = Rc::new(vec![1, 2]).into_iter(); - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr similarity index 81% rename from src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr index 81afb104c9d4d..7dc8e1749b5e3 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of an `Rc` - --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:7:14 + --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:4:14 | LL | let _x = Rc::new(vec![1, 2]).into_iter(); | ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc` diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr deleted file mode 100644 index e6af992c4d95b..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of an `Rc` - --> $DIR/borrowck-move-out-of-overloaded-deref.rs:4:14 - | -LL | let _x = *Rc::new("hi".to_string()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | cannot move out of an `Rc` - | help: consider removing the `*`: `Rc::new("hi".to_string())` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs index d5b60139fa6b1..ecb135f68d5af 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs @@ -2,5 +2,5 @@ use std::rc::Rc; pub fn main() { let _x = *Rc::new("hi".to_string()); - //~^ ERROR cannot move out of borrowed content + //~^ ERROR cannot move out of an `Rc` } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr index cd8d146ab1eaa..e6af992c4d95b 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of an `Rc` --> $DIR/borrowck-move-out-of-overloaded-deref.rs:4:14 | LL | let _x = *Rc::new("hi".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | cannot move out of borrowed content - | help: consider using a reference instead: `&*Rc::new("hi".to_string())` + | cannot move out of an `Rc` + | help: consider removing the `*`: `Rc::new("hi".to_string())` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-out-of-static-item.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-of-static-item.mir.stderr deleted file mode 100644 index 752d5330e0279..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-static-item.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of static item - --> $DIR/borrowck-move-out-of-static-item.rs:18:10 - | -LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] - | ^^^ cannot move out of static item - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs b/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs index d68d5de5c014b..8bb48a1d45f99 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Ensure that moves out of static items is forbidden struct Foo { @@ -15,6 +12,5 @@ fn test(f: Foo) { } fn main() { - test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] - //[mir]~^ ERROR [E0507] + test(BAR); //~ ERROR cannot move out of static item [E0507] } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-of-static-item.stderr similarity index 61% rename from src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.stderr rename to src/test/ui/borrowck/borrowck-move-out-of-static-item.stderr index 752d5330e0279..accddd916b635 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-static-item.stderr @@ -1,7 +1,7 @@ error[E0507]: cannot move out of static item - --> $DIR/borrowck-move-out-of-static-item.rs:18:10 + --> $DIR/borrowck-move-out-of-static-item.rs:15:10 | -LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] +LL | test(BAR); //~ ERROR cannot move out of static item [E0507] | ^^^ cannot move out of static item error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr deleted file mode 100644 index 0b025fa175a5f..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:12:9 - | -LL | S {f:_s} => {} - | ^^^^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:9 - | -LL | let S {f:_s} = S {f:"foo".to_string()}; - | ^^^^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:19 - | -LL | fn move_in_fn_arg(S {f:_s}: S) { - | ^^^^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr deleted file mode 100644 index 7025ce08fedf6..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:10:11 - | -LL | match (S {f:"foo".to_string()}) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here -LL | //[mir]~^ ERROR [E0509] -LL | S {f:_s} => {} - | -- data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:12:14 - | -LL | S {f:_s} => {} - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:20 - | -LL | let S {f:_s} = S {f:"foo".to_string()}; - | -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here - | | - | data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:14 - | -LL | let S {f:_s} = S {f:"foo".to_string()}; - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:19 - | -LL | fn move_in_fn_arg(S {f:_s}: S) { - | ^^^^^--^ - | | | - | | data moved here - | cannot move out of here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:24 - | -LL | fn move_in_fn_arg(S {f:_s}: S) { - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs index cdd71d889ab2f..a429f4bc33b06 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct S {f:String} impl Drop for S { fn drop(&mut self) { println!("{}", self.f); } @@ -8,21 +5,18 @@ impl Drop for S { fn move_in_match() { match (S {f:"foo".to_string()}) { - //[mir]~^ ERROR [E0509] + //~^ ERROR [E0509] S {f:_s} => {} - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] } } fn move_in_let() { let S {f:_s} = S {f:"foo".to_string()}; - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn move_in_fn_arg(S {f:_s}: S) { - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.stderr similarity index 78% rename from src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.stderr index 7025ce08fedf6..536c5dcbd4724 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.stderr @@ -1,20 +1,20 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:10:11 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:7:11 | LL | match (S {f:"foo".to_string()}) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here -LL | //[mir]~^ ERROR [E0509] +LL | //~^ ERROR [E0509] LL | S {f:_s} => {} | -- data moved here | note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:12:14 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:9:14 | LL | S {f:_s} => {} | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:20 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:14:20 | LL | let S {f:_s} = S {f:"foo".to_string()}; | -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here @@ -22,13 +22,13 @@ LL | let S {f:_s} = S {f:"foo".to_string()}; | data moved here | note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:14 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:14:14 | LL | let S {f:_s} = S {f:"foo".to_string()}; | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:19 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:19 | LL | fn move_in_fn_arg(S {f:_s}: S) { | ^^^^^--^ @@ -37,7 +37,7 @@ LL | fn move_in_fn_arg(S {f:_s}: S) { | cannot move out of here | note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:24 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:24 | LL | fn move_in_fn_arg(S {f:_s}: S) { | ^^ diff --git a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr deleted file mode 100644 index cecba15acce96..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:7:11 - | -LL | match S("foo".to_string()) { - | ^^^^^^^^^^^^^^^^^^^^ cannot move out of here -LL | S(_s) => {} - | -- data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:8:11 - | -LL | S(_s) => {} - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:17 - | -LL | let S(_s) = S("foo".to_string()); - | -- ^^^^^^^^^^^^^^^^^^^^ cannot move out of here - | | - | data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:11 - | -LL | let S(_s) = S("foo".to_string()); - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:19 - | -LL | fn move_in_fn_arg(S(_s): S) { - | ^^--^ - | | | - | | data moved here - | cannot move out of here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:21 - | -LL | fn move_in_fn_arg(S(_s): S) { - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs index bb294111add7e..5bd32f82ebc44 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs @@ -5,8 +5,8 @@ impl Drop for S { fn move_in_match() { match S("foo".to_string()) { - S(_s) => {} //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait + S(_s) => {} } } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr index 134b5e3481efd..760aaa3dc3783 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr @@ -1,20 +1,31 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:8:9 + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:7:11 | +LL | match S("foo".to_string()) { + | ^^^^^^^^^^^^^^^^^^^^ cannot move out of here +LL | //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait LL | S(_s) => {} - | ^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here + | -- data moved here + | +note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:9:11 + | +LL | S(_s) => {} + | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:9 + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:17 | LL | let S(_s) = S("foo".to_string()); - | ^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here + | -- ^^^^^^^^^^^^^^^^^^^^ cannot move out of here + | | + | data moved here + | +note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:11 + | +LL | let S(_s) = S("foo".to_string()); + | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:19 @@ -22,8 +33,14 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait LL | fn move_in_fn_arg(S(_s): S) { | ^^--^ | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` + | | data moved here | cannot move out of here + | +note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:21 + | +LL | fn move_in_fn_arg(S(_s): S) { + | ^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr deleted file mode 100644 index 9aaeefd4cfc32..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0508]: cannot move out of type `[Foo]`, a non-copy slice - --> $DIR/borrowck-move-out-of-vec-tail.rs:19:19 - | -LL | match tail { - | ^^^^ cannot move out of here -LL | &[Foo { string: a }, - | - data moved here -... -LL | Foo { string: b }] => { - | - ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-move-out-of-vec-tail.rs:20:33 - | -LL | &[Foo { string: a }, - | ^ -... -LL | Foo { string: b }] => { - | ^ -help: consider removing the `&` - | -LL | [Foo { string: a }, -LL | //~^ ERROR cannot move out of type `[Foo]` -LL | //~| cannot move out -LL | //~| to prevent move -LL | Foo { string: b }] => { - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs index 5f6e01f2df0ff..cc524c1ac3e6e 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs @@ -17,10 +17,8 @@ pub fn main() { match *x { [_, ref tail..] => { match tail { + //~^ ERROR cannot move out of type `[Foo]` &[Foo { string: a }, - //~^ ERROR cannot move out of type `[Foo]` - //~| cannot move out - //~| to prevent move Foo { string: b }] => { } _ => { diff --git a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr index 156ba0d4d7bb2..f6bc6928fa520 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr @@ -1,17 +1,26 @@ error[E0508]: cannot move out of type `[Foo]`, a non-copy slice - --> $DIR/borrowck-move-out-of-vec-tail.rs:20:18 + --> $DIR/borrowck-move-out-of-vec-tail.rs:19:19 + | +LL | match tail { + | ^^^^ cannot move out of here +LL | //~^ ERROR cannot move out of type `[Foo]` +LL | &[Foo { string: a }, + | - data moved here +LL | Foo { string: b }] => { + | - ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-move-out-of-vec-tail.rs:21:33 + | +LL | &[Foo { string: a }, + | ^ +LL | Foo { string: b }] => { + | ^ +help: consider removing the `&` + | +LL | [Foo { string: a }, +LL | Foo { string: b }] => { | -LL | &[Foo { string: a }, - | ^ - hint: to prevent move, use `ref a` or `ref mut a` - | __________________| - | | -LL | | //~^ ERROR cannot move out of type `[Foo]` -LL | | //~| cannot move out -LL | | //~| to prevent move -LL | | Foo { string: b }] => { - | |_________________________________-__^ cannot move out of here - | | - | ...and here (use `ref b` or `ref mut b`) error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-subcomponent.nll.stderr b/src/test/ui/borrowck/borrowck-move-subcomponent.nll.stderr deleted file mode 100644 index 3bb5351f97ba3..0000000000000 --- a/src/test/ui/borrowck/borrowck-move-subcomponent.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `a.x` because it is borrowed - --> $DIR/borrowck-move-subcomponent.rs:15:14 - | -LL | let pb = &a; - | -- borrow of `a` occurs here -LL | let S { x: ax } = a; //~ ERROR cannot move out - | ^^ move out of `a.x` occurs here -LL | f(pb); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-move-subcomponent.stderr b/src/test/ui/borrowck/borrowck-move-subcomponent.stderr index 187cdbbf81565..3bb5351f97ba3 100644 --- a/src/test/ui/borrowck/borrowck-move-subcomponent.stderr +++ b/src/test/ui/borrowck/borrowck-move-subcomponent.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `a.x` because it is borrowed --> $DIR/borrowck-move-subcomponent.rs:15:14 | LL | let pb = &a; - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | let S { x: ax } = a; //~ ERROR cannot move out | ^^ move out of `a.x` occurs here +LL | f(pb); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-multiple-captures.nll.stderr b/src/test/ui/borrowck/borrowck-multiple-captures.nll.stderr deleted file mode 100644 index d0065a2e7dc3d..0000000000000 --- a/src/test/ui/borrowck/borrowck-multiple-captures.nll.stderr +++ /dev/null @@ -1,103 +0,0 @@ -error[E0505]: cannot move out of `x1` because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:12:19 - | -LL | let p1 = &x1; - | --- borrow of `x1` occurs here -... -LL | thread::spawn(move|| { - | ^^^^^^ move out of `x1` occurs here -LL | drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed - | -- move occurs due to use in closure -... -LL | borrow(&*p1); - | ---- borrow later used here - -error[E0505]: cannot move out of `x2` because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:12:19 - | -LL | let p2 = &x2; - | --- borrow of `x2` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `x2` occurs here -LL | drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed -LL | drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed - | -- move occurs due to use in closure -... -LL | borrow(&*p2); - | ---- borrow later used here - -error[E0382]: use of moved value: `x1` - --> $DIR/borrowck-multiple-captures.rs:25:19 - | -LL | let x1: Box<_> = box 1; - | -- move occurs because `x1` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | drop(x1); - | -- value moved here -... -LL | thread::spawn(move|| { - | ^^^^^^ value used here after move -LL | drop(x1); //~ ERROR capture of moved value: `x1` - | -- use occurs due to use in closure - -error[E0382]: use of moved value: `x2` - --> $DIR/borrowck-multiple-captures.rs:25:19 - | -LL | let x2: Box<_> = box 2; - | -- move occurs because `x2` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | drop(x2); - | -- value moved here -LL | thread::spawn(move|| { - | ^^^^^^ value used here after move -LL | drop(x1); //~ ERROR capture of moved value: `x1` -LL | drop(x2); //~ ERROR capture of moved value: `x2` - | -- use occurs due to use in closure - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:36:14 - | -LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed - | - value moved here -LL | drop(x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:34:19 - | -LL | let p = &x; - | -- borrow of `x` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `x` occurs here -LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed - | - move occurs due to use in closure -... -LL | borrow(&*p); - | --- borrow later used here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:46:14 - | -LL | drop(x); //~ ERROR capture of moved value: `x` - | - value moved here -LL | drop(x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:44:19 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | drop(x); - | - value moved here -LL | thread::spawn(move|| { - | ^^^^^^ value used here after move -LL | drop(x); //~ ERROR capture of moved value: `x` - | - use occurs due to use in closure - -error: aborting due to 8 previous errors - -Some errors occurred: E0382, E0505. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-multiple-captures.rs b/src/test/ui/borrowck/borrowck-multiple-captures.rs index ad753781cd60f..9f09f8442c044 100644 --- a/src/test/ui/borrowck/borrowck-multiple-captures.rs +++ b/src/test/ui/borrowck/borrowck-multiple-captures.rs @@ -10,8 +10,10 @@ fn different_vars_after_borrows() { let x2: Box<_> = box 2; let p2 = &x2; thread::spawn(move|| { - drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed - drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed + //~^ ERROR cannot move out of `x1` because it is borrowed + //~| ERROR cannot move out of `x2` because it is borrowed + drop(x1); + drop(x2); }); borrow(&*p1); borrow(&*p2); @@ -23,8 +25,10 @@ fn different_vars_after_moves() { let x2: Box<_> = box 2; drop(x2); thread::spawn(move|| { - drop(x1); //~ ERROR capture of moved value: `x1` - drop(x2); //~ ERROR capture of moved value: `x2` + //~^ ERROR use of moved value: `x1` + //~| ERROR use of moved value: `x2` + drop(x1); + drop(x2); }); } @@ -32,7 +36,8 @@ fn same_var_after_borrow() { let x: Box<_> = box 1; let p = &x; thread::spawn(move|| { - drop(x); //~ ERROR cannot move `x` into closure because it is borrowed + //~^ ERROR cannot move out of `x` because it is borrowed + drop(x); drop(x); //~ ERROR use of moved value: `x` }); borrow(&*p); @@ -42,7 +47,8 @@ fn same_var_after_move() { let x: Box<_> = box 1; drop(x); thread::spawn(move|| { - drop(x); //~ ERROR capture of moved value: `x` + //~^ ERROR use of moved value: `x` + drop(x); drop(x); //~ ERROR use of moved value: `x` }); } diff --git a/src/test/ui/borrowck/borrowck-multiple-captures.stderr b/src/test/ui/borrowck/borrowck-multiple-captures.stderr index 3cdd094260833..0e20dc1558db4 100644 --- a/src/test/ui/borrowck/borrowck-multiple-captures.stderr +++ b/src/test/ui/borrowck/borrowck-multiple-captures.stderr @@ -1,84 +1,107 @@ -error[E0504]: cannot move `x1` into closure because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:13:14 +error[E0505]: cannot move out of `x1` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:12:19 | LL | let p1 = &x1; - | -- borrow of `x1` occurs here + | --- borrow of `x1` occurs here ... -LL | drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed - | ^^ move into closure occurs here +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x1` occurs here +... +LL | drop(x1); + | -- move occurs due to use in closure +... +LL | borrow(&*p1); + | ---- borrow later used here -error[E0504]: cannot move `x2` into closure because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:14:14 +error[E0505]: cannot move out of `x2` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:12:19 | LL | let p2 = &x2; - | -- borrow of `x2` occurs here + | --- borrow of `x2` occurs here +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x2` occurs here ... -LL | drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed - | ^^ move into closure occurs here +LL | drop(x2); + | -- move occurs due to use in closure +... +LL | borrow(&*p2); + | ---- borrow later used here -error[E0382]: capture of moved value: `x1` - --> $DIR/borrowck-multiple-captures.rs:26:14 +error[E0382]: use of moved value: `x1` + --> $DIR/borrowck-multiple-captures.rs:27:19 | +LL | let x1: Box<_> = box 1; + | -- move occurs because `x1` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | drop(x1); | -- value moved here ... -LL | drop(x1); //~ ERROR capture of moved value: `x1` - | ^^ value captured here after move - | - = note: move occurs because `x1` has type `std::boxed::Box`, which does not implement the `Copy` trait +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move +... +LL | drop(x1); + | -- use occurs due to use in closure -error[E0382]: capture of moved value: `x2` - --> $DIR/borrowck-multiple-captures.rs:27:14 +error[E0382]: use of moved value: `x2` + --> $DIR/borrowck-multiple-captures.rs:27:19 | +LL | let x2: Box<_> = box 2; + | -- move occurs because `x2` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | drop(x2); | -- value moved here -... -LL | drop(x2); //~ ERROR capture of moved value: `x2` - | ^^ value captured here after move - | - = note: move occurs because `x2` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0504]: cannot move `x` into closure because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:35:14 - | -LL | let p = &x; - | - borrow of `x` occurs here LL | thread::spawn(move|| { -LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed - | ^ move into closure occurs here + | ^^^^^^ value used here after move +... +LL | drop(x2); + | -- use occurs due to use in closure error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:36:14 + --> $DIR/borrowck-multiple-captures.rs:41:14 | -LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed +LL | drop(x); | - value moved here LL | drop(x); //~ ERROR use of moved value: `x` | ^ value used here after move | = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -error[E0382]: capture of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:45:14 +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:38:19 | -LL | drop(x); - | - value moved here +LL | let p = &x; + | -- borrow of `x` occurs here LL | thread::spawn(move|| { -LL | drop(x); //~ ERROR capture of moved value: `x` - | ^ value captured here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^^^^^^ move out of `x` occurs here +LL | //~^ ERROR cannot move out of `x` because it is borrowed +LL | drop(x); + | - move occurs due to use in closure +... +LL | borrow(&*p); + | --- borrow later used here error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:46:14 + --> $DIR/borrowck-multiple-captures.rs:52:14 | -LL | drop(x); //~ ERROR capture of moved value: `x` +LL | drop(x); | - value moved here LL | drop(x); //~ ERROR use of moved value: `x` | ^ value used here after move | = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:49:19 + | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +LL | drop(x); + | - value moved here +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move +LL | //~^ ERROR use of moved value: `x` +LL | drop(x); + | - use occurs due to use in closure + error: aborting due to 8 previous errors -Some errors occurred: E0382, E0504. +Some errors occurred: E0382, E0505. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr b/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr deleted file mode 100644 index be69be6341172..0000000000000 --- a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-mut-addr-of-imm-var.rs:3:25 - | -LL | let x: isize = 3; - | - help: consider changing this to be mutable: `mut x` -LL | let y: &mut isize = &mut x; //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr b/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr index 95635f7f67031..be69be6341172 100644 --- a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr +++ b/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/borrowck-mut-addr-of-imm-var.rs:3:30 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/borrowck-mut-addr-of-imm-var.rs:3:25 | LL | let x: isize = 3; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | let y: &mut isize = &mut x; //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr deleted file mode 100644 index dafb60c959afd..0000000000000 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:13:35 - | -LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ^ mutable borrow starts here in previous iteration of loop -... -LL | } - | - mutable borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:15:35 - | -LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | - first mutable borrow occurs here -LL | //[mir]~^ ERROR [E0499] -LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:17:35 - | -LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | - first mutable borrow occurs here -... -LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr deleted file mode 100644 index 0f07776533608..0000000000000 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:13:30 - | -LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ---- ^^^^^^ second mutable borrow occurs here - | | - | first borrow later used here -... -LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ------ first mutable borrow occurs here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:15:30 - | -LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ---- first borrow later used here -LL | //[mir]~^ ERROR [E0499] -LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR [E0499] -LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ------ first mutable borrow occurs here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:17:30 - | -LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ^^^^^^ mutable borrow starts here in previous iteration of loop - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs index bb0b26ecf0663..e3d76398bc26f 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs @@ -2,20 +2,14 @@ // conflicts with a new loan, as opposed to every issued loan. This keeps us // down to O(n) errors (for n problem lines), instead of O(n^2) errors. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let mut x = 1; let mut addr = vec![]; loop { match 1 { - 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] - 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] - _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] + 1 => { addr.push(&mut x); } //~ ERROR [E0499] + 2 => { addr.push(&mut x); } //~ ERROR [E0499] + _ => { addr.push(&mut x); } //~ ERROR [E0499] } } } diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr similarity index 56% rename from src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr index 0f07776533608..869a7b3afb246 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr @@ -1,30 +1,28 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:13:30 + --> $DIR/borrowck-mut-borrow-linear-errors.rs:10:30 | -LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] +LL | 1 => { addr.push(&mut x); } //~ ERROR [E0499] | ---- ^^^^^^ second mutable borrow occurs here | | | first borrow later used here -... -LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] +LL | 2 => { addr.push(&mut x); } //~ ERROR [E0499] +LL | _ => { addr.push(&mut x); } //~ ERROR [E0499] | ------ first mutable borrow occurs here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:15:30 + --> $DIR/borrowck-mut-borrow-linear-errors.rs:11:30 | -LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] +LL | 1 => { addr.push(&mut x); } //~ ERROR [E0499] | ---- first borrow later used here -LL | //[mir]~^ ERROR [E0499] -LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] +LL | 2 => { addr.push(&mut x); } //~ ERROR [E0499] | ^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR [E0499] -LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] +LL | _ => { addr.push(&mut x); } //~ ERROR [E0499] | ------ first mutable borrow occurs here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:17:30 + --> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30 | -LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] +LL | _ => { addr.push(&mut x); } //~ ERROR [E0499] | ^^^^^^ mutable borrow starts here in previous iteration of loop error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr deleted file mode 100644 index 666ccf35a7c9b..0000000000000 --- a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:18 - | -LL | let p: &isize = &*t0; // Freezes `*t0` - | ---- immutable borrow occurs here -LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` - | ^^^^^^^ mutable borrow occurs here -LL | **t2 += 1; // Mutates `*t0` -LL | p.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `t0` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18 - | -LL | let p: &mut isize = &mut *t0; // Claims `*t0` - | -------- first mutable borrow occurs here -LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` - | ^^^^^^^ second mutable borrow occurs here -LL | **t2 += 1; // Mutates `*t0` but not through `*p` -LL | p.use_mut(); - | - first borrow later used here - -error: aborting due to 2 previous errors - -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr index 154a283b43b5b..666ccf35a7c9b 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr @@ -1,24 +1,24 @@ -error[E0502]: cannot borrow `t0` as mutable because `*t0` is also borrowed as immutable - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:23 +error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:18 | LL | let p: &isize = &*t0; // Freezes `*t0` - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` - | ^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^ mutable borrow occurs here +LL | **t2 += 1; // Mutates `*t0` +LL | p.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `t0` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:23 + --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18 | LL | let p: &mut isize = &mut *t0; // Claims `*t0` - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` - | ^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^ second mutable borrow occurs here +LL | **t2 += 1; // Mutates `*t0` but not through `*p` +LL | p.use_mut(); + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr b/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr deleted file mode 100644 index 5a9ec98a2db06..0000000000000 --- a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable - --> $DIR/borrowck-mut-slice-of-imm-vec.rs:7:11 - | -LL | let v = vec![1, 2, 3]; - | - help: consider changing this to be mutable: `mut v` -LL | write(&mut v); //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr b/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr index 41ee2adf8aa0c..5a9ec98a2db06 100644 --- a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr +++ b/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `v` as mutable - --> $DIR/borrowck-mut-slice-of-imm-vec.rs:7:16 +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable + --> $DIR/borrowck-mut-slice-of-imm-vec.rs:7:11 | LL | let v = vec![1, 2, 3]; - | - help: make this binding mutable: `mut v` + | - help: consider changing this to be mutable: `mut v` LL | write(&mut v); //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr b/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr deleted file mode 100644 index c1b794fc86e3b..0000000000000 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0302]: cannot assign in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:10:25 - | -LL | Enum::A(_) if { x = Enum::B(false); false } => 1, - | ^^^^^^^^^^^^^^^^^^ assignment in pattern guard - -error[E0301]: cannot mutably borrow in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:12:38 - | -LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - | ^ borrowed mutably in pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error[E0302]: cannot assign in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:12:41 - | -LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - | ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard - -error: aborting due to 3 previous errors - -Some errors occurred: E0301, E0302. -For more information about an error, try `rustc --explain E0301`. diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr index 9e40856deb031..c1b794fc86e3b 100644 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr +++ b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr @@ -9,6 +9,8 @@ error[E0301]: cannot mutably borrow in a pattern guard | LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, | ^ borrowed mutably in pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error[E0302]: cannot assign in a pattern guard --> $DIR/borrowck-mutate-in-guard.rs:12:41 diff --git a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr b/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr deleted file mode 100644 index b106708352ef6..0000000000000 --- a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-no-cycle-in-exchange-heap.rs:16:15 - | -LL | Cycle::Node(ref mut y) => { - | --------- borrow of `x.0` occurs here -LL | y.a = x; //~ ERROR cannot move out of - | --- ^ move out of `x` occurs here - | | - | borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr b/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr index 5aaf825a3c368..b106708352ef6 100644 --- a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr +++ b/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr @@ -4,7 +4,9 @@ error[E0505]: cannot move out of `x` because it is borrowed LL | Cycle::Node(ref mut y) => { | --------- borrow of `x.0` occurs here LL | y.a = x; //~ ERROR cannot move out of - | ^ move out of `x` occurs here + | --- ^ move out of `x` occurs here + | | + | borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr b/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr deleted file mode 100644 index ff0cc93323257..0000000000000 --- a/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-object-lifetime.rs:20:13 - | -LL | let y = x.borrowed(); - | - immutable borrow occurs here -LL | let z = x.mut_borrowed(); //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | y.use_ref(); - | - immutable borrow later used here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-object-lifetime.rs:26:13 - | -LL | let y = x.borrowed(); - | - immutable borrow occurs here -LL | let z = &mut x; //~ ERROR cannot borrow - | ^^^^^^ mutable borrow occurs here -LL | y.use_ref(); - | - immutable borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-object-lifetime.stderr b/src/test/ui/borrowck/borrowck-object-lifetime.stderr index b22d05b8a2a82..ff0cc93323257 100644 --- a/src/test/ui/borrowck/borrowck-object-lifetime.stderr +++ b/src/test/ui/borrowck/borrowck-object-lifetime.stderr @@ -4,21 +4,19 @@ error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immut LL | let y = x.borrowed(); | - immutable borrow occurs here LL | let z = x.mut_borrowed(); //~ ERROR cannot borrow - | ^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | y.use_ref(); -LL | } - | - immutable borrow ends here + | - immutable borrow later used here -error[E0502]: cannot borrow `x` as mutable because `*x` is also borrowed as immutable - --> $DIR/borrowck-object-lifetime.rs:26:18 +error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-object-lifetime.rs:26:13 | LL | let y = x.borrowed(); | - immutable borrow occurs here LL | let z = &mut x; //~ ERROR cannot borrow - | ^ mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); -LL | } - | - immutable borrow ends here + | - immutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-or-init.nll.stderr b/src/test/ui/borrowck/borrowck-or-init.nll.stderr deleted file mode 100644 index dcd2c18dcaa23..0000000000000 --- a/src/test/ui/borrowck/borrowck-or-init.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `i` - --> $DIR/borrowck-or-init.rs:5:20 - | -LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` - | ^ use of possibly uninitialized `i` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-or-init.rs b/src/test/ui/borrowck/borrowck-or-init.rs index 5b1487831a689..c0d6c9c2739b2 100644 --- a/src/test/ui/borrowck/borrowck-or-init.rs +++ b/src/test/ui/borrowck/borrowck-or-init.rs @@ -2,5 +2,5 @@ fn main() { let i: isize; println!("{}", false || { i = 5; true }); - println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i` } diff --git a/src/test/ui/borrowck/borrowck-or-init.stderr b/src/test/ui/borrowck/borrowck-or-init.stderr index 60024c08303ac..babbed6d4812c 100644 --- a/src/test/ui/borrowck/borrowck-or-init.stderr +++ b/src/test/ui/borrowck/borrowck-or-init.stderr @@ -1,7 +1,7 @@ -error[E0381]: use of possibly uninitialized variable: `i` +error[E0381]: borrow of possibly uninitialized variable: `i` --> $DIR/borrowck-or-init.rs:5:20 | -LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` +LL | println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i` | ^ use of possibly uninitialized `i` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr deleted file mode 100644 index c5a4c4e005aa7..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-call.rs:59:5 - | -LL | let sp = &mut s; - | ------ mutable borrow occurs here -LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - | ^ immutable borrow occurs here -LL | use_mut(sp); - | -- mutable borrow later used here - -error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable - --> $DIR/borrowck-overloaded-call.rs:67:5 - | -LL | let s = SFnMut { - | - help: consider changing this to be mutable: `mut s` -... -LL | s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable - | ^ cannot borrow as mutable - -error[E0382]: use of moved value: `s` - --> $DIR/borrowck-overloaded-call.rs:75:5 - | -LL | let s = SFnOnce { - | - move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait -... -LL | s(" world".to_string()); - | - value moved here -LL | s(" world".to_string()); //~ ERROR use of moved value: `s` - | ^ value used here after move - -error: aborting due to 3 previous errors - -Some errors occurred: E0382, E0502, E0596. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.rs b/src/test/ui/borrowck/borrowck-overloaded-call.rs index 8601449b331a3..7b16bf666d062 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-call.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-call.rs @@ -64,7 +64,7 @@ fn g() { x: 1, y: 2, }; - s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable + s(3); //~ ERROR cannot borrow `s` as mutable, as it is not declared as mutable } fn h() { diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.stderr b/src/test/ui/borrowck/borrowck-overloaded-call.stderr index 0429226130656..f71d87d55d671 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-call.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-call.stderr @@ -2,31 +2,31 @@ error[E0502]: cannot borrow `s` as immutable because it is also borrowed as muta --> $DIR/borrowck-overloaded-call.rs:59:5 | LL | let sp = &mut s; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable | ^ immutable borrow occurs here LL | use_mut(sp); -LL | } - | - mutable borrow ends here + | -- mutable borrow later used here -error[E0596]: cannot borrow immutable local variable `s` as mutable +error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable --> $DIR/borrowck-overloaded-call.rs:67:5 | LL | let s = SFnMut { - | - help: make this binding mutable: `mut s` + | - help: consider changing this to be mutable: `mut s` ... -LL | s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable - | ^ cannot borrow mutably +LL | s(3); //~ ERROR cannot borrow `s` as mutable, as it is not declared as mutable + | ^ cannot borrow as mutable error[E0382]: use of moved value: `s` --> $DIR/borrowck-overloaded-call.rs:75:5 | +LL | let s = SFnOnce { + | - move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait +... LL | s(" world".to_string()); | - value moved here LL | s(" world".to_string()); //~ ERROR use of moved value: `s` | ^ value used here after move - | - = note: move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr deleted file mode 100644 index 59841ee2dbedd..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `v` because it is borrowed - --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:34:5 - | -LL | let i = &v[0].f; - | - borrow of `v` occurs here -LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr deleted file mode 100644 index f33fb55f9cdfc..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `v` because it is borrowed - --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:34:5 - | -LL | let i = &v[0].f; - | - borrow of `v` occurs here -LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here -... -LL | read(*i); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs index 348d99f4f9898..0e3e01a9332cf 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs @@ -3,9 +3,6 @@ // operator. The accounting of the all the implicit things going on // here is rather subtle. Issue #20232. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::ops::{Deref, Index}; struct MyVec { x: T } @@ -32,8 +29,7 @@ fn main() { let mut v = MyVec { x: MyPtr { x: Foo { f: 22 } } }; let i = &v[0].f; v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - //[ast]~^ ERROR cannot assign to `v` - //[mir]~^^ ERROR cannot assign to `v` because it is borrowed + //~^ ERROR cannot assign to `v` because it is borrowed read(*i); } diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr similarity index 77% rename from src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr index f33fb55f9cdfc..ab1c4feba80fc 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `v` because it is borrowed - --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:34:5 + --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:31:5 | LL | let i = &v[0].f; | - borrow of `v` occurs here LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here -... +LL | //~^ ERROR cannot assign to `v` because it is borrowed LL | read(*i); | -- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr deleted file mode 100644 index 13ace0178f892..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr +++ /dev/null @@ -1,84 +0,0 @@ -error[E0502]: cannot borrow `*f` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-autoderef.rs:37:14 - | -LL | let p = &mut f[&s]; - | - mutable borrow occurs here -LL | let q = &f[&s]; //~ ERROR cannot borrow - | ^ immutable borrow occurs here -LL | p.use_mut(); - | - mutable borrow later used here - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/borrowck-overloaded-index-autoderef.rs:43:18 - | -LL | let p = &mut f[&s]; - | - first mutable borrow occurs here -LL | let q = &mut f[&s]; //~ ERROR cannot borrow - | ^ second mutable borrow occurs here -LL | p.use_mut(); - | - first borrow later used here - -error[E0499]: cannot borrow `f.foo` as mutable more than once at a time - --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 - | -LL | let p = &mut f.foo[&s]; - | ----- first mutable borrow occurs here -LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow - | ^^^^^ second mutable borrow occurs here -LL | p.use_mut(); - | - first borrow later used here - -error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-overloaded-index-autoderef.rs:65:18 - | -LL | let p = &f.foo[&s]; - | ----- immutable borrow occurs here -LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow - | ^^^^^ mutable borrow occurs here -LL | p.use_ref(); - | - immutable borrow later used here - -error[E0506]: cannot assign to `f.foo` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:71:5 - | -LL | let p = &f.foo[&s]; - | ----- borrow of `f.foo` occurs here -LL | f.foo = g; //~ ERROR cannot assign - | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here -LL | p.use_ref(); - | - borrow later used here - -error[E0506]: cannot assign to `*f` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:77:5 - | -LL | let p = &f.foo[&s]; - | ----- borrow of `*f` occurs here -LL | *f = g; //~ ERROR cannot assign - | ^^^^^^ assignment to borrowed `*f` occurs here -LL | p.use_ref(); - | - borrow later used here - -error[E0506]: cannot assign to `f.foo` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:83:5 - | -LL | let p = &mut f.foo[&s]; - | ----- borrow of `f.foo` occurs here -LL | f.foo = g; //~ ERROR cannot assign - | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here -LL | p.use_mut(); - | - borrow later used here - -error[E0506]: cannot assign to `*f` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 - | -LL | let p = &mut f.foo[&s]; - | ----- borrow of `*f` occurs here -LL | *f = g; //~ ERROR cannot assign - | ^^^^^^ assignment to borrowed `*f` occurs here -LL | p.use_mut(); - | - borrow later used here - -error: aborting due to 8 previous errors - -Some errors occurred: E0499, E0502, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr index 9bc83f84339c7..13ace0178f892 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr @@ -6,8 +6,7 @@ LL | let p = &mut f[&s]; LL | let q = &f[&s]; //~ ERROR cannot borrow | ^ immutable borrow occurs here LL | p.use_mut(); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:43:18 @@ -17,8 +16,7 @@ LL | let p = &mut f[&s]; LL | let q = &mut f[&s]; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | p.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error[E0499]: cannot borrow `f.foo` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 @@ -28,8 +26,7 @@ LL | let p = &mut f.foo[&s]; LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow | ^^^^^ second mutable borrow occurs here LL | p.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-overloaded-index-autoderef.rs:65:18 @@ -39,8 +36,7 @@ LL | let p = &f.foo[&s]; LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow | ^^^^^ mutable borrow occurs here LL | p.use_ref(); -LL | } - | - immutable borrow ends here + | - immutable borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:71:5 @@ -49,6 +45,8 @@ LL | let p = &f.foo[&s]; | ----- borrow of `f.foo` occurs here LL | f.foo = g; //~ ERROR cannot assign | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here +LL | p.use_ref(); + | - borrow later used here error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:77:5 @@ -57,6 +55,8 @@ LL | let p = &f.foo[&s]; | ----- borrow of `*f` occurs here LL | *f = g; //~ ERROR cannot assign | ^^^^^^ assignment to borrowed `*f` occurs here +LL | p.use_ref(); + | - borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:83:5 @@ -65,6 +65,8 @@ LL | let p = &mut f.foo[&s]; | ----- borrow of `f.foo` occurs here LL | f.foo = g; //~ ERROR cannot assign | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here +LL | p.use_mut(); + | - borrow later used here error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 @@ -73,6 +75,8 @@ LL | let p = &mut f.foo[&s]; | ----- borrow of `*f` occurs here LL | *f = g; //~ ERROR cannot assign | ^^^^^^ assignment to borrowed `*f` occurs here +LL | p.use_mut(); + | - borrow later used here error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr deleted file mode 100644 index dbd805f1d2652..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-overloaded-index-move-from-vec.rs:20:15 - | -LL | let bad = v[0]; - | ^^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&v[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs index 76dd97ea242e3..b3060824f87ab 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs @@ -18,5 +18,5 @@ fn main() { let v = MyVec::> { data: vec![box 1, box 2, box 3] }; let good = &v[0]; // Shouldn't fail here let bad = v[0]; - //~^ ERROR cannot move out of indexed content + //~^ ERROR cannot move out of borrowed content } diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr index fe655dc8b131f..dbd805f1d2652 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-overloaded-index-move-from-vec.rs:20:15 | LL | let bad = v[0]; | ^^^^ | | - | cannot move out of indexed content - | help: consider using a reference instead: `&v[0]` + | cannot move out of borrowed content + | help: consider borrowing here: `&v[0]` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr deleted file mode 100644 index de60067f1a613..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0505]: cannot move out of `s` because it is borrowed - --> $DIR/borrowck-overloaded-index-move-index.rs:50:22 - | -LL | let rs = &mut s; - | ------ borrow of `s` occurs here -LL | -LL | println!("{}", f[s]); - | ^ move out of `s` occurs here -... -LL | use_mut(rs); - | -- borrow later used here - -error[E0505]: cannot move out of `s` because it is borrowed - --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 - | -LL | let rs = &mut s; - | ------ borrow of `s` occurs here -... -LL | f[s] = 10; - | ^ move out of `s` occurs here -... -LL | use_mut(rs); - | -- borrow later used here - -error[E0382]: use of moved value: `s` - --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 - | -LL | let mut s = "hello".to_string(); - | ----- move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | println!("{}", f[s]); - | - value moved here -... -LL | f[s] = 10; - | ^ value used here after move - -error: aborting due to 3 previous errors - -Some errors occurred: E0382, E0505. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr index 7ea311f3e7f2f..de60067f1a613 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr @@ -2,30 +2,37 @@ error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:50:22 | LL | let rs = &mut s; - | - borrow of `s` occurs here + | ------ borrow of `s` occurs here LL | LL | println!("{}", f[s]); | ^ move out of `s` occurs here +... +LL | use_mut(rs); + | -- borrow later used here error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 | LL | let rs = &mut s; - | - borrow of `s` occurs here + | ------ borrow of `s` occurs here ... LL | f[s] = 10; | ^ move out of `s` occurs here +... +LL | use_mut(rs); + | -- borrow later used here error[E0382]: use of moved value: `s` --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 | +LL | let mut s = "hello".to_string(); + | ----- move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait +... LL | println!("{}", f[s]); | - value moved here ... LL | f[s] = 10; | ^ value used here after move - | - = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.stderr deleted file mode 100644 index f97f0464fc009..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0594]: cannot assign to immutable indexed content - --> $DIR/borrowck-overloaded-index-ref-index.rs:61:5 - | -LL | s[2] = 20; - | ^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Bar` - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:52:23 - | -LL | let rs = &mut s; - | - mutable borrow occurs here -LL | println!("{}", f[&s]); - | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:55:8 - | -LL | let rs = &mut s; - | - mutable borrow occurs here -... -LL | f[&s] = 10; - | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error: aborting due to 3 previous errors - -Some errors occurred: E0502, E0594. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr deleted file mode 100644 index 2010e8f496245..0000000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:52:22 - | -LL | let rs = &mut s; - | ------ mutable borrow occurs here -LL | println!("{}", f[&s]); - | ^^ immutable borrow occurs here -... -LL | drop(rs); - | -- mutable borrow later used here - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:55:7 - | -LL | let rs = &mut s; - | ------ mutable borrow occurs here -... -LL | f[&s] = 10; - | ^^ immutable borrow occurs here -... -LL | drop(rs); - | -- mutable borrow later used here - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-overloaded-index-ref-index.rs:61:5 - | -LL | s[2] = 20; - | ^^^^^^^^^ cannot assign - -error: aborting due to 3 previous errors - -Some errors occurred: E0502, E0594. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs index 53cab520e4361..cb20873432b7c 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::ops::{Index, IndexMut}; struct Foo { @@ -50,16 +47,13 @@ fn main() { let mut s = "hello".to_string(); let rs = &mut s; println!("{}", f[&s]); - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable f[&s] = 10; - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable let s = Bar { x: 1, }; s[2] = 20; - //[ast]~^ ERROR cannot assign to immutable indexed content - //[mir]~^^ ERROR cannot assign to data in a `&` reference + //~^ ERROR cannot assign to data in a `&` reference drop(rs); } diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.stderr similarity index 84% rename from src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-overloaded-index-ref-index.stderr index 2010e8f496245..b54de1f0bf179 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:52:22 + --> $DIR/borrowck-overloaded-index-ref-index.rs:49:22 | LL | let rs = &mut s; | ------ mutable borrow occurs here @@ -10,7 +10,7 @@ LL | drop(rs); | -- mutable borrow later used here error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:55:7 + --> $DIR/borrowck-overloaded-index-ref-index.rs:51:7 | LL | let rs = &mut s; | ------ mutable borrow occurs here @@ -22,7 +22,7 @@ LL | drop(rs); | -- mutable borrow later used here error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-overloaded-index-ref-index.rs:61:5 + --> $DIR/borrowck-overloaded-index-ref-index.rs:56:5 | LL | s[2] = 20; | ^^^^^^^^^ cannot assign diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-1.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-1.nll.stderr deleted file mode 100644 index 65f2bd6cfbda9..0000000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-1.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0382]: assign of moved value: `t` - --> $DIR/borrowck-partial-reinit-1.rs:27:5 - | -LL | let mut t = Test2 { b: None }; - | ----- move occurs because `t` has type `Test2`, which does not implement the `Copy` trait -LL | let u = Test; -LL | drop(t); - | - value moved here -LL | t.b = Some(u); - | ^^^ value assigned here after move - -error[E0382]: assign of moved value: `t` - --> $DIR/borrowck-partial-reinit-1.rs:33:5 - | -LL | let mut t = Test3(None); - | ----- move occurs because `t` has type `Test3`, which does not implement the `Copy` trait -LL | let u = Test; -LL | drop(t); - | - value moved here -LL | t.0 = Some(u); - | ^^^ value assigned here after move - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-1.rs b/src/test/ui/borrowck/borrowck-partial-reinit-1.rs index f763759152cb3..4e695158154e7 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-1.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-1.rs @@ -25,13 +25,13 @@ fn stuff() { let u = Test; drop(t); t.b = Some(u); - //~^ ERROR partial reinitialization of uninitialized structure `t` + //~^ ERROR assign of moved value: `t` let mut t = Test3(None); let u = Test; drop(t); t.0 = Some(u); - //~^ ERROR partial reinitialization of uninitialized structure `t` + //~^ ERROR assign of moved value: `t` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr index 23f5035369d62..65f2bd6cfbda9 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr @@ -1,15 +1,25 @@ -error[E0383]: partial reinitialization of uninitialized structure `t` +error[E0382]: assign of moved value: `t` --> $DIR/borrowck-partial-reinit-1.rs:27:5 | +LL | let mut t = Test2 { b: None }; + | ----- move occurs because `t` has type `Test2`, which does not implement the `Copy` trait +LL | let u = Test; +LL | drop(t); + | - value moved here LL | t.b = Some(u); - | ^^^^^^^^^^^^^ + | ^^^ value assigned here after move -error[E0383]: partial reinitialization of uninitialized structure `t` +error[E0382]: assign of moved value: `t` --> $DIR/borrowck-partial-reinit-1.rs:33:5 | +LL | let mut t = Test3(None); + | ----- move occurs because `t` has type `Test3`, which does not implement the `Copy` trait +LL | let u = Test; +LL | drop(t); + | - value moved here LL | t.0 = Some(u); - | ^^^^^^^^^^^^^ + | ^^^ value assigned here after move error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-2.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-2.nll.stderr deleted file mode 100644 index 36a871fbb12a1..0000000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-2.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: assign of moved value: `t` - --> $DIR/borrowck-partial-reinit-2.rs:15:5 - | -LL | let mut t = Test { a: 1, b: None}; - | ----- move occurs because `t` has type `Test`, which does not implement the `Copy` trait -LL | let mut u = Test { a: 2, b: Some(Box::new(t))}; - | - value moved here -LL | t.b = Some(Box::new(u)); - | ^^^ value assigned here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-2.rs b/src/test/ui/borrowck/borrowck-partial-reinit-2.rs index 986c20e361c30..06cd322e77ea7 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-2.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-2.rs @@ -13,7 +13,7 @@ fn stuff() { let mut t = Test { a: 1, b: None}; let mut u = Test { a: 2, b: Some(Box::new(t))}; t.b = Some(Box::new(u)); - //~^ ERROR partial reinitialization of uninitialized structure `t` + //~^ ERROR assign of moved value: `t` println!("done"); } diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr index 891f608850808..36a871fbb12a1 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr @@ -1,9 +1,13 @@ -error[E0383]: partial reinitialization of uninitialized structure `t` +error[E0382]: assign of moved value: `t` --> $DIR/borrowck-partial-reinit-2.rs:15:5 | +LL | let mut t = Test { a: 1, b: None}; + | ----- move occurs because `t` has type `Test`, which does not implement the `Copy` trait +LL | let mut u = Test { a: 2, b: Some(Box::new(t))}; + | - value moved here LL | t.b = Some(Box::new(u)); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ value assigned here after move error: aborting due to previous error -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-3.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-3.nll.stderr deleted file mode 100644 index 05f5411eed68c..0000000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-3.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: assign of moved value: `x.0` - --> $DIR/borrowck-partial-reinit-3.rs:11:5 - | -LL | mem::drop(x.0); - | --- value moved here -LL | x.0.f = 3; - | ^^^^^^^^^ value assigned here after move - | - = note: move occurs because `x.0` has type `Test`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-3.rs b/src/test/ui/borrowck/borrowck-partial-reinit-3.rs index c7fbd7fc88135..ca484315ba5d6 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-3.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-3.rs @@ -9,5 +9,5 @@ fn main() { let mut x = (Test { f: 2 }, Test { f: 4 }); mem::drop(x.0); x.0.f = 3; - //~^ ERROR partial reinitialization of uninitialized structure `x.0` + //~^ ERROR assign of moved value: `x.0` } diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr index 262317444cb45..05f5411eed68c 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr @@ -1,9 +1,13 @@ -error[E0383]: partial reinitialization of uninitialized structure `x.0` +error[E0382]: assign of moved value: `x.0` --> $DIR/borrowck-partial-reinit-3.rs:11:5 | +LL | mem::drop(x.0); + | --- value moved here LL | x.0.f = 3; - | ^^^^^^^^^ + | ^^^^^^^^^ value assigned here after move + | + = note: move occurs because `x.0` has type `Test`, which does not implement the `Copy` trait error: aborting due to previous error -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-4.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-4.nll.stderr deleted file mode 100644 index f0a9a7dd5e243..0000000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-4.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: assign of possibly uninitialized variable: `x.0` - --> $DIR/borrowck-partial-reinit-4.rs:17:5 - | -LL | (x.0).0 = Some(Test); - | ^^^^^^^ use of possibly uninitialized `x.0` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-4.rs b/src/test/ui/borrowck/borrowck-partial-reinit-4.rs index ffa6b11b6fa62..0fb955d201d03 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-4.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-4.rs @@ -15,7 +15,7 @@ impl Drop for Test2 { fn stuff() { let mut x : (Test2, Test2); (x.0).0 = Some(Test); - //~^ ERROR partial reinitialization of uninitialized structure `x.0` + //~^ ERROR assign of possibly uninitialized variable: `x.0` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr index 8ca8e7e13c6e2..f0a9a7dd5e243 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr @@ -1,9 +1,9 @@ -error[E0383]: partial reinitialization of uninitialized structure `x.0` +error[E0381]: assign of possibly uninitialized variable: `x.0` --> $DIR/borrowck-partial-reinit-4.rs:17:5 | LL | (x.0).0 = Some(Test); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ use of possibly uninitialized `x.0` error: aborting due to previous error -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.stderr deleted file mode 100644 index 207f971acff7d..0000000000000 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-pat-reassign-binding.rs:13:11 - | -LL | Some(ref i) => { - | ----- borrow of `x` occurs here -LL | // But on this branch, `i` is an outstanding borrow -LL | x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` - | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.mir.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.mir.stderr deleted file mode 100644 index d65ba12295d5d..0000000000000 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-pat-reassign-binding.rs:13:11 - | -LL | Some(ref i) => { - | ----- borrow of `x` occurs here -LL | // But on this branch, `i` is an outstanding borrow -LL | x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` - | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed -LL | drop(i); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs b/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs index 9befa9162d51c..f02c46fb8f0fd 100644 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs +++ b/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let mut x: Option = None; match x { @@ -10,8 +7,7 @@ fn main() { } Some(ref i) => { // But on this branch, `i` is an outstanding borrow - x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = Some(*i+1); //~ ERROR cannot assign to `x` because it is borrowed drop(i); } } diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.stderr similarity index 70% rename from src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-pat-reassign-binding.stderr index d65ba12295d5d..59db91b8d950c 100644 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-pat-reassign-binding.stderr @@ -1,12 +1,11 @@ error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-pat-reassign-binding.rs:13:11 + --> $DIR/borrowck-pat-reassign-binding.rs:10:11 | LL | Some(ref i) => { | ----- borrow of `x` occurs here LL | // But on this branch, `i` is an outstanding borrow -LL | x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` +LL | x = Some(*i+1); //~ ERROR cannot assign to `x` because it is borrowed | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed LL | drop(i); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr deleted file mode 100644 index 6b41b6f9c4fd4..0000000000000 --- a/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:13:17 - | -LL | let _bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:18:17 - | -LL | let _bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^ immutable borrow occurs here -LL | use_mut(_bar1); - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:23:17 - | -LL | let _bar1 = &foo.bar1; - | --------- immutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | use_imm(_bar1); - | ----- immutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:45:21 - | -LL | let _bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | match *foo { -LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} - | ^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:52:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^ immutable borrow occurs here -LL | let _foo2 = &*foo; //~ ERROR cannot borrow -LL | use_mut(_bar1); - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:53:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow -LL | let _foo2 = &*foo; //~ ERROR cannot borrow - | ^^^^^ immutable borrow occurs here -LL | use_mut(_bar1); - | ----- mutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:58:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:63:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^^^^^^ second mutable borrow occurs here -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:68:17 - | -LL | let _bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | use_imm(_bar1); - | ----- immutable borrow later used here - -error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:73:17 - | -LL | let _bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^^^^^^ mutable borrow occurs here -LL | use_imm(_bar1); - | ----- immutable borrow later used here - -error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-reborrow-from-mut.rs:88:17 - | -LL | fn borrow_mut_from_imm(foo: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut Foo` -LL | let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 11 previous errors - -Some errors occurred: E0499, E0502, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr index c20df9f5ff3ff..6b41b6f9c4fd4 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr @@ -1,122 +1,114 @@ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:13:22 + --> $DIR/borrowck-reborrow-from-mut.rs:13:17 | LL | let _bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:18:18 + --> $DIR/borrowck-reborrow-from-mut.rs:18:17 | LL | let _bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here + | ------------- mutable borrow occurs here LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ immutable borrow occurs here + | ^^^^^^^^^ immutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:23:22 + --> $DIR/borrowck-reborrow-from-mut.rs:23:17 | LL | let _bar1 = &foo.bar1; - | -------- immutable borrow occurs here + | --------- immutable borrow occurs here LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | use_imm(_bar1); -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-reborrow-from-mut.rs:45:21 | LL | let _bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | match *foo { LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} | ^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | use_mut(_bar1); + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:52:18 +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:52:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &*foo; //~ ERROR cannot borrow +LL | use_mut(_bar1); + | ----- mutable borrow later used here -error[E0502]: cannot borrow `*foo` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:53:18 +error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:53:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow LL | let _foo2 = &*foo; //~ ERROR cannot borrow - | ^^^^ immutable borrow occurs here + | ^^^^^ immutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:58:22 + --> $DIR/borrowck-reborrow-from-mut.rs:58:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:63:22 + --> $DIR/borrowck-reborrow-from-mut.rs:63:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^ second mutable borrow occurs here + | ^^^^^^^^^ second mutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - first borrow ends here + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:68:22 +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:68:17 | LL | let _bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | use_imm(_bar1); -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0502]: cannot borrow `*foo` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:73:22 +error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:73:17 | LL | let _bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow - | ^^^^ mutable borrow occurs here + | ^^^^^^^^^ mutable borrow occurs here LL | use_imm(_bar1); -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:88:22 +error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-reborrow-from-mut.rs:88:17 | LL | fn borrow_mut_from_imm(foo: &Foo) { - | ---- use `&mut Foo` here to make mutable + | ---- help: consider changing this to be a mutable reference: `&mut Foo` LL | let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 11 previous errors diff --git a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.nll.stderr b/src/test/ui/borrowck/borrowck-ref-mut-of-imm.nll.stderr deleted file mode 100644 index 67948ad387928..0000000000000 --- a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/borrowck-ref-mut-of-imm.rs:4:12 - | -LL | fn destructure(x: Option) -> isize { - | - help: consider changing this to be mutable: `mut x` -... -LL | Some(ref mut v) => *v //~ ERROR cannot borrow - | ^^^^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr b/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr index 4eb41758fc19b..67948ad387928 100644 --- a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr +++ b/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow field `(x as std::prelude::v1::Some).0` of immutable binding as mutable +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-ref-mut-of-imm.rs:4:12 | LL | fn destructure(x: Option) -> isize { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... LL | Some(ref mut v) => *v //~ ERROR cannot borrow - | ^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr deleted file mode 100644 index 7b026ee995118..0000000000000 --- a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:8:13 - | -LL | let y = &mut x; - | ------ mutable borrow occurs here -LL | //~^ mutable borrow occurs here -LL | let z = &x; //~ ERROR cannot borrow - | ^^ immutable borrow occurs here -... -LL | y.use_mut(); - | - mutable borrow later used here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21 - | -LL | let y = &x; - | -- immutable borrow occurs here -LL | //~^ immutable borrow occurs here -LL | let z = &mut x; //~ ERROR cannot borrow - | ^^^^^^ mutable borrow occurs here -... -LL | y.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | //~^ first mutable borrow occurs here -LL | let z = &mut x; //~ ERROR cannot borrow - | ^^^^^^ second mutable borrow occurs here -... -LL | y.use_mut(); - | - first borrow later used here - -error: aborting due to 3 previous errors - -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr index cb65ea11205d7..7b026ee995118 100644 --- a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr +++ b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr @@ -1,38 +1,38 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:8:14 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:8:13 | LL | let y = &mut x; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | //~^ mutable borrow occurs here LL | let z = &x; //~ ERROR cannot borrow - | ^ immutable borrow occurs here + | ^^ immutable borrow occurs here ... -LL | } - | - mutable borrow ends here +LL | y.use_mut(); + | - mutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:26 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21 | LL | let y = &x; - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | //~^ immutable borrow occurs here LL | let z = &mut x; //~ ERROR cannot borrow - | ^ mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here ... -LL | } - | - immutable borrow ends here +LL | y.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:22 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17 | LL | let y = &mut x; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | //~^ first mutable borrow occurs here LL | let z = &mut x; //~ ERROR cannot borrow - | ^ second mutable borrow occurs here + | ^^^^^^ second mutable borrow occurs here ... -LL | }; - | - first borrow ends here +LL | y.use_mut(); + | - first borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr deleted file mode 100644 index 65f910de4c3b3..0000000000000 --- a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing function parameter `x` - --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:7:5 - | -LL | (&x).clone() //~ ERROR `x` does not live long enough - | ----^^^^^^^^ - | | - | returns a value referencing data owned by the current function - | `x` is borrowed here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs index f8cdc3ed97c40..75e5e7fd4211a 100644 --- a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs +++ b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs @@ -4,7 +4,7 @@ // Issue #19261. fn leak<'a, T>(x: T) -> &'a T { - (&x).clone() //~ ERROR `x` does not live long enough + (&x).clone() //~ ERROR cannot return value referencing function parameter `x` } fn main() { } diff --git a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr index b54941eed1be5..6c727dd78325e 100644 --- a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr +++ b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr @@ -1,17 +1,12 @@ -error[E0597]: `x` does not live long enough - --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:7:7 +error[E0515]: cannot return value referencing function parameter `x` + --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:7:5 | -LL | (&x).clone() //~ ERROR `x` does not live long enough - | ^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 6:9... - --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:6:9 - | -LL | fn leak<'a, T>(x: T) -> &'a T { - | ^^ +LL | (&x).clone() //~ ERROR cannot return value referencing function parameter `x` + | ----^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `x` is borrowed here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr deleted file mode 100644 index dbc9ece0c8f86..0000000000000 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:15:15 - | -LL | let _s2 = S{a: 2, ..s0}; - | ^^^^^^^^^^^^^ cannot move out of here - -error[E0509]: cannot move out of type `T`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:21:15 - | -LL | let _s2 = T{a: 2, ..s0}; - | ^^^^^^^^^^^^^ cannot move out of here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.stderr deleted file mode 100644 index bc0a954b46d01..0000000000000 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:15:25 - | -LL | let _s2 = S{a: 2, ..s0}; - | ^^ cannot move out of here - -error[E0509]: cannot move out of type `T`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:21:25 - | -LL | let _s2 = T{a: 2, ..s0}; - | ^^ cannot move out of here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs index da5bb6366314a..1f6ed6d46aa69 100644 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs +++ b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Issue 4691: Ensure that functional-struct-update can only copy, not // move, when the struct implements Drop. @@ -13,14 +10,12 @@ impl Drop for T { fn drop(&mut self) { } } fn f(s0:S) { let _s2 = S{a: 2, ..s0}; - //[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn g(s0:T) { let _s2 = T{a: 2, ..s0}; - //[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn main() { } diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.stderr similarity index 81% rename from src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.stderr rename to src/test/ui/borrowck/borrowck-struct-update-with-dtor.stderr index dbc9ece0c8f86..ea16502ebe5da 100644 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.stderr +++ b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.stderr @@ -1,11 +1,11 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:15:15 + --> $DIR/borrowck-struct-update-with-dtor.rs:12:15 | LL | let _s2 = S{a: 2, ..s0}; | ^^^^^^^^^^^^^ cannot move out of here error[E0509]: cannot move out of type `T`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:21:15 + --> $DIR/borrowck-struct-update-with-dtor.rs:17:15 | LL | let _s2 = T{a: 2, ..s0}; | ^^^^^^^^^^^^^ cannot move out of here diff --git a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr deleted file mode 100644 index 8fdd5ef4ca6be..0000000000000 --- a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-swap-mut-base-ptr.rs:13:10 - | -LL | let p: &isize = &*t0; // Freezes `*t0` - | ---- immutable borrow occurs here -LL | swap(&mut t0, &mut t1); //~ ERROR cannot borrow `t0` - | ^^^^^^^ mutable borrow occurs here -LL | *t1 = 22; -LL | p.use_ref(); - | - immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr index 35007216dace1..8fdd5ef4ca6be 100644 --- a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr @@ -1,13 +1,13 @@ -error[E0502]: cannot borrow `t0` as mutable because `*t0` is also borrowed as immutable - --> $DIR/borrowck-swap-mut-base-ptr.rs:13:15 +error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-swap-mut-base-ptr.rs:13:10 | LL | let p: &isize = &*t0; // Freezes `*t0` - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | swap(&mut t0, &mut t1); //~ ERROR cannot borrow `t0` - | ^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^ mutable borrow occurs here +LL | *t1 = 22; +LL | p.use_ref(); + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr deleted file mode 100644 index 34d08a026dd35..0000000000000 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0712]: thread-local variable borrowed past end of function - --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:11:20 - | -LL | assert_static(&FOO); //[ast]~ ERROR [E0597] - | ^^^^ thread-local variables cannot be borrowed beyond the end of the function -LL | //[mir]~^ ERROR [E0712] -LL | } - | - end of enclosing function is here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0712`. diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr deleted file mode 100644 index 4724f1772bafd..0000000000000 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:11:21 - | -LL | assert_static(&FOO); //[ast]~ ERROR [E0597] - | ^^^ - borrowed value only lives until here - | | - | borrowed value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs index 6fd6acc834666..1cf8d187c25f4 100644 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs +++ b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(thread_local)] #[thread_local] @@ -8,6 +5,5 @@ static FOO: u8 = 3; fn assert_static(_t: &'static u8) {} fn main() { - assert_static(&FOO); //[ast]~ ERROR [E0597] - //[mir]~^ ERROR [E0712] + assert_static(&FOO); //~ ERROR [E0712] } diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr similarity index 65% rename from src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr rename to src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr index 34d08a026dd35..e37e48b797a34 100644 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr +++ b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr @@ -1,9 +1,8 @@ error[E0712]: thread-local variable borrowed past end of function - --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:11:20 + --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:8:20 | -LL | assert_static(&FOO); //[ast]~ ERROR [E0597] +LL | assert_static(&FOO); //~ ERROR [E0712] | ^^^^ thread-local variables cannot be borrowed beyond the end of the function -LL | //[mir]~^ ERROR [E0712] LL | } | - end of enclosing function is here diff --git a/src/test/ui/borrowck/borrowck-unary-move.ast.stderr b/src/test/ui/borrowck/borrowck-unary-move.ast.stderr deleted file mode 100644 index 9383298af9bfe..0000000000000 --- a/src/test/ui/borrowck/borrowck-unary-move.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-unary-move.rs:7:10 - | -LL | let y = &*x; - | -- borrow of `*x` occurs here -LL | free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-unary-move.mir.stderr b/src/test/ui/borrowck/borrowck-unary-move.mir.stderr deleted file mode 100644 index 53dc6a77887d4..0000000000000 --- a/src/test/ui/borrowck/borrowck-unary-move.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-unary-move.rs:7:10 - | -LL | let y = &*x; - | --- borrow of `*x` occurs here -LL | free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here -LL | //[mir]~^ ERROR cannot move out of `x` because it is borrowed -LL | *y - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-unary-move.rs b/src/test/ui/borrowck/borrowck-unary-move.rs index 4e023ac859937..3b4c0731fc5c7 100644 --- a/src/test/ui/borrowck/borrowck-unary-move.rs +++ b/src/test/ui/borrowck/borrowck-unary-move.rs @@ -1,11 +1,6 @@ -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn foo(x: Box) -> isize { let y = &*x; - free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed - //[mir]~^ ERROR cannot move out of `x` because it is borrowed + free(x); //~ ERROR cannot move out of `x` because it is borrowed *y } diff --git a/src/test/ui/borrowck/borrowck-unary-move.ast.nll.stderr b/src/test/ui/borrowck/borrowck-unary-move.stderr similarity index 63% rename from src/test/ui/borrowck/borrowck-unary-move.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-unary-move.stderr index 53dc6a77887d4..535246a818343 100644 --- a/src/test/ui/borrowck/borrowck-unary-move.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-unary-move.stderr @@ -1,11 +1,10 @@ error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-unary-move.rs:7:10 + --> $DIR/borrowck-unary-move.rs:3:10 | LL | let y = &*x; | --- borrow of `*x` occurs here -LL | free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed +LL | free(x); //~ ERROR cannot move out of `x` because it is borrowed | ^ move out of `x` occurs here -LL | //[mir]~^ ERROR cannot move out of `x` because it is borrowed LL | *y | -- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr deleted file mode 100644 index 363a5a69a07e3..0000000000000 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-unboxed-closures.rs:3:5 - | -LL | let g = &mut f; - | ------ mutable borrow occurs here -LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable - | ^ immutable borrow occurs here -LL | use_mut(g); - | - mutable borrow later used here - -error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable - --> $DIR/borrowck-unboxed-closures.rs:7:5 - | -LL | fn b isize>(f: F) { - | - help: consider changing this to be mutable: `mut f` -LL | f(1, 2); //~ ERROR cannot borrow immutable argument - | ^ cannot borrow as mutable - -error[E0382]: use of moved value: `f` - --> $DIR/borrowck-unboxed-closures.rs:12:5 - | -LL | fn c isize>(f: F) { - | - - move occurs because `f` has type `F`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | f(1, 2); - | - value moved here -LL | f(1, 2); //~ ERROR use of moved value - | ^ value used here after move - -error: aborting due to 3 previous errors - -Some errors occurred: E0382, E0502, E0596. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.rs b/src/test/ui/borrowck/borrowck-unboxed-closures.rs index bfd0fbb30505f..f0048dd7de03f 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.rs +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.rs @@ -4,7 +4,7 @@ fn a isize>(mut f: F) { use_mut(g); } fn b isize>(f: F) { - f(1, 2); //~ ERROR cannot borrow immutable argument + f(1, 2); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable } fn c isize>(f: F) { diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr index 044119f508950..4c520d3d3f54b 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr @@ -2,30 +2,31 @@ error[E0502]: cannot borrow `f` as immutable because it is also borrowed as muta --> $DIR/borrowck-unboxed-closures.rs:3:5 | LL | let g = &mut f; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable | ^ immutable borrow occurs here LL | use_mut(g); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here -error[E0596]: cannot borrow immutable argument `f` as mutable +error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable --> $DIR/borrowck-unboxed-closures.rs:7:5 | LL | fn b isize>(f: F) { - | - help: make this binding mutable: `mut f` -LL | f(1, 2); //~ ERROR cannot borrow immutable argument - | ^ cannot borrow mutably + | - help: consider changing this to be mutable: `mut f` +LL | f(1, 2); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable + | ^ cannot borrow as mutable error[E0382]: use of moved value: `f` --> $DIR/borrowck-unboxed-closures.rs:12:5 | +LL | fn c isize>(f: F) { + | - - move occurs because `f` has type `F`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | f(1, 2); | - value moved here LL | f(1, 2); //~ ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr b/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr deleted file mode 100644 index 99cbf64fd5d46..0000000000000 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-field-access.rs:24:13 - | -LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` - | ^^^ use of possibly uninitialized `a.x` - -error[E0382]: use of moved value: `line1.origin` - --> $DIR/borrowck-uninit-field-access.rs:29:13 - | -LL | let _moved = line1.origin; - | ------------ value moved here -LL | let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` - | ^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `line2` - --> $DIR/borrowck-uninit-field-access.rs:34:5 - | -LL | let _moved = (line2.origin, line2.middle); - | ------------ value moved here -LL | line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] - | ^^^^^ value used here after partial move - | - = note: move occurs because `line2.middle` has type `Point`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -Some errors occurred: E0381, E0382. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.stderr b/src/test/ui/borrowck/borrowck-uninit-field-access.ast.stderr deleted file mode 100644 index 8c05272e5fbae..0000000000000 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `a.x` - --> $DIR/borrowck-uninit-field-access.rs:24:13 - | -LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` - | ^^^ use of possibly uninitialized `a.x` - -error[E0382]: use of moved value: `line1.origin.x` - --> $DIR/borrowck-uninit-field-access.rs:29:13 - | -LL | let _moved = line1.origin; - | ------ value moved here -LL | let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` - | ^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait - -error[E0382]: use of partially moved value: `line2` - --> $DIR/borrowck-uninit-field-access.rs:34:5 - | -LL | let _moved = (line2.origin, line2.middle); - | ------------ value moved here -LL | line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] - | ^^^^^ value used here after move - | - = note: move occurs because `line2.origin` has type `Point`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -Some errors occurred: E0381, E0382. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.rs b/src/test/ui/borrowck/borrowck-uninit-field-access.rs index ab19b2d773519..bc931eef93a8b 100644 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.rs +++ b/src/test/ui/borrowck/borrowck-uninit-field-access.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Check that do not allow access to fields of uninitialized or moved // structs. @@ -21,16 +18,13 @@ impl Line { fn consume(self) { } } fn main() { let mut a: Point; - let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` - //[mir]~^ ERROR [E0381] + let _ = a.x + 1; //~ ERROR [E0381] let mut line1 = Line::default(); let _moved = line1.origin; - let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` - //[mir]~^ [E0382] + let _ = line1.origin.x + 1; //~ ERROR [E0382] let mut line2 = Line::default(); let _moved = (line2.origin, line2.middle); - line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] - //[mir]~^ [E0382] + line2.consume(); //~ ERROR [E0382] } diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr b/src/test/ui/borrowck/borrowck-uninit-field-access.stderr similarity index 68% rename from src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr rename to src/test/ui/borrowck/borrowck-uninit-field-access.stderr index 99cbf64fd5d46..656d8b17dd512 100644 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr +++ b/src/test/ui/borrowck/borrowck-uninit-field-access.stderr @@ -1,25 +1,25 @@ error[E0381]: use of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-field-access.rs:24:13 + --> $DIR/borrowck-uninit-field-access.rs:21:13 | -LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` +LL | let _ = a.x + 1; //~ ERROR [E0381] | ^^^ use of possibly uninitialized `a.x` error[E0382]: use of moved value: `line1.origin` - --> $DIR/borrowck-uninit-field-access.rs:29:13 + --> $DIR/borrowck-uninit-field-access.rs:25:13 | LL | let _moved = line1.origin; | ------------ value moved here -LL | let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` +LL | let _ = line1.origin.x + 1; //~ ERROR [E0382] | ^^^^^^^^^^^^^^ value used here after move | = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait error[E0382]: use of moved value: `line2` - --> $DIR/borrowck-uninit-field-access.rs:34:5 + --> $DIR/borrowck-uninit-field-access.rs:29:5 | LL | let _moved = (line2.origin, line2.middle); | ------------ value moved here -LL | line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] +LL | line2.consume(); //~ ERROR [E0382] | ^^^^^ value used here after partial move | = note: move occurs because `line2.middle` has type `Point`, which does not implement the `Copy` trait diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.stderr b/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.stderr deleted file mode 100644 index e8ebf8c2dd048..0000000000000 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `**x` - --> $DIR/borrowck-uninit-ref-chain.rs:11:15 - | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - | ^^^ use of possibly uninitialized `**x` - -error[E0381]: use of possibly uninitialized variable: `**x` - --> $DIR/borrowck-uninit-ref-chain.rs:15:15 - | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - | ^^^ use of possibly uninitialized `**x` - -error[E0381]: use of possibly uninitialized variable: `**x` - --> $DIR/borrowck-uninit-ref-chain.rs:19:15 - | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - | ^^^ use of possibly uninitialized `**x` - -error[E0381]: use of possibly uninitialized variable: `a.x` - --> $DIR/borrowck-uninit-ref-chain.rs:25:15 - | -LL | let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] - | ^^^ use of possibly uninitialized `a.x` - -error[E0381]: use of possibly uninitialized variable: `**a.x` - --> $DIR/borrowck-uninit-ref-chain.rs:30:15 - | -LL | let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] - | ^^^^^ use of possibly uninitialized `**a.x` - -error[E0381]: use of possibly uninitialized variable: `a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:36:15 - | -LL | let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] - | ^^^ use of possibly uninitialized `a.y` - -error[E0381]: use of possibly uninitialized variable: `**a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:41:15 - | -LL | let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] - | ^^^^^ use of possibly uninitialized `**a.y` - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr b/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr deleted file mode 100644 index 7687176947a73..0000000000000 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:11:14 - | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - | ^^^^ use of possibly uninitialized `**x` - -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:15:14 - | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - | ^^^^ use of possibly uninitialized `**x` - -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:19:14 - | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - | ^^^^ use of possibly uninitialized `**x` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:24:5 - | -LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - | ^^^^^^^ use of possibly uninitialized `a` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:29:5 - | -LL | a.x = &&0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - | ^^^^^^^^^ use of possibly uninitialized `a` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:35:5 - | -LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - | ^^^^^^^ use of possibly uninitialized `a` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:40:5 - | -LL | a.x = &&0; //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381] - | ^^^^^^^^^ use of possibly uninitialized `a` - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs b/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs index 562012a23da67..fa9148f984077 100644 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs +++ b/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct S { x: X, y: Y, @@ -8,36 +5,29 @@ struct S { fn main() { let x: &&Box; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] + let _y = &**x; //~ [E0381] let x: &&S; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] + let _y = &**x; //~ [E0381] let x: &&i32; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] + let _y = &**x; //~ [E0381] let mut a: S; - a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] - + a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &a.x; let mut a: S<&&i32, &&i32>; - a.x = &&0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] - + a.x = &&0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &**a.x; let mut a: S; - a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] - + a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &a.y; let mut a: S<&&i32, &&i32>; - a.x = &&0; //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] - + a.x = &&0; //~ assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &**a.y; } diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr b/src/test/ui/borrowck/borrowck-uninit-ref-chain.stderr similarity index 55% rename from src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-uninit-ref-chain.stderr index 7687176947a73..976c6f1bffdad 100644 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-uninit-ref-chain.stderr @@ -1,43 +1,43 @@ error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:11:14 + --> $DIR/borrowck-uninit-ref-chain.rs:8:14 | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] +LL | let _y = &**x; //~ [E0381] | ^^^^ use of possibly uninitialized `**x` error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:15:14 + --> $DIR/borrowck-uninit-ref-chain.rs:11:14 | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] +LL | let _y = &**x; //~ [E0381] | ^^^^ use of possibly uninitialized `**x` error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:19:14 + --> $DIR/borrowck-uninit-ref-chain.rs:14:14 | -LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] +LL | let _y = &**x; //~ [E0381] | ^^^^ use of possibly uninitialized `**x` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:24:5 + --> $DIR/borrowck-uninit-ref-chain.rs:18:5 | -LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] +LL | a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] | ^^^^^^^ use of possibly uninitialized `a` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:29:5 + --> $DIR/borrowck-uninit-ref-chain.rs:22:5 | -LL | a.x = &&0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] +LL | a.x = &&0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] | ^^^^^^^^^ use of possibly uninitialized `a` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:35:5 + --> $DIR/borrowck-uninit-ref-chain.rs:27:5 | -LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] +LL | a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] | ^^^^^^^ use of possibly uninitialized `a` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:40:5 + --> $DIR/borrowck-uninit-ref-chain.rs:31:5 | -LL | a.x = &&0; //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381] +LL | a.x = &&0; //~ assign to part of possibly uninitialized variable: `a` [E0381] | ^^^^^^^^^ use of possibly uninitialized `a` error: aborting due to 7 previous errors diff --git a/src/test/ui/borrowck/borrowck-union-borrow-nested.nll.stderr b/src/test/ui/borrowck/borrowck-union-borrow-nested.nll.stderr deleted file mode 100644 index 6bb6fc4cf29a1..0000000000000 --- a/src/test/ui/borrowck/borrowck-union-borrow-nested.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0503]: cannot use `u.c` because it was mutably borrowed - --> $DIR/borrowck-union-borrow-nested.rs:24:21 - | -LL | let ra = &mut u.s.a; - | ---------- borrow of `u.s.a` occurs here -LL | let b = u.c; //~ ERROR cannot use `u.c` because it was mutably borrowed - | ^^^ use of borrowed `u.s.a` -LL | ra.use_mut(); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr b/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr index 199a13352c4a0..6bb6fc4cf29a1 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr +++ b/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr @@ -1,10 +1,12 @@ error[E0503]: cannot use `u.c` because it was mutably borrowed - --> $DIR/borrowck-union-borrow-nested.rs:24:17 + --> $DIR/borrowck-union-borrow-nested.rs:24:21 | LL | let ra = &mut u.s.a; - | ----- borrow of `u.s.a` occurs here + | ---------- borrow of `u.s.a` occurs here LL | let b = u.c; //~ ERROR cannot use `u.c` because it was mutably borrowed - | ^ use of borrowed `u.s.a` + | ^^^ use of borrowed `u.s.a` +LL | ra.use_mut(); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr b/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr deleted file mode 100644 index 1a2433c8f6afd..0000000000000 --- a/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr +++ /dev/null @@ -1,136 +0,0 @@ -error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-union-borrow.rs:27:23 - | -LL | let ra = &u.a; - | ---- immutable borrow occurs here -LL | let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable - | ^^^^^^^^ mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable -LL | drop(ra); - | -- immutable borrow later used here - -error[E0506]: cannot assign to `u.a` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:33:13 - | -LL | let ra = &u.a; - | ---- borrow of `u.a` occurs here -LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed -LL | drop(ra); - | -- borrow later used here - -error[E0502]: cannot borrow `u.b` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-union-borrow.rs:50:23 - | -LL | let ra = &u.a; - | ---- immutable borrow occurs here -LL | let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) - | ^^^^^^^^ mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable -LL | drop(ra); - | -- immutable borrow later used here - -error[E0506]: cannot assign to `u.b` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:56:13 - | -LL | let ra = &u.a; - | ---- borrow of `u.b` occurs here -LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.b` occurs here -LL | //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed -LL | drop(ra); - | -- borrow later used here - -error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-union-borrow.rs:63:22 - | -LL | let rma = &mut u.a; - | -------- mutable borrow occurs here -LL | let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable - | ^^^^ immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable -LL | drop(rma); - | --- mutable borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:69:21 - | -LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - | ^^^ use of borrowed `u.a` -LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed -LL | drop(ra); - | -- borrow later used here - -error[E0499]: cannot borrow `u.a` as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:75:24 - | -LL | let rma = &mut u.a; - | -------- first mutable borrow occurs here -LL | let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time - | ^^^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time -LL | drop(rma); - | --- first borrow later used here - -error[E0506]: cannot assign to `u.a` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:81:13 - | -LL | let rma = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.a` occurs here -LL | //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed -LL | drop(rma); - | --- borrow later used here - -error[E0502]: cannot borrow `u.b` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-union-borrow.rs:88:22 - | -LL | let rma = &mut u.a; - | -------- mutable borrow occurs here -LL | let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) - | ^^^^ immutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable -LL | drop(rma); - | --- mutable borrow later used here - -error[E0503]: cannot use `u.b` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:94:21 - | -LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed - | ^^^ use of borrowed `u.a` -... -LL | drop(ra); - | -- borrow later used here - -error[E0499]: cannot borrow `u.b` as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:101:24 - | -LL | let rma = &mut u.a; - | -------- first mutable borrow occurs here -LL | let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time - | ^^^^^^^^ second mutable borrow occurs here -LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time -LL | drop(rma); - | --- first borrow later used here - -error[E0506]: cannot assign to `u.b` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:107:13 - | -LL | let rma = &mut u.a; - | -------- borrow of `u.b` occurs here -LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.b` occurs here -LL | //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed -LL | drop(rma); - | --- borrow later used here - -error: aborting due to 12 previous errors - -Some errors occurred: E0499, E0502, E0503, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-union-borrow.nll.stderr b/src/test/ui/borrowck/borrowck-union-borrow.nll.stderr deleted file mode 100644 index 5cba30b43b8a0..0000000000000 --- a/src/test/ui/borrowck/borrowck-union-borrow.nll.stderr +++ /dev/null @@ -1,131 +0,0 @@ -error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-union-borrow.rs:25:23 - | -LL | let ra = &u.a; - | ---- immutable borrow occurs here -LL | let rma = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable - | ^^^^^^^^ mutable borrow occurs here -LL | drop(ra); - | -- immutable borrow later used here - -error[E0506]: cannot assign to `u.a` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:30:13 - | -LL | let ra = &u.a; - | ---- borrow of `u.a` occurs here -LL | u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.a` occurs here -LL | drop(ra); - | -- borrow later used here - -error[E0502]: cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:46:23 - | -LL | let ra = &u.a; - | ---- immutable borrow occurs here (via `u.a`) -LL | let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) - | ^^^^^^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here -LL | drop(ra); - | -- immutable borrow later used here - | - = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` - -error[E0506]: cannot assign to `u.b` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:51:13 - | -LL | let ra = &u.a; - | ---- borrow of `u.b` occurs here -LL | u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.b` occurs here -LL | drop(ra); - | -- borrow later used here - -error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-union-borrow.rs:57:22 - | -LL | let rma = &mut u.a; - | -------- mutable borrow occurs here -LL | let ra = &u.a; //~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable - | ^^^^ immutable borrow occurs here -LL | drop(rma); - | --- mutable borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:62:21 - | -LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | let a = u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed - | ^^^ use of borrowed `u.a` -LL | drop(ra); - | -- borrow later used here - -error[E0499]: cannot borrow `u.a` as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:67:24 - | -LL | let rma = &mut u.a; - | -------- first mutable borrow occurs here -LL | let rma2 = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable more than once at a time - | ^^^^^^^^ second mutable borrow occurs here -LL | drop(rma); - | --- first borrow later used here - -error[E0506]: cannot assign to `u.a` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:72:13 - | -LL | let rma = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.a` occurs here -LL | drop(rma); - | --- borrow later used here - -error[E0502]: cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:78:22 - | -LL | let rma = &mut u.a; - | -------- mutable borrow occurs here (via `u.a`) -LL | let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) - | ^^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here -LL | drop(rma); - | --- mutable borrow later used here - | - = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` - -error[E0503]: cannot use `u.b` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:83:21 - | -LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | let b = u.b; //~ ERROR cannot use `u.b` because it was mutably borrowed - | ^^^ use of borrowed `u.a` -LL | -LL | drop(ra); - | -- borrow later used here - -error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:89:24 - | -LL | let rma = &mut u.a; - | -------- first mutable borrow occurs here (via `u.a`) -LL | let rmb2 = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time - | ^^^^^^^^ second mutable borrow occurs here (via `u.b`) -LL | drop(rma); - | --- first borrow later used here - | - = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` - -error[E0506]: cannot assign to `u.b` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:94:13 - | -LL | let rma = &mut u.a; - | -------- borrow of `u.b` occurs here -LL | u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed - | ^^^^^^^ assignment to borrowed `u.b` occurs here -LL | drop(rma); - | --- borrow later used here - -error: aborting due to 12 previous errors - -Some errors occurred: E0499, E0502, E0503, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-union-borrow.rs b/src/test/ui/borrowck/borrowck-union-borrow.rs index 8afc0be8b55c5..63901680bd157 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow.rs +++ b/src/test/ui/borrowck/borrowck-union-borrow.rs @@ -43,7 +43,7 @@ fn main() { } { let ra = &u.a; - let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`) drop(ra); } { @@ -75,7 +75,7 @@ fn main() { // Mut borrow, other field { let rma = &mut u.a; - let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`) drop(rma); } { diff --git a/src/test/ui/borrowck/borrowck-union-borrow.stderr b/src/test/ui/borrowck/borrowck-union-borrow.stderr index ef6a331eda04c..02d281e3248ef 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow.stderr +++ b/src/test/ui/borrowck/borrowck-union-borrow.stderr @@ -1,116 +1,129 @@ error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-union-borrow.rs:25:28 + --> $DIR/borrowck-union-borrow.rs:25:23 | LL | let ra = &u.a; - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let rma = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable - | ^^^ mutable borrow occurs here + | ^^^^^^^^ mutable borrow occurs here LL | drop(ra); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:30:13 | LL | let ra = &u.a; - | --- borrow of `u.a` occurs here + | ---- borrow of `u.a` occurs here LL | u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | drop(ra); + | -- borrow later used here -error[E0502]: cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:46:28 +error[E0502]: cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`) + --> $DIR/borrowck-union-borrow.rs:46:23 | LL | let ra = &u.a; - | --- immutable borrow occurs here (via `u.a`) -LL | let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) - | ^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here + | ---- immutable borrow occurs here (via `u.a`) +LL | let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`) + | ^^^^^^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here LL | drop(ra); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here + | + = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:51:13 | LL | let ra = &u.a; - | --- borrow of `u.b` occurs here + | ---- borrow of `u.b` occurs here LL | u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | drop(ra); + | -- borrow later used here error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-union-borrow.rs:57:23 + --> $DIR/borrowck-union-borrow.rs:57:22 | LL | let rma = &mut u.a; - | --- mutable borrow occurs here + | -------- mutable borrow occurs here LL | let ra = &u.a; //~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable - | ^^^ immutable borrow occurs here + | ^^^^ immutable borrow occurs here LL | drop(rma); -LL | } - | - mutable borrow ends here + | --- mutable borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:62:17 + --> $DIR/borrowck-union-borrow.rs:62:21 | LL | let ra = &mut u.a; - | --- borrow of `u.a` occurs here + | -------- borrow of `u.a` occurs here LL | let a = u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed - | ^ use of borrowed `u.a` + | ^^^ use of borrowed `u.a` +LL | drop(ra); + | -- borrow later used here error[E0499]: cannot borrow `u.a` as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:67:29 + --> $DIR/borrowck-union-borrow.rs:67:24 | LL | let rma = &mut u.a; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let rma2 = &mut u.a; //~ ERROR cannot borrow `u.a` as mutable more than once at a time - | ^^^ second mutable borrow occurs here + | ^^^^^^^^ second mutable borrow occurs here LL | drop(rma); -LL | } - | - first borrow ends here + | --- first borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:72:13 | LL | let rma = &mut u.a; - | --- borrow of `u.a` occurs here + | -------- borrow of `u.a` occurs here LL | u.a = 1; //~ ERROR cannot assign to `u.a` because it is borrowed | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | drop(rma); + | --- borrow later used here -error[E0502]: cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:78:23 +error[E0502]: cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`) + --> $DIR/borrowck-union-borrow.rs:78:22 | LL | let rma = &mut u.a; - | --- mutable borrow occurs here (via `u.a`) -LL | let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) - | ^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here + | -------- mutable borrow occurs here (via `u.a`) +LL | let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`) + | ^^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here LL | drop(rma); -LL | } - | - mutable borrow ends here + | --- mutable borrow later used here + | + = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` error[E0503]: cannot use `u.b` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:83:17 + --> $DIR/borrowck-union-borrow.rs:83:21 | LL | let ra = &mut u.a; - | --- borrow of `u.a` occurs here + | -------- borrow of `u.a` occurs here LL | let b = u.b; //~ ERROR cannot use `u.b` because it was mutably borrowed - | ^ use of borrowed `u.a` + | ^^^ use of borrowed `u.a` +LL | +LL | drop(ra); + | -- borrow later used here error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:89:29 + --> $DIR/borrowck-union-borrow.rs:89:24 | LL | let rma = &mut u.a; - | --- first mutable borrow occurs here (via `u.a`) + | -------- first mutable borrow occurs here (via `u.a`) LL | let rmb2 = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time - | ^^^ second mutable borrow occurs here (via `u.b`) + | ^^^^^^^^ second mutable borrow occurs here (via `u.b`) LL | drop(rma); -LL | } - | - first borrow ends here + | --- first borrow later used here + | + = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:94:13 | LL | let rma = &mut u.a; - | --- borrow of `u.b` occurs here + | -------- borrow of `u.b` occurs here LL | u.b = 1; //~ ERROR cannot assign to `u.b` because it is borrowed | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | drop(rma); + | --- borrow later used here error: aborting due to 12 previous errors diff --git a/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr b/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr deleted file mode 100644 index e59fef2dc0d2f..0000000000000 --- a/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move-assign.rs:17:21 - | -LL | let mut u = U { a: A }; - | ----- move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = u.a; - | --- value moved here -LL | let a = u.a; //~ ERROR use of moved value: `u.a` - | ^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-union-move-assign.rs b/src/test/ui/borrowck/borrowck-union-move-assign.rs index 1bb4325203610..a24f42d2ddf87 100644 --- a/src/test/ui/borrowck/borrowck-union-move-assign.rs +++ b/src/test/ui/borrowck/borrowck-union-move-assign.rs @@ -14,7 +14,7 @@ fn main() { { let mut u = U { a: A }; let a = u.a; - let a = u.a; //~ ERROR use of moved value: `u.a` + let a = u.a; //~ ERROR use of moved value: `u` } { let mut u = U { a: A }; diff --git a/src/test/ui/borrowck/borrowck-union-move-assign.stderr b/src/test/ui/borrowck/borrowck-union-move-assign.stderr index f304dc3a12427..09737ea072891 100644 --- a/src/test/ui/borrowck/borrowck-union-move-assign.stderr +++ b/src/test/ui/borrowck/borrowck-union-move-assign.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `u.a` - --> $DIR/borrowck-union-move-assign.rs:17:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move-assign.rs:17:21 | +LL | let mut u = U { a: A }; + | ----- move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = u.a; - | - value moved here -LL | let a = u.a; //~ ERROR use of moved value: `u.a` - | ^ value used here after move - | - = note: move occurs because `u.a` has type `A`, which does not implement the `Copy` trait + | --- value moved here +LL | let a = u.a; //~ ERROR use of moved value: `u` + | ^^^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-union-move.nll.stderr b/src/test/ui/borrowck/borrowck-union-move.nll.stderr deleted file mode 100644 index 1392a7931c30a..0000000000000 --- a/src/test/ui/borrowck/borrowck-union-move.nll.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:26:21 - | -LL | let mut u = Unn { n1: NonCopy }; - | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -LL | let a = u.n1; - | ---- value moved here -LL | let a = u.n1; //~ ERROR use of moved value: `u.n1` - | ^^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:31:21 - | -LL | let mut u = Unn { n1: NonCopy }; - | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -LL | let a = u.n1; - | ---- value moved here -LL | let a = u; //~ ERROR use of partially moved value: `u` - | ^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:36:21 - | -LL | let mut u = Unn { n1: NonCopy }; - | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -LL | let a = u.n1; - | ---- value moved here -LL | let a = u.n2; //~ ERROR use of moved value: `u.n2` - | ^^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:63:21 - | -LL | let mut u = Ucn { c: Copy }; - | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait -LL | let a = u.n; - | --- value moved here -LL | let a = u.n; //~ ERROR use of moved value: `u.n` - | ^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:68:21 - | -LL | let mut u = Ucn { c: Copy }; - | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait -LL | let a = u.n; - | --- value moved here -LL | let a = u.c; //~ ERROR use of moved value: `u.c` - | ^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:83:21 - | -LL | let mut u = Ucn { c: Copy }; - | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait -LL | let a = u.n; - | --- value moved here -LL | let a = u; //~ ERROR use of partially moved value: `u` - | ^ value used here after move - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-union-move.rs b/src/test/ui/borrowck/borrowck-union-move.rs index e2480604f29c7..d0aa6dff74410 100644 --- a/src/test/ui/borrowck/borrowck-union-move.rs +++ b/src/test/ui/borrowck/borrowck-union-move.rs @@ -23,17 +23,17 @@ fn main() { { let mut u = Unn { n1: NonCopy }; let a = u.n1; - let a = u.n1; //~ ERROR use of moved value: `u.n1` + let a = u.n1; //~ ERROR use of moved value: `u` } { let mut u = Unn { n1: NonCopy }; let a = u.n1; - let a = u; //~ ERROR use of partially moved value: `u` + let a = u; //~ ERROR use of moved value: `u` } { let mut u = Unn { n1: NonCopy }; let a = u.n1; - let a = u.n2; //~ ERROR use of moved value: `u.n2` + let a = u.n2; //~ ERROR use of moved value: `u` } // 2 Copy { @@ -60,12 +60,12 @@ fn main() { { let mut u = Ucn { c: Copy }; let a = u.n; - let a = u.n; //~ ERROR use of moved value: `u.n` + let a = u.n; //~ ERROR use of moved value: `u` } { let mut u = Ucn { c: Copy }; let a = u.n; - let a = u.c; //~ ERROR use of moved value: `u.c` + let a = u.c; //~ ERROR use of moved value: `u` } { let mut u = Ucn { c: Copy }; @@ -80,7 +80,7 @@ fn main() { { let mut u = Ucn { c: Copy }; let a = u.n; - let a = u; //~ ERROR use of partially moved value: `u` + let a = u; //~ ERROR use of moved value: `u` } } } diff --git a/src/test/ui/borrowck/borrowck-union-move.stderr b/src/test/ui/borrowck/borrowck-union-move.stderr index ebd8bdc69c023..2786495334b03 100644 --- a/src/test/ui/borrowck/borrowck-union-move.stderr +++ b/src/test/ui/borrowck/borrowck-union-move.stderr @@ -1,62 +1,62 @@ -error[E0382]: use of moved value: `u.n1` - --> $DIR/borrowck-union-move.rs:26:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:26:21 | +LL | let mut u = Unn { n1: NonCopy }; + | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait LL | let a = u.n1; - | - value moved here -LL | let a = u.n1; //~ ERROR use of moved value: `u.n1` - | ^ value used here after move - | - = note: move occurs because `u.n1` has type `NonCopy`, which does not implement the `Copy` trait + | ---- value moved here +LL | let a = u.n1; //~ ERROR use of moved value: `u` + | ^^^^ value used here after move -error[E0382]: use of partially moved value: `u` - --> $DIR/borrowck-union-move.rs:31:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:31:21 | +LL | let mut u = Unn { n1: NonCopy }; + | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait LL | let a = u.n1; - | - value moved here -LL | let a = u; //~ ERROR use of partially moved value: `u` - | ^ value used here after move - | - = note: move occurs because `u.n2` has type `[type error]`, which does not implement the `Copy` trait + | ---- value moved here +LL | let a = u; //~ ERROR use of moved value: `u` + | ^ value used here after move -error[E0382]: use of moved value: `u.n2` - --> $DIR/borrowck-union-move.rs:36:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:36:21 | +LL | let mut u = Unn { n1: NonCopy }; + | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait LL | let a = u.n1; - | - value moved here -LL | let a = u.n2; //~ ERROR use of moved value: `u.n2` - | ^ value used here after move - | - = note: move occurs because `u.n2` has type `[type error]`, which does not implement the `Copy` trait + | ---- value moved here +LL | let a = u.n2; //~ ERROR use of moved value: `u` + | ^^^^ value used here after move -error[E0382]: use of moved value: `u.n` - --> $DIR/borrowck-union-move.rs:63:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:63:21 | +LL | let mut u = Ucn { c: Copy }; + | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait LL | let a = u.n; - | - value moved here -LL | let a = u.n; //~ ERROR use of moved value: `u.n` - | ^ value used here after move - | - = note: move occurs because `u.n` has type `NonCopy`, which does not implement the `Copy` trait + | --- value moved here +LL | let a = u.n; //~ ERROR use of moved value: `u` + | ^^^ value used here after move -error[E0382]: use of moved value: `u.c` - --> $DIR/borrowck-union-move.rs:68:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:68:21 | +LL | let mut u = Ucn { c: Copy }; + | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait LL | let a = u.n; - | - value moved here -LL | let a = u.c; //~ ERROR use of moved value: `u.c` - | ^ value used here after move - | - = note: move occurs because `u.c` has type `[type error]`, which does not implement the `Copy` trait + | --- value moved here +LL | let a = u.c; //~ ERROR use of moved value: `u` + | ^^^ value used here after move -error[E0382]: use of partially moved value: `u` - --> $DIR/borrowck-union-move.rs:83:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:83:21 | +LL | let mut u = Ucn { c: Copy }; + | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait LL | let a = u.n; - | - value moved here -LL | let a = u; //~ ERROR use of partially moved value: `u` - | ^ value used here after move - | - = note: move occurs because `u.c` has type `[type error]`, which does not implement the `Copy` trait + | --- value moved here +LL | let a = u; //~ ERROR use of moved value: `u` + | ^ value used here after move error: aborting due to 6 previous errors diff --git a/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr b/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr deleted file mode 100644 index 06c884e244667..0000000000000 --- a/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `s` - --> $DIR/borrowck-union-uninitialized.rs:13:9 - | -LL | s.a = 0; - | ^^^^^^^ use of possibly uninitialized `s` - -error[E0381]: assign to part of possibly uninitialized variable: `u` - --> $DIR/borrowck-union-uninitialized.rs:14:9 - | -LL | u.a = 0; - | ^^^^^^^ use of possibly uninitialized `u` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-union-uninitialized.rs b/src/test/ui/borrowck/borrowck-union-uninitialized.rs index e7d456ea746cf..9cab0b19202a0 100644 --- a/src/test/ui/borrowck/borrowck-union-uninitialized.rs +++ b/src/test/ui/borrowck/borrowck-union-uninitialized.rs @@ -10,9 +10,9 @@ fn main() { unsafe { let mut s: S; let mut u: U; - s.a = 0; - u.a = 0; - let sa = s.a; //~ ERROR use of possibly uninitialized variable: `s.a` - let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` + s.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `s` + u.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `u` + let sa = s.a; + let ua = u.a; } } diff --git a/src/test/ui/borrowck/borrowck-union-uninitialized.stderr b/src/test/ui/borrowck/borrowck-union-uninitialized.stderr index c8b22dd1c9efd..a3ab82fbe78da 100644 --- a/src/test/ui/borrowck/borrowck-union-uninitialized.stderr +++ b/src/test/ui/borrowck/borrowck-union-uninitialized.stderr @@ -1,14 +1,14 @@ -error[E0381]: use of possibly uninitialized variable: `s.a` - --> $DIR/borrowck-union-uninitialized.rs:15:13 +error[E0381]: assign to part of possibly uninitialized variable: `s` + --> $DIR/borrowck-union-uninitialized.rs:13:9 | -LL | let sa = s.a; //~ ERROR use of possibly uninitialized variable: `s.a` - | ^^ use of possibly uninitialized `s.a` +LL | s.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `s` + | ^^^^^^^ use of possibly uninitialized `s` -error[E0381]: use of possibly uninitialized variable: `u.a` - --> $DIR/borrowck-union-uninitialized.rs:16:13 +error[E0381]: assign to part of possibly uninitialized variable: `u` + --> $DIR/borrowck-union-uninitialized.rs:14:9 | -LL | let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` - | ^^ use of possibly uninitialized `u.a` +LL | u.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `u` + | ^^^^^^^ use of possibly uninitialized `u` error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr b/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr deleted file mode 100644 index 7ca277ac07428..0000000000000 --- a/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:36:12 - | -LL | let w = &mut v; - | ------ mutable borrow occurs here -LL | borrow(&*v); //~ ERROR cannot borrow `*v` - | ^^^ immutable borrow occurs here -LL | w.use_mut(); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:53:12 - | -LL | x = &mut v; - | ------ mutable borrow occurs here -LL | borrow(&*v); //~ ERROR cannot borrow `*v` - | ^^^ immutable borrow occurs here -LL | x.use_mut(); - | - mutable borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr b/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr index 14a9551acc6ea..7ca277ac07428 100644 --- a/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr +++ b/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr @@ -1,24 +1,22 @@ -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:36:13 +error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-uniq-via-lend.rs:36:12 | LL | let w = &mut v; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | borrow(&*v); //~ ERROR cannot borrow `*v` - | ^^ immutable borrow occurs here + | ^^^ immutable borrow occurs here LL | w.use_mut(); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:53:13 +error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-uniq-via-lend.rs:53:12 | LL | x = &mut v; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | borrow(&*v); //~ ERROR cannot borrow `*v` - | ^^ immutable borrow occurs here + | ^^^ immutable borrow occurs here LL | x.use_mut(); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.stderr b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.stderr deleted file mode 100644 index abe515788292b..0000000000000 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `*w` - --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 - | -LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - | ^^^^^^^^ use of possibly uninitialized `*w` - -error[E0381]: use of possibly uninitialized variable: `*w` - --> $DIR/borrowck-use-in-index-lvalue.rs:10:5 - | -LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - | ^^^^^^^^ use of possibly uninitialized `*w` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr deleted file mode 100644 index 181912320e57b..0000000000000 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 - | -LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - | ^^^^ use of possibly uninitialized `*w` - -error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:10:5 - | -LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - | ^^^^ use of possibly uninitialized `*w` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs index f953dec444ab9..d30b1de5cd00f 100644 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs +++ b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs @@ -1,14 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn test() { let w: &mut [isize]; - w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - //[mir]~^ ERROR [E0381] + w[5] = 0; //~ ERROR [E0381] let mut w: &mut [isize]; - w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - //[mir]~^ ERROR [E0381] + w[5] = 0; //~ ERROR [E0381] } fn main() { test(); } diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.stderr similarity index 63% rename from src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-use-in-index-lvalue.stderr index 181912320e57b..2b6bf25fdf7d0 100644 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.stderr @@ -1,13 +1,13 @@ error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 + --> $DIR/borrowck-use-in-index-lvalue.rs:3:5 | -LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] +LL | w[5] = 0; //~ ERROR [E0381] | ^^^^ use of possibly uninitialized `*w` error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:10:5 + --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 | -LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] +LL | w[5] = 0; //~ ERROR [E0381] | ^^^^ use of possibly uninitialized `*w` error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-use-mut-borrow.nll.stderr b/src/test/ui/borrowck/borrowck-use-mut-borrow.nll.stderr deleted file mode 100644 index e7b972fb0141a..0000000000000 --- a/src/test/ui/borrowck/borrowck-use-mut-borrow.nll.stderr +++ /dev/null @@ -1,95 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:11:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed - | ^ use of borrowed `x` -LL | *p = 2; - | ------ borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:18:10 - | -LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here -LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed - | ^ use of borrowed `x.a` -LL | *p = 3; - | ------ borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:25:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed - | ^^^ use of borrowed `x` -LL | p.a = 3; - | ------- borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:32:10 - | -LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here -LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed - | ^^^ use of borrowed `x.a` -LL | *p = 3; - | ------ borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:39:13 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed - | ^^^^^^^^^^^^^^^^ use of borrowed `x` -LL | drop(y); -LL | p.a = 4; - | ------- borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:47:13 - | -LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here -LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed - | ^^^^^^^^^^^^^^^^ use of borrowed `x.a` -LL | drop(y); -LL | *p = 4; - | ------ borrow later used here - -error[E0503]: cannot use `*x` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:55:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(*x); //~ ERROR cannot use `*x` because it was mutably borrowed - | ^^ use of borrowed `x` -LL | **p = 2; - | ------- borrow later used here - -error[E0503]: cannot use `*x.b` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:62:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed - | ^^^^ use of borrowed `x` -LL | p.a = 3; - | ------- borrow later used here - -error[E0503]: cannot use `*x.b` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:69:10 - | -LL | let p = &mut x.b; - | -------- borrow of `x.b` occurs here -LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed - | ^^^^ use of borrowed `x.b` -LL | **p = 3; - | ------- borrow later used here - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr b/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr index b6b09f008a4e0..e7b972fb0141a 100644 --- a/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr +++ b/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr @@ -2,73 +2,93 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:11:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed | ^ use of borrowed `x` +LL | *p = 2; + | ------ borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:18:10 | LL | let p = &mut x.a; - | --- borrow of `x.a` occurs here + | -------- borrow of `x.a` occurs here LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed | ^ use of borrowed `x.a` +LL | *p = 3; + | ------ borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:25:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed | ^^^ use of borrowed `x` +LL | p.a = 3; + | ------- borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:32:10 | LL | let p = &mut x.a; - | --- borrow of `x.a` occurs here + | -------- borrow of `x.a` occurs here LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed | ^^^ use of borrowed `x.a` +LL | *p = 3; + | ------ borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:39:26 + --> $DIR/borrowck-use-mut-borrow.rs:39:13 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed - | ^ use of borrowed `x` + | ^^^^^^^^^^^^^^^^ use of borrowed `x` +LL | drop(y); +LL | p.a = 4; + | ------- borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:47:26 + --> $DIR/borrowck-use-mut-borrow.rs:47:13 | LL | let p = &mut x.a; - | --- borrow of `x.a` occurs here + | -------- borrow of `x.a` occurs here LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed - | ^ use of borrowed `x.a` + | ^^^^^^^^^^^^^^^^ use of borrowed `x.a` +LL | drop(y); +LL | *p = 4; + | ------ borrow later used here error[E0503]: cannot use `*x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:55:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(*x); //~ ERROR cannot use `*x` because it was mutably borrowed | ^^ use of borrowed `x` +LL | **p = 2; + | ------- borrow later used here error[E0503]: cannot use `*x.b` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:62:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed | ^^^^ use of borrowed `x` +LL | p.a = 3; + | ------- borrow later used here error[E0503]: cannot use `*x.b` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:69:10 | LL | let p = &mut x.b; - | --- borrow of `x.b` occurs here + | -------- borrow of `x.b` occurs here LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed | ^^^^ use of borrowed `x.b` +LL | **p = 3; + | ------- borrow later used here error: aborting due to 9 previous errors diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr deleted file mode 100644 index ecb8922ff8df8..0000000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `*x` - --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:12:13 - | -LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs index 518228a50ff56..1e272372f6c94 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Variation on `borrowck-use-uninitialized-in-cast` in which we do a // trait cast from an uninitialized source. Issue #20791. @@ -9,6 +6,5 @@ impl Foo for i32 { } fn main() { let x: &i32; - let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` - //[mir]~^ ERROR [E0381] + let y = x as *const Foo; //~ ERROR [E0381] } diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr similarity index 59% rename from src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr index 8f4b02a1df3a4..931a983173450 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr @@ -1,7 +1,7 @@ error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:12:13 + --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13 | -LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` +LL | let y = x as *const Foo; //~ ERROR [E0381] | ^ use of possibly uninitialized `*x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr deleted file mode 100644 index dd0a7509a2b06..0000000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast.rs:10:13 - | -LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr deleted file mode 100644 index d3ddf24d22dd1..0000000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `*x` - --> $DIR/borrowck-use-uninitialized-in-cast.rs:10:13 - | -LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr deleted file mode 100644 index dd0a7509a2b06..0000000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast.rs:10:13 - | -LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs index e15479bde283d..a355a546dc6bf 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs @@ -1,12 +1,8 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Check that we detect unused values that are cast to other things. // The problem was specified to casting to `*`, as creating unsafe // pointers was not being fully checked. Issue #20791. fn main() { let x: &i32; - let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] - //[mir]~^ ERROR [E0381] + let y = x as *const i32; //~ ERROR [E0381] } diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.stderr similarity index 59% rename from src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr rename to src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.stderr index 8f4b02a1df3a4..a8aca4152798a 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.stderr @@ -1,7 +1,7 @@ error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:12:13 + --> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13 | -LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` +LL | let y = x as *const i32; //~ ERROR [E0381] | ^ use of possibly uninitialized `*x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr deleted file mode 100644 index eabd0731388dc..0000000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-element-loan.rs:10:5 - | -LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ---- `vec` is borrowed here -... -LL | tail - | ^^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-element-loan.rs:20:5 - | -LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ---- `vec` is borrowed here -... -LL | init - | ^^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-element-loan.rs:30:5 - | -LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ---- `vec` is borrowed here -... -LL | slice - | ^^^^^ returns a value referencing data owned by the current function - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs index 0de5132466bfb..100384d78c8ea 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs @@ -2,32 +2,32 @@ fn a<'a>() -> &'a [isize] { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough + let vec: &[isize] = &vec; let tail = match vec { &[_, ref tail..] => tail, _ => panic!("a") }; - tail + tail //~ ERROR cannot return value referencing local variable `vec` } fn b<'a>() -> &'a [isize] { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough + let vec: &[isize] = &vec; let init = match vec { &[ref init.., _] => init, _ => panic!("b") }; - init + init //~ ERROR cannot return value referencing local variable `vec` } fn c<'a>() -> &'a [isize] { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough + let vec: &[isize] = &vec; let slice = match vec { &[_, ref slice.., _] => slice, _ => panic!("c") }; - slice + slice //~ ERROR cannot return value referencing local variable `vec` } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr index b2fcb2f8cd1b7..d5290a5ba186a 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr @@ -1,48 +1,30 @@ -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:5:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:10:5 | -LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ^^^ borrowed value does not live long enough +LL | let vec: &[isize] = &vec; + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 3:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:3:6 - | -LL | fn a<'a>() -> &'a [isize] { - | ^^ +LL | tail //~ ERROR cannot return value referencing local variable `vec` + | ^^^^ returns a value referencing data owned by the current function -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:15:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:20:5 | -LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ^^^ borrowed value does not live long enough +LL | let vec: &[isize] = &vec; + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:13:6 - | -LL | fn b<'a>() -> &'a [isize] { - | ^^ +LL | init //~ ERROR cannot return value referencing local variable `vec` + | ^^^^ returns a value referencing data owned by the current function -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:25:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:30:5 | -LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ^^^ borrowed value does not live long enough +LL | let vec: &[isize] = &vec; + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:23:6 - | -LL | fn c<'a>() -> &'a [isize] { - | ^^ +LL | slice //~ ERROR cannot return value referencing local variable `vec` + | ^^^^^ returns a value referencing data owned by the current function error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr deleted file mode 100644 index 0059dd60f8407..0000000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/borrowck-vec-pattern-loan-from-mut.rs:8:13 - | -LL | let vb: &mut [isize] = &mut v; - | ------ first mutable borrow occurs here -... -LL | v.push(tail[0] + tail[1]); //~ ERROR cannot borrow - | ^ ------- first borrow later used here - | | - | second mutable borrow occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr index caadcb3611545..0059dd60f8407 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr @@ -2,13 +2,12 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/borrowck-vec-pattern-loan-from-mut.rs:8:13 | LL | let vb: &mut [isize] = &mut v; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here ... LL | v.push(tail[0] + tail[1]); //~ ERROR cannot borrow - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^ ------- first borrow later used here + | | + | second mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.stderr deleted file mode 100644 index c456dac316db8..0000000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `a[..]` because it is borrowed - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 - | -LL | [1, 2, ref tail..] => tail, - | -------- borrow of `a[..]` occurs here -... -LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed - | ^^^^^^^^ assignment to borrowed `a[..]` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr deleted file mode 100644 index 6eb9eac760f00..0000000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0506]: cannot assign to `a[..]` because it is borrowed (Ast) - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 - | -LL | [1, 2, ref tail..] => tail, - | -------- borrow of `a[..]` occurs here -... -LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed - | ^^^^^^^^ assignment to borrowed `a[..]` occurs here - -error[E0506]: cannot assign to `a[_]` because it is borrowed (Mir) - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 - | -LL | [1, 2, ref tail..] => tail, - | -------- borrow of `a[_]` occurs here -... -LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed - | ^^^^^^^^ assignment to borrowed `a[_]` occurs here -... -LL | println!("t[0]: {}", t[0]); - | ---- borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs index e14ecd90d56fb..efc52530716c8 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs @@ -1,8 +1,4 @@ // http://rust-lang.org/COPYRIGHT. -// - -// revisions: ast cmp -//[cmp]compile-flags: -Z borrowck=compare #![feature(slice_patterns)] @@ -13,9 +9,7 @@ fn main() { _ => unreachable!() }; println!("t[0]: {}", t[0]); - a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed - //[cmp]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast) - //[cmp]~| ERROR cannot assign to `a[_]` because it is borrowed (Mir) + a[2] = 0; //~ ERROR cannot assign to `a[_]` because it is borrowed println!("t[0]: {}", t[0]); t[0]; } diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.stderr similarity index 76% rename from src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-vec-pattern-move-tail.stderr index 6dc2778892d2e..9c147679ae2d2 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.stderr @@ -1,12 +1,11 @@ error[E0506]: cannot assign to `a[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 + --> $DIR/borrowck-vec-pattern-move-tail.rs:12:5 | LL | [1, 2, ref tail..] => tail, | -------- borrow of `a[_]` occurs here ... -LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed +LL | a[2] = 0; //~ ERROR cannot assign to `a[_]` because it is borrowed | ^^^^^^^^ assignment to borrowed `a[_]` occurs here -... LL | println!("t[0]: {}", t[0]); | ---- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr deleted file mode 100644 index 018a3173af1b0..0000000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr +++ /dev/null @@ -1,117 +0,0 @@ -error[E0506]: cannot assign to `vec[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:10:13 - | -LL | [box ref _a, _, _] => { - | ------ borrow of `vec[_]` occurs here -LL | //~^ borrow of `vec[..]` occurs here -LL | vec[0] = box 4; //~ ERROR cannot assign - | ^^^^^^ assignment to borrowed `vec[_]` occurs here -LL | //~^ assignment to borrowed `vec[..]` occurs here -LL | _a.use_ref(); - | -- borrow later used here - -error[E0506]: cannot assign to `vec[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 - | -LL | &mut [ref _b..] => { - | ------ borrow of `vec[_]` occurs here -LL | //~^ borrow of `vec[..]` occurs here -LL | vec[0] = box 4; //~ ERROR cannot assign - | ^^^^^^ assignment to borrowed `vec[_]` occurs here -LL | //~^ assignment to borrowed `vec[..]` occurs here -LL | _b.use_ref(); - | -- borrow later used here - -error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:33:11 - | -LL | match vec { - | ^^^ cannot move out of here -LL | &mut [_a, //~ ERROR cannot move out - | -- data moved here - | -note: move occurs because `_a` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/borrowck-vec-pattern-nesting.rs:34:15 - | -LL | &mut [_a, //~ ERROR cannot move out - | ^^ -help: consider removing the `&mut` - | -LL | [_a, //~ ERROR cannot move out -LL | //~| cannot move out -LL | //~| to prevent move -LL | .. -LL | ] => { - | - -error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:47:13 - | -LL | let a = vec[0]; //~ ERROR cannot move out - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&vec[0]` - -error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:54:11 - | -LL | match vec { - | ^^^ cannot move out of here -... -LL | _b] => {} - | -- data moved here - | -note: move occurs because `_b` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/borrowck-vec-pattern-nesting.rs:57:10 - | -LL | _b] => {} - | ^^ -help: consider removing the `&mut` - | -LL | [ //~ ERROR cannot move out -LL | //~^ cannot move out -LL | _b] => {} - | - -error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:60:13 - | -LL | let a = vec[0]; //~ ERROR cannot move out - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&vec[0]` - -error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:67:11 - | -LL | match vec { - | ^^^ cannot move out of here -LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out - | ----------------- - | | | | | - | | | | ...and here - | | | ...and here - | | data moved here - | help: consider removing the `&mut`: `[_a, _b, _c]` - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-vec-pattern-nesting.rs:68:15 - | -LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out - | ^^ ^^ ^^ - -error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:72:13 - | -LL | let a = vec[0]; //~ ERROR cannot move out - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&vec[0]` - -error: aborting due to 8 previous errors - -Some errors occurred: E0506, E0508. -For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs index 46203b7a3deed..3e2935f6df156 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs @@ -6,10 +6,11 @@ fn a() { let mut vec = [box 1, box 2, box 3]; match vec { [box ref _a, _, _] => { - //~^ borrow of `vec[..]` occurs here + //~^ NOTE borrow of `vec[_]` occurs here vec[0] = box 4; //~ ERROR cannot assign - //~^ assignment to borrowed `vec[..]` occurs here + //~^ NOTE assignment to borrowed `vec[_]` occurs here _a.use_ref(); + //~^ NOTE borrow later used here } } } @@ -19,10 +20,11 @@ fn b() { let vec: &mut [Box] = &mut vec; match vec { &mut [ref _b..] => { - //~^ borrow of `vec[..]` occurs here + //~^ borrow of `vec[_]` occurs here vec[0] = box 4; //~ ERROR cannot assign - //~^ assignment to borrowed `vec[..]` occurs here + //~^ NOTE assignment to borrowed `vec[_]` occurs here _b.use_ref(); + //~^ NOTE borrow later used here } } } @@ -31,46 +33,57 @@ fn c() { let mut vec = vec![box 1, box 2, box 3]; let vec: &mut [Box] = &mut vec; match vec { - &mut [_a, //~ ERROR cannot move out - //~| cannot move out - //~| to prevent move + //~^ ERROR cannot move out + //~| NOTE cannot move out + &mut [_a, + //~^ NOTE data moved here + //~| NOTE move occurs because `_a` has type + //~| HELP consider removing the `&mut` .. ] => { - // Note: `_a` is *moved* here, but `b` is borrowing, - // hence illegal. - // - // See comment in middle/borrowck/gather_loans/mod.rs - // in the case covering these sorts of vectors. } _ => {} } let a = vec[0]; //~ ERROR cannot move out - //~| cannot move out of here + //~| NOTE cannot move out of here + //~| HELP consider borrowing here } fn d() { let mut vec = vec![box 1, box 2, box 3]; let vec: &mut [Box] = &mut vec; match vec { - &mut [ //~ ERROR cannot move out - //~^ cannot move out + //~^ ERROR cannot move out + //~| NOTE cannot move out + &mut [ + //~^ HELP consider removing the `&mut` _b] => {} + //~^ NOTE data moved here + //~| NOTE move occurs because `_b` has type _ => {} } let a = vec[0]; //~ ERROR cannot move out - //~| cannot move out of here + //~| NOTE cannot move out of here + //~| HELP consider borrowing here } fn e() { let mut vec = vec![box 1, box 2, box 3]; let vec: &mut [Box] = &mut vec; match vec { - &mut [_a, _b, _c] => {} //~ ERROR cannot move out - //~| cannot move out + //~^ ERROR cannot move out + //~| NOTE cannot move out + &mut [_a, _b, _c] => {} + //~^ NOTE data moved here + //~| NOTE and here + //~| NOTE and here + //~| HELP consider removing the `&mut` + //~| NOTE move occurs because these variables have types _ => {} } let a = vec[0]; //~ ERROR cannot move out - //~| cannot move out of here + //~| NOTE cannot move out of here + //~| HELP consider borrowing here } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 25825fea15877..9371d99ce93a8 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -1,33 +1,50 @@ -error[E0506]: cannot assign to `vec[..]` because it is borrowed +error[E0506]: cannot assign to `vec[_]` because it is borrowed --> $DIR/borrowck-vec-pattern-nesting.rs:10:13 | LL | [box ref _a, _, _] => { - | ------ borrow of `vec[..]` occurs here -LL | //~^ borrow of `vec[..]` occurs here + | ------ borrow of `vec[_]` occurs here +LL | //~^ NOTE borrow of `vec[_]` occurs here LL | vec[0] = box 4; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^ assignment to borrowed `vec[..]` occurs here + | ^^^^^^ assignment to borrowed `vec[_]` occurs here +LL | //~^ NOTE assignment to borrowed `vec[_]` occurs here +LL | _a.use_ref(); + | -- borrow later used here -error[E0506]: cannot assign to `vec[..]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 +error[E0506]: cannot assign to `vec[_]` because it is borrowed + --> $DIR/borrowck-vec-pattern-nesting.rs:24:13 | LL | &mut [ref _b..] => { - | ------ borrow of `vec[..]` occurs here -LL | //~^ borrow of `vec[..]` occurs here + | ------ borrow of `vec[_]` occurs here +LL | //~^ borrow of `vec[_]` occurs here LL | vec[0] = box 4; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^ assignment to borrowed `vec[..]` occurs here + | ^^^^^^ assignment to borrowed `vec[_]` occurs here +LL | //~^ NOTE assignment to borrowed `vec[_]` occurs here +LL | _b.use_ref(); + | -- borrow later used here error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:34:14 - | -LL | &mut [_a, //~ ERROR cannot move out - | ^-- hint: to prevent move, use `ref _a` or `ref mut _a` - | ______________| - | | -LL | | //~| cannot move out -LL | | //~| to prevent move -LL | | .. -LL | | ] => { - | |_________^ cannot move out of here + --> $DIR/borrowck-vec-pattern-nesting.rs:35:11 + | +LL | match vec { + | ^^^ cannot move out of here +... +LL | &mut [_a, + | -- data moved here + | +note: move occurs because `_a` has type `std::boxed::Box`, which does not implement the `Copy` trait + --> $DIR/borrowck-vec-pattern-nesting.rs:38:15 + | +LL | &mut [_a, + | ^^ +help: consider removing the `&mut` + | +LL | [_a, +LL | //~^ NOTE data moved here +LL | //~| NOTE move occurs because `_a` has type +LL | //~| HELP consider removing the `&mut` +LL | .. +LL | ] => { + | error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice --> $DIR/borrowck-vec-pattern-nesting.rs:47:13 @@ -36,47 +53,66 @@ LL | let a = vec[0]; //~ ERROR cannot move out | ^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&vec[0]` + | help: consider borrowing here: `&vec[0]` error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:55:14 - | -LL | &mut [ //~ ERROR cannot move out - | ______________^ -LL | | //~^ cannot move out -LL | | _b] => {} - | |__________--^ cannot move out of here - | | - | hint: to prevent move, use `ref _b` or `ref mut _b` + --> $DIR/borrowck-vec-pattern-nesting.rs:55:11 + | +LL | match vec { + | ^^^ cannot move out of here +... +LL | _b] => {} + | -- data moved here + | +note: move occurs because `_b` has type `std::boxed::Box`, which does not implement the `Copy` trait + --> $DIR/borrowck-vec-pattern-nesting.rs:60:10 + | +LL | _b] => {} + | ^^ +help: consider removing the `&mut` + | +LL | [ +LL | //~^ HELP consider removing the `&mut` +LL | _b] => {} + | error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:60:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:65:13 | LL | let a = vec[0]; //~ ERROR cannot move out | ^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&vec[0]` + | help: consider borrowing here: `&vec[0]` error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:68:14 - | -LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out - | ^--^^--^^--^ - | || | | - | || | ...and here (use `ref _c` or `ref mut _c`) - | || ...and here (use `ref _b` or `ref mut _b`) - | |hint: to prevent move, use `ref _a` or `ref mut _a` - | cannot move out of here + --> $DIR/borrowck-vec-pattern-nesting.rs:73:11 + | +LL | match vec { + | ^^^ cannot move out of here +... +LL | &mut [_a, _b, _c] => {} + | ----------------- + | | | | | + | | | | ...and here + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `[_a, _b, _c]` + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-vec-pattern-nesting.rs:76:15 + | +LL | &mut [_a, _b, _c] => {} + | ^^ ^^ ^^ error[E0508]: cannot move out of type `[std::boxed::Box]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:72:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:84:13 | LL | let a = vec[0]; //~ ERROR cannot move out | ^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&vec[0]` + | help: consider borrowing here: `&vec[0]` error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr deleted file mode 100644 index d9d3930dc49a7..0000000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:10:5 - | -LL | let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough - | ---- `vec` is borrowed here -... -LL | tail - | ^^^^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs index b18052a689936..e602e75886d95 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs @@ -2,12 +2,12 @@ fn a<'a>() -> &'a isize { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough + let vec: &[isize] = &vec; let tail = match vec { &[_a, ref tail..] => &tail[0], _ => panic!("foo") }; - tail + tail //~ ERROR cannot return value referencing local variable `vec` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr index a4584aac0e8d7..cfd1dcb4065b6 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr @@ -1,18 +1,12 @@ -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:5:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:10:5 | -LL | let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough - | ^^^ borrowed value does not live long enough +LL | let vec: &[isize] = &vec; + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 3:6... - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:3:6 - | -LL | fn a<'a>() -> &'a isize { - | ^^ +LL | tail //~ ERROR cannot return value referencing local variable `vec` + | ^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-while-break.nll.stderr b/src/test/ui/borrowck/borrowck-while-break.nll.stderr deleted file mode 100644 index 1defa3da60ce8..0000000000000 --- a/src/test/ui/borrowck/borrowck-while-break.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `v` - --> $DIR/borrowck-while-break.rs:7:20 - | -LL | println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` - | ^ use of possibly uninitialized `v` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-while-break.rs b/src/test/ui/borrowck/borrowck-while-break.rs index 293760efba5e5..e16bc58656d81 100644 --- a/src/test/ui/borrowck/borrowck-while-break.rs +++ b/src/test/ui/borrowck/borrowck-while-break.rs @@ -4,7 +4,7 @@ fn test(cond: bool) { v = 3; break; } - println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` + println!("{}", v); //~ ERROR borrow of possibly uninitialized variable: `v` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-while-break.stderr b/src/test/ui/borrowck/borrowck-while-break.stderr index f35d43162b244..39066b83ca513 100644 --- a/src/test/ui/borrowck/borrowck-while-break.stderr +++ b/src/test/ui/borrowck/borrowck-while-break.stderr @@ -1,7 +1,7 @@ -error[E0381]: use of possibly uninitialized variable: `v` +error[E0381]: borrow of possibly uninitialized variable: `v` --> $DIR/borrowck-while-break.rs:7:20 | -LL | println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` +LL | println!("{}", v); //~ ERROR borrow of possibly uninitialized variable: `v` | ^ use of possibly uninitialized `v` error: aborting due to previous error diff --git a/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr b/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr deleted file mode 100644 index cd88e25cc42c7..0000000000000 --- a/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/index-mut-help-with-impl.rs:9:5 - | -LL | Index::index(&v, 1..2).make_ascii_uppercase(); //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/index-mut-help-with-impl.stderr b/src/test/ui/borrowck/index-mut-help-with-impl.stderr index 260ef7c92d0f5..cd88e25cc42c7 100644 --- a/src/test/ui/borrowck/index-mut-help-with-impl.stderr +++ b/src/test/ui/borrowck/index-mut-help-with-impl.stderr @@ -1,8 +1,10 @@ -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/index-mut-help-with-impl.rs:9:5 | LL | Index::index(&v, 1..2).make_ascii_uppercase(); //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | + = help: trait `IndexMut` is required to modify indexed content error: aborting due to previous error diff --git a/src/test/ui/borrowck/index-mut-help.nll.stderr b/src/test/ui/borrowck/index-mut-help.nll.stderr deleted file mode 100644 index e7047f0048db3..0000000000000 --- a/src/test/ui/borrowck/index-mut-help.nll.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/index-mut-help.rs:11:5 - | -LL | map["peter"].clear(); //~ ERROR - | ^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/index-mut-help.rs:12:5 - | -LL | map["peter"] = "0".to_string(); //~ ERROR - | ^^^^^^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/index-mut-help.rs:13:13 - | -LL | let _ = &mut map["peter"]; //~ ERROR - | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` - -error: aborting due to 3 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/index-mut-help.stderr b/src/test/ui/borrowck/index-mut-help.stderr index 985fa9f0361ee..e7047f0048db3 100644 --- a/src/test/ui/borrowck/index-mut-help.stderr +++ b/src/test/ui/borrowck/index-mut-help.stderr @@ -1,4 +1,4 @@ -error[E0596]: cannot borrow immutable indexed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/index-mut-help.rs:11:5 | LL | map["peter"].clear(); //~ ERROR @@ -6,19 +6,17 @@ LL | map["peter"].clear(); //~ ERROR | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` -error[E0594]: cannot assign to immutable indexed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/index-mut-help.rs:12:5 | LL | map["peter"] = "0".to_string(); //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` + | ^^^^^^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable indexed content as mutable - --> $DIR/index-mut-help.rs:13:18 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/index-mut-help.rs:13:13 | LL | let _ = &mut map["peter"]; //~ ERROR - | ^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` diff --git a/src/test/ui/borrowck/issue-45983.ast.stderr b/src/test/ui/borrowck/issue-45983.ast.stderr deleted file mode 100644 index 9cb83c92cae84..0000000000000 --- a/src/test/ui/borrowck/issue-45983.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: borrowed data cannot be stored outside of its closure - --> $DIR/issue-45983.rs:26:27 - | -LL | let x = None; - | - borrowed data cannot be stored into here... -LL | give_any(|y| x = Some(y)); - | --- ^ cannot be stored outside of its closure - | | - | ...because it cannot outlive this closure - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/issue-45983.migrate.stderr b/src/test/ui/borrowck/issue-45983.migrate.stderr index 9cb83c92cae84..3a6b2f69a1ffc 100644 --- a/src/test/ui/borrowck/issue-45983.migrate.stderr +++ b/src/test/ui/borrowck/issue-45983.migrate.stderr @@ -1,5 +1,5 @@ error: borrowed data cannot be stored outside of its closure - --> $DIR/issue-45983.rs:26:27 + --> $DIR/issue-45983.rs:19:27 | LL | let x = None; | - borrowed data cannot be stored into here... diff --git a/src/test/ui/borrowck/issue-45983.nll.stderr b/src/test/ui/borrowck/issue-45983.nll.stderr index 0a03858d568ee..d1eaf17bf1cac 100644 --- a/src/test/ui/borrowck/issue-45983.nll.stderr +++ b/src/test/ui/borrowck/issue-45983.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/issue-45983.rs:26:18 + --> $DIR/issue-45983.rs:19:18 | LL | let x = None; | - `x` is declared here, outside of the closure body @@ -9,7 +9,7 @@ LL | give_any(|y| x = Some(y)); | `y` is a reference that is only valid in the closure body error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-45983.rs:26:18 + --> $DIR/issue-45983.rs:19:18 | LL | let x = None; | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/borrowck/issue-45983.rs b/src/test/ui/borrowck/issue-45983.rs index 4dac67d9ae900..a2656f5939aa1 100644 --- a/src/test/ui/borrowck/issue-45983.rs +++ b/src/test/ui/borrowck/issue-45983.rs @@ -1,21 +1,14 @@ // As documented in Issue #45983, this test is evaluating the quality // of our diagnostics on erroneous code using higher-ranked closures. -// -// However, as documented on Issue #53026, this test also became a -// prime example of our need to test the NLL migration mode -// *separately* from the existing test suites that focus solely on -// AST-borrwock and NLL. -// revisions: ast migrate nll +// revisions: migrate nll // Since we are testing nll (and migration) explicitly as a separate // revisions, don't worry about the --compare-mode=nll on this test. // ignore-compare-mode-nll -//[ast]compile-flags: -Z borrowck=ast -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir fn give_any FnOnce(&'r ())>(f: F) { f(&()); @@ -24,8 +17,7 @@ fn give_any FnOnce(&'r ())>(f: F) { fn main() { let x = None; give_any(|y| x = Some(y)); - //[ast]~^ ERROR borrowed data cannot be stored outside of its closure - //[migrate]~^^ ERROR borrowed data cannot be stored outside of its closure - //[nll]~^^^ ERROR borrowed data escapes outside of closure + //[migrate]~^ ERROR borrowed data cannot be stored outside of its closure + //[nll]~^^ ERROR borrowed data escapes outside of closure //[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable } diff --git a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.nll.stderr b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.nll.stderr deleted file mode 100644 index 255eb757a4989..0000000000000 --- a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of static item - --> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 - | -LL | let mut x = X; //~ ERROR cannot move out of thread-local static item [E0507] - | ^ - | | - | cannot move out of static item - | help: consider borrowing here: `&X` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs index 7477947b89ca4..48dd14c4976cb 100644 --- a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs +++ b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs @@ -14,7 +14,7 @@ static mut X: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::AtomicUsiz fn main() { unsafe { - let mut x = X; //~ ERROR cannot move out of thread-local static item [E0507] + let mut x = X; //~ ERROR cannot move out of static item [E0507] let _y = x.get_mut(); } } diff --git a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr index 219a1fd2e7727..4a88c55507681 100644 --- a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr +++ b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of thread-local static item +error[E0507]: cannot move out of static item --> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 | -LL | let mut x = X; //~ ERROR cannot move out of thread-local static item [E0507] +LL | let mut x = X; //~ ERROR cannot move out of static item [E0507] | ^ | | - | cannot move out of thread-local static item - | help: consider using a reference instead: `&X` + | cannot move out of static item + | help: consider borrowing here: `&X` error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-51117.nll.stderr b/src/test/ui/borrowck/issue-51117.nll.stderr deleted file mode 100644 index 140be098a99de..0000000000000 --- a/src/test/ui/borrowck/issue-51117.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `*bar` as mutable more than once at a time - --> $DIR/issue-51117.rs:10:13 - | -LL | Some(baz) => { - | --- first mutable borrow occurs here -LL | bar.take(); //~ ERROR cannot borrow - | ^^^ second mutable borrow occurs here -LL | drop(baz); - | --- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/issue-51117.stderr b/src/test/ui/borrowck/issue-51117.stderr index 783ba8df1a6e7..140be098a99de 100644 --- a/src/test/ui/borrowck/issue-51117.stderr +++ b/src/test/ui/borrowck/issue-51117.stderr @@ -5,9 +5,8 @@ LL | Some(baz) => { | --- first mutable borrow occurs here LL | bar.take(); //~ ERROR cannot borrow | ^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here +LL | drop(baz); + | --- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-51415.nll.stderr b/src/test/ui/borrowck/issue-51415.nll.stderr deleted file mode 100644 index b025374257f7c..0000000000000 --- a/src/test/ui/borrowck/issue-51415.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-51415.rs:6:42 - | -LL | let opt = a.iter().enumerate().find(|(_, &s)| { - | ^^^^^-^ - | | | - | | data moved here - | cannot move out of borrowed content - | -note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/issue-51415.rs:6:47 - | -LL | let opt = a.iter().enumerate().find(|(_, &s)| { - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/issue-51415.stderr b/src/test/ui/borrowck/issue-51415.stderr index 895c35e4e776a..b025374257f7c 100644 --- a/src/test/ui/borrowck/issue-51415.stderr +++ b/src/test/ui/borrowck/issue-51415.stderr @@ -1,11 +1,17 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/issue-51415.rs:6:46 + --> $DIR/issue-51415.rs:6:42 | LL | let opt = a.iter().enumerate().find(|(_, &s)| { - | ^- - | || - | |hint: to prevent move, use `ref s` or `ref mut s` - | cannot move out of borrowed content + | ^^^^^-^ + | | | + | | data moved here + | cannot move out of borrowed content + | +note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/issue-51415.rs:6:47 + | +LL | let opt = a.iter().enumerate().find(|(_, &s)| { + | ^ error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs b/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs index dcf047c545fe9..fc8a075540b3f 100644 --- a/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs +++ b/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs @@ -2,9 +2,8 @@ // the initial deployment of NLL for the 2018 edition, I forgot to // turn on two-phase-borrows in addition to `-Z borrowck=migrate`. -// revisions: ast zflags edition -//[zflags]compile-flags: -Z borrowck=migrate -Z two-phase-borrows -//[edition]edition:2018 +// revisions: edition2015 edition2018 +//[edition2018]edition:2018 // run-pass diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr deleted file mode 100644 index d72cc20971b0e..0000000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `t.0` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:31 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.0` - -error[E0381]: use of possibly uninitialized variable: `t.1` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:36 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.1` - -error[E0381]: use of possibly uninitialized variable: `u.0` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:31 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.0` - -error[E0381]: use of possibly uninitialized variable: `u.1` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:36 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.1` - -error[E0381]: use of possibly uninitialized variable: `v.x` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:31 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.x` - -error[E0381]: use of possibly uninitialized variable: `v.y` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:36 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.y` - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs index 4358e8e440237..8d8ac279b23a8 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -20,30 +10,24 @@ fn main() { { let mut t: Tuple; t.0 = S(1); - //[nll]~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] t.1 = 2; println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381] } { let mut u: Tpair; u.0 = S(1); - //[nll]~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] u.1 = 2; println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381] } { let mut v: Spair; v.x = S(1); - //[nll]~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] v.y = 2; println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381] } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.stderr similarity index 75% rename from src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr rename to src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.stderr index ebc6c7fca62b9..6f18ff161372a 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.stderr @@ -1,17 +1,17 @@ error[E0381]: assign to part of possibly uninitialized variable: `t` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:22:9 + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:12:9 | LL | t.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `t` error[E0381]: assign to part of possibly uninitialized variable: `u` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:32:9 + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:20:9 | LL | u.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `u` error[E0381]: assign to part of possibly uninitialized variable: `v` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:42:9 + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:28:9 | LL | v.x = S(1); | ^^^^^^^^^^ use of possibly uninitialized `v` diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr deleted file mode 100644 index 4f845d87aa2f8..0000000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0382]: use of moved value: `t.0` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:26:31 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `t.1` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:26:36 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.0` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:37:31 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.1` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:37:36 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.x` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:48:31 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.y` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:48:36 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs index 358a5dd1cbdcf..f7fb2fd4da914 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -21,32 +11,26 @@ fn main() { let mut t: Tuple = (S(0), 0); drop(t); t.0 = S(1); - //[nll]~^ ERROR assign to part of moved value + //~^ ERROR assign to part of moved value t.1 = 2; println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of moved value - //[ast]~^^ ERROR use of moved value } { let mut u: Tpair = Tpair(S(0), 0); drop(u); u.0 = S(1); - //[nll]~^ ERROR assign to part of moved value + //~^ ERROR assign to part of moved value u.1 = 2; println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of moved value - //[ast]~^^ ERROR use of moved value } { let mut v: Spair = Spair { x: S(0), y: 0 }; drop(v); v.x = S(1); - //[nll]~^ ERROR assign to part of moved value + //~^ ERROR assign to part of moved value v.y = 2; println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of moved value - //[ast]~^^ ERROR use of moved value } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.stderr similarity index 94% rename from src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr rename to src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.stderr index 42aa038170238..b188766e221be 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.stderr @@ -1,5 +1,5 @@ error[E0382]: assign to part of moved value: `t` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:23:9 + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:13:9 | LL | let mut t: Tuple = (S(0), 0); | ----- move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | t.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `u` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:34:9 + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:22:9 | LL | let mut u: Tpair = Tpair(S(0), 0); | ----- move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait @@ -19,7 +19,7 @@ LL | u.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `v` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:45:9 + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:31:9 | LL | let mut v: Spair = Spair { x: S(0), y: 0 }; | ----- move occurs because `v` has type `Spair`, which does not implement the `Copy` trait diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr deleted file mode 100644 index 565272af39049..0000000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr +++ /dev/null @@ -1,124 +0,0 @@ -error[E0594]: cannot assign to field `t.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 - | -LL | let t: Tuple = (S(0), 0); - | - help: make this binding mutable: `mut t` -LL | drop(t); -LL | t.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `t.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 - | -LL | let t: Tuple = (S(0), 0); - | - help: make this binding mutable: `mut t` -... -LL | t.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 - | -LL | let u: Tpair = Tpair(S(0), 0); - | - help: make this binding mutable: `mut u` -LL | drop(u); -LL | u.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:42:9 - | -LL | let u: Tpair = Tpair(S(0), 0); - | - help: make this binding mutable: `mut u` -... -LL | u.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.x` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 - | -LL | let v: Spair = Spair { x: S(0), y: 0 }; - | - help: make this binding mutable: `mut v` -LL | drop(v); -LL | v.x = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.y` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:57:9 - | -LL | let v: Spair = Spair { x: S(0), y: 0 }; - | - help: make this binding mutable: `mut v` -... -LL | v.y = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0382]: use of moved value: `t.0` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:31 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `t.1` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:36 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.0` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:31 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.1` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:36 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.x` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:31 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.y` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:36 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error: aborting due to 12 previous errors - -Some errors occurred: E0382, E0594. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs index b19dcd65a6c7e..498ca01e9729f 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -21,44 +11,32 @@ fn main() { let t: Tuple = (S(0), 0); drop(t); t.0 = S(1); - //[ast]~^ ERROR cannot assign to field `t.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of moved value: `t` [E0382] - //[nll]~| ERROR cannot assign to `t.0`, as `t` is not declared as mutable [E0594] + //~^ ERROR assign to part of moved value: `t` [E0382] + //~| ERROR cannot assign to `t.0`, as `t` is not declared as mutable [E0594] t.1 = 2; - //[ast]~^ ERROR cannot assign to field `t.1` of immutable binding [E0594] - //[nll]~^^ ERROR cannot assign to `t.1`, as `t` is not declared as mutable [E0594] + //~^ ERROR cannot assign to `t.1`, as `t` is not declared as mutable [E0594] println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of moved value: `t.0` [E0382] - //[ast]~| ERROR use of moved value: `t.1` [E0382] } { let u: Tpair = Tpair(S(0), 0); drop(u); u.0 = S(1); - //[ast]~^ ERROR cannot assign to field `u.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of moved value: `u` [E0382] - //[nll]~| ERROR cannot assign to `u.0`, as `u` is not declared as mutable [E0594] + //~^ ERROR assign to part of moved value: `u` [E0382] + //~| ERROR cannot assign to `u.0`, as `u` is not declared as mutable [E0594] u.1 = 2; - //[ast]~^ ERROR cannot assign to field `u.1` of immutable binding [E0594] - //[nll]~^^ ERROR cannot assign to `u.1`, as `u` is not declared as mutable [E0594] + //~^ ERROR cannot assign to `u.1`, as `u` is not declared as mutable [E0594] println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of moved value: `u.0` [E0382] - //[ast]~| ERROR use of moved value: `u.1` [E0382] } { let v: Spair = Spair { x: S(0), y: 0 }; drop(v); v.x = S(1); - //[ast]~^ ERROR cannot assign to field `v.x` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of moved value: `v` [E0382] - //[nll]~| ERROR cannot assign to `v.x`, as `v` is not declared as mutable [E0594] + //~^ ERROR assign to part of moved value: `v` [E0382] + //~| ERROR cannot assign to `v.x`, as `v` is not declared as mutable [E0594] v.y = 2; - //[ast]~^ ERROR cannot assign to field `v.y` of immutable binding [E0594] - //[nll]~^^ ERROR cannot assign to `v.y`, as `v` is not declared as mutable [E0594] + //~^ ERROR cannot assign to `v.y`, as `v` is not declared as mutable [E0594] println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of moved value: `v.x` [E0382] - //[ast]~| ERROR use of moved value: `v.y` [E0382] } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.stderr similarity index 87% rename from src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr rename to src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.stderr index 1184907f307cb..803d28f669cc4 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `t.0`, as `t` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9 | LL | let t: Tuple = (S(0), 0); | - help: consider changing this to be mutable: `mut t` @@ -8,7 +8,7 @@ LL | t.0 = S(1); | ^^^^^^^^^^ cannot assign error[E0382]: assign to part of moved value: `t` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9 | LL | let t: Tuple = (S(0), 0); | - move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait @@ -18,7 +18,7 @@ LL | t.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0594]: cannot assign to `t.1`, as `t` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:16:9 | LL | let t: Tuple = (S(0), 0); | - help: consider changing this to be mutable: `mut t` @@ -27,7 +27,7 @@ LL | t.1 = 2; | ^^^^^^^ cannot assign error[E0594]: cannot assign to `u.0`, as `u` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9 | LL | let u: Tpair = Tpair(S(0), 0); | - help: consider changing this to be mutable: `mut u` @@ -36,7 +36,7 @@ LL | u.0 = S(1); | ^^^^^^^^^^ cannot assign error[E0382]: assign to part of moved value: `u` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9 | LL | let u: Tpair = Tpair(S(0), 0); | - move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait @@ -46,7 +46,7 @@ LL | u.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0594]: cannot assign to `u.1`, as `u` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:42:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 | LL | let u: Tpair = Tpair(S(0), 0); | - help: consider changing this to be mutable: `mut u` @@ -55,7 +55,7 @@ LL | u.1 = 2; | ^^^^^^^ cannot assign error[E0594]: cannot assign to `v.x`, as `v` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9 | LL | let v: Spair = Spair { x: S(0), y: 0 }; | - help: consider changing this to be mutable: `mut v` @@ -64,7 +64,7 @@ LL | v.x = S(1); | ^^^^^^^^^^ cannot assign error[E0382]: assign to part of moved value: `v` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9 | LL | let v: Spair = Spair { x: S(0), y: 0 }; | - move occurs because `v` has type `Spair`, which does not implement the `Copy` trait @@ -74,7 +74,7 @@ LL | v.x = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0594]: cannot assign to `v.y`, as `v` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:57:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 | LL | let v: Spair = Spair { x: S(0), y: 0 }; | - help: consider changing this to be mutable: `mut v` diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr deleted file mode 100644 index ea6b63b7a297d..0000000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr +++ /dev/null @@ -1,91 +0,0 @@ -error[E0594]: cannot assign to field `t.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:22:9 - | -LL | let t: Tuple; - | - help: make this binding mutable: `mut t` -LL | t.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `t.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:25:9 - | -LL | let t: Tuple; - | - help: make this binding mutable: `mut t` -... -LL | t.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:34:9 - | -LL | let u: Tpair; - | - help: make this binding mutable: `mut u` -LL | u.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:37:9 - | -LL | let u: Tpair; - | - help: make this binding mutable: `mut u` -... -LL | u.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.x` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:46:9 - | -LL | let v: Spair; - | - help: make this binding mutable: `mut v` -LL | v.x = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.y` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:49:9 - | -LL | let v: Spair; - | - help: make this binding mutable: `mut v` -... -LL | v.y = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0381]: use of possibly uninitialized variable: `t.0` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:27:31 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.0` - -error[E0381]: use of possibly uninitialized variable: `t.1` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:27:36 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.1` - -error[E0381]: use of possibly uninitialized variable: `u.0` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:39:31 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.0` - -error[E0381]: use of possibly uninitialized variable: `u.1` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:39:36 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.1` - -error[E0381]: use of possibly uninitialized variable: `v.x` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:51:31 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.x` - -error[E0381]: use of possibly uninitialized variable: `v.y` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:51:36 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.y` - -error: aborting due to 12 previous errors - -Some errors occurred: E0381, E0594. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs index 03eb9621ee215..1a1b376bf9bcf 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -20,36 +10,24 @@ fn main() { { let t: Tuple; t.0 = S(1); - //[ast]~^ ERROR cannot assign to field `t.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] t.1 = 2; - //[ast]~^ ERROR cannot assign to field `t.1` of immutable binding [E0594] println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381] } { let u: Tpair; u.0 = S(1); - //[ast]~^ ERROR cannot assign to field `u.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] u.1 = 2; - //[ast]~^ ERROR cannot assign to field `u.1` of immutable binding [E0594] println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381] } { let v: Spair; v.x = S(1); - //[ast]~^ ERROR cannot assign to field `v.x` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] v.y = 2; - //[ast]~^ ERROR cannot assign to field `v.y` of immutable binding [E0594] println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381] } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.stderr similarity index 76% rename from src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr rename to src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.stderr index 3dc2b5b3b8f9f..68873ac5c02e2 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.stderr @@ -1,17 +1,17 @@ error[E0381]: assign to part of possibly uninitialized variable: `t` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:22:9 + --> $DIR/issue-54499-field-mutation-of-never-init.rs:12:9 | LL | t.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `t` error[E0381]: assign to part of possibly uninitialized variable: `u` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:34:9 + --> $DIR/issue-54499-field-mutation-of-never-init.rs:20:9 | LL | u.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `u` error[E0381]: assign to part of possibly uninitialized variable: `v` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:46:9 + --> $DIR/issue-54499-field-mutation-of-never-init.rs:28:9 | LL | v.x = S(1); | ^^^^^^^^^^ use of possibly uninitialized `v` diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr deleted file mode 100644 index f3e9ce364d9b4..0000000000000 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:22 - | -LL | let mut c1 = |y: &'static mut isize| x = y; - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x - | - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:32:22 - | -LL | let mut c1 = |z: &'static mut isize| { - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x - | - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:9 - | -LL | pub fn capture_assign_whole(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { x = (1,); }; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:9 - | -LL | pub fn capture_assign_part(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { x.0 = 1; }; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:58:9 - | -LL | pub fn capture_reborrow_whole(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { &mut x; }; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:9 - | -LL | pub fn capture_reborrow_part(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { &mut x.0; }; - | ^^ cannot borrow mutably - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0595`. diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr index 434f318ad1449..4100dbe51cb30 100644 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr +++ b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:19:46 | LL | pub fn e(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -8,7 +8,7 @@ LL | let mut c1 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:34:50 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50 | LL | pub fn ee(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -17,7 +17,7 @@ LL | let mut c2 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:42:14 | LL | pub fn capture_assign_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -25,7 +25,7 @@ LL | || { x = (1,); }; | ^^^^^^^^ cannot assign error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:47:14 | LL | pub fn capture_assign_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -33,7 +33,7 @@ LL | || { x.0 = 1; }; | ^^^^^^^ cannot assign error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:58:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 | LL | pub fn capture_reborrow_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -41,7 +41,7 @@ LL | || { &mut x; }; | ^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:57:14 | LL | pub fn capture_reborrow_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr index 434f318ad1449..4100dbe51cb30 100644 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr +++ b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:19:46 | LL | pub fn e(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -8,7 +8,7 @@ LL | let mut c1 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:34:50 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50 | LL | pub fn ee(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -17,7 +17,7 @@ LL | let mut c2 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:42:14 | LL | pub fn capture_assign_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -25,7 +25,7 @@ LL | || { x = (1,); }; | ^^^^^^^^ cannot assign error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:47:14 | LL | pub fn capture_assign_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -33,7 +33,7 @@ LL | || { x.0 = 1; }; | ^^^^^^^ cannot assign error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:58:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 | LL | pub fn capture_reborrow_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -41,7 +41,7 @@ LL | || { &mut x; }; | ^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:57:14 | LL | pub fn capture_reborrow_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs index 2bd71ec25f841..751a911a6bb86 100644 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs +++ b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs @@ -2,16 +2,14 @@ // analysis of a closure body may only be caught when AST-borrowck // looks at some parent. -// revisions: ast migrate nll +// revisions: migrate nll // Since we are testing nll (and migration) explicitly as a separate // revisions, don't worry about the --compare-mode=nll on this test. // ignore-compare-mode-nll -//[ast]compile-flags: -Z borrowck=ast -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir // transcribed from borrowck-closures-unique.rs @@ -21,7 +19,6 @@ mod borrowck_closures_unique { let mut c1 = |y: &'static mut isize| x = y; //[migrate]~^ ERROR is not declared as mutable //[nll]~^^ ERROR is not declared as mutable - //[ast]~^^^ closure cannot assign to immutable unsafe { c1(&mut Y); } } } @@ -30,7 +27,6 @@ mod borrowck_closures_unique_grandparent { pub fn ee(x: &'static mut isize) { static mut Z: isize = 3; let mut c1 = |z: &'static mut isize| { - //[ast]~^ closure cannot assign to immutable let mut c2 = |y: &'static mut isize| x = y; //[migrate]~^ ERROR is not declared as mutable //[nll]~^^ ERROR is not declared as mutable @@ -44,27 +40,23 @@ mod borrowck_closures_unique_grandparent { mod mutability_errors { pub fn capture_assign_whole(x: (i32,)) { || { x = (1,); }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } pub fn capture_assign_part(x: (i32,)) { || { x.0 = 1; }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } pub fn capture_reborrow_whole(x: (i32,)) { || { &mut x; }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } pub fn capture_reborrow_part(x: (i32,)) { || { &mut x.0; }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } } diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.ast.stderr b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.ast.stderr deleted file mode 100644 index 9e0b0aac1e3c6..0000000000000 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `**greeting` does not live long enough - --> $DIR/issue-58776-borrowck-scans-children.rs:10:24 - | -LL | let res = (|| (|| &greeting)())(); - | -- ^^^^^^^^ - borrowed value only lives until here - | | | - | | borrowed value does not live long enough - | capture occurs here -... -LL | } - | - borrowed value needs to live until here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr index bd8f2286f170c..c2ac75983efcc 100644 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr +++ b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:13:5 + --> $DIR/issue-58776-borrowck-scans-children.rs:11:5 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure | | | borrow of `greeting` occurs here -... +LL | LL | greeting = "DEALLOCATED".to_string(); | ^^^^^^^^ assignment to borrowed `greeting` occurs here ... @@ -13,7 +13,7 @@ LL | println!("thread result: {:?}", res); | --- borrow later used here error[E0505]: cannot move out of `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:16:10 + --> $DIR/issue-58776-borrowck-scans-children.rs:14:10 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr index bd8f2286f170c..c2ac75983efcc 100644 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr +++ b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:13:5 + --> $DIR/issue-58776-borrowck-scans-children.rs:11:5 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure | | | borrow of `greeting` occurs here -... +LL | LL | greeting = "DEALLOCATED".to_string(); | ^^^^^^^^ assignment to borrowed `greeting` occurs here ... @@ -13,7 +13,7 @@ LL | println!("thread result: {:?}", res); | --- borrow later used here error[E0505]: cannot move out of `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:16:10 + --> $DIR/issue-58776-borrowck-scans-children.rs:14:10 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs index 378969f9a1867..0f3f1a639f7e0 100644 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs +++ b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs @@ -1,14 +1,12 @@ // ignore-compare-mode-nll -// revisions: ast migrate nll +// revisions: migrate nll -//[migrate]compile-flags: -Z borrowck=migrate #![cfg_attr(nll, feature(nll))] fn main() { let mut greeting = "Hello world!".to_string(); let res = (|| (|| &greeting)())(); - //[ast]~^ ERROR does not live long enough greeting = "DEALLOCATED".to_string(); //[migrate]~^ ERROR cannot assign diff --git a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr deleted file mode 100644 index 6793e1a1312da..0000000000000 --- a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:15:23 - | -LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 - | ^^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:17:22 - | -LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 - | ^^^ cannot move out of borrowed content - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs index a7b17f7d6516b..c2a59a1054c75 100644 --- a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs +++ b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Regression test for #38520. Check that moves of `Foo` are not // permitted as `Foo` is not copy (even in a static/const // initializer). @@ -12,10 +9,8 @@ const fn get(x: Foo) -> usize { } const X: Foo = Foo(22); -static Y: usize = get(*&X); //[ast]~ ERROR E0507 - //[mir]~^ ERROR [E0507] -const Z: usize = get(*&X); //[ast]~ ERROR E0507 - //[mir]~^ ERROR [E0507] +static Y: usize = get(*&X); //~ ERROR [E0507] +const Z: usize = get(*&X); //~ ERROR [E0507] fn main() { } diff --git a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.stderr similarity index 61% rename from src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr rename to src/test/ui/borrowck/move-in-static-initializer-issue-38520.stderr index 6793e1a1312da..f24bf9b77f4eb 100644 --- a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr +++ b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.stderr @@ -1,13 +1,13 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:15:23 + --> $DIR/move-in-static-initializer-issue-38520.rs:12:23 | -LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 +LL | static Y: usize = get(*&X); //~ ERROR [E0507] | ^^^ cannot move out of borrowed content error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:17:22 + --> $DIR/move-in-static-initializer-issue-38520.rs:13:22 | -LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 +LL | const Z: usize = get(*&X); //~ ERROR [E0507] | ^^^ cannot move out of borrowed content error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr b/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr deleted file mode 100644 index ab05358d03f86..0000000000000 --- a/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0499]: cannot borrow `*arg` as mutable more than once at a time - --> $DIR/mut-borrow-in-loop.rs:10:25 - | -LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | -- lifetime `'a` defined here -... -LL | (self.func)(arg) //~ ERROR cannot borrow - | ------------^^^- - | | | - | | mutable borrow starts here in previous iteration of loop - | argument requires that `*arg` is borrowed for `'a` - -error[E0499]: cannot borrow `*arg` as mutable more than once at a time - --> $DIR/mut-borrow-in-loop.rs:16:25 - | -LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | -- lifetime `'a` defined here -... -LL | (self.func)(arg) //~ ERROR cannot borrow - | ------------^^^- - | | | - | | mutable borrow starts here in previous iteration of loop - | argument requires that `*arg` is borrowed for `'a` - -error[E0499]: cannot borrow `*arg` as mutable more than once at a time - --> $DIR/mut-borrow-in-loop.rs:23:25 - | -LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | -- lifetime `'a` defined here -... -LL | (self.func)(arg) //~ ERROR cannot borrow - | ------------^^^- - | | | - | | mutable borrow starts here in previous iteration of loop - | argument requires that `*arg` is borrowed for `'a` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/mut-borrow-in-loop.stderr b/src/test/ui/borrowck/mut-borrow-in-loop.stderr index 749e0e172f775..ab05358d03f86 100644 --- a/src/test/ui/borrowck/mut-borrow-in-loop.stderr +++ b/src/test/ui/borrowck/mut-borrow-in-loop.stderr @@ -1,29 +1,38 @@ error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:10:25 | +LL | impl<'a, T : 'a> FuncWrapper<'a, T> { + | -- lifetime `'a` defined here +... LL | (self.func)(arg) //~ ERROR cannot borrow - | ^^^ mutable borrow starts here in previous iteration of loop -LL | } -LL | } - | - mutable borrow ends here + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:16:25 | +LL | impl<'a, T : 'a> FuncWrapper<'a, T> { + | -- lifetime `'a` defined here +... LL | (self.func)(arg) //~ ERROR cannot borrow - | ^^^ mutable borrow starts here in previous iteration of loop -LL | } -LL | } - | - mutable borrow ends here + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:23:25 | +LL | impl<'a, T : 'a> FuncWrapper<'a, T> { + | -- lifetime `'a` defined here +... LL | (self.func)(arg) //~ ERROR cannot borrow - | ^^^ mutable borrow starts here in previous iteration of loop -LL | } -LL | } - | - mutable borrow ends here + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr b/src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr deleted file mode 100644 index 5ee31b5efd091..0000000000000 --- a/src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable - --> $DIR/mut-borrow-of-mut-ref.rs:8:7 - | -LL | fn f(b: &mut i32) { - | - help: consider changing this to be mutable: `mut b` -LL | g(&mut b) //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr b/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr index 5278056ac0f51..5ee31b5efd091 100644 --- a/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr +++ b/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr @@ -1,12 +1,10 @@ -error[E0596]: cannot borrow immutable argument `b` as mutable - --> $DIR/mut-borrow-of-mut-ref.rs:8:12 +error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable + --> $DIR/mut-borrow-of-mut-ref.rs:8:7 | +LL | fn f(b: &mut i32) { + | - help: consider changing this to be mutable: `mut b` LL | g(&mut b) //~ ERROR cannot borrow - | ^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | g(b) //~ ERROR cannot borrow - | ^ + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr b/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr deleted file mode 100644 index 9b20fc0231934..0000000000000 --- a/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0499]: cannot borrow `void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:7:18 - | -LL | let first = &mut void; - | --------- first mutable borrow occurs here -LL | let second = &mut void; //~ ERROR cannot borrow - | ^^^^^^^^^ second mutable borrow occurs here -LL | first.use_mut(); - | ----- first borrow later used here - -error[E0499]: cannot borrow `inner_void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:15:28 - | -LL | let inner_first = &mut inner_void; - | --------------- first mutable borrow occurs here -LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -LL | inner_second.use_mut(); -LL | inner_first.use_mut(); - | ----------- first borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/mut-borrow-outside-loop.stderr b/src/test/ui/borrowck/mut-borrow-outside-loop.stderr index 1b32d8589b522..9b20fc0231934 100644 --- a/src/test/ui/borrowck/mut-borrow-outside-loop.stderr +++ b/src/test/ui/borrowck/mut-borrow-outside-loop.stderr @@ -1,24 +1,23 @@ error[E0499]: cannot borrow `void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:7:23 + --> $DIR/mut-borrow-outside-loop.rs:7:18 | LL | let first = &mut void; - | ---- first mutable borrow occurs here + | --------- first mutable borrow occurs here LL | let second = &mut void; //~ ERROR cannot borrow - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^^ second mutable borrow occurs here +LL | first.use_mut(); + | ----- first borrow later used here error[E0499]: cannot borrow `inner_void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:15:33 + --> $DIR/mut-borrow-outside-loop.rs:15:28 | LL | let inner_first = &mut inner_void; - | ---------- first mutable borrow occurs here + | --------------- first mutable borrow occurs here LL | let inner_second = &mut inner_void; //~ ERROR cannot borrow - | ^^^^^^^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^^^^^^^^ second mutable borrow occurs here +LL | inner_second.use_mut(); +LL | inner_first.use_mut(); + | ----------- first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/mutability-errors.nll.stderr b/src/test/ui/borrowck/mutability-errors.nll.stderr deleted file mode 100644 index 6dd3582f95f5d..0000000000000 --- a/src/test/ui/borrowck/mutability-errors.nll.stderr +++ /dev/null @@ -1,379 +0,0 @@ -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/mutability-errors.rs:9:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -LL | *x = (1,); //~ ERROR - | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `x.0` which is behind a `&` reference - --> $DIR/mutability-errors.rs:10:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -LL | *x = (1,); //~ ERROR -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/mutability-errors.rs:11:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -... -LL | &mut *x; //~ ERROR - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference - --> $DIR/mutability-errors.rs:12:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -... -LL | &mut x.0; //~ ERROR - | ^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/mutability-errors.rs:16:5 - | -LL | *f() = (1,); //~ ERROR - | ^^^^^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/mutability-errors.rs:17:5 - | -LL | f().0 = 1; //~ ERROR - | ^^^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/mutability-errors.rs:18:5 - | -LL | &mut *f(); //~ ERROR - | ^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/mutability-errors.rs:19:5 - | -LL | &mut f().0; //~ ERROR - | ^^^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `*x` which is behind a `*const` pointer - --> $DIR/mutability-errors.rs:23:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -LL | *x = (1,); //~ ERROR - | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written - -error[E0594]: cannot assign to `x.0` which is behind a `*const` pointer - --> $DIR/mutability-errors.rs:24:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -LL | *x = (1,); //~ ERROR -LL | (*x).0 = 1; //~ ERROR - | ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer - --> $DIR/mutability-errors.rs:25:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -... -LL | &mut *x; //~ ERROR - | ^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer - --> $DIR/mutability-errors.rs:26:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -... -LL | &mut (*x).0; //~ ERROR - | ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable - -error[E0594]: cannot assign to data in a `*const` pointer - --> $DIR/mutability-errors.rs:30:5 - | -LL | *f() = (1,); //~ ERROR - | ^^^^^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `*const` pointer - --> $DIR/mutability-errors.rs:31:5 - | -LL | (*f()).0 = 1; //~ ERROR - | ^^^^^^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `*const` pointer as mutable - --> $DIR/mutability-errors.rs:32:5 - | -LL | &mut *f(); //~ ERROR - | ^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `*const` pointer as mutable - --> $DIR/mutability-errors.rs:33:5 - | -LL | &mut (*f()).0; //~ ERROR - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:40:9 - | -LL | x = (1,); //~ ERROR - | ^^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:41:9 - | -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:42:9 - | -LL | &mut x; //~ ERROR - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:43:9 - | -LL | &mut x.0; //~ ERROR - | ^^^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:46:9 - | -LL | x = (1,); //~ ERROR - | ^^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:47:9 - | -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:48:9 - | -LL | &mut x; //~ ERROR - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:49:9 - | -LL | &mut x.0; //~ ERROR - | ^^^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); //~ ERROR -LL | | x.0 = 1; //~ ERROR -LL | | &mut x; //~ ERROR -LL | | &mut x.0; //~ ERROR -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/mutability-errors.rs:54:5 - | -LL | fn imm_local(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -LL | &mut x; //~ ERROR - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:55:5 - | -LL | fn imm_local(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -LL | &mut x; //~ ERROR -LL | &mut x.0; //~ ERROR - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/mutability-errors.rs:60:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -LL | || { //~ ERROR -LL | x = (1,); - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:61:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | x.0 = 1; - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/mutability-errors.rs:62:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:63:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/mutability-errors.rs:66:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | x = (1,); //~ ERROR - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:67:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/mutability-errors.rs:68:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x; //~ ERROR - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:69:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x.0; //~ ERROR - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to immutable static item `X` - --> $DIR/mutability-errors.rs:76:5 - | -LL | X = (1,); //~ ERROR - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `X.0`, as `X` is an immutable static item - --> $DIR/mutability-errors.rs:77:5 - | -LL | X.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/mutability-errors.rs:78:5 - | -LL | &mut X; //~ ERROR - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item - --> $DIR/mutability-errors.rs:79:5 - | -LL | &mut X.0; //~ ERROR - | ^^^^^^^^ cannot borrow as mutable - -error: aborting due to 38 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/mutability-errors.rs b/src/test/ui/borrowck/mutability-errors.rs index 26f7f605ebeb8..5be0df1376135 100644 --- a/src/test/ui/borrowck/mutability-errors.rs +++ b/src/test/ui/borrowck/mutability-errors.rs @@ -56,11 +56,11 @@ fn imm_local(x: (i32,)) { } fn imm_capture(x: (i32,)) { - || { //~ ERROR - x = (1,); - x.0 = 1; - &mut x; - &mut x.0; + || { + x = (1,); //~ ERROR + x.0 = 1; //~ ERROR + &mut x; //~ ERROR + &mut x.0; //~ ERROR }; move || { x = (1,); //~ ERROR diff --git a/src/test/ui/borrowck/mutability-errors.stderr b/src/test/ui/borrowck/mutability-errors.stderr index b7fd6ee7214f1..a739c24eaafe5 100644 --- a/src/test/ui/borrowck/mutability-errors.stderr +++ b/src/test/ui/borrowck/mutability-errors.stderr @@ -1,117 +1,128 @@ -error[E0594]: cannot assign to immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/mutability-errors.rs:9:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` LL | *x = (1,); //~ ERROR - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0` which is behind a `&` reference --> $DIR/mutability-errors.rs:10:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` LL | *x = (1,); //~ ERROR LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable - --> $DIR/mutability-errors.rs:11:10 +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/mutability-errors.rs:11:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` ... LL | &mut *x; //~ ERROR - | ^^ cannot borrow as mutable + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:12:10 +error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference + --> $DIR/mutability-errors.rs:12:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` ... LL | &mut x.0; //~ ERROR - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/mutability-errors.rs:16:5 | LL | *f() = (1,); //~ ERROR - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/mutability-errors.rs:17:5 | LL | f().0 = 1; //~ ERROR - | ^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/mutability-errors.rs:18:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/mutability-errors.rs:18:5 | LL | &mut *f(); //~ ERROR - | ^^^^ cannot borrow as mutable + | ^^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/mutability-errors.rs:19:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/mutability-errors.rs:19:5 | LL | &mut f().0; //~ ERROR - | ^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to immutable dereference of raw pointer `*x` +error[E0594]: cannot assign to `*x` which is behind a `*const` pointer --> $DIR/mutability-errors.rs:23:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` LL | *x = (1,); //~ ERROR - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0` which is behind a `*const` pointer --> $DIR/mutability-errors.rs:24:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` +LL | *x = (1,); //~ ERROR LL | (*x).0 = 1; //~ ERROR - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written -error[E0596]: cannot borrow immutable dereference of raw pointer `*x` as mutable - --> $DIR/mutability-errors.rs:25:10 +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer + --> $DIR/mutability-errors.rs:25:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` +... LL | &mut *x; //~ ERROR - | ^^ cannot borrow as mutable + | ^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:26:10 +error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer + --> $DIR/mutability-errors.rs:26:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` +... LL | &mut (*x).0; //~ ERROR - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable -error[E0594]: cannot assign to immutable dereference of raw pointer +error[E0594]: cannot assign to data in a `*const` pointer --> $DIR/mutability-errors.rs:30:5 | LL | *f() = (1,); //~ ERROR - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `*const` pointer --> $DIR/mutability-errors.rs:31:5 | LL | (*f()).0 = 1; //~ ERROR - | ^^^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable dereference of raw pointer as mutable - --> $DIR/mutability-errors.rs:32:10 +error[E0596]: cannot borrow data in a `*const` pointer as mutable + --> $DIR/mutability-errors.rs:32:5 | LL | &mut *f(); //~ ERROR - | ^^^^ cannot borrow as mutable + | ^^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/mutability-errors.rs:33:10 +error[E0596]: cannot borrow data in a `*const` pointer as mutable + --> $DIR/mutability-errors.rs:33:5 | LL | &mut (*f()).0; //~ ERROR - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^ cannot borrow as mutable -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:40:9 | LL | x = (1,); //~ ERROR - | ^^^^^^^^ + | ^^^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -123,13 +134,13 @@ LL | | &mut x.0; //~ ERROR LL | | }); | |_____^ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:41:9 | LL | x.0 = 1; //~ ERROR - | ^^^^^^^ + | ^^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -141,13 +152,13 @@ LL | | &mut x.0; //~ ERROR LL | | }); | |_____^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/mutability-errors.rs:42:14 +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/mutability-errors.rs:42:9 | LL | &mut x; //~ ERROR - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -159,13 +170,13 @@ LL | | &mut x.0; //~ ERROR LL | | }); | |_____^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/mutability-errors.rs:43:14 +error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables + --> $DIR/mutability-errors.rs:43:9 | LL | &mut x.0; //~ ERROR - | ^^^ + | ^^^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -177,14 +188,13 @@ LL | | &mut x.0; //~ ERROR LL | | }); | |_____^ -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:46:9 | LL | x = (1,); //~ ERROR - | ^^^^^^^^ + | ^^^^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:45:12 | LL | fn_ref(move || { @@ -196,19 +206,31 @@ LL | | &mut x.0; //~ ERROR LL | | }); | |_____^ -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:47:9 | LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/mutability-errors.rs:45:12 + | +LL | fn_ref(move || { + | ____________^ +LL | | x = (1,); //~ ERROR +LL | | x.0 = 1; //~ ERROR +LL | | &mut x; //~ ERROR +LL | | &mut x.0; //~ ERROR +LL | | }); + | |_____^ -error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable - --> $DIR/mutability-errors.rs:48:14 +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/mutability-errors.rs:48:9 | LL | &mut x; //~ ERROR - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:45:12 | LL | fn_ref(move || { @@ -220,89 +242,138 @@ LL | | &mut x.0; //~ ERROR LL | | }); | |_____^ -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:49:14 +error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables + --> $DIR/mutability-errors.rs:49:9 | LL | &mut x.0; //~ ERROR - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/mutability-errors.rs:45:12 + | +LL | fn_ref(move || { + | ____________^ +LL | | x = (1,); //~ ERROR +LL | | x.0 = 1; //~ ERROR +LL | | &mut x; //~ ERROR +LL | | &mut x.0; //~ ERROR +LL | | }); + | |_____^ -error[E0596]: cannot borrow immutable argument `x` as mutable - --> $DIR/mutability-errors.rs:54:10 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/mutability-errors.rs:54:5 | LL | fn imm_local(x: (i32,)) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | &mut x; //~ ERROR - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:55:10 +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:55:5 | LL | fn imm_local(x: (i32,)) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | &mut x; //~ ERROR LL | &mut x.0; //~ ERROR - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/mutability-errors.rs:59:5 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/mutability-errors.rs:60:9 | LL | fn imm_capture(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { //~ ERROR - | ^^ cannot borrow mutably + | - help: consider changing this to be mutable: `mut x` +LL | || { +LL | x = (1,); //~ ERROR + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:61:9 + | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... +LL | x.0 = 1; //~ ERROR + | ^^^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/mutability-errors.rs:62:9 + | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... +LL | &mut x; //~ ERROR + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:63:9 + | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... +LL | &mut x.0; //~ ERROR + | ^^^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/mutability-errors.rs:66:9 | LL | fn imm_capture(x: (i32,)) { - | - help: consider making `x` mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... LL | x = (1,); //~ ERROR - | ^^^^^^^^ + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable --> $DIR/mutability-errors.rs:67:9 | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable - --> $DIR/mutability-errors.rs:68:14 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/mutability-errors.rs:68:9 | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... LL | &mut x; //~ ERROR - | ^ + | ^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:69:14 +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:69:9 | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... LL | &mut x.0; //~ ERROR - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to immutable static item +error[E0594]: cannot assign to immutable static item `X` --> $DIR/mutability-errors.rs:76:5 | LL | X = (1,); //~ ERROR - | ^^^^^^^^ + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to `X.0`, as `X` is an immutable static item --> $DIR/mutability-errors.rs:77:5 | LL | X.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/mutability-errors.rs:78:10 +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/mutability-errors.rs:78:5 | LL | &mut X; //~ ERROR - | ^ + | ^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/mutability-errors.rs:79:10 +error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item + --> $DIR/mutability-errors.rs:79:5 | LL | &mut X.0; //~ ERROR - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error: aborting due to 35 previous errors +error: aborting due to 38 previous errors -Some errors occurred: E0387, E0594, E0595, E0596. -For more information about an error, try `rustc --explain E0387`. +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr deleted file mode 100644 index 66e3c4056a229..0000000000000 --- a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:6:5 - | -LL | let ref mut x = 1234543; //~ ERROR - | ------- temporary value created here -LL | x - | ^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:11:5 - | -LL | let (ref mut x, ) = (1234543, ); //~ ERROR - | ----------- temporary value created here -LL | x - | ^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:5 - | -LL | match 1234543 { - | ^ ------- temporary value created here - | _____| - | | -LL | | ref mut x => x //~ ERROR -LL | | } - | |_____^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 - | -LL | match (123443,) { - | ^ --------- temporary value created here - | _____| - | | -LL | | (ref mut x,) => x, //~ ERROR -LL | | } - | |_____^ returns a value referencing data owned by the current function - -error[E0515]: cannot return reference to temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:5 - | -LL | &mut 1234543 //~ ERROR - | ^^^^^------- - | | | - | | temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs index ae305b68941e7..3576734de3c5b 100644 --- a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs +++ b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs @@ -2,24 +2,24 @@ // mut` borrow. fn gimme_static_mut_let() -> &'static mut u32 { - let ref mut x = 1234543; //~ ERROR - x + let ref mut x = 1234543; + x //~ ERROR } fn gimme_static_mut_let_nested() -> &'static mut u32 { - let (ref mut x, ) = (1234543, ); //~ ERROR - x + let (ref mut x, ) = (1234543, ); + x //~ ERROR } fn gimme_static_mut_match() -> &'static mut u32 { - match 1234543 { - ref mut x => x //~ ERROR + match 1234543 { //~ ERROR + ref mut x => x } } fn gimme_static_mut_match_nested() -> &'static mut u32 { - match (123443,) { - (ref mut x,) => x, //~ ERROR + match (123443,) { //~ ERROR + (ref mut x,) => x, } } diff --git a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr index 51e47fd44d90b..c7268beda2b39 100644 --- a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr +++ b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr @@ -1,57 +1,50 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:5:9 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:6:5 | -LL | let ref mut x = 1234543; //~ ERROR - | ^^^^^^^^^ temporary value does not live long enough -LL | x -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | let ref mut x = 1234543; + | ------- temporary value created here +LL | x //~ ERROR + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:10:10 - | -LL | let (ref mut x, ) = (1234543, ); //~ ERROR - | ^^^^^^^^^ borrowed value does not live long enough -LL | x -LL | } - | - borrowed value only lives until here +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:11:5 | - = note: borrowed value must be valid for the static lifetime... +LL | let (ref mut x, ) = (1234543, ); + | ----------- temporary value created here +LL | x //~ ERROR + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:16:9 - | -LL | ref mut x => x //~ ERROR - | ^^^^^^^^^ temporary value does not live long enough -LL | } -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:5 + | +LL | match 1234543 { //~ ERROR + | ^ ------- temporary value created here + | _____| + | | +LL | | ref mut x => x +LL | | } + | |_____^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:22:10 - | -LL | (ref mut x,) => x, //~ ERROR - | ^^^^^^^^^ borrowed value does not live long enough -LL | } -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 + | +LL | match (123443,) { //~ ERROR + | ^ --------- temporary value created here + | _____| + | | +LL | | (ref mut x,) => x, +LL | | } + | |_____^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:10 +error[E0515]: cannot return reference to temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:5 | LL | &mut 1234543 //~ ERROR - | ^^^^^^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^^^^^------- + | | | + | | temporary value created here + | returns a reference to data owned by the current function error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr b/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr deleted file mode 100644 index bf9084259c834..0000000000000 --- a/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields.rs:7:5 - | -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields.rs:15:5 - | -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields.rs b/src/test/ui/borrowck/reassignment_immutable_fields.rs index 4529e32a6928e..fd2ab62a40f1d 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields.rs +++ b/src/test/ui/borrowck/reassignment_immutable_fields.rs @@ -5,16 +5,16 @@ fn assign_both_fields_and_use() { let x: (u32, u32); x.0 = 1; //~ ERROR - x.1 = 22; //~ ERROR - drop(x.0); //~ ERROR - drop(x.1); //~ ERROR + x.1 = 22; + drop(x.0); + drop(x.1); } fn assign_both_fields_the_use_var() { let x: (u32, u32); x.0 = 1; //~ ERROR - x.1 = 22; //~ ERROR - drop(x); //~ ERROR + x.1 = 22; + drop(x); } fn main() { } diff --git a/src/test/ui/borrowck/reassignment_immutable_fields.stderr b/src/test/ui/borrowck/reassignment_immutable_fields.stderr index c63f56702ab69..bf9084259c834 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields.stderr +++ b/src/test/ui/borrowck/reassignment_immutable_fields.stderr @@ -1,56 +1,15 @@ -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields.rs:7:5 | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ use of possibly uninitialized `x` -error[E0594]: cannot assign to field `x.1` of immutable binding - --> $DIR/reassignment_immutable_fields.rs:8:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -LL | x.0 = 1; //~ ERROR -LL | x.1 = 22; //~ ERROR - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0381]: use of possibly uninitialized variable: `x.0` - --> $DIR/reassignment_immutable_fields.rs:9:10 - | -LL | drop(x.0); //~ ERROR - | ^^^ use of possibly uninitialized `x.0` - -error[E0381]: use of possibly uninitialized variable: `x.1` - --> $DIR/reassignment_immutable_fields.rs:10:10 - | -LL | drop(x.1); //~ ERROR - | ^^^ use of possibly uninitialized `x.1` - -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields.rs:15:5 | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `x.1` of immutable binding - --> $DIR/reassignment_immutable_fields.rs:16:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` LL | x.0 = 1; //~ ERROR -LL | x.1 = 22; //~ ERROR - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields.rs:17:10 - | -LL | drop(x); //~ ERROR - | ^ use of possibly uninitialized `x` + | ^^^^^^^ use of possibly uninitialized `x` -error: aborting due to 7 previous errors +error: aborting due to 2 previous errors -Some errors occurred: E0381, E0594. -For more information about an error, try `rustc --explain E0381`. +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr deleted file mode 100644 index 53b51eb894ae7..0000000000000 --- a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields_overlapping.rs:12:5 - | -LL | x.a = 1; //~ ERROR - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields_overlapping.rs:13:5 - | -LL | let x: Foo; - | - help: consider changing this to be mutable: `mut x` -LL | x.a = 1; //~ ERROR -LL | x.b = 22; //~ ERROR - | ^^^^^^^^ cannot assign - -error: aborting due to 2 previous errors - -Some errors occurred: E0381, E0594. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr index e34024736c6a2..53b51eb894ae7 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr +++ b/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr @@ -1,20 +1,19 @@ -error[E0594]: cannot assign to field `x.a` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields_overlapping.rs:12:5 | -LL | let x: Foo; - | - help: make this binding mutable: `mut x` LL | x.a = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ use of possibly uninitialized `x` -error[E0594]: cannot assign to field `x.b` of immutable binding +error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable --> $DIR/reassignment_immutable_fields_overlapping.rs:13:5 | LL | let x: Foo; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.a = 1; //~ ERROR LL | x.b = 22; //~ ERROR - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot assign error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0594`. +Some errors occurred: E0381, E0594. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr deleted file mode 100644 index 910b8292ec8ff..0000000000000 --- a/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields_twice.rs:7:5 - | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` -LL | x = (22, 44); -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields_twice.rs:12:5 - | -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors - -Some errors occurred: E0381, E0594. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs b/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs index a10baf627f30b..2775a54c8304b 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs +++ b/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs @@ -10,8 +10,8 @@ fn var_then_field() { fn same_field_twice() { let x: (u32, u32); x.0 = 1; //~ ERROR - x.0 = 22; //~ ERROR - x.1 = 44; //~ ERROR + x.0 = 22; + x.1 = 44; } fn main() { } diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr index 75d7f99ed0c8c..910b8292ec8ff 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr +++ b/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr @@ -1,38 +1,19 @@ -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable --> $DIR/reassignment_immutable_fields_twice.rs:7:5 | LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x = (22, 44); LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields_twice.rs:12:5 | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `x.0` of immutable binding - --> $DIR/reassignment_immutable_fields_twice.rs:13:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` LL | x.0 = 1; //~ ERROR -LL | x.0 = 22; //~ ERROR - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `x.1` of immutable binding - --> $DIR/reassignment_immutable_fields_twice.rs:14:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -... -LL | x.1 = 44; //~ ERROR - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ use of possibly uninitialized `x` -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0594`. +Some errors occurred: E0381, E0594. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs index 5754220e824f5..55a8ae7a49ef3 100644 --- a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs +++ b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs @@ -3,9 +3,9 @@ // revisions: nll_target // The following revisions are disabled due to missing support from two-phase beyond autorefs -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll_target] compile-flags: -Z borrowck=mir // This is an important corner case pointed out by Niko: one is // allowed to initiate a shared borrow during a reservation, but it diff --git a/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs b/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs index e428964939aff..07169afefc988 100644 --- a/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs +++ b/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs @@ -3,9 +3,9 @@ // revisions: nll_target // The following revisions are disabled due to missing support for two_phase_beyond_autoref -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two_phase_beyond_autoref -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll_target] compile-flags: -Z borrowck=mir // This is the second counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ diff --git a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs index fd1b8841b4e8a..f2097fdf823f1 100644 --- a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs +++ b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z borrowck=mir -Z two-phase-borrows +// compile-flags: -Z borrowck=mir // This is the third counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ diff --git a/src/test/ui/borrowck/two-phase-method-receivers.rs b/src/test/ui/borrowck/two-phase-method-receivers.rs index f1df1a6a2c899..6838f6c7efd5d 100644 --- a/src/test/ui/borrowck/two-phase-method-receivers.rs +++ b/src/test/ui/borrowck/two-phase-method-receivers.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z borrowck=mir -Z two-phase-borrows +// compile-flags: -Z borrowck=mir // run-pass diff --git a/src/test/ui/borrowck/two-phase-multiple-activations.rs b/src/test/ui/borrowck/two-phase-multiple-activations.rs index 38ba094864069..a7fa7fac13e73 100644 --- a/src/test/ui/borrowck/two-phase-multiple-activations.rs +++ b/src/test/ui/borrowck/two-phase-multiple-activations.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z borrowck=mir -Z two-phase-borrows +// compile-flags: -Z borrowck=mir // run-pass diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr deleted file mode 100644 index d026f81b7aad6..0000000000000 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr +++ /dev/null @@ -1,85 +0,0 @@ -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:60:11 - | -LL | f(f(10)); - | - ^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error[E0382]: use of moved value: `*f` - --> $DIR/two-phase-nonrecv-autoref.rs:69:11 - | -LL | fn twice_ten_so i32>(f: Box) { - | - consider adding a `Copy` constraint to this type argument -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:76:11 - | -LL | f(f(10)); - | - ^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined - --> $DIR/two-phase-nonrecv-autoref.rs:85:9 - | -LL | f(f(10)); - | ^ - -error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 - | -LL | f(f(10)); - | ^ - -error[E0382]: use of moved value: `*f` - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 - | -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait - -error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:129:27 - | -LL | double_access(&mut a, &a); - | ------------- ------ ^^ immutable borrow occurs here - | | | - | | mutable borrow occurs here - | mutable borrow later used by call - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:157:7 - | -LL | i[i[3]] = 4; - | --^---- - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - | mutable borrow later used here - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:163:7 - | -LL | i[i[3]] = i[4]; - | --^---- - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - | mutable borrow later used here - -error: aborting due to 9 previous errors - -Some errors occurred: E0161, E0382, E0499, E0502. -For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr deleted file mode 100644 index 426939f371ca5..0000000000000 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr +++ /dev/null @@ -1,113 +0,0 @@ -error[E0503]: cannot use `*x` because it was mutably borrowed - --> $DIR/two-phase-nonrecv-autoref.rs:31:12 - | -LL | foo(x, *x); - | - ^^ use of borrowed `*x` - | | - | borrow of `*x` occurs here - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:60:11 - | -LL | f(f(10)); - | - ^ - first borrow ends here - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here - -error[E0382]: use of moved value: `*f` - --> $DIR/two-phase-nonrecv-autoref.rs:69:11 - | -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:76:11 - | -LL | f(f(10)); - | - ^ - first borrow ends here - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here - -error[E0382]: use of moved value: `*f` - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 - | -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `*f` has type `(dyn std::ops::FnOnce(i32) -> i32 + 'static)`, which does not implement the `Copy` trait - -error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:129:28 - | -LL | double_access(&mut a, &a); - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:135:9 - | -LL | a.m(a.i(10)); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:157:7 - | -LL | i[i[3]] = 4; - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:163:7 - | -LL | i[i[3]] = i[4]; - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:172:12 - | -LL | v.push(v.len()); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:183:9 - | -LL | s.m(s.i(10)); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `t` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:188:9 - | -LL | t.m(t.i(10)); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error: aborting due to 12 previous errors - -Some errors occurred: E0382, E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr index d026f81b7aad6..d64c041ac1d1f 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:60:11 + --> $DIR/two-phase-nonrecv-autoref.rs:58:11 | LL | f(f(10)); | - ^ second mutable borrow occurs here @@ -8,7 +8,7 @@ LL | f(f(10)); | first borrow later used by call error[E0382]: use of moved value: `*f` - --> $DIR/two-phase-nonrecv-autoref.rs:69:11 + --> $DIR/two-phase-nonrecv-autoref.rs:66:11 | LL | fn twice_ten_so i32>(f: Box) { | - consider adding a `Copy` constraint to this type argument @@ -20,7 +20,7 @@ LL | f(f(10)); = note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:76:11 + --> $DIR/two-phase-nonrecv-autoref.rs:72:11 | LL | f(f(10)); | - ^ second mutable borrow occurs here @@ -29,19 +29,19 @@ LL | f(f(10)); | first borrow later used by call error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined - --> $DIR/two-phase-nonrecv-autoref.rs:85:9 + --> $DIR/two-phase-nonrecv-autoref.rs:80:9 | LL | f(f(10)); | ^ error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 + --> $DIR/two-phase-nonrecv-autoref.rs:80:11 | LL | f(f(10)); | ^ error[E0382]: use of moved value: `*f` - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 + --> $DIR/two-phase-nonrecv-autoref.rs:80:11 | LL | f(f(10)); | - ^ value used here after move @@ -51,7 +51,7 @@ LL | f(f(10)); = note: move occurs because `*f` has type `dyn std::ops::FnOnce(i32) -> i32`, which does not implement the `Copy` trait error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:129:27 + --> $DIR/two-phase-nonrecv-autoref.rs:123:27 | LL | double_access(&mut a, &a); | ------------- ------ ^^ immutable borrow occurs here @@ -60,7 +60,7 @@ LL | double_access(&mut a, &a); | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:157:7 + --> $DIR/two-phase-nonrecv-autoref.rs:149:7 | LL | i[i[3]] = 4; | --^---- @@ -70,7 +70,7 @@ LL | i[i[3]] = 4; | mutable borrow later used here error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:163:7 + --> $DIR/two-phase-nonrecv-autoref.rs:154:7 | LL | i[i[3]] = i[4]; | --^---- diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs index 1a14cb90f38ef..f7bae4a5a75a6 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs @@ -1,8 +1,7 @@ -// revisions: ast nll -//[ast]compile-flags: -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows +// revisions: nll +//[nll]compile-flags: -Z borrowck=mir -//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref // the above revision is disabled until two-phase-beyond-autoref support is better // This is a test checking that when we limit two-phase borrows to @@ -29,7 +28,6 @@ fn foo(x: &mut u32, y: u32) { fn deref_coercion(x: &mut u32) { foo(x, *x); - //[ast]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503] // Above error is a known limitation of AST borrowck } @@ -60,7 +58,6 @@ fn overloaded_call_traits() { f(f(10)); //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_si i32>(f: &mut F) { f(f(10)); @@ -69,14 +66,12 @@ fn overloaded_call_traits() { f(f(10)); //[nll]~^ ERROR use of moved value: `*f` //[g2p]~^^ ERROR use of moved value: `*f` - //[ast]~^^^ ERROR use of moved value: `*f` } fn twice_ten_om(f: &mut FnMut(i32) -> i32) { f(f(10)); //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_oi(f: &mut Fn(i32) -> i32) { f(f(10)); @@ -89,7 +84,6 @@ fn overloaded_call_traits() { //[g2p]~^^^^ ERROR cannot move a value of type //[g2p]~^^^^^ ERROR cannot move a value of type //[g2p]~^^^^^^ ERROR use of moved value: `*f` - //[ast]~^^^^^^^ ERROR use of moved value: `*f` } twice_ten_sm(&mut |x| x + 1); @@ -129,11 +123,9 @@ fn coerce_unsized() { double_access(&mut a, &a); //[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] //[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] // But this is okay. a.m(a.i(10)); - //[ast]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] // Above error is an expected limitation of AST borrowck } @@ -156,13 +148,11 @@ fn coerce_index_op() { let mut i = I(10); i[i[3]] = 4; //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] i[3] = i[4]; i[i[3]] = i[4]; //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] } fn main() { @@ -170,7 +160,6 @@ fn main() { // As a reminder, this is the basic case we want to ensure we handle. let mut v = vec![1, 2, 3]; v.push(v.len()); - //[ast]~^ ERROR cannot borrow `v` as immutable because it is also borrowed as mutable [E0502] // Error above is an expected limitation of AST borrowck // (as a rule, pnkfelix does not like to write tests with dead code.) @@ -181,12 +170,10 @@ fn main() { let mut s = S; s.m(s.i(10)); - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable [E0502] // Error above is an expected limitation of AST borrowck let mut t = T; t.m(t.i(10)); - //[ast]~^ ERROR cannot borrow `t` as immutable because it is also borrowed as mutable [E0502] // Error above is an expected limitation of AST borrowck coerce_unsized(); diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs index 13c1df7db2bc7..44a640df9291d 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z borrowck=mir -Z two-phase-borrows +// compile-flags: -Z borrowck=mir // This is similar to two-phase-reservation-sharing-interference.rs // in that it shows a reservation that overlaps with a shared borrow. diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs b/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs index f5fa8218edc71..d8e60c5859e89 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs @@ -3,10 +3,10 @@ // revisions: nll_target // The following revisions are disabled due to missing support from two-phase beyond autorefs -//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref //[nll_beyond] should-fail -//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll_target]compile-flags: -Z borrowck=mir // This is a corner case that the current implementation is (probably) // treating more conservatively than is necessary. But it also does diff --git a/src/test/ui/borrowck/two-phase-sneaky.nll.stderr b/src/test/ui/borrowck/two-phase-sneaky.nll.stderr deleted file mode 100644 index c66f3cbed918d..0000000000000 --- a/src/test/ui/borrowck/two-phase-sneaky.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/two-phase-sneaky.rs:12:9 - | -LL | v[0].push_str({ - | - -------- first borrow later used by call - | | - | first mutable borrow occurs here -LL | -LL | v.push(format!("foo")); - | ^ second mutable borrow occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/two-phase-sneaky.rs b/src/test/ui/borrowck/two-phase-sneaky.rs index abfa13da6af00..b6e33d5d1b82f 100644 --- a/src/test/ui/borrowck/two-phase-sneaky.rs +++ b/src/test/ui/borrowck/two-phase-sneaky.rs @@ -1,4 +1,4 @@ -// cmpile-flags: -Z borrowck=mir -Z two-phase-borrows +// cmpile-flags: -Z borrowck=mir // This is the first counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ diff --git a/src/test/ui/borrowck/two-phase-sneaky.stderr b/src/test/ui/borrowck/two-phase-sneaky.stderr index 38f24ccd6068b..c66f3cbed918d 100644 --- a/src/test/ui/borrowck/two-phase-sneaky.stderr +++ b/src/test/ui/borrowck/two-phase-sneaky.stderr @@ -2,13 +2,12 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/two-phase-sneaky.rs:12:9 | LL | v[0].push_str({ - | - first mutable borrow occurs here + | - -------- first borrow later used by call + | | + | first mutable borrow occurs here LL | LL | v.push(format!("foo")); | ^ second mutable borrow occurs here -... -LL | }); - | - first borrow ends here error: aborting due to previous error diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.ast.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.ast.stderr deleted file mode 100644 index a2e5c7e88e820..0000000000000 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.ast.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0503]: cannot use `self.cx` because it was mutably borrowed - --> $DIR/two-phase-surprise-no-conflict.rs:30:13 - | -LL | let _mut_borrow = &mut *self; - | ----- borrow of `*self` occurs here -LL | let _access = self.cx; - | ^^^^^^^ use of borrowed `*self` - -error[E0502]: cannot borrow `*self.cx_mut` as immutable because `*self` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:69:33 - | -LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ---- ^^^^^^^^^^^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:121:52 - | -LL | reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:125:51 - | -LL | reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:129:50 - | -LL | reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:133:41 - | -LL | reg.register_ref(&TrivialPass::new(®.sess_mut)); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:141:56 - | -LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:146:59 - | -LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:151:58 - | -LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:156:49 - | -LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:168:51 - | -LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:173:50 - | -LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:178:41 - | -LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:59 - | -LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:58 - | -LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:49 - | -LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error: aborting due to 16 previous errors - -Some errors occurred: E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr deleted file mode 100644 index 9b46567318c05..0000000000000 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr +++ /dev/null @@ -1,159 +0,0 @@ -error[E0503]: cannot use `self.cx` because it was mutably borrowed - --> $DIR/two-phase-surprise-no-conflict.rs:30:23 - | -LL | let _mut_borrow = &mut *self; - | ---------- borrow of `*self` occurs here -LL | let _access = self.cx; - | ^^^^^^^ use of borrowed `*self` -... -LL | _mut_borrow; - | ----------- borrow later used here - -error[E0502]: cannot borrow `*self.cx` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:54:33 - | -LL | self.hash_expr(&self.cx.body(eid).value); - | ---- --------- ^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `*self.cx_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:69:33 - | -LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ---- --------- ^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:121:51 - | -LL | reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - | --- --------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:125:50 - | -LL | reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:129:49 - | -LL | reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:133:40 - | -LL | reg.register_ref(&TrivialPass::new(®.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:141:51 - | -LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:146:54 - | -LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:151:53 - | -LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:156:44 - | -LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:168:50 - | -LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:173:49 - | -LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:178:40 - | -LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:54 - | -LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:53 - | -LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:44 - | -LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error: aborting due to 17 previous errors - -Some errors occurred: E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs b/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs index f097defa2240e..3fd24bbf290b5 100644 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs +++ b/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs @@ -5,15 +5,6 @@ // that we decided it warranted its own unit test, and pnkfelix // decided to use that test as an opportunity to illustrate the cases. -// revisions: ast no2pb nll -//[ast]compile-flags: -Z borrowck=ast -//[no2pb]compile-flags: -Z borrowck=mir -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// (Since we are manually toggling NLL variations on and off, don't -// bother with compare-mode=nll) -// ignore-compare-mode-nll - #[derive(Copy, Clone)] struct BodyId; enum Expr { Closure(BodyId), Others } @@ -28,9 +19,7 @@ impl <'a> SpanlessHash<'a> { fn demo(&mut self) { let _mut_borrow = &mut *self; let _access = self.cx; - //[ast]~^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] - //[no2pb]~^^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] - //[nll]~^^^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] + //~^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] _mut_borrow; } @@ -52,7 +41,6 @@ impl <'a> SpanlessHash<'a> { // nothing in the activation for `self.hash_expr(..)` // can interfere with that immutable borrow. self.hash_expr(&self.cx.body(eid).value); - //[no2pb]~^ ERROR cannot borrow `*self.cx` }, _ => {} } @@ -67,9 +55,7 @@ impl <'a> SpanlessHash<'a> { // eventual activation of the `self` mutable borrow // for `self.hash_expr(..)` self.hash_expr(&self.cx_mut.body(eid).value); - //[ast]~^ ERROR cannot borrow `*self.cx_mut` - //[no2pb]~^^ ERROR cannot borrow `*self.cx_mut` - //[nll]~^^^ ERROR cannot borrow `*self` + //~^ ERROR cannot borrow `*self` }, _ => {} } @@ -119,44 +105,28 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { // cannot (according to its type) keep them alive. let reg = mk_reg(); reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_ref(&TrivialPass::new(®.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` // These are not okay: the inner mutable borrows immediately // conflict with the outer borrow/reservation, even with support // for two-phase borrows. let reg = mk_reg(); reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` // These are not okay: the inner borrows may reach the actual // method invocation, because `CapturePass::new` might (according @@ -166,19 +136,13 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { // that will fail to get past lifetime inference.) let reg = mk_reg(); reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `*reg` as mutable + //~^ ERROR cannot borrow `*reg` as mutable let reg = mk_reg(); reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `*reg` as mutable + //~^ ERROR cannot borrow `*reg` as mutable let reg = mk_reg(); reg.register_ref(&CapturePass::new(®.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `*reg` as mutable + //~^ ERROR cannot borrow `*reg` as mutable // These are not okay: the inner mutable borrows immediately // conflict with the outer borrow/reservation, even with support @@ -188,22 +152,16 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { // that will fail to get past lifetime inference.) let reg = mk_reg(); reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time - //[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time + //~^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time + //~^^ ERROR cannot borrow `*reg` as mutable more than once at a time let reg = mk_reg(); reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time - //[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time + //~^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time + //~^^ ERROR cannot borrow `*reg` as mutable more than once at a time let reg = mk_reg(); reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time - //[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time + //~^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time + //~^^ ERROR cannot borrow `*reg` as mutable more than once at a time } fn main() { } diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.stderr similarity index 88% rename from src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr rename to src/test/ui/borrowck/two-phase-surprise-no-conflict.stderr index 1ac3a696704bb..bf7d15a343e4a 100644 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr +++ b/src/test/ui/borrowck/two-phase-surprise-no-conflict.stderr @@ -1,16 +1,16 @@ error[E0503]: cannot use `self.cx` because it was mutably borrowed - --> $DIR/two-phase-surprise-no-conflict.rs:30:23 + --> $DIR/two-phase-surprise-no-conflict.rs:21:23 | LL | let _mut_borrow = &mut *self; | ---------- borrow of `*self` occurs here LL | let _access = self.cx; | ^^^^^^^ use of borrowed `*self` -... +LL | //~^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] LL | _mut_borrow; | ----------- borrow later used here error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:69:17 + --> $DIR/two-phase-surprise-no-conflict.rs:57:17 | LL | self.hash_expr(&self.cx_mut.body(eid).value); | ^^^^^---------^^-----------^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | self.hash_expr(&self.cx_mut.body(eid).value); | mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:141:51 + --> $DIR/two-phase-surprise-no-conflict.rs:119:51 | LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -29,7 +29,7 @@ LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:146:54 + --> $DIR/two-phase-surprise-no-conflict.rs:122:54 | LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -38,7 +38,7 @@ LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:151:53 + --> $DIR/two-phase-surprise-no-conflict.rs:125:53 | LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -47,7 +47,7 @@ LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:156:44 + --> $DIR/two-phase-surprise-no-conflict.rs:128:44 | LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -56,7 +56,7 @@ LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); | first mutable borrow occurs here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:168:5 + --> $DIR/two-phase-surprise-no-conflict.rs:138:5 | LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^ @@ -66,7 +66,7 @@ LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); | mutable borrow occurs here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:173:5 + --> $DIR/two-phase-surprise-no-conflict.rs:141:5 | LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { | -- lifetime `'a` defined here @@ -79,7 +79,7 @@ LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); | mutable borrow occurs here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:178:5 + --> $DIR/two-phase-surprise-no-conflict.rs:144:5 | LL | reg.register_ref(&CapturePass::new(®.sess_mut)); | ^^^^------------^^^^^^^^^^^^^^^^^^^-------------^^ @@ -89,7 +89,7 @@ LL | reg.register_ref(&CapturePass::new(®.sess_mut)); | mutable borrow occurs here error[E0499]: cannot borrow `*reg` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:5 + --> $DIR/two-phase-surprise-no-conflict.rs:154:5 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^ @@ -99,7 +99,7 @@ LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | second mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:54 + --> $DIR/two-phase-surprise-no-conflict.rs:154:54 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -108,7 +108,7 @@ LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `*reg` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:5 + --> $DIR/two-phase-surprise-no-conflict.rs:158:5 | LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { | -- lifetime `'a` defined here @@ -121,7 +121,7 @@ LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | second mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:53 + --> $DIR/two-phase-surprise-no-conflict.rs:158:53 | LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -130,7 +130,7 @@ LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `*reg` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:5 + --> $DIR/two-phase-surprise-no-conflict.rs:162:5 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); | ^^^^------------^^^^^^^^^^^^^^^^^^^^^^^-----------------^^ @@ -140,7 +140,7 @@ LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); | second mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:44 + --> $DIR/two-phase-surprise-no-conflict.rs:162:44 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr deleted file mode 100644 index d6125cfd72108..0000000000000 --- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:11:9 - | -LL | let y = vec![format!("World")]; - | - captured outer variable -LL | call(|| { -LL | y.into_iter(); - | ^ cannot move out of captured variable in an `Fn` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs index 4c6a05338a1ea..f45aa90b607e8 100644 --- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs +++ b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs @@ -9,6 +9,6 @@ fn main() { let y = vec![format!("World")]; call(|| { y.into_iter(); - //~^ ERROR cannot move out of captured outer variable in an `Fn` closure + //~^ ERROR cannot move out of captured variable in an `Fn` closure }); } diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr index bdfd6fb7e5539..d6125cfd72108 100644 --- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr +++ b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of captured outer variable in an `Fn` closure +error[E0507]: cannot move out of captured variable in an `Fn` closure --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:11:9 | LL | let y = vec![format!("World")]; | - captured outer variable LL | call(|| { LL | y.into_iter(); - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure error: aborting due to previous error diff --git a/src/test/ui/by-move-pattern-binding.nll.stderr b/src/test/ui/by-move-pattern-binding.nll.stderr deleted file mode 100644 index 4b4a989368a78..0000000000000 --- a/src/test/ui/by-move-pattern-binding.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/by-move-pattern-binding.rs:14:11 - | -LL | match &s.x { - | ^^^^ cannot move out of borrowed content -LL | &E::Foo => {} -LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move - | ------------------- - | | | - | | data moved here - | help: consider removing the `&`: `E::Bar(identifier)` - | -note: move occurs because `identifier` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/by-move-pattern-binding.rs:16:17 - | -LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move - | ^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/by-move-pattern-binding.rs b/src/test/ui/by-move-pattern-binding.rs index 455b206e53f1a..d4c9f23164f8b 100644 --- a/src/test/ui/by-move-pattern-binding.rs +++ b/src/test/ui/by-move-pattern-binding.rs @@ -11,9 +11,9 @@ fn f(x: String) {} fn main() { let s = S { x: E::Bar("hello".to_string()) }; - match &s.x { + match &s.x { //~ ERROR cannot move &E::Foo => {} - &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move + &E::Bar(identifier) => f(identifier.clone()) }; match &s.x { &E::Foo => {} diff --git a/src/test/ui/by-move-pattern-binding.stderr b/src/test/ui/by-move-pattern-binding.stderr index d3c5e2caa4294..99fa12617d337 100644 --- a/src/test/ui/by-move-pattern-binding.stderr +++ b/src/test/ui/by-move-pattern-binding.stderr @@ -1,11 +1,20 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/by-move-pattern-binding.rs:16:9 + --> $DIR/by-move-pattern-binding.rs:14:11 | -LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move - | ^^^^^^^^----------^ +LL | match &s.x { //~ ERROR cannot move + | ^^^^ cannot move out of borrowed content +LL | &E::Foo => {} +LL | &E::Bar(identifier) => f(identifier.clone()) + | ------------------- | | | - | | hint: to prevent move, use `ref identifier` or `ref mut identifier` - | cannot move out of borrowed content + | | data moved here + | help: consider removing the `&`: `E::Bar(identifier)` + | +note: move occurs because `identifier` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/by-move-pattern-binding.rs:16:17 + | +LL | &E::Bar(identifier) => f(identifier.clone()) + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.stderr b/src/test/ui/cannot-mutate-captured-non-mut-var.ast.stderr deleted file mode 100644 index 1098c16aaf63f..0000000000000 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0594]: cannot assign to immutable captured outer variable in an `FnOnce` closure `x` - --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 - | -LL | to_fn_once(move|| { x = 2; }); - | ^^^^^ - -error[E0596]: cannot borrow immutable captured outer variable in an `FnOnce` closure `s` as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:18:25 - | -LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - | ^ - -error: aborting due to 2 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.mir.stderr b/src/test/ui/cannot-mutate-captured-non-mut-var.mir.stderr deleted file mode 100644 index 581dcde59f5e9..0000000000000 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.mir.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 - | -LL | let x = 1; - | - help: consider changing this to be mutable: `mut x` -LL | to_fn_once(move|| { x = 2; }); - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:18:25 - | -LL | let s = std::io::stdin(); - | - help: consider changing this to be mutable: `mut s` -LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - | ^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.rs b/src/test/ui/cannot-mutate-captured-non-mut-var.rs index 18257d09fa090..a83884acb1d29 100644 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.rs +++ b/src/test/ui/cannot-mutate-captured-non-mut-var.rs @@ -1,7 +1,3 @@ -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(unboxed_closures)] use std::io::Read; @@ -11,11 +7,9 @@ fn to_fn_once>(f: F) -> F { f } fn main() { let x = 1; to_fn_once(move|| { x = 2; }); - //[ast]~^ ERROR: cannot assign to immutable captured outer variable - //[mir]~^^ ERROR: cannot assign to `x`, as it is not declared as mutable + //~^ ERROR: cannot assign to `x`, as it is not declared as mutable let s = std::io::stdin(); to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - //[ast]~^ ERROR: cannot borrow immutable captured outer variable - //[mir]~^^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable + //~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.nll.stderr b/src/test/ui/cannot-mutate-captured-non-mut-var.stderr similarity index 93% rename from src/test/ui/cannot-mutate-captured-non-mut-var.ast.nll.stderr rename to src/test/ui/cannot-mutate-captured-non-mut-var.stderr index 581dcde59f5e9..c0f5b78af409d 100644 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.nll.stderr +++ b/src/test/ui/cannot-mutate-captured-non-mut-var.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 + --> $DIR/cannot-mutate-captured-non-mut-var.rs:9:25 | LL | let x = 1; | - help: consider changing this to be mutable: `mut x` @@ -7,7 +7,7 @@ LL | to_fn_once(move|| { x = 2; }); | ^^^^^ cannot assign error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:18:25 + --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 | LL | let s = std::io::stdin(); | - help: consider changing this to be mutable: `mut s` diff --git a/src/test/ui/check-static-values-constraints.nll.stderr b/src/test/ui/check-static-values-constraints.nll.stderr deleted file mode 100644 index f1a2312490813..0000000000000 --- a/src/test/ui/check-static-values-constraints.nll.stderr +++ /dev/null @@ -1,112 +0,0 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/check-static-values-constraints.rs:65:43 - | -LL | ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), - | ___________________________________________^ -LL | | //~^ ERROR destructors cannot be evaluated at compile-time -LL | | field2: SafeEnum::Variant1}}; - | |________________________________________________________________________________^ statics cannot evaluate destructors - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:79:33 - | -LL | static STATIC11: Box = box MyOwned; - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:79:37 - | -LL | static STATIC11: Box = box MyOwned; - | ^^^^^^^ - -error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/check-static-values-constraints.rs:90:32 - | -LL | field2: SafeEnum::Variant4("str".to_string()) - | ^^^^^^^^^^^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:95:5 - | -LL | box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:95:9 - | -LL | box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:97:5 - | -LL | box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:97:9 - | -LL | box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:102:6 - | -LL | &box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:102:10 - | -LL | &box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:104:6 - | -LL | &box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:104:10 - | -LL | &box MyOwned, //~ ERROR allocations are not allowed in statics - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:111:5 - | -LL | box 3; - | ^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:111:9 - | -LL | box 3; - | ^ - -error[E0507]: cannot move out of static item - --> $DIR/check-static-values-constraints.rs:116:45 - | -LL | let y = { static x: Box = box 3; x }; - | ^ - | | - | cannot move out of static item - | help: consider borrowing here: `&x` - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:116:38 - | -LL | let y = { static x: Box = box 3; x }; - | ^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:116:42 - | -LL | let y = { static x: Box = box 3; x }; - | ^ - -error: aborting due to 17 previous errors - -Some errors occurred: E0010, E0015, E0019, E0493, E0507. -For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/check-static-values-constraints.stderr b/src/test/ui/check-static-values-constraints.stderr index 5b1f265c34aef..f1a2312490813 100644 --- a/src/test/ui/check-static-values-constraints.stderr +++ b/src/test/ui/check-static-values-constraints.stderr @@ -89,7 +89,10 @@ error[E0507]: cannot move out of static item --> $DIR/check-static-values-constraints.rs:116:45 | LL | let y = { static x: Box = box 3; x }; - | ^ cannot move out of static item + | ^ + | | + | cannot move out of static item + | help: consider borrowing here: `&x` error[E0010]: allocations are not allowed in statics --> $DIR/check-static-values-constraints.rs:116:38 diff --git a/src/test/ui/cleanup-rvalue-scopes-cf.rs b/src/test/ui/cleanup-rvalue-scopes-cf.rs index 106dbd324ff9e..e3cecb1bffed6 100644 --- a/src/test/ui/cleanup-rvalue-scopes-cf.rs +++ b/src/test/ui/cleanup-rvalue-scopes-cf.rs @@ -1,5 +1,3 @@ -// ignore-compare-mode-nll - // Test that the borrow checker prevents pointers to temporaries // with statement lifetimes from escaping. @@ -7,7 +5,7 @@ use std::ops::Drop; static mut FLAGS: u64 = 0; -struct Box { f: T } +struct StackBox { f: T } struct AddFlags { bits: u64 } fn AddFlags(bits: u64) -> AddFlags { @@ -25,11 +23,13 @@ impl AddFlags { } pub fn main() { - let _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - let _x = &*arg(&AddFlags(1)); //~ ERROR value does not live long enough - let ref _x = *arg(&AddFlags(1)); //~ ERROR value does not live long enough - let &ref _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough + let x1 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let x2 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed + let x3 = &*arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let ref x4 = *arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let &ref x5 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let x6 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed + let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; + //~^ ERROR temporary value dropped while borrowed + (x1, x2, x3, x4, x5, x6, x7); } diff --git a/src/test/ui/cleanup-rvalue-scopes-cf.stderr b/src/test/ui/cleanup-rvalue-scopes-cf.stderr index 561403d1b42de..3b7b55fe62786 100644 --- a/src/test/ui/cleanup-rvalue-scopes-cf.stderr +++ b/src/test/ui/cleanup-rvalue-scopes-cf.stderr @@ -1,93 +1,94 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:28:19 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:26:19 | -LL | let _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x1 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:29:14 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:27:14 | -LL | let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x2 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:30:21 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:28:21 | -LL | let _x = &*arg(&AddFlags(1)); //~ ERROR value does not live long enough - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x3 = &*arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:31:24 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:29:24 | -LL | let ref _x = *arg(&AddFlags(1)); //~ ERROR value does not live long enough - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let ref x4 = *arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:32:24 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:30:24 | -LL | let &ref _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let &ref x5 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:33:14 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:31:14 | -LL | let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x6 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough -LL | let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough -LL | } - | - temporary value needs to live until here + | creates a temporary which is freed while still in use +... +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:34:34 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:32:44 | -LL | let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -LL | } - | - temporary value needs to live until here +LL | let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | + | creates a temporary which is freed while still in use +LL | //~^ ERROR temporary value dropped while borrowed +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/closure_promotion.rs b/src/test/ui/closure_promotion.rs index a80745e8bcc18..db9c0a6ef3be4 100644 --- a/src/test/ui/closure_promotion.rs +++ b/src/test/ui/closure_promotion.rs @@ -1,8 +1,7 @@ -// ignore-compare-mode-nll +// compile-pass #![allow(const_err)] -// nll successfully compiles this. fn main() { - let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough + let x: &'static _ = &|| { let z = 3; z }; } diff --git a/src/test/ui/closure_promotion.stderr b/src/test/ui/closure_promotion.stderr deleted file mode 100644 index 7b901e3011785..0000000000000 --- a/src/test/ui/closure_promotion.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/closure_promotion.rs:7:26 - | -LL | let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/closures/closure-immutable-outer-variable.fixed b/src/test/ui/closures/closure-immutable-outer-variable.fixed index 22164a24d8bf0..03240d4857ca8 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.fixed +++ b/src/test/ui/closures/closure-immutable-outer-variable.fixed @@ -8,5 +8,6 @@ fn foo(mut f: Box) { fn main() { let mut y = true; - foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable + foo(Box::new(move || y = false) as Box<_>); + //~^ ERROR cannot assign to `y`, as it is not declared as mutable } diff --git a/src/test/ui/closures/closure-immutable-outer-variable.nll.stderr b/src/test/ui/closures/closure-immutable-outer-variable.nll.stderr deleted file mode 100644 index 0c4d90f4c531a..0000000000000 --- a/src/test/ui/closures/closure-immutable-outer-variable.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to `y`, as it is not declared as mutable - --> $DIR/closure-immutable-outer-variable.rs:11:26 - | -LL | let y = true; - | - help: consider changing this to be mutable: `mut y` -LL | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable - | ^^^^^^^^^ cannot assign - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/closures/closure-immutable-outer-variable.rs b/src/test/ui/closures/closure-immutable-outer-variable.rs index fc4e3857268a8..8fa9e44845d5b 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.rs +++ b/src/test/ui/closures/closure-immutable-outer-variable.rs @@ -8,5 +8,6 @@ fn foo(mut f: Box) { fn main() { let y = true; - foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable + foo(Box::new(move || y = false) as Box<_>); + //~^ ERROR cannot assign to `y`, as it is not declared as mutable } diff --git a/src/test/ui/closures/closure-immutable-outer-variable.stderr b/src/test/ui/closures/closure-immutable-outer-variable.stderr index c6a6ebd931c68..7e60f3cd8ffa4 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.stderr +++ b/src/test/ui/closures/closure-immutable-outer-variable.stderr @@ -1,10 +1,10 @@ -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `y`, as it is not declared as mutable --> $DIR/closure-immutable-outer-variable.rs:11:26 | LL | let y = true; - | - help: consider making `y` mutable: `mut y` -LL | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable - | ^^^^^^^^^ + | - help: consider changing this to be mutable: `mut y` +LL | foo(Box::new(move || y = false) as Box<_>); + | ^^^^^^^^^ cannot assign error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr b/src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr deleted file mode 100644 index 7fdeb03acbd6c..0000000000000 --- a/src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/huge_multispan_highlight.rs:90:13 - | -LL | let x = "foo"; - | - help: consider changing this to be mutable: `mut x` -... -LL | let y = &mut x; //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/codemap_tests/huge_multispan_highlight.stderr b/src/test/ui/codemap_tests/huge_multispan_highlight.stderr index 41df802b503d6..7fdeb03acbd6c 100644 --- a/src/test/ui/codemap_tests/huge_multispan_highlight.stderr +++ b/src/test/ui/codemap_tests/huge_multispan_highlight.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/huge_multispan_highlight.rs:90:18 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/huge_multispan_highlight.rs:90:13 | LL | let x = "foo"; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... LL | let y = &mut x; //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/issue-11715.nll.stderr b/src/test/ui/codemap_tests/issue-11715.nll.stderr deleted file mode 100644 index 9f30f38542549..0000000000000 --- a/src/test/ui/codemap_tests/issue-11715.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/issue-11715.rs:5:13 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | let z = &mut x; //~ ERROR cannot borrow - | ^^^^^^ second mutable borrow occurs here -LL | z.use_mut(); -LL | y.use_mut(); - | - first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/codemap_tests/issue-11715.stderr b/src/test/ui/codemap_tests/issue-11715.stderr index 8f320a4e19b2d..9f30f38542549 100644 --- a/src/test/ui/codemap_tests/issue-11715.stderr +++ b/src/test/ui/codemap_tests/issue-11715.stderr @@ -1,13 +1,13 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/issue-11715.rs:5:18 + --> $DIR/issue-11715.rs:5:13 | LL | let y = &mut x; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | let z = &mut x; //~ ERROR cannot borrow - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^ second mutable borrow occurs here +LL | z.use_mut(); +LL | y.use_mut(); + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/one_line.nll.stderr b/src/test/ui/codemap_tests/one_line.nll.stderr deleted file mode 100644 index 0eb257c5976a5..0000000000000 --- a/src/test/ui/codemap_tests/one_line.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/one_line.rs:3:12 - | -LL | v.push(v.pop().unwrap()); //~ ERROR cannot borrow - | - ---- ^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/codemap_tests/one_line.stderr b/src/test/ui/codemap_tests/one_line.stderr index 2ea793c096942..0eb257c5976a5 100644 --- a/src/test/ui/codemap_tests/one_line.stderr +++ b/src/test/ui/codemap_tests/one_line.stderr @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/one_line.rs:3:12 | LL | v.push(v.pop().unwrap()); //~ ERROR cannot borrow - | - ^ - first borrow ends here - | | | - | | second mutable borrow occurs here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/tab_3.nll.stderr b/src/test/ui/codemap_tests/tab_3.nll.stderr deleted file mode 100644 index 3b8507a067ded..0000000000000 --- a/src/test/ui/codemap_tests/tab_3.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `some_vec` - --> $DIR/tab_3.rs:7:20 - | -LL | let some_vec = vec!["hi"]; - | -------- move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait -LL | some_vec.into_iter(); - | -------- value moved here -LL | { -LL | println!("{:?}", some_vec); //~ ERROR use of moved - | ^^^^^^^^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/codemap_tests/tab_3.rs b/src/test/ui/codemap_tests/tab_3.rs index 4fd5b70f7ae37..58b034d0fcf18 100644 --- a/src/test/ui/codemap_tests/tab_3.rs +++ b/src/test/ui/codemap_tests/tab_3.rs @@ -4,6 +4,6 @@ fn main() { let some_vec = vec!["hi"]; some_vec.into_iter(); { - println!("{:?}", some_vec); //~ ERROR use of moved + println!("{:?}", some_vec); //~ ERROR borrow of moved } } diff --git a/src/test/ui/codemap_tests/tab_3.stderr b/src/test/ui/codemap_tests/tab_3.stderr index 6e93ae1306961..ecd626963a0e4 100644 --- a/src/test/ui/codemap_tests/tab_3.stderr +++ b/src/test/ui/codemap_tests/tab_3.stderr @@ -1,13 +1,13 @@ -error[E0382]: use of moved value: `some_vec` +error[E0382]: borrow of moved value: `some_vec` --> $DIR/tab_3.rs:7:20 | +LL | let some_vec = vec!["hi"]; + | -------- move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait LL | some_vec.into_iter(); | -------- value moved here LL | { -LL | println!("{:?}", some_vec); //~ ERROR use of moved - | ^^^^^^^^ value used here after move - | - = note: move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait +LL | println!("{:?}", some_vec); //~ ERROR borrow of moved + | ^^^^^^^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr deleted file mode 100644 index 5b9249cffaea4..0000000000000 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 - | -LL | let y = borrow_mut(x); - | - first mutable borrow occurs here -LL | let z = borrow_mut(x); - | ^ second mutable borrow occurs here -... -LL | drop((y, z)); - | - first borrow later used here - -error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 - | -LL | let y = borrow(x); - | - borrow of `**x` occurs here -LL | let z = borrow(x); -LL | **x += 1; - | ^^^^^^^^ assignment to borrowed `**x` occurs here -... -LL | drop((y, z)); - | - borrow later used here - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 - | -LL | borrow_mut2(x, x); - | ----------- - ^ second mutable borrow occurs here - | | | - | | first mutable borrow occurs here - | first borrow later used by call - -error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable - --> $DIR/coerce-overloaded-autoderef.rs:34:5 - | -LL | borrow2(x, x); - | -------^^^^-^ - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - | immutable borrow later used by call - -error: aborting due to 4 previous errors - -Some errors occurred: E0499, E0502, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.ast.stderr deleted file mode 100644 index 54215f56bca7a..0000000000000 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 - | -LL | let y = borrow_mut(x); - | - first mutable borrow occurs here -LL | let z = borrow_mut(x); - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 - | -LL | let y = borrow(x); - | - borrow of `**x` occurs here -LL | let z = borrow(x); -LL | **x += 1; - | ^^^^^^^^ assignment to borrowed `**x` occurs here - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 - | -LL | borrow_mut2(x, x); - | - ^- first borrow ends here - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here - -error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable - --> $DIR/coerce-overloaded-autoderef.rs:34:16 - | -LL | borrow2(x, x); - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error: aborting due to 4 previous errors - -Some errors occurred: E0499, E0502, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr deleted file mode 100644 index 8dc6fe50afb5f..0000000000000 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 - | -LL | let y = borrow_mut(x); - | - first mutable borrow occurs here -LL | let z = borrow_mut(x); - | ^ second mutable borrow occurs here -... -LL | drop((y, z)); - | - first borrow later used here - -error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 - | -LL | let y = borrow(x); - | - borrow of `**x` occurs here -LL | let z = borrow(x); -LL | **x += 1; - | ^^^^^^^^ assignment to borrowed `**x` occurs here -... -LL | drop((y, z)); - | - borrow later used here - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 - | -LL | borrow_mut2(x, x); - | ----------- - ^ second mutable borrow occurs here - | | | - | | first mutable borrow occurs here - | first borrow later used by call - -error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable - --> $DIR/coerce-overloaded-autoderef.rs:34:16 - | -LL | borrow2(x, x); - | ------- - ^ immutable borrow occurs here - | | | - | | mutable borrow occurs here - | mutable borrow later used by call - -error: aborting due to 4 previous errors - -Some errors occurred: E0499, E0502, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.rs b/src/test/ui/coercion/coerce-overloaded-autoderef.rs index ec72745cd71ed..01d9c1e486a42 100644 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.rs +++ b/src/test/ui/coercion/coerce-overloaded-autoderef.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn borrow_mut(x: &mut T) -> &mut T { x } fn borrow(x: &T) -> &T { x } @@ -10,8 +7,7 @@ fn borrow2(_: &mut T, _: &T) {} fn double_mut_borrow(x: &mut Box) { let y = borrow_mut(x); let z = borrow_mut(x); - //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time - //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time + //~^ ERROR cannot borrow `*x` as mutable more than once at a time drop((y, z)); } @@ -19,21 +15,18 @@ fn double_imm_borrow(x: &mut Box) { let y = borrow(x); let z = borrow(x); **x += 1; - //[ast]~^ ERROR cannot assign to `**x` because it is borrowed - //[mir]~^^ ERROR cannot assign to `**x` because it is borrowed + //~^ ERROR cannot assign to `**x` because it is borrowed drop((y, z)); } fn double_mut_borrow2(x: &mut Box) { borrow_mut2(x, x); - //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time - //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time + //~^ ERROR cannot borrow `*x` as mutable more than once at a time } fn double_borrow2(x: &mut Box) { borrow2(x, x); - //[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `*x` as mutable because it is also borrowed as immutable } pub fn main() {} diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.stderr similarity index 80% rename from src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr rename to src/test/ui/coercion/coerce-overloaded-autoderef.stderr index 5b9249cffaea4..6389a4a388e5f 100644 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr +++ b/src/test/ui/coercion/coerce-overloaded-autoderef.stderr @@ -1,28 +1,28 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 + --> $DIR/coerce-overloaded-autoderef.rs:9:24 | LL | let y = borrow_mut(x); | - first mutable borrow occurs here LL | let z = borrow_mut(x); | ^ second mutable borrow occurs here -... +LL | //~^ ERROR cannot borrow `*x` as mutable more than once at a time LL | drop((y, z)); | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 + --> $DIR/coerce-overloaded-autoderef.rs:17:5 | LL | let y = borrow(x); | - borrow of `**x` occurs here LL | let z = borrow(x); LL | **x += 1; | ^^^^^^^^ assignment to borrowed `**x` occurs here -... +LL | //~^ ERROR cannot assign to `**x` because it is borrowed LL | drop((y, z)); | - borrow later used here error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 + --> $DIR/coerce-overloaded-autoderef.rs:23:20 | LL | borrow_mut2(x, x); | ----------- - ^ second mutable borrow occurs here @@ -31,7 +31,7 @@ LL | borrow_mut2(x, x); | first borrow later used by call error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable - --> $DIR/coerce-overloaded-autoderef.rs:34:5 + --> $DIR/coerce-overloaded-autoderef.rs:28:5 | LL | borrow2(x, x); | -------^^^^-^ diff --git a/src/test/ui/command-line-diagnostics.nll.stderr b/src/test/ui/command-line-diagnostics.nll.stderr deleted file mode 100644 index b3f8d8a643fb5..0000000000000 --- a/src/test/ui/command-line-diagnostics.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/command-line-diagnostics.rs:6:5 - | -LL | let x = 42; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x = 43; - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/command-line-diagnostics.stderr b/src/test/ui/command-line-diagnostics.stderr index 6f1156e0d36d7..b3f8d8a643fb5 100644 --- a/src/test/ui/command-line-diagnostics.stderr +++ b/src/test/ui/command-line-diagnostics.stderr @@ -2,7 +2,10 @@ error[E0384]: cannot assign twice to immutable variable `x` --> $DIR/command-line-diagnostics.rs:6:5 | LL | let x = 42; - | - first assignment to `x` + | - + | | + | first assignment to `x` + | help: make this binding mutable: `mut x` LL | x = 43; | ^^^^^^ cannot assign twice to immutable variable diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr deleted file mode 100644 index 238db527e3883..0000000000000 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error: `foo` is not yet stable as a const fn - --> $DIR/dont_promote_unstable_const_fn.rs:15:25 - | -LL | const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn - | ^^^^^ - | - = help: add `#![feature(foo)]` to the crate attributes to enable - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn.rs:18:28 - | -LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn.rs:22:28 - | -LL | let _: &'static u32 = &meh(); //~ ERROR does not live long enough - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn.rs:23:26 - | -LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | //~^ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs index 7170be1b88baf..900286909902c 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs @@ -15,11 +15,11 @@ fn meh() -> u32 { 42 } const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn fn a() { - let _: &'static u32 = &foo(); //~ ERROR does not live long enough + let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed } fn main() { - let _: &'static u32 = &meh(); //~ ERROR does not live long enough + let _: &'static u32 = &meh(); //~ ERROR temporary value dropped while borrowed let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr index fdbc4cb0c8d27..e79632aabfdca 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr @@ -6,38 +6,38 @@ LL | const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a cons | = help: add `#![feature(foo)]` to the crate attributes to enable -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:18:28 | -LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough - | ^^^^^ temporary value does not live long enough +LL | let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:22:28 | -LL | let _: &'static u32 = &meh(); //~ ERROR does not live long enough - | ^^^^^ temporary value does not live long enough +LL | let _: &'static u32 = &meh(); //~ ERROR temporary value dropped while borrowed + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:23:26 | LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | //~^ ERROR does not live long enough + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr deleted file mode 100644 index 4355401987b01..0000000000000 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:8:28 - | -LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:9:29 - | -LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs index 6dcfcfe6780c9..ea35f46807abb 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs @@ -5,6 +5,6 @@ extern crate stability; use stability::foo; fn main() { - let _: &'static u32 = &foo(); //~ ERROR does not live long enough - let _x: &'static u32 = &foo(); //~ ERROR does not live long enough + let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed + let _x: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr index 8be7add22009e..c297fe1c675f7 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr @@ -1,24 +1,24 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:8:28 | -LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough - | ^^^^^ temporary value does not live long enough -LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough +LL | let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let _x: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:9:29 | -LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough - | ^^^^^ temporary value does not live long enough +LL | let _x: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr deleted file mode 100644 index a2a71fc2ce368..0000000000000 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail.rs:20:27 - | -LL | let x: &'static u8 = &(bar() + 1); //~ ERROR does not live long enough - | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs index 80562b0ee830b..88181cb86100f 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs @@ -17,7 +17,7 @@ const fn bar() -> u8 { } fn main() { - let x: &'static u8 = &(bar() + 1); //~ ERROR does not live long enough + let x: &'static u8 = &(bar() + 1); //~ ERROR temporary value dropped while borrowed let y = *x; unreachable!(); } diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr index 9316d48ab4318..7beb9c50d4655 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_fn_fail.rs:20:27 | -LL | let x: &'static u8 = &(bar() + 1); //~ ERROR does not live long enough - | ^^^^^^^^^^^ temporary value does not live long enough +LL | let x: &'static u8 = &(bar() + 1); //~ ERROR temporary value dropped while borrowed + | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.nll.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.nll.stderr deleted file mode 100644 index 987d2304ae871..0000000000000 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail_deny_const_err.rs:21:27 - | -LL | let x: &'static u8 = &(bar() + 1); - | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs index f331e44de17d1..061ab7eeb029d 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs @@ -19,7 +19,7 @@ fn main() { // This will compile, but then hard-abort at runtime. // FIXME(oli-obk): this should instead panic (not hard-abort) at runtime. let x: &'static u8 = &(bar() + 1); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let y = *x; unreachable!(); } diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr index 9c786b0864cb6..987d2304ae871 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_fn_fail_deny_const_err.rs:21:27 | LL | let x: &'static u8 = &(bar() + 1); - | ^^^^^^^^^^^ temporary value does not live long enough + | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr deleted file mode 100644 index 117090d89fd73..0000000000000 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:4:29 - | -LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:6:30 - | -LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough - | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:7:28 - | -LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:8:29 - | -LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs index ef7e5506f22ae..c6fb5eeab5aec 100644 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs +++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs @@ -2,8 +2,11 @@ fn main() { let x: &'static bool = &(42 as *const i32 == 43 as *const i32); - //~^ ERROR does not live long enough - let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough - let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough - let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed + let y: &'static usize = &(&1 as *const i32 as usize + 1); + //~^ ERROR temporary value dropped while borrowed + let z: &'static i32 = &(unsafe { *(42 as *const i32) }); + //~^ ERROR temporary value dropped while borrowed + let a: &'static bool = &(main as fn() == main as fn()); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr index 9d1dcfafa6363..b79756fb73af2 100644 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr @@ -1,46 +1,47 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:4:29 | LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:6:30 | -LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); + | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/promoted_raw_ptr_ops.rs:7:28 +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:8:28 | -LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough +LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/promoted_raw_ptr_ops.rs:8:29 - | -LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:10:29 + | +LL | let a: &'static bool = &(main as fn() == main as fn()); + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr b/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr deleted file mode 100644 index 90fe7eebe4a76..0000000000000 --- a/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/transmute-const-promotion.rs:6:37 - | -LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | //~^ ERROR value does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/transmute-const-promotion.rs b/src/test/ui/consts/const-eval/transmute-const-promotion.rs index a1da35039739e..8bd1b341e6e12 100644 --- a/src/test/ui/consts/const-eval/transmute-const-promotion.rs +++ b/src/test/ui/consts/const-eval/transmute-const-promotion.rs @@ -4,5 +4,5 @@ use std::mem; fn main() { let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; - //~^ ERROR value does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/transmute-const-promotion.stderr b/src/test/ui/consts/const-eval/transmute-const-promotion.stderr index 996e84de06dcf..43df187f8de0c 100644 --- a/src/test/ui/consts/const-eval/transmute-const-promotion.stderr +++ b/src/test/ui/consts/const-eval/transmute-const-promotion.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/transmute-const-promotion.rs:6:37 | LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; - | ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | //~^ ERROR value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/union_promotion.nll.stderr b/src/test/ui/consts/const-eval/union_promotion.nll.stderr deleted file mode 100644 index 11bc7f9da35f7..0000000000000 --- a/src/test/ui/consts/const-eval/union_promotion.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/union_promotion.rs:9:29 - | -LL | let x: &'static bool = &unsafe { //~ borrowed value does not live long enough - | ____________-------------____^ - | | | - | | type annotation requires that borrow lasts for `'static` -LL | | Foo { a: &1 }.b == Foo { a: &2 }.b -LL | | }; - | |_____^ creates a temporary which is freed while still in use -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/union_promotion.rs b/src/test/ui/consts/const-eval/union_promotion.rs index c308c81cf64b8..d3566511ef8ee 100644 --- a/src/test/ui/consts/const-eval/union_promotion.rs +++ b/src/test/ui/consts/const-eval/union_promotion.rs @@ -6,7 +6,7 @@ union Foo { } fn main() { - let x: &'static bool = &unsafe { //~ borrowed value does not live long enough + let x: &'static bool = &unsafe { //~ temporary value dropped while borrowed Foo { a: &1 }.b == Foo { a: &2 }.b }; } diff --git a/src/test/ui/consts/const-eval/union_promotion.stderr b/src/test/ui/consts/const-eval/union_promotion.stderr index 643c784ca08fc..7fafb6c72a1ec 100644 --- a/src/test/ui/consts/const-eval/union_promotion.stderr +++ b/src/test/ui/consts/const-eval/union_promotion.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/union_promotion.rs:9:29 | -LL | let x: &'static bool = &unsafe { //~ borrowed value does not live long enough - | _____________________________^ +LL | let x: &'static bool = &unsafe { //~ temporary value dropped while borrowed + | ____________-------------____^ + | | | + | | type annotation requires that borrow lasts for `'static` LL | | Foo { a: &1 }.b == Foo { a: &2 }.b LL | | }; - | |_____^ temporary value does not live long enough + | |_____^ creates a temporary which is freed while still in use LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-conversion.nll.stderr b/src/test/ui/consts/const-int-conversion.nll.stderr deleted file mode 100644 index afc051013ed7c..0000000000000 --- a/src/test/ui/consts/const-int-conversion.nll.stderr +++ /dev/null @@ -1,80 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:4:28 - | -LL | let x: &'static i32 = &(5_i32.reverse_bits()); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:6:28 - | -LL | let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:8:28 - | -LL | let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:10:28 - | -LL | let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:12:29 - | -LL | let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:14:29 - | -LL | let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:16:29 - | -LL | let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | //~^ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-conversion.rs b/src/test/ui/consts/const-int-conversion.rs index 8f0aa141a9d64..ea409439ed604 100644 --- a/src/test/ui/consts/const-int-conversion.rs +++ b/src/test/ui/consts/const-int-conversion.rs @@ -2,17 +2,17 @@ fn main() { let x: &'static i32 = &(5_i32.reverse_bits()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-conversion.stderr b/src/test/ui/consts/const-int-conversion.stderr index b216d41727b5f..0e09d1fe54e62 100644 --- a/src/test/ui/consts/const-int-conversion.stderr +++ b/src/test/ui/consts/const-int-conversion.stderr @@ -1,80 +1,80 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:4:28 | LL | let x: &'static i32 = &(5_i32.reverse_bits()); - | ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:6:28 | LL | let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:8:28 | LL | let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:10:28 | LL | let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:12:29 | LL | let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:14:29 | LL | let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:16:29 | LL | let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | //~^ ERROR does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-overflowing.nll.stderr b/src/test/ui/consts/const-int-overflowing.nll.stderr deleted file mode 100644 index ffcac69c1af8b..0000000000000 --- a/src/test/ui/consts/const-int-overflowing.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-overflowing.rs:2:36 - | -LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-overflowing.rs:3:36 - | -LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-overflowing.rs:4:36 - | -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-overflowing.rs b/src/test/ui/consts/const-int-overflowing.rs index 4e69e85780606..cd74c9990995e 100644 --- a/src/test/ui/consts/const-int-overflowing.rs +++ b/src/test/ui/consts/const-int-overflowing.rs @@ -1,5 +1,8 @@ fn main() { - let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough - let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough - let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough + let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); + //~^ ERROR temporary value dropped while borrowed + let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); + //~^ ERROR temporary value dropped while borrowed + let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-overflowing.stderr b/src/test/ui/consts/const-int-overflowing.stderr index 736909e093227..dddc6d5d8b2b4 100644 --- a/src/test/ui/consts/const-int-overflowing.stderr +++ b/src/test/ui/consts/const-int-overflowing.stderr @@ -1,35 +1,36 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-overflowing.rs:2:36 | -LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-overflowing.rs:3:36 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-overflowing.rs:4:36 | -LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough +LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-overflowing.rs:4:36 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-overflowing.rs:6:36 | -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-rotate.nll.stderr b/src/test/ui/consts/const-int-rotate.nll.stderr deleted file mode 100644 index 9923096f46d63..0000000000000 --- a/src/test/ui/consts/const-int-rotate.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-rotate.rs:2:28 - | -LL | let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-rotate.rs:3:28 - | -LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-rotate.rs b/src/test/ui/consts/const-int-rotate.rs index d07c00e0110c9..3aacf854db1da 100644 --- a/src/test/ui/consts/const-int-rotate.rs +++ b/src/test/ui/consts/const-int-rotate.rs @@ -1,4 +1,6 @@ fn main() { - let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough - let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough + let x: &'static i32 = &(5_i32.rotate_left(3)); + //~^ ERROR temporary value dropped while borrowed + let y: &'static i32 = &(5_i32.rotate_right(3)); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-rotate.stderr b/src/test/ui/consts/const-int-rotate.stderr index c15727961f9f6..9d9ebdaec3b1f 100644 --- a/src/test/ui/consts/const-int-rotate.stderr +++ b/src/test/ui/consts/const-int-rotate.stderr @@ -1,24 +1,25 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-rotate.rs:2:28 | -LL | let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough +LL | let x: &'static i32 = &(5_i32.rotate_left(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-rotate.rs:3:28 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-rotate.rs:4:28 | -LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let y: &'static i32 = &(5_i32.rotate_right(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-sign.nll.stderr b/src/test/ui/consts/const-int-sign.nll.stderr deleted file mode 100644 index 43fd002ff3a65..0000000000000 --- a/src/test/ui/consts/const-int-sign.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-sign.rs:2:29 - | -LL | let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough - | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-sign.rs:3:29 - | -LL | let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough - | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-sign.rs b/src/test/ui/consts/const-int-sign.rs index a21797c5ce441..c3111ddf56ca2 100644 --- a/src/test/ui/consts/const-int-sign.rs +++ b/src/test/ui/consts/const-int-sign.rs @@ -1,4 +1,6 @@ fn main() { - let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough - let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough + let x: &'static bool = &(5_i32.is_negative()); + //~^ ERROR temporary value dropped while borrowed + let y: &'static bool = &(5_i32.is_positive()); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-sign.stderr b/src/test/ui/consts/const-int-sign.stderr index 5a9a23af9d655..0fc0f1621bcd4 100644 --- a/src/test/ui/consts/const-int-sign.stderr +++ b/src/test/ui/consts/const-int-sign.stderr @@ -1,24 +1,25 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-sign.rs:2:29 | -LL | let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough +LL | let x: &'static bool = &(5_i32.is_negative()); + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-sign.rs:3:29 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-sign.rs:4:29 | -LL | let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let y: &'static bool = &(5_i32.is_positive()); + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-wrapping.nll.stderr b/src/test/ui/consts/const-int-wrapping.nll.stderr deleted file mode 100644 index 036c8b9d95e1a..0000000000000 --- a/src/test/ui/consts/const-int-wrapping.nll.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:2:28 - | -LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:3:28 - | -LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:4:28 - | -LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:5:28 - | -LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:6:28 - | -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-wrapping.rs b/src/test/ui/consts/const-int-wrapping.rs index 720e40b6ebdeb..50d04f9641d8b 100644 --- a/src/test/ui/consts/const-int-wrapping.rs +++ b/src/test/ui/consts/const-int-wrapping.rs @@ -1,7 +1,12 @@ fn main() { - let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough - let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough - let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough - let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough - let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough + let x: &'static i32 = &(5_i32.wrapping_add(3)); + //~^ ERROR temporary value dropped while borrowed + let y: &'static i32 = &(5_i32.wrapping_sub(3)); + //~^ ERROR temporary value dropped while borrowed + let z: &'static i32 = &(5_i32.wrapping_mul(3)); + //~^ ERROR temporary value dropped while borrowed + let a: &'static i32 = &(5_i32.wrapping_shl(3)); + //~^ ERROR temporary value dropped while borrowed + let b: &'static i32 = &(5_i32.wrapping_shr(3)); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-wrapping.stderr b/src/test/ui/consts/const-int-wrapping.stderr index ec9776b821194..5f5a49802bd6f 100644 --- a/src/test/ui/consts/const-int-wrapping.stderr +++ b/src/test/ui/consts/const-int-wrapping.stderr @@ -1,57 +1,58 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:2:28 | -LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-wrapping.rs:3:28 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:4:28 | -LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-wrapping.rs:4:28 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:6:28 | -LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-wrapping.rs:5:28 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:8:28 | -LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough +LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-wrapping.rs:6:28 - | -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:10:28 + | +LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-ptr-nonnull.nll.stderr b/src/test/ui/consts/const-ptr-nonnull.nll.stderr deleted file mode 100644 index 6977e7fdc1183..0000000000000 --- a/src/test/ui/consts/const-ptr-nonnull.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-ptr-nonnull.rs:4:37 - | -LL | let x: &'static NonNull = &(NonNull::dangling()); - | --------------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-ptr-nonnull.rs:9:37 - | -LL | let x: &'static NonNull = &(non_null.cast()); - | --------------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | //~^ ERROR borrowed value does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-ptr-nonnull.rs b/src/test/ui/consts/const-ptr-nonnull.rs index 54e743aa32e23..25cf6cf4aaa6c 100644 --- a/src/test/ui/consts/const-ptr-nonnull.rs +++ b/src/test/ui/consts/const-ptr-nonnull.rs @@ -2,10 +2,10 @@ use std::ptr::NonNull; fn main() { let x: &'static NonNull = &(NonNull::dangling()); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed let mut i: i32 = 10; let non_null = NonNull::new(&mut i).unwrap(); let x: &'static NonNull = &(non_null.cast()); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-ptr-nonnull.stderr b/src/test/ui/consts/const-ptr-nonnull.stderr index a9476dda6d320..2e42e1e968de9 100644 --- a/src/test/ui/consts/const-ptr-nonnull.stderr +++ b/src/test/ui/consts/const-ptr-nonnull.stderr @@ -1,25 +1,25 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-nonnull.rs:4:37 | LL | let x: &'static NonNull = &(NonNull::dangling()); - | ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-nonnull.rs:9:37 | LL | let x: &'static NonNull = &(non_null.cast()); - | ^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | //~^ ERROR borrowed value does not live long enough + | --------------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-ptr-unique.nll.stderr b/src/test/ui/consts/const-ptr-unique.nll.stderr deleted file mode 100644 index b201994c894e4..0000000000000 --- a/src/test/ui/consts/const-ptr-unique.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-ptr-unique.rs:8:33 - | -LL | let x: &'static *mut u32 = &(unique.as_ptr()); - | ----------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | //~^ ERROR borrowed value does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-ptr-unique.rs b/src/test/ui/consts/const-ptr-unique.rs index be44a24181606..252c5d1a9cda5 100644 --- a/src/test/ui/consts/const-ptr-unique.rs +++ b/src/test/ui/consts/const-ptr-unique.rs @@ -6,5 +6,5 @@ fn main() { let mut i: u32 = 10; let unique = Unique::new(&mut i).unwrap(); let x: &'static *mut u32 = &(unique.as_ptr()); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-ptr-unique.stderr b/src/test/ui/consts/const-ptr-unique.stderr index 141465bf184d0..f76815fd105ea 100644 --- a/src/test/ui/consts/const-ptr-unique.stderr +++ b/src/test/ui/consts/const-ptr-unique.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-unique.rs:8:33 | LL | let x: &'static *mut u32 = &(unique.as_ptr()); - | ^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | //~^ ERROR borrowed value does not live long enough + | ----------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr deleted file mode 100644 index feb4960e0c746..0000000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr +++ /dev/null @@ -1,298 +0,0 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:37:25 - | -LL | const fn into_inner(self) -> T { self.0 } //~ destructors cannot be evaluated - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:39:36 - | -LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:44:28 - | -LL | const fn into_inner_lt(self) -> T { self.0 } //~ destructors cannot be evaluated - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:46:42 - | -LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:51:27 - | -LL | const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructors - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:53:38 - | -LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:58:39 - | -LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:76:16 - | -LL | const fn foo11(t: T) -> T { t } - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:78:18 - | -LL | const fn foo11_2(t: T) -> T { t } - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:80:33 - | -LL | const fn foo19(f: f32) -> f32 { f * 2.0 } - | ^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:82:35 - | -LL | const fn foo19_2(f: f32) -> f32 { 2.0 - f } - | ^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int and `bool` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:84:35 - | -LL | const fn foo19_3(f: f32) -> f32 { -f } - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:86:43 - | -LL | const fn foo19_4(f: f32, g: f32) -> f32 { f / g } - | ^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: cannot access `static` items in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:90:27 - | -LL | const fn foo25() -> u32 { BAR } //~ ERROR cannot access `static` items in const fn - | ^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: cannot access `static` items in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:91:36 - | -LL | const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot access `static` items - | ^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:92:42 - | -LL | const fn foo30(x: *const u32) -> usize { x as usize } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:94:63 - | -LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:96:42 - | -LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:98:63 - | -LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:100:38 - | -LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } } - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:102:29 - | -LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn - | ^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:104:44 - | -LL | const fn foo36(a: bool, b: bool) -> bool { a && b } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:106:44 - | -LL | const fn foo37(a: bool, b: bool) -> bool { a || b } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:108:14 - | -LL | const fn inc(x: &mut i32) { *x += 1 } - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:113:6 - | -LL | impl Foo { - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:118:6 - | -LL | impl Foo { - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:123:6 - | -LL | impl Foo { - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `impl Trait` in const fn is unstable (see issue #57563) - --> $DIR/min_const_fn.rs:129:24 - | -LL | const fn no_rpit2() -> AlanTuring { AlanTuring(0) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:131:34 - | -LL | const fn no_apit2(_x: AlanTuring) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:133:22 - | -LL | const fn no_apit(_x: impl std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `impl Trait` in const fn is unstable (see issue #57563) - --> $DIR/min_const_fn.rs:134:23 - | -LL | const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn is unstable - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:135:23 - | -LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:136:32 - | -LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -warning[E0515]: cannot return reference to temporary value - --> $DIR/min_const_fn.rs:136:63 - | -LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^-- - | || - | |temporary value created here - | returns a reference to data owned by the current function - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:141:41 - | -LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:144:21 - | -LL | const fn no_fn_ptrs(_x: fn()) {} - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:146:27 - | -LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } - | ^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error: aborting due to 36 previous errors - -Some errors occurred: E0493, E0515, E0723. -For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index ee3ffcd4026d3..881cbb14b538f 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -135,6 +135,9 @@ const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } //~^ ERROR trait bounds other than `Sized` +//~| WARNING cannot return reference to temporary value +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future const fn no_unsafe() { unsafe {} } diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index e095ccaf20e29..315f2f6d834e0 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -256,8 +256,20 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } | = help: add #![feature(const_fn)] to the crate attributes to enable +warning[E0515]: cannot return reference to temporary value + --> $DIR/min_const_fn.rs:136:63 + | +LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } + | ^-- + | || + | |temporary value created here + | returns a reference to data owned by the current function + | + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:141:41 + --> $DIR/min_const_fn.rs:144:41 | LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -265,7 +277,7 @@ LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } = help: add #![feature(const_fn)] to the crate attributes to enable error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:144:21 + --> $DIR/min_const_fn.rs:147:21 | LL | const fn no_fn_ptrs(_x: fn()) {} | ^^ @@ -273,7 +285,7 @@ LL | const fn no_fn_ptrs(_x: fn()) {} = help: add #![feature(const_fn)] to the crate attributes to enable error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:146:27 + --> $DIR/min_const_fn.rs:149:27 | LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } | ^^^^ @@ -282,5 +294,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } error: aborting due to 36 previous errors -Some errors occurred: E0493, E0723. +Some errors occurred: E0493, E0515, E0723. For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr deleted file mode 100644 index 2800d622f5353..0000000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn_dyn.rs:9:5 - | -LL | x.0.field; - | ^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn_dyn.rs:12:66 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -warning[E0716]: temporary value dropped while borrowed - --> $DIR/min_const_fn_dyn.rs:12:67 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | -^ - temporary value is freed at the end of this statement - | || - | |creates a temporary which is freed while still in use - | cast requires that borrow lasts for `'static` - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error: aborting due to 2 previous errors - -Some errors occurred: E0716, E0723. -For more information about an error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs index 6ca1e59b3af10..75b67192f0081 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs @@ -11,5 +11,8 @@ const fn no_inner_dyn_trait2(x: Hide) { } const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } //~^ ERROR trait bounds other than `Sized` +//~| WARNING temporary value dropped while borrowed +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future fn main() {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr index 8ff963722cf15..2800d622f5353 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr @@ -14,6 +14,19 @@ LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } | = help: add #![feature(const_fn)] to the crate attributes to enable +warning[E0716]: temporary value dropped while borrowed + --> $DIR/min_const_fn_dyn.rs:12:67 + | +LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } + | -^ - temporary value is freed at the end of this statement + | || + | |creates a temporary which is freed while still in use + | cast requires that borrow lasts for `'static` + | + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0723`. +Some errors occurred: E0716, E0723. +For more information about an error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/promotion.nll.stderr b/src/test/ui/consts/min_const_fn/promotion.nll.stderr deleted file mode 100644 index eb186ce495137..0000000000000 --- a/src/test/ui/consts/min_const_fn/promotion.nll.stderr +++ /dev/null @@ -1,68 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:11:27 - | -LL | let x: &'static () = &foo1(); //~ ERROR does not live long enough - | ----------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:12:28 - | -LL | let y: &'static i32 = &foo2(42); //~ ERROR does not live long enough - | ------------ ^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:13:28 - | -LL | let z: &'static i32 = &foo3(); //~ ERROR does not live long enough - | ------------ ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:14:34 - | -LL | let a: &'static Cell = &foo4(); //~ ERROR does not live long enough - | ------------------ ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:15:42 - | -LL | let a: &'static Option> = &foo5(); //~ ERROR does not live long enough - | -------------------------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:16:42 - | -LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough - | -------------------------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/promotion.rs b/src/test/ui/consts/min_const_fn/promotion.rs index 969bf40a93ba7..fbe535c714b32 100644 --- a/src/test/ui/consts/min_const_fn/promotion.rs +++ b/src/test/ui/consts/min_const_fn/promotion.rs @@ -8,10 +8,10 @@ const fn foo5() -> Option> { Some(Cell::new(42)) } const fn foo6() -> Option> { None } fn main() { - let x: &'static () = &foo1(); //~ ERROR does not live long enough - let y: &'static i32 = &foo2(42); //~ ERROR does not live long enough - let z: &'static i32 = &foo3(); //~ ERROR does not live long enough - let a: &'static Cell = &foo4(); //~ ERROR does not live long enough - let a: &'static Option> = &foo5(); //~ ERROR does not live long enough - let a: &'static Option> = &foo6(); //~ ERROR does not live long enough + let x: &'static () = &foo1(); //~ ERROR temporary value dropped while borrowed + let y: &'static i32 = &foo2(42); //~ ERROR temporary value dropped while borrowed + let z: &'static i32 = &foo3(); //~ ERROR temporary value dropped while borrowed + let a: &'static Cell = &foo4(); //~ ERROR temporary value dropped while borrowed + let a: &'static Option> = &foo5(); //~ ERROR temporary value dropped while borrowed + let a: &'static Option> = &foo6(); //~ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/min_const_fn/promotion.stderr b/src/test/ui/consts/min_const_fn/promotion.stderr index 7052f68c3ec61..201b82753c7ce 100644 --- a/src/test/ui/consts/min_const_fn/promotion.stderr +++ b/src/test/ui/consts/min_const_fn/promotion.stderr @@ -1,68 +1,68 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:11:27 | -LL | let x: &'static () = &foo1(); //~ ERROR does not live long enough - | ^^^^^^ temporary value does not live long enough +LL | let x: &'static () = &foo1(); //~ ERROR temporary value dropped while borrowed + | ----------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:12:28 | -LL | let y: &'static i32 = &foo2(42); //~ ERROR does not live long enough - | ^^^^^^^^ temporary value does not live long enough +LL | let y: &'static i32 = &foo2(42); //~ ERROR temporary value dropped while borrowed + | ------------ ^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:13:28 | -LL | let z: &'static i32 = &foo3(); //~ ERROR does not live long enough - | ^^^^^^ temporary value does not live long enough +LL | let z: &'static i32 = &foo3(); //~ ERROR temporary value dropped while borrowed + | ------------ ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:14:34 | -LL | let a: &'static Cell = &foo4(); //~ ERROR does not live long enough - | ^^^^^^ temporary value does not live long enough +LL | let a: &'static Cell = &foo4(); //~ ERROR temporary value dropped while borrowed + | ------------------ ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:15:42 | -LL | let a: &'static Option> = &foo5(); //~ ERROR does not live long enough - | ^^^^^^ temporary value does not live long enough -LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough +LL | let a: &'static Option> = &foo5(); //~ ERROR temporary value dropped while borrowed + | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let a: &'static Option> = &foo6(); //~ ERROR temporary value dropped while borrowed LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:16:42 | -LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough - | ^^^^^^ temporary value does not live long enough +LL | let a: &'static Option> = &foo6(); //~ ERROR temporary value dropped while borrowed + | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/promote_const_let.nll.stderr b/src/test/ui/consts/promote_const_let.nll.stderr deleted file mode 100644 index e6ee1523a3b28..0000000000000 --- a/src/test/ui/consts/promote_const_let.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/promote_const_let.rs:4:9 - | -LL | let x: &'static u32 = { - | ------------ type annotation requires that `y` is borrowed for `'static` -LL | let y = 42; -LL | &y //~ ERROR does not live long enough - | ^^ borrowed value does not live long enough -LL | }; - | - `y` dropped here while still borrowed - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promote_const_let.rs:6:28 - | -LL | let x: &'static u32 = &{ //~ ERROR does not live long enough - | ____________------------____^ - | | | - | | type annotation requires that borrow lasts for `'static` -LL | | let y = 42; -LL | | y -LL | | }; - | |_____^ creates a temporary which is freed while still in use -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -Some errors occurred: E0597, E0716. -For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/consts/promote_const_let.rs b/src/test/ui/consts/promote_const_let.rs index a8a6d4d99c6ff..51a0fec2e7bfe 100644 --- a/src/test/ui/consts/promote_const_let.rs +++ b/src/test/ui/consts/promote_const_let.rs @@ -3,7 +3,7 @@ fn main() { let y = 42; &y //~ ERROR does not live long enough }; - let x: &'static u32 = &{ //~ ERROR does not live long enough + let x: &'static u32 = &{ //~ ERROR temporary value dropped while borrowed let y = 42; y }; diff --git a/src/test/ui/consts/promote_const_let.stderr b/src/test/ui/consts/promote_const_let.stderr index d37bd49186032..e525ac6ed541a 100644 --- a/src/test/ui/consts/promote_const_let.stderr +++ b/src/test/ui/consts/promote_const_let.stderr @@ -1,27 +1,29 @@ error[E0597]: `y` does not live long enough - --> $DIR/promote_const_let.rs:4:10 + --> $DIR/promote_const_let.rs:4:9 | +LL | let x: &'static u32 = { + | ------------ type annotation requires that `y` is borrowed for `'static` +LL | let y = 42; LL | &y //~ ERROR does not live long enough - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `y` dropped here while still borrowed -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promote_const_let.rs:6:28 | -LL | let x: &'static u32 = &{ //~ ERROR does not live long enough - | ____________________________^ +LL | let x: &'static u32 = &{ //~ ERROR temporary value dropped while borrowed + | ____________------------____^ + | | | + | | type annotation requires that borrow lasts for `'static` LL | | let y = 42; LL | | y LL | | }; - | |_____^ temporary value does not live long enough + | |_____^ creates a temporary which is freed while still in use LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/did_you_mean/issue-31424.nll.stderr b/src/test/ui/did_you_mean/issue-31424.nll.stderr deleted file mode 100644 index 91368dded3758..0000000000000 --- a/src/test/ui/did_you_mean/issue-31424.nll.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable - --> $DIR/issue-31424.rs:7:9 - | -LL | (&mut self).bar(); //~ ERROR cannot borrow - | ^^^^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -warning: function cannot return without recursing - --> $DIR/issue-31424.rs:12:5 - | -LL | fn bar(self: &mut Self) { - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -LL | //~^ WARN function cannot return without recursing -LL | (&mut self).bar(); //~ ERROR cannot borrow - | ----------------- recursive call site - | - = note: #[warn(unconditional_recursion)] on by default - = help: a `loop` may express intention better if this is on purpose - -error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable - --> $DIR/issue-31424.rs:14:9 - | -LL | (&mut self).bar(); //~ ERROR cannot borrow - | ^^^^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-31424.stderr b/src/test/ui/did_you_mean/issue-31424.stderr index 1442666ef66a5..91368dded3758 100644 --- a/src/test/ui/did_you_mean/issue-31424.stderr +++ b/src/test/ui/did_you_mean/issue-31424.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable argument `self` as mutable - --> $DIR/issue-31424.rs:7:15 +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-31424.rs:7:9 | LL | (&mut self).bar(); //~ ERROR cannot borrow - | ^^^^ - | | - | cannot reborrow mutably - | try removing `&mut` here + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here warning: function cannot return without recursing --> $DIR/issue-31424.rs:12:5 @@ -19,15 +19,14 @@ LL | (&mut self).bar(); //~ ERROR cannot borrow = note: #[warn(unconditional_recursion)] on by default = help: a `loop` may express intention better if this is on purpose -error[E0596]: cannot borrow immutable argument `self` as mutable - --> $DIR/issue-31424.rs:14:15 +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-31424.rs:14:9 | LL | (&mut self).bar(); //~ ERROR cannot borrow - | ^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | self.bar(); //~ ERROR cannot borrow - | ^^^^ + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to 2 previous errors diff --git a/src/test/ui/did_you_mean/issue-34126.nll.stderr b/src/test/ui/did_you_mean/issue-34126.nll.stderr deleted file mode 100644 index ed73cca435fd0..0000000000000 --- a/src/test/ui/did_you_mean/issue-34126.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable - --> $DIR/issue-34126.rs:6:18 - | -LL | self.run(&mut self); //~ ERROR cannot borrow - | ^^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable - --> $DIR/issue-34126.rs:6:18 - | -LL | self.run(&mut self); //~ ERROR cannot borrow - | ---- --- ^^^^^^^^^ mutable borrow occurs here - | | | - | | immutable borrow later used by call - | immutable borrow occurs here - -error: aborting due to 2 previous errors - -Some errors occurred: E0502, E0596. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/did_you_mean/issue-34126.rs b/src/test/ui/did_you_mean/issue-34126.rs index 15bef1ef815d6..4989577dbb68f 100644 --- a/src/test/ui/did_you_mean/issue-34126.rs +++ b/src/test/ui/did_you_mean/issue-34126.rs @@ -4,6 +4,7 @@ impl Z { fn run(&self, z: &mut Z) { } fn start(&mut self) { self.run(&mut self); //~ ERROR cannot borrow + //~| ERROR cannot borrow } } diff --git a/src/test/ui/did_you_mean/issue-34126.stderr b/src/test/ui/did_you_mean/issue-34126.stderr index 05ea4ef91ce49..ed73cca435fd0 100644 --- a/src/test/ui/did_you_mean/issue-34126.stderr +++ b/src/test/ui/did_you_mean/issue-34126.stderr @@ -1,12 +1,22 @@ -error[E0596]: cannot borrow immutable argument `self` as mutable - --> $DIR/issue-34126.rs:6:23 +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-34126.rs:6:18 | LL | self.run(&mut self); //~ ERROR cannot borrow - | ^^^^ - | | - | cannot reborrow mutably - | try removing `&mut` here + | ^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here -error: aborting due to previous error +error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable + --> $DIR/issue-34126.rs:6:18 + | +LL | self.run(&mut self); //~ ERROR cannot borrow + | ---- --- ^^^^^^^^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call + | immutable borrow occurs here + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0596`. +Some errors occurred: E0502, E0596. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/did_you_mean/issue-34337.nll.stderr b/src/test/ui/did_you_mean/issue-34337.nll.stderr deleted file mode 100644 index 5e46889866d4d..0000000000000 --- a/src/test/ui/did_you_mean/issue-34337.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `key` as mutable, as it is not declared as mutable - --> $DIR/issue-34337.rs:6:9 - | -LL | get(&mut key); //~ ERROR cannot borrow - | ^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-34337.stderr b/src/test/ui/did_you_mean/issue-34337.stderr index 4bf988b72cd00..5e46889866d4d 100644 --- a/src/test/ui/did_you_mean/issue-34337.stderr +++ b/src/test/ui/did_you_mean/issue-34337.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `key` as mutable - --> $DIR/issue-34337.rs:6:14 +error[E0596]: cannot borrow `key` as mutable, as it is not declared as mutable + --> $DIR/issue-34337.rs:6:9 | LL | get(&mut key); //~ ERROR cannot borrow - | ^^^ - | | - | cannot reborrow mutably - | try removing `&mut` here + | ^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/issue-35937.nll.stderr b/src/test/ui/did_you_mean/issue-35937.nll.stderr deleted file mode 100644 index 76fb1e229536d..0000000000000 --- a/src/test/ui/did_you_mean/issue-35937.nll.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0596]: cannot borrow `f.v` as mutable, as `f` is not declared as mutable - --> $DIR/issue-35937.rs:7:5 - | -LL | let f = Foo { v: Vec::new() }; - | - help: consider changing this to be mutable: `mut f` -LL | f.v.push("cat".to_string()); //~ ERROR cannot borrow - | ^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable - --> $DIR/issue-35937.rs:16:5 - | -LL | let s = S { x: 42 }; - | - help: consider changing this to be mutable: `mut s` -LL | s.x += 1; //~ ERROR cannot assign - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable - --> $DIR/issue-35937.rs:20:5 - | -LL | fn bar(s: S) { - | - help: consider changing this to be mutable: `mut s` -LL | s.x += 1; //~ ERROR cannot assign - | ^^^^^^^^ cannot assign - -error: aborting due to 3 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/did_you_mean/issue-35937.stderr b/src/test/ui/did_you_mean/issue-35937.stderr index 7499a9475e889..76fb1e229536d 100644 --- a/src/test/ui/did_you_mean/issue-35937.stderr +++ b/src/test/ui/did_you_mean/issue-35937.stderr @@ -1,26 +1,26 @@ -error[E0596]: cannot borrow field `f.v` of immutable binding as mutable +error[E0596]: cannot borrow `f.v` as mutable, as `f` is not declared as mutable --> $DIR/issue-35937.rs:7:5 | LL | let f = Foo { v: Vec::new() }; - | - help: make this binding mutable: `mut f` + | - help: consider changing this to be mutable: `mut f` LL | f.v.push("cat".to_string()); //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^ cannot borrow as mutable -error[E0594]: cannot assign to field `s.x` of immutable binding +error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable --> $DIR/issue-35937.rs:16:5 | LL | let s = S { x: 42 }; - | - help: make this binding mutable: `mut s` + | - help: consider changing this to be mutable: `mut s` LL | s.x += 1; //~ ERROR cannot assign - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to field `s.x` of immutable binding +error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable --> $DIR/issue-35937.rs:20:5 | LL | fn bar(s: S) { - | - help: make this binding mutable: `mut s` + | - help: consider changing this to be mutable: `mut s` LL | s.x += 1; //~ ERROR cannot assign - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot assign error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/issue-37139.nll.stderr b/src/test/ui/did_you_mean/issue-37139.nll.stderr deleted file mode 100644 index 4d1c8a6b0eb18..0000000000000 --- a/src/test/ui/did_you_mean/issue-37139.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/issue-37139.rs:12:18 - | -LL | test(&mut x); //~ ERROR cannot borrow immutable - | ^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-37139.rs b/src/test/ui/did_you_mean/issue-37139.rs index b7f419ae4a644..07d855d0969f3 100644 --- a/src/test/ui/did_you_mean/issue-37139.rs +++ b/src/test/ui/did_you_mean/issue-37139.rs @@ -9,7 +9,7 @@ fn main() { let mut x = TestEnum::Item(10); match x { TestEnum::Item(ref mut x) => { - test(&mut x); //~ ERROR cannot borrow immutable + test(&mut x); //~ ERROR cannot borrow `x` as mutable, as it is not declared as mutable } } } diff --git a/src/test/ui/did_you_mean/issue-37139.stderr b/src/test/ui/did_you_mean/issue-37139.stderr index 38617fda2afac..a68c7c5b7b056 100644 --- a/src/test/ui/did_you_mean/issue-37139.stderr +++ b/src/test/ui/did_you_mean/issue-37139.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/issue-37139.rs:12:23 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/issue-37139.rs:12:18 | -LL | test(&mut x); //~ ERROR cannot borrow immutable - | ^ - | | - | cannot reborrow mutably - | try removing `&mut` here +LL | test(&mut x); //~ ERROR cannot borrow `x` as mutable, as it is not declared as mutable + | ^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/issue-38147-1.nll.stderr b/src/test/ui/did_you_mean/issue-38147-1.nll.stderr deleted file mode 100644 index 838673b21d1ec..0000000000000 --- a/src/test/ui/did_you_mean/issue-38147-1.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-1.rs:17:9 - | -LL | fn f(&self) { - | ----- help: consider changing this to be a mutable reference: `&mut self` -LL | self.s.push('x'); //~ ERROR cannot borrow data mutably - | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-1.rs b/src/test/ui/did_you_mean/issue-38147-1.rs index b67239619d979..c068a1834f350 100644 --- a/src/test/ui/did_you_mean/issue-38147-1.rs +++ b/src/test/ui/did_you_mean/issue-38147-1.rs @@ -14,7 +14,7 @@ struct Foo<'a> { impl<'a> Foo<'a> { fn f(&self) { - self.s.push('x'); //~ ERROR cannot borrow data mutably + self.s.push('x'); //~ cannot borrow `*self.s` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/did_you_mean/issue-38147-1.stderr b/src/test/ui/did_you_mean/issue-38147-1.stderr index 74c72edd028b0..4629c49a1ed65 100644 --- a/src/test/ui/did_you_mean/issue-38147-1.stderr +++ b/src/test/ui/did_you_mean/issue-38147-1.stderr @@ -1,11 +1,11 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-1.rs:17:9 | LL | fn f(&self) { - | ----- use `&mut self` here to make mutable -LL | self.s.push('x'); //~ ERROR cannot borrow data mutably - | ^^^^^^ assignment into an immutable reference + | ----- help: consider changing this to be a mutable reference: `&mut self` +LL | self.s.push('x'); //~ cannot borrow `*self.s` as mutable, as it is behind a `&` reference + | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-2.nll.stderr b/src/test/ui/did_you_mean/issue-38147-2.nll.stderr deleted file mode 100644 index cb4981089310a..0000000000000 --- a/src/test/ui/did_you_mean/issue-38147-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-2.rs:7:9 - | -LL | s: &'a String - | ---------- help: consider changing this to be mutable: `&'a mut String` -... -LL | self.s.push('x'); - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-2.rs b/src/test/ui/did_you_mean/issue-38147-2.rs index e43ebf9d26142..fe2634d88abf4 100644 --- a/src/test/ui/did_you_mean/issue-38147-2.rs +++ b/src/test/ui/did_you_mean/issue-38147-2.rs @@ -5,7 +5,7 @@ struct Bar<'a> { impl<'a> Bar<'a> { fn f(&mut self) { self.s.push('x'); - //~^ ERROR cannot borrow borrowed content `*self.s` of immutable binding as mutable + //~^ ERROR cannot borrow `*self.s` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/did_you_mean/issue-38147-2.stderr b/src/test/ui/did_you_mean/issue-38147-2.stderr index fa4fccb8d2775..cb4981089310a 100644 --- a/src/test/ui/did_you_mean/issue-38147-2.stderr +++ b/src/test/ui/did_you_mean/issue-38147-2.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow borrowed content `*self.s` of immutable binding as mutable +error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-2.rs:7:9 | LL | s: &'a String - | ---------- use `&'a mut String` here to make mutable + | ---------- help: consider changing this to be mutable: `&'a mut String` ... LL | self.s.push('x'); | ^^^^^^ cannot borrow as mutable diff --git a/src/test/ui/did_you_mean/issue-38147-3.nll.stderr b/src/test/ui/did_you_mean/issue-38147-3.nll.stderr deleted file mode 100644 index 67782578a2c64..0000000000000 --- a/src/test/ui/did_you_mean/issue-38147-3.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-3.rs:7:9 - | -LL | s: &'a String - | ---------- help: consider changing this to be mutable: `&'a mut String` -... -LL | self.s.push('x'); - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-3.rs b/src/test/ui/did_you_mean/issue-38147-3.rs index 4cd703f2f61f0..40b8e0dba26a3 100644 --- a/src/test/ui/did_you_mean/issue-38147-3.rs +++ b/src/test/ui/did_you_mean/issue-38147-3.rs @@ -5,7 +5,7 @@ struct Qux<'a> { impl<'a> Qux<'a> { fn f(&self) { self.s.push('x'); - //~^ ERROR cannot borrow borrowed content `*self.s` of immutable binding as mutable + //~^ ERROR cannot borrow `*self.s` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/did_you_mean/issue-38147-3.stderr b/src/test/ui/did_you_mean/issue-38147-3.stderr index 2cb9835278db1..67782578a2c64 100644 --- a/src/test/ui/did_you_mean/issue-38147-3.stderr +++ b/src/test/ui/did_you_mean/issue-38147-3.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow borrowed content `*self.s` of immutable binding as mutable +error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-3.rs:7:9 | LL | s: &'a String - | ---------- use `&'a mut String` here to make mutable + | ---------- help: consider changing this to be mutable: `&'a mut String` ... LL | self.s.push('x'); | ^^^^^^ cannot borrow as mutable diff --git a/src/test/ui/did_you_mean/issue-38147-4.nll.stderr b/src/test/ui/did_you_mean/issue-38147-4.nll.stderr deleted file mode 100644 index 458e41f6aae7c..0000000000000 --- a/src/test/ui/did_you_mean/issue-38147-4.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-4.rs:6:5 - | -LL | fn f(x: usize, f: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut Foo<'_>` -LL | f.s.push('x'); //~ ERROR cannot borrow data mutably - | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-4.rs b/src/test/ui/did_you_mean/issue-38147-4.rs index 26573d4fddeb6..e2028a9e67bca 100644 --- a/src/test/ui/did_you_mean/issue-38147-4.rs +++ b/src/test/ui/did_you_mean/issue-38147-4.rs @@ -3,7 +3,7 @@ struct Foo<'a> { } fn f(x: usize, f: &Foo) { - f.s.push('x'); //~ ERROR cannot borrow data mutably + f.s.push('x'); //~ ERROR cannot borrow `*f.s` as mutable, as it is behind a `&` reference } fn main() {} diff --git a/src/test/ui/did_you_mean/issue-38147-4.stderr b/src/test/ui/did_you_mean/issue-38147-4.stderr index 6dc4f101084b5..8639d65e45c9d 100644 --- a/src/test/ui/did_you_mean/issue-38147-4.stderr +++ b/src/test/ui/did_you_mean/issue-38147-4.stderr @@ -1,11 +1,11 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-4.rs:6:5 | LL | fn f(x: usize, f: &Foo) { - | ---- use `&mut Foo` here to make mutable -LL | f.s.push('x'); //~ ERROR cannot borrow data mutably - | ^^^ assignment into an immutable reference + | ---- help: consider changing this to be a mutable reference: `&mut Foo<'_>` +LL | f.s.push('x'); //~ ERROR cannot borrow `*f.s` as mutable, as it is behind a `&` reference + | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-39544.nll.stderr b/src/test/ui/did_you_mean/issue-39544.nll.stderr deleted file mode 100644 index 2fb8e3db68cbe..0000000000000 --- a/src/test/ui/did_you_mean/issue-39544.nll.stderr +++ /dev/null @@ -1,102 +0,0 @@ -error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable - --> $DIR/issue-39544.rs:11:13 - | -LL | let z = Z { x: X::Y }; - | - help: consider changing this to be mutable: `mut z` -LL | let _ = &mut z.x; //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:16:17 - | -LL | fn foo<'z>(&'z self) { - | -------- help: consider changing this to be a mutable reference: `&'z mut self` -LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:20:17 - | -LL | fn foo1(&self, other: &Z) { - | ----- help: consider changing this to be a mutable reference: `&mut self` -LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:21:17 - | -LL | fn foo1(&self, other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut self.x; //~ ERROR cannot borrow -LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:25:17 - | -LL | fn foo2<'a>(&'a self, other: &Z) { - | -------- help: consider changing this to be a mutable reference: `&'a mut self` -LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:26:17 - | -LL | fn foo2<'a>(&'a self, other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut self.x; //~ ERROR cannot borrow -LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:30:17 - | -LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -------- help: consider changing this to be a mutable reference: `&'a mut Self` -LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:31:17 - | -LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut self.x; //~ ERROR cannot borrow -LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:35:17 - | -LL | fn foo4(other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable - --> $DIR/issue-39544.rs:41:13 - | -LL | pub fn with_arg(z: Z, w: &Z) { - | - help: consider changing this to be mutable: `mut z` -LL | let _ = &mut z.x; //~ ERROR cannot borrow - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:42:13 - | -LL | pub fn with_arg(z: Z, w: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut z.x; //~ ERROR cannot borrow -LL | let _ = &mut w.x; //~ ERROR cannot borrow - | ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0594]: cannot assign to `*x.0` which is behind a `&` reference - --> $DIR/issue-39544.rs:48:5 - | -LL | *x.0 = 1; - | ^^^^^^^^ cannot assign - -error: aborting due to 12 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/did_you_mean/issue-39544.rs b/src/test/ui/did_you_mean/issue-39544.rs index 89696a06aaae8..3c86f29a89c30 100644 --- a/src/test/ui/did_you_mean/issue-39544.rs +++ b/src/test/ui/did_you_mean/issue-39544.rs @@ -46,5 +46,5 @@ pub fn with_tuple() { let mut y = 0; let x = (&y,); *x.0 = 1; - //~^ ERROR cannot assign to borrowed content `*x.0` of immutable binding + //~^ ERROR cannot assign to `*x.0` which is behind a `&` reference } diff --git a/src/test/ui/did_you_mean/issue-39544.stderr b/src/test/ui/did_you_mean/issue-39544.stderr index 7d6a672843a27..2fb8e3db68cbe 100644 --- a/src/test/ui/did_you_mean/issue-39544.stderr +++ b/src/test/ui/did_you_mean/issue-39544.stderr @@ -1,100 +1,100 @@ -error[E0596]: cannot borrow field `z.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:11:18 +error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable + --> $DIR/issue-39544.rs:11:13 | LL | let z = Z { x: X::Y }; - | - help: make this binding mutable: `mut z` + | - help: consider changing this to be mutable: `mut z` LL | let _ = &mut z.x; //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:16:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:16:17 | LL | fn foo<'z>(&'z self) { - | -------- use `&'z mut self` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&'z mut self` LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:20:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:20:17 | LL | fn foo1(&self, other: &Z) { - | ----- use `&mut self` here to make mutable + | ----- help: consider changing this to be a mutable reference: `&mut self` LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:21:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:21:17 | LL | fn foo1(&self, other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut self.x; //~ ERROR cannot borrow LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:25:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:25:17 | LL | fn foo2<'a>(&'a self, other: &Z) { - | -------- use `&'a mut self` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&'a mut self` LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:26:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:26:17 | LL | fn foo2<'a>(&'a self, other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut self.x; //~ ERROR cannot borrow LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:30:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:30:17 | LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -------- use `&'a mut Self` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&'a mut Self` LL | let _ = &mut self.x; //~ ERROR cannot borrow - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:31:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:31:17 | LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut self.x; //~ ERROR cannot borrow LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:35:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:35:17 | LL | fn foo4(other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut other.x; //~ ERROR cannot borrow - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `z.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:41:18 +error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable + --> $DIR/issue-39544.rs:41:13 | LL | pub fn with_arg(z: Z, w: &Z) { - | - help: make this binding mutable: `mut z` + | - help: consider changing this to be mutable: `mut z` LL | let _ = &mut z.x; //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `w.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:42:18 +error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:42:13 | LL | pub fn with_arg(z: Z, w: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut z.x; //~ ERROR cannot borrow LL | let _ = &mut w.x; //~ ERROR cannot borrow - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0594]: cannot assign to borrowed content `*x.0` of immutable binding +error[E0594]: cannot assign to `*x.0` which is behind a `&` reference --> $DIR/issue-39544.rs:48:5 | LL | *x.0 = 1; - | ^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^ cannot assign error: aborting due to 12 previous errors diff --git a/src/test/ui/did_you_mean/issue-40823.nll.stderr b/src/test/ui/did_you_mean/issue-40823.nll.stderr deleted file mode 100644 index 0389cf5499d9b..0000000000000 --- a/src/test/ui/did_you_mean/issue-40823.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference - --> $DIR/issue-40823.rs:3:5 - | -LL | let mut buf = &[1, 2, 3, 4]; - | ------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4]` -LL | buf.iter_mut(); //~ ERROR cannot borrow immutable borrowed content - | ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-40823.rs b/src/test/ui/did_you_mean/issue-40823.rs index 7e456a354b390..0f8c745546778 100644 --- a/src/test/ui/did_you_mean/issue-40823.rs +++ b/src/test/ui/did_you_mean/issue-40823.rs @@ -1,4 +1,4 @@ fn main() { let mut buf = &[1, 2, 3, 4]; - buf.iter_mut(); //~ ERROR cannot borrow immutable borrowed content + buf.iter_mut(); //~ ERROR cannot borrow `*buf` as mutable, as it is behind a `&` reference } diff --git a/src/test/ui/did_you_mean/issue-40823.stderr b/src/test/ui/did_you_mean/issue-40823.stderr index ee64e79ead931..8ef8408877112 100644 --- a/src/test/ui/did_you_mean/issue-40823.stderr +++ b/src/test/ui/did_you_mean/issue-40823.stderr @@ -1,8 +1,10 @@ -error[E0596]: cannot borrow immutable borrowed content `*buf` as mutable +error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference --> $DIR/issue-40823.rs:3:5 | -LL | buf.iter_mut(); //~ ERROR cannot borrow immutable borrowed content - | ^^^ cannot borrow as mutable +LL | let mut buf = &[1, 2, 3, 4]; + | ------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4]` +LL | buf.iter_mut(); //~ ERROR cannot borrow `*buf` as mutable, as it is behind a `&` reference + | ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.nll.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.nll.stderr deleted file mode 100644 index 59cb804a801fd..0000000000000 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:22 - | -LL | let X { x: y } = x; //~ ERROR cannot move out of type - | - ^ cannot move out of here - | | - | data moved here - | -note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:16 - | -LL | let X { x: y } = x; //~ ERROR cannot move out of type - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr index cb32616d6e6fb..59cb804a801fd 100644 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr +++ b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr @@ -1,11 +1,16 @@ error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:9 + --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:22 | LL | let X { x: y } = x; //~ ERROR cannot move out of type - | ^^^^^^^-^^ - | | | - | | hint: to prevent move, use `ref y` or `ref mut y` - | cannot move out of here + | - ^ cannot move out of here + | | + | data moved here + | +note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:16 + | +LL | let X { x: y } = x; //~ ERROR cannot move out of type + | ^ error: aborting due to previous error diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.nll.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.nll.stderr deleted file mode 100644 index 2143c2f9b2244..0000000000000 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:14:11 - | -LL | match x { - | ^ cannot move out of here -LL | X { x: y } => println!("contents: {}", y) - | - data moved here - | -note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:15:16 - | -LL | X { x: y } => println!("contents: {}", y) - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs index 3a5ed6e3b3e53..9c996a93b9532 100644 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs +++ b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs @@ -12,7 +12,7 @@ fn main() { let x = X { x: "hello".to_string() }; match x { + //~^ ERROR cannot move out of type `X`, which implements the `Drop` trait X { x: y } => println!("contents: {}", y) - //~^ ERROR cannot move out of type `X`, which implements the `Drop` trait } } diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr index 8be1b385afe6c..db08a97240bcc 100644 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr +++ b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr @@ -1,11 +1,17 @@ error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:15:9 + --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:14:11 | +LL | match x { + | ^ cannot move out of here +LL | //~^ ERROR cannot move out of type `X`, which implements the `Drop` trait LL | X { x: y } => println!("contents: {}", y) - | ^^^^^^^-^^ - | | | - | | hint: to prevent move, use `ref y` or `ref mut y` - | cannot move out of here + | - data moved here + | +note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:16:16 + | +LL | X { x: y } => println!("contents: {}", y) + | ^ error: aborting due to previous error diff --git a/src/test/ui/dropck/drop-with-active-borrows-1.nll.stderr b/src/test/ui/dropck/drop-with-active-borrows-1.nll.stderr deleted file mode 100644 index 9c6c9341be77a..0000000000000 --- a/src/test/ui/dropck/drop-with-active-borrows-1.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/drop-with-active-borrows-1.rs:4:10 - | -LL | let b: Vec<&str> = a.lines().collect(); - | - borrow of `a` occurs here -LL | drop(a); //~ ERROR cannot move out of `a` because it is borrowed - | ^ move out of `a` occurs here -LL | for s in &b { - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/dropck/drop-with-active-borrows-1.stderr b/src/test/ui/dropck/drop-with-active-borrows-1.stderr index a4295f96205ac..9c6c9341be77a 100644 --- a/src/test/ui/dropck/drop-with-active-borrows-1.stderr +++ b/src/test/ui/dropck/drop-with-active-borrows-1.stderr @@ -5,6 +5,8 @@ LL | let b: Vec<&str> = a.lines().collect(); | - borrow of `a` occurs here LL | drop(a); //~ ERROR cannot move out of `a` because it is borrowed | ^ move out of `a` occurs here +LL | for s in &b { + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr b/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr deleted file mode 100644 index ffec9306b7771..0000000000000 --- a/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local variable `raw_lines` - --> $DIR/drop-with-active-borrows-2.rs:3:5 - | -LL | raw_lines.iter().map(|l| l.trim()).collect() - | ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | returns a value referencing data owned by the current function - | `raw_lines` is borrowed here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/dropck/drop-with-active-borrows-2.rs b/src/test/ui/dropck/drop-with-active-borrows-2.rs index 4e45633a281cb..cf4cb3dbe7aaf 100644 --- a/src/test/ui/dropck/drop-with-active-borrows-2.rs +++ b/src/test/ui/dropck/drop-with-active-borrows-2.rs @@ -1,7 +1,7 @@ fn read_lines_borrowed<'a>() -> Vec<&'a str> { let raw_lines: Vec = vec!["foo ".to_string(), " bar".to_string()]; raw_lines.iter().map(|l| l.trim()).collect() - //~^ ERROR `raw_lines` does not live long enough + //~^ ERROR cannot return value referencing local variable `raw_lines` } fn main() { diff --git a/src/test/ui/dropck/drop-with-active-borrows-2.stderr b/src/test/ui/dropck/drop-with-active-borrows-2.stderr index 347389cb59d70..ffec9306b7771 100644 --- a/src/test/ui/dropck/drop-with-active-borrows-2.stderr +++ b/src/test/ui/dropck/drop-with-active-borrows-2.stderr @@ -1,18 +1,12 @@ -error[E0597]: `raw_lines` does not live long enough +error[E0515]: cannot return value referencing local variable `raw_lines` --> $DIR/drop-with-active-borrows-2.rs:3:5 | LL | raw_lines.iter().map(|l| l.trim()).collect() - | ^^^^^^^^^ borrowed value does not live long enough -LL | //~^ ERROR `raw_lines` does not live long enough -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 1:24... - --> $DIR/drop-with-active-borrows-2.rs:1:24 - | -LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { - | ^^ + | ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `raw_lines` is borrowed here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr deleted file mode 100644 index 31adb2f3f1471..0000000000000 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:41:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:43:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:47:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:50:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:57:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:59:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr deleted file mode 100644 index e0b7fc4eb9054..0000000000000 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:47:19 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c_shortest` dropped here while still borrowed - | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `other::Dt` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs index 68065639398a5..b8f30355413e5 100644 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs +++ b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs @@ -1,13 +1,3 @@ -// The behavior of AST-borrowck and NLL explcitly differ here due to -// NLL's increased precision; so we use revisions and do not worry -// about the --compare-mode=nll on this test. - -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// ignore-compare-mode-nll - // aux-build:dropck_eyepatch_extern_crate.rs // The point of this test is to illustrate that the `#[may_dangle]` @@ -19,52 +9,74 @@ // // See also dropck-eyepatch.rs for more information about the general // structure of the test. -#![feature(rustc_attrs)] extern crate dropck_eyepatch_extern_crate as other; use other::{Dt,Dr,Pt,Pr,St,Sr}; -fn main() { #![rustc_error] // rust-lang/rust#49855 +fn main() { use std::cell::Cell; - let c_long; - let (c, mut dt, mut dr, mut pt, mut pr, st, sr, c_shortest) - : (Cell<_>, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>, Cell<_>); - c_long = Cell::new(1); - c = Cell::new(1); - c_shortest = Cell::new(1); - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long); - dr = Dr("dr", &c_long); + // We use separate blocks with separate variable to prevent the error + // messages from being deduplicated. + + { + let c_long; + let (mut dt, mut dr): (Dt<_>, Dr<_>); + c_long = Cell::new(1); + + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long); + dr = Dr("dr", &c_long); + } + + { + let (c, mut dt, mut dr): (Cell<_>, Dt<_>, Dr<_>); + c = Cell::new(1); + + // No Error: destructor order precisely modelled + dt = Dt("dt", &c); + dr = Dr("dr", &c); + } + + { + let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + c_shortest = Cell::new(1); - // Error: destructor order imprecisely modelled - dt = Dt("dt", &c); - //[ast]~^ ERROR `c` does not live long enough - dr = Dr("dr", &c); - //[ast]~^ ERROR `c` does not live long enough + // Error: `c_shortest` dies too soon for the references in dtors to be valid. + dt = Dt("dt", &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + dr = Dr("dr", &c_shortest); + } - // Error: `c_shortest` dies too soon for the references in dtors to be valid. - dt = Dt("dt", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - //[nll]~^^ ERROR `c_shortest` does not live long enough - dr = Dr("dr", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c_shortest, &c_long); - pr = Pr("pr", &c_shortest, &c_long); + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); - // Error: Drop impl's assertion does not apply to `B` nor `&'b _` - pt = Pt("pt", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - pr = Pr("pr", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c_shortest, &c_long); + pr = Pr("pr", &c_shortest, &c_long); + } - // No error: St and Sr have no destructor. - st = St("st", &c_shortest); - sr = Sr("sr", &c_shortest); + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + // Error: Drop impl's assertion does not apply to `B` nor `&'b _` + pt = Pt("pt", &c_long, &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + pr = Pr("pr", &c_long, &c_shortest); + } - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); + { + let (st, sr, c_shortest): (St<_>, Sr<_>, Cell<_>); + c_shortest = Cell::new(1); + // No error: St and Sr have no destructor. + st = St("st", &c_shortest); + sr = Sr("sr", &c_shortest); + } } fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr new file mode 100644 index 0000000000000..c10232107e8c4 --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr @@ -0,0 +1,31 @@ +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:46:23 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `other::Dt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:68:32 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `pt` is dropped and runs the `Drop` code for type `other::Pt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr deleted file mode 100644 index ddd47e9743497..0000000000000 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:58:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:60:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:64:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:67:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:74:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:76:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr deleted file mode 100644 index 97c1caa87f5c5..0000000000000 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:64:19 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c_shortest` dropped here while still borrowed - | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.rs b/src/test/ui/dropck/dropck-eyepatch-reorder.rs index 16aaa26125768..44552b3fc1d9f 100644 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.rs +++ b/src/test/ui/dropck/dropck-eyepatch-reorder.rs @@ -1,14 +1,4 @@ -// The behavior of AST-borrowck and NLL explcitly differ here due to -// NLL's increased precision; so we use revisions and do not worry -// about the --compare-mode=nll on this test. - -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// ignore-compare-mode-nll - -#![feature(dropck_eyepatch, rustc_attrs)] +#![feature(dropck_eyepatch)] // The point of this test is to test uses of `#[may_dangle]` attribute // where the formal declaration order (in the impl generics) does not @@ -41,47 +31,70 @@ unsafe impl<'b, #[may_dangle] 'a, B: fmt::Debug> Drop for Pr<'a, 'b, B> { fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } } -fn main() { #![rustc_error] // rust-lang/rust#49855 +fn main() { use std::cell::Cell; - let c_long; - let (c, mut dt, mut dr, mut pt, mut pr, st, sr, c_shortest) - : (Cell<_>, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>, Cell<_>); - c_long = Cell::new(1); - c = Cell::new(1); - c_shortest = Cell::new(1); - - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long); - dr = Dr("dr", &c_long); - - // Error: destructor order imprecisely modelled - dt = Dt("dt", &c); - //[ast]~^ ERROR `c` does not live long enough - dr = Dr("dr", &c); - //[ast]~^ ERROR `c` does not live long enough - - // Error: `c_shortest` dies too soon for the references in dtors to be valid. - dt = Dt("dt", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - //[nll]~^^ ERROR `c_shortest` does not live long enough - dr = Dr("dr", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c_shortest, &c_long); - pr = Pr("pr", &c_shortest, &c_long); - - // Error: Drop impl's assertion does not apply to `B` nor `&'b _` - pt = Pt("pt", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - pr = Pr("pr", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - - // No error: St and Sr have no destructor. - st = St("st", &c_shortest); - sr = Sr("sr", &c_shortest); - - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); + + // We use separate blocks with separate variable to prevent the error + // messages from being deduplicated. + + { + let c_long; + let (mut dt, mut dr): (Dt<_>, Dr<_>); + c_long = Cell::new(1); + + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long); + dr = Dr("dr", &c_long); + } + + { + let (c, mut dt, mut dr): (Cell<_>, Dt<_>, Dr<_>); + c = Cell::new(1); + + // No Error: destructor order precisely modelled + dt = Dt("dt", &c); + dr = Dr("dr", &c); + } + + { + let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + c_shortest = Cell::new(1); + + // Error: `c_shortest` dies too soon for the references in dtors to be valid. + dt = Dt("dt", &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + dr = Dr("dr", &c_shortest); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c_shortest, &c_long); + pr = Pr("pr", &c_shortest, &c_long); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + // Error: Drop impl's assertion does not apply to `B` nor `&'b _` + pt = Pt("pt", &c_long, &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + pr = Pr("pr", &c_long, &c_shortest); + } + + { + let (st, sr, c_shortest): (St<_>, Sr<_>, Cell<_>); + c_shortest = Cell::new(1); + // No error: St and Sr have no destructor. + st = St("st", &c_shortest); + sr = Sr("sr", &c_shortest); + } } fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.stderr new file mode 100644 index 0000000000000..5055cdd8b2bf9 --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch-reorder.stderr @@ -0,0 +1,31 @@ +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:64:23 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:86:32 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `pt` is dropped and runs the `Drop` code for type `Pt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.ast.stderr b/src/test/ui/dropck/dropck-eyepatch.ast.stderr deleted file mode 100644 index 0952ed0d6b793..0000000000000 --- a/src/test/ui/dropck/dropck-eyepatch.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch.rs:81:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch.rs:83:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:87:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:90:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:98:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:100:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.nll.stderr b/src/test/ui/dropck/dropck-eyepatch.nll.stderr deleted file mode 100644 index 4a6e42ef94a85..0000000000000 --- a/src/test/ui/dropck/dropck-eyepatch.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:87:19 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c_shortest` dropped here while still borrowed - | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.rs b/src/test/ui/dropck/dropck-eyepatch.rs index fb1c03b678632..ec1c685613832 100644 --- a/src/test/ui/dropck/dropck-eyepatch.rs +++ b/src/test/ui/dropck/dropck-eyepatch.rs @@ -1,14 +1,4 @@ -// The behavior of AST-borrowck and NLL explcitly differ here due to -// NLL's increased precision; so we use revisions and do not worry -// about the --compare-mode=nll on this test. - -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// ignore-compare-mode-nll - -#![feature(dropck_eyepatch, rustc_attrs)] +#![feature(dropck_eyepatch)] // The point of this test is to illustrate that the `#[may_dangle]` // attribute specifically allows, in the context of a type @@ -64,48 +54,70 @@ unsafe impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> { fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } } -fn main() { #![rustc_error] // rust-lang/rust#49855 + +fn main() { use std::cell::Cell; - let c_long; - let (c, mut dt, mut dr, mut pt, mut pr, st, sr, c_shortest) - : (Cell<_>, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>, Cell<_>); - c_long = Cell::new(1); - c = Cell::new(1); - c_shortest = Cell::new(1); - - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long); - dr = Dr("dr", &c_long); - - // Error: destructor order imprecisely modelled - dt = Dt("dt", &c); - //[ast]~^ ERROR `c` does not live long enough - dr = Dr("dr", &c); - //[ast]~^ ERROR `c` does not live long enough - - // Error: `c_shortest` dies too soon for the references in dtors to be valid. - dt = Dt("dt", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - //[nll]~^^ ERROR `c_shortest` does not live long enough - dr = Dr("dr", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c_shortest, &c_long); - pr = Pr("pr", &c_shortest, &c_long); - - // Error: Drop impl's assertion does not apply to `B` nor `&'b _` - pt = Pt("pt", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - pr = Pr("pr", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - - // No error: St and Sr have no destructor. - st = St("st", &c_shortest); - sr = Sr("sr", &c_shortest); - - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); -} + // We use separate blocks with separate variable to prevent the error + // messages from being deduplicated. + + { + let c_long; + let (mut dt, mut dr): (Dt<_>, Dr<_>); + c_long = Cell::new(1); + + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long); + dr = Dr("dr", &c_long); + } + + { + let (c, mut dt, mut dr): (Cell<_>, Dt<_>, Dr<_>); + c = Cell::new(1); + + // No Error: destructor order precisely modelled + dt = Dt("dt", &c); + dr = Dr("dr", &c); + } + + { + let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + c_shortest = Cell::new(1); + + // Error: `c_shortest` dies too soon for the references in dtors to be valid. + dt = Dt("dt", &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + dr = Dr("dr", &c_shortest); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c_shortest, &c_long); + pr = Pr("pr", &c_shortest, &c_long); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + // Error: Drop impl's assertion does not apply to `B` nor `&'b _` + pt = Pt("pt", &c_long, &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + pr = Pr("pr", &c_long, &c_shortest); + } + + { + let (st, sr, c_shortest): (St<_>, Sr<_>, Cell<_>); + c_shortest = Cell::new(1); + // No error: St and Sr have no destructor. + st = St("st", &c_shortest); + sr = Sr("sr", &c_shortest); + } +} fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch.stderr b/src/test/ui/dropck/dropck-eyepatch.stderr new file mode 100644 index 0000000000000..21295e6c6019e --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch.stderr @@ -0,0 +1,31 @@ +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:88:23 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:110:32 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `pt` is dropped and runs the `Drop` code for type `Pt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-union.nll.stderr b/src/test/ui/dropck/dropck-union.nll.stderr deleted file mode 100644 index 667bb7221aacd..0000000000000 --- a/src/test/ui/dropck/dropck-union.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `v` does not live long enough - --> $DIR/dropck-union.rs:39:18 - | -LL | v.0.set(Some(&v)); //~ ERROR: `v` does not live long enough - | ^^ borrowed value does not live long enough -LL | } - | - - | | - | `v` dropped here while still borrowed - | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Wrap` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-union.stderr b/src/test/ui/dropck/dropck-union.stderr index 6cb3c139132f3..667bb7221aacd 100644 --- a/src/test/ui/dropck/dropck-union.stderr +++ b/src/test/ui/dropck/dropck-union.stderr @@ -1,12 +1,13 @@ error[E0597]: `v` does not live long enough - --> $DIR/dropck-union.rs:39:19 + --> $DIR/dropck-union.rs:39:18 | LL | v.0.set(Some(&v)); //~ ERROR: `v` does not live long enough - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } - | - `v` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `v` dropped here while still borrowed + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Wrap` error: aborting due to previous error diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr b/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr deleted file mode 100644 index 28b9656c6fd17..0000000000000 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr +++ /dev/null @@ -1,73 +0,0 @@ -error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:111:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` -LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o2` dropped here while still borrowed - -error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:112:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` -LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough -LL | o1.set1(&o3); //~ ERROR `o3` does not live long enough - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o3` dropped here while still borrowed - -error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:113:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` -... -LL | o2.set0(&o2); //~ ERROR `o2` does not live long enough - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o2` dropped here while still borrowed - -error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:114:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` -... -LL | o2.set1(&o3); //~ ERROR `o3` does not live long enough - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o3` dropped here while still borrowed - -error[E0597]: `o1` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:115:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o1` is borrowed for `'static` -... -LL | o3.set0(&o1); //~ ERROR `o1` does not live long enough - | ^^^ borrowed value does not live long enough -LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough -LL | } - | - `o1` dropped here while still borrowed - -error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:116:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` -... -LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough - | ^^^ borrowed value does not live long enough -LL | } - | - `o2` dropped here while still borrowed - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr index 0e4bd829a949d..28b9656c6fd17 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr @@ -1,67 +1,72 @@ error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:111:14 + --> $DIR/dropck_trait_cycle_checked.rs:111:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o2` dropped here while still borrowed error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:112:14 + --> $DIR/dropck_trait_cycle_checked.rs:112:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` +LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough LL | o1.set1(&o3); //~ ERROR `o3` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o3` dropped here while still borrowed error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:113:14 + --> $DIR/dropck_trait_cycle_checked.rs:113:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` +... LL | o2.set0(&o2); //~ ERROR `o2` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o2` dropped here while still borrowed error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:114:14 + --> $DIR/dropck_trait_cycle_checked.rs:114:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` +... LL | o2.set1(&o3); //~ ERROR `o3` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o3` dropped here while still borrowed error[E0597]: `o1` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:115:14 + --> $DIR/dropck_trait_cycle_checked.rs:115:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o1` is borrowed for `'static` +... LL | o3.set0(&o1); //~ ERROR `o1` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o1` dropped here while still borrowed error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:116:14 + --> $DIR/dropck_trait_cycle_checked.rs:116:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` +... LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o2` dropped here while still borrowed error: aborting due to 6 previous errors diff --git a/src/test/ui/dst/dst-bad-coerce3.nll.stderr b/src/test/ui/dst/dst-bad-coerce3.nll.stderr deleted file mode 100644 index 8f1289845e37b..0000000000000 --- a/src/test/ui/dst/dst-bad-coerce3.nll.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:16:32 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough - | ^^^ borrowed value does not live long enough -LL | let f3: &'a Fat<[isize]> = f2; - | ---------------- type annotation requires that `f1` is borrowed for `'a` -... -LL | } - | - `f1` dropped here while still borrowed - -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:21:25 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough - | ^^^ borrowed value does not live long enough -LL | let f3: &'a Fat = f2; - | ------------ type annotation requires that `f1` is borrowed for `'a` -... -LL | } - | - `f1` dropped here while still borrowed - -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:26:30 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough - | ^^^ borrowed value does not live long enough -LL | let f3: &'a ([isize],) = f2; - | -------------- type annotation requires that `f1` is borrowed for `'a` -... -LL | } - | - `f1` dropped here while still borrowed - -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:31:23 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough - | ^^^ borrowed value does not live long enough -LL | let f3: &'a (Bar,) = f2; - | ---------- type annotation requires that `f1` is borrowed for `'a` -LL | } - | - `f1` dropped here while still borrowed - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dst/dst-bad-coerce3.stderr b/src/test/ui/dst/dst-bad-coerce3.stderr index 701a869ee91e7..8f1289845e37b 100644 --- a/src/test/ui/dst/dst-bad-coerce3.stderr +++ b/src/test/ui/dst/dst-bad-coerce3.stderr @@ -1,62 +1,57 @@ error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:16:33 + --> $DIR/dst-bad-coerce3.rs:16:32 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough +LL | let f3: &'a Fat<[isize]> = f2; + | ---------------- type annotation requires that `f1` is borrowed for `'a` ... LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:8... - --> $DIR/dst-bad-coerce3.rs:13:8 - | -LL | fn baz<'a>() { - | ^^ + | - `f1` dropped here while still borrowed error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:21:26 + --> $DIR/dst-bad-coerce3.rs:21:25 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough +LL | let f3: &'a Fat = f2; + | ------------ type annotation requires that `f1` is borrowed for `'a` ... LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:8... - --> $DIR/dst-bad-coerce3.rs:13:8 - | -LL | fn baz<'a>() { - | ^^ + | - `f1` dropped here while still borrowed error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:26:31 + --> $DIR/dst-bad-coerce3.rs:26:30 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough +LL | let f3: &'a ([isize],) = f2; + | -------------- type annotation requires that `f1` is borrowed for `'a` ... LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:8... - --> $DIR/dst-bad-coerce3.rs:13:8 - | -LL | fn baz<'a>() { - | ^^ + | - `f1` dropped here while still borrowed error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:31:24 + --> $DIR/dst-bad-coerce3.rs:31:23 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | let f3: &'a (Bar,) = f2; + | ---------- type annotation requires that `f1` is borrowed for `'a` LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:8... - --> $DIR/dst-bad-coerce3.rs:13:8 - | -LL | fn baz<'a>() { - | ^^ + | - `f1` dropped here while still borrowed error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-index.nll.stderr b/src/test/ui/dst/dst-index.nll.stderr deleted file mode 100644 index 92e3d2b684a68..0000000000000 --- a/src/test/ui/dst/dst-index.nll.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0161]: cannot move a value of type str: the size of str cannot be statically determined - --> $DIR/dst-index.rs:31:5 - | -LL | S[0]; - | ^^^^ - -error[E0161]: cannot move a value of type dyn std::fmt::Debug: the size of dyn std::fmt::Debug cannot be statically determined - --> $DIR/dst-index.rs:34:5 - | -LL | T[0]; - | ^^^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/dst-index.rs:31:5 - | -LL | S[0]; - | ^^^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/dst-index.rs:34:5 - | -LL | T[0]; - | ^^^^ cannot move out of borrowed content - -error: aborting due to 4 previous errors - -Some errors occurred: E0161, E0507. -For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/dst/dst-index.rs b/src/test/ui/dst/dst-index.rs index 663c704ff39ac..71ff067bbd9dc 100644 --- a/src/test/ui/dst/dst-index.rs +++ b/src/test/ui/dst/dst-index.rs @@ -29,9 +29,9 @@ impl Index for T { fn main() { S[0]; - //~^ ERROR cannot move out of indexed content + //~^ ERROR cannot move out of borrowed content //~^^ ERROR E0161 T[0]; - //~^ ERROR cannot move out of indexed content + //~^ ERROR cannot move out of borrowed content //~^^ ERROR E0161 } diff --git a/src/test/ui/dst/dst-index.stderr b/src/test/ui/dst/dst-index.stderr index 05993f50fa1a5..92e3d2b684a68 100644 --- a/src/test/ui/dst/dst-index.stderr +++ b/src/test/ui/dst/dst-index.stderr @@ -4,23 +4,23 @@ error[E0161]: cannot move a value of type str: the size of str cannot be statica LL | S[0]; | ^^^^ -error[E0161]: cannot move a value of type (dyn std::fmt::Debug + 'static): the size of (dyn std::fmt::Debug + 'static) cannot be statically determined +error[E0161]: cannot move a value of type dyn std::fmt::Debug: the size of dyn std::fmt::Debug cannot be statically determined --> $DIR/dst-index.rs:34:5 | LL | T[0]; | ^^^^ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/dst-index.rs:31:5 | LL | S[0]; - | ^^^^ cannot move out of indexed content + | ^^^^ cannot move out of borrowed content -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/dst-index.rs:34:5 | LL | T[0]; - | ^^^^ cannot move out of indexed content + | ^^^^ cannot move out of borrowed content error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-rvalue.nll.stderr b/src/test/ui/dst/dst-rvalue.nll.stderr deleted file mode 100644 index d0d8f79395971..0000000000000 --- a/src/test/ui/dst/dst-rvalue.nll.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0161]: cannot move a value of type str: the size of str cannot be statically determined - --> $DIR/dst-rvalue.rs:6:28 - | -LL | let _x: Box = box *"hello world"; - | ^^^^^^^^^^^^^^ - -error[E0161]: cannot move a value of type [isize]: the size of [isize] cannot be statically determined - --> $DIR/dst-rvalue.rs:11:32 - | -LL | let _x: Box<[isize]> = box *array; - | ^^^^^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/dst-rvalue.rs:6:28 - | -LL | let _x: Box = box *"hello world"; - | ^^^^^^^^^^^^^^ cannot move out of borrowed content - -error[E0508]: cannot move out of type `[isize]`, a non-copy slice - --> $DIR/dst-rvalue.rs:11:32 - | -LL | let _x: Box<[isize]> = box *array; - | ^^^^^^ cannot move out of here - -error: aborting due to 4 previous errors - -Some errors occurred: E0161, E0507, E0508. -For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/dst/dst-rvalue.rs b/src/test/ui/dst/dst-rvalue.rs index 86747dad00ddb..5115bee836bc4 100644 --- a/src/test/ui/dst/dst-rvalue.rs +++ b/src/test/ui/dst/dst-rvalue.rs @@ -10,5 +10,5 @@ pub fn main() { let array: &[isize] = &[1, 2, 3]; let _x: Box<[isize]> = box *array; //~^ ERROR E0161 - //~^^ ERROR cannot move out of borrowed content + //~^^ ERROR cannot move out of type `[isize]`, a non-copy slice } diff --git a/src/test/ui/dst/dst-rvalue.stderr b/src/test/ui/dst/dst-rvalue.stderr index 2c92f5dcbf547..d0d8f79395971 100644 --- a/src/test/ui/dst/dst-rvalue.stderr +++ b/src/test/ui/dst/dst-rvalue.stderr @@ -16,13 +16,13 @@ error[E0507]: cannot move out of borrowed content LL | let _x: Box = box *"hello world"; | ^^^^^^^^^^^^^^ cannot move out of borrowed content -error[E0507]: cannot move out of borrowed content +error[E0508]: cannot move out of type `[isize]`, a non-copy slice --> $DIR/dst-rvalue.rs:11:32 | LL | let _x: Box<[isize]> = box *array; - | ^^^^^^ cannot move out of borrowed content + | ^^^^^^ cannot move out of here error: aborting due to 4 previous errors -Some errors occurred: E0161, E0507. +Some errors occurred: E0161, E0507, E0508. For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/error-codes/E0008.nll.stderr b/src/test/ui/error-codes/E0008.nll.stderr deleted file mode 100644 index 2505c03a148af..0000000000000 --- a/src/test/ui/error-codes/E0008.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/E0008.rs:3:14 - | -LL | Some(s) if s.len() == 0 => {}, - | ^ moves value into pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/error-codes/E0008.stderr b/src/test/ui/error-codes/E0008.stderr index d5c44efd667ee..2505c03a148af 100644 --- a/src/test/ui/error-codes/E0008.stderr +++ b/src/test/ui/error-codes/E0008.stderr @@ -3,6 +3,8 @@ error[E0008]: cannot bind by-move into a pattern guard | LL | Some(s) if s.len() == 0 => {}, | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0017.nll.stderr b/src/test/ui/error-codes/E0017.nll.stderr deleted file mode 100644 index 0477f06010b02..0000000000000 --- a/src/test/ui/error-codes/E0017.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0017]: references in constants may only refer to immutable values - --> $DIR/E0017.rs:4:30 - | -LL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ constants require immutable values - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error: cannot mutate statics in the initializer of another static - --> $DIR/E0017.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ - -error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/E0017.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ cannot borrow as mutable - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:8:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error: aborting due to 5 previous errors - -Some errors occurred: E0017, E0596. -For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr index cc202ec912e96..0477f06010b02 100644 --- a/src/test/ui/error-codes/E0017.stderr +++ b/src/test/ui/error-codes/E0017.stderr @@ -16,11 +16,11 @@ error: cannot mutate statics in the initializer of another static LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 | ^^^^^^ -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/E0017.rs:5:44 +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/E0017.rs:5:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^ + | ^^^^^^ cannot borrow as mutable error[E0017]: references in statics may only refer to immutable values --> $DIR/E0017.rs:8:38 diff --git a/src/test/ui/error-codes/E0161.ast.stderr b/src/test/ui/error-codes/E0161.migrate.stderr similarity index 100% rename from src/test/ui/error-codes/E0161.ast.stderr rename to src/test/ui/error-codes/E0161.migrate.stderr diff --git a/src/test/ui/error-codes/E0161.astul.stderr b/src/test/ui/error-codes/E0161.migrateul.stderr similarity index 100% rename from src/test/ui/error-codes/E0161.astul.stderr rename to src/test/ui/error-codes/E0161.migrateul.stderr diff --git a/src/test/ui/error-codes/E0161.rs b/src/test/ui/error-codes/E0161.rs index a6d2b245eb184..2ca17050ae2a4 100644 --- a/src/test/ui/error-codes/E0161.rs +++ b/src/test/ui/error-codes/E0161.rs @@ -3,15 +3,15 @@ // Check that E0161 is a hard error in all possible configurations that might // affect it. -// revisions: ast nll zflags edition astul nllul zflagsul editionul -//[zflags]compile-flags: -Z borrowck=migrate -Z two-phase-borrows +// revisions: migrate nll zflags edition migrateul nllul zflagsul editionul +//[zflags]compile-flags: -Z borrowck=migrate //[edition]edition:2018 -//[zflagsul]compile-flags: -Z borrowck=migrate -Z two-phase-borrows +//[zflagsul]compile-flags: -Z borrowck=migrate //[editionul]edition:2018 #![cfg_attr(nll, feature(nll))] #![cfg_attr(nllul, feature(nll))] -#![cfg_attr(astul, feature(unsized_locals))] +#![cfg_attr(migrateul, feature(unsized_locals))] #![cfg_attr(zflagsul, feature(unsized_locals))] #![cfg_attr(nllul, feature(unsized_locals))] #![cfg_attr(editionul, feature(unsized_locals))] @@ -20,11 +20,11 @@ fn foo(x: Box<[i32]>) { box *x; - //[ast]~^ ERROR E0161 + //[migrate]~^ ERROR E0161 //[nll]~^^ ERROR E0161 //[zflags]~^^^ ERROR E0161 //[edition]~^^^^ ERROR E0161 - //[astul]~^^^^^ ERROR E0161 + //[migrateul]~^^^^^ ERROR E0161 //[nllul]~^^^^^^ ERROR E0161 //[zflagsul]~^^^^^^^ ERROR E0161 //[editionul]~^^^^^^^^ ERROR E0161 diff --git a/src/test/ui/error-codes/E0161.stderr b/src/test/ui/error-codes/E0161.stderr deleted file mode 100644 index 0135e495c16b5..0000000000000 --- a/src/test/ui/error-codes/E0161.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0161]: cannot move a value of type str: the size of str cannot be statically determined - --> $DIR/E0161.rs:14:28 - | -LL | let _x: Box = box *"hello"; //~ ERROR E0161 - | ^^^^^^^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/E0161.rs:14:28 - | -LL | let _x: Box = box *"hello"; //~ ERROR E0161 - | ^^^^^^^^ cannot move out of borrowed content - -error: aborting due to 2 previous errors - -Some errors occurred: E0161, E0507. -For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/error-codes/E0301.nll.stderr b/src/test/ui/error-codes/E0301.nll.stderr deleted file mode 100644 index 898c30a75b28d..0000000000000 --- a/src/test/ui/error-codes/E0301.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0301]: cannot mutably borrow in a pattern guard - --> $DIR/E0301.rs:4:19 - | -LL | option if option.take().is_none() => {}, //~ ERROR E0301 - | ^^^^^^ borrowed mutably in pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0301`. diff --git a/src/test/ui/error-codes/E0301.stderr b/src/test/ui/error-codes/E0301.stderr index 3cfacd5983f0d..898c30a75b28d 100644 --- a/src/test/ui/error-codes/E0301.stderr +++ b/src/test/ui/error-codes/E0301.stderr @@ -3,6 +3,8 @@ error[E0301]: cannot mutably borrow in a pattern guard | LL | option if option.take().is_none() => {}, //~ ERROR E0301 | ^^^^^^ borrowed mutably in pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0388.nll.stderr b/src/test/ui/error-codes/E0388.nll.stderr deleted file mode 100644 index a898d60a98595..0000000000000 --- a/src/test/ui/error-codes/E0388.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0017]: references in constants may only refer to immutable values - --> $DIR/E0388.rs:4:30 - | -LL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ constants require immutable values - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error: cannot mutate statics in the initializer of another static - --> $DIR/E0388.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ - -error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/E0388.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ cannot borrow as mutable - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:8:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error: aborting due to 5 previous errors - -Some errors occurred: E0017, E0596. -For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr index f641830ae9ff2..a898d60a98595 100644 --- a/src/test/ui/error-codes/E0388.stderr +++ b/src/test/ui/error-codes/E0388.stderr @@ -16,11 +16,11 @@ error: cannot mutate statics in the initializer of another static LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 | ^^^^^^ -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/E0388.rs:5:44 +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/E0388.rs:5:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^ + | ^^^^^^ cannot borrow as mutable error[E0017]: references in statics may only refer to immutable values --> $DIR/E0388.rs:8:38 diff --git a/src/test/ui/error-codes/E0389.nll.stderr b/src/test/ui/error-codes/E0389.nll.stderr deleted file mode 100644 index 13d2f8cfaa59c..0000000000000 --- a/src/test/ui/error-codes/E0389.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference - --> $DIR/E0389.rs:8:5 - | -LL | let fancy_ref = &(&mut fancy); - | ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)` -LL | fancy_ref.num = 6; //~ ERROR E0389 - | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/error-codes/E0389.rs b/src/test/ui/error-codes/E0389.rs index 8b821330ebec2..9dab2c3092434 100644 --- a/src/test/ui/error-codes/E0389.rs +++ b/src/test/ui/error-codes/E0389.rs @@ -5,6 +5,6 @@ struct FancyNum { fn main() { let mut fancy = FancyNum{ num: 5 }; let fancy_ref = &(&mut fancy); - fancy_ref.num = 6; //~ ERROR E0389 + fancy_ref.num = 6; //~ ERROR cannot assign to `fancy_ref.num` which is behind a `&` reference println!("{}", fancy_ref.num); } diff --git a/src/test/ui/error-codes/E0389.stderr b/src/test/ui/error-codes/E0389.stderr index cc8914ef3a6f7..81ffed356e246 100644 --- a/src/test/ui/error-codes/E0389.stderr +++ b/src/test/ui/error-codes/E0389.stderr @@ -1,9 +1,11 @@ -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference --> $DIR/E0389.rs:8:5 | -LL | fancy_ref.num = 6; //~ ERROR E0389 - | ^^^^^^^^^^^^^^^^^ assignment into an immutable reference +LL | let fancy_ref = &(&mut fancy); + | ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)` +LL | fancy_ref.num = 6; //~ ERROR cannot assign to `fancy_ref.num` which is behind a `&` reference + | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/error-codes/E0499.nll.stderr b/src/test/ui/error-codes/E0499.nll.stderr deleted file mode 100644 index c1acef10e6e6a..0000000000000 --- a/src/test/ui/error-codes/E0499.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `i` as mutable more than once at a time - --> $DIR/E0499.rs:4:17 - | -LL | let mut x = &mut i; - | ------ first mutable borrow occurs here -LL | let mut a = &mut i; //~ ERROR E0499 - | ^^^^^^ second mutable borrow occurs here -LL | a.use_mut(); -LL | x.use_mut(); - | - first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/error-codes/E0499.stderr b/src/test/ui/error-codes/E0499.stderr index 92157e4eba6c4..c1acef10e6e6a 100644 --- a/src/test/ui/error-codes/E0499.stderr +++ b/src/test/ui/error-codes/E0499.stderr @@ -1,13 +1,13 @@ error[E0499]: cannot borrow `i` as mutable more than once at a time - --> $DIR/E0499.rs:4:22 + --> $DIR/E0499.rs:4:17 | LL | let mut x = &mut i; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | let mut a = &mut i; //~ ERROR E0499 - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^ second mutable borrow occurs here +LL | a.use_mut(); +LL | x.use_mut(); + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0502.nll.stderr b/src/test/ui/error-codes/E0502.nll.stderr deleted file mode 100644 index 64ca8f0e6b9a4..0000000000000 --- a/src/test/ui/error-codes/E0502.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `*a` as mutable because it is also borrowed as immutable - --> $DIR/E0502.rs:4:5 - | -LL | let ref y = a; - | ----- immutable borrow occurs here -LL | bar(a); //~ ERROR E0502 - | ^^^^^^ mutable borrow occurs here -LL | y.use_ref(); - | - immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/error-codes/E0502.stderr b/src/test/ui/error-codes/E0502.stderr index 9193886b00969..64ca8f0e6b9a4 100644 --- a/src/test/ui/error-codes/E0502.stderr +++ b/src/test/ui/error-codes/E0502.stderr @@ -1,13 +1,12 @@ -error[E0502]: cannot borrow `*a` as mutable because `a` is also borrowed as immutable - --> $DIR/E0502.rs:4:9 +error[E0502]: cannot borrow `*a` as mutable because it is also borrowed as immutable + --> $DIR/E0502.rs:4:5 | LL | let ref y = a; | ----- immutable borrow occurs here LL | bar(a); //~ ERROR E0502 - | ^ mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); -LL | } - | - immutable borrow ends here + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0503.nll.stderr b/src/test/ui/error-codes/E0503.nll.stderr deleted file mode 100644 index 7b483a5eaa585..0000000000000 --- a/src/test/ui/error-codes/E0503.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0503]: cannot use `value` because it was mutably borrowed - --> $DIR/E0503.rs:4:16 - | -LL | let _borrow = &mut value; - | ---------- borrow of `value` occurs here -LL | let _sum = value + 1; //~ ERROR E0503 - | ^^^^^ use of borrowed `value` -LL | _borrow.use_mut(); - | ------- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/error-codes/E0503.stderr b/src/test/ui/error-codes/E0503.stderr index 83391146b602d..7b483a5eaa585 100644 --- a/src/test/ui/error-codes/E0503.stderr +++ b/src/test/ui/error-codes/E0503.stderr @@ -2,9 +2,11 @@ error[E0503]: cannot use `value` because it was mutably borrowed --> $DIR/E0503.rs:4:16 | LL | let _borrow = &mut value; - | ----- borrow of `value` occurs here + | ---------- borrow of `value` occurs here LL | let _sum = value + 1; //~ ERROR E0503 | ^^^^^ use of borrowed `value` +LL | _borrow.use_mut(); + | ------- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0504.nll.stderr b/src/test/ui/error-codes/E0504.nll.stderr deleted file mode 100644 index 8d7387e86e524..0000000000000 --- a/src/test/ui/error-codes/E0504.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0505]: cannot move out of `fancy_num` because it is borrowed - --> $DIR/E0504.rs:9:13 - | -LL | let fancy_ref = &fancy_num; - | ---------- borrow of `fancy_num` occurs here -LL | -LL | let x = move || { - | ^^^^^^^ move out of `fancy_num` occurs here -LL | println!("child function: {}", fancy_num.num); //~ ERROR E0504 - | --------- move occurs due to use in closure -... -LL | println!("main function: {}", fancy_ref.num); - | ------------- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/error-codes/E0504.rs b/src/test/ui/error-codes/E0504.rs index 06ae0848b7c88..c2658bef61975 100644 --- a/src/test/ui/error-codes/E0504.rs +++ b/src/test/ui/error-codes/E0504.rs @@ -6,8 +6,8 @@ fn main() { let fancy_num = FancyNum { num: 5 }; let fancy_ref = &fancy_num; - let x = move || { - println!("child function: {}", fancy_num.num); //~ ERROR E0504 + let x = move || { //~ ERROR E0505 + println!("child function: {}", fancy_num.num); }; x(); diff --git a/src/test/ui/error-codes/E0504.stderr b/src/test/ui/error-codes/E0504.stderr index 7f4a611c5d53f..bab9b5c04c818 100644 --- a/src/test/ui/error-codes/E0504.stderr +++ b/src/test/ui/error-codes/E0504.stderr @@ -1,12 +1,17 @@ -error[E0504]: cannot move `fancy_num` into closure because it is borrowed - --> $DIR/E0504.rs:10:40 +error[E0505]: cannot move out of `fancy_num` because it is borrowed + --> $DIR/E0504.rs:9:13 | LL | let fancy_ref = &fancy_num; - | --------- borrow of `fancy_num` occurs here + | ---------- borrow of `fancy_num` occurs here +LL | +LL | let x = move || { //~ ERROR E0505 + | ^^^^^^^ move out of `fancy_num` occurs here +LL | println!("child function: {}", fancy_num.num); + | --------- move occurs due to use in closure ... -LL | println!("child function: {}", fancy_num.num); //~ ERROR E0504 - | ^^^^^^^^^ move into closure occurs here +LL | println!("main function: {}", fancy_ref.num); + | ------------- borrow later used here error: aborting due to previous error -For more information about this error, try `rustc --explain E0504`. +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/error-codes/E0505.nll.stderr b/src/test/ui/error-codes/E0505.nll.stderr deleted file mode 100644 index 181e5e33d29d7..0000000000000 --- a/src/test/ui/error-codes/E0505.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/E0505.rs:9:13 - | -LL | let _ref_to_val: &Value = &x; - | -- borrow of `x` occurs here -LL | eat(x); //~ ERROR E0505 - | ^ move out of `x` occurs here -LL | _ref_to_val.use_ref(); - | ----------- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/error-codes/E0505.stderr b/src/test/ui/error-codes/E0505.stderr index 268eb88019220..181e5e33d29d7 100644 --- a/src/test/ui/error-codes/E0505.stderr +++ b/src/test/ui/error-codes/E0505.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/E0505.rs:9:13 | LL | let _ref_to_val: &Value = &x; - | - borrow of `x` occurs here + | -- borrow of `x` occurs here LL | eat(x); //~ ERROR E0505 | ^ move out of `x` occurs here +LL | _ref_to_val.use_ref(); + | ----------- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0509.nll.stderr b/src/test/ui/error-codes/E0509.nll.stderr deleted file mode 100644 index 0233c7d6d1651..0000000000000 --- a/src/test/ui/error-codes/E0509.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0509]: cannot move out of type `DropStruct`, which implements the `Drop` trait - --> $DIR/E0509.rs:16:23 - | -LL | let fancy_field = drop_struct.fancy; //~ ERROR E0509 - | ^^^^^^^^^^^^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&drop_struct.fancy` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/error-codes/E0509.stderr b/src/test/ui/error-codes/E0509.stderr index b1f256d2d9e33..0233c7d6d1651 100644 --- a/src/test/ui/error-codes/E0509.stderr +++ b/src/test/ui/error-codes/E0509.stderr @@ -5,7 +5,7 @@ LL | let fancy_field = drop_struct.fancy; //~ ERROR E0509 | ^^^^^^^^^^^^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&drop_struct.fancy` + | help: consider borrowing here: `&drop_struct.fancy` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0597.nll.stderr b/src/test/ui/error-codes/E0597.nll.stderr deleted file mode 100644 index 88a8a46930d2c..0000000000000 --- a/src/test/ui/error-codes/E0597.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/E0597.rs:8:16 - | -LL | x.x = Some(&y); - | ^^ borrowed value does not live long enough -LL | //~^ `y` does not live long enough [E0597] -LL | } - | - - | | - | `y` dropped here while still borrowed - | borrow might be used here, when `x` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/error-codes/E0597.stderr b/src/test/ui/error-codes/E0597.stderr index a5b0cc49d0c83..88a8a46930d2c 100644 --- a/src/test/ui/error-codes/E0597.stderr +++ b/src/test/ui/error-codes/E0597.stderr @@ -1,13 +1,16 @@ error[E0597]: `y` does not live long enough - --> $DIR/E0597.rs:8:17 + --> $DIR/E0597.rs:8:16 | LL | x.x = Some(&y); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | //~^ `y` does not live long enough [E0597] LL | } - | - `y` dropped here while still borrowed + | - + | | + | `y` dropped here while still borrowed + | borrow might be used here, when `x` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-nll.rs b/src/test/ui/feature-gates/feature-gate-nll.rs index 14c48fb48a09b..2cf6e4d52094e 100644 --- a/src/test/ui/feature-gates/feature-gate-nll.rs +++ b/src/test/ui/feature-gates/feature-gate-nll.rs @@ -1,18 +1,20 @@ -// This is a test checking that if you do not opt into NLL then you -// should not get the effects of NLL applied to the test. - -// Don't use 2018 edition, since that turns on NLL (migration mode). -// edition:2015 +// There isn't a great way to test feature(nll), since it just disables migrate +// mode and changes some error messages. We just test for migrate mode. // Don't use compare-mode=nll, since that turns on NLL. // ignore-compare-mode-nll +#![feature(rustc_attrs)] -#![allow(dead_code)] - -fn main() { - let mut x = 33; +#[rustc_error] +fn main() { //~ ERROR compilation successful + let mut x = (33, &0); - let p = &x; - x = 22; //~ ERROR cannot assign to `x` because it is borrowed [E0506] + let m = &mut x; + let p = &*x.1; + //~^ WARNING cannot borrow + //~| WARNING this error has been downgraded to a warning + //~| WARNING this warning will become a hard error in the future + m; } + diff --git a/src/test/ui/feature-gates/feature-gate-nll.stderr b/src/test/ui/feature-gates/feature-gate-nll.stderr index f7b431d19be7a..6559dd3c3963a 100644 --- a/src/test/ui/feature-gates/feature-gate-nll.stderr +++ b/src/test/ui/feature-gates/feature-gate-nll.stderr @@ -1,11 +1,29 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/feature-gate-nll.rs:17:5 +warning[E0502]: cannot borrow `*x.1` as immutable because it is also borrowed as mutable + --> $DIR/feature-gate-nll.rs:14:13 | -LL | let p = &x; - | - borrow of `x` occurs here -LL | x = 22; //~ ERROR cannot assign to `x` because it is borrowed [E0506] - | ^^^^^^ assignment to borrowed `x` occurs here +LL | let m = &mut x; + | ------ mutable borrow occurs here +LL | let p = &*x.1; + | ^^^^^ immutable borrow occurs here +... +LL | m; + | - mutable borrow later used here + | + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + +error: compilation successful + --> $DIR/feature-gate-nll.rs:10:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | let mut x = (33, &0); +LL | | +LL | | let m = &mut x; +... | +LL | | m; +LL | | } + | |_^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0506`. +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/fn/fn-closure-mutable-capture.nll.stderr b/src/test/ui/fn/fn-closure-mutable-capture.nll.stderr deleted file mode 100644 index f7ab56da8de97..0000000000000 --- a/src/test/ui/fn/fn-closure-mutable-capture.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/fn-closure-mutable-capture.rs:5:17 - | -LL | bar(move || x = 1); - | ^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/fn-closure-mutable-capture.rs:5:9 - | -LL | bar(move || x = 1); - | ^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/fn/fn-closure-mutable-capture.rs b/src/test/ui/fn/fn-closure-mutable-capture.rs index a37eceffb9dae..81376af091b45 100644 --- a/src/test/ui/fn/fn-closure-mutable-capture.rs +++ b/src/test/ui/fn/fn-closure-mutable-capture.rs @@ -3,8 +3,9 @@ pub fn bar(_f: F) {} pub fn foo() { let mut x = 0; bar(move || x = 1); - //~^ ERROR cannot assign to captured outer variable in an `Fn` closure - //~| NOTE `Fn` closures cannot capture their enclosing environment for modifications + //~^ ERROR cannot assign to `x`, as it is a captured variable in a `Fn` closure + //~| NOTE cannot assign + //~| HELP consider changing this to accept closures that implement `FnMut` } fn main() {} diff --git a/src/test/ui/fn/fn-closure-mutable-capture.stderr b/src/test/ui/fn/fn-closure-mutable-capture.stderr index 84a5989c28c09..f7ab56da8de97 100644 --- a/src/test/ui/fn/fn-closure-mutable-capture.stderr +++ b/src/test/ui/fn/fn-closure-mutable-capture.stderr @@ -1,11 +1,10 @@ -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/fn-closure-mutable-capture.rs:5:17 | LL | bar(move || x = 1); - | ^^^^^ + | ^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/fn-closure-mutable-capture.rs:5:9 | LL | bar(move || x = 1); diff --git a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.nll.stderr b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.nll.stderr deleted file mode 100644 index 67cca25ac0cac..0000000000000 --- a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0509]: cannot move out of type `A`, which implements the `Drop` trait - --> $DIR/functional-struct-update-noncopyable.rs:12:14 - | -LL | let _b = A { y: Arc::new(3), ..a }; //~ ERROR cannot move out of type `A` - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr index a3497c59a52b1..67cca25ac0cac 100644 --- a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr +++ b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr @@ -1,8 +1,8 @@ error[E0509]: cannot move out of type `A`, which implements the `Drop` trait - --> $DIR/functional-struct-update-noncopyable.rs:12:36 + --> $DIR/functional-struct-update-noncopyable.rs:12:14 | LL | let _b = A { y: Arc::new(3), ..a }; //~ ERROR cannot move out of type `A` - | ^ cannot move out of here + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here error: aborting due to previous error diff --git a/src/test/ui/generator/borrowing.nll.stderr b/src/test/ui/generator/borrowing.nll.stderr deleted file mode 100644 index 3c9221d28e74d..0000000000000 --- a/src/test/ui/generator/borrowing.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:9:33 - | -LL | Pin::new(&mut || yield &a).resume() - | ----------^ - | | | - | | borrowed value does not live long enough - | value captured here by generator - | a temporary with access to the borrow is created here ... -LL | //~^ ERROR: `a` does not live long enough -LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator - | | - | `a` dropped here while still borrowed - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:16:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generator/borrowing.stderr b/src/test/ui/generator/borrowing.stderr index 169e4a8561c1d..3c9221d28e74d 100644 --- a/src/test/ui/generator/borrowing.stderr +++ b/src/test/ui/generator/borrowing.stderr @@ -2,28 +2,32 @@ error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:9:33 | LL | Pin::new(&mut || yield &a).resume() - | -- ^ borrowed value does not live long enough - | | - | capture occurs here + | ----------^ + | | | + | | borrowed value does not live long enough + | value captured here by generator + | a temporary with access to the borrow is created here ... LL | //~^ ERROR: `a` does not live long enough LL | }; - | - borrowed value only lives until here -... -LL | } - | - borrowed value needs to live until here + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator + | | + | `a` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:16:20 | +LL | let _b = { + | -- borrow later stored here +LL | let a = 3; LL | || { - | -- capture occurs here + | -- value captured here by generator LL | yield &a | ^ borrowed value does not live long enough ... LL | }; - | - borrowed value only lives until here -LL | } - | - borrowed value needs to live until here + | - `a` dropped here while still borrowed error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/dropck.nll.stderr b/src/test/ui/generator/dropck.nll.stderr deleted file mode 100644 index a90a47fe9aa01..0000000000000 --- a/src/test/ui/generator/dropck.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0597]: `*cell` does not live long enough - --> $DIR/dropck.rs:10:40 - | -LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); - | ^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `*cell` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `ref_` does not live long enough - --> $DIR/dropck.rs:15:18 - | -LL | gen = || { - | -- value captured here by generator -LL | // but the generator can use it to drop a `Ref<'a, i32>`. -LL | let _d = ref_.take(); //~ ERROR `ref_` does not live long enough - | ^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `ref_` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generator/dropck.stderr b/src/test/ui/generator/dropck.stderr index fdaa5cfbae3e6..a90a47fe9aa01 100644 --- a/src/test/ui/generator/dropck.stderr +++ b/src/test/ui/generator/dropck.stderr @@ -5,23 +5,29 @@ LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); | ^^^^ borrowed value does not live long enough ... LL | } - | - `*cell` dropped here while still borrowed + | - + | | + | `*cell` dropped here while still borrowed + | borrow might be used here, when `gen` is dropped and runs the destructor for generator | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `ref_` does not live long enough --> $DIR/dropck.rs:15:18 | LL | gen = || { - | -- capture occurs here + | -- value captured here by generator LL | // but the generator can use it to drop a `Ref<'a, i32>`. LL | let _d = ref_.take(); //~ ERROR `ref_` does not live long enough | ^^^^ borrowed value does not live long enough ... LL | } - | - borrowed value dropped before borrower + | - + | | + | `ref_` dropped here while still borrowed + | borrow might be used here, when `gen` is dropped and runs the destructor for generator | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/generator-region-requirements.ast.stderr b/src/test/ui/generator/generator-region-requirements.migrate.stderr similarity index 100% rename from src/test/ui/generator/generator-region-requirements.ast.stderr rename to src/test/ui/generator/generator-region-requirements.migrate.stderr diff --git a/src/test/ui/generator/generator-region-requirements.rs b/src/test/ui/generator/generator-region-requirements.rs index 9738f6c3932ed..cd9abaae056c1 100644 --- a/src/test/ui/generator/generator-region-requirements.rs +++ b/src/test/ui/generator/generator-region-requirements.rs @@ -1,4 +1,4 @@ -// revisions: ast nll +// revisions: migrate nll // ignore-compare-mode-nll #![feature(generators, generator_trait)] @@ -15,7 +15,7 @@ fn dangle(x: &mut i32) -> &'static mut i32 { match Pin::new(&mut g).resume() { GeneratorState::Complete(c) => return c, //[nll]~^ ERROR explicit lifetime required -//[ast]~^^ ERROR explicit lifetime required +//[migrate]~^^ ERROR explicit lifetime required GeneratorState::Yielded(_) => (), } } diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr b/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr deleted file mode 100644 index 01eea627351fb..0000000000000 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0521]: borrowed data escapes outside of generator - --> $DIR/ref-escapes-but-not-over-yield.rs:11:9 - | -LL | let mut a = &3; - | ----- `a` is declared here, outside of the generator body -... -LL | a = &b; - | ^^^^-- - | | | - | | borrow is only valid in the generator body - | reference to `b` escapes the generator body here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.rs b/src/test/ui/generator/ref-escapes-but-not-over-yield.rs index 8c576581ad8dd..3856d8233bcc0 100644 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.rs +++ b/src/test/ui/generator/ref-escapes-but-not-over-yield.rs @@ -9,7 +9,7 @@ fn foo(x: &i32) { yield(); let b = 5; a = &b; - //~^ ERROR `b` does not live long enough + //~^ ERROR borrowed data escapes outside of generator }; } diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr b/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr index 29299b2405a00..01eea627351fb 100644 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr +++ b/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr @@ -1,14 +1,15 @@ -error[E0597]: `b` does not live long enough - --> $DIR/ref-escapes-but-not-over-yield.rs:11:14 +error[E0521]: borrowed data escapes outside of generator + --> $DIR/ref-escapes-but-not-over-yield.rs:11:9 | +LL | let mut a = &3; + | ----- `a` is declared here, outside of the generator body +... LL | a = &b; - | ^ borrowed value does not live long enough -LL | //~^ ERROR `b` does not live long enough -LL | }; - | - `b` dropped here while still borrowed -LL | } - | - borrowed value needs to live until here + | ^^^^-- + | | | + | | borrow is only valid in the generator body + | reference to `b` escapes the generator body here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generator/yield-in-args.nll.stderr b/src/test/ui/generator/yield-in-args.nll.stderr deleted file mode 100644 index f753daafa9741..0000000000000 --- a/src/test/ui/generator/yield-in-args.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-in-args.rs:8:13 - | -LL | foo(&b, yield); //~ ERROR - | ^^ ----- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/generator/yield-in-args.stderr b/src/test/ui/generator/yield-in-args.stderr index f53677b5312ed..f753daafa9741 100644 --- a/src/test/ui/generator/yield-in-args.stderr +++ b/src/test/ui/generator/yield-in-args.stderr @@ -1,8 +1,8 @@ error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-in-args.rs:8:14 + --> $DIR/yield-in-args.rs:8:13 | LL | foo(&b, yield); //~ ERROR - | ^ ----- possible yield occurs here + | ^^ ----- possible yield occurs here error: aborting due to previous error diff --git a/src/test/ui/generator/yield-while-iterating.nll.stderr b/src/test/ui/generator/yield-while-iterating.nll.stderr deleted file mode 100644 index 2dc12f843b220..0000000000000 --- a/src/test/ui/generator/yield-while-iterating.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-iterating.rs:13:18 - | -LL | for p in &x { //~ ERROR - | ^^ -LL | yield(); - | ------- possible yield occurs here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/yield-while-iterating.rs:58:20 - | -LL | let mut b = || { - | -- mutable borrow occurs here -LL | for p in &mut x { - | - first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x[0]); //~ ERROR - | ^ immutable borrow occurs here -LL | Pin::new(&mut b).resume(); - | ------ mutable borrow later used here - -error: aborting due to 2 previous errors - -Some errors occurred: E0502, E0626. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/generator/yield-while-iterating.stderr b/src/test/ui/generator/yield-while-iterating.stderr index 1e3e31470e9d6..2dc12f843b220 100644 --- a/src/test/ui/generator/yield-while-iterating.stderr +++ b/src/test/ui/generator/yield-while-iterating.stderr @@ -1,8 +1,8 @@ error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-iterating.rs:13:19 + --> $DIR/yield-while-iterating.rs:13:18 | LL | for p in &x { //~ ERROR - | ^ + | ^^ LL | yield(); | ------- possible yield occurs here @@ -12,13 +12,12 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as muta LL | let mut b = || { | -- mutable borrow occurs here LL | for p in &mut x { - | - previous borrow occurs due to use of `x` in closure + | - first borrow occurs due to use of `x` in generator ... LL | println!("{}", x[0]); //~ ERROR | ^ immutable borrow occurs here LL | Pin::new(&mut b).resume(); -LL | } - | - mutable borrow ends here + | ------ mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr b/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr deleted file mode 100644 index d0d6a98301e59..0000000000000 --- a/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access - --> $DIR/yield-while-ref-reborrowed.rs:36:20 - | -LL | let mut b = || { - | -- generator construction occurs here -LL | let a = &mut *x; - | - first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x); //~ ERROR - | ^ second borrow occurs here -LL | Pin::new(&mut b).resume(); - | ------ first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.stderr b/src/test/ui/generator/yield-while-ref-reborrowed.stderr index 5c9de279c02d8..d0d6a98301e59 100644 --- a/src/test/ui/generator/yield-while-ref-reborrowed.stderr +++ b/src/test/ui/generator/yield-while-ref-reborrowed.stderr @@ -2,15 +2,14 @@ error[E0501]: cannot borrow `x` as immutable because previous closure requires u --> $DIR/yield-while-ref-reborrowed.rs:36:20 | LL | let mut b = || { - | -- closure construction occurs here + | -- generator construction occurs here LL | let a = &mut *x; - | - previous borrow occurs due to use of `x` in closure + | - first borrow occurs due to use of `x` in generator ... LL | println!("{}", x); //~ ERROR - | ^ borrow occurs here + | ^ second borrow occurs here LL | Pin::new(&mut b).resume(); -LL | } - | - borrow from closure ends here + | ------ first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr b/src/test/ui/hashmap-iter-value-lifetime.nll.stderr deleted file mode 100644 index cff58af3775c4..0000000000000 --- a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-iter-value-lifetime.rs:7:5 - | -LL | let (_, thing) = my_stuff.iter().next().unwrap(); - | -------- immutable borrow occurs here -LL | -LL | my_stuff.clear(); //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | -LL | println!("{}", *thing); - | ------ immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/hashmap-iter-value-lifetime.stderr b/src/test/ui/hashmap-iter-value-lifetime.stderr index 99761dd1cd7f5..cff58af3775c4 100644 --- a/src/test/ui/hashmap-iter-value-lifetime.stderr +++ b/src/test/ui/hashmap-iter-value-lifetime.stderr @@ -5,10 +5,10 @@ LL | let (_, thing) = my_stuff.iter().next().unwrap(); | -------- immutable borrow occurs here LL | LL | my_stuff.clear(); //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | println!("{}", *thing); + | ------ immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hashmap-lifetimes.nll.stderr b/src/test/ui/hashmap-lifetimes.nll.stderr deleted file mode 100644 index 08b8e3e443a9b..0000000000000 --- a/src/test/ui/hashmap-lifetimes.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-lifetimes.rs:6:5 - | -LL | let mut it = my_stuff.iter(); - | -------- immutable borrow occurs here -LL | my_stuff.insert(1, 43); //~ ERROR cannot borrow - | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | it; - | -- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/hashmap-lifetimes.stderr b/src/test/ui/hashmap-lifetimes.stderr index 81b2304f38102..08b8e3e443a9b 100644 --- a/src/test/ui/hashmap-lifetimes.stderr +++ b/src/test/ui/hashmap-lifetimes.stderr @@ -4,10 +4,9 @@ error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as LL | let mut it = my_stuff.iter(); | -------- immutable borrow occurs here LL | my_stuff.insert(1, 43); //~ ERROR cannot borrow - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | it; -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr deleted file mode 100644 index 80ecc4741a2e8..0000000000000 --- a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/hrtb-debruijn-in-receiver.rs:17:5 - | -LL | foo.insert(); - | --- first mutable borrow occurs here -LL | foo.insert(); //~ ERROR cannot borrow - | ^^^ - | | - | second mutable borrow occurs here - | first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr index 85bff4ce7911f..80ecc4741a2e8 100644 --- a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr +++ b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr @@ -4,9 +4,10 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time LL | foo.insert(); | --- first mutable borrow occurs here LL | foo.insert(); //~ ERROR cannot borrow - | ^^^ second mutable borrow occurs here -LL | } - | - first borrow ends here + | ^^^ + | | + | second mutable borrow occurs here + | first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.stderr b/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.stderr deleted file mode 100644 index f6f9200a354d5..0000000000000 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/hrtb-identity-fn-borrows.rs:17:5 - | -LL | let y = f.call(&x); - | - borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign - | ^^^^^ assignment to borrowed `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.mir.stderr b/src/test/ui/hrtb/hrtb-identity-fn-borrows.mir.stderr deleted file mode 100644 index bbb95e8c8d440..0000000000000 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/hrtb-identity-fn-borrows.rs:17:5 - | -LL | let y = f.call(&x); - | -- borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign - | ^^^^^ assignment to borrowed `x` occurs here -... -LL | drop(y); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs b/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs index 35b39a9a69dd0..89fc4705a787f 100644 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs +++ b/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs @@ -1,9 +1,6 @@ // Test that the `'a` in the where clause correctly links the region // of the output to the region of the input. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - trait FnLike { fn call(&self, arg: A) -> R; } @@ -14,8 +11,7 @@ fn call_repeatedly(f: F) // Result is stored: cannot re-assign `x` let mut x = 3; let y = f.call(&x); - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = 5; //~ ERROR cannot assign to `x` because it is borrowed // Result is not stored: can re-assign `x` let mut x = 3; diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.nll.stderr b/src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr similarity index 76% rename from src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.nll.stderr rename to src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr index bbb95e8c8d440..faa8d11b31a43 100644 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.nll.stderr +++ b/src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr @@ -1,9 +1,9 @@ error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/hrtb-identity-fn-borrows.rs:17:5 + --> $DIR/hrtb-identity-fn-borrows.rs:14:5 | LL | let y = f.call(&x); | -- borrow of `x` occurs here -LL | x = 5; //[ast]~ ERROR cannot assign +LL | x = 5; //~ ERROR cannot assign to `x` because it is borrowed | ^^^^^ assignment to borrowed `x` occurs here ... LL | drop(y); diff --git a/src/test/ui/hygiene/fields-move.nll.stderr b/src/test/ui/hygiene/fields-move.nll.stderr deleted file mode 100644 index f72a52e2535d2..0000000000000 --- a/src/test/ui/hygiene/fields-move.nll.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:18:9 - | -LL | $foo.x //~ ERROR use of moved value: `foo.x` - | ^^^^^^ value used here after move -... -LL | assert_two_copies(copy_modern!(foo), foo.x); //~ ERROR use of moved value: `foo.x` - | ----- value moved here -LL | assert_two_copies(copy_legacy!(foo), foo.x); //~ ERROR use of moved value: `foo.x` - | ----------------- in this macro invocation - | - = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:28:42 - | -LL | $foo.x - | ------ value moved here -... -LL | assert_two_copies(copy_modern!(foo), foo.x); //~ ERROR use of moved value: `foo.x` - | ^^^^^ value used here after move - | - = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:29:42 - | -LL | $foo.x //~ ERROR use of moved value: `foo.x` - | ------ value moved here -... -LL | assert_two_copies(copy_legacy!(foo), foo.x); //~ ERROR use of moved value: `foo.x` - | ^^^^^ value used here after move - | - = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/hygiene/fields-move.stderr b/src/test/ui/hygiene/fields-move.stderr index a5eeadff4dc05..f72a52e2535d2 100644 --- a/src/test/ui/hygiene/fields-move.stderr +++ b/src/test/ui/hygiene/fields-move.stderr @@ -1,33 +1,32 @@ error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:28:42 + --> $DIR/fields-move.rs:18:9 | -LL | $foo.x - | ------ value moved here +LL | $foo.x //~ ERROR use of moved value: `foo.x` + | ^^^^^^ value used here after move ... LL | assert_two_copies(copy_modern!(foo), foo.x); //~ ERROR use of moved value: `foo.x` - | ^^^^^ value used here after move + | ----- value moved here +LL | assert_two_copies(copy_legacy!(foo), foo.x); //~ ERROR use of moved value: `foo.x` + | ----------------- in this macro invocation | = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:18:9 + --> $DIR/fields-move.rs:28:42 | LL | $foo.x | ------ value moved here ... -LL | $foo.x //~ ERROR use of moved value: `foo.x` - | ^^^^^^ value used here after move -... -LL | assert_two_copies(copy_legacy!(foo), foo.x); //~ ERROR use of moved value: `foo.x` - | ----------------- in this macro invocation +LL | assert_two_copies(copy_modern!(foo), foo.x); //~ ERROR use of moved value: `foo.x` + | ^^^^^ value used here after move | = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait error[E0382]: use of moved value: `foo.x` --> $DIR/fields-move.rs:29:42 | -LL | $foo.x - | ------ value moved here +LL | $foo.x //~ ERROR use of moved value: `foo.x` + | ------ value moved here ... LL | assert_two_copies(copy_legacy!(foo), foo.x); //~ ERROR use of moved value: `foo.x` | ^^^^^ value used here after move diff --git a/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr b/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr deleted file mode 100644 index fb90825c0d93d..0000000000000 --- a/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `s.0` as mutable more than once at a time - --> $DIR/fields-numeric-borrowck.rs:6:16 - | -LL | let borrow1 = &mut s.0; - | -------- first mutable borrow occurs here -LL | let S { 0: ref mut borrow2 } = s; - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | borrow1.use_mut(); - | ------- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/hygiene/fields-numeric-borrowck.stderr b/src/test/ui/hygiene/fields-numeric-borrowck.stderr index 11b5fd70aff9f..fb90825c0d93d 100644 --- a/src/test/ui/hygiene/fields-numeric-borrowck.stderr +++ b/src/test/ui/hygiene/fields-numeric-borrowck.stderr @@ -2,12 +2,12 @@ error[E0499]: cannot borrow `s.0` as mutable more than once at a time --> $DIR/fields-numeric-borrowck.rs:6:16 | LL | let borrow1 = &mut s.0; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let S { 0: ref mut borrow2 } = s; | ^^^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | borrow1.use_mut(); + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/immut-function-arguments.ast.nll.stderr b/src/test/ui/immut-function-arguments.ast.nll.stderr deleted file mode 100644 index f0163390ae000..0000000000000 --- a/src/test/ui/immut-function-arguments.ast.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0594]: cannot assign to `*y`, as `y` is not declared as mutable - --> $DIR/immut-function-arguments.rs:5:5 - | -LL | fn f(y: Box) { - | - help: consider changing this to be mutable: `mut y` -LL | *y = 5; //[ast]~ ERROR cannot assign - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `*q`, as `q` is not declared as mutable - --> $DIR/immut-function-arguments.rs:10:35 - | -LL | let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign - | - ^^^^^^ cannot assign - | | - | help: consider changing this to be mutable: `mut q` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/immut-function-arguments.ast.stderr b/src/test/ui/immut-function-arguments.ast.stderr deleted file mode 100644 index 1ffe569d8281a..0000000000000 --- a/src/test/ui/immut-function-arguments.ast.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0594]: cannot assign to immutable `Box` content `*y` - --> $DIR/immut-function-arguments.rs:5:5 - | -LL | fn f(y: Box) { - | - help: make this binding mutable: `mut y` -LL | *y = 5; //[ast]~ ERROR cannot assign - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to immutable `Box` content `*q` - --> $DIR/immut-function-arguments.rs:10:35 - | -LL | let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign - | - ^^^^^^ cannot borrow as mutable - | | - | help: make this binding mutable: `mut q` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/immut-function-arguments.rs b/src/test/ui/immut-function-arguments.rs index 2cc9c694ef198..242a33e8216d8 100644 --- a/src/test/ui/immut-function-arguments.rs +++ b/src/test/ui/immut-function-arguments.rs @@ -1,14 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn f(y: Box) { - *y = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign + *y = 5; //~ ERROR cannot assign } fn g() { - let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign + let _frob = |q: Box| { *q = 2; }; //~ ERROR cannot assign } fn main() {} diff --git a/src/test/ui/immut-function-arguments.mir.stderr b/src/test/ui/immut-function-arguments.stderr similarity index 71% rename from src/test/ui/immut-function-arguments.mir.stderr rename to src/test/ui/immut-function-arguments.stderr index f0163390ae000..015c0dac2e967 100644 --- a/src/test/ui/immut-function-arguments.mir.stderr +++ b/src/test/ui/immut-function-arguments.stderr @@ -1,15 +1,15 @@ error[E0594]: cannot assign to `*y`, as `y` is not declared as mutable - --> $DIR/immut-function-arguments.rs:5:5 + --> $DIR/immut-function-arguments.rs:2:5 | LL | fn f(y: Box) { | - help: consider changing this to be mutable: `mut y` -LL | *y = 5; //[ast]~ ERROR cannot assign +LL | *y = 5; //~ ERROR cannot assign | ^^^^^^ cannot assign error[E0594]: cannot assign to `*q`, as `q` is not declared as mutable - --> $DIR/immut-function-arguments.rs:10:35 + --> $DIR/immut-function-arguments.rs:6:35 | -LL | let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign +LL | let _frob = |q: Box| { *q = 2; }; //~ ERROR cannot assign | - ^^^^^^ cannot assign | | | help: consider changing this to be mutable: `mut q` diff --git a/src/test/ui/in-band-lifetimes/mut_while_borrow.nll.stderr b/src/test/ui/in-band-lifetimes/mut_while_borrow.nll.stderr deleted file mode 100644 index 3f5dbb850cc71..0000000000000 --- a/src/test/ui/in-band-lifetimes/mut_while_borrow.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/mut_while_borrow.rs:9:5 - | -LL | let r = foo(&p); - | -- borrow of `p` occurs here -LL | p += 1; //~ ERROR cannot assign to `p` because it is borrowed - | ^^^^^^ assignment to borrowed `p` occurs here -LL | println!("{}", r); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/in-band-lifetimes/mut_while_borrow.stderr b/src/test/ui/in-band-lifetimes/mut_while_borrow.stderr index e710986c7217b..3f5dbb850cc71 100644 --- a/src/test/ui/in-band-lifetimes/mut_while_borrow.stderr +++ b/src/test/ui/in-band-lifetimes/mut_while_borrow.stderr @@ -2,9 +2,11 @@ error[E0506]: cannot assign to `p` because it is borrowed --> $DIR/mut_while_borrow.rs:9:5 | LL | let r = foo(&p); - | - borrow of `p` occurs here + | -- borrow of `p` occurs here LL | p += 1; //~ ERROR cannot assign to `p` because it is borrowed | ^^^^^^ assignment to borrowed `p` occurs here +LL | println!("{}", r); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issue-55511.nll.stderr b/src/test/ui/issue-55511.nll.stderr deleted file mode 100644 index bf3e58e8cdb19..0000000000000 --- a/src/test/ui/issue-55511.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/issue-55511.rs:13:28 - | -LL | let b = Some(Cell::new(&a)); - | ^^ borrowed value does not live long enough -... -LL | <() as Foo<'static>>::C => { } - | ----------------------- type annotation requires that `a` is borrowed for `'static` -... -LL | } - | - `a` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issue-55511.stderr b/src/test/ui/issue-55511.stderr index 24668f045517a..bf3e58e8cdb19 100644 --- a/src/test/ui/issue-55511.stderr +++ b/src/test/ui/issue-55511.stderr @@ -1,13 +1,14 @@ error[E0597]: `a` does not live long enough - --> $DIR/issue-55511.rs:13:29 + --> $DIR/issue-55511.rs:13:28 | LL | let b = Some(Cell::new(&a)); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough +... +LL | <() as Foo<'static>>::C => { } + | ----------------------- type annotation requires that `a` is borrowed for `'static` ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `a` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/issues/issue-10398.nll.stderr b/src/test/ui/issues/issue-10398.nll.stderr deleted file mode 100644 index f5f4974265b9a..0000000000000 --- a/src/test/ui/issues/issue-10398.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/issue-10398.rs:7:14 - | -LL | let _a = x; - | - value moved here -LL | drop(x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-10398.stderr b/src/test/ui/issues/issue-10398.stderr index ceb2cfe2b75af..f5f4974265b9a 100644 --- a/src/test/ui/issues/issue-10398.stderr +++ b/src/test/ui/issues/issue-10398.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/issue-10398.rs:7:14 | LL | let _a = x; - | -- value moved here + | - value moved here LL | drop(x); | ^ value used here after move | diff --git a/src/test/ui/issues/issue-11192.nll.stderr b/src/test/ui/issues/issue-11192.nll.stderr deleted file mode 100644 index 2a9d913171c3e..0000000000000 --- a/src/test/ui/issues/issue-11192.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable - --> $DIR/issue-11192.rs:20:10 - | -LL | let mut test = |foo: &Foo| { - | ----------- mutable borrow occurs here -LL | println!("access {}", foo.x); -LL | ptr = box Foo { x: ptr.x + 1 }; - | --- first borrow occurs due to use of `ptr` in closure -... -LL | test(&*ptr); - | ---- ^^^^^ immutable borrow occurs here - | | - | mutable borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/issues/issue-11192.stderr b/src/test/ui/issues/issue-11192.stderr index 37ae73685b4f2..2a9d913171c3e 100644 --- a/src/test/ui/issues/issue-11192.stderr +++ b/src/test/ui/issues/issue-11192.stderr @@ -1,17 +1,16 @@ -error[E0502]: cannot borrow `*ptr` as immutable because `ptr` is also borrowed as mutable - --> $DIR/issue-11192.rs:20:11 +error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable + --> $DIR/issue-11192.rs:20:10 | LL | let mut test = |foo: &Foo| { | ----------- mutable borrow occurs here LL | println!("access {}", foo.x); LL | ptr = box Foo { x: ptr.x + 1 }; - | --- previous borrow occurs due to use of `ptr` in closure + | --- first borrow occurs due to use of `ptr` in closure ... LL | test(&*ptr); - | ^^^^ immutable borrow occurs here -LL | //~^ ERROR: cannot borrow `*ptr` as immutable -LL | } - | - mutable borrow ends here + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/issues/issue-11493.ast.stderr b/src/test/ui/issues/issue-11493.ast.stderr deleted file mode 100644 index a5f8aefd194b0..0000000000000 --- a/src/test/ui/issues/issue-11493.ast.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: borrowed value does not live long enough (Ast) - --> $DIR/issue-11493.rs:10:35 - | -LL | let y = x.as_ref().unwrap_or(&id(5)); - | ^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here - | - = note: consider using a `let` binding to increase its lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-11493.mir.stderr b/src/test/ui/issues/issue-11493.mir.stderr deleted file mode 100644 index a5f8aefd194b0..0000000000000 --- a/src/test/ui/issues/issue-11493.mir.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: borrowed value does not live long enough (Ast) - --> $DIR/issue-11493.rs:10:35 - | -LL | let y = x.as_ref().unwrap_or(&id(5)); - | ^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here - | - = note: consider using a `let` binding to increase its lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-11493.rs b/src/test/ui/issues/issue-11493.rs index 4fdc32b42c2e9..b28c173b19b71 100644 --- a/src/test/ui/issues/issue-11493.rs +++ b/src/test/ui/issues/issue-11493.rs @@ -1,14 +1,7 @@ -// This file must never have a trailing newline -// -// revisions: ast mir -// compile-flags: -Z borrowck=compare - fn id(x: T) -> T { x } fn main() { let x = Some(3); - let y = x.as_ref().unwrap_or(&id(5)); - //[ast]~^ ERROR borrowed value does not live long enough (Ast) - //[mir]~^^ ERROR borrowed value does not live long enough (Ast) - // This actually passes in mir + let y = x.as_ref().unwrap_or(&id(5)); //~ ERROR + &y; } diff --git a/src/test/ui/issues/issue-11493.stderr b/src/test/ui/issues/issue-11493.stderr new file mode 100644 index 0000000000000..035fe4c20c7b8 --- /dev/null +++ b/src/test/ui/issues/issue-11493.stderr @@ -0,0 +1,15 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/issue-11493.rs:5:35 + | +LL | let y = x.as_ref().unwrap_or(&id(5)); //~ ERROR + | ^^^^^ - temporary value is freed at the end of this statement + | | + | creates a temporary which is freed while still in use +LL | &y; + | -- borrow later used here + | + = note: consider using a `let` binding to create a longer lived value + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-11681.nll.stderr b/src/test/ui/issues/issue-11681.nll.stderr deleted file mode 100644 index a3c71ffe95a8a..0000000000000 --- a/src/test/ui/issues/issue-11681.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-11681.rs:13:10 - | -LL | let testValue = &Test; //~ ERROR borrowed value does not live long enough - | ---- temporary value created here -LL | return testValue; - | ^^^^^^^^^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-11681.rs b/src/test/ui/issues/issue-11681.rs index 8294ca6b22e2e..6d8810d805200 100644 --- a/src/test/ui/issues/issue-11681.rs +++ b/src/test/ui/issues/issue-11681.rs @@ -9,8 +9,8 @@ impl Drop for Test { } fn createTest<'a>() -> &'a Test { - let testValue = &Test; //~ ERROR borrowed value does not live long enough - return testValue; + let testValue = &Test; + return testValue; //~ ERROR cannot return value referencing temporary value } diff --git a/src/test/ui/issues/issue-11681.stderr b/src/test/ui/issues/issue-11681.stderr index 210c6dc5a00b6..ce39a85aa21af 100644 --- a/src/test/ui/issues/issue-11681.stderr +++ b/src/test/ui/issues/issue-11681.stderr @@ -1,18 +1,11 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-11681.rs:12:20 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-11681.rs:13:10 | -LL | let testValue = &Test; //~ ERROR borrowed value does not live long enough - | ^^^^ temporary value does not live long enough -LL | return testValue; -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 11:15... - --> $DIR/issue-11681.rs:11:15 - | -LL | fn createTest<'a>() -> &'a Test { - | ^^ +LL | let testValue = &Test; + | ---- temporary value created here +LL | return testValue; //~ ERROR cannot return value referencing temporary value + | ^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-11873.nll.stderr b/src/test/ui/issues/issue-11873.nll.stderr deleted file mode 100644 index e5abf07420233..0000000000000 --- a/src/test/ui/issues/issue-11873.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/issue-11873.rs:4:14 - | -LL | let mut f = || v.push(2); - | -- - borrow occurs due to use in closure - | | - | borrow of `v` occurs here -LL | let _w = v; //~ ERROR: cannot move out of `v` - | ^ move out of `v` occurs here -LL | -LL | f(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/issues/issue-11873.stderr b/src/test/ui/issues/issue-11873.stderr index 1e44754c707d7..e5abf07420233 100644 --- a/src/test/ui/issues/issue-11873.stderr +++ b/src/test/ui/issues/issue-11873.stderr @@ -1,10 +1,15 @@ error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/issue-11873.rs:4:9 + --> $DIR/issue-11873.rs:4:14 | LL | let mut f = || v.push(2); - | -- borrow of `v` occurs here + | -- - borrow occurs due to use in closure + | | + | borrow of `v` occurs here LL | let _w = v; //~ ERROR: cannot move out of `v` - | ^^ move out of `v` occurs here + | ^ move out of `v` occurs here +LL | +LL | f(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-12041.nll.stderr b/src/test/ui/issues/issue-12041.nll.stderr deleted file mode 100644 index d95cc89ce99ad..0000000000000 --- a/src/test/ui/issues/issue-12041.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0382]: use of moved value: `tx` - --> $DIR/issue-12041.rs:8:22 - | -LL | let tx = tx; - | ^^ value moved here, in previous iteration of loop - | - = note: move occurs because `tx` has type `std::sync::mpsc::Sender`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-12041.stderr b/src/test/ui/issues/issue-12041.stderr index 48544c073efcf..d95cc89ce99ad 100644 --- a/src/test/ui/issues/issue-12041.stderr +++ b/src/test/ui/issues/issue-12041.stderr @@ -1,8 +1,8 @@ error[E0382]: use of moved value: `tx` - --> $DIR/issue-12041.rs:8:17 + --> $DIR/issue-12041.rs:8:22 | LL | let tx = tx; - | ^^ value moved here in previous iteration of loop + | ^^ value moved here, in previous iteration of loop | = note: move occurs because `tx` has type `std::sync::mpsc::Sender`, which does not implement the `Copy` trait diff --git a/src/test/ui/issues/issue-12470.nll.stderr b/src/test/ui/issues/issue-12470.nll.stderr deleted file mode 100644 index 27878e7718bef..0000000000000 --- a/src/test/ui/issues/issue-12470.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing local data `*b` - --> $DIR/issue-12470.rs:29:5 - | -LL | let bb: &B = &*b; //~ ERROR does not live long enough - | --- `*b` is borrowed here -LL | make_a(bb) - | ^^^^^^^^^^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-12470.rs b/src/test/ui/issues/issue-12470.rs index acf1b764fd92c..77b78c8a1f723 100644 --- a/src/test/ui/issues/issue-12470.rs +++ b/src/test/ui/issues/issue-12470.rs @@ -25,8 +25,8 @@ fn make_a<'a>(p: &'a X) -> A<'a> { fn make_make_a<'a>() -> A<'a> { let b: Box = box B {i:1}; - let bb: &B = &*b; //~ ERROR does not live long enough - make_a(bb) + let bb: &B = &*b; + make_a(bb) //~ ERROR cannot return value referencing local data `*b` } fn main() { diff --git a/src/test/ui/issues/issue-12470.stderr b/src/test/ui/issues/issue-12470.stderr index 59056aaca9022..02bce348de4d7 100644 --- a/src/test/ui/issues/issue-12470.stderr +++ b/src/test/ui/issues/issue-12470.stderr @@ -1,18 +1,11 @@ -error[E0597]: `*b` does not live long enough - --> $DIR/issue-12470.rs:28:19 +error[E0515]: cannot return value referencing local data `*b` + --> $DIR/issue-12470.rs:29:5 | -LL | let bb: &B = &*b; //~ ERROR does not live long enough - | ^^ borrowed value does not live long enough -LL | make_a(bb) -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 26:16... - --> $DIR/issue-12470.rs:26:16 - | -LL | fn make_make_a<'a>() -> A<'a> { - | ^^ +LL | let bb: &B = &*b; + | --- `*b` is borrowed here +LL | make_a(bb) //~ ERROR cannot return value referencing local data `*b` + | ^^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-12567.nll.stderr b/src/test/ui/issues/issue-12567.nll.stderr deleted file mode 100644 index 17388df91d1f3..0000000000000 --- a/src/test/ui/issues/issue-12567.nll.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:4:11 - | -LL | match (l1, l2) { - | ^^^^^^^^ cannot move out of here -LL | (&[], &[]) => println!("both empty"), -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | -- data moved here -... -LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/issue-12567.rs:6:17 - | -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^^ -... -LL | (&[hd1, ..], &[hd2, ..]) - | ^^^ - -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:4:11 - | -LL | match (l1, l2) { - | ^^^^^^^^ cannot move out of here -LL | (&[], &[]) => println!("both empty"), -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | -- data moved here -... -LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/issue-12567.rs:6:17 - | -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^^ -... -LL | (&[hd1, ..], &[hd2, ..]) - | ^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/issues/issue-12567.rs b/src/test/ui/issues/issue-12567.rs index 1e1debe31ce6d..643d9a2fc69e9 100644 --- a/src/test/ui/issues/issue-12567.rs +++ b/src/test/ui/issues/issue-12567.rs @@ -2,15 +2,13 @@ fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) { match (l1, l2) { + //~^ ERROR: cannot move out of type `[T]`, a non-copy slice + //~| ERROR: cannot move out of type `[T]`, a non-copy slice (&[], &[]) => println!("both empty"), (&[], &[hd, ..]) | (&[hd, ..], &[]) => println!("one empty"), - //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice - //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice (&[hd1, ..], &[hd2, ..]) => println!("both nonempty"), - //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice - //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice } } diff --git a/src/test/ui/issues/issue-12567.stderr b/src/test/ui/issues/issue-12567.stderr index 15f723f1cee0f..1de29dc8c6108 100644 --- a/src/test/ui/issues/issue-12567.stderr +++ b/src/test/ui/issues/issue-12567.stderr @@ -1,39 +1,45 @@ error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:6:16 + --> $DIR/issue-12567.rs:4:11 | +LL | match (l1, l2) { + | ^^^^^^^^ cannot move out of here +... LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^--^^^^^ - | || - | |hint: to prevent move, use `ref hd` or `ref mut hd` - | cannot move out of here - -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:6:30 + | -- data moved here +LL | => println!("one empty"), +LL | (&[hd1, ..], &[hd2, ..]) + | --- ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/issue-12567.rs:8:17 | LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^--^^^^^ - | || - | |hint: to prevent move, use `ref hd` or `ref mut hd` - | cannot move out of here + | ^^ +LL | => println!("one empty"), +LL | (&[hd1, ..], &[hd2, ..]) + | ^^^ error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:10:11 + --> $DIR/issue-12567.rs:4:11 | +LL | match (l1, l2) { + | ^^^^^^^^ cannot move out of here +... +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | -- data moved here +LL | => println!("one empty"), LL | (&[hd1, ..], &[hd2, ..]) - | ^---^^^^^ - | || - | |hint: to prevent move, use `ref hd1` or `ref mut hd1` - | cannot move out of here - -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:10:23 + | --- ...and here | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/issue-12567.rs:8:17 + | +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | ^^ +LL | => println!("one empty"), LL | (&[hd1, ..], &[hd2, ..]) - | ^---^^^^^ - | || - | |hint: to prevent move, use `ref hd2` or `ref mut hd2` - | cannot move out of here + | ^^^ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/issues/issue-13497-2.nll.stderr b/src/test/ui/issues/issue-13497-2.nll.stderr deleted file mode 100644 index fb0d606690d04..0000000000000 --- a/src/test/ui/issues/issue-13497-2.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0515]: cannot return value referencing local variable `rawLines` - --> $DIR/issue-13497-2.rs:3:5 - | -LL | rawLines //~ ERROR `rawLines` does not live long enough - | ^------- - | | - | _____`rawLines` is borrowed here - | | -LL | | .iter().map(|l| l.trim()).collect() - | |___________________________________________^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-13497-2.rs b/src/test/ui/issues/issue-13497-2.rs index a39ae4f1cf33b..c82da0f0096ad 100644 --- a/src/test/ui/issues/issue-13497-2.rs +++ b/src/test/ui/issues/issue-13497-2.rs @@ -1,6 +1,6 @@ fn read_lines_borrowed<'a>() -> Vec<&'a str> { let rawLines: Vec = vec!["foo ".to_string(), " bar".to_string()]; - rawLines //~ ERROR `rawLines` does not live long enough + rawLines //~ ERROR cannot return value referencing local variable `rawLines` .iter().map(|l| l.trim()).collect() } diff --git a/src/test/ui/issues/issue-13497-2.stderr b/src/test/ui/issues/issue-13497-2.stderr index c91ab789fe8a8..f6acdd6af70d4 100644 --- a/src/test/ui/issues/issue-13497-2.stderr +++ b/src/test/ui/issues/issue-13497-2.stderr @@ -1,18 +1,14 @@ -error[E0597]: `rawLines` does not live long enough +error[E0515]: cannot return value referencing local variable `rawLines` --> $DIR/issue-13497-2.rs:3:5 | -LL | rawLines //~ ERROR `rawLines` does not live long enough - | ^^^^^^^^ borrowed value does not live long enough -LL | .iter().map(|l| l.trim()).collect() -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 1:24... - --> $DIR/issue-13497-2.rs:1:24 - | -LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { - | ^^ +LL | rawLines //~ ERROR cannot return value referencing local variable `rawLines` + | ^------- + | | + | _____`rawLines` is borrowed here + | | +LL | | .iter().map(|l| l.trim()).collect() + | |___________________________________________^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-17263.ast.stderr b/src/test/ui/issues/issue-17263.ast.stderr deleted file mode 100644 index 823f2c747d686..0000000000000 --- a/src/test/ui/issues/issue-17263.ast.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0499]: cannot borrow `x` (via `x.b`) as mutable more than once at a time - --> $DIR/issue-17263.rs:17:34 - | -LL | let (a, b) = (&mut x.a, &mut x.b); - | --- ^^^ second mutable borrow occurs here (via `x.b`) - | | - | first mutable borrow occurs here (via `x.a`) -... -LL | } - | - first borrow ends here - -error[E0502]: cannot borrow `foo` (via `foo.b`) as immutable because `foo` is also borrowed as mutable (via `foo.a`) - --> $DIR/issue-17263.rs:21:32 - | -LL | let (c, d) = (&mut foo.a, &foo.b); - | ----- ^^^^^ immutable borrow of `foo.b` -- which overlaps with `foo.a` -- occurs here - | | - | mutable borrow occurs here (via `foo.a`) -... -LL | } - | - mutable borrow ends here - -error: aborting due to 2 previous errors - -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/issues/issue-17263.nll.stderr b/src/test/ui/issues/issue-17263.nll.stderr deleted file mode 100644 index cdb574b8b9f94..0000000000000 --- a/src/test/ui/issues/issue-17263.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/issue-17263.rs:15:1 - | -LL | / fn main() { //[nll]~ ERROR compilation successful -LL | | let mut x: Box<_> = box Foo { a: 1, b: 2 }; -LL | | let (a, b) = (&mut x.a, &mut x.b); -LL | | //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time -... | -LL | | use_mut(a); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-17263.rs b/src/test/ui/issues/issue-17263.rs index 754f3b90aacf1..dce30275ff354 100644 --- a/src/test/ui/issues/issue-17263.rs +++ b/src/test/ui/issues/issue-17263.rs @@ -1,28 +1,18 @@ -// This checks diagnostic quality for cases where AST-borrowck treated -// `Box` as other types (see rust-lang/rfcs#130). NLL again treats -// `Box` specially. We capture the differences via revisions. +// compile-pass -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// don't worry about the --compare-mode=nll on this test. -// ignore-compare-mode-nll -#![feature(box_syntax, rustc_attrs)] +#![feature(box_syntax)] struct Foo { a: isize, b: isize } -#[rustc_error] // rust-lang/rust#49855 -fn main() { //[nll]~ ERROR compilation successful + +fn main() { let mut x: Box<_> = box Foo { a: 1, b: 2 }; let (a, b) = (&mut x.a, &mut x.b); - //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time let mut foo: Box<_> = box Foo { a: 1, b: 2 }; let (c, d) = (&mut foo.a, &foo.b); - //[ast]~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable - // We explicitly use the references created above to illustrate - // that NLL is accepting this code *not* because of artificially + // We explicitly use the references created above to illustrate that the + // borrow checker is accepting this code *not* because of artificially // short lifetimes, but rather because it understands that all the // references are of disjoint parts of memory. use_imm(d); diff --git a/src/test/ui/issues/issue-17385.nll.stderr b/src/test/ui/issues/issue-17385.nll.stderr deleted file mode 100644 index 20198f19dd5f5..0000000000000 --- a/src/test/ui/issues/issue-17385.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0382]: use of moved value: `foo` - --> $DIR/issue-17385.rs:19:11 - | -LL | let foo = X(1); - | --- move occurs because `foo` has type `X`, which does not implement the `Copy` trait -LL | drop(foo); - | --- value moved here -LL | match foo { //~ ERROR use of moved value -LL | X(1) => (), - | ^ value used here after move - -error[E0382]: use of moved value: `e` - --> $DIR/issue-17385.rs:25:11 - | -LL | let e = Enum::Variant2; - | - move occurs because `e` has type `Enum`, which does not implement the `Copy` trait -LL | drop(e); - | - value moved here -LL | match e { //~ ERROR use of moved value - | ^ value used here after move - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-17385.rs b/src/test/ui/issues/issue-17385.rs index 7400aadb059f7..93364d2f6259e 100644 --- a/src/test/ui/issues/issue-17385.rs +++ b/src/test/ui/issues/issue-17385.rs @@ -15,8 +15,8 @@ impl Drop for Enum { fn main() { let foo = X(1); drop(foo); - match foo { //~ ERROR use of moved value - X(1) => (), + match foo { + X(1) => (), //~ ERROR use of moved value _ => unreachable!() } diff --git a/src/test/ui/issues/issue-17385.stderr b/src/test/ui/issues/issue-17385.stderr index 5f28a3c2c2785..2919c1a51968e 100644 --- a/src/test/ui/issues/issue-17385.stderr +++ b/src/test/ui/issues/issue-17385.stderr @@ -1,22 +1,23 @@ error[E0382]: use of moved value: `foo` - --> $DIR/issue-17385.rs:18:11 + --> $DIR/issue-17385.rs:19:11 | +LL | let foo = X(1); + | --- move occurs because `foo` has type `X`, which does not implement the `Copy` trait LL | drop(foo); | --- value moved here -LL | match foo { //~ ERROR use of moved value - | ^^^ value used here after move - | - = note: move occurs because `foo` has type `X`, which does not implement the `Copy` trait +LL | match foo { +LL | X(1) => (), //~ ERROR use of moved value + | ^ value used here after move error[E0382]: use of moved value: `e` --> $DIR/issue-17385.rs:25:11 | +LL | let e = Enum::Variant2; + | - move occurs because `e` has type `Enum`, which does not implement the `Copy` trait LL | drop(e); | - value moved here LL | match e { //~ ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `e` has type `Enum`, which does not implement the `Copy` trait error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-17545.nll.stderr b/src/test/ui/issues/issue-17545.nll.stderr deleted file mode 100644 index 527f8df9ccbb8..0000000000000 --- a/src/test/ui/issues/issue-17545.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-17545.rs:7:10 - | -LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { - | -- lifetime `'a` defined here -LL | / bar.call(( -LL | | &id(()), //~ ERROR borrowed value does not live long enough - | | ^^^^^^ creates a temporary which is freed while still in use -LL | | )); - | | -- temporary value is freed at the end of this statement - | |______| - | argument requires that borrow lasts for `'a` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-17545.rs b/src/test/ui/issues/issue-17545.rs index d62c0b9f32cb9..ced6fff315f4a 100644 --- a/src/test/ui/issues/issue-17545.rs +++ b/src/test/ui/issues/issue-17545.rs @@ -4,7 +4,7 @@ fn id(x: T) -> T { x } pub fn foo<'a, F: Fn(&'a ())>(bar: F) { bar.call(( - &id(()), //~ ERROR borrowed value does not live long enough + &id(()), //~ ERROR temporary value dropped while borrowed )); } fn main() {} diff --git a/src/test/ui/issues/issue-17545.stderr b/src/test/ui/issues/issue-17545.stderr index 62ec25e1d1a4f..596f13c785a00 100644 --- a/src/test/ui/issues/issue-17545.stderr +++ b/src/test/ui/issues/issue-17545.stderr @@ -1,18 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-17545.rs:7:10 | -LL | &id(()), //~ ERROR borrowed value does not live long enough - | ^^^^^^ temporary value does not live long enough -LL | )); - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 5:12... - --> $DIR/issue-17545.rs:5:12 - | -LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { - | ^^ - = note: consider using a `let` binding to increase its lifetime +LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { + | -- lifetime `'a` defined here +LL | / bar.call(( +LL | | &id(()), //~ ERROR temporary value dropped while borrowed + | | ^^^^^^ creates a temporary which is freed while still in use +LL | | )); + | | -- temporary value is freed at the end of this statement + | |______| + | argument requires that borrow lasts for `'a` error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr b/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr deleted file mode 100644 index 8f3acae71391f..0000000000000 --- a/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/issue-17718-constants-not-static.rs:5:30 - | -LL | fn foo() -> &'static usize { &id(FOO) } - | ^------- - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-17718-constants-not-static.rs b/src/test/ui/issues/issue-17718-constants-not-static.rs index e857b906efa7b..2e6aff1618bfb 100644 --- a/src/test/ui/issues/issue-17718-constants-not-static.rs +++ b/src/test/ui/issues/issue-17718-constants-not-static.rs @@ -3,7 +3,7 @@ fn id(x: T) -> T { x } const FOO: usize = 3; fn foo() -> &'static usize { &id(FOO) } -//~^ ERROR: borrowed value does not live long enough +//~^ ERROR: cannot return reference to temporary value fn main() { } diff --git a/src/test/ui/issues/issue-17718-constants-not-static.stderr b/src/test/ui/issues/issue-17718-constants-not-static.stderr index 2a5b9d7222345..8f3acae71391f 100644 --- a/src/test/ui/issues/issue-17718-constants-not-static.stderr +++ b/src/test/ui/issues/issue-17718-constants-not-static.stderr @@ -1,13 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-17718-constants-not-static.rs:5:31 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-17718-constants-not-static.rs:5:30 | LL | fn foo() -> &'static usize { &id(FOO) } - | ^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | ^------- + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-17718-static-move.nll.stderr b/src/test/ui/issues/issue-17718-static-move.nll.stderr deleted file mode 100644 index 86e7a18491041..0000000000000 --- a/src/test/ui/issues/issue-17718-static-move.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of static item - --> $DIR/issue-17718-static-move.rs:6:14 - | -LL | let _a = FOO; //~ ERROR: cannot move out of static item - | ^^^ - | | - | cannot move out of static item - | help: consider borrowing here: `&FOO` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-17718-static-move.stderr b/src/test/ui/issues/issue-17718-static-move.stderr index dd473f0a4c457..86e7a18491041 100644 --- a/src/test/ui/issues/issue-17718-static-move.stderr +++ b/src/test/ui/issues/issue-17718-static-move.stderr @@ -5,7 +5,7 @@ LL | let _a = FOO; //~ ERROR: cannot move out of static item | ^^^ | | | cannot move out of static item - | help: consider using a reference instead: `&FOO` + | help: consider borrowing here: `&FOO` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-17954.nll.stderr b/src/test/ui/issues/issue-17954.nll.stderr deleted file mode 100644 index e08375fee1fe4..0000000000000 --- a/src/test/ui/issues/issue-17954.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0712]: thread-local variable borrowed past end of function - --> $DIR/issue-17954.rs:7:13 - | -LL | let a = &FOO; - | ^^^^ thread-local variables cannot be borrowed beyond the end of the function -... -LL | } - | - end of enclosing function is here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0712`. diff --git a/src/test/ui/issues/issue-17954.rs b/src/test/ui/issues/issue-17954.rs index a8fbf2372b06a..eb6a3d70f58e2 100644 --- a/src/test/ui/issues/issue-17954.rs +++ b/src/test/ui/issues/issue-17954.rs @@ -5,12 +5,11 @@ static FOO: u8 = 3; fn main() { let a = &FOO; - //~^ ERROR borrowed value does not live long enough - //~| does not live long enough - //~| NOTE borrowed value must be valid for the static lifetime + //~^ ERROR thread-local variable borrowed past end of function + //~| NOTE thread-local variables cannot be borrowed beyond the end of the function std::thread::spawn(move || { println!("{}", a); }); } -//~^ NOTE borrowed value only lives until here +//~^ NOTE end of enclosing function is here diff --git a/src/test/ui/issues/issue-17954.stderr b/src/test/ui/issues/issue-17954.stderr index 458bef5499236..e08375fee1fe4 100644 --- a/src/test/ui/issues/issue-17954.stderr +++ b/src/test/ui/issues/issue-17954.stderr @@ -1,14 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-17954.rs:7:14 +error[E0712]: thread-local variable borrowed past end of function + --> $DIR/issue-17954.rs:7:13 | LL | let a = &FOO; - | ^^^ borrowed value does not live long enough + | ^^^^ thread-local variables cannot be borrowed beyond the end of the function ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - end of enclosing function is here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0712`. diff --git a/src/test/ui/issues/issue-18118.nll.stderr b/src/test/ui/issues/issue-18118.nll.stderr deleted file mode 100644 index 1920e1637d149..0000000000000 --- a/src/test/ui/issues/issue-18118.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `p` does not live long enough - --> $DIR/issue-18118.rs:4:9 - | -LL | &p //~ ERROR `p` does not live long enough - | ^^ - | | - | borrowed value does not live long enough - | using this value as a constant requires that `p` is borrowed for `'static` -LL | }; - | - `p` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-18118.stderr b/src/test/ui/issues/issue-18118.stderr index 9b21ece341a9f..1920e1637d149 100644 --- a/src/test/ui/issues/issue-18118.stderr +++ b/src/test/ui/issues/issue-18118.stderr @@ -1,12 +1,13 @@ error[E0597]: `p` does not live long enough - --> $DIR/issue-18118.rs:4:10 + --> $DIR/issue-18118.rs:4:9 | LL | &p //~ ERROR `p` does not live long enough - | ^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | using this value as a constant requires that `p` is borrowed for `'static` LL | }; - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `p` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18566.nll.stderr b/src/test/ui/issues/issue-18566.nll.stderr deleted file mode 100644 index 8db78935f839c..0000000000000 --- a/src/test/ui/issues/issue-18566.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `*s` as mutable more than once at a time - --> $DIR/issue-18566.rs:23:19 - | -LL | MyPtr(s).poke(s); - | - ---- ^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/issues/issue-18566.stderr b/src/test/ui/issues/issue-18566.stderr index 90c3af48eb482..8db78935f839c 100644 --- a/src/test/ui/issues/issue-18566.stderr +++ b/src/test/ui/issues/issue-18566.stderr @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `*s` as mutable more than once at a time --> $DIR/issue-18566.rs:23:19 | LL | MyPtr(s).poke(s); - | - ^- first borrow ends here - | | | - | | second mutable borrow occurs here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18783.nll.stderr b/src/test/ui/issues/issue-18783.nll.stderr deleted file mode 100644 index f49a2d7a2b2fd..0000000000000 --- a/src/test/ui/issues/issue-18783.nll.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0499]: cannot borrow `y` as mutable more than once at a time - --> $DIR/issue-18783.rs:7:21 - | -LL | c.push(Box::new(|| y = 0)); - | -- - first borrow occurs due to use of `y` in closure - | | - | first mutable borrow occurs here -LL | c.push(Box::new(|| y = 0)); - | ^^ - second borrow occurs due to use of `y` in closure - | | - | second mutable borrow occurs here -LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time -LL | } - | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` - -error[E0499]: cannot borrow `y` as mutable more than once at a time - --> $DIR/issue-18783.rs:16:29 - | -LL | Push::push(&c, Box::new(|| y = 0)); - | -- - first borrow occurs due to use of `y` in closure - | | - | first mutable borrow occurs here -LL | Push::push(&c, Box::new(|| y = 0)); - | ^^ - second borrow occurs due to use of `y` in closure - | | - | second mutable borrow occurs here -LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time -LL | } - | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/issues/issue-18783.stderr b/src/test/ui/issues/issue-18783.stderr index 68eb5167ecbdc..f49a2d7a2b2fd 100644 --- a/src/test/ui/issues/issue-18783.stderr +++ b/src/test/ui/issues/issue-18783.stderr @@ -2,31 +2,31 @@ error[E0499]: cannot borrow `y` as mutable more than once at a time --> $DIR/issue-18783.rs:7:21 | LL | c.push(Box::new(|| y = 0)); - | -- - previous borrow occurs due to use of `y` in closure + | -- - first borrow occurs due to use of `y` in closure | | | first mutable borrow occurs here LL | c.push(Box::new(|| y = 0)); - | ^^ - borrow occurs due to use of `y` in closure + | ^^ - second borrow occurs due to use of `y` in closure | | | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | } - | - first borrow ends here + | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` error[E0499]: cannot borrow `y` as mutable more than once at a time --> $DIR/issue-18783.rs:16:29 | LL | Push::push(&c, Box::new(|| y = 0)); - | -- - previous borrow occurs due to use of `y` in closure + | -- - first borrow occurs due to use of `y` in closure | | | first mutable borrow occurs here LL | Push::push(&c, Box::new(|| y = 0)); - | ^^ - borrow occurs due to use of `y` in closure + | ^^ - second borrow occurs due to use of `y` in closure | | | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | } - | - first borrow ends here + | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-19163.nll.stderr b/src/test/ui/issues/issue-19163.nll.stderr deleted file mode 100644 index af509aa59d481..0000000000000 --- a/src/test/ui/issues/issue-19163.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/issue-19163.rs:9:14 - | -LL | mywrite!(&v, "Hello world"); - | ^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-19163.rs b/src/test/ui/issues/issue-19163.rs index 20d3244027da1..d98c5912af2ee 100644 --- a/src/test/ui/issues/issue-19163.rs +++ b/src/test/ui/issues/issue-19163.rs @@ -7,5 +7,5 @@ use std::io::Write; fn main() { let mut v = vec![]; mywrite!(&v, "Hello world"); - //~^ error: cannot borrow immutable borrowed content as mutable + //~^ ERROR cannot borrow data in a `&` reference as mutable } diff --git a/src/test/ui/issues/issue-19163.stderr b/src/test/ui/issues/issue-19163.stderr index 242ceaedcb0b4..af509aa59d481 100644 --- a/src/test/ui/issues/issue-19163.stderr +++ b/src/test/ui/issues/issue-19163.stderr @@ -1,4 +1,4 @@ -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/issue-19163.rs:9:14 | LL | mywrite!(&v, "Hello world"); diff --git a/src/test/ui/issues/issue-20801.nll.stderr b/src/test/ui/issues/issue-20801.nll.stderr deleted file mode 100644 index adcbe55aa325f..0000000000000 --- a/src/test/ui/issues/issue-20801.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-20801.rs:26:22 - | -LL | let a = unsafe { *mut_ref() }; - | ^^^^^^^^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `mut_ref()` - -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-20801.rs:29:22 - | -LL | let b = unsafe { *imm_ref() }; - | ^^^^^^^^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `imm_ref()` - -error[E0507]: cannot move out of dereference of raw pointer - --> $DIR/issue-20801.rs:32:22 - | -LL | let c = unsafe { *mut_ptr() }; - | ^^^^^^^^^^ - | | - | cannot move out of dereference of raw pointer - | help: consider removing the `*`: `mut_ptr()` - -error[E0507]: cannot move out of dereference of raw pointer - --> $DIR/issue-20801.rs:35:22 - | -LL | let d = unsafe { *const_ptr() }; - | ^^^^^^^^^^^^ - | | - | cannot move out of dereference of raw pointer - | help: consider removing the `*`: `const_ptr()` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-20801.stderr b/src/test/ui/issues/issue-20801.stderr index 3e273919bb9e2..adcbe55aa325f 100644 --- a/src/test/ui/issues/issue-20801.stderr +++ b/src/test/ui/issues/issue-20801.stderr @@ -2,25 +2,37 @@ error[E0507]: cannot move out of borrowed content --> $DIR/issue-20801.rs:26:22 | LL | let a = unsafe { *mut_ref() }; - | ^^^^^^^^^^ cannot move out of borrowed content + | ^^^^^^^^^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `mut_ref()` error[E0507]: cannot move out of borrowed content --> $DIR/issue-20801.rs:29:22 | LL | let b = unsafe { *imm_ref() }; - | ^^^^^^^^^^ cannot move out of borrowed content + | ^^^^^^^^^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `imm_ref()` error[E0507]: cannot move out of dereference of raw pointer --> $DIR/issue-20801.rs:32:22 | LL | let c = unsafe { *mut_ptr() }; - | ^^^^^^^^^^ cannot move out of dereference of raw pointer + | ^^^^^^^^^^ + | | + | cannot move out of dereference of raw pointer + | help: consider removing the `*`: `mut_ptr()` error[E0507]: cannot move out of dereference of raw pointer --> $DIR/issue-20801.rs:35:22 | LL | let d = unsafe { *const_ptr() }; - | ^^^^^^^^^^^^ cannot move out of dereference of raw pointer + | ^^^^^^^^^^^^ + | | + | cannot move out of dereference of raw pointer + | help: consider removing the `*`: `const_ptr()` error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-21600.nll.stderr b/src/test/ui/issues/issue-21600.nll.stderr deleted file mode 100644 index 05837e92cdbc1..0000000000000 --- a/src/test/ui/issues/issue-21600.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/issue-21600.rs:14:20 - | -LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - | ^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/issue-21600.rs:14:17 - | -LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - | ^^^^^^^^^^^^^^ - -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/issue-21600.rs:14:17 - | -LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - | ^^ - mutable borrow occurs due to use of `x` in closure - | | - | cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/issue-21600.rs:12:13 - | -LL | call_it(|| { - | _____________^ -LL | | call_it(|| x.gen()); -LL | | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer -LL | | //~^ ERROR cannot borrow data mutably in a captured outer -LL | | }); - | |_____^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-21600.rs b/src/test/ui/issues/issue-21600.rs index 1efc873bee266..2e22e5e6fa2e0 100644 --- a/src/test/ui/issues/issue-21600.rs +++ b/src/test/ui/issues/issue-21600.rs @@ -11,7 +11,8 @@ fn main() { let mut x = A; call_it(|| { call_it(|| x.gen()); - call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - //~^ ERROR cannot borrow data mutably in a captured outer + call_it(|| x.gen_mut()); + //~^ ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + //~| ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure }); } diff --git a/src/test/ui/issues/issue-21600.stderr b/src/test/ui/issues/issue-21600.stderr index ccb75f4cc005c..1de3589e5d440 100644 --- a/src/test/ui/issues/issue-21600.stderr +++ b/src/test/ui/issues/issue-21600.stderr @@ -1,8 +1,22 @@ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/issue-21600.rs:14:20 + | +LL | call_it(|| x.gen_mut()); + | ^ cannot borrow as mutable + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/issue-21600.rs:14:17 + | +LL | call_it(|| x.gen_mut()); + | ^^^^^^^^^^^^^^ + +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure --> $DIR/issue-21600.rs:14:17 | -LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - | ^^ +LL | call_it(|| x.gen_mut()); + | ^^ - mutable borrow occurs due to use of `x` in closure + | | + | cannot borrow as mutable | help: consider changing this to accept closures that implement `FnMut` --> $DIR/issue-21600.rs:12:13 @@ -10,23 +24,12 @@ help: consider changing this to accept closures that implement `FnMut` LL | call_it(|| { | _____________^ LL | | call_it(|| x.gen()); -LL | | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer -LL | | //~^ ERROR cannot borrow data mutably in a captured outer +LL | | call_it(|| x.gen_mut()); +LL | | //~^ ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure +LL | | //~| ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure LL | | }); | |_____^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/issue-21600.rs:14:20 - | -LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - | ^ - | -help: consider changing this closure to take self by mutable reference - --> $DIR/issue-21600.rs:14:17 - | -LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - | ^^^^^^^^^^^^^^ - error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0387`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-24267-flow-exit.nll.stderr b/src/test/ui/issues/issue-24267-flow-exit.nll.stderr deleted file mode 100644 index 52e637a3f0b0b..0000000000000 --- a/src/test/ui/issues/issue-24267-flow-exit.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/issue-24267-flow-exit.rs:12:20 - | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - | ^ use of possibly uninitialized `x` - -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/issue-24267-flow-exit.rs:18:20 - | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - | ^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/issues/issue-24267-flow-exit.rs b/src/test/ui/issues/issue-24267-flow-exit.rs index ce3a799fb3817..a1b4d75d4048f 100644 --- a/src/test/ui/issues/issue-24267-flow-exit.rs +++ b/src/test/ui/issues/issue-24267-flow-exit.rs @@ -9,11 +9,11 @@ pub fn main() { pub fn foo1() { let x: i32; loop { x = break; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` } pub fn foo2() { let x: i32; for _ in 0..10 { x = continue; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` } diff --git a/src/test/ui/issues/issue-24267-flow-exit.stderr b/src/test/ui/issues/issue-24267-flow-exit.stderr index 0d226e01809be..fb5e78ab63771 100644 --- a/src/test/ui/issues/issue-24267-flow-exit.stderr +++ b/src/test/ui/issues/issue-24267-flow-exit.stderr @@ -1,13 +1,13 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/issue-24267-flow-exit.rs:12:20 | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` +LL | println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` | ^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/issue-24267-flow-exit.rs:18:20 | -LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` +LL | println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` | ^ use of possibly uninitialized `x` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-24357.nll.stderr b/src/test/ui/issues/issue-24357.nll.stderr deleted file mode 100644 index 310535434cd08..0000000000000 --- a/src/test/ui/issues/issue-24357.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/issue-24357.rs:6:12 - | -LL | let x = NoCopy; - | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait -LL | let f = move || { let y = x; }; - | ------- - variable moved due to use in closure - | | - | value moved into closure here -LL | //~^ NOTE value moved (into closure) here -LL | let z = x; - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-24357.rs b/src/test/ui/issues/issue-24357.rs index 84f263ff649c4..152e69ebc873f 100644 --- a/src/test/ui/issues/issue-24357.rs +++ b/src/test/ui/issues/issue-24357.rs @@ -1,10 +1,11 @@ struct NoCopy; fn main() { let x = NoCopy; + //~^ NOTE move occurs because `x` has type `NoCopy` let f = move || { let y = x; }; - //~^ NOTE value moved (into closure) here + //~^ NOTE value moved into closure here + //~| NOTE variable moved due to use in closure let z = x; //~^ ERROR use of moved value: `x` //~| NOTE value used here after move - //~| NOTE move occurs because `x` has type `NoCopy` } diff --git a/src/test/ui/issues/issue-24357.stderr b/src/test/ui/issues/issue-24357.stderr index 3bc84cba0f53f..db954d9d3ce6a 100644 --- a/src/test/ui/issues/issue-24357.stderr +++ b/src/test/ui/issues/issue-24357.stderr @@ -1,13 +1,16 @@ error[E0382]: use of moved value: `x` - --> $DIR/issue-24357.rs:6:8 + --> $DIR/issue-24357.rs:8:12 | +LL | let x = NoCopy; + | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait +LL | //~^ NOTE move occurs because `x` has type `NoCopy` LL | let f = move || { let y = x; }; - | ------- value moved (into closure) here -LL | //~^ NOTE value moved (into closure) here + | ------- - variable moved due to use in closure + | | + | value moved into closure here +... LL | let z = x; - | ^ value used here after move - | - = note: move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait + | ^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25579.ast.nll.stderr b/src/test/ui/issues/issue-25579.ast.nll.stderr deleted file mode 100644 index b791f600f50cb..0000000000000 --- a/src/test/ui/issues/issue-25579.ast.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error: compilation successful - --> $DIR/issue-25579.rs:21:1 - | -LL | / fn main() { //[mir]~ ERROR compilation successful -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-25579.ast.stderr b/src/test/ui/issues/issue-25579.ast.stderr deleted file mode 100644 index 3de7f565b7b8a..0000000000000 --- a/src/test/ui/issues/issue-25579.ast.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0499]: cannot borrow `l.0` as mutable more than once at a time - --> $DIR/issue-25579.rs:14:32 - | -LL | &mut Sexpression::Cons(ref mut expr) => { //[ast]~ ERROR [E0499] - | ^^^^^^^^^^^^ mutable borrow starts here in previous iteration of loop -... -LL | } - | - mutable borrow ends here - -error[E0506]: cannot assign to `l` because it is borrowed - --> $DIR/issue-25579.rs:15:13 - | -LL | &mut Sexpression::Cons(ref mut expr) => { //[ast]~ ERROR [E0499] - | ------------ borrow of `l` occurs here -LL | l = &mut **expr; //[ast]~ ERROR [E0506] - | ^^^^^^^^^^^^^^^ assignment to borrowed `l` occurs here - -error: aborting due to 2 previous errors - -Some errors occurred: E0499, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/issues/issue-25579.mir.stderr b/src/test/ui/issues/issue-25579.mir.stderr deleted file mode 100644 index b791f600f50cb..0000000000000 --- a/src/test/ui/issues/issue-25579.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error: compilation successful - --> $DIR/issue-25579.rs:21:1 - | -LL | / fn main() { //[mir]~ ERROR compilation successful -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-25579.rs b/src/test/ui/issues/issue-25579.rs index 1813253332f98..31ba102746b34 100644 --- a/src/test/ui/issues/issue-25579.rs +++ b/src/test/ui/issues/issue-25579.rs @@ -1,7 +1,4 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(rustc_attrs)] +// compile-pass enum Sexpression { Num(()), @@ -11,12 +8,13 @@ enum Sexpression { fn causes_error_in_ast(mut l: &mut Sexpression) { loop { match l { &mut Sexpression::Num(ref mut n) => {}, - &mut Sexpression::Cons(ref mut expr) => { //[ast]~ ERROR [E0499] - l = &mut **expr; //[ast]~ ERROR [E0506] + &mut Sexpression::Cons(ref mut expr) => { + l = &mut **expr; } }} } -#[rustc_error] -fn main() { //[mir]~ ERROR compilation successful + +fn main() { + causes_error_in_ast(&mut Sexpression::Num(())); } diff --git a/src/test/ui/issues/issue-25700.nll.stderr b/src/test/ui/issues/issue-25700.nll.stderr deleted file mode 100644 index ba5403cca4d06..0000000000000 --- a/src/test/ui/issues/issue-25700.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `t` - --> $DIR/issue-25700.rs:13:10 - | -LL | let t = S::<()>(None); - | - move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait -LL | drop(t); - | - value moved here -LL | drop(t); //~ ERROR use of moved value - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-25700.stderr b/src/test/ui/issues/issue-25700.stderr index d4cf89d0abd5f..ba5403cca4d06 100644 --- a/src/test/ui/issues/issue-25700.stderr +++ b/src/test/ui/issues/issue-25700.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `t` --> $DIR/issue-25700.rs:13:10 | +LL | let t = S::<()>(None); + | - move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait LL | drop(t); | - value moved here LL | drop(t); //~ ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25793.nll.stderr b/src/test/ui/issues/issue-25793.nll.stderr deleted file mode 100644 index daea9cd8cd717..0000000000000 --- a/src/test/ui/issues/issue-25793.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0503]: cannot use `self.width` because it was mutably borrowed - --> $DIR/issue-25793.rs:4:9 - | -LL | $this.width.unwrap() - | ^^^^^^^^^^^ use of borrowed `*self` -... -LL | let r = &mut *self; - | ---------- borrow of `*self` occurs here -LL | r.get_size(width!(self)) - | -------- ------------ in this macro invocation - | | - | borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/issues/issue-25793.stderr b/src/test/ui/issues/issue-25793.stderr index e8d208c19aa37..daea9cd8cd717 100644 --- a/src/test/ui/issues/issue-25793.stderr +++ b/src/test/ui/issues/issue-25793.stderr @@ -5,9 +5,11 @@ LL | $this.width.unwrap() | ^^^^^^^^^^^ use of borrowed `*self` ... LL | let r = &mut *self; - | ----- borrow of `*self` occurs here + | ---------- borrow of `*self` occurs here LL | r.get_size(width!(self)) - | ------------ in this macro invocation + | -------- ------------ in this macro invocation + | | + | borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/issues/issue-2590.nll.stderr b/src/test/ui/issues/issue-2590.nll.stderr deleted file mode 100644 index 1252578419a80..0000000000000 --- a/src/test/ui/issues/issue-2590.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-2590.rs:11:9 - | -LL | self.tokens //~ ERROR cannot move out of borrowed content - | ^^^^^^^^^^^ cannot move out of borrowed content - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-2590.stderr b/src/test/ui/issues/issue-2590.stderr index f93b5db3adfbc..1252578419a80 100644 --- a/src/test/ui/issues/issue-2590.stderr +++ b/src/test/ui/issues/issue-2590.stderr @@ -2,7 +2,7 @@ error[E0507]: cannot move out of borrowed content --> $DIR/issue-2590.rs:11:9 | LL | self.tokens //~ ERROR cannot move out of borrowed content - | ^^^^ cannot move out of borrowed content + | ^^^^^^^^^^^ cannot move out of borrowed content error: aborting due to previous error diff --git a/src/test/ui/issues/issue-27592.nll.stderr b/src/test/ui/issues/issue-27592.nll.stderr deleted file mode 100644 index 9d3eaa9705d44..0000000000000 --- a/src/test/ui/issues/issue-27592.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-27592.rs:16:14 - | -LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^^^^^^^^^^^^^^^^---------------------------^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-27592.rs:16:14 - | -LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-27592.rs b/src/test/ui/issues/issue-27592.rs index 6006f9a7c51d6..b023ea18ac9a9 100644 --- a/src/test/ui/issues/issue-27592.rs +++ b/src/test/ui/issues/issue-27592.rs @@ -14,6 +14,6 @@ impl ::std::fmt::Write for Stream { fn main() { write(|| format_args!("{}", String::from("Hello world"))); - //~^ ERROR borrowed value does not live long enough - //~| ERROR borrowed value does not live long enough + //~^ ERROR cannot return value referencing temporary value + //~| ERROR cannot return value referencing temporary value } diff --git a/src/test/ui/issues/issue-27592.stderr b/src/test/ui/issues/issue-27592.stderr index 0f62abee1ca88..9d3eaa9705d44 100644 --- a/src/test/ui/issues/issue-27592.stderr +++ b/src/test/ui/issues/issue-27592.stderr @@ -1,21 +1,21 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-27592.rs:16:27 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-27592.rs:16:14 | LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^ -- temporary value needs to live until here - | | | - | | temporary value dropped here while still borrowed - | temporary value does not live long enough + | ^^^^^^^^^^^^^^^^^^^---------------------------^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-27592.rs:16:33 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-27592.rs:16:14 | LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^-- temporary value needs to live until here - | | | - | | temporary value dropped here while still borrowed - | temporary value does not live long enough + | ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-a.nll.stderr b/src/test/ui/issues/issue-30438-a.nll.stderr deleted file mode 100644 index 53845af82fb11..0000000000000 --- a/src/test/ui/issues/issue-30438-a.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/issue-30438-a.rs:12:16 - | -LL | return &Test { s: &self.s}; - | ^------------------ - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-a.rs b/src/test/ui/issues/issue-30438-a.rs index 8900821090b1c..0d4eb796ad9b0 100644 --- a/src/test/ui/issues/issue-30438-a.rs +++ b/src/test/ui/issues/issue-30438-a.rs @@ -10,7 +10,7 @@ impl <'a> Index for Test<'a> { type Output = Test<'a>; fn index(&self, _: usize) -> &Self::Output { return &Test { s: &self.s}; - //~^ ERROR: borrowed value does not live long enough + //~^ ERROR: cannot return reference to temporary value } } diff --git a/src/test/ui/issues/issue-30438-a.stderr b/src/test/ui/issues/issue-30438-a.stderr index 94aca7f031999..53845af82fb11 100644 --- a/src/test/ui/issues/issue-30438-a.stderr +++ b/src/test/ui/issues/issue-30438-a.stderr @@ -1,21 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-30438-a.rs:12:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-30438-a.rs:12:16 | LL | return &Test { s: &self.s}; - | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 11:5... - --> $DIR/issue-30438-a.rs:11:5 - | -LL | / fn index(&self, _: usize) -> &Self::Output { -LL | | return &Test { s: &self.s}; -LL | | //~^ ERROR: borrowed value does not live long enough -LL | | } - | |_____^ - = note: consider using a `let` binding to increase its lifetime + | ^------------------ + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-b.nll.stderr b/src/test/ui/issues/issue-30438-b.nll.stderr deleted file mode 100644 index fd6bd25b1da16..0000000000000 --- a/src/test/ui/issues/issue-30438-b.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/issue-30438-b.rs:13:9 - | -LL | &Test { s: &self.s} - | ^------------------ - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-b.rs b/src/test/ui/issues/issue-30438-b.rs index b84211bec67d1..79510cdb66366 100644 --- a/src/test/ui/issues/issue-30438-b.rs +++ b/src/test/ui/issues/issue-30438-b.rs @@ -11,7 +11,7 @@ impl <'a> Index for Test<'a> { type Output = Test<'a>; fn index(&self, _: usize) -> &Self::Output { &Test { s: &self.s} - //~^ ERROR: borrowed value does not live long enough + //~^ ERROR: cannot return reference to temporary value } } diff --git a/src/test/ui/issues/issue-30438-b.stderr b/src/test/ui/issues/issue-30438-b.stderr index b99801dad81d5..fd6bd25b1da16 100644 --- a/src/test/ui/issues/issue-30438-b.stderr +++ b/src/test/ui/issues/issue-30438-b.stderr @@ -1,21 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-30438-b.rs:13:10 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-30438-b.rs:13:9 | LL | &Test { s: &self.s} - | ^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | //~^ ERROR: borrowed value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 12:5... - --> $DIR/issue-30438-b.rs:12:5 - | -LL | / fn index(&self, _: usize) -> &Self::Output { -LL | | &Test { s: &self.s} -LL | | //~^ ERROR: borrowed value does not live long enough -LL | | } - | |_____^ + | ^------------------ + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-c.nll.stderr b/src/test/ui/issues/issue-30438-c.nll.stderr deleted file mode 100644 index 7c001088097ab..0000000000000 --- a/src/test/ui/issues/issue-30438-c.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0515]: cannot return reference to local variable `x` - --> $DIR/issue-30438-c.rs:9:5 - | -LL | &x - | ^^ returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-c.rs b/src/test/ui/issues/issue-30438-c.rs index 75caf0a75dfb6..813c1d3e2cccd 100644 --- a/src/test/ui/issues/issue-30438-c.rs +++ b/src/test/ui/issues/issue-30438-c.rs @@ -7,7 +7,7 @@ struct Test<'a> { s: &'a str } fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y as Trait>::Out where 'z: 'static { let x = Test { s: "this cannot last" }; &x - //~^ ERROR: `x` does not live long enough + //~^ ERROR: cannot return reference to local variable `x` } impl<'b> Trait for Test<'b> { type Out = Test<'b>; } diff --git a/src/test/ui/issues/issue-30438-c.stderr b/src/test/ui/issues/issue-30438-c.stderr index 71c2ed9dfc935..7c001088097ab 100644 --- a/src/test/ui/issues/issue-30438-c.stderr +++ b/src/test/ui/issues/issue-30438-c.stderr @@ -1,18 +1,9 @@ -error[E0597]: `x` does not live long enough - --> $DIR/issue-30438-c.rs:9:6 +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-30438-c.rs:9:5 | LL | &x - | ^ borrowed value does not live long enough -LL | //~^ ERROR: `x` does not live long enough -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'y as defined on the function body at 7:10... - --> $DIR/issue-30438-c.rs:7:10 - | -LL | fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y as Trait>::Out where 'z: 'static { - | ^^ + | ^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-33819.nll.stderr b/src/test/ui/issues/issue-33819.nll.stderr deleted file mode 100644 index 8bc2d82cd3f14..0000000000000 --- a/src/test/ui/issues/issue-33819.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable - --> $DIR/issue-33819.rs:4:34 - | -LL | Some(ref v) => { let a = &mut v; }, - | ^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-33819.rs b/src/test/ui/issues/issue-33819.rs index 7f25ebd18fffc..b73e85974a8e1 100644 --- a/src/test/ui/issues/issue-33819.rs +++ b/src/test/ui/issues/issue-33819.rs @@ -2,8 +2,7 @@ fn main() { let mut op = Some(2); match op { Some(ref v) => { let a = &mut v; }, - //~^ ERROR:cannot borrow immutable - //~| cannot borrow mutably + //~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable None => {}, } } diff --git a/src/test/ui/issues/issue-33819.stderr b/src/test/ui/issues/issue-33819.stderr index 09b8835a8a69c..8bc2d82cd3f14 100644 --- a/src/test/ui/issues/issue-33819.stderr +++ b/src/test/ui/issues/issue-33819.stderr @@ -1,8 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `v` as mutable - --> $DIR/issue-33819.rs:4:39 +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable + --> $DIR/issue-33819.rs:4:34 | LL | Some(ref v) => { let a = &mut v; }, - | ^ cannot borrow mutably + | ^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-36082.ast.nll.stderr b/src/test/ui/issues/issue-36082.ast.nll.stderr deleted file mode 100644 index 6b3b13aa291d8..0000000000000 --- a/src/test/ui/issues/issue-36082.ast.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-36082.rs:11:19 - | -LL | let val: &_ = x.borrow().0; - | ^^^^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | println!("{}", val); - | --- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-36082.ast.stderr b/src/test/ui/issues/issue-36082.ast.stderr deleted file mode 100644 index 56e50e55ed3ef..0000000000000 --- a/src/test/ui/issues/issue-36082.ast.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-36082.rs:11:19 - | -LL | let val: &_ = x.borrow().0; - | ^^^^^^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here - | - = note: consider using a `let` binding to increase its lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-36082.rs b/src/test/ui/issues/issue-36082.rs index 2658ef0ddaaec..a2ff477eb816a 100644 --- a/src/test/ui/issues/issue-36082.rs +++ b/src/test/ui/issues/issue-36082.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::cell::RefCell; fn main() { @@ -9,15 +6,10 @@ fn main() { let x = RefCell::new((&mut r,s)); let val: &_ = x.borrow().0; - //[ast]~^ ERROR borrowed value does not live long enough [E0597] - //[ast]~| NOTE temporary value dropped here while still borrowed - //[ast]~| NOTE temporary value does not live long enough - //[ast]~| NOTE consider using a `let` binding to increase its lifetime - //[mir]~^^^^^ ERROR temporary value dropped while borrowed [E0716] - //[mir]~| NOTE temporary value is freed at the end of this statement - //[mir]~| NOTE creates a temporary which is freed while still in use - //[mir]~| NOTE consider using a `let` binding to create a longer lived value + //~^ ERROR temporary value dropped while borrowed [E0716] + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE consider using a `let` binding to create a longer lived value println!("{}", val); - //[mir]~^ borrow later used here + //~^ borrow later used here } -//[ast]~^ NOTE temporary value needs to live until here diff --git a/src/test/ui/issues/issue-36082.mir.stderr b/src/test/ui/issues/issue-36082.stderr similarity index 94% rename from src/test/ui/issues/issue-36082.mir.stderr rename to src/test/ui/issues/issue-36082.stderr index 6b3b13aa291d8..26bf4cb1be8be 100644 --- a/src/test/ui/issues/issue-36082.mir.stderr +++ b/src/test/ui/issues/issue-36082.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-36082.rs:11:19 + --> $DIR/issue-36082.rs:8:19 | LL | let val: &_ = x.borrow().0; | ^^^^^^^^^^ - temporary value is freed at the end of this statement diff --git a/src/test/ui/issues/issue-36400.nll.stderr b/src/test/ui/issues/issue-36400.nll.stderr deleted file mode 100644 index e260fab779112..0000000000000 --- a/src/test/ui/issues/issue-36400.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable - --> $DIR/issue-36400.rs:5:7 - | -LL | let x = Box::new(3); - | - help: consider changing this to be mutable: `mut x` -LL | f(&mut *x); //~ ERROR cannot borrow immutable - | ^^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-36400.rs b/src/test/ui/issues/issue-36400.rs index 5ba9eb2333bbd..a405f9b113525 100644 --- a/src/test/ui/issues/issue-36400.rs +++ b/src/test/ui/issues/issue-36400.rs @@ -2,5 +2,5 @@ fn f(x: &mut u32) {} fn main() { let x = Box::new(3); - f(&mut *x); //~ ERROR cannot borrow immutable + f(&mut *x); //~ ERROR cannot borrow `*x` as mutable, as `x` is not declared as mutable } diff --git a/src/test/ui/issues/issue-36400.stderr b/src/test/ui/issues/issue-36400.stderr index d9394277050de..e390e196305df 100644 --- a/src/test/ui/issues/issue-36400.stderr +++ b/src/test/ui/issues/issue-36400.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable `Box` content `*x` as mutable - --> $DIR/issue-36400.rs:5:12 +error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable + --> $DIR/issue-36400.rs:5:7 | LL | let x = Box::new(3); - | - help: make this binding mutable: `mut x` -LL | f(&mut *x); //~ ERROR cannot borrow immutable - | ^^ cannot borrow as mutable + | - help: consider changing this to be mutable: `mut x` +LL | f(&mut *x); //~ ERROR cannot borrow `*x` as mutable, as `x` is not declared as mutable + | ^^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40288.nll.stderr b/src/test/ui/issues/issue-40288.nll.stderr deleted file mode 100644 index bb4110948d54f..0000000000000 --- a/src/test/ui/issues/issue-40288.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `*refr` because it is borrowed - --> $DIR/issue-40288.rs:16:5 - | -LL | save_ref(&*refr, &mut out); - | ------ borrow of `*refr` occurs here -... -LL | *refr = 3; //~ ERROR cannot assign to `*refr` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `*refr` occurs here -... -LL | println!("{:?}", out[0]); - | ------ borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/issues/issue-40288.stderr b/src/test/ui/issues/issue-40288.stderr index 2ac5964f5da7f..bb4110948d54f 100644 --- a/src/test/ui/issues/issue-40288.stderr +++ b/src/test/ui/issues/issue-40288.stderr @@ -2,10 +2,13 @@ error[E0506]: cannot assign to `*refr` because it is borrowed --> $DIR/issue-40288.rs:16:5 | LL | save_ref(&*refr, &mut out); - | ----- borrow of `*refr` occurs here + | ------ borrow of `*refr` occurs here ... LL | *refr = 3; //~ ERROR cannot assign to `*refr` because it is borrowed | ^^^^^^^^^ assignment to borrowed `*refr` occurs here +... +LL | println!("{:?}", out[0]); + | ------ borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr deleted file mode 100644 index a4847568ba0cb..0000000000000 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-40402-1.rs:9:13 - | -LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content - | ^^^^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&f.v[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs index 6bb0b6f1cfb04..786c37e5969d8 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs @@ -6,5 +6,5 @@ struct Foo { fn main() { let mut f = Foo { v: Vec::new() }; f.v.push("hello".to_string()); - let e = f.v[0]; //~ ERROR cannot move out of indexed content + let e = f.v[0]; //~ ERROR cannot move out of borrowed content } diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr index 87b98bbcedb6a..91f867ae320af 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/issue-40402-1.rs:9:13 | -LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content +LL | let e = f.v[0]; //~ ERROR cannot move out of borrowed content | ^^^^^^ | | - | cannot move out of indexed content - | help: consider using a reference instead: `&f.v[0]` + | cannot move out of borrowed content + | help: consider borrowing here: `&f.v[0]` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr deleted file mode 100644 index 5c23021ee2c87..0000000000000 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-40402-2.rs:5:18 - | -LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content - | - - ^^^^ - | | | | - | | | cannot move out of borrowed content - | | | help: consider borrowing here: `&x[0]` - | | ...and here - | data moved here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/issue-40402-2.rs:5:10 - | -LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content - | ^ ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs index 0b8f40c5eff7f..480a4df48a3e5 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs @@ -2,5 +2,5 @@ // are nested within a pattern fn main() { let x = vec![(String::new(), String::new())]; - let (a, b) = x[0]; //~ ERROR cannot move out of indexed content + let (a, b) = x[0]; //~ ERROR cannot move out of borrowed content } diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr index d64cd96e959ff..28d472f5579d9 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr @@ -1,11 +1,19 @@ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/issue-40402-2.rs:5:18 | -LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content - | - - ^^^^ cannot move out of indexed content - | | | - | | ...and here (use `ref b` or `ref mut b`) - | hint: to prevent move, use `ref a` or `ref mut a` +LL | let (a, b) = x[0]; //~ ERROR cannot move out of borrowed content + | - - ^^^^ + | | | | + | | | cannot move out of borrowed content + | | | help: consider borrowing here: `&x[0]` + | | ...and here + | data moved here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/issue-40402-2.rs:5:10 + | +LL | let (a, b) = x[0]; //~ ERROR cannot move out of borrowed content + | ^ ^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40510-1.nll.stderr b/src/test/ui/issues/issue-40510-1.stderr similarity index 100% rename from src/test/ui/issues/issue-40510-1.nll.stderr rename to src/test/ui/issues/issue-40510-1.stderr diff --git a/src/test/ui/issues/issue-40510-3.nll.stderr b/src/test/ui/issues/issue-40510-3.stderr similarity index 100% rename from src/test/ui/issues/issue-40510-3.nll.stderr rename to src/test/ui/issues/issue-40510-3.stderr diff --git a/src/test/ui/issues/issue-41139.nll.stderr b/src/test/ui/issues/issue-41139.nll.stderr deleted file mode 100644 index 4dd017b0a9191..0000000000000 --- a/src/test/ui/issues/issue-41139.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0161]: cannot move a value of type dyn Trait: the size of dyn Trait cannot be statically determined - --> $DIR/issue-41139.rs:6:23 - | -LL | let t : &Trait = &get_function()(); - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0161`. diff --git a/src/test/ui/issues/issue-41139.rs b/src/test/ui/issues/issue-41139.rs index 0bfbea11b0e08..f3e6c44ecb921 100644 --- a/src/test/ui/issues/issue-41139.rs +++ b/src/test/ui/issues/issue-41139.rs @@ -4,5 +4,5 @@ fn get_function<'a>() -> &'a Fn() -> Trait { panic!("") } fn main() { let t : &Trait = &get_function()(); - //~^ ERROR cannot move a value of type (dyn Trait + 'static) + //~^ ERROR cannot move a value of type dyn Trait } diff --git a/src/test/ui/issues/issue-41139.stderr b/src/test/ui/issues/issue-41139.stderr index 3e3de7b7cf12d..4dd017b0a9191 100644 --- a/src/test/ui/issues/issue-41139.stderr +++ b/src/test/ui/issues/issue-41139.stderr @@ -1,4 +1,4 @@ -error[E0161]: cannot move a value of type (dyn Trait + 'static): the size of (dyn Trait + 'static) cannot be statically determined +error[E0161]: cannot move a value of type dyn Trait: the size of dyn Trait cannot be statically determined --> $DIR/issue-41139.rs:6:23 | LL | let t : &Trait = &get_function()(); diff --git a/src/test/ui/issues/issue-41726.nll.stderr b/src/test/ui/issues/issue-41726.nll.stderr deleted file mode 100644 index 087f557a0d4fc..0000000000000 --- a/src/test/ui/issues/issue-41726.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/issue-41726.rs:5:9 - | -LL | things[src.as_str()].sort(); //~ ERROR cannot borrow immutable - | ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-41726.rs b/src/test/ui/issues/issue-41726.rs index 41dcaa8e280b8..ed05629389005 100644 --- a/src/test/ui/issues/issue-41726.rs +++ b/src/test/ui/issues/issue-41726.rs @@ -2,6 +2,6 @@ use std::collections::HashMap; fn main() { let things: HashMap> = HashMap::new(); for src in things.keys() { - things[src.as_str()].sort(); //~ ERROR cannot borrow immutable + things[src.as_str()].sort(); //~ ERROR cannot borrow data in a `&` reference as mutable } } diff --git a/src/test/ui/issues/issue-41726.stderr b/src/test/ui/issues/issue-41726.stderr index e6b92dc9dfeaf..2a79e26ccadbd 100644 --- a/src/test/ui/issues/issue-41726.stderr +++ b/src/test/ui/issues/issue-41726.stderr @@ -1,7 +1,7 @@ -error[E0596]: cannot borrow immutable indexed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/issue-41726.rs:5:9 | -LL | things[src.as_str()].sort(); //~ ERROR cannot borrow immutable +LL | things[src.as_str()].sort(); //~ ERROR cannot borrow data in a `&` reference as mutable | ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap>` diff --git a/src/test/ui/issues/issue-42106.nll.stderr b/src/test/ui/issues/issue-42106.nll.stderr deleted file mode 100644 index 3a31e439c078a..0000000000000 --- a/src/test/ui/issues/issue-42106.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `*collection` as mutable because it is also borrowed as immutable - --> $DIR/issue-42106.rs:3:5 - | -LL | let _a = &collection; - | ----------- immutable borrow occurs here -LL | collection.swap(1, 2); //~ ERROR also borrowed as immutable - | ^^^^^^^^^^ mutable borrow occurs here -LL | _a.use_ref(); - | -- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/issues/issue-42106.stderr b/src/test/ui/issues/issue-42106.stderr index e1018a89d2091..3a31e439c078a 100644 --- a/src/test/ui/issues/issue-42106.stderr +++ b/src/test/ui/issues/issue-42106.stderr @@ -1,13 +1,12 @@ -error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable +error[E0502]: cannot borrow `*collection` as mutable because it is also borrowed as immutable --> $DIR/issue-42106.rs:3:5 | LL | let _a = &collection; - | ---------- immutable borrow occurs here + | ----------- immutable borrow occurs here LL | collection.swap(1, 2); //~ ERROR also borrowed as immutable | ^^^^^^^^^^ mutable borrow occurs here LL | _a.use_ref(); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-42344.nll.stderr b/src/test/ui/issues/issue-42344.nll.stderr deleted file mode 100644 index 9770d26fb12d8..0000000000000 --- a/src/test/ui/issues/issue-42344.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item - --> $DIR/issue-42344.rs:4:5 - | -LL | TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389] - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-42344.rs b/src/test/ui/issues/issue-42344.rs index 5f1bb4f91bb84..a7636edf2f8db 100644 --- a/src/test/ui/issues/issue-42344.rs +++ b/src/test/ui/issues/issue-42344.rs @@ -1,7 +1,8 @@ static TAB: [&mut [u8]; 0] = []; pub unsafe fn test() { - TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389] + TAB[0].iter_mut(); + //~^ ERROR cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item [E0596] } pub fn main() {} diff --git a/src/test/ui/issues/issue-42344.stderr b/src/test/ui/issues/issue-42344.stderr index cb0fe78d10205..5cffa1b51219f 100644 --- a/src/test/ui/issues/issue-42344.stderr +++ b/src/test/ui/issues/issue-42344.stderr @@ -1,9 +1,9 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item --> $DIR/issue-42344.rs:4:5 | -LL | TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389] - | ^^^^^^ assignment into an immutable reference +LL | TAB[0].iter_mut(); + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-42796.nll.stderr b/src/test/ui/issues/issue-42796.nll.stderr deleted file mode 100644 index 23cc88bab52d5..0000000000000 --- a/src/test/ui/issues/issue-42796.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `s` - --> $DIR/issue-42796.rs:18:20 - | -LL | let s = "Hello!".to_owned(); - | - move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait -LL | let mut s_copy = s; - | - value moved here -... -LL | println!("{}", s); //~ ERROR use of moved value - | ^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-42796.rs b/src/test/ui/issues/issue-42796.rs index 98b91270b7d30..5e83a1cd67785 100644 --- a/src/test/ui/issues/issue-42796.rs +++ b/src/test/ui/issues/issue-42796.rs @@ -15,5 +15,5 @@ fn main() { let mut s_copy = s; s_copy.push_str("World!"); "0wned!".to_owned(); - println!("{}", s); //~ ERROR use of moved value + println!("{}", s); //~ ERROR borrow of moved value } diff --git a/src/test/ui/issues/issue-42796.stderr b/src/test/ui/issues/issue-42796.stderr index 530eedd68e6a1..959877502e075 100644 --- a/src/test/ui/issues/issue-42796.stderr +++ b/src/test/ui/issues/issue-42796.stderr @@ -1,13 +1,13 @@ -error[E0382]: use of moved value: `s` +error[E0382]: borrow of moved value: `s` --> $DIR/issue-42796.rs:18:20 | +LL | let s = "Hello!".to_owned(); + | - move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait LL | let mut s_copy = s; - | ---------- value moved here + | - value moved here ... -LL | println!("{}", s); //~ ERROR use of moved value - | ^ value used here after move - | - = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait +LL | println!("{}", s); //~ ERROR borrow of moved value + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/issues/issue-4335.nll.stderr b/src/test/ui/issues/issue-4335.nll.stderr deleted file mode 100644 index 5ac3bdb805cb8..0000000000000 --- a/src/test/ui/issues/issue-4335.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/issue-4335.rs:6:20 - | -LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { - | - captured outer variable -LL | id(Box::new(|| *v)) - | ^^ cannot move out of captured variable in an `FnMut` closure - -error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function - --> $DIR/issue-4335.rs:6:17 - | -LL | id(Box::new(|| *v)) - | ^^ - `v` is borrowed here - | | - | may outlive borrowed value `v` - | -note: closure is returned here - --> $DIR/issue-4335.rs:6:5 - | -LL | id(Box::new(|| *v)) - | ^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword - | -LL | id(Box::new(move || *v)) - | ^^^^^^^ - -error: aborting due to 2 previous errors - -Some errors occurred: E0373, E0507. -For more information about an error, try `rustc --explain E0373`. diff --git a/src/test/ui/issues/issue-4335.stderr b/src/test/ui/issues/issue-4335.stderr index 9ef8e16bbd3c9..5ac3bdb805cb8 100644 --- a/src/test/ui/issues/issue-4335.stderr +++ b/src/test/ui/issues/issue-4335.stderr @@ -1,3 +1,11 @@ +error[E0507]: cannot move out of captured variable in an `FnMut` closure + --> $DIR/issue-4335.rs:6:20 + | +LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { + | - captured outer variable +LL | id(Box::new(|| *v)) + | ^^ cannot move out of captured variable in an `FnMut` closure + error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function --> $DIR/issue-4335.rs:6:17 | @@ -5,17 +13,17 @@ LL | id(Box::new(|| *v)) | ^^ - `v` is borrowed here | | | may outlive borrowed value `v` + | +note: closure is returned here + --> $DIR/issue-4335.rs:6:5 + | +LL | id(Box::new(|| *v)) + | ^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword | LL | id(Box::new(move || *v)) | ^^^^^^^ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-4335.rs:6:20 - | -LL | id(Box::new(|| *v)) - | ^^ cannot move out of borrowed content - error: aborting due to 2 previous errors Some errors occurred: E0373, E0507. diff --git a/src/test/ui/issues/issue-44373.nll.stderr b/src/test/ui/issues/issue-44373.nll.stderr deleted file mode 100644 index 8359e5af2b8de..0000000000000 --- a/src/test/ui/issues/issue-44373.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-44373.rs:4:42 - | -LL | let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR borrowed value does not live long enough - | ----------------------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-44373.rs b/src/test/ui/issues/issue-44373.rs index 13e9fa9ea6743..0d011d096bd1f 100644 --- a/src/test/ui/issues/issue-44373.rs +++ b/src/test/ui/issues/issue-44373.rs @@ -1,5 +1,5 @@ static FOO: u32 = 50; fn main() { - let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR borrowed value does not live long enough + let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/issues/issue-44373.stderr b/src/test/ui/issues/issue-44373.stderr index 5a4bf18f3d5aa..8a5550777db3c 100644 --- a/src/test/ui/issues/issue-44373.stderr +++ b/src/test/ui/issues/issue-44373.stderr @@ -1,13 +1,13 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-44373.rs:4:42 | -LL | let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR borrowed value does not live long enough - | ^^^^^^ temporary value does not live long enough +LL | let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR temporary value dropped while borrowed + | ----------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-45199.ast.nll.stderr b/src/test/ui/issues/issue-45199.ast.nll.stderr deleted file mode 100644 index 6d6af83598226..0000000000000 --- a/src/test/ui/issues/issue-45199.ast.nll.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:10:5 - | -LL | let b: Box; - | - help: make this binding mutable: `mut b` -... -LL | b = Box::new(1); //[ast]~ NOTE first assignment - | - first assignment to `b` -LL | //[mir]~^ NOTE first assignment -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:21:5 - | -LL | let b = Box::new(1); //[ast]~ NOTE first assignment - | - - | | - | first assignment to `b` - | help: make this binding mutable: `mut b` -... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^ cannot assign twice to immutable variable - -error[E0384]: cannot assign to immutable argument `b` - --> $DIR/issue-45199.rs:30:5 - | -LL | fn test_args(b: Box) { //[ast]~ NOTE first assignment - | - help: make this binding mutable: `mut b` -... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^ cannot assign to immutable argument - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/issues/issue-45199.ast.stderr b/src/test/ui/issues/issue-45199.ast.stderr deleted file mode 100644 index fa9d8e09af5a1..0000000000000 --- a/src/test/ui/issues/issue-45199.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:10:5 - | -LL | b = Box::new(1); //[ast]~ NOTE first assignment - | --------------- first assignment to `b` -LL | //[mir]~^ NOTE first assignment -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:21:5 - | -LL | let b = Box::new(1); //[ast]~ NOTE first assignment - | - first assignment to `b` -... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:30:5 - | -LL | fn test_args(b: Box) { //[ast]~ NOTE first assignment - | - first assignment to `b` -... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/issues/issue-45199.rs b/src/test/ui/issues/issue-45199.rs index bb55534c13218..cbd45cbb61990 100644 --- a/src/test/ui/issues/issue-45199.rs +++ b/src/test/ui/issues/issue-45199.rs @@ -1,36 +1,24 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test_drop_replace() { let b: Box; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut b - b = Box::new(1); //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + //~^ HELP make this binding mutable + //~| SUGGESTION mut b + b = Box::new(1); //~ NOTE first assignment + b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` + //~| NOTE cannot assign twice to immutable } fn test_call() { - let b = Box::new(1); //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| HELP make this binding mutable - //[mir]~| SUGGESTION mut b - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + let b = Box::new(1); //~ NOTE first assignment + //~| HELP make this binding mutable + //~| SUGGESTION mut b + b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` + //~| NOTE cannot assign twice to immutable } -fn test_args(b: Box) { //[ast]~ NOTE first assignment - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut b - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign to immutable argument `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign to immutable argument +fn test_args(b: Box) { //~ HELP make this binding mutable + //~| SUGGESTION mut b + b = Box::new(2); //~ ERROR cannot assign to immutable argument `b` + //~| NOTE cannot assign to immutable argument } fn main() {} diff --git a/src/test/ui/issues/issue-45199.mir.stderr b/src/test/ui/issues/issue-45199.stderr similarity index 55% rename from src/test/ui/issues/issue-45199.mir.stderr rename to src/test/ui/issues/issue-45199.stderr index 6d6af83598226..657a1ef6cc887 100644 --- a/src/test/ui/issues/issue-45199.mir.stderr +++ b/src/test/ui/issues/issue-45199.stderr @@ -1,34 +1,33 @@ error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:10:5 + --> $DIR/issue-45199.rs:6:5 | LL | let b: Box; | - help: make this binding mutable: `mut b` ... -LL | b = Box::new(1); //[ast]~ NOTE first assignment +LL | b = Box::new(1); //~ NOTE first assignment | - first assignment to `b` -LL | //[mir]~^ NOTE first assignment -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable +LL | b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:21:5 + --> $DIR/issue-45199.rs:14:5 | -LL | let b = Box::new(1); //[ast]~ NOTE first assignment +LL | let b = Box::new(1); //~ NOTE first assignment | - | | | first assignment to `b` | help: make this binding mutable: `mut b` ... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable +LL | b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` | ^ cannot assign twice to immutable variable error[E0384]: cannot assign to immutable argument `b` - --> $DIR/issue-45199.rs:30:5 + --> $DIR/issue-45199.rs:20:5 | -LL | fn test_args(b: Box) { //[ast]~ NOTE first assignment +LL | fn test_args(b: Box) { //~ HELP make this binding mutable | - help: make this binding mutable: `mut b` -... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable +LL | //~| SUGGESTION mut b +LL | b = Box::new(2); //~ ERROR cannot assign to immutable argument `b` | ^ cannot assign to immutable argument error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs b/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs index 9f86caeaea9e9..b3f655628ba94 100644 --- a/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs +++ b/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs @@ -1,14 +1,5 @@ // rust-lang/rust#45696: This test is checking that we can return // mutable borrows owned by boxes even when the boxes are dropped. -// -// We will explicitly test AST-borrowck, NLL, and migration modes; -// thus we will also skip the automated compare-mode=nll. - -// revisions: ast nll migrate -// ignore-compare-mode-nll - -#![cfg_attr(nll, feature(nll))] -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows // run-pass diff --git a/src/test/ui/issues/issue-45696-no-variant-box-recur.rs b/src/test/ui/issues/issue-45696-no-variant-box-recur.rs index 867da22221aee..b5d9036aba67c 100644 --- a/src/test/ui/issues/issue-45696-no-variant-box-recur.rs +++ b/src/test/ui/issues/issue-45696-no-variant-box-recur.rs @@ -1,16 +1,15 @@ -// rust-lang/rust#45696: This test checks the compiler won't infinite -// loop when you declare a variable of type `struct A(Box, ...);` -// (which is impossible to construct but *is* possible to declare; see -// also issues #4287, #44933, and #52852). +// rust-lang/rust#45696: This test checks the compiler won't infinite loop when +// you declare a variable of type `struct A(Box, ...);` (which is impossible +// to construct but *is* possible to declare; see also issues #4287, #44933, +// and #52852). // -// We will explicitly test AST-borrowck, NLL, and migration modes; -// thus we will also skip the automated compare-mode=nll. +// We will explicitly test NLL, and migration modes; thus we will also skip the +// automated compare-mode=nll. -// revisions: ast nll migrate +// revisions: nll migrate // ignore-compare-mode-nll #![cfg_attr(nll, feature(nll))] -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows // run-pass diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.ast.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.ast.stderr deleted file mode 100644 index 1992e32bf8406..0000000000000 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.ast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:1 - | -LL | / fn main() { //[ast]~ ERROR compilation successful -LL | | //[migrate]~^ ERROR compilation successful -LL | | let mut x = 1; -LL | | { -... | -LL | | *boxed_boxed_scribbled(Box::new(Box::new(Scribble(&mut x)))) += 10; -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr index 129c6292b15a1..103033af1daa2 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr @@ -1,5 +1,5 @@ warning[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:53:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:51:5 | LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -13,7 +13,7 @@ LL | } = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future warning[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:64:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:62:5 | LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -27,7 +27,7 @@ LL | } = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future warning[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:75:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5 | LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -41,12 +41,12 @@ LL | } = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future error: compilation successful - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:1 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:80:1 | -LL | / fn main() { //[ast]~ ERROR compilation successful -LL | | //[migrate]~^ ERROR compilation successful +LL | / fn main() { //[migrate]~ ERROR compilation successful LL | | let mut x = 1; LL | | { +LL | | let mut long_lived = Scribble(&mut x); ... | LL | | *boxed_boxed_scribbled(Box::new(Box::new(Scribble(&mut x)))) += 10; LL | | } diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr index 2cb07f0ad0013..11a3d76b3fa75 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr @@ -1,5 +1,5 @@ error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:53:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:51:5 | LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -10,7 +10,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:64:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:62:5 | LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -21,7 +21,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:75:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5 | LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs index fc56a2a8b70ad..f568efa487cd7 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs @@ -2,21 +2,19 @@ // mutable borrows that would be scribbled over by destructors before // the return occurs. // -// We will explicitly test AST-borrowck, NLL, and migration modes; +// We will explicitly test NLL, and migration modes; // thus we will also skip the automated compare-mode=nll. -// revisions: ast nll migrate +// revisions: nll migrate // ignore-compare-mode-nll -// This test is going to pass in the ast and migrate revisions, -// because the AST-borrowck accepted this code in the past (see notes -// below). So we use `#[rustc_error]` to keep the outcome as an error -// in all scenarios, and rely on the stderr files to show what the -// actual behavior is. (See rust-lang/rust#49855.) +// This test is going to pass in the migrate revision, because the AST-borrowck +// accepted this code in the past (see notes below). So we use `#[rustc_error]` +// to keep the outcome as an error in all scenarios, and rely on the stderr +// files to show what the actual behavior is. (See rust-lang/rust#49855.) #![feature(rustc_attrs)] #![cfg_attr(nll, feature(nll))] -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows struct Scribble<'a>(&'a mut u32); @@ -79,8 +77,7 @@ fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { } #[rustc_error] -fn main() { //[ast]~ ERROR compilation successful - //[migrate]~^ ERROR compilation successful +fn main() { //[migrate]~ ERROR compilation successful let mut x = 1; { let mut long_lived = Scribble(&mut x); diff --git a/src/test/ui/issues/issue-46023.ast.stderr b/src/test/ui/issues/issue-46023.ast.stderr deleted file mode 100644 index ace48f8be6b29..0000000000000 --- a/src/test/ui/issues/issue-46023.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure - --> $DIR/issue-46023.rs:8:9 - | -LL | let x = 0; - | - help: consider making `x` mutable: `mut x` -... -LL | x = 1; - | ^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/issues/issue-46023.mir.stderr b/src/test/ui/issues/issue-46023.mir.stderr deleted file mode 100644 index 05dbe42732b62..0000000000000 --- a/src/test/ui/issues/issue-46023.mir.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-46023.rs:8:9 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | x = 1; - | ^^^^^ cannot assign - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/issues/issue-46023.rs b/src/test/ui/issues/issue-46023.rs index a9ecbbeea4751..a923eb2442101 100644 --- a/src/test/ui/issues/issue-46023.rs +++ b/src/test/ui/issues/issue-46023.rs @@ -1,12 +1,8 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let x = 0; (move || { x = 1; - //[mir]~^ ERROR cannot assign to `x`, as it is not declared as mutable [E0594] - //[ast]~^^ ERROR cannot assign to captured outer variable in an `FnMut` closure [E0594] + //~^ ERROR cannot assign to `x`, as it is not declared as mutable [E0594] })() } diff --git a/src/test/ui/issues/issue-46023.ast.nll.stderr b/src/test/ui/issues/issue-46023.stderr similarity index 91% rename from src/test/ui/issues/issue-46023.ast.nll.stderr rename to src/test/ui/issues/issue-46023.stderr index 05dbe42732b62..ca19c2501205d 100644 --- a/src/test/ui/issues/issue-46023.ast.nll.stderr +++ b/src/test/ui/issues/issue-46023.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-46023.rs:8:9 + --> $DIR/issue-46023.rs:5:9 | LL | let x = 0; | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/issues/issue-46604.ast.nll.stderr b/src/test/ui/issues/issue-46604.ast.nll.stderr deleted file mode 100644 index 4f73a0f9d541d..0000000000000 --- a/src/test/ui/issues/issue-46604.ast.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0017]: references in statics may only refer to immutable values - --> $DIR/issue-46604.rs:4:25 - | -LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //[ast]~ ERROR E0017 - | ^^^^^^^^^^^^^^^^^^^^ statics require immutable values - -error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item - --> $DIR/issue-46604.rs:10:5 - | -LL | buf[0]=2; //[ast]~ ERROR E0389 - | ^^^^^^^^ cannot assign - -error: aborting due to 2 previous errors - -Some errors occurred: E0017, E0594. -For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/issues/issue-46604.ast.stderr b/src/test/ui/issues/issue-46604.ast.stderr deleted file mode 100644 index 14b9242ba0c3d..0000000000000 --- a/src/test/ui/issues/issue-46604.ast.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0017]: references in statics may only refer to immutable values - --> $DIR/issue-46604.rs:4:25 - | -LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //[ast]~ ERROR E0017 - | ^^^^^^^^^^^^^^^^^^^^ statics require immutable values - -error[E0389]: cannot assign to data in a `&` reference - --> $DIR/issue-46604.rs:10:5 - | -LL | buf[0]=2; //[ast]~ ERROR E0389 - | ^^^^^^^^ assignment into an immutable reference - -error: aborting due to 2 previous errors - -Some errors occurred: E0017, E0389. -For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/issues/issue-46604.rs b/src/test/ui/issues/issue-46604.rs index 34fe3af3ab6ca..4f1ad38dbdd94 100644 --- a/src/test/ui/issues/issue-46604.rs +++ b/src/test/ui/issues/issue-46604.rs @@ -1,12 +1,7 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //[ast]~ ERROR E0017 - //[mir]~^ ERROR E0017 +static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR E0017 fn write>(buffer: T) { } fn main() { write(&buf); - buf[0]=2; //[ast]~ ERROR E0389 - //[mir]~^ ERROR E0594 + buf[0]=2; //~ ERROR E0594 } diff --git a/src/test/ui/issues/issue-46604.mir.stderr b/src/test/ui/issues/issue-46604.stderr similarity index 66% rename from src/test/ui/issues/issue-46604.mir.stderr rename to src/test/ui/issues/issue-46604.stderr index 4f73a0f9d541d..cce6b2a3e38cd 100644 --- a/src/test/ui/issues/issue-46604.mir.stderr +++ b/src/test/ui/issues/issue-46604.stderr @@ -1,13 +1,13 @@ error[E0017]: references in statics may only refer to immutable values - --> $DIR/issue-46604.rs:4:25 + --> $DIR/issue-46604.rs:1:25 | -LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //[ast]~ ERROR E0017 +LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR E0017 | ^^^^^^^^^^^^^^^^^^^^ statics require immutable values error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item - --> $DIR/issue-46604.rs:10:5 + --> $DIR/issue-46604.rs:6:5 | -LL | buf[0]=2; //[ast]~ ERROR E0389 +LL | buf[0]=2; //~ ERROR E0594 | ^^^^^^^^ cannot assign error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-49824.nll.stderr b/src/test/ui/issues/issue-49824.nll.stderr deleted file mode 100644 index 4e2f3f59a6445..0000000000000 --- a/src/test/ui/issues/issue-49824.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-49824.rs:12:9 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | / || { -LL | | let _y = &mut x; -LL | | } - | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body - | - = note: `FnMut` closures only have access to their captured variables while they are executing... - = note: ...therefore, they cannot allow references to captured variables to escape - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error: compilation successful - --> $DIR/issue-49824.rs:8:1 - | -LL | / fn main() { -LL | | //~^ compilation successful -LL | | let mut x = 0; -LL | | || { -... | -LL | | }; -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-49824.rs b/src/test/ui/issues/issue-49824.rs index 58cada5d31ea0..b0d01b3d98d51 100644 --- a/src/test/ui/issues/issue-49824.rs +++ b/src/test/ui/issues/issue-49824.rs @@ -1,15 +1,16 @@ #![feature(rustc_attrs)] -// This test checks that a failure occurs with NLL but does not fail with the -// legacy AST output. Check issue-49824.nll.stderr for expected compilation error -// output under NLL and #49824 for more information. +// This test checks that a warning occurs with migrate mode. #[rustc_error] fn main() { - //~^ compilation successful + //~^ ERROR compilation successful let mut x = 0; || { || { + //~^ WARNING captured variable cannot escape `FnMut` closure body + //~| WARNING this error has been downgraded to a warning + //~| WARNING this warning will become a hard error in the future let _y = &mut x; } }; diff --git a/src/test/ui/issues/issue-49824.stderr b/src/test/ui/issues/issue-49824.stderr index f487c363ea674..7fc422fe9f53f 100644 --- a/src/test/ui/issues/issue-49824.stderr +++ b/src/test/ui/issues/issue-49824.stderr @@ -1,8 +1,26 @@ +warning: captured variable cannot escape `FnMut` closure body + --> $DIR/issue-49824.rs:10:9 + | +LL | || { + | - inferred to be a `FnMut` closure +LL | / || { +LL | | //~^ WARNING captured variable cannot escape `FnMut` closure body +LL | | //~| WARNING this error has been downgraded to a warning +LL | | //~| WARNING this warning will become a hard error in the future +LL | | let _y = &mut x; +LL | | } + | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body + | + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + error: compilation successful - --> $DIR/issue-49824.rs:8:1 + --> $DIR/issue-49824.rs:6:1 | LL | / fn main() { -LL | | //~^ compilation successful +LL | | //~^ ERROR compilation successful LL | | let mut x = 0; LL | | || { ... | diff --git a/src/test/ui/issues/issue-51244.nll.stderr b/src/test/ui/issues/issue-51244.nll.stderr deleted file mode 100644 index 7a4935fafc6e9..0000000000000 --- a/src/test/ui/issues/issue-51244.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference - --> $DIR/issue-51244.rs:3:5 - | -LL | let ref my_ref @ _ = 0; - | -------------- help: consider changing this to be a mutable reference: `ref mut my_ref @ _` -LL | *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594] - | ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/issues/issue-51244.rs b/src/test/ui/issues/issue-51244.rs index d365181013172..509060e1ad81b 100644 --- a/src/test/ui/issues/issue-51244.rs +++ b/src/test/ui/issues/issue-51244.rs @@ -1,4 +1,4 @@ fn main() { let ref my_ref @ _ = 0; - *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594] + *my_ref = 0; //~ ERROR cannot assign to `*my_ref` which is behind a `&` reference [E0594] } diff --git a/src/test/ui/issues/issue-51244.stderr b/src/test/ui/issues/issue-51244.stderr index a5b06aa228290..1701f7b3c4998 100644 --- a/src/test/ui/issues/issue-51244.stderr +++ b/src/test/ui/issues/issue-51244.stderr @@ -1,10 +1,10 @@ -error[E0594]: cannot assign to immutable borrowed content `*my_ref` +error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference --> $DIR/issue-51244.rs:3:5 | LL | let ref my_ref @ _ = 0; - | -------------- help: use a mutable reference instead: `ref mut my_ref @ _` -LL | *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594] - | ^^^^^^^^^^^ cannot borrow as mutable + | -------------- help: consider changing this to be a mutable reference: `ref mut my_ref @ _` +LL | *my_ref = 0; //~ ERROR cannot assign to `*my_ref` which is behind a `&` reference [E0594] + | ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written error: aborting due to previous error diff --git a/src/test/ui/issues/issue-52049.nll.stderr b/src/test/ui/issues/issue-52049.nll.stderr deleted file mode 100644 index 55929d85da457..0000000000000 --- a/src/test/ui/issues/issue-52049.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-52049.rs:6:10 - | -LL | foo(&unpromotable(5u32)); - | -----^^^^^^^^^^^^^^^^^^- - | | | - | | creates a temporary which is freed while still in use - | argument requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-52049.rs b/src/test/ui/issues/issue-52049.rs index 23b21cf4e615d..efdcc44930567 100644 --- a/src/test/ui/issues/issue-52049.rs +++ b/src/test/ui/issues/issue-52049.rs @@ -5,4 +5,4 @@ fn unpromotable(t: T) -> T { t } fn main() { foo(&unpromotable(5u32)); } -//~^^ ERROR borrowed value does not live long enough +//~^^ ERROR temporary value dropped while borrowed diff --git a/src/test/ui/issues/issue-52049.stderr b/src/test/ui/issues/issue-52049.stderr index 45381765f8c09..55929d85da457 100644 --- a/src/test/ui/issues/issue-52049.stderr +++ b/src/test/ui/issues/issue-52049.stderr @@ -1,13 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-52049.rs:6:10 | LL | foo(&unpromotable(5u32)); - | ^^^^^^^^^^^^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | -----^^^^^^^^^^^^^^^^^^- + | | | + | | creates a temporary which is freed while still in use + | argument requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr b/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr deleted file mode 100644 index d231f621e59c7..0000000000000 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `line` does not live long enough - --> $DIR/issue-52126-assign-op-invariance.rs:34:28 - | -LL | let v: Vec<&str> = line.split_whitespace().collect(); - | ^^^^ borrowed value does not live long enough -... -LL | acc += cnt2; - | --- borrow later used here -... -LL | } - | - `line` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-52126-assign-op-invariance.stderr b/src/test/ui/issues/issue-52126-assign-op-invariance.stderr index b07b8d5281e8f..d231f621e59c7 100644 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.stderr +++ b/src/test/ui/issues/issue-52126-assign-op-invariance.stderr @@ -4,10 +4,11 @@ error[E0597]: `line` does not live long enough LL | let v: Vec<&str> = line.split_whitespace().collect(); | ^^^^ borrowed value does not live long enough ... +LL | acc += cnt2; + | --- borrow later used here +... LL | } | - `line` dropped here while still borrowed -LL | } - | - borrowed value needs to live until here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-52240.nll.stderr b/src/test/ui/issues/issue-52240.nll.stderr deleted file mode 100644 index 69b663b17d340..0000000000000 --- a/src/test/ui/issues/issue-52240.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/issue-52240.rs:9:27 - | -LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { - | ^^^^^^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-52240.rs b/src/test/ui/issues/issue-52240.rs index 9ac7e9905da3a..5def557789f0f 100644 --- a/src/test/ui/issues/issue-52240.rs +++ b/src/test/ui/issues/issue-52240.rs @@ -7,7 +7,7 @@ enum Foo { fn main() { let arr = vec!(Foo::Bar(0)); if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { - //~^ ERROR cannot borrow field of immutable binding as mutable + //~^ ERROR cannot borrow data in a `&` reference as mutable *val = 9001; } match arr[0] { diff --git a/src/test/ui/issues/issue-52240.stderr b/src/test/ui/issues/issue-52240.stderr index c2c2524816dc1..69b663b17d340 100644 --- a/src/test/ui/issues/issue-52240.stderr +++ b/src/test/ui/issues/issue-52240.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow field of immutable binding as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/issue-52240.rs:9:27 | LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { - | ^^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/issues/issue-5500-1.ast.stderr b/src/test/ui/issues/issue-5500-1.ast.stderr deleted file mode 100644 index 681ccbc4276a1..0000000000000 --- a/src/test/ui/issues/issue-5500-1.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0594]: cannot assign to field `_iter.node` of immutable binding - --> $DIR/issue-5500-1.rs:12:5 - | -LL | let _iter = TrieMapIterator{node: &a}; - | ----- help: make this binding mutable: `mut _iter` -LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding -LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) -LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK -LL | | // because the test is here to check that the compiler doesn't ICE (cf. #5500). -LL | | panic!() - | |____________^ cannot mutably borrow field of immutable binding - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/issues/issue-5500-1.mir.stderr b/src/test/ui/issues/issue-5500-1.mir.stderr deleted file mode 100644 index 67ca23ca2974b..0000000000000 --- a/src/test/ui/issues/issue-5500-1.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0594]: cannot assign to field `_iter.node` of immutable binding (Ast) - --> $DIR/issue-5500-1.rs:12:5 - | -LL | let _iter = TrieMapIterator{node: &a}; - | ----- help: make this binding mutable: `mut _iter` -LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding -LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) -LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK -LL | | // because the test is here to check that the compiler doesn't ICE (cf. #5500). -LL | | panic!() - | |____________^ cannot mutably borrow field of immutable binding - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/issues/issue-5500-1.rs b/src/test/ui/issues/issue-5500-1.rs index e8043563c7359..56f5ce9901e68 100644 --- a/src/test/ui/issues/issue-5500-1.rs +++ b/src/test/ui/issues/issue-5500-1.rs @@ -1,6 +1,8 @@ -// ignore-compare-mode-nll -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=compare +// MIR doesn't generate an error because the assignment isn't reachable. This +// is OK because the test is here to check that the compiler doesn't ICE (cf. +// #5500). + +// compile-pass struct TrieMapIterator<'a> { node: &'a usize @@ -9,9 +11,5 @@ struct TrieMapIterator<'a> { fn main() { let a = 5; let _iter = TrieMapIterator{node: &a}; - _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding - //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) - // MIR doesn't generate an error because the code isn't reachable. This is OK - // because the test is here to check that the compiler doesn't ICE (cf. #5500). - panic!() + _iter.node = &panic!() } diff --git a/src/test/ui/issues/issue-6801.nll.stderr b/src/test/ui/issues/issue-6801.nll.stderr deleted file mode 100644 index 2c0fedf351a23..0000000000000 --- a/src/test/ui/issues/issue-6801.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/issue-6801.rs:19:13 - | -LL | let sq = || { *x * *x }; - | -- - borrow occurs due to use in closure - | | - | borrow of `x` occurs here -LL | -LL | twice(x); //~ ERROR: cannot move out of - | ^ move out of `x` occurs here -LL | invoke(sq); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/issues/issue-6801.stderr b/src/test/ui/issues/issue-6801.stderr index fa0e1928ba4bd..2c0fedf351a23 100644 --- a/src/test/ui/issues/issue-6801.stderr +++ b/src/test/ui/issues/issue-6801.stderr @@ -2,10 +2,14 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/issue-6801.rs:19:13 | LL | let sq = || { *x * *x }; - | -- borrow of `x` occurs here + | -- - borrow occurs due to use in closure + | | + | borrow of `x` occurs here LL | LL | twice(x); //~ ERROR: cannot move out of | ^ move out of `x` occurs here +LL | invoke(sq); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr deleted file mode 100644 index d70524b2387fd..0000000000000 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion.rs:2:17 - | -LL | let mut x = vec![1].iter(); - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -LL | //~^ ERROR borrowed value does not live long enough -LL | x.use_mut(); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.rs b/src/test/ui/lifetimes/borrowck-let-suggestion.rs index 1deb0457e95af..3d591a506d59e 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.rs +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.rs @@ -1,6 +1,6 @@ fn f() { let mut x = vec![1].iter(); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed x.use_mut(); } diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr index 7a95137ac9274..e089eedb2db38 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr @@ -1,17 +1,17 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion.rs:2:17 | LL | let mut x = vec![1].iter(); - | ^^^^^^^ - temporary value dropped here while still borrowed + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here + | creates a temporary which is freed while still in use +LL | //~^ ERROR temporary value dropped while borrowed +LL | x.use_mut(); + | - borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.nll.stderr deleted file mode 100644 index 9d24570057375..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-loop.rs:9:9 - | -LL | let v: isize; - | - help: make this binding mutable: `mut v` -... -LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.stderr deleted file mode 100644 index 20003b73d3999..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-loop.rs:9:9 - | -LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs index 59447ba3d755a..c9e1851b9a980 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { let v: isize; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut v + //~^ HELP make this binding mutable + //~| SUGGESTION mut v loop { - v = 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable variable - //[mir]~| NOTE cannot assign twice to immutable variable - v.clone(); // just to prevent liveness warnings + v = 1; //~ ERROR cannot assign twice to immutable variable `v` + //~| NOTE cannot assign twice to immutable variable } } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr similarity index 71% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.mir.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr index 9d24570057375..c0d1fd7610b1d 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.mir.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr @@ -1,10 +1,10 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-loop.rs:9:9 + --> $DIR/liveness-assign-imm-local-in-loop.rs:6:9 | LL | let v: isize; | - help: make this binding mutable: `mut v` ... -LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable +LL | v = 1; //~ ERROR cannot assign twice to immutable variable `v` | ^^^^^ cannot assign twice to immutable variable error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.stderr deleted file mode 100644 index 4ab254beb2d86..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-op-eq.rs:10:5 - | -LL | v = 2; //[ast]~ NOTE first assignment - | ----- first assignment to `v` -LL | //[mir]~^ NOTE first assignment -LL | v += 1; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.mir.stderr deleted file mode 100644 index 47b9b029d3171..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-op-eq.rs:10:5 - | -LL | let v: isize; - | - help: make this binding mutable: `mut v` -... -LL | v = 2; //[ast]~ NOTE first assignment - | ----- first assignment to `v` -LL | //[mir]~^ NOTE first assignment -LL | v += 1; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs index a2677f4e22351..f24f7d2bcfc52 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { let v: isize; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut v - v = 2; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - v += 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + //~^ HELP make this binding mutable + //~| SUGGESTION mut v + v = 2; //~ NOTE first assignment + v += 1; //~ ERROR cannot assign twice to immutable variable `v` + //~| NOTE cannot assign twice to immutable v.clone(); } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr similarity index 61% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.nll.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr index 47b9b029d3171..8881740042074 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.nll.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr @@ -1,13 +1,12 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-op-eq.rs:10:5 + --> $DIR/liveness-assign-imm-local-in-op-eq.rs:6:5 | LL | let v: isize; | - help: make this binding mutable: `mut v` ... -LL | v = 2; //[ast]~ NOTE first assignment +LL | v = 2; //~ NOTE first assignment | ----- first assignment to `v` -LL | //[mir]~^ NOTE first assignment -LL | v += 1; //[ast]~ ERROR cannot assign twice to immutable variable +LL | v += 1; //~ ERROR cannot assign twice to immutable variable `v` | ^^^^^^ cannot assign twice to immutable variable error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.stderr deleted file mode 100644 index d543fb9ac6bd7..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/liveness-assign-imm-local-with-drop.rs:10:5 - | -LL | let b = Box::new(1); //[ast]~ NOTE first assignment - | - first assignment to `b` -... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.mir.stderr deleted file mode 100644 index 08a1e9d2bb4ca..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/liveness-assign-imm-local-with-drop.rs:10:5 - | -LL | let b = Box::new(1); //[ast]~ NOTE first assignment - | - - | | - | first assignment to `b` - | help: make this binding mutable: `mut b` -... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - | ^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs index 4a81dcd3cfb54..8963e32717e22 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { - let b = Box::new(1); //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| HELP make this binding mutable - //[mir]~| SUGGESTION mut b + let b = Box::new(1); //~ NOTE first assignment + //~| HELP make this binding mutable + //~| SUGGESTION mut b drop(b); - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` + //~| NOTE cannot assign twice to immutable drop(b); } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr similarity index 63% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.nll.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr index 08a1e9d2bb4ca..e827e2275432e 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.nll.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr @@ -1,13 +1,13 @@ error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/liveness-assign-imm-local-with-drop.rs:10:5 + --> $DIR/liveness-assign-imm-local-with-drop.rs:6:5 | -LL | let b = Box::new(1); //[ast]~ NOTE first assignment +LL | let b = Box::new(1); //~ NOTE first assignment | - | | | first assignment to `b` | help: make this binding mutable: `mut b` ... -LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable +LL | b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` | ^ cannot assign twice to immutable variable error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.nll.stderr deleted file mode 100644 index 3c1a5692fece7..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-with-init.rs:10:5 - | -LL | let v: isize = 1; //[ast]~ NOTE first assignment - | - - | | - | first assignment to `v` - | help: make this binding mutable: `mut v` -... -LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.stderr deleted file mode 100644 index cf293ae9f2f70..0000000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-with-init.rs:10:5 - | -LL | let v: isize = 1; //[ast]~ NOTE first assignment - | - first assignment to `v` -... -LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs index 2c59aaf4f92d5..4ab222af8d088 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { - let v: isize = 1; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| HELP make this binding mutable - //[mir]~| SUGGESTION mut v + let v: isize = 1; //~ NOTE first assignment + //~| HELP make this binding mutable + //~| SUGGESTION mut v v.clone(); - v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + v = 2; //~ ERROR cannot assign twice to immutable variable `v` + //~| NOTE cannot assign twice to immutable v.clone(); } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr similarity index 65% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.mir.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr index 3c1a5692fece7..1f1f3b4969f5f 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.mir.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr @@ -1,13 +1,13 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-with-init.rs:10:5 + --> $DIR/liveness-assign-imm-local-with-init.rs:6:5 | -LL | let v: isize = 1; //[ast]~ NOTE first assignment +LL | let v: isize = 1; //~ NOTE first assignment | - | | | first assignment to `v` | help: make this binding mutable: `mut v` ... -LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable +LL | v = 2; //~ ERROR cannot assign twice to immutable variable `v` | ^^^^^ cannot assign twice to immutable variable error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-move-call-arg.nll.stderr b/src/test/ui/liveness/liveness-move-call-arg.nll.stderr deleted file mode 100644 index 521304d560554..0000000000000 --- a/src/test/ui/liveness/liveness-move-call-arg.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/liveness-move-call-arg.rs:9:14 - | -LL | let x: Box = box 25; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | loop { -LL | take(x); //~ ERROR use of moved value: `x` - | ^ value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-move-call-arg.stderr b/src/test/ui/liveness/liveness-move-call-arg.stderr index 21d285463e384..521304d560554 100644 --- a/src/test/ui/liveness/liveness-move-call-arg.stderr +++ b/src/test/ui/liveness/liveness-move-call-arg.stderr @@ -1,10 +1,11 @@ error[E0382]: use of moved value: `x` --> $DIR/liveness-move-call-arg.rs:9:14 | +LL | let x: Box = box 25; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +LL | loop { LL | take(x); //~ ERROR use of moved value: `x` - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value moved here, in previous iteration of loop error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-move-in-loop.nll.stderr b/src/test/ui/liveness/liveness-move-in-loop.nll.stderr deleted file mode 100644 index b7e973bc9140d..0000000000000 --- a/src/test/ui/liveness/liveness-move-in-loop.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0382]: use of moved value: `y` - --> $DIR/liveness-move-in-loop.rs:11:25 - | -LL | let y: Box = box 42; - | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | x = y; //~ ERROR use of moved value - | ^ value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-move-in-loop.stderr b/src/test/ui/liveness/liveness-move-in-loop.stderr index d00c2d6ac35ec..b7e973bc9140d 100644 --- a/src/test/ui/liveness/liveness-move-in-loop.stderr +++ b/src/test/ui/liveness/liveness-move-in-loop.stderr @@ -1,10 +1,11 @@ error[E0382]: use of moved value: `y` --> $DIR/liveness-move-in-loop.rs:11:25 | +LL | let y: Box = box 42; + | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | x = y; //~ ERROR use of moved value - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value moved here, in previous iteration of loop error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-move-in-while.nll.stderr b/src/test/ui/liveness/liveness-move-in-while.nll.stderr deleted file mode 100644 index 167dcc6b64372..0000000000000 --- a/src/test/ui/liveness/liveness-move-in-while.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `y` - --> $DIR/liveness-move-in-while.rs:7:24 - | -LL | let y: Box = box 42; - | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | println!("{}", y); //~ ERROR use of moved value: `y` - | ^ value borrowed here after move -LL | while true { while true { while true { x = y; x.clone(); } } } - | - value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-move-in-while.rs b/src/test/ui/liveness/liveness-move-in-while.rs index a43e75982a1d1..420d1311f8b1f 100644 --- a/src/test/ui/liveness/liveness-move-in-while.rs +++ b/src/test/ui/liveness/liveness-move-in-while.rs @@ -4,8 +4,7 @@ fn main() { let y: Box = box 42; let mut x: Box; loop { - println!("{}", y); //~ ERROR use of moved value: `y` + println!("{}", y); //~ ERROR borrow of moved value: `y` while true { while true { while true { x = y; x.clone(); } } } - //~^ ERROR use of moved value: `y` } } diff --git a/src/test/ui/liveness/liveness-move-in-while.stderr b/src/test/ui/liveness/liveness-move-in-while.stderr index 91f722cb42288..3cf1a54571b20 100644 --- a/src/test/ui/liveness/liveness-move-in-while.stderr +++ b/src/test/ui/liveness/liveness-move-in-while.stderr @@ -1,21 +1,14 @@ -error[E0382]: use of moved value: `y` +error[E0382]: borrow of moved value: `y` --> $DIR/liveness-move-in-while.rs:7:24 | -LL | println!("{}", y); //~ ERROR use of moved value: `y` - | ^ value used here after move +LL | let y: Box = box 42; + | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait +... +LL | println!("{}", y); //~ ERROR borrow of moved value: `y` + | ^ value borrowed here after move LL | while true { while true { while true { x = y; x.clone(); } } } - | - value moved here - | - = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `y` - --> $DIR/liveness-move-in-while.rs:8:52 - | -LL | while true { while true { while true { x = y; x.clone(); } } } - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + | - value moved here, in previous iteration of loop -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-use-after-move.nll.stderr b/src/test/ui/liveness/liveness-use-after-move.nll.stderr deleted file mode 100644 index 36c25882ccd4f..0000000000000 --- a/src/test/ui/liveness/liveness-use-after-move.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/liveness-use-after-move.rs:6:20 - | -LL | let x: Box<_> = box 5; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | let y = x; - | - value moved here -LL | println!("{}", *x); //~ ERROR use of moved value: `*x` - | ^^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-use-after-move.rs b/src/test/ui/liveness/liveness-use-after-move.rs index 157587c7a7b54..5263e293603cd 100644 --- a/src/test/ui/liveness/liveness-use-after-move.rs +++ b/src/test/ui/liveness/liveness-use-after-move.rs @@ -3,6 +3,6 @@ fn main() { let x: Box<_> = box 5; let y = x; - println!("{}", *x); //~ ERROR use of moved value: `*x` + println!("{}", *x); //~ ERROR borrow of moved value: `x` y.clone(); } diff --git a/src/test/ui/liveness/liveness-use-after-move.stderr b/src/test/ui/liveness/liveness-use-after-move.stderr index 62475943d0e3d..7e25e18e1bcd3 100644 --- a/src/test/ui/liveness/liveness-use-after-move.stderr +++ b/src/test/ui/liveness/liveness-use-after-move.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `*x` +error[E0382]: borrow of moved value: `x` --> $DIR/liveness-use-after-move.rs:6:20 | +LL | let x: Box<_> = box 5; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | let y = x; - | - value moved here -LL | println!("{}", *x); //~ ERROR use of moved value: `*x` - | ^^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | - value moved here +LL | println!("{}", *x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-use-after-send.nll.stderr b/src/test/ui/liveness/liveness-use-after-send.nll.stderr deleted file mode 100644 index d9367c871165a..0000000000000 --- a/src/test/ui/liveness/liveness-use-after-send.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `message` - --> $DIR/liveness-use-after-send.rs:16:20 - | -LL | fn test00_start(ch: Chan>, message: Box, _count: Box) { - | ------- move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | send(ch, message); - | ------- value moved here -LL | println!("{}", message); //~ ERROR use of moved value: `message` - | ^^^^^^^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-use-after-send.rs b/src/test/ui/liveness/liveness-use-after-send.rs index 7f2cc3c00f459..6fcd91a9d9b2e 100644 --- a/src/test/ui/liveness/liveness-use-after-send.rs +++ b/src/test/ui/liveness/liveness-use-after-send.rs @@ -13,7 +13,7 @@ struct Chan(isize, marker::PhantomData); // message after the send deinitializes it fn test00_start(ch: Chan>, message: Box, _count: Box) { send(ch, message); - println!("{}", message); //~ ERROR use of moved value: `message` + println!("{}", message); //~ ERROR borrow of moved value: `message` } fn main() { panic!(); } diff --git a/src/test/ui/liveness/liveness-use-after-send.stderr b/src/test/ui/liveness/liveness-use-after-send.stderr index 1fdb1d3ec39bc..331e9f7233323 100644 --- a/src/test/ui/liveness/liveness-use-after-send.stderr +++ b/src/test/ui/liveness/liveness-use-after-send.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `message` +error[E0382]: borrow of moved value: `message` --> $DIR/liveness-use-after-send.rs:16:20 | +LL | fn test00_start(ch: Chan>, message: Box, _count: Box) { + | ------- move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | send(ch, message); | ------- value moved here -LL | println!("{}", message); //~ ERROR use of moved value: `message` - | ^^^^^^^ value used here after move - | - = note: move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait +LL | println!("{}", message); //~ ERROR borrow of moved value: `message` + | ^^^^^^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/loops/loop-proper-liveness.nll.stderr b/src/test/ui/loops/loop-proper-liveness.nll.stderr deleted file mode 100644 index 745f0876b404d..0000000000000 --- a/src/test/ui/loops/loop-proper-liveness.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/loop-proper-liveness.rs:9:22 - | -LL | println!("{:?}", x); //~ ERROR use of possibly uninitialized variable - | ^ use of possibly uninitialized `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/loops/loop-proper-liveness.rs b/src/test/ui/loops/loop-proper-liveness.rs index fd9d6612220c7..b8f76fbe57ba3 100644 --- a/src/test/ui/loops/loop-proper-liveness.rs +++ b/src/test/ui/loops/loop-proper-liveness.rs @@ -6,7 +6,7 @@ fn test1() { 'a: loop { x = loop { break 'a }; } - println!("{:?}", x); //~ ERROR use of possibly uninitialized variable + println!("{:?}", x); //~ ERROR borrow of possibly uninitialized variable } // test2 and test3 should not fail. diff --git a/src/test/ui/loops/loop-proper-liveness.stderr b/src/test/ui/loops/loop-proper-liveness.stderr index b8fb3fe00ee54..d5bb0b594366d 100644 --- a/src/test/ui/loops/loop-proper-liveness.stderr +++ b/src/test/ui/loops/loop-proper-liveness.stderr @@ -1,7 +1,7 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/loop-proper-liveness.rs:9:22 | -LL | println!("{:?}", x); //~ ERROR use of possibly uninitialized variable +LL | println!("{:?}", x); //~ ERROR borrow of possibly uninitialized variable | ^ use of possibly uninitialized `x` error: aborting due to previous error diff --git a/src/test/ui/macros/span-covering-argument-1.nll.stderr b/src/test/ui/macros/span-covering-argument-1.nll.stderr deleted file mode 100644 index 2ac881107b96a..0000000000000 --- a/src/test/ui/macros/span-covering-argument-1.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable - --> $DIR/span-covering-argument-1.rs:5:14 - | -LL | let $s = 0; - | -- help: consider changing this to be mutable: `mut foo` -LL | *&mut $s = 0; - | ^^^^^^^ cannot borrow as mutable -... -LL | bad!(foo whatever); - | ------------------- in this macro invocation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/macros/span-covering-argument-1.rs b/src/test/ui/macros/span-covering-argument-1.rs index 0256aaf901e3a..9b9506c80b150 100644 --- a/src/test/ui/macros/span-covering-argument-1.rs +++ b/src/test/ui/macros/span-covering-argument-1.rs @@ -3,7 +3,7 @@ macro_rules! bad { { let $s = 0; *&mut $s = 0; - //~^ ERROR cannot borrow immutable local variable `foo` as mutable [E0596] + //~^ ERROR cannot borrow `foo` as mutable, as it is not declared as mutable [E0596] } } } diff --git a/src/test/ui/macros/span-covering-argument-1.stderr b/src/test/ui/macros/span-covering-argument-1.stderr index 345b880ccad9b..2ac881107b96a 100644 --- a/src/test/ui/macros/span-covering-argument-1.stderr +++ b/src/test/ui/macros/span-covering-argument-1.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `foo` as mutable - --> $DIR/span-covering-argument-1.rs:5:19 +error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable + --> $DIR/span-covering-argument-1.rs:5:14 | LL | let $s = 0; - | -- help: make this binding mutable: `mut $s` + | -- help: consider changing this to be mutable: `mut foo` LL | *&mut $s = 0; - | ^^ cannot borrow mutably + | ^^^^^^^ cannot borrow as mutable ... LL | bad!(foo whatever); | ------------------- in this macro invocation diff --git a/src/test/ui/methods/method-self-arg-2.nll.stderr b/src/test/ui/methods/method-self-arg-2.nll.stderr deleted file mode 100644 index 8cfecdba41c0a..0000000000000 --- a/src/test/ui/methods/method-self-arg-2.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/method-self-arg-2.rs:15:14 - | -LL | let y = &mut x; - | ------ mutable borrow occurs here -LL | Foo::bar(&x); //~ERROR cannot borrow `x` - | ^^ immutable borrow occurs here -LL | y.use_mut(); - | - mutable borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/method-self-arg-2.rs:20:14 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | Foo::baz(&mut x); //~ERROR cannot borrow `x` - | ^^^^^^ second mutable borrow occurs here -LL | y.use_mut(); - | - first borrow later used here - -error: aborting due to 2 previous errors - -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/methods/method-self-arg-2.stderr b/src/test/ui/methods/method-self-arg-2.stderr index 9746ac316d92f..8cfecdba41c0a 100644 --- a/src/test/ui/methods/method-self-arg-2.stderr +++ b/src/test/ui/methods/method-self-arg-2.stderr @@ -1,24 +1,22 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/method-self-arg-2.rs:15:15 + --> $DIR/method-self-arg-2.rs:15:14 | LL | let y = &mut x; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | Foo::bar(&x); //~ERROR cannot borrow `x` - | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^ immutable borrow occurs here +LL | y.use_mut(); + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/method-self-arg-2.rs:20:19 + --> $DIR/method-self-arg-2.rs:20:14 | LL | let y = &mut x; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | Foo::baz(&mut x); //~ERROR cannot borrow `x` - | ^ second mutable borrow occurs here + | ^^^^^^ second mutable borrow occurs here LL | y.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/move-guard-same-consts.nll.stderr b/src/test/ui/moves/move-guard-same-consts.nll.stderr deleted file mode 100644 index 43f99cabcae94..0000000000000 --- a/src/test/ui/moves/move-guard-same-consts.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/move-guard-same-consts.rs:20:24 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | (1, 2) if take(x) => (), - | - value moved here -LL | (1, 2) if take(x) => (), //~ ERROR use of moved value: `x` - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/move-guard-same-consts.stderr b/src/test/ui/moves/move-guard-same-consts.stderr index 78a76a47b8a52..43f99cabcae94 100644 --- a/src/test/ui/moves/move-guard-same-consts.stderr +++ b/src/test/ui/moves/move-guard-same-consts.stderr @@ -1,12 +1,13 @@ error[E0382]: use of moved value: `x` --> $DIR/move-guard-same-consts.rs:20:24 | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | (1, 2) if take(x) => (), | - value moved here LL | (1, 2) if take(x) => (), //~ ERROR use of moved value: `x` | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/moves/move-in-guard-1.nll.stderr b/src/test/ui/moves/move-in-guard-1.nll.stderr deleted file mode 100644 index 41abe6fa72a57..0000000000000 --- a/src/test/ui/moves/move-in-guard-1.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/move-in-guard-1.rs:10:24 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | (1, _) if take(x) => (), - | - value moved here -LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/move-in-guard-1.stderr b/src/test/ui/moves/move-in-guard-1.stderr index d4cb538e05d1c..41abe6fa72a57 100644 --- a/src/test/ui/moves/move-in-guard-1.stderr +++ b/src/test/ui/moves/move-in-guard-1.stderr @@ -1,12 +1,13 @@ error[E0382]: use of moved value: `x` --> $DIR/move-in-guard-1.rs:10:24 | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | (1, _) if take(x) => (), | - value moved here LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/moves/move-in-guard-2.nll.stderr b/src/test/ui/moves/move-in-guard-2.nll.stderr deleted file mode 100644 index 0b14c1620d3cf..0000000000000 --- a/src/test/ui/moves/move-in-guard-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/move-in-guard-2.rs:10:24 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` - | ^ value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/move-in-guard-2.stderr b/src/test/ui/moves/move-in-guard-2.stderr index d4e747c9f61d0..0b14c1620d3cf 100644 --- a/src/test/ui/moves/move-in-guard-2.stderr +++ b/src/test/ui/moves/move-in-guard-2.stderr @@ -1,10 +1,11 @@ error[E0382]: use of moved value: `x` --> $DIR/move-in-guard-2.rs:10:24 | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value moved here, in previous iteration of loop error: aborting due to previous error diff --git a/src/test/ui/moves/move-into-dead-array-1.nll.stderr b/src/test/ui/moves/move-into-dead-array-1.nll.stderr deleted file mode 100644 index e3a2a601246d4..0000000000000 --- a/src/test/ui/moves/move-into-dead-array-1.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `a` - --> $DIR/move-into-dead-array-1.rs:14:5 - | -LL | a[i] = d(); //~ ERROR use of possibly uninitialized variable: `a` - | ^^^^ use of possibly uninitialized `a` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/moves/move-into-dead-array-1.stderr b/src/test/ui/moves/move-into-dead-array-1.stderr index 36f98a76b5473..e3a2a601246d4 100644 --- a/src/test/ui/moves/move-into-dead-array-1.stderr +++ b/src/test/ui/moves/move-into-dead-array-1.stderr @@ -2,7 +2,7 @@ error[E0381]: use of possibly uninitialized variable: `a` --> $DIR/move-into-dead-array-1.rs:14:5 | LL | a[i] = d(); //~ ERROR use of possibly uninitialized variable: `a` - | ^^^^^^^^^^ use of possibly uninitialized `a` + | ^^^^ use of possibly uninitialized `a` error: aborting due to previous error diff --git a/src/test/ui/moves/move-into-dead-array-2.nll.stderr b/src/test/ui/moves/move-into-dead-array-2.nll.stderr deleted file mode 100644 index 20bfdc2bbac72..0000000000000 --- a/src/test/ui/moves/move-into-dead-array-2.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `a` - --> $DIR/move-into-dead-array-2.rs:14:5 - | -LL | fn foo(mut a: [D; 4], i: usize) { - | ----- move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait -LL | drop(a); - | - value moved here -LL | a[i] = d(); //~ ERROR use of moved value: `a` - | ^^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/move-into-dead-array-2.stderr b/src/test/ui/moves/move-into-dead-array-2.stderr index 417b1ab205407..20bfdc2bbac72 100644 --- a/src/test/ui/moves/move-into-dead-array-2.stderr +++ b/src/test/ui/moves/move-into-dead-array-2.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `a` --> $DIR/move-into-dead-array-2.rs:14:5 | +LL | fn foo(mut a: [D; 4], i: usize) { + | ----- move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait LL | drop(a); | - value moved here LL | a[i] = d(); //~ ERROR use of moved value: `a` - | ^^^^^^^^^^ value used here after move - | - = note: move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait + | ^^^^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/moves/move-out-of-slice-1.nll.stderr b/src/test/ui/moves/move-out-of-slice-1.nll.stderr deleted file mode 100644 index c8c09b31d36b8..0000000000000 --- a/src/test/ui/moves/move-out-of-slice-1.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-1.rs:7:11 - | -LL | match a { - | ^ cannot move out of here -LL | box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice - | - data moved here - | -note: move occurs because `a` has type `A`, which does not implement the `Copy` trait - --> $DIR/move-out-of-slice-1.rs:8:14 - | -LL | box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/moves/move-out-of-slice-1.rs b/src/test/ui/moves/move-out-of-slice-1.rs index 3e0906060e601..982648f5b237c 100644 --- a/src/test/ui/moves/move-out-of-slice-1.rs +++ b/src/test/ui/moves/move-out-of-slice-1.rs @@ -4,8 +4,8 @@ struct A; fn main() { let a: Box<[A]> = Box::new([A]); - match a { - box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice + match a { //~ ERROR cannot move out of type `[A]`, a non-copy slice + box [a] => {}, _ => {} } } diff --git a/src/test/ui/moves/move-out-of-slice-1.stderr b/src/test/ui/moves/move-out-of-slice-1.stderr index bfdf641986908..c1b97b843cd2c 100644 --- a/src/test/ui/moves/move-out-of-slice-1.stderr +++ b/src/test/ui/moves/move-out-of-slice-1.stderr @@ -1,11 +1,16 @@ error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-1.rs:8:13 + --> $DIR/move-out-of-slice-1.rs:7:11 | -LL | box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice - | ^-^ - | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of here +LL | match a { //~ ERROR cannot move out of type `[A]`, a non-copy slice + | ^ cannot move out of here +LL | box [a] => {}, + | - data moved here + | +note: move occurs because `a` has type `A`, which does not implement the `Copy` trait + --> $DIR/move-out-of-slice-1.rs:8:14 + | +LL | box [a] => {}, + | ^ error: aborting due to previous error diff --git a/src/test/ui/moves/move-out-of-tuple-field.nll.stderr b/src/test/ui/moves/move-out-of-tuple-field.nll.stderr deleted file mode 100644 index 2efdc84ca37d1..0000000000000 --- a/src/test/ui/moves/move-out-of-tuple-field.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:8:13 - | -LL | let y = x.0; - | --- value moved here -LL | let z = x.0; //~ ERROR use of moved value: `x.0` - | ^^^ value used here after move - | - = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:12:13 - | -LL | let y = x.0; - | --- value moved here -LL | let z = x.0; //~ ERROR use of moved value: `x.0` - | ^^^ value used here after move - | - = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/move-out-of-tuple-field.stderr b/src/test/ui/moves/move-out-of-tuple-field.stderr index 6839c49c82963..2efdc84ca37d1 100644 --- a/src/test/ui/moves/move-out-of-tuple-field.stderr +++ b/src/test/ui/moves/move-out-of-tuple-field.stderr @@ -1,20 +1,20 @@ error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:8:9 + --> $DIR/move-out-of-tuple-field.rs:8:13 | LL | let y = x.0; - | - value moved here + | --- value moved here LL | let z = x.0; //~ ERROR use of moved value: `x.0` - | ^ value used here after move + | ^^^ value used here after move | = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:12:9 + --> $DIR/move-out-of-tuple-field.rs:12:13 | LL | let y = x.0; - | - value moved here + | --- value moved here LL | let z = x.0; //~ ERROR use of moved value: `x.0` - | ^ value used here after move + | ^^^ value used here after move | = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.nll.stderr b/src/test/ui/moves/moves-based-on-type-access-to-field.nll.stderr deleted file mode 100644 index 6ad9a2d414c77..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-access-to-field.rs:11:12 - | -LL | let x = vec!["hi".to_string()]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | consume(x.into_iter().next().unwrap()); - | - value moved here -LL | touch(&x[0]); //~ ERROR use of moved value: `x` - | ^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.rs b/src/test/ui/moves/moves-based-on-type-access-to-field.rs index c7ea357a5d9a0..e2003ed6e4716 100644 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.rs +++ b/src/test/ui/moves/moves-based-on-type-access-to-field.rs @@ -8,7 +8,7 @@ fn touch(_a: &A) {} fn f20() { let x = vec!["hi".to_string()]; consume(x.into_iter().next().unwrap()); - touch(&x[0]); //~ ERROR use of moved value: `x` + touch(&x[0]); //~ ERROR borrow of moved value: `x` } fn main() {} diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr index 882c1fe1706d2..c53e297778c6c 100644 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr +++ b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-access-to-field.rs:11:12 | +LL | let x = vec!["hi".to_string()]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | consume(x.into_iter().next().unwrap()); | - value moved here -LL | touch(&x[0]); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait +LL | touch(&x[0]); //~ ERROR borrow of moved value: `x` + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr b/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr deleted file mode 100644 index 6950a56a5335a..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/moves-based-on-type-block-bad.rs:24:19 - | -LL | match hellothere.x { //~ ERROR cannot move out - | ^^^^^^^^^^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&hellothere.x` -... -LL | box E::Bar(x) => println!("{}", x.to_string()), - | - data moved here - | -note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/moves-based-on-type-block-bad.rs:27:28 - | -LL | box E::Bar(x) => println!("{}", x.to_string()), - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.stderr b/src/test/ui/moves/moves-based-on-type-block-bad.stderr index 4ecaed3b69b54..6950a56a5335a 100644 --- a/src/test/ui/moves/moves-based-on-type-block-bad.stderr +++ b/src/test/ui/moves/moves-based-on-type-block-bad.stderr @@ -2,10 +2,19 @@ error[E0507]: cannot move out of borrowed content --> $DIR/moves-based-on-type-block-bad.rs:24:19 | LL | match hellothere.x { //~ ERROR cannot move out - | ^^^^^^^^^^ cannot move out of borrowed content + | ^^^^^^^^^^^^ + | | + | cannot move out of borrowed content + | help: consider borrowing here: `&hellothere.x` ... LL | box E::Bar(x) => println!("{}", x.to_string()), - | - hint: to prevent move, use `ref x` or `ref mut x` + | - data moved here + | +note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + --> $DIR/moves-based-on-type-block-bad.rs:27:28 + | +LL | box E::Bar(x) => println!("{}", x.to_string()), + | ^ error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.nll.stderr b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.nll.stderr deleted file mode 100644 index bed0ae7275cc5..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-capture-clause-bad.rs:8:20 - | -LL | let x = "Hello world!".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | println!("{}", x); - | - variable moved due to use in closure -LL | }); -LL | println!("{}", x); //~ ERROR use of moved value - | ^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs index d5f44a0b3f75d..b2f68352f896c 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs +++ b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs @@ -5,5 +5,5 @@ fn main() { thread::spawn(move|| { println!("{}", x); }); - println!("{}", x); //~ ERROR use of moved value + println!("{}", x); //~ ERROR borrow of moved value } diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr index 88e58fdf58bcd..50d40231ca2d1 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr +++ b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr @@ -1,13 +1,15 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-capture-clause-bad.rs:8:20 | +LL | let x = "Hello world!".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | thread::spawn(move|| { - | ------ value moved (into closure) here -... -LL | println!("{}", x); //~ ERROR use of moved value - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ------ value moved into closure here +LL | println!("{}", x); + | - variable moved due to use in closure +LL | }); +LL | println!("{}", x); //~ ERROR borrow of moved value + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.nll.stderr b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.nll.stderr deleted file mode 100644 index 5f0d2b42671de..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: use of moved value: `node` - --> $DIR/moves-based-on-type-cyclic-types-issue-4821.rs:13:13 - | -LL | Some(right) => consume(right), - | ----- value moved here -... -LL | consume(node) + r //~ ERROR use of partially moved value: `node` - | ^^^^ value used here after partial move - | - = note: move occurs because value has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs index 4417fb926d96d..b070671cb250e 100644 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs +++ b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs @@ -10,7 +10,7 @@ fn foo(node: Box) -> isize { Some(right) => consume(right), None => 0 }; - consume(node) + r //~ ERROR use of partially moved value: `node` + consume(node) + r //~ ERROR use of moved value: `node` } fn consume(v: Box) -> isize { diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr index 7624ba5fe28d9..454ae79ba66e8 100644 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr +++ b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr @@ -1,13 +1,13 @@ -error[E0382]: use of partially moved value: `node` +error[E0382]: use of moved value: `node` --> $DIR/moves-based-on-type-cyclic-types-issue-4821.rs:13:13 | LL | Some(right) => consume(right), | ----- value moved here ... -LL | consume(node) + r //~ ERROR use of partially moved value: `node` - | ^^^^ value used here after move +LL | consume(node) + r //~ ERROR use of moved value: `node` + | ^^^^ value used here after partial move | - = note: move occurs because the value has type `std::boxed::Box`, which does not implement the `Copy` trait + = note: move occurs because value has type `std::boxed::Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.nll.stderr b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.nll.stderr deleted file mode 100644 index 07f40274f9e31..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:11:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = Foo { f:x }; - | - value moved here -LL | //~^ NOTE value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:20:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = Foo { f:(((x))) }; - | ------- value moved here -LL | //~^ NOTE value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs index 7c7ca0044e29c..0b44ca56ced47 100644 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs +++ b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs @@ -6,20 +6,20 @@ fn touch(_a: &A) {} fn f00() { let x = "hi".to_string(); + //~^ NOTE move occurs because `x` has type `std::string::String` let _y = Foo { f:x }; //~^ NOTE value moved here - touch(&x); //~ ERROR use of moved value: `x` - //~^ NOTE value used here after move - //~| NOTE move occurs because `x` has type `std::string::String` + touch(&x); //~ ERROR borrow of moved value: `x` + //~^ NOTE value borrowed here after move } fn f05() { let x = "hi".to_string(); + //~^ NOTE move occurs because `x` has type `std::string::String` let _y = Foo { f:(((x))) }; //~^ NOTE value moved here - touch(&x); //~ ERROR use of moved value: `x` - //~^ NOTE value used here after move - //~| NOTE move occurs because `x` has type `std::string::String` + touch(&x); //~ ERROR borrow of moved value: `x` + //~^ NOTE value borrowed here after move } fn f10() { diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr index 374ac61e7f5e9..dbc1c05a41652 100644 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr +++ b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr @@ -1,24 +1,26 @@ -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:11:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:12:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | //~^ NOTE move occurs because `x` has type `std::string::String` LL | let _y = Foo { f:x }; | - value moved here LL | //~^ NOTE value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:20:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | //~^ NOTE move occurs because `x` has type `std::string::String` LL | let _y = Foo { f:(((x))) }; | ------- value moved here LL | //~^ NOTE value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-exprs.nll.stderr b/src/test/ui/moves/moves-based-on-type-exprs.nll.stderr deleted file mode 100644 index 162aec45f5f57..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-exprs.nll.stderr +++ /dev/null @@ -1,123 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:12:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = Foo { f:x }; - | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:18:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = (x, 3); - | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:35:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | x - | - value moved here -... -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:36:11 - | -LL | let y = "ho".to_string(); - | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | y - | - value moved here -... -LL | touch(&y); //~ ERROR use of moved value: `y` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:46:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | true => x, - | - value moved here -... -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:47:11 - | -LL | let y = "ho".to_string(); - | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | false => y - | - value moved here -... -LL | touch(&y); //~ ERROR use of moved value: `y` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:58:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | _ if guard(x) => 10, - | - value moved here -... -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:65:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = [x]; - | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:71:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = vec![x]; - | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:77:11 - | -LL | let x = vec!["hi".to_string()]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let _y = x.into_iter().next().unwrap(); - | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:83:11 - | -LL | let x = vec!["hi".to_string()]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let _y = [x.into_iter().next().unwrap(); 1]; - | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^^ value borrowed here after move - -error: aborting due to 11 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-exprs.rs b/src/test/ui/moves/moves-based-on-type-exprs.rs index b058f83291b10..4a52d8d32064f 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.rs +++ b/src/test/ui/moves/moves-based-on-type-exprs.rs @@ -9,13 +9,13 @@ fn touch(_a: &A) {} fn f10() { let x = "hi".to_string(); let _y = Foo { f:x }; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f20() { let x = "hi".to_string(); let _y = (x, 3); - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f21() { @@ -32,8 +32,8 @@ fn f30(cond: bool) { } else { y }; - touch(&x); //~ ERROR use of moved value: `x` - touch(&y); //~ ERROR use of moved value: `y` + touch(&x); //~ ERROR borrow of moved value: `x` + touch(&y); //~ ERROR borrow of moved value: `y` } fn f40(cond: bool) { @@ -43,8 +43,8 @@ fn f40(cond: bool) { true => x, false => y }; - touch(&x); //~ ERROR use of moved value: `x` - touch(&y); //~ ERROR use of moved value: `y` + touch(&x); //~ ERROR borrow of moved value: `x` + touch(&y); //~ ERROR borrow of moved value: `y` } fn f50(cond: bool) { @@ -55,32 +55,32 @@ fn f50(cond: bool) { true => 10, false => 20, }; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` touch(&y); } fn f70() { let x = "hi".to_string(); let _y = [x]; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f80() { let x = "hi".to_string(); let _y = vec![x]; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f100() { let x = vec!["hi".to_string()]; let _y = x.into_iter().next().unwrap(); - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f110() { let x = vec!["hi".to_string()]; let _y = [x.into_iter().next().unwrap(); 1]; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f120() { diff --git a/src/test/ui/moves/moves-based-on-type-exprs.stderr b/src/test/ui/moves/moves-based-on-type-exprs.stderr index e6177c6b6c836..70c63b9611536 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.stderr +++ b/src/test/ui/moves/moves-based-on-type-exprs.stderr @@ -1,117 +1,122 @@ -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:12:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:12:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = Foo { f:x }; | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:18:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:18:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = (x, 3); | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:35:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:35:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +... LL | x | - value moved here ... -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:36:12 +error[E0382]: borrow of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:36:11 | +LL | let y = "ho".to_string(); + | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait +... LL | y | - value moved here ... -LL | touch(&y); //~ ERROR use of moved value: `y` - | ^ value used here after move - | - = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&y); //~ ERROR borrow of moved value: `y` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:46:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:46:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +... LL | true => x, | - value moved here ... -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:47:12 +error[E0382]: borrow of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:47:11 | +LL | let y = "ho".to_string(); + | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait +... LL | false => y | - value moved here ... -LL | touch(&y); //~ ERROR use of moved value: `y` - | ^ value used here after move - | - = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&y); //~ ERROR borrow of moved value: `y` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:58:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:58:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +... LL | _ if guard(x) => 10, | - value moved here ... -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:65:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:65:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = [x]; | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:71:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:71:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = vec![x]; | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:77:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:77:11 | +LL | let x = vec!["hi".to_string()]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let _y = x.into_iter().next().unwrap(); | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:83:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:83:11 | +LL | let x = vec!["hi".to_string()]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let _y = [x.into_iter().next().unwrap(); 1]; | - value moved here -LL | touch(&x); //~ ERROR use of moved value: `x` - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after move error: aborting due to 11 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.nll.stderr b/src/test/ui/moves/moves-based-on-type-match-bindings.nll.stderr deleted file mode 100644 index 6d523fc09c08b..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-match-bindings.rs:16:11 - | -LL | Foo {f} => {} - | - value moved here -... -LL | touch(&x); //~ ERROR use of partially moved value: `x` - | ^^ value borrowed here after partial move - | - = note: move occurs because `x.f` has type `std::string::String`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.rs b/src/test/ui/moves/moves-based-on-type-match-bindings.rs index 59e5a8f684e9a..1290d4a25abc4 100644 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.rs +++ b/src/test/ui/moves/moves-based-on-type-match-bindings.rs @@ -13,8 +13,8 @@ fn f10() { Foo {f} => {} }; - touch(&x); //~ ERROR use of partially moved value: `x` - //~^ value used here after move + touch(&x); //~ ERROR borrow of moved value: `x` + //~^ value borrowed here after partial move //~| move occurs because `x.f` has type `std::string::String` } diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr index 41ced9dfd935b..e71e69b622db4 100644 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr +++ b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr @@ -1,11 +1,11 @@ -error[E0382]: use of partially moved value: `x` - --> $DIR/moves-based-on-type-match-bindings.rs:16:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-match-bindings.rs:16:11 | LL | Foo {f} => {} | - value moved here ... -LL | touch(&x); //~ ERROR use of partially moved value: `x` - | ^ value used here after move +LL | touch(&x); //~ ERROR borrow of moved value: `x` + | ^^ value borrowed here after partial move | = note: move occurs because `x.f` has type `std::string::String`, which does not implement the `Copy` trait diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr deleted file mode 100644 index 7d410f6cabc83..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:11:28 - | -LL | let i = box 3; - | - captured outer variable -LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out - | ^ cannot move out of captured variable in an `Fn` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr index 49113a57d2fa5..7d410f6cabc83 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr +++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr @@ -1,10 +1,10 @@ -error[E0507]: cannot move out of captured outer variable in an `Fn` closure +error[E0507]: cannot move out of captured variable in an `Fn` closure --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:11:28 | LL | let i = box 3; | - captured outer variable LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr deleted file mode 100644 index 391dd67dbf60a..0000000000000 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:20:27 - | -LL | (f.c)(f, true); - | ----- ^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error[E0382]: borrow of moved value: `f` - --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:32:5 - | -LL | fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { - | - ----- move occurs because `f` has type `F`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | let mut r = R {c: Box::new(f)}; - | - value moved here -LL | f(&mut r, false) //~ ERROR use of moved value - | ^ value borrowed here after move - -error: aborting due to 2 previous errors - -Some errors occurred: E0382, E0499. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs index 737a131c9bf6a..3fa11878629c3 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs @@ -29,7 +29,7 @@ fn innocent_looking_victim() { fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { let mut r = R {c: Box::new(f)}; - f(&mut r, false) //~ ERROR use of moved value + f(&mut r, false) //~ ERROR borrow of moved value } fn main() { innocent_looking_victim() } diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr index 05ced7f0107ae..157531aedd67d 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr @@ -2,20 +2,22 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:20:27 | LL | (f.c)(f, true); - | ----- ^ - first borrow ends here - | | | - | | second mutable borrow occurs here + | ----- ^ second mutable borrow occurs here + | | | first mutable borrow occurs here + | first borrow later used by call -error[E0382]: use of moved value: `f` +error[E0382]: borrow of moved value: `f` --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:32:5 | +LL | fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { + | - ----- move occurs because `f` has type `F`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | let mut r = R {c: Box::new(f)}; | - value moved here -LL | f(&mut r, false) //~ ERROR use of moved value - | ^ value used here after move - | - = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait +LL | f(&mut r, false) //~ ERROR borrow of moved value + | ^ value borrowed here after move error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/moves-sru-moved-field.nll.stderr b/src/test/ui/moves/moves-sru-moved-field.nll.stderr deleted file mode 100644 index e5daab36f6ee7..0000000000000 --- a/src/test/ui/moves/moves-sru-moved-field.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `f.moved` - --> $DIR/moves-sru-moved-field.rs:20:14 - | -LL | let _b = Foo {noncopyable: g, ..f}; - | ------------------------- value moved here -LL | let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved` - | ^^^^^^^^^^^^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `f.moved` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-sru-moved-field.stderr b/src/test/ui/moves/moves-sru-moved-field.stderr index 3d38faa20a1e4..e5daab36f6ee7 100644 --- a/src/test/ui/moves/moves-sru-moved-field.stderr +++ b/src/test/ui/moves/moves-sru-moved-field.stderr @@ -1,10 +1,10 @@ error[E0382]: use of moved value: `f.moved` - --> $DIR/moves-sru-moved-field.rs:20:37 + --> $DIR/moves-sru-moved-field.rs:20:14 | LL | let _b = Foo {noncopyable: g, ..f}; - | - value moved here + | ------------------------- value moved here LL | let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved` - | ^ value used here after move + | ^^^^^^^^^^^^^^^^^^^^^^^^^ value used here after move | = note: move occurs because `f.moved` has type `std::boxed::Box`, which does not implement the `Copy` trait diff --git a/src/test/ui/mut/mut-cant-alias.nll.stderr b/src/test/ui/mut/mut-cant-alias.nll.stderr deleted file mode 100644 index 2d7104b39c4b2..0000000000000 --- a/src/test/ui/mut/mut-cant-alias.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `b` as mutable more than once at a time - --> $DIR/mut-cant-alias.rs:9:20 - | -LL | let b1 = &mut *b; - | - first mutable borrow occurs here -LL | let b2 = &mut *b; //~ ERROR cannot borrow - | ^ second mutable borrow occurs here -LL | b1.use_mut(); - | -- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/mut/mut-cant-alias.stderr b/src/test/ui/mut/mut-cant-alias.stderr index ce942677bed61..2d7104b39c4b2 100644 --- a/src/test/ui/mut/mut-cant-alias.stderr +++ b/src/test/ui/mut/mut-cant-alias.stderr @@ -6,8 +6,7 @@ LL | let b1 = &mut *b; LL | let b2 = &mut *b; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | b1.use_mut(); -LL | } - | - first borrow ends here + | -- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.ast.stderr b/src/test/ui/mut/mut-pattern-internal-mutability.ast.stderr deleted file mode 100644 index e3423d5388e43..0000000000000 --- a/src/test/ui/mut/mut-pattern-internal-mutability.ast.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/mut-pattern-internal-mutability.rs:8:5 - | -LL | let &mut x = foo; - | - first assignment to `x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^ cannot assign twice to immutable variable - -error[E0506]: cannot assign to `*foo` because it is borrowed - --> $DIR/mut-pattern-internal-mutability.rs:17:5 - | -LL | let &mut ref x = foo; - | ----- borrow of `*foo` occurs here -LL | *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `*foo` occurs here - -error: aborting due to 2 previous errors - -Some errors occurred: E0384, E0506. -For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.mir.stderr b/src/test/ui/mut/mut-pattern-internal-mutability.mir.stderr deleted file mode 100644 index 82a4628a0e6b7..0000000000000 --- a/src/test/ui/mut/mut-pattern-internal-mutability.mir.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/mut-pattern-internal-mutability.rs:8:5 - | -LL | let &mut x = foo; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable - | ^^^^^^ cannot assign twice to immutable variable - -error[E0506]: cannot assign to `*foo` because it is borrowed - --> $DIR/mut-pattern-internal-mutability.rs:17:5 - | -LL | let &mut ref x = foo; - | ----- borrow of `*foo` occurs here -LL | *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed - | ^^^^^^^^^ assignment to borrowed `*foo` occurs here -LL | //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed -LL | drop(x); - | - borrow later used here - -error: aborting due to 2 previous errors - -Some errors occurred: E0384, E0506. -For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.rs b/src/test/ui/mut/mut-pattern-internal-mutability.rs index ffad623e572a7..bcee878e3894b 100644 --- a/src/test/ui/mut/mut-pattern-internal-mutability.rs +++ b/src/test/ui/mut/mut-pattern-internal-mutability.rs @@ -1,12 +1,8 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let foo = &mut 1; let &mut x = foo; - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `x` + x += 1; //~ ERROR cannot assign twice to immutable variable `x` // explicitly mut-ify internals let &mut mut x = foo; @@ -14,7 +10,6 @@ fn main() { // check borrowing is detected successfully let &mut ref x = foo; - *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed - //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed + *foo += 1; //~ ERROR cannot assign to `*foo` because it is borrowed drop(x); } diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.ast.nll.stderr b/src/test/ui/mut/mut-pattern-internal-mutability.stderr similarity index 68% rename from src/test/ui/mut/mut-pattern-internal-mutability.ast.nll.stderr rename to src/test/ui/mut/mut-pattern-internal-mutability.stderr index 82a4628a0e6b7..31f72e2ad1921 100644 --- a/src/test/ui/mut/mut-pattern-internal-mutability.ast.nll.stderr +++ b/src/test/ui/mut/mut-pattern-internal-mutability.stderr @@ -1,22 +1,21 @@ error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/mut-pattern-internal-mutability.rs:8:5 + --> $DIR/mut-pattern-internal-mutability.rs:5:5 | LL | let &mut x = foo; | - | | | first assignment to `x` | help: make this binding mutable: `mut x` -LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable +LL | x += 1; //~ ERROR cannot assign twice to immutable variable `x` | ^^^^^^ cannot assign twice to immutable variable error[E0506]: cannot assign to `*foo` because it is borrowed - --> $DIR/mut-pattern-internal-mutability.rs:17:5 + --> $DIR/mut-pattern-internal-mutability.rs:13:5 | LL | let &mut ref x = foo; | ----- borrow of `*foo` occurs here -LL | *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed +LL | *foo += 1; //~ ERROR cannot assign to `*foo` because it is borrowed | ^^^^^^^^^ assignment to borrowed `*foo` occurs here -LL | //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed LL | drop(x); | - borrow later used here diff --git a/src/test/ui/mut/mut-suggestion.nll.stderr b/src/test/ui/mut/mut-suggestion.nll.stderr deleted file mode 100644 index 61656db5ec295..0000000000000 --- a/src/test/ui/mut/mut-suggestion.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/mut-suggestion.rs:12:5 - | -LL | fn func(arg: S) { - | --- help: consider changing this to be mutable: `mut arg` -... -LL | arg.mutate(); - | ^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable - --> $DIR/mut-suggestion.rs:21:5 - | -LL | let local = S; - | ----- help: consider changing this to be mutable: `mut local` -... -LL | local.mutate(); - | ^^^^^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/mut/mut-suggestion.rs b/src/test/ui/mut/mut-suggestion.rs index 0d95a8bc12a9f..3104b20aca4e6 100644 --- a/src/test/ui/mut/mut-suggestion.rs +++ b/src/test/ui/mut/mut-suggestion.rs @@ -7,18 +7,16 @@ impl S { } fn func(arg: S) { - //~^ HELP make this binding mutable + //~^ HELP consider changing this to be mutable //~| SUGGESTION mut arg arg.mutate(); - //~^ ERROR cannot borrow immutable argument - //~| cannot borrow mutably + //~^ ERROR cannot borrow `arg` as mutable, as it is not declared as mutable } fn main() { let local = S; - //~^ HELP make this binding mutable + //~^ HELP consider changing this to be mutable //~| SUGGESTION mut local local.mutate(); - //~^ ERROR cannot borrow immutable local variable - //~| cannot borrow mutably + //~^ ERROR cannot borrow `local` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/mut/mut-suggestion.stderr b/src/test/ui/mut/mut-suggestion.stderr index 1998ec1eca9e3..245eaff4bb4ec 100644 --- a/src/test/ui/mut/mut-suggestion.stderr +++ b/src/test/ui/mut/mut-suggestion.stderr @@ -1,20 +1,20 @@ -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/mut-suggestion.rs:12:5 | LL | fn func(arg: S) { - | --- help: make this binding mutable: `mut arg` + | --- help: consider changing this to be mutable: `mut arg` ... LL | arg.mutate(); - | ^^^ cannot borrow mutably + | ^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable local variable `local` as mutable - --> $DIR/mut-suggestion.rs:21:5 +error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable + --> $DIR/mut-suggestion.rs:20:5 | LL | let local = S; - | ----- help: make this binding mutable: `mut local` + | ----- help: consider changing this to be mutable: `mut local` ... LL | local.mutate(); - | ^^^^^ cannot borrow mutably + | ^^^^^ cannot borrow as mutable error: aborting due to 2 previous errors diff --git a/src/test/ui/mut/mutable-class-fields-2.nll.stderr b/src/test/ui/mut/mutable-class-fields-2.nll.stderr deleted file mode 100644 index 53127922263cd..0000000000000 --- a/src/test/ui/mut/mutable-class-fields-2.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to `self.how_hungry` which is behind a `&` reference - --> $DIR/mutable-class-fields-2.rs:9:5 - | -LL | pub fn eat(&self) { - | ----- help: consider changing this to be a mutable reference: `&mut self` -LL | self.how_hungry -= 5; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/mut/mutable-class-fields-2.stderr b/src/test/ui/mut/mutable-class-fields-2.stderr index daeee1117bcc3..53127922263cd 100644 --- a/src/test/ui/mut/mutable-class-fields-2.stderr +++ b/src/test/ui/mut/mutable-class-fields-2.stderr @@ -1,10 +1,10 @@ -error[E0594]: cannot assign to field `self.how_hungry` of immutable binding +error[E0594]: cannot assign to `self.how_hungry` which is behind a `&` reference --> $DIR/mutable-class-fields-2.rs:9:5 | LL | pub fn eat(&self) { - | ----- use `&mut self` here to make mutable + | ----- help: consider changing this to be a mutable reference: `&mut self` LL | self.how_hungry -= 5; //~ ERROR cannot assign - | ^^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written error: aborting due to previous error diff --git a/src/test/ui/mut/mutable-class-fields.ast.stderr b/src/test/ui/mut/mutable-class-fields.ast.stderr deleted file mode 100644 index 80185703a9e02..0000000000000 --- a/src/test/ui/mut/mutable-class-fields.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to field `nyan.how_hungry` of immutable binding - --> $DIR/mutable-class-fields.rs:18:3 - | -LL | let nyan : Cat = cat(52, 99); - | ---- help: make this binding mutable: `mut nyan` -LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign - | ^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/mut/mutable-class-fields.mir.stderr b/src/test/ui/mut/mutable-class-fields.mir.stderr deleted file mode 100644 index 6b36b29d46028..0000000000000 --- a/src/test/ui/mut/mutable-class-fields.mir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to `nyan.how_hungry`, as `nyan` is not declared as mutable - --> $DIR/mutable-class-fields.rs:18:3 - | -LL | let nyan : Cat = cat(52, 99); - | ---- help: consider changing this to be mutable: `mut nyan` -LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign - | ^^^^^^^^^^^^^^^^^^^ cannot assign - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/mut/mutable-class-fields.rs b/src/test/ui/mut/mutable-class-fields.rs index 2a729a5f6e626..30768a1ec9bcd 100644 --- a/src/test/ui/mut/mutable-class-fields.rs +++ b/src/test/ui/mut/mutable-class-fields.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct Cat { meows : usize, how_hungry : isize, @@ -15,6 +12,5 @@ fn cat(in_x : usize, in_y : isize) -> Cat { fn main() { let nyan : Cat = cat(52, 99); - nyan.how_hungry = 0; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign + nyan.how_hungry = 0; //~ ERROR cannot assign } diff --git a/src/test/ui/mut/mutable-class-fields.ast.nll.stderr b/src/test/ui/mut/mutable-class-fields.stderr similarity index 78% rename from src/test/ui/mut/mutable-class-fields.ast.nll.stderr rename to src/test/ui/mut/mutable-class-fields.stderr index 6b36b29d46028..c072c9bdbe59b 100644 --- a/src/test/ui/mut/mutable-class-fields.ast.nll.stderr +++ b/src/test/ui/mut/mutable-class-fields.stderr @@ -1,9 +1,9 @@ error[E0594]: cannot assign to `nyan.how_hungry`, as `nyan` is not declared as mutable - --> $DIR/mutable-class-fields.rs:18:3 + --> $DIR/mutable-class-fields.rs:15:3 | LL | let nyan : Cat = cat(52, 99); | ---- help: consider changing this to be mutable: `mut nyan` -LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign +LL | nyan.how_hungry = 0; //~ ERROR cannot assign | ^^^^^^^^^^^^^^^^^^^ cannot assign error: aborting due to previous error diff --git a/src/test/ui/nll/cannot-move-block-spans.nll.stderr b/src/test/ui/nll/cannot-move-block-spans.nll.stderr deleted file mode 100644 index 30b4bf75af693..0000000000000 --- a/src/test/ui/nll/cannot-move-block-spans.nll.stderr +++ /dev/null @@ -1,85 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:5:15 - | -LL | let x = { *r }; //~ ERROR - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:6:22 - | -LL | let y = unsafe { *r }; //~ ERROR - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:7:26 - | -LL | let z = loop { break *r; }; //~ ERROR - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array - --> $DIR/cannot-move-block-spans.rs:11:15 - | -LL | let x = { arr[0] }; //~ ERROR - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&arr[0]` - -error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array - --> $DIR/cannot-move-block-spans.rs:12:22 - | -LL | let y = unsafe { arr[0] }; //~ ERROR - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&arr[0]` - -error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array - --> $DIR/cannot-move-block-spans.rs:13:26 - | -LL | let z = loop { break arr[0]; }; //~ ERROR - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&arr[0]` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:17:38 - | -LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:18:45 - | -LL | let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:19:49 - | -LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error: aborting due to 9 previous errors - -Some errors occurred: E0507, E0508. -For more information about an error, try `rustc --explain E0507`. diff --git a/src/test/ui/nll/cannot-move-block-spans.stderr b/src/test/ui/nll/cannot-move-block-spans.stderr index e37c6ff06f7e8..30b4bf75af693 100644 --- a/src/test/ui/nll/cannot-move-block-spans.stderr +++ b/src/test/ui/nll/cannot-move-block-spans.stderr @@ -2,55 +2,82 @@ error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:5:15 | LL | let x = { *r }; //~ ERROR - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:6:22 | LL | let y = unsafe { *r }; //~ ERROR - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:7:26 | LL | let z = loop { break *r; }; //~ ERROR - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array --> $DIR/cannot-move-block-spans.rs:11:15 | LL | let x = { arr[0] }; //~ ERROR - | ^^^^^^ cannot move out of here + | ^^^^^^ + | | + | cannot move out of here + | help: consider borrowing here: `&arr[0]` error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array --> $DIR/cannot-move-block-spans.rs:12:22 | LL | let y = unsafe { arr[0] }; //~ ERROR - | ^^^^^^ cannot move out of here + | ^^^^^^ + | | + | cannot move out of here + | help: consider borrowing here: `&arr[0]` error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array --> $DIR/cannot-move-block-spans.rs:13:26 | LL | let z = loop { break arr[0]; }; //~ ERROR - | ^^^^^^ cannot move out of here + | ^^^^^^ + | | + | cannot move out of here + | help: consider borrowing here: `&arr[0]` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:17:38 | LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:18:45 | LL | let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:19:49 | LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error: aborting due to 9 previous errors diff --git a/src/test/ui/nll/get_default.nll.stderr b/src/test/ui/nll/get_default.nll.stderr deleted file mode 100644 index 0f71452805db0..0000000000000 --- a/src/test/ui/nll/get_default.nll.stderr +++ /dev/null @@ -1,84 +0,0 @@ -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:23:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -... -LL | map.set(String::new()); // Ideally, this would not error. - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:35:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -LL | Some(v) => { -LL | map.set(String::new()); // Both AST and MIR error here - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/get_default.rs:41:17 - | -LL | match map.get() { - | --- immutable borrow occurs here -... -LL | map.set(String::new()); // Ideally, just AST would error here - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:23:17 - | -LL | fn ok(map: &mut Map) -> &String { - | - let's call the lifetime of this reference `'1` -LL | loop { -LL | match map.get() { - | --- immutable borrow occurs here -LL | Some(v) => { -LL | return v; - | - returning this value requires that `*map` is borrowed for `'1` -... -LL | map.set(String::new()); // Ideally, this would not error. - | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:35:17 - | -LL | fn err(map: &mut Map) -> &String { - | - let's call the lifetime of this reference `'1` -LL | loop { -LL | match map.get() { - | --- immutable borrow occurs here -LL | Some(v) => { -LL | map.set(String::new()); // Both AST and MIR error here - | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | return v; - | - returning this value requires that `*map` is borrowed for `'1` - -error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/get_default.rs:41:17 - | -LL | fn err(map: &mut Map) -> &String { - | - let's call the lifetime of this reference `'1` -LL | loop { -LL | match map.get() { - | --- immutable borrow occurs here -... -LL | return v; - | - returning this value requires that `*map` is borrowed for `'1` -... -LL | map.set(String::new()); // Ideally, just AST would error here - | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/nll/get_default.stderr b/src/test/ui/nll/get_default.stderr index abb5343845b57..0f71452805db0 100644 --- a/src/test/ui/nll/get_default.stderr +++ b/src/test/ui/nll/get_default.stderr @@ -47,7 +47,7 @@ LL | return v; | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, this would not error. - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:35:17 @@ -59,7 +59,7 @@ LL | match map.get() { | --- immutable borrow occurs here LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | return v; | - returning this value requires that `*map` is borrowed for `'1` @@ -77,7 +77,7 @@ LL | return v; | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, just AST would error here - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here error: aborting due to 6 previous errors diff --git a/src/test/ui/nll/issue-50716-1.rs b/src/test/ui/nll/issue-50716-1.rs index db7e6b30f2718..d963a620c9ac7 100644 --- a/src/test/ui/nll/issue-50716-1.rs +++ b/src/test/ui/nll/issue-50716-1.rs @@ -3,11 +3,11 @@ // bounds derived from `Sized` requirements” that checks that the fixed compiler // accepts this code fragment with both AST and MIR borrow checkers. // -// revisions: ast mir +// revisions: migrate nll // // compile-pass -#![cfg_attr(mir, feature(nll))] +#![cfg_attr(nll, feature(nll))] struct Qey(Q); diff --git a/src/test/ui/nll/issue-53807.nll.stderr b/src/test/ui/nll/issue-53807.nll.stderr deleted file mode 100644 index 2b15da3710e62..0000000000000 --- a/src/test/ui/nll/issue-53807.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0382]: use of moved value - --> $DIR/issue-53807.rs:4:21 - | -LL | if let Some(thing) = maybe { - | ^^^^^ value moved here, in previous iteration of loop - | - = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/nll/issue-53807.rs b/src/test/ui/nll/issue-53807.rs index f69d8c14935f9..d494f7e151dfb 100644 --- a/src/test/ui/nll/issue-53807.rs +++ b/src/test/ui/nll/issue-53807.rs @@ -2,8 +2,7 @@ pub fn main(){ let maybe = Some(vec![true, true]); loop { if let Some(thing) = maybe { -//~^ ERROR use of partially moved value -//~| ERROR use of moved value +//~^ ERROR use of moved value } } } diff --git a/src/test/ui/nll/issue-53807.stderr b/src/test/ui/nll/issue-53807.stderr index fb6701452cb6c..2b15da3710e62 100644 --- a/src/test/ui/nll/issue-53807.stderr +++ b/src/test/ui/nll/issue-53807.stderr @@ -1,21 +1,11 @@ -error[E0382]: use of partially moved value: `maybe` - --> $DIR/issue-53807.rs:4:30 - | -LL | if let Some(thing) = maybe { - | ----- ^^^^^ value used here after move - | | - | value moved here - | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` +error[E0382]: use of moved value --> $DIR/issue-53807.rs:4:21 | LL | if let Some(thing) = maybe { - | ^^^^^ value moved here in previous iteration of loop + | ^^^^^ value moved here, in previous iteration of loop | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait + = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.nll.stderr b/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.nll.stderr deleted file mode 100644 index 8412cbdc54b3b..0000000000000 --- a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:29 - | -LL | D("other").next(&_thing1) - | ----------------^^^^^^^^- - | | | - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -... -LL | } - | - `_thing1` dropped here while still borrowed -LL | -LL | ; - | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr b/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr index 8d23891e1ba79..8412cbdc54b3b 100644 --- a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr +++ b/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr @@ -1,14 +1,19 @@ error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:30 + --> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:29 | LL | D("other").next(&_thing1) - | ^^^^^^^ borrowed value does not live long enough + | ----------------^^^^^^^^- + | | | + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... ... LL | } | - `_thing1` dropped here while still borrowed LL | LL | ; - | - borrowed value needs to live until here + | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-niconii.nll.stderr b/src/test/ui/nll/issue-54556-niconii.nll.stderr deleted file mode 100644 index 58239fe6e888d..0000000000000 --- a/src/test/ui/nll/issue-54556-niconii.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0597]: `counter` does not live long enough - --> $DIR/issue-54556-niconii.rs:22:20 - | -LL | if let Ok(_) = counter.lock() { } //~ ERROR does not live long enough - | ^^^^^^^------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -... -LL | } - | - - | | - | `counter` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result, ()>` - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-niconii.stderr b/src/test/ui/nll/issue-54556-niconii.stderr index 03a7b94d181ba..58239fe6e888d 100644 --- a/src/test/ui/nll/issue-54556-niconii.stderr +++ b/src/test/ui/nll/issue-54556-niconii.stderr @@ -2,12 +2,18 @@ error[E0597]: `counter` does not live long enough --> $DIR/issue-54556-niconii.rs:22:20 | LL | if let Ok(_) = counter.lock() { } //~ ERROR does not live long enough - | ^^^^^^^ borrowed value does not live long enough + | ^^^^^^^------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... ... LL | } - | - `counter` dropped here while still borrowed + | - + | | + | `counter` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result, ()>` | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr b/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr deleted file mode 100644 index b58454427af84..0000000000000 --- a/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0597]: `stmt` does not live long enough - --> $DIR/issue-54556-stephaneyfx.rs:27:21 - | -LL | let rows = Rows(&stmt); //~ ERROR does not live long enough - | ^^^^^ borrowed value does not live long enough -LL | rows.map(|row| row).next() - | ------------------- a temporary with access to the borrow is created here ... -... -LL | } - | - - | | - | `stmt` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::iter::Map, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23]>` - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-stephaneyfx.stderr b/src/test/ui/nll/issue-54556-stephaneyfx.stderr index bf3285a73c7c5..b58454427af84 100644 --- a/src/test/ui/nll/issue-54556-stephaneyfx.stderr +++ b/src/test/ui/nll/issue-54556-stephaneyfx.stderr @@ -1,13 +1,18 @@ error[E0597]: `stmt` does not live long enough - --> $DIR/issue-54556-stephaneyfx.rs:27:22 + --> $DIR/issue-54556-stephaneyfx.rs:27:21 | LL | let rows = Rows(&stmt); //~ ERROR does not live long enough - | ^^^^ borrowed value does not live long enough + | ^^^^^ borrowed value does not live long enough +LL | rows.map(|row| row).next() + | ------------------- a temporary with access to the borrow is created here ... ... LL | } - | - `stmt` dropped here while still borrowed + | - + | | + | `stmt` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::iter::Map, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23]>` | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr b/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr deleted file mode 100644 index 1bc43017bc675..0000000000000 --- a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:11 - | -LL | D(&_thing1).end() //~ ERROR does not live long enough - | --^^^^^^^^- - | | | - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | } - | - `_thing1` dropped here while still borrowed -LL | -LL | ; - | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr b/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr index ca636e7613265..1bc43017bc675 100644 --- a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr +++ b/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr @@ -1,13 +1,18 @@ error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:12 + --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:11 | LL | D(&_thing1).end() //~ ERROR does not live long enough - | ^^^^^^^ borrowed value does not live long enough + | --^^^^^^^^- + | | | + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | } | - `_thing1` dropped here while still borrowed LL | LL | ; - | - borrowed value needs to live until here + | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr b/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr deleted file mode 100644 index 52d0870b78f95..0000000000000 --- a/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr +++ /dev/null @@ -1,113 +0,0 @@ -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:10:55 - | -LL | { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:13:55 - | -LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:16:55 - | -LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` - | --^^^^- -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:19:55 - | -LL | let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:22:55 - | -LL | let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:25:55 - | -LL | let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:30:55 - | -LL | _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:37:55 - | -LL | fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` - | --^^^^- - - | | | | - | | | `_t1` dropped here while still borrowed - | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:40:55 - | -LL | fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` - | --^^^^- - - | | | | - | | | `_t1` dropped here while still borrowed - | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr b/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr index e9e4e51136d0a..52d0870b78f95 100644 --- a/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr +++ b/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr @@ -1,85 +1,112 @@ error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:10:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:10:55 | LL | { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:13:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:13:55 | LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:16:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:16:55 | LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` - | ^^^ -- borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:19:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:19:55 | LL | let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:22:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:22:55 | LL | let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:25:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:25:55 | LL | let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:30:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:30:55 | LL | _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:37:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:37:55 | LL | fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` - | ^^^ - `_t1` dropped here while still borrowed - | | - | borrowed value does not live long enough + | --^^^^- - + | | | | + | | | `_t1` dropped here while still borrowed + | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:40:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:40:55 | LL | fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` - | ^^^ - `_t1` dropped here while still borrowed - | | - | borrowed value does not live long enough + | --^^^^- - + | | | | + | | | `_t1` dropped here while still borrowed + | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to 9 previous errors diff --git a/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr b/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr deleted file mode 100644 index a13e59fa48b5c..0000000000000 --- a/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/issue-54556-wrap-it-up.rs:27:5 - | -LL | let wrap = Wrap { p: &mut x }; - | ------ borrow of `x` occurs here -... -LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] - | ^^^^^ assignment to borrowed `x` occurs here -LL | } - | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/nll/issue-54556-wrap-it-up.stderr b/src/test/ui/nll/issue-54556-wrap-it-up.stderr index a0c19b9638798..a13e59fa48b5c 100644 --- a/src/test/ui/nll/issue-54556-wrap-it-up.stderr +++ b/src/test/ui/nll/issue-54556-wrap-it-up.stderr @@ -2,10 +2,12 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/issue-54556-wrap-it-up.rs:27:5 | LL | let wrap = Wrap { p: &mut x }; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here ... LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] | ^^^^^ assignment to borrowed `x` occurs here +LL | } + | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` error: aborting due to previous error diff --git a/src/test/ui/nll/issue-55850.nll.stderr b/src/test/ui/nll/issue-55850.nll.stderr deleted file mode 100644 index e09711f74fd72..0000000000000 --- a/src/test/ui/nll/issue-55850.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0597]: `s` does not live long enough - --> $DIR/issue-55850.rs:28:16 - | -LL | yield &s[..] //~ ERROR `s` does not live long enough [E0597] - | ^ borrowed value does not live long enough -LL | }) - | - `s` dropped here while still borrowed - -error[E0626]: borrow may still be in use when generator yields - --> $DIR/issue-55850.rs:28:16 - | -LL | yield &s[..] //~ ERROR `s` does not live long enough [E0597] - | -------^---- possible yield occurs here - -error: aborting due to 2 previous errors - -Some errors occurred: E0597, E0626. -For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-55850.rs b/src/test/ui/nll/issue-55850.rs index 8b5887224d19a..8a016bf87795b 100644 --- a/src/test/ui/nll/issue-55850.rs +++ b/src/test/ui/nll/issue-55850.rs @@ -26,6 +26,7 @@ fn bug<'a>() -> impl Iterator { GenIter(move || { let mut s = String::new(); yield &s[..] //~ ERROR `s` does not live long enough [E0597] + //~| ERROR borrow may still be in use when generator yields }) } diff --git a/src/test/ui/nll/issue-55850.stderr b/src/test/ui/nll/issue-55850.stderr index 2a24cba1a6846..17ae70688116f 100644 --- a/src/test/ui/nll/issue-55850.stderr +++ b/src/test/ui/nll/issue-55850.stderr @@ -3,15 +3,17 @@ error[E0597]: `s` does not live long enough | LL | yield &s[..] //~ ERROR `s` does not live long enough [E0597] | ^ borrowed value does not live long enough +LL | //~| ERROR borrow may still be in use when generator yields LL | }) - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 25:8... - --> $DIR/issue-55850.rs:25:8 + | - `s` dropped here while still borrowed + +error[E0626]: borrow may still be in use when generator yields + --> $DIR/issue-55850.rs:28:16 | -LL | fn bug<'a>() -> impl Iterator { - | ^^ +LL | yield &s[..] //~ ERROR `s` does not live long enough [E0597] + | -------^---- possible yield occurs here -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0597, E0626. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr b/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr deleted file mode 100644 index 4d647949038ac..0000000000000 --- a/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning[E0507]: cannot move out of borrowed content - --> $DIR/match-guards-always-borrow.rs:13:13 - | -LL | (|| { let bar = foo; bar.take() })(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error: compilation successful - --> $DIR/match-guards-always-borrow.rs:47:1 - | -LL | / fn main() { //[ast]~ ERROR compilation successful -LL | | should_reject_destructive_mutate_in_guard(); -LL | | allow_mutate_in_arm_body(); -LL | | allow_move_into_arm_body(); -LL | | } - | |_^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/nll/match-guards-always-borrow.ast.stderr b/src/test/ui/nll/match-guards-always-borrow.ast.stderr deleted file mode 100644 index 92d76d577d55f..0000000000000 --- a/src/test/ui/nll/match-guards-always-borrow.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: compilation successful - --> $DIR/match-guards-always-borrow.rs:47:1 - | -LL | / fn main() { //[ast]~ ERROR compilation successful -LL | | should_reject_destructive_mutate_in_guard(); -LL | | allow_mutate_in_arm_body(); -LL | | allow_move_into_arm_body(); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/nll/match-guards-always-borrow.rs b/src/test/ui/nll/match-guards-always-borrow.rs index ec4eed6797600..5900dc3ade030 100644 --- a/src/test/ui/nll/match-guards-always-borrow.rs +++ b/src/test/ui/nll/match-guards-always-borrow.rs @@ -1,7 +1,4 @@ -//revisions: ast mir -//[mir] compile-flags: -Z borrowck=mir - -#![feature(rustc_attrs)] +#![feature(nll)] // Here is arielb1's basic example from rust-lang/rust#27282 // that AST borrowck is flummoxed by: @@ -11,7 +8,7 @@ fn should_reject_destructive_mutate_in_guard() { None => {}, ref mut foo if { (|| { let bar = foo; bar.take() })(); - //[mir]~^ ERROR cannot move out of borrowed content [E0507] + //~^ ERROR cannot move out of borrowed content [E0507] false } => { }, Some(s) => std::process::exit(*s), } @@ -39,12 +36,7 @@ fn allow_move_into_arm_body() { } } -// Since this is a compile-fail test that is explicitly encoding the -// different behavior of AST- vs MIR-borrowck where AST-borrowck does -// not error, we need to use rustc_error to placate the test harness -// that wants *some* error to occur. -#[rustc_error] -fn main() { //[ast]~ ERROR compilation successful +fn main() { should_reject_destructive_mutate_in_guard(); allow_mutate_in_arm_body(); allow_move_into_arm_body(); diff --git a/src/test/ui/nll/match-guards-always-borrow.mir.stderr b/src/test/ui/nll/match-guards-always-borrow.stderr similarity index 86% rename from src/test/ui/nll/match-guards-always-borrow.mir.stderr rename to src/test/ui/nll/match-guards-always-borrow.stderr index 3e90c5a154259..2492397c65deb 100644 --- a/src/test/ui/nll/match-guards-always-borrow.mir.stderr +++ b/src/test/ui/nll/match-guards-always-borrow.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/match-guards-always-borrow.rs:13:13 + --> $DIR/match-guards-always-borrow.rs:10:13 | LL | (|| { let bar = foo; bar.take() })(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content diff --git a/src/test/ui/nll/reference-carried-through-struct-field.ast.nll.stderr b/src/test/ui/nll/reference-carried-through-struct-field.ast.nll.stderr deleted file mode 100644 index f28e552901530..0000000000000 --- a/src/test/ui/nll/reference-carried-through-struct-field.ast.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/reference-carried-through-struct-field.rs:11:5 - | -LL | let wrapper = Wrap { w: &mut x }; - | ------ borrow of `x` occurs here -LL | x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] - | ^^^^^^ use of borrowed `x` -LL | //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] -LL | *wrapper.w += 1; - | --------------- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/nll/reference-carried-through-struct-field.ast.stderr b/src/test/ui/nll/reference-carried-through-struct-field.ast.stderr deleted file mode 100644 index b19d0b5277cea..0000000000000 --- a/src/test/ui/nll/reference-carried-through-struct-field.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/reference-carried-through-struct-field.rs:11:5 - | -LL | let wrapper = Wrap { w: &mut x }; - | - borrow of `x` occurs here -LL | x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] - | ^^^^^^ assignment to borrowed `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/nll/reference-carried-through-struct-field.rs b/src/test/ui/nll/reference-carried-through-struct-field.rs index f7903cba6a22c..effd610849940 100644 --- a/src/test/ui/nll/reference-carried-through-struct-field.rs +++ b/src/test/ui/nll/reference-carried-through-struct-field.rs @@ -1,15 +1,9 @@ -//revisions: ast mir -//[mir] compile-flags: -Z borrowck=mir - -#![allow(unused_assignments)] - struct Wrap<'a> { w: &'a mut u32 } fn foo() { let mut x = 22; let wrapper = Wrap { w: &mut x }; - x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] - //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] + x += 1; //~ ERROR cannot use `x` because it was mutably borrowed [E0503] *wrapper.w += 1; } diff --git a/src/test/ui/nll/reference-carried-through-struct-field.mir.stderr b/src/test/ui/nll/reference-carried-through-struct-field.stderr similarity index 63% rename from src/test/ui/nll/reference-carried-through-struct-field.mir.stderr rename to src/test/ui/nll/reference-carried-through-struct-field.stderr index f28e552901530..566dbb2e97e9c 100644 --- a/src/test/ui/nll/reference-carried-through-struct-field.mir.stderr +++ b/src/test/ui/nll/reference-carried-through-struct-field.stderr @@ -1,11 +1,10 @@ error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/reference-carried-through-struct-field.rs:11:5 + --> $DIR/reference-carried-through-struct-field.rs:6:5 | LL | let wrapper = Wrap { w: &mut x }; | ------ borrow of `x` occurs here -LL | x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] +LL | x += 1; //~ ERROR cannot use `x` because it was mutably borrowed [E0503] | ^^^^^^ use of borrowed `x` -LL | //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] LL | *wrapper.w += 1; | --------------- borrow later used here diff --git a/src/test/ui/nll/region-ends-after-if-condition.nll.stderr b/src/test/ui/nll/region-ends-after-if-condition.nll.stderr deleted file mode 100644 index ab8d96d4e9916..0000000000000 --- a/src/test/ui/nll/region-ends-after-if-condition.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/region-ends-after-if-condition.rs:19:9 - | -LL | let value = &my_struct.field; - | --------------- immutable borrow occurs here -LL | if value.is_empty() { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) - --> $DIR/region-ends-after-if-condition.rs:29:9 - | -LL | let value = &my_struct.field; - | --------------- immutable borrow occurs here -LL | if value.is_empty() { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Mir) - --> $DIR/region-ends-after-if-condition.rs:29:9 - | -LL | let value = &my_struct.field; - | ---------------- immutable borrow occurs here -LL | if value.is_empty() { -LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -... -LL | drop(value); - | ----- immutable borrow later used here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/nll/region-ends-after-if-condition.stderr b/src/test/ui/nll/region-ends-after-if-condition.stderr index aa876a0bcb3bf..ab8d96d4e9916 100644 --- a/src/test/ui/nll/region-ends-after-if-condition.stderr +++ b/src/test/ui/nll/region-ends-after-if-condition.stderr @@ -29,7 +29,7 @@ LL | let value = &my_struct.field; | ---------------- immutable borrow occurs here LL | if value.is_empty() { LL | my_struct.field.push_str("Hello, world!"); - | ^^^^^^^^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | drop(value); | ----- immutable borrow later used here diff --git a/src/test/ui/no-capture-arc.nll.stderr b/src/test/ui/no-capture-arc.nll.stderr deleted file mode 100644 index 476b6f75abb46..0000000000000 --- a/src/test/ui/no-capture-arc.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0382]: borrow of moved value: `arc_v` - --> $DIR/no-capture-arc.rs:14:18 - | -LL | let arc_v = Arc::new(v); - | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait -LL | -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | assert_eq!((*arc_v)[3], 4); - | ----- variable moved due to use in closure -... -LL | assert_eq!((*arc_v)[2], 3); - | ^^^^^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/no-capture-arc.rs b/src/test/ui/no-capture-arc.rs index 06f5fb3da3c0b..3f0b075778bd9 100644 --- a/src/test/ui/no-capture-arc.rs +++ b/src/test/ui/no-capture-arc.rs @@ -1,4 +1,4 @@ -// error-pattern: use of moved value +// error-pattern: borrow of moved value use std::sync::Arc; use std::thread; diff --git a/src/test/ui/no-capture-arc.stderr b/src/test/ui/no-capture-arc.stderr index 0dfa5cdbe9ef3..476b6f75abb46 100644 --- a/src/test/ui/no-capture-arc.stderr +++ b/src/test/ui/no-capture-arc.stderr @@ -1,25 +1,17 @@ -error[E0382]: use of moved value: `arc_v` +error[E0382]: borrow of moved value: `arc_v` --> $DIR/no-capture-arc.rs:14:18 | +LL | let arc_v = Arc::new(v); + | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait +LL | LL | thread::spawn(move|| { - | ------ value moved (into closure) here + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure ... LL | assert_eq!((*arc_v)[2], 3); - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `arc_v` - --> $DIR/no-capture-arc.rs:16:23 - | -LL | thread::spawn(move|| { - | ------ value moved (into closure) here -... -LL | println!("{:?}", *arc_v); - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + | ^^^^^ value borrowed here after move -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/no-reuse-move-arc.nll.stderr b/src/test/ui/no-reuse-move-arc.nll.stderr deleted file mode 100644 index 0b14f65a77073..0000000000000 --- a/src/test/ui/no-reuse-move-arc.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0382]: borrow of moved value: `arc_v` - --> $DIR/no-reuse-move-arc.rs:12:18 - | -LL | let arc_v = Arc::new(v); - | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait -LL | -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | assert_eq!((*arc_v)[3], 4); - | ----- variable moved due to use in closure -... -LL | assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` - | ^^^^^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/no-reuse-move-arc.rs b/src/test/ui/no-reuse-move-arc.rs index b60a7f24999af..9c957a4e01b41 100644 --- a/src/test/ui/no-reuse-move-arc.rs +++ b/src/test/ui/no-reuse-move-arc.rs @@ -9,7 +9,7 @@ fn main() { assert_eq!((*arc_v)[3], 4); }); - assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` + assert_eq!((*arc_v)[2], 3); //~ ERROR borrow of moved value: `arc_v` - println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` + println!("{:?}", *arc_v); } diff --git a/src/test/ui/no-reuse-move-arc.stderr b/src/test/ui/no-reuse-move-arc.stderr index d8ab314e7625e..3017529db437b 100644 --- a/src/test/ui/no-reuse-move-arc.stderr +++ b/src/test/ui/no-reuse-move-arc.stderr @@ -1,25 +1,17 @@ -error[E0382]: use of moved value: `arc_v` +error[E0382]: borrow of moved value: `arc_v` --> $DIR/no-reuse-move-arc.rs:12:18 | +LL | let arc_v = Arc::new(v); + | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait +LL | LL | thread::spawn(move|| { - | ------ value moved (into closure) here + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure ... -LL | assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `arc_v` - --> $DIR/no-reuse-move-arc.rs:14:23 - | -LL | thread::spawn(move|| { - | ------ value moved (into closure) here -... -LL | println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait +LL | assert_eq!((*arc_v)[2], 3); //~ ERROR borrow of moved value: `arc_v` + | ^^^^^ value borrowed here after move -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/not-copy-closure.nll.stderr b/src/test/ui/not-copy-closure.nll.stderr deleted file mode 100644 index 1a65bcf447317..0000000000000 --- a/src/test/ui/not-copy-closure.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0382]: use of moved value: `hello` - --> $DIR/not-copy-closure.rs:10:13 - | -LL | let b = hello; - | ----- value moved here -LL | let c = hello; //~ ERROR use of moved value: `hello` [E0382] - | ^^^^^ value used here after move - | -note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment - --> $DIR/not-copy-closure.rs:6:9 - | -LL | a += 1; - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/not-copy-closure.stderr b/src/test/ui/not-copy-closure.stderr index bdae06d3a66c4..1a65bcf447317 100644 --- a/src/test/ui/not-copy-closure.stderr +++ b/src/test/ui/not-copy-closure.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `hello` - --> $DIR/not-copy-closure.rs:10:9 + --> $DIR/not-copy-closure.rs:10:13 | LL | let b = hello; - | - value moved here + | ----- value moved here LL | let c = hello; //~ ERROR use of moved value: `hello` [E0382] - | ^ value used here after move + | ^^^^^ value used here after move | -note: closure cannot be invoked more than once because it moves the variable `a` out of its environment +note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment --> $DIR/not-copy-closure.rs:6:9 | LL | a += 1; diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.nll.stderr b/src/test/ui/object-safety/object-safety-by-value-self-use.nll.stderr deleted file mode 100644 index 0dd50b2802678..0000000000000 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined - --> $DIR/object-safety-by-value-self-use.rs:15:5 - | -LL | t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0161`. diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.rs b/src/test/ui/object-safety/object-safety-by-value-self-use.rs index dc8ea64ec9ce2..0b70c8ad45e7d 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.rs +++ b/src/test/ui/object-safety/object-safety-by-value-self-use.rs @@ -12,7 +12,7 @@ trait Baz { } fn use_bar(t: Box) { - t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) + t.bar() //~ ERROR cannot move a value of type dyn Bar } fn main() { } diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.stderr b/src/test/ui/object-safety/object-safety-by-value-self-use.stderr index 0711981a5215d..ecd8b84897fee 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.stderr +++ b/src/test/ui/object-safety/object-safety-by-value-self-use.stderr @@ -1,7 +1,7 @@ -error[E0161]: cannot move a value of type (dyn Bar + 'static): the size of (dyn Bar + 'static) cannot be statically determined +error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined --> $DIR/object-safety-by-value-self-use.rs:15:5 | -LL | t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) +LL | t.bar() //~ ERROR cannot move a value of type dyn Bar | ^ error: aborting due to previous error diff --git a/src/test/ui/once-cant-call-twice-on-heap.nll.stderr b/src/test/ui/once-cant-call-twice-on-heap.nll.stderr deleted file mode 100644 index ea53abc1b0f2d..0000000000000 --- a/src/test/ui/once-cant-call-twice-on-heap.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0382]: use of moved value: `blk` - --> $DIR/once-cant-call-twice-on-heap.rs:9:5 - | -LL | fn foo(blk: F) { - | - --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | blk(); - | --- value moved here -LL | blk(); //~ ERROR use of moved value - | ^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/once-cant-call-twice-on-heap.stderr b/src/test/ui/once-cant-call-twice-on-heap.stderr index 4559425e5be0d..ea53abc1b0f2d 100644 --- a/src/test/ui/once-cant-call-twice-on-heap.stderr +++ b/src/test/ui/once-cant-call-twice-on-heap.stderr @@ -1,12 +1,14 @@ error[E0382]: use of moved value: `blk` --> $DIR/once-cant-call-twice-on-heap.rs:9:5 | +LL | fn foo(blk: F) { + | - --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | blk(); | --- value moved here LL | blk(); //~ ERROR use of moved value | ^^^ value used here after move - | - = note: move occurs because `blk` has type `F`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/parser/mod_file_not_exist_windows.stderr b/src/test/ui/parser/mod_file_not_exist_windows.stderr deleted file mode 100644 index 67abd6304d515..0000000000000 --- a/src/test/ui/parser/mod_file_not_exist_windows.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0583]: file not found for module `not_a_real_file` - --> $DIR/mod_file_not_exist_windows.rs:3:5 - | -LL | mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` - | ^^^^^^^^^^^^^^^ - | - = help: name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory "$DIR" - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0583`. diff --git a/src/test/ui/ref-suggestion.nll.stderr b/src/test/ui/ref-suggestion.nll.stderr deleted file mode 100644 index 402f3c77cdb7b..0000000000000 --- a/src/test/ui/ref-suggestion.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/ref-suggestion.rs:4:5 - | -LL | let x = vec![1]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let y = x; - | - value moved here -LL | x; //~ ERROR use of moved value - | ^ value used here after move - -error[E0382]: use of moved value: `x` - --> $DIR/ref-suggestion.rs:8:5 - | -LL | let x = vec![1]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let mut y = x; - | - value moved here -LL | x; //~ ERROR use of moved value - | ^ value used here after move - -error[E0382]: use of moved value: `x` - --> $DIR/ref-suggestion.rs:16:5 - | -LL | (Some(y), ()) => {}, - | - value moved here -... -LL | x; //~ ERROR use of partially moved value - | ^ value used here after partial move - | - = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/ref-suggestion.rs b/src/test/ui/ref-suggestion.rs index 346d118f0f9a9..49d199cd9e754 100644 --- a/src/test/ui/ref-suggestion.rs +++ b/src/test/ui/ref-suggestion.rs @@ -13,5 +13,5 @@ fn main() { (Some(y), ()) => {}, _ => {}, } - x; //~ ERROR use of partially moved value + x; //~ ERROR use of moved value } diff --git a/src/test/ui/ref-suggestion.stderr b/src/test/ui/ref-suggestion.stderr index 1f871bafeec99..60bf9e66cd297 100644 --- a/src/test/ui/ref-suggestion.stderr +++ b/src/test/ui/ref-suggestion.stderr @@ -1,33 +1,33 @@ error[E0382]: use of moved value: `x` --> $DIR/ref-suggestion.rs:4:5 | +LL | let x = vec![1]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let y = x; - | - value moved here + | - value moved here LL | x; //~ ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x` --> $DIR/ref-suggestion.rs:8:5 | +LL | let x = vec![1]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let mut y = x; - | ----- value moved here + | - value moved here LL | x; //~ ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -error[E0382]: use of partially moved value: `x` +error[E0382]: use of moved value: `x` --> $DIR/ref-suggestion.rs:16:5 | LL | (Some(y), ()) => {}, | - value moved here ... -LL | x; //~ ERROR use of partially moved value - | ^ value used here after move +LL | x; //~ ERROR use of moved value + | ^ value used here after partial move | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait + = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs b/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs index 24676fe5e5bd9..5cbfe6ebebb7e 100644 --- a/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs +++ b/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs @@ -9,13 +9,6 @@ // rust-lang/rust#56537 // compile-pass -// We are already testing NLL explicitly via the revision system below. -// ignore-compare-mode-nll - -// revisions: ll nll migrate -//[ll] compile-flags:-Zborrowck=ast -//[nll] compile-flags:-Zborrowck=mir -Z two-phase-borrows -//[migrate] compile-flags:-Zborrowck=migrate -Z two-phase-borrows fn willy_no_annot<'w>(p: &'w str, q: &str) -> &'w str { let free_dumb = |_x| { p }; // no type annotation at all diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.stderr deleted file mode 100644 index 27d8ce4ab5092..0000000000000 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:71:43 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough - | | - | capture occurs here -... -LL | }); - | - borrowed value dropped before borrower - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:71:54 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough - | | - | capture occurs here -... -LL | }); - | - borrowed value dropped before borrower - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr deleted file mode 100644 index 8fb1ebbf7d0d0..0000000000000 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.rs b/src/test/ui/regions/region-borrow-params-issue-29793-big.rs index f21140b43de92..83b1a6eab57b4 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.rs +++ b/src/test/ui/regions/region-borrow-params-issue-29793-big.rs @@ -6,10 +6,6 @@ // behavior (because the improperly accepted closure was actually // able to be invoked). -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct WrapA(Option); impl WrapA { @@ -69,10 +65,8 @@ impl WrapA fn main() { let mut w = WrapA::new().set(|x: usize, y: usize| { WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - //[ast]~^ ERROR `x` does not live long enough - //[ast]~| ERROR `y` does not live long enough - //[mir]~^^^ ERROR closure may outlive the current function - //[mir]~| ERROR closure may outlive the current function + //~^ ERROR closure may outlive the current function + //~| ERROR closure may outlive the current function }); w.handle(); // This works diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-big.stderr similarity index 88% rename from src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr rename to src/test/ui/regions/region-borrow-params-issue-29793-big.stderr index 8fb1ebbf7d0d0..328e602ca765c 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr +++ b/src/test/ui/regions/region-borrow-params-issue-29793-big.stderr @@ -1,5 +1,5 @@ error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^ - `x` is borrowed here @@ -7,7 +7,7 @@ LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate erro | may outlive borrowed value `x` | note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:9 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate | ^^^^^^^^^^^^^^ error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^ - `y` is borrowed here @@ -25,7 +25,7 @@ LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate erro | may outlive borrowed value `y` | note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:9 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr deleted file mode 100644 index 18610b7cffb02..0000000000000 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr +++ /dev/null @@ -1,363 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 - | -LL | return f; - | ^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 - | -LL | return f; - | ^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 - | -LL | f - | ^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 - | -LL | f - | ^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:55:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:55:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:66:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:66:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:90:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:90:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:104:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:104:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:132:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:132:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:147:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:147:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:175:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:175:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:189:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:189:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error: aborting due to 20 previous errors - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs index 08ed79cbdbf3c..0d8c9fb269932 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs +++ b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs @@ -7,8 +7,8 @@ fn escaping_borrow_of_closure_params_1() { let g = |x: usize, y:usize| { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - //~^ ERROR `x` does not live long enough - //~| ERROR `y` does not live long enough + //~^ ERROR E0373 + //~| ERROR E0373 return f; }; @@ -22,8 +22,8 @@ fn escaping_borrow_of_closure_params_1() { fn escaping_borrow_of_closure_params_2() { let g = |x: usize, y:usize| { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - //~^ ERROR `x` does not live long enough - //~| ERROR `y` does not live long enough + //~^ ERROR E0373 + //~| ERROR E0373 f }; diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr index d6ad68fe94e1e..18610b7cffb02 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr +++ b/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr @@ -1,54 +1,74 @@ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:9:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 | - = note: values in a scope are dropped in the opposite order they are created +LL | return f; + | ^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:9:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 | - = note: values in a scope are dropped in the opposite order they are created +LL | return f; + | ^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:24:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 | - = note: values in a scope are dropped in the opposite order they are created +LL | f + | ^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:24:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 | - = note: values in a scope are dropped in the opposite order they are created +LL | f + | ^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function --> $DIR/region-borrow-params-issue-29793-small.rs:55:17 @@ -57,6 +77,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -69,6 +95,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -81,6 +113,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -93,6 +131,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -105,6 +149,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -117,6 +167,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -129,6 +185,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -141,6 +203,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -153,6 +221,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -165,6 +239,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -177,6 +257,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -189,6 +275,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -201,6 +293,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -213,6 +311,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -225,6 +329,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -237,6 +347,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -244,5 +360,4 @@ LL | let f = move |t: bool| if t { x } else { y }; // (separate erro error: aborting due to 20 previous errors -Some errors occurred: E0373, E0597. -For more information about an error, try `rustc --explain E0373`. +For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr b/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr deleted file mode 100644 index fa4c8a9dc6d8d..0000000000000 --- a/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -warning: function cannot return without recursing - --> $DIR/region-bound-on-closure-outlives-call.rs:1:1 - | -LL | fn call_rec(mut f: F) -> usize where F: FnMut(usize) -> usize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -LL | //~^ WARN function cannot return without recursing -LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` - | ----------- recursive call site - | - = note: #[warn(unconditional_recursion)] on by default - = help: a `loop` may express intention better if this is on purpose - -error[E0505]: cannot move out of `f` because it is borrowed - --> $DIR/region-bound-on-closure-outlives-call.rs:3:25 - | -LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` - | ---------- ^ move out of `f` occurs here - | || | - | || borrow occurs due to use in closure - | |borrow of `f` occurs here - | borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr b/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr index 3e60efd14720e..fa4c8a9dc6d8d 100644 --- a/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr +++ b/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr @@ -14,9 +14,11 @@ error[E0505]: cannot move out of `f` because it is borrowed --> $DIR/region-bound-on-closure-outlives-call.rs:3:25 | LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` - | --- ^ move out of `f` occurs here - | | - | borrow of `f` occurs here + | ---------- ^ move out of `f` occurs here + | || | + | || borrow occurs due to use in closure + | |borrow of `f` occurs here + | borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/regions/region-object-lifetime-5.nll.stderr b/src/test/ui/regions/region-object-lifetime-5.nll.stderr deleted file mode 100644 index c6d7135a2dbca..0000000000000 --- a/src/test/ui/regions/region-object-lifetime-5.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*x` - --> $DIR/region-object-lifetime-5.rs:11:5 - | -LL | x.borrowed() //~ ERROR `*x` does not live long enough - | -^^^^^^^^^^^ - | | - | returns a value referencing data owned by the current function - | `*x` is borrowed here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/region-object-lifetime-5.rs b/src/test/ui/regions/region-object-lifetime-5.rs index 5009b2bbf32f6..bd68aebbeeb09 100644 --- a/src/test/ui/regions/region-object-lifetime-5.rs +++ b/src/test/ui/regions/region-object-lifetime-5.rs @@ -8,7 +8,7 @@ trait Foo { // Here, the object is bounded by an anonymous lifetime and returned // as `&'static`, so you get an error. fn owned_receiver(x: Box) -> &'static () { - x.borrowed() //~ ERROR `*x` does not live long enough + x.borrowed() //~ ERROR cannot return value referencing local data `*x` } fn main() {} diff --git a/src/test/ui/regions/region-object-lifetime-5.stderr b/src/test/ui/regions/region-object-lifetime-5.stderr index 002bae18b1c01..6cc929ee037dc 100644 --- a/src/test/ui/regions/region-object-lifetime-5.stderr +++ b/src/test/ui/regions/region-object-lifetime-5.stderr @@ -1,13 +1,12 @@ -error[E0597]: `*x` does not live long enough +error[E0515]: cannot return value referencing local data `*x` --> $DIR/region-object-lifetime-5.rs:11:5 | -LL | x.borrowed() //~ ERROR `*x` does not live long enough - | ^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | x.borrowed() //~ ERROR cannot return value referencing local data `*x` + | -^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `*x` is borrowed here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-addr-of-arg.nll.stderr b/src/test/ui/regions/regions-addr-of-arg.nll.stderr deleted file mode 100644 index 0f60bc669b2dc..0000000000000 --- a/src/test/ui/regions/regions-addr-of-arg.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/regions-addr-of-arg.rs:5:30 - | -LL | let _p: &'static isize = &a; //~ ERROR `a` does not live long enough - | -------------- ^^ borrowed value does not live long enough - | | - | type annotation requires that `a` is borrowed for `'static` -LL | } - | - `a` dropped here while still borrowed - -error[E0515]: cannot return reference to function parameter `a` - --> $DIR/regions-addr-of-arg.rs:13:5 - | -LL | &a //~ ERROR `a` does not live long enough - | ^^ returns a reference to data owned by the current function - -error: aborting due to 2 previous errors - -Some errors occurred: E0515, E0597. -For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-addr-of-arg.rs b/src/test/ui/regions/regions-addr-of-arg.rs index 06f16be8217c0..1805141c4210e 100644 --- a/src/test/ui/regions/regions-addr-of-arg.rs +++ b/src/test/ui/regions/regions-addr-of-arg.rs @@ -10,7 +10,7 @@ fn bar(a: isize) { } fn zed<'a>(a: isize) -> &'a isize { - &a //~ ERROR `a` does not live long enough + &a //~ ERROR cannot return reference to function parameter `a` } fn main() { diff --git a/src/test/ui/regions/regions-addr-of-arg.stderr b/src/test/ui/regions/regions-addr-of-arg.stderr index 61e28b8bbeadf..6367d1c282bdf 100644 --- a/src/test/ui/regions/regions-addr-of-arg.stderr +++ b/src/test/ui/regions/regions-addr-of-arg.stderr @@ -1,27 +1,20 @@ error[E0597]: `a` does not live long enough - --> $DIR/regions-addr-of-arg.rs:5:31 + --> $DIR/regions-addr-of-arg.rs:5:30 | LL | let _p: &'static isize = &a; //~ ERROR `a` does not live long enough - | ^ borrowed value does not live long enough + | -------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `a` is borrowed for `'static` LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `a` dropped here while still borrowed -error[E0597]: `a` does not live long enough - --> $DIR/regions-addr-of-arg.rs:13:6 - | -LL | &a //~ ERROR `a` does not live long enough - | ^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 12:8... - --> $DIR/regions-addr-of-arg.rs:12:8 +error[E0515]: cannot return reference to function parameter `a` + --> $DIR/regions-addr-of-arg.rs:13:5 | -LL | fn zed<'a>(a: isize) -> &'a isize { - | ^^ +LL | &a //~ ERROR cannot return reference to function parameter `a` + | ^^ returns a reference to data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0515, E0597. +For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr b/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr deleted file mode 100644 index f188da5038d8b..0000000000000 --- a/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:14:16 - | -LL | v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | - ----- ^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:15:16 - | -LL | (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | - ----- ^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/regions/regions-adjusted-lvalue-op.stderr b/src/test/ui/regions/regions-adjusted-lvalue-op.stderr index 9988289b91e6c..f188da5038d8b 100644 --- a/src/test/ui/regions/regions-adjusted-lvalue-op.stderr +++ b/src/test/ui/regions/regions-adjusted-lvalue-op.stderr @@ -1,19 +1,19 @@ error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:14:17 + --> $DIR/regions-adjusted-lvalue-op.rs:14:16 | LL | v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:15:17 + --> $DIR/regions-adjusted-lvalue-op.rs:15:16 | LL | (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.ast.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.stderr similarity index 87% rename from src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.ast.stderr rename to src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.stderr index 76ead4e94ef66..f31f25bf00b60 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.ast.stderr +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:45:13 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:43:12 | -LL | let _x: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime 'a as defined on the function body at 37:15 --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:37:15 diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.mir.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr similarity index 65% rename from src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.mir.stderr rename to src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr index ad94d375b5bb7..867eafe2529d8 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.mir.stderr +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr @@ -1,13 +1,13 @@ error: lifetime may not live long enough - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:45:13 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:43:12 | LL | fn with_assoc<'a,'b>() { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here ... -LL | let _x: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` +LL | let _: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs index 1d53492199230..97c5559360077 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs @@ -3,8 +3,8 @@ // outlive the location in which the type appears, even when the // associted type is in a supertype. Issue #22246. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir #![allow(dead_code)] @@ -40,11 +40,9 @@ fn with_assoc<'a,'b>() { // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. - // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if - // `_x` is changed to `_` - let _x: &'a WithAssoc> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + let _: &'a WithAssoc> = loop { }; + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr deleted file mode 100644 index aa92c59cee076..0000000000000 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:42:13 - | -LL | let _x: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 34:15 - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:34:15 - | -LL | fn with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 34:18 - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:34:18 - | -LL | fn with_assoc<'a,'b>() { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr deleted file mode 100644 index 0e68a0548e622..0000000000000 --- a/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-1.rs:12:5 - | -LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough - | ^^^^^^---^^^^^^^^^^^ - | | | - | | `*v` is borrowed here - | returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-close-object-into-object-1.rs b/src/test/ui/regions/regions-close-object-into-object-1.rs index 7a862f97a99d2..5518c6a94b1d0 100644 --- a/src/test/ui/regions/regions-close-object-into-object-1.rs +++ b/src/test/ui/regions/regions-close-object-into-object-1.rs @@ -9,7 +9,7 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn f<'a, T:'static, U>(v: Box+'static>) -> Box { - box B(&*v) as Box //~ ERROR `*v` does not live long enough + box B(&*v) as Box //~ ERROR cannot return value referencing local data `*v` } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-1.stderr b/src/test/ui/regions/regions-close-object-into-object-1.stderr index 817f664db45d1..151746384547e 100644 --- a/src/test/ui/regions/regions-close-object-into-object-1.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-1.stderr @@ -1,13 +1,12 @@ -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-1.rs:12:12 +error[E0515]: cannot return value referencing local data `*v` + --> $DIR/regions-close-object-into-object-1.rs:12:5 | -LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough - | ^^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | box B(&*v) as Box //~ ERROR cannot return value referencing local data `*v` + | ^^^^^^---^^^^^^^^^^^ + | | | + | | `*v` is borrowed here + | returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr deleted file mode 100644 index 6225575ddf3a1..0000000000000 --- a/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-3.rs:11:5 - | -LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough - | ^^^^^^---^^^^^^^^^^^ - | | | - | | `*v` is borrowed here - | returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-close-object-into-object-3.rs b/src/test/ui/regions/regions-close-object-into-object-3.rs index cafbf0932249d..6f6b3a170027d 100644 --- a/src/test/ui/regions/regions-close-object-into-object-3.rs +++ b/src/test/ui/regions/regions-close-object-into-object-3.rs @@ -8,7 +8,7 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn h<'a, T, U:'static>(v: Box+'static>) -> Box { - box B(&*v) as Box //~ ERROR `*v` does not live long enough + box B(&*v) as Box //~ ERROR cannot return value referencing local data `*v` } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-3.stderr b/src/test/ui/regions/regions-close-object-into-object-3.stderr index 1736a5f215cd7..83e2fdd219c3e 100644 --- a/src/test/ui/regions/regions-close-object-into-object-3.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-3.stderr @@ -1,13 +1,12 @@ -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-3.rs:11:12 +error[E0515]: cannot return value referencing local data `*v` + --> $DIR/regions-close-object-into-object-3.rs:11:5 | -LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough - | ^^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | box B(&*v) as Box //~ ERROR cannot return value referencing local data `*v` + | ^^^^^^---^^^^^^^^^^^ + | | | + | | `*v` is borrowed here + | returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-creating-enums.nll.stderr b/src/test/ui/regions/regions-creating-enums.nll.stderr deleted file mode 100644 index fe4b97a33b5cf..0000000000000 --- a/src/test/ui/regions/regions-creating-enums.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-creating-enums.rs:23:16 - | -LL | return &Ast::Num((*f)(x)); //~ ERROR borrowed value does not live long enough - | ^----------------- - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-creating-enums.rs:28:16 - | -LL | return &Ast::Add(m_x, m_y); //~ ERROR borrowed value does not live long enough - | ^------------------ - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-creating-enums.rs b/src/test/ui/regions/regions-creating-enums.rs index ea8d4373e0931..6ed68f8033ccd 100644 --- a/src/test/ui/regions/regions-creating-enums.rs +++ b/src/test/ui/regions/regions-creating-enums.rs @@ -20,12 +20,12 @@ fn compute(x: &Ast) -> usize { fn map_nums<'a,'b, F>(x: &Ast, f: &mut F) -> &'a Ast<'b> where F: FnMut(usize) -> usize { match *x { Ast::Num(x) => { - return &Ast::Num((*f)(x)); //~ ERROR borrowed value does not live long enough + return &Ast::Num((*f)(x)); //~ ERROR cannot return reference to temporary value } Ast::Add(x, y) => { let m_x = map_nums(x, f); let m_y = map_nums(y, f); - return &Ast::Add(m_x, m_y); //~ ERROR borrowed value does not live long enough + return &Ast::Add(m_x, m_y); //~ ERROR cannot return reference to temporary value } } } diff --git a/src/test/ui/regions/regions-creating-enums.stderr b/src/test/ui/regions/regions-creating-enums.stderr index 36cd6d0c22e5b..17548e0761bf3 100644 --- a/src/test/ui/regions/regions-creating-enums.stderr +++ b/src/test/ui/regions/regions-creating-enums.stderr @@ -1,33 +1,21 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-creating-enums.rs:23:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-creating-enums.rs:23:16 | -LL | return &Ast::Num((*f)(x)); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:13... - --> $DIR/regions-creating-enums.rs:20:13 - | -LL | fn map_nums<'a,'b, F>(x: &Ast, f: &mut F) -> &'a Ast<'b> where F: FnMut(usize) -> usize { - | ^^ - = note: consider using a `let` binding to increase its lifetime +LL | return &Ast::Num((*f)(x)); //~ ERROR cannot return reference to temporary value + | ^----------------- + | || + | |temporary value created here + | returns a reference to data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-creating-enums.rs:28:17 - | -LL | return &Ast::Add(m_x, m_y); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:13... - --> $DIR/regions-creating-enums.rs:20:13 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-creating-enums.rs:28:16 | -LL | fn map_nums<'a,'b, F>(x: &Ast, f: &mut F) -> &'a Ast<'b> where F: FnMut(usize) -> usize { - | ^^ - = note: consider using a `let` binding to increase its lifetime +LL | return &Ast::Add(m_x, m_y); //~ ERROR cannot return reference to temporary value + | ^------------------ + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.ast.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.migrate.stderr similarity index 85% rename from src/test/ui/regions/regions-free-region-ordering-caller.ast.stderr rename to src/test/ui/regions/regions-free-region-ordering-caller.migrate.stderr index 73266ab50fad0..ca6667875c189 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller.ast.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller.migrate.stderr @@ -5,7 +5,7 @@ LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { | --------- --------- | | | these two types are declared with different lifetimes... -LL | let z: Option<&'b &'a usize> = None;//[ast]~ ERROR E0623 +LL | let z: Option<&'b &'a usize> = None;//[migrate]~ ERROR E0623 | ^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here error[E0623]: lifetime mismatch @@ -16,7 +16,7 @@ LL | fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { | | | these two types are declared with different lifetimes... LL | let y: Paramd<'a> = Paramd { x: a }; -LL | let z: Option<&'b Paramd<'a>> = None;//[ast]~ ERROR E0623 +LL | let z: Option<&'b Paramd<'a>> = None;//[migrate]~ ERROR E0623 | ^^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here error[E0623]: lifetime mismatch @@ -24,7 +24,7 @@ error[E0623]: lifetime mismatch | LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { | --------- --------- these two types are declared with different lifetimes... -LL | let z: Option<&'a &'b usize> = None;//[ast]~ ERROR E0623 +LL | let z: Option<&'a &'b usize> = None;//[migrate]~ ERROR E0623 | ^^^^^^^^^^^^^^^^^^^^^ ...but data from `b` flows into `a` here error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.mir.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr similarity index 84% rename from src/test/ui/regions/regions-free-region-ordering-caller.mir.stderr rename to src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr index abec468c9ea3e..832aa06ffd183 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller.mir.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr @@ -5,7 +5,7 @@ LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let z: Option<&'b &'a usize> = None;//[ast]~ ERROR E0623 +LL | let z: Option<&'b &'a usize> = None;//[migrate]~ ERROR E0623 | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` error: lifetime may not live long enough @@ -16,7 +16,7 @@ LL | fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { | | | lifetime `'a` defined here LL | let y: Paramd<'a> = Paramd { x: a }; -LL | let z: Option<&'b Paramd<'a>> = None;//[ast]~ ERROR E0623 +LL | let z: Option<&'b Paramd<'a>> = None;//[migrate]~ ERROR E0623 | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'b` error: lifetime may not live long enough @@ -26,7 +26,7 @@ LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let z: Option<&'a &'b usize> = None;//[ast]~ ERROR E0623 +LL | let z: Option<&'a &'b usize> = None;//[migrate]~ ERROR E0623 | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.rs b/src/test/ui/regions/regions-free-region-ordering-caller.rs index 621e6e78b4650..c0b12f23cdba7 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller.rs +++ b/src/test/ui/regions/regions-free-region-ordering-caller.rs @@ -2,25 +2,25 @@ // than the thing it points at and ensure that they result in // errors. See also regions-free-region-ordering-callee.rs -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir struct Paramd<'a> { x: &'a usize } fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'b &'a usize> = None;//[ast]~ ERROR E0623 - //[mir]~^ ERROR lifetime may not live long enough + let z: Option<&'b &'a usize> = None;//[migrate]~ ERROR E0623 + //[nll]~^ ERROR lifetime may not live long enough } fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { let y: Paramd<'a> = Paramd { x: a }; - let z: Option<&'b Paramd<'a>> = None;//[ast]~ ERROR E0623 - //[mir]~^ ERROR lifetime may not live long enough + let z: Option<&'b Paramd<'a>> = None;//[migrate]~ ERROR E0623 + //[nll]~^ ERROR lifetime may not live long enough } fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'a &'b usize> = None;//[ast]~ ERROR E0623 - //[mir]~^ ERROR lifetime may not live long enough + let z: Option<&'a &'b usize> = None;//[migrate]~ ERROR E0623 + //[nll]~^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.stderr deleted file mode 100644 index 67ee950ae8f5a..0000000000000 --- a/src/test/ui/regions/regions-free-region-ordering-caller.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-caller.rs:8:12 - | -LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { - | --------- --------- - | | - | these two types are declared with different lifetimes... -LL | let z: Option<&'b &'a usize> = None;//~ ERROR E0623 - | ^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here - -error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-caller.rs:13:12 - | -LL | fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { - | --------- --------- - | | - | these two types are declared with different lifetimes... -LL | let y: Paramd<'a> = Paramd { x: a }; -LL | let z: Option<&'b Paramd<'a>> = None;//~ ERROR E0623 - | ^^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here - -error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-caller.rs:17:12 - | -LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { - | --------- --------- these two types are declared with different lifetimes... -LL | let z: Option<&'a &'b usize> = None;//~ ERROR E0623 - | ^^^^^^^^^^^^^^^^^^^^^ ...but data from `b` flows into `a` here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr deleted file mode 100644 index 539343a68294f..0000000000000 --- a/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/regions-free-region-ordering-caller1.rs:9:27 - | -LL | fn call1<'a>(x: &'a usize) { - | -- lifetime `'a` defined here -... -LL | let z: &'a & usize = &(&y); - | ----------- ^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'a` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0597]: `y` does not live long enough - --> $DIR/regions-free-region-ordering-caller1.rs:9:27 - | -LL | fn call1<'a>(x: &'a usize) { - | -- lifetime `'a` defined here -... -LL | let z: &'a & usize = &(&y); - | ----------- ^^^^ borrowed value does not live long enough - | | - | type annotation requires that `y` is borrowed for `'a` -... -LL | } - | - `y` dropped here while still borrowed - -error: aborting due to 2 previous errors - -Some errors occurred: E0597, E0716. -For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.rs b/src/test/ui/regions/regions-free-region-ordering-caller1.rs index d9251c085e1d2..f32455616699f 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller1.rs +++ b/src/test/ui/regions/regions-free-region-ordering-caller1.rs @@ -7,7 +7,7 @@ fn call1<'a>(x: &'a usize) { // &'a &'z usize requires that 'a <= 'z: let y: usize = 3; let z: &'a & usize = &(&y); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed //~^^ ERROR `y` does not live long enough } diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.stderr b/src/test/ui/regions/regions-free-region-ordering-caller1.stderr index 08aaa35e08c48..539343a68294f 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller1.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller1.stderr @@ -1,33 +1,32 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-free-region-ordering-caller1.rs:9:27 | +LL | fn call1<'a>(x: &'a usize) { + | -- lifetime `'a` defined here +... LL | let z: &'a & usize = &(&y); - | ^^^^ temporary value does not live long enough + | ----------- ^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'a` ... LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 5:10... - --> $DIR/regions-free-region-ordering-caller1.rs:5:10 - | -LL | fn call1<'a>(x: &'a usize) { - | ^^ + | - temporary value is freed at the end of this statement error[E0597]: `y` does not live long enough - --> $DIR/regions-free-region-ordering-caller1.rs:9:29 + --> $DIR/regions-free-region-ordering-caller1.rs:9:27 | +LL | fn call1<'a>(x: &'a usize) { + | -- lifetime `'a` defined here +... LL | let z: &'a & usize = &(&y); - | ^ borrowed value does not live long enough + | ----------- ^^^^ borrowed value does not live long enough + | | + | type annotation requires that `y` is borrowed for `'a` ... LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 5:10... - --> $DIR/regions-free-region-ordering-caller1.rs:5:10 - | -LL | fn call1<'a>(x: &'a usize) { - | ^^ + | - `y` dropped here while still borrowed error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr b/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr deleted file mode 100644 index 62f0ceba94f29..0000000000000 --- a/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*p` - --> $DIR/regions-infer-borrow-scope-too-big.rs:13:12 - | -LL | let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough - | --- `*p` is borrowed here -LL | assert_eq!(*xc, 3); -LL | return xc; - | ^^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-infer-borrow-scope-too-big.rs b/src/test/ui/regions/regions-infer-borrow-scope-too-big.rs index 3bf1c67da9971..250b41da5788a 100644 --- a/src/test/ui/regions/regions-infer-borrow-scope-too-big.rs +++ b/src/test/ui/regions/regions-infer-borrow-scope-too-big.rs @@ -8,9 +8,9 @@ fn x_coord<'r>(p: &'r Point) -> &'r isize { } fn foo<'a>(p: Box) -> &'a isize { - let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough + let xc = x_coord(&*p); assert_eq!(*xc, 3); - return xc; + return xc; //~ ERROR cannot return value referencing local data `*p` } fn main() {} diff --git a/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr b/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr index 562ec649a48ec..193feecd7f727 100644 --- a/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr +++ b/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr @@ -1,18 +1,12 @@ -error[E0597]: `*p` does not live long enough - --> $DIR/regions-infer-borrow-scope-too-big.rs:11:23 +error[E0515]: cannot return value referencing local data `*p` + --> $DIR/regions-infer-borrow-scope-too-big.rs:13:12 | -LL | let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough - | ^^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 10:8... - --> $DIR/regions-infer-borrow-scope-too-big.rs:10:8 - | -LL | fn foo<'a>(p: Box) -> &'a isize { - | ^^ +LL | let xc = x_coord(&*p); + | --- `*p` is borrowed here +LL | assert_eq!(*xc, 3); +LL | return xc; //~ ERROR cannot return value referencing local data `*p` + | ^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr b/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr deleted file mode 100644 index b44f8c1e7a8dd..0000000000000 --- a/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/regions-infer-proc-static-upvar.rs:10:13 - | -LL | let y = &x; //~ ERROR `x` does not live long enough - | ^^ borrowed value does not live long enough -LL | / foo(move|| { -LL | | let _a = *y; -LL | | }); - | |______- argument requires that `x` is borrowed for `'static` -LL | } - | - `x` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-infer-proc-static-upvar.stderr b/src/test/ui/regions/regions-infer-proc-static-upvar.stderr index f929a06bad75d..b44f8c1e7a8dd 100644 --- a/src/test/ui/regions/regions-infer-proc-static-upvar.stderr +++ b/src/test/ui/regions/regions-infer-proc-static-upvar.stderr @@ -1,13 +1,14 @@ error[E0597]: `x` does not live long enough - --> $DIR/regions-infer-proc-static-upvar.rs:10:14 + --> $DIR/regions-infer-proc-static-upvar.rs:10:13 | -LL | let y = &x; //~ ERROR `x` does not live long enough - | ^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | let y = &x; //~ ERROR `x` does not live long enough + | ^^ borrowed value does not live long enough +LL | / foo(move|| { +LL | | let _a = *y; +LL | | }); + | |______- argument requires that `x` is borrowed for `'static` +LL | } + | - `x` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr deleted file mode 100644 index 48daff1dbd872..0000000000000 --- a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:16:3 - | -LL | let testValue = &id(Test); - | -------- temporary value created here -LL | //~^ ERROR borrowed value does not live long enough -LL | testValue - | ^^^^^^^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:22:3 - | -LL | let testValue = &id(MyEnum::Variant1); - | -------------------- temporary value created here -LL | //~^ ERROR borrowed value does not live long enough -LL | testValue - | ^^^^^^^^^ returns a value referencing data owned by the current function - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs index 2d21a51108381..1b25294c7e161 100644 --- a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs +++ b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs @@ -12,14 +12,14 @@ enum MyEnum { fn structLifetime<'a>() -> &'a Test { let testValue = &id(Test); - //~^ ERROR borrowed value does not live long enough testValue + //~^ ERROR cannot return value referencing temporary value } fn variantLifetime<'a>() -> &'a MyEnum { let testValue = &id(MyEnum::Variant1); - //~^ ERROR borrowed value does not live long enough testValue + //~^ ERROR cannot return value referencing temporary value } diff --git a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr index c0bfc475f1960..b4bf2ab312d30 100644 --- a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr +++ b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr @@ -1,33 +1,19 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:14:20 +error[E0515]: cannot return value referencing temporary value + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:15:3 | LL | let testValue = &id(Test); - | ^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:19... - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:13:19 - | -LL | fn structLifetime<'a>() -> &'a Test { - | ^^ + | -------- temporary value created here +LL | testValue + | ^^^^^^^^^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:20:20 +error[E0515]: cannot return value referencing temporary value + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:21:3 | LL | let testValue = &id(MyEnum::Variant1); - | ^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 19:20... - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:19:20 - | -LL | fn variantLifetime<'a>() -> &'a MyEnum { - | ^^ + | -------------------- temporary value created here +LL | testValue + | ^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-nested-fns-2.nll.stderr b/src/test/ui/regions/regions-nested-fns-2.nll.stderr deleted file mode 100644 index ebcc31d3a20e9..0000000000000 --- a/src/test/ui/regions/regions-nested-fns-2.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns-2.rs:8:25 - | -LL | |z| { - | --- value captured here -LL | //~^ ERROR E0373 -LL | if false { &y } else { z } - | -^ - | || - | |borrowed value does not live long enough - | returning this value requires that `y` is borrowed for `'static` -LL | }); -LL | } - | - `y` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-nested-fns-2.rs b/src/test/ui/regions/regions-nested-fns-2.rs index 1b51880f4159b..3b3e26c4503d4 100644 --- a/src/test/ui/regions/regions-nested-fns-2.rs +++ b/src/test/ui/regions/regions-nested-fns-2.rs @@ -4,8 +4,8 @@ fn nested() { let y = 3; ignore( |z| { - //~^ ERROR E0373 if false { &y } else { z } + //~^ ERROR `y` does not live long enough }); } diff --git a/src/test/ui/regions/regions-nested-fns-2.stderr b/src/test/ui/regions/regions-nested-fns-2.stderr index 924eac6fdd41e..43c8d1272c744 100644 --- a/src/test/ui/regions/regions-nested-fns-2.stderr +++ b/src/test/ui/regions/regions-nested-fns-2.stderr @@ -1,16 +1,17 @@ -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/regions-nested-fns-2.rs:6:9 +error[E0597]: `y` does not live long enough + --> $DIR/regions-nested-fns-2.rs:7:25 | LL | |z| { - | ^^^ may outlive borrowed value `y` -LL | //~^ ERROR E0373 + | --- value captured here LL | if false { &y } else { z } - | - `y` is borrowed here -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | move |z| { - | ^^^^^^^^ + | -^ + | || + | |borrowed value does not live long enough + | returning this value requires that `y` is borrowed for `'static` +... +LL | } + | - `y` dropped here while still borrowed error: aborting due to previous error -For more information about this error, try `rustc --explain E0373`. +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.ast.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-hrtb.ast.stderr rename to src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.mir.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-hrtb.mir.stderr rename to src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs index 2871d962c42c9..407a4fdf59bb7 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs +++ b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs @@ -1,8 +1,8 @@ // Test that structs with higher-ranked where clauses don't generate // "outlives" requirements. Issue #22246. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir #![allow(dead_code)] @@ -33,8 +33,8 @@ fn with_assoc<'a,'b>() { // We get an error because 'b:'a does not hold: let _: &'a WithHrAssoc> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } /////////////////////////////////////////////////////////////////////////// @@ -55,8 +55,8 @@ fn with_assoc_sub<'a,'b>() { // below to be well-formed, it is not related to the HR relation. let _: &'a WithHrAssocSub> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.stderr deleted file mode 100644 index 856e28f141f10..0000000000000 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0491]: in type `&'a WithHrAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container-hrtb.rs:32:12 - | -LL | let _: &'a WithHrAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 29:15 - --> $DIR/regions-outlives-projection-container-hrtb.rs:29:15 - | -LL | fn with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 29:18 - --> $DIR/regions-outlives-projection-container-hrtb.rs:29:18 - | -LL | fn with_assoc<'a,'b>() { - | ^^ - -error[E0491]: in type `&'a WithHrAssocSub>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container-hrtb.rs:53:12 - | -LL | let _: &'a WithHrAssocSub> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 49:19 - --> $DIR/regions-outlives-projection-container-hrtb.rs:49:19 - | -LL | fn with_assoc_sub<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 49:22 - --> $DIR/regions-outlives-projection-container-hrtb.rs:49:22 - | -LL | fn with_assoc_sub<'a,'b>() { - | ^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.ast.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.migrate.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-wc.ast.stderr rename to src/test/ui/regions/regions-outlives-projection-container-wc.migrate.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.mir.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-wc.mir.stderr rename to src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.rs b/src/test/ui/regions/regions-outlives-projection-container-wc.rs index 37622211327c0..5037ea536dae9 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.rs +++ b/src/test/ui/regions/regions-outlives-projection-container-wc.rs @@ -3,8 +3,8 @@ // outlive the location in which the type appears, even when the // constraint is in a where clause not a bound. Issue #22246. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir #![allow(dead_code)] @@ -35,8 +35,8 @@ fn with_assoc<'a,'b>() { // which is &'b (), must outlive 'a. let _: &'a WithAssoc> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.stderr deleted file mode 100644 index 0d73d3d64322e..0000000000000 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container-wc.rs:34:12 - | -LL | let _: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 28:15 - --> $DIR/regions-outlives-projection-container-wc.rs:28:15 - | -LL | fn with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 28:18 - --> $DIR/regions-outlives-projection-container-wc.rs:28:18 - | -LL | fn with_assoc<'a,'b>() { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr deleted file mode 100644 index 8809cf4b09e52..0000000000000 --- a/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `line` does not live long enough - --> $DIR/regions-pattern-typing-issue-19552.rs:5:14 - | -LL | match [&*line] { //~ ERROR `line` does not live long enough - | ^^^^ borrowed value does not live long enough -LL | [ word ] => { assert_static(word); } - | ------------------- argument requires that `line` is borrowed for `'static` -LL | } -LL | } - | - `line` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19552.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19552.stderr index ad80925cad7d2..8809cf4b09e52 100644 --- a/src/test/ui/regions/regions-pattern-typing-issue-19552.stderr +++ b/src/test/ui/regions/regions-pattern-typing-issue-19552.stderr @@ -3,11 +3,11 @@ error[E0597]: `line` does not live long enough | LL | match [&*line] { //~ ERROR `line` does not live long enough | ^^^^ borrowed value does not live long enough -... +LL | [ word ] => { assert_static(word); } + | ------------------- argument requires that `line` is borrowed for `'static` +LL | } LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `line` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.stderr deleted file mode 100644 index e23c6ada2b565..0000000000000 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `a1` because it is borrowed - --> $DIR/regions-pattern-typing-issue-19997.rs:10:13 - | -LL | match (&a1,) { - | -- borrow of `a1` occurs here -LL | (&ref b0,) => { -LL | a1 = &f; //[ast]~ ERROR cannot assign - | ^^^^^^^ assignment to borrowed `a1` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19997.mir.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19997.mir.stderr deleted file mode 100644 index 935620075f7c6..0000000000000 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `a1` because it is borrowed - --> $DIR/regions-pattern-typing-issue-19997.rs:10:13 - | -LL | match (&a1,) { - | --- borrow of `a1` occurs here -LL | (&ref b0,) => { -LL | a1 = &f; //[ast]~ ERROR cannot assign - | ^^^^^^^ assignment to borrowed `a1` occurs here -LL | //[mir]~^ ERROR cannot assign to `a1` because it is borrowed -LL | drop(b0); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19997.rs b/src/test/ui/regions/regions-pattern-typing-issue-19997.rs index 35f38af0cfef1..39190697fe70e 100644 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.rs +++ b/src/test/ui/regions/regions-pattern-typing-issue-19997.rs @@ -1,14 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let a0 = 0; let f = 1; let mut a1 = &a0; match (&a1,) { (&ref b0,) => { - a1 = &f; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `a1` because it is borrowed + a1 = &f; //~ ERROR cannot assign to `a1` because it is borrowed drop(b0); } } diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.nll.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19997.stderr similarity index 68% rename from src/test/ui/regions/regions-pattern-typing-issue-19997.ast.nll.stderr rename to src/test/ui/regions/regions-pattern-typing-issue-19997.stderr index 935620075f7c6..b9ac4d7b4b0f4 100644 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.nll.stderr +++ b/src/test/ui/regions/regions-pattern-typing-issue-19997.stderr @@ -1,12 +1,11 @@ error[E0506]: cannot assign to `a1` because it is borrowed - --> $DIR/regions-pattern-typing-issue-19997.rs:10:13 + --> $DIR/regions-pattern-typing-issue-19997.rs:7:13 | LL | match (&a1,) { | --- borrow of `a1` occurs here LL | (&ref b0,) => { -LL | a1 = &f; //[ast]~ ERROR cannot assign +LL | a1 = &f; //~ ERROR cannot assign to `a1` because it is borrowed | ^^^^^^^ assignment to borrowed `a1` occurs here -LL | //[mir]~^ ERROR cannot assign to `a1` because it is borrowed LL | drop(b0); | -- borrow later used here diff --git a/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr b/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr deleted file mode 100644 index bead12356f1f2..0000000000000 --- a/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0515]: cannot return value referencing function parameter - --> $DIR/regions-ref-in-fn-arg.rs:5:5 - | -LL | fn arg_item(box ref x: Box) -> &'static isize { - | --------- function parameter borrowed here -LL | x //~^ ERROR borrowed value does not live long enough - | ^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing function parameter - --> $DIR/regions-ref-in-fn-arg.rs:11:22 - | -LL | with(|box ref x| x) //~ ERROR borrowed value does not live long enough - | --------- ^ returns a value referencing data owned by the current function - | | - | function parameter borrowed here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-ref-in-fn-arg.rs b/src/test/ui/regions/regions-ref-in-fn-arg.rs index cf9e7b27ed0af..d1cbd279b65a5 100644 --- a/src/test/ui/regions/regions-ref-in-fn-arg.rs +++ b/src/test/ui/regions/regions-ref-in-fn-arg.rs @@ -2,13 +2,13 @@ #![feature(box_syntax)] fn arg_item(box ref x: Box) -> &'static isize { - x //~^ ERROR borrowed value does not live long enough + x //~ ERROR cannot return value referencing function parameter } fn with(f: F) -> R where F: FnOnce(Box) -> R { f(box 3) } fn arg_closure() -> &'static isize { - with(|box ref x| x) //~ ERROR borrowed value does not live long enough + with(|box ref x| x) //~ ERROR cannot return value referencing function parameter } fn main() {} diff --git a/src/test/ui/regions/regions-ref-in-fn-arg.stderr b/src/test/ui/regions/regions-ref-in-fn-arg.stderr index 748508ecbcd39..fcf66ac148cff 100644 --- a/src/test/ui/regions/regions-ref-in-fn-arg.stderr +++ b/src/test/ui/regions/regions-ref-in-fn-arg.stderr @@ -1,24 +1,19 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ref-in-fn-arg.rs:4:17 +error[E0515]: cannot return value referencing function parameter + --> $DIR/regions-ref-in-fn-arg.rs:5:5 | LL | fn arg_item(box ref x: Box) -> &'static isize { - | ^^^^^ borrowed value does not live long enough -LL | x //~^ ERROR borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | --------- function parameter borrowed here +LL | x //~ ERROR cannot return value referencing function parameter + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ref-in-fn-arg.rs:11:15 - | -LL | with(|box ref x| x) //~ ERROR borrowed value does not live long enough - | ^^^^^ - borrowed value only lives until here - | | - | borrowed value does not live long enough +error[E0515]: cannot return value referencing function parameter + --> $DIR/regions-ref-in-fn-arg.rs:11:22 | - = note: borrowed value must be valid for the static lifetime... +LL | with(|box ref x| x) //~ ERROR cannot return value referencing function parameter + | --------- ^ returns a value referencing data owned by the current function + | | + | function parameter borrowed here error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-ret.nll.stderr b/src/test/ui/regions/regions-ret.nll.stderr deleted file mode 100644 index b8b4ce56bb249..0000000000000 --- a/src/test/ui/regions/regions-ret.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-ret.rs:4:12 - | -LL | return &id(3); //~ ERROR borrowed value does not live long enough - | ^----- - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-ret.rs b/src/test/ui/regions/regions-ret.rs index a094d1af5b709..580545ef8566c 100644 --- a/src/test/ui/regions/regions-ret.rs +++ b/src/test/ui/regions/regions-ret.rs @@ -1,7 +1,7 @@ fn id(x: T) -> T { x } fn f(_x: &isize) -> &isize { - return &id(3); //~ ERROR borrowed value does not live long enough + return &id(3); //~ ERROR cannot return reference to temporary value } fn main() { diff --git a/src/test/ui/regions/regions-ret.stderr b/src/test/ui/regions/regions-ret.stderr index 001f62ab60cde..2afd7d4501945 100644 --- a/src/test/ui/regions/regions-ret.stderr +++ b/src/test/ui/regions/regions-ret.stderr @@ -1,20 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ret.rs:4:13 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-ret.rs:4:12 | -LL | return &id(3); //~ ERROR borrowed value does not live long enough - | ^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 3:1... - --> $DIR/regions-ret.rs:3:1 - | -LL | / fn f(_x: &isize) -> &isize { -LL | | return &id(3); //~ ERROR borrowed value does not live long enough -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime +LL | return &id(3); //~ ERROR cannot return reference to temporary value + | ^----- + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr b/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr deleted file mode 100644 index 1bdcf83521d0a..0000000000000 --- a/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-return-stack-allocated-vec.rs:4:5 - | -LL | &[x] //~ ERROR borrowed value does not live long enough - | ^--- - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-return-stack-allocated-vec.rs b/src/test/ui/regions/regions-return-stack-allocated-vec.rs index 8d071dbc60695..97fbdbf46851e 100644 --- a/src/test/ui/regions/regions-return-stack-allocated-vec.rs +++ b/src/test/ui/regions/regions-return-stack-allocated-vec.rs @@ -1,7 +1,7 @@ // Test that we cannot return a stack allocated slice fn function(x: isize) -> &'static [isize] { - &[x] //~ ERROR borrowed value does not live long enough + &[x] //~ ERROR cannot return reference to temporary value } fn main() { diff --git a/src/test/ui/regions/regions-return-stack-allocated-vec.stderr b/src/test/ui/regions/regions-return-stack-allocated-vec.stderr index 78eec7cc456e8..44a477eff89e0 100644 --- a/src/test/ui/regions/regions-return-stack-allocated-vec.stderr +++ b/src/test/ui/regions/regions-return-stack-allocated-vec.stderr @@ -1,13 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-return-stack-allocated-vec.rs:4:6 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-return-stack-allocated-vec.rs:4:5 | -LL | &[x] //~ ERROR borrowed value does not live long enough - | ^^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | &[x] //~ ERROR cannot return reference to temporary value + | ^--- + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-static-bound.ll.stderr b/src/test/ui/regions/regions-static-bound.migrate.stderr similarity index 83% rename from src/test/ui/regions/regions-static-bound.ll.stderr rename to src/test/ui/regions/regions-static-bound.migrate.stderr index 4695a82ebb4cd..c1f80d0c12802 100644 --- a/src/test/ui/regions/regions-static-bound.ll.stderr +++ b/src/test/ui/regions/regions-static-bound.migrate.stderr @@ -1,7 +1,7 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... --> $DIR/regions-static-bound.rs:9:5 | -LL | t //[ll]~ ERROR E0312 +LL | t //[migrate]~ ERROR E0312 | ^ | = note: ...the reference is valid for the static lifetime... @@ -16,7 +16,7 @@ error[E0621]: explicit lifetime required in the type of `u` | LL | fn error(u: &(), v: &()) { | --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()` -LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] +LL | static_id(&u); //[migrate]~ ERROR explicit lifetime required in the type of `u` [E0621] | ^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` @@ -25,7 +25,7 @@ error[E0621]: explicit lifetime required in the type of `v` LL | fn error(u: &(), v: &()) { | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` ... -LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] +LL | static_id_indirect(&v); //[migrate]~ ERROR explicit lifetime required in the type of `v` [E0621] | ^^^^^^^^^^^^^^^^^^ lifetime `'static` required error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-static-bound.nll.stderr b/src/test/ui/regions/regions-static-bound.nll.stderr index d6cec03e0ff2e..5ce3edb0a86b2 100644 --- a/src/test/ui/regions/regions-static-bound.nll.stderr +++ b/src/test/ui/regions/regions-static-bound.nll.stderr @@ -3,7 +3,7 @@ error: lifetime may not live long enough | LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | -- lifetime `'a` defined here -LL | t //[ll]~ ERROR E0312 +LL | t //[migrate]~ ERROR E0312 | ^ returning this value requires that `'a` must outlive `'static` error[E0621]: explicit lifetime required in the type of `u` @@ -11,7 +11,7 @@ error[E0621]: explicit lifetime required in the type of `u` | LL | fn error(u: &(), v: &()) { | --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()` -LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] +LL | static_id(&u); //[migrate]~ ERROR explicit lifetime required in the type of `u` [E0621] | ^^^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` @@ -20,7 +20,7 @@ error[E0621]: explicit lifetime required in the type of `v` LL | fn error(u: &(), v: &()) { | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` ... -LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] +LL | static_id_indirect(&v); //[migrate]~ ERROR explicit lifetime required in the type of `v` [E0621] | ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-static-bound.rs b/src/test/ui/regions/regions-static-bound.rs index c1a15e50a4d06..1db54881d3e03 100644 --- a/src/test/ui/regions/regions-static-bound.rs +++ b/src/test/ui/regions/regions-static-bound.rs @@ -1,4 +1,4 @@ -// revisions: ll nll +// revisions: migrate nll //[nll] compile-flags:-Zborrowck=mir fn static_id<'a,'b>(t: &'a ()) -> &'static () @@ -6,14 +6,14 @@ fn static_id<'a,'b>(t: &'a ()) -> &'static () fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () where 'a: 'b, 'b: 'static { t } fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { - t //[ll]~ ERROR E0312 + t //[migrate]~ ERROR E0312 //[nll]~^ ERROR lifetime may not live long enough } fn error(u: &(), v: &()) { - static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + static_id(&u); //[migrate]~ ERROR explicit lifetime required in the type of `u` [E0621] //[nll]~^ ERROR explicit lifetime required in the type of `u` [E0621] - static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + static_id_indirect(&v); //[migrate]~ ERROR explicit lifetime required in the type of `v` [E0621] //[nll]~^ ERROR explicit lifetime required in the type of `v` [E0621] } diff --git a/src/test/ui/regions/regions-steal-closure.nll.stderr b/src/test/ui/regions/regions-steal-closure.nll.stderr deleted file mode 100644 index c30f9c52363a6..0000000000000 --- a/src/test/ui/regions/regions-steal-closure.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `i` does not live long enough - --> $DIR/regions-steal-closure.rs:14:28 - | -LL | let mut cl_box = { - | ---------- borrow later stored here -LL | let mut i = 3; -LL | box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough - | -- ^ borrowed value does not live long enough - | | - | value captured here -LL | }; - | - `i` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-steal-closure.stderr b/src/test/ui/regions/regions-steal-closure.stderr index dc5c167153525..c30f9c52363a6 100644 --- a/src/test/ui/regions/regions-steal-closure.stderr +++ b/src/test/ui/regions/regions-steal-closure.stderr @@ -1,15 +1,15 @@ error[E0597]: `i` does not live long enough --> $DIR/regions-steal-closure.rs:14:28 | +LL | let mut cl_box = { + | ---------- borrow later stored here +LL | let mut i = 3; LL | box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough | -- ^ borrowed value does not live long enough | | - | capture occurs here + | value captured here LL | }; - | - borrowed value only lives until here -LL | cl_box.cl.call_mut(()); -LL | } - | - borrowed value needs to live until here + | - `i` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/regions/regions-trait-variance.nll.stderr b/src/test/ui/regions/regions-trait-variance.nll.stderr deleted file mode 100644 index ca05c93a7ecea..0000000000000 --- a/src/test/ui/regions/regions-trait-variance.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing local data `*b` - --> $DIR/regions-trait-variance.rs:38:5 - | -LL | let bb: &B = &*b; //~ ERROR `*b` does not live long enough - | --- `*b` is borrowed here -LL | make_a(bb) - | ^^^^^^^^^^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-trait-variance.rs b/src/test/ui/regions/regions-trait-variance.rs index d5462b21fa71c..73baa84ec9049 100644 --- a/src/test/ui/regions/regions-trait-variance.rs +++ b/src/test/ui/regions/regions-trait-variance.rs @@ -34,8 +34,8 @@ fn make_make_a<'a>() -> A<'a> { let b: Box = box B { i: 1, }; - let bb: &B = &*b; //~ ERROR `*b` does not live long enough - make_a(bb) + let bb: &B = &*b; + make_a(bb) //~ ERROR cannot return value referencing local data `*b` } fn main() { diff --git a/src/test/ui/regions/regions-trait-variance.stderr b/src/test/ui/regions/regions-trait-variance.stderr index ddc8ce9796d60..356b257552f2b 100644 --- a/src/test/ui/regions/regions-trait-variance.stderr +++ b/src/test/ui/regions/regions-trait-variance.stderr @@ -1,18 +1,11 @@ -error[E0597]: `*b` does not live long enough - --> $DIR/regions-trait-variance.rs:37:19 +error[E0515]: cannot return value referencing local data `*b` + --> $DIR/regions-trait-variance.rs:38:5 | -LL | let bb: &B = &*b; //~ ERROR `*b` does not live long enough - | ^^ borrowed value does not live long enough -LL | make_a(bb) -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 33:16... - --> $DIR/regions-trait-variance.rs:33:16 - | -LL | fn make_make_a<'a>() -> A<'a> { - | ^^ +LL | let bb: &B = &*b; + | --- `*b` is borrowed here +LL | make_a(bb) //~ ERROR cannot return value referencing local data `*b` + | ^^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr b/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr deleted file mode 100644 index e38574e774d14..0000000000000 --- a/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/regions-var-type-out-of-scope.rs:9:14 - | -LL | x = &id(3); //~ ERROR borrowed value does not live long enough - | ^^^^^- temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -LL | assert_eq!(*x, 3); - | ------------------ borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/regions/regions-var-type-out-of-scope.rs b/src/test/ui/regions/regions-var-type-out-of-scope.rs index e972163097490..aba55e9df6ac6 100644 --- a/src/test/ui/regions/regions-var-type-out-of-scope.rs +++ b/src/test/ui/regions/regions-var-type-out-of-scope.rs @@ -6,7 +6,7 @@ fn foo(cond: bool) { let mut x; if cond { - x = &id(3); //~ ERROR borrowed value does not live long enough + x = &id(3); //~ ERROR temporary value dropped while borrowed assert_eq!(*x, 3); } } diff --git a/src/test/ui/regions/regions-var-type-out-of-scope.stderr b/src/test/ui/regions/regions-var-type-out-of-scope.stderr index f474b9a2343cf..12ea6728ee72b 100644 --- a/src/test/ui/regions/regions-var-type-out-of-scope.stderr +++ b/src/test/ui/regions/regions-var-type-out-of-scope.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-var-type-out-of-scope.rs:9:14 | -LL | x = &id(3); //~ ERROR borrowed value does not live long enough - | ^^^^^- temporary value dropped here while still borrowed +LL | x = &id(3); //~ ERROR temporary value dropped while borrowed + | ^^^^^- temporary value is freed at the end of this statement | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here + | creates a temporary which is freed while still in use +LL | assert_eq!(*x, 3); + | ------------------ borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr index 4c17ce23b3768..34e8b0e14399e 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr @@ -1,9 +1,10 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/feature-gate.rs:33:16 +error: compilation successful + --> $DIR/feature-gate.rs:41:1 | -LL | A { a: v } if *v == 42 => v, - | ^ moves value into pattern guard +LL | / fn main() { +LL | | foo(107) +LL | | } + | |_^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr index 4bde9b0c8d910..34e8b0e14399e 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr @@ -1,5 +1,5 @@ error: compilation successful - --> $DIR/feature-gate.rs:42:1 + --> $DIR/feature-gate.rs:41:1 | LL | / fn main() { LL | | foo(107) diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr index 4bde9b0c8d910..34e8b0e14399e 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr @@ -1,5 +1,5 @@ error: compilation successful - --> $DIR/feature-gate.rs:42:1 + --> $DIR/feature-gate.rs:41:1 | LL | / fn main() { LL | | foo(107) diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr index 4bde9b0c8d910..34e8b0e14399e 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr @@ -1,5 +1,5 @@ error: compilation successful - --> $DIR/feature-gate.rs:42:1 + --> $DIR/feature-gate.rs:41:1 | LL | / fn main() { LL | | foo(107) diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr index 4c17ce23b3768..2a1a04b3f494c 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr @@ -3,6 +3,8 @@ error[E0008]: cannot bind by-move into a pattern guard | LL | A { a: v } if *v == 42 => v, | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs index f6df4d07baad0..97f90f7762a41 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs @@ -32,7 +32,6 @@ fn foo(n: i32) { A { a: v } if *v == 42 => v, //[no_gate]~^ ERROR cannot bind by-move into a pattern guard - //[gate_and_2015]~^^ ERROR cannot bind by-move into a pattern guard _ => Box::new(0) }; @@ -42,6 +41,7 @@ fn foo(n: i32) { fn main() { foo(107) } -//[gate_and_2018]~^^^ ERROR compilation successful -//[gate_and_znll]~^^^^ ERROR compilation successful -//[gate_and_feature_nll]~^^^^^ ERROR compilation successful +//[gate_and_2015]~^^^ ERROR compilation successful +//[gate_and_2018]~^^^^ ERROR compilation successful +//[gate_and_znll]~^^^^^ ERROR compilation successful +//[gate_and_feature_nll]~^^^^^^ ERROR compilation successful diff --git a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr deleted file mode 100644 index 3a6f66ca4dac5..0000000000000 --- a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-issue-49631.rs:20:9 - | -LL | while let Some(Ok(string)) = foo.get() { - | --- immutable borrow occurs here -LL | foo.mutate(); - | ^^^^^^^^^^^^ mutable borrow occurs here -LL | //~^ ERROR cannot borrow `foo` as mutable -LL | println!("foo={:?}", *string); - | ------- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr index e946d41e23489..3a6f66ca4dac5 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr @@ -2,11 +2,12 @@ error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immu --> $DIR/borrowck-issue-49631.rs:20:9 | LL | while let Some(Ok(string)) = foo.get() { - | --- - immutable borrow ends here - | | - | immutable borrow occurs here + | --- immutable borrow occurs here LL | foo.mutate(); - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^ mutable borrow occurs here +LL | //~^ ERROR cannot borrow `foo` as mutable +LL | println!("foo={:?}", *string); + | ------- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr b/src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr deleted file mode 100644 index 5920be4132a96..0000000000000 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/enum.rs:9:5 - | -LL | *x += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/enum.rs:13:9 - | -LL | *x += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/enum.rs:19:9 - | -LL | *x += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.rs b/src/test/ui/rfc-2005-default-binding-mode/enum.rs index 7609345404feb..af82d36f87eb0 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/enum.rs @@ -6,17 +6,17 @@ use Wrapper::Wrap; pub fn main() { let Wrap(x) = &Wrap(3); - *x += 1; //~ ERROR cannot assign to immutable + *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference if let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to immutable + *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference } else { panic!(); } while let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to immutable + *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference break; } } diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.stderr b/src/test/ui/rfc-2005-default-binding-mode/enum.stderr index d29b0111d8bb2..e5976b3bcbb5f 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/enum.stderr @@ -1,20 +1,20 @@ -error[E0594]: cannot assign to immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/enum.rs:9:5 | -LL | *x += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ cannot borrow as mutable +LL | *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/enum.rs:13:9 | -LL | *x += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ cannot borrow as mutable +LL | *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/enum.rs:19:9 | -LL | *x += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ cannot borrow as mutable +LL | *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr deleted file mode 100644 index 2206c2f340e14..0000000000000 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0594]: cannot assign to `*n` which is behind a `&` reference - --> $DIR/explicit-mut.rs:7:13 - | -LL | *n += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*n` which is behind a `&` reference - --> $DIR/explicit-mut.rs:15:13 - | -LL | *n += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*n` which is behind a `&` reference - --> $DIR/explicit-mut.rs:23:13 - | -LL | *n += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs index 73efddef6cd10..212fd94ded3e7 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs @@ -4,7 +4,7 @@ fn main() { match &&Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to immutable + *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference let _ = n; } None => {}, @@ -12,7 +12,7 @@ fn main() { match &mut &Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to immutable + *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference let _ = n; } None => {}, @@ -20,7 +20,7 @@ fn main() { match &&mut Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to immutable + *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference let _ = n; } None => {}, diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr index e03f67760d7e7..631de514e6d2f 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr @@ -1,20 +1,20 @@ -error[E0594]: cannot assign to immutable borrowed content `*n` +error[E0594]: cannot assign to `*n` which is behind a `&` reference --> $DIR/explicit-mut.rs:7:13 | -LL | *n += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ cannot borrow as mutable +LL | *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to immutable borrowed content `*n` +error[E0594]: cannot assign to `*n` which is behind a `&` reference --> $DIR/explicit-mut.rs:15:13 | -LL | *n += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ cannot borrow as mutable +LL | *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to immutable borrowed content `*n` +error[E0594]: cannot assign to `*n` which is behind a `&` reference --> $DIR/explicit-mut.rs:23:13 | -LL | *n += 1; //~ ERROR cannot assign to immutable - | ^^^^^^^ cannot borrow as mutable +LL | *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr deleted file mode 100644 index 5a730ad2be42c..0000000000000 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:9:18 - | -LL | let a = NoCopy(0); - | - move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait -LL | let _ = dbg!(a); - | ------- value moved here -LL | let _ = dbg!(a); //~ ERROR use of moved value - | ^ value used here after move - | - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs index e6ddb3d91bfef..9f3c567b641b5 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs @@ -7,5 +7,4 @@ fn main() { let a = NoCopy(0); let _ = dbg!(a); let _ = dbg!(a); //~ ERROR use of moved value - //~^ ERROR use of moved value } diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr index 5f3a6b414e048..5a730ad2be42c 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr @@ -1,25 +1,15 @@ error[E0382]: use of moved value: `a` --> $DIR/dbg-macro-move-semantics.rs:9:18 | +LL | let a = NoCopy(0); + | - move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait LL | let _ = dbg!(a); | ------- value moved here LL | let _ = dbg!(a); //~ ERROR use of moved value | ^ value used here after move | - = note: move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:9:13 - | -LL | let _ = dbg!(a); - | ------- value moved here -LL | let _ = dbg!(a); //~ ERROR use of moved value - | ^^^^^^^ value used here after move - | - = note: move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/slice-mut-2.nll.stderr b/src/test/ui/slice-mut-2.nll.stderr deleted file mode 100644 index eeef23e694b7a..0000000000000 --- a/src/test/ui/slice-mut-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/slice-mut-2.rs:7:18 - | -LL | let x: &[isize] = &[1, 2, 3, 4, 5]; - | ---------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4, 5]` -... -LL | let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/slice-mut-2.rs b/src/test/ui/slice-mut-2.rs index 9586103f5f18c..216edbb780886 100644 --- a/src/test/ui/slice-mut-2.rs +++ b/src/test/ui/slice-mut-2.rs @@ -4,5 +4,5 @@ fn main() { let x: &[isize] = &[1, 2, 3, 4, 5]; // Can't mutably slice an immutable slice let slice: &mut [isize] = &mut [0, 1]; - let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable + let _ = &mut x[2..4]; //~ERROR cannot borrow `*x` as mutable, as it is behind a `&` reference } diff --git a/src/test/ui/slice-mut-2.stderr b/src/test/ui/slice-mut-2.stderr index 07a8bd7699ec2..ca0fb43c27df6 100644 --- a/src/test/ui/slice-mut-2.stderr +++ b/src/test/ui/slice-mut-2.stderr @@ -1,8 +1,11 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/slice-mut-2.rs:7:18 | -LL | let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable - | ^ cannot borrow as mutable +LL | let x: &[isize] = &[1, 2, 3, 4, 5]; + | ---------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4, 5]` +... +LL | let _ = &mut x[2..4]; //~ERROR cannot borrow `*x` as mutable, as it is behind a `&` reference + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr deleted file mode 100644 index 0aa44fa3a3ae0..0000000000000 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr +++ /dev/null @@ -1,88 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:53:24 - | -LL | fn deref_mut_field1(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | let __isize = &mut x.y; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10 - | -LL | fn deref_extend_mut_field1(x: &Own) -> &mut isize { - | ----------- help: consider changing this to be a mutable reference: `&mut Own` -LL | &mut x.y //~ ERROR cannot borrow - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19 - | -LL | let _x = &mut x.x; - | - first mutable borrow occurs here -LL | let _y = &mut x.y; //~ ERROR cannot borrow - | ^ second mutable borrow occurs here -LL | use_mut(_x); - | -- first borrow later used here - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:5 - | -LL | fn assign_field1<'a>(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | x.y = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5 - | -LL | fn assign_field2<'a>(x: &'a Own) { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | x.y = 3; //~ ERROR cannot borrow - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5 - | -LL | let _p: &mut Point = &mut **x; - | -- first mutable borrow occurs here -LL | x.y = 3; //~ ERROR cannot borrow - | ^ second mutable borrow occurs here -LL | use_mut(_p); - | -- first borrow later used here - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:109:5 - | -LL | fn deref_mut_method1(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | x.set(0, 0); //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5 - | -LL | fn deref_extend_mut_method1(x: &Own) -> &mut isize { - | ----------- help: consider changing this to be a mutable reference: `&mut Own` -LL | x.y_mut() //~ ERROR cannot borrow - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6 - | -LL | fn assign_method1<'a>(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6 - | -LL | fn assign_method2<'a>(x: &'a Own) { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 10 previous errors - -Some errors occurred: E0499, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr index e0524be6b0c46..0aa44fa3a3ae0 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr @@ -1,18 +1,18 @@ -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:53:24 | LL | fn deref_mut_field1(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | let __isize = &mut x.y; //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10 | LL | fn deref_extend_mut_field1(x: &Own) -> &mut isize { - | ----------- use `&mut Own` here to make mutable + | ----------- help: consider changing this to be a mutable reference: `&mut Own` LL | &mut x.y //~ ERROR cannot borrow - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19 @@ -22,24 +22,23 @@ LL | let _x = &mut x.x; LL | let _y = &mut x.y; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | use_mut(_x); -LL | } - | - first borrow ends here + | -- first borrow later used here -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:5 | LL | fn assign_field1<'a>(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.y = 3; //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5 | LL | fn assign_field2<'a>(x: &'a Own) { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` LL | x.y = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5 @@ -49,40 +48,39 @@ LL | let _p: &mut Point = &mut **x; LL | x.y = 3; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | use_mut(_p); -LL | } - | - first borrow ends here + | -- first borrow later used here -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:109:5 | LL | fn deref_mut_method1(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.set(0, 0); //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5 | LL | fn deref_extend_mut_method1(x: &Own) -> &mut isize { - | ----------- use `&mut Own` here to make mutable + | ----------- help: consider changing this to be a mutable reference: `&mut Own` LL | x.y_mut() //~ ERROR cannot borrow - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6 | LL | fn assign_method1<'a>(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6 | LL | fn assign_method2<'a>(x: &'a Own) { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` LL | *x.y_mut() = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 10 previous errors diff --git a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.nll.stderr b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.nll.stderr deleted file mode 100644 index ef80e4bc3d645..0000000000000 --- a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:29:25 - | -LL | fn deref_mut1(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | let __isize = &mut *x; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:41:11 - | -LL | fn deref_extend_mut1<'a>(x: &'a Own) -> &'a mut isize { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | &mut **x //~ ERROR cannot borrow - | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6 - | -LL | fn assign1<'a>(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | *x = 3; //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:53:6 - | -LL | fn assign2<'a>(x: &'a Own) { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | **x = 3; //~ ERROR cannot borrow - | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr index 46d11065a86e5..ef80e4bc3d645 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr @@ -1,34 +1,34 @@ -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:29:25 | LL | fn deref_mut1(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | let __isize = &mut *x; //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:41:11 | LL | fn deref_extend_mut1<'a>(x: &'a Own) -> &'a mut isize { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` LL | &mut **x //~ ERROR cannot borrow - | ^^ cannot borrow as mutable + | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6 | LL | fn assign1<'a>(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | *x = 3; //~ ERROR cannot borrow - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:53:6 | LL | fn assign2<'a>(x: &'a Own) { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` LL | **x = 3; //~ ERROR cannot borrow - | ^^ cannot borrow as mutable + | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 4 previous errors diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr deleted file mode 100644 index e752a467edcf3..0000000000000 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr +++ /dev/null @@ -1,52 +0,0 @@ -error[E0499]: cannot borrow `f` as mutable more than once at a time - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:12:16 - | -LL | f(Box::new(|| { - | - ^^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call -LL | //~^ ERROR: cannot borrow `f` as mutable more than once -LL | f((Box::new(|| {}))) - | - second borrow occurs due to use of `f` in closure - -error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5 - | -LL | fn test2(f: &F) where F: FnMut() { - | -- help: consider changing this to be a mutable reference: `&mut F` -LL | (*f)(); - | ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*f.f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5 - | -LL | fn test4(f: &Test) { - | ----- help: consider changing this to be a mutable reference: `&mut Test<'_>` -LL | f.f.call_mut(()) - | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13 - | -LL | let mut f = move |g: Box, b: isize| { - | ----- captured outer variable -... -LL | foo(f); - | ^ cannot move out of captured variable in an `FnMut` closure - -error[E0505]: cannot move out of `f` because it is borrowed - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16 - | -LL | f(Box::new(|a| { - | - ^^^ move out of `f` occurs here - | | - | borrow of `f` occurs here - | borrow later used by call -LL | foo(f); - | - move occurs due to use in closure - -error: aborting due to 5 previous errors - -Some errors occurred: E0499, E0505, E0507, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs index cfebd6f700359..f4072b7f1a1e5 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs @@ -23,7 +23,7 @@ fn test1() { fn test2(f: &F) where F: FnMut() { (*f)(); - //~^ ERROR cannot borrow immutable borrowed content `*f` as mutable + //~^ ERROR cannot borrow `*f` as mutable, as it is behind a `&` reference } fn test3(f: &mut F) where F: FnMut() { @@ -32,7 +32,7 @@ fn test3(f: &mut F) where F: FnMut() { fn test4(f: &Test) { f.f.call_mut(()) - //~^ ERROR: cannot borrow `Box` content `*f.f` of immutable binding as mutable + //~^ ERROR: cannot borrow `*f.f` as mutable, as it is behind a `&` reference } fn test5(f: &mut Test) { @@ -53,9 +53,9 @@ fn test7() { let _ = s.len(); }; f(Box::new(|a| { + //~^ ERROR cannot move out of `f` because it is borrowed foo(f); - //~^ ERROR cannot move `f` into closure because it is borrowed - //~| ERROR cannot move out of captured outer variable in an `FnMut` closure + //~^ ERROR cannot move out of captured variable in an `FnMut` closure }), 3); } diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr index d81d402fce733..ae2aa835efbb4 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -5,46 +5,49 @@ LL | f(Box::new(|| { | - ^^ second mutable borrow occurs here | | | first mutable borrow occurs here + | first borrow later used by call LL | //~^ ERROR: cannot borrow `f` as mutable more than once LL | f((Box::new(|| {}))) - | - borrow occurs due to use of `f` in closure -LL | })); - | - first borrow ends here + | - second borrow occurs due to use of `f` in closure -error[E0596]: cannot borrow immutable borrowed content `*f` as mutable +error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5 | LL | fn test2(f: &F) where F: FnMut() { - | -- use `&mut F` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut F` LL | (*f)(); - | ^^^^ cannot borrow as mutable + | ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow `Box` content `*f.f` of immutable binding as mutable +error[E0596]: cannot borrow `*f.f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5 | LL | fn test4(f: &Test) { - | ----- use `&mut Test` here to make mutable + | ----- help: consider changing this to be a mutable reference: `&mut Test<'_>` LL | f.f.call_mut(()) - | ^^^ cannot borrow as mutable + | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0504]: cannot move `f` into closure because it is borrowed - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13 - | -LL | f(Box::new(|a| { - | - borrow of `f` occurs here -LL | foo(f); - | ^ move into closure occurs here - -error[E0507]: cannot move out of captured outer variable in an `FnMut` closure - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13 +error[E0507]: cannot move out of captured variable in an `FnMut` closure + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 | LL | let mut f = move |g: Box, b: isize| { | ----- captured outer variable ... LL | foo(f); - | ^ cannot move out of captured outer variable in an `FnMut` closure + | ^ cannot move out of captured variable in an `FnMut` closure + +error[E0505]: cannot move out of `f` because it is borrowed + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16 + | +LL | f(Box::new(|a| { + | - ^^^ move out of `f` occurs here + | | + | borrow of `f` occurs here + | borrow later used by call +LL | //~^ ERROR cannot move out of `f` because it is borrowed +LL | foo(f); + | - move occurs due to use in closure error: aborting due to 5 previous errors -Some errors occurred: E0499, E0504, E0507, E0596. +Some errors occurred: E0499, E0505, E0507, E0596. For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.nll.stderr b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.nll.stderr deleted file mode 100644 index 16c482b575aae..0000000000000 --- a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-call-method-from-mut-aliasable.rs:17:5 - | -LL | fn b(x: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut Foo` -LL | x.f(); -LL | x.h(); //~ ERROR cannot borrow - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr index 4875e27ef4552..16c482b575aae 100644 --- a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr +++ b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-method-from-mut-aliasable.rs:17:5 | LL | fn b(x: &Foo) { - | ---- use `&mut Foo` here to make mutable + | ---- help: consider changing this to be a mutable reference: `&mut Foo` LL | x.f(); LL | x.h(); //~ ERROR cannot borrow - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-fn-in-const-b.nll.stderr b/src/test/ui/span/borrowck-fn-in-const-b.nll.stderr deleted file mode 100644 index 9133d482c29c6..0000000000000 --- a/src/test/ui/span/borrowck-fn-in-const-b.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-fn-in-const-b.rs:7:9 - | -LL | fn broken(x: &Vec) { - | ------------ help: consider changing this to be a mutable reference: `&mut std::vec::Vec` -LL | x.push(format!("this is broken")); - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-fn-in-const-b.stderr b/src/test/ui/span/borrowck-fn-in-const-b.stderr index 4a30bdf3b08cb..9133d482c29c6 100644 --- a/src/test/ui/span/borrowck-fn-in-const-b.stderr +++ b/src/test/ui/span/borrowck-fn-in-const-b.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-fn-in-const-b.rs:7:9 | LL | fn broken(x: &Vec) { - | ------------ use `&mut Vec` here to make mutable + | ------------ help: consider changing this to be a mutable reference: `&mut std::vec::Vec` LL | x.push(format!("this is broken")); - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr b/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr deleted file mode 100644 index f5f1193264822..0000000000000 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:19:14 - | -LL | v3.push(&id('x')); // statement 6 - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); - | -- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:29:18 - | -LL | v4.push(&id('y')); - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | v4.use_ref(); - | -- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:40:14 - | -LL | v5.push(&id('z')); - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); - | -- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs index 4b14907cec04f..4744f3710ce53 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs @@ -1,4 +1,3 @@ -#![feature(rustc_attrs)] fn id(x: T) -> T { x } fn f() { @@ -7,51 +6,52 @@ fn f() { let mut v2 = Vec::new(); // statement 2 - let young = ['y']; // statement 3 + { + let young = ['y']; // statement 3 - v2.push(&young[0]); // statement 4 - //~^ ERROR `young[..]` does not live long enough - //~| NOTE borrowed value does not live long enough - //~| NOTE values in a scope are dropped in the opposite order they are created + v2.push(&young[0]); // statement 4 + //~^ ERROR `young[_]` does not live long enough + //~| NOTE borrowed value does not live long enough + } //~ NOTE `young[_]` dropped here while still borrowed let mut v3 = Vec::new(); // statement 5 v3.push(&id('x')); // statement 6 - //~^ ERROR borrowed value does not live long enough - //~| NOTE temporary value does not live long enough - //~| NOTE temporary value dropped here while still borrowed - //~| NOTE consider using a `let` binding to increase its lifetime + //~^ ERROR temporary value dropped while borrowed + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE consider using a `let` binding to create a longer lived value { let mut v4 = Vec::new(); // (sub) statement 0 v4.push(&id('y')); - //~^ ERROR borrowed value does not live long enough - //~| NOTE temporary value does not live long enough - //~| NOTE temporary value dropped here while still borrowed - //~| NOTE consider using a `let` binding to increase its lifetime + //~^ ERROR temporary value dropped while borrowed + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE consider using a `let` binding to create a longer lived value v4.use_ref(); + //~^ NOTE borrow later used here } // (statement 7) - //~^ NOTE temporary value needs to live until here let mut v5 = Vec::new(); // statement 8 v5.push(&id('z')); - //~^ ERROR borrowed value does not live long enough - //~| NOTE temporary value does not live long enough - //~| NOTE temporary value dropped here while still borrowed - //~| NOTE consider using a `let` binding to increase its lifetime + //~^ ERROR temporary value dropped while borrowed + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE consider using a `let` binding to create a longer lived value v1.push(&old[0]); (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + //~^ NOTE borrow later used here + //~| NOTE borrow later used here + //~| NOTE borrow later used here } -//~^ NOTE `young[..]` dropped here while still borrowed -//~| NOTE temporary value needs to live until here -//~| NOTE temporary value needs to live until here -fn main() { #![rustc_error] // rust-lang/rust#49855 +fn main() { f(); } diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr index 8bf542e37ff19..557e48797ccfe 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr @@ -1,53 +1,55 @@ -error[E0597]: `young[..]` does not live long enough - --> $DIR/borrowck-let-suggestion-suffixes.rs:12:14 +error[E0597]: `young[_]` does not live long enough + --> $DIR/borrowck-let-suggestion-suffixes.rs:12:17 | -LL | v2.push(&young[0]); // statement 4 - | ^^^^^^^^ borrowed value does not live long enough +LL | v2.push(&young[0]); // statement 4 + | ^^^^^^^^^ borrowed value does not live long enough ... -LL | } - | - `young[..]` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created +LL | } //~ NOTE `young[_]` dropped here while still borrowed + | - `young[_]` dropped here while still borrowed +... +LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + | -- borrow later used here -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:19:14 | LL | v3.push(&id('x')); // statement 6 - | ^^^^^^^ - temporary value dropped here while still borrowed + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } - | - temporary value needs to live until here +LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:29:18 | LL | v4.push(&id('y')); - | ^^^^^^^ - temporary value dropped here while still borrowed + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } // (statement 7) - | - temporary value needs to live until here +LL | v4.use_ref(); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:40:14 | LL | v5.push(&id('z')); - | ^^^^^^^ - temporary value dropped here while still borrowed + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... -LL | } - | - temporary value needs to live until here +LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/borrowck-object-mutability.nll.stderr b/src/test/ui/span/borrowck-object-mutability.nll.stderr deleted file mode 100644 index 1a5802e98114d..0000000000000 --- a/src/test/ui/span/borrowck-object-mutability.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-object-mutability.rs:8:5 - | -LL | fn borrowed_receiver(x: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut dyn Foo` -LL | x.borrowed(); -LL | x.borrowed_mut(); //~ ERROR cannot borrow - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable - --> $DIR/borrowck-object-mutability.rs:18:5 - | -LL | fn owned_receiver(x: Box) { - | - help: consider changing this to be mutable: `mut x` -LL | x.borrowed(); -LL | x.borrowed_mut(); //~ ERROR cannot borrow - | ^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-object-mutability.stderr b/src/test/ui/span/borrowck-object-mutability.stderr index e846331dc0b86..1a5802e98114d 100644 --- a/src/test/ui/span/borrowck-object-mutability.stderr +++ b/src/test/ui/span/borrowck-object-mutability.stderr @@ -1,17 +1,17 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-object-mutability.rs:8:5 | LL | fn borrowed_receiver(x: &Foo) { - | ---- use `&mut Foo` here to make mutable + | ---- help: consider changing this to be a mutable reference: `&mut dyn Foo` LL | x.borrowed(); LL | x.borrowed_mut(); //~ ERROR cannot borrow - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable `Box` content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-object-mutability.rs:18:5 | LL | fn owned_receiver(x: Box) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.borrowed(); LL | x.borrowed_mut(); //~ ERROR cannot borrow | ^ cannot borrow as mutable diff --git a/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr b/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr deleted file mode 100644 index 4f529ce9511db..0000000000000 --- a/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-ref-into-rvalue.rs:3:11 - | -LL | match Some("Hello".to_string()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use -... -LL | } - | - temporary value is freed at the end of this statement -LL | println!("{}", *msg); - | ---- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/borrowck-ref-into-rvalue.rs b/src/test/ui/span/borrowck-ref-into-rvalue.rs index aeaebf073a708..c11aa1af54095 100644 --- a/src/test/ui/span/borrowck-ref-into-rvalue.rs +++ b/src/test/ui/span/borrowck-ref-into-rvalue.rs @@ -1,8 +1,8 @@ fn main() { let msg; match Some("Hello".to_string()) { + //~^ ERROR temporary value dropped while borrowed Some(ref m) => { - //~^ ERROR borrowed value does not live long enough msg = m; }, None => { panic!() } diff --git a/src/test/ui/span/borrowck-ref-into-rvalue.stderr b/src/test/ui/span/borrowck-ref-into-rvalue.stderr index b8e79be8b61b8..4f529ce9511db 100644 --- a/src/test/ui/span/borrowck-ref-into-rvalue.stderr +++ b/src/test/ui/span/borrowck-ref-into-rvalue.stderr @@ -1,17 +1,16 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-ref-into-rvalue.rs:4:14 +error[E0716]: temporary value dropped while borrowed + --> $DIR/borrowck-ref-into-rvalue.rs:3:11 | -LL | Some(ref m) => { - | ^^^^^ borrowed value does not live long enough +LL | match Some("Hello".to_string()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use ... LL | } - | - borrowed value dropped here while still borrowed + | - temporary value is freed at the end of this statement LL | println!("{}", *msg); -LL | } - | - borrowed value needs to live until here + | ---- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/destructor-restrictions.nll.stderr b/src/test/ui/span/destructor-restrictions.nll.stderr deleted file mode 100644 index 981c5a23816fa..0000000000000 --- a/src/test/ui/span/destructor-restrictions.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0597]: `*a` does not live long enough - --> $DIR/destructor-restrictions.rs:8:10 - | -LL | *a.borrow() + 1 - | ^--------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | }; //~^ ERROR `*a` does not live long enough - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, i32>` - | | - | `*a` dropped here while still borrowed - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/destructor-restrictions.stderr b/src/test/ui/span/destructor-restrictions.stderr index 8fec877467813..981c5a23816fa 100644 --- a/src/test/ui/span/destructor-restrictions.stderr +++ b/src/test/ui/span/destructor-restrictions.stderr @@ -2,11 +2,16 @@ error[E0597]: `*a` does not live long enough --> $DIR/destructor-restrictions.rs:8:10 | LL | *a.borrow() + 1 - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | }; //~^ ERROR `*a` does not live long enough - | -- borrowed value needs to live until here + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, i32>` | | | `*a` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to previous error diff --git a/src/test/ui/span/dropck-object-cycle.nll.stderr b/src/test/ui/span/dropck-object-cycle.nll.stderr deleted file mode 100644 index cfaf470212fdd..0000000000000 --- a/src/test/ui/span/dropck-object-cycle.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `*m` does not live long enough - --> $DIR/dropck-object-cycle.rs:27:31 - | -LL | assert_eq!(object_invoke1(&*m), (4,5)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `*m` dropped here while still borrowed - | borrow might be used here, when `m` is dropped and runs the destructor for type `std::boxed::Box>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck-object-cycle.stderr b/src/test/ui/span/dropck-object-cycle.stderr index 3fc52853d0220..cfaf470212fdd 100644 --- a/src/test/ui/span/dropck-object-cycle.stderr +++ b/src/test/ui/span/dropck-object-cycle.stderr @@ -1,13 +1,14 @@ error[E0597]: `*m` does not live long enough - --> $DIR/dropck-object-cycle.rs:27:32 + --> $DIR/dropck-object-cycle.rs:27:31 | LL | assert_eq!(object_invoke1(&*m), (4,5)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `*m` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `*m` dropped here while still borrowed + | borrow might be used here, when `m` is dropped and runs the destructor for type `std::boxed::Box>` error: aborting due to previous error diff --git a/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr b/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr deleted file mode 100644 index e9caae64beb82..0000000000000 --- a/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:93:24 - | -LL | b1.a[0].v.set(Some(&b2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `b2` dropped here while still borrowed - | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `b3` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:95:24 - | -LL | b1.a[1].v.set(Some(&b3)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `b3` dropped here while still borrowed - | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `b1` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:101:24 - | -LL | b3.a[0].v.set(Some(&b1)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `b1` dropped here while still borrowed - | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_arr_cycle_checked.rs b/src/test/ui/span/dropck_arr_cycle_checked.rs index 35145014a5a40..ac31e4910d5a6 100644 --- a/src/test/ui/span/dropck_arr_cycle_checked.rs +++ b/src/test/ui/span/dropck_arr_cycle_checked.rs @@ -95,13 +95,10 @@ fn f() { b1.a[1].v.set(Some(&b3)); //~^ ERROR `b3` does not live long enough b2.a[0].v.set(Some(&b2)); - //~^ ERROR `b2` does not live long enough b2.a[1].v.set(Some(&b3)); - //~^ ERROR `b3` does not live long enough b3.a[0].v.set(Some(&b1)); //~^ ERROR `b1` does not live long enough b3.a[1].v.set(Some(&b2)); - //~^ ERROR `b2` does not live long enough } fn main() { diff --git a/src/test/ui/span/dropck_arr_cycle_checked.stderr b/src/test/ui/span/dropck_arr_cycle_checked.stderr index aae71799e30f2..068c779ae5267 100644 --- a/src/test/ui/span/dropck_arr_cycle_checked.stderr +++ b/src/test/ui/span/dropck_arr_cycle_checked.stderr @@ -1,69 +1,43 @@ error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:93:25 + --> $DIR/dropck_arr_cycle_checked.rs:93:24 | LL | b1.a[0].v.set(Some(&b2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `b2` dropped here while still borrowed + | - + | | + | `b2` dropped here while still borrowed + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `b3` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:95:25 + --> $DIR/dropck_arr_cycle_checked.rs:95:24 | LL | b1.a[1].v.set(Some(&b3)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `b3` dropped here while still borrowed + | - + | | + | `b3` dropped here while still borrowed + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:97:25 - | -LL | b2.a[0].v.set(Some(&b2)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `b2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `b3` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:99:25 - | -LL | b2.a[1].v.set(Some(&b3)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `b3` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `b1` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:101:25 + --> $DIR/dropck_arr_cycle_checked.rs:99:24 | LL | b3.a[0].v.set(Some(&b1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `b1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:103:25 - | -LL | b3.a[1].v.set(Some(&b2)); - | ^^ borrowed value does not live long enough -LL | //~^ ERROR `b2` does not live long enough -LL | } - | - `b2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `b1` dropped here while still borrowed + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr b/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr deleted file mode 100644 index 5774ac13cb7e5..0000000000000 --- a/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `d2` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:36:19 - | -LL | d1.p.set(Some(&d2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `d2` dropped here while still borrowed - | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `d1` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:38:19 - | -LL | d2.p.set(Some(&d1)); - | ^^^ borrowed value does not live long enough -LL | //~^ ERROR `d1` does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr index bc4b517c51d6e..5774ac13cb7e5 100644 --- a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr +++ b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr @@ -1,24 +1,28 @@ error[E0597]: `d2` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:36:20 + --> $DIR/dropck_direct_cycle_with_drop.rs:36:19 | LL | d1.p.set(Some(&d2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `d2` dropped here while still borrowed + | - + | | + | `d2` dropped here while still borrowed + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `d1` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:38:20 + --> $DIR/dropck_direct_cycle_with_drop.rs:38:19 | LL | d2.p.set(Some(&d1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | //~^ ERROR `d1` does not live long enough LL | } - | - `d1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` error: aborting due to 2 previous errors diff --git a/src/test/ui/span/dropck_misc_variants.nll.stderr b/src/test/ui/span/dropck_misc_variants.nll.stderr deleted file mode 100644 index 76e90574cef44..0000000000000 --- a/src/test/ui/span/dropck_misc_variants.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0597]: `bomb` does not live long enough - --> $DIR/dropck_misc_variants.rs:23:36 - | -LL | _w = Wrap::<&[&str]>(NoisyDrop(&bomb)); - | ^^^^^ borrowed value does not live long enough -LL | } - | - - | | - | `bomb` dropped here while still borrowed - | borrow might be used here, when `_w` is dropped and runs the destructor for type `Wrap<&[&str]>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `v` does not live long enough - --> $DIR/dropck_misc_variants.rs:31:27 - | -LL | let u = NoisyDrop(&v); - | ^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `v` dropped here while still borrowed - | borrow might be used here, when `_w` is dropped and runs the destructor for closure - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_misc_variants.stderr b/src/test/ui/span/dropck_misc_variants.stderr index b2de455cdc819..76e90574cef44 100644 --- a/src/test/ui/span/dropck_misc_variants.stderr +++ b/src/test/ui/span/dropck_misc_variants.stderr @@ -1,23 +1,29 @@ error[E0597]: `bomb` does not live long enough - --> $DIR/dropck_misc_variants.rs:23:37 + --> $DIR/dropck_misc_variants.rs:23:36 | LL | _w = Wrap::<&[&str]>(NoisyDrop(&bomb)); - | ^^^^ borrowed value does not live long enough + | ^^^^^ borrowed value does not live long enough LL | } - | - `bomb` dropped here while still borrowed + | - + | | + | `bomb` dropped here while still borrowed + | borrow might be used here, when `_w` is dropped and runs the destructor for type `Wrap<&[&str]>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `v` does not live long enough - --> $DIR/dropck_misc_variants.rs:31:28 + --> $DIR/dropck_misc_variants.rs:31:27 | LL | let u = NoisyDrop(&v); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } - | - `v` dropped here while still borrowed + | - + | | + | `v` dropped here while still borrowed + | borrow might be used here, when `_w` is dropped and runs the destructor for closure | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr deleted file mode 100644 index 05692515af846..0000000000000 --- a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:98:24 - | -LL | c1.v[0].v.set(Some(&c2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c2` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:100:24 - | -LL | c1.v[1].v.set(Some(&c3)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c3` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:106:24 - | -LL | c3.v[0].v.set(Some(&c1)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c1` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_vec_cycle_checked.rs b/src/test/ui/span/dropck_vec_cycle_checked.rs index c80e0386e6a15..bacd99c68254f 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.rs +++ b/src/test/ui/span/dropck_vec_cycle_checked.rs @@ -100,13 +100,10 @@ fn f() { c1.v[1].v.set(Some(&c3)); //~^ ERROR `c3` does not live long enough c2.v[0].v.set(Some(&c2)); - //~^ ERROR `c2` does not live long enough c2.v[1].v.set(Some(&c3)); - //~^ ERROR `c3` does not live long enough c3.v[0].v.set(Some(&c1)); //~^ ERROR `c1` does not live long enough c3.v[1].v.set(Some(&c2)); - //~^ ERROR `c2` does not live long enough } fn main() { diff --git a/src/test/ui/span/dropck_vec_cycle_checked.stderr b/src/test/ui/span/dropck_vec_cycle_checked.stderr index 35e4314d0c66f..7ff991c0c3737 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.stderr +++ b/src/test/ui/span/dropck_vec_cycle_checked.stderr @@ -1,69 +1,43 @@ error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:98:25 + --> $DIR/dropck_vec_cycle_checked.rs:98:24 | LL | c1.v[0].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c2` dropped here while still borrowed + | - + | | + | `c2` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:100:25 + --> $DIR/dropck_vec_cycle_checked.rs:100:24 | LL | c1.v[1].v.set(Some(&c3)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c3` dropped here while still borrowed + | - + | | + | `c3` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:102:25 - | -LL | c2.v[0].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `c2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:104:25 - | -LL | c2.v[1].v.set(Some(&c3)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `c3` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:106:25 + --> $DIR/dropck_vec_cycle_checked.rs:104:24 | LL | c3.v[0].v.set(Some(&c1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:108:25 - | -LL | c3.v[1].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough -LL | //~^ ERROR `c2` does not live long enough -LL | } - | - `c2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `c1` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-11925.nll.stderr b/src/test/ui/span/issue-11925.nll.stderr deleted file mode 100644 index f5e329f6c397e..0000000000000 --- a/src/test/ui/span/issue-11925.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0515]: cannot return reference to local data `x` - --> $DIR/issue-11925.rs:8:35 - | -LL | let f = to_fn_once(move|| &x); //~ ERROR does not live long enough - | ^^ returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/span/issue-11925.rs b/src/test/ui/span/issue-11925.rs index 276aaa1c2931d..0f6472b05f7aa 100644 --- a/src/test/ui/span/issue-11925.rs +++ b/src/test/ui/span/issue-11925.rs @@ -5,7 +5,7 @@ fn to_fn_once>(f: F) -> F { f } fn main() { let r = { let x: Box<_> = box 42; - let f = to_fn_once(move|| &x); //~ ERROR does not live long enough + let f = to_fn_once(move|| &x); //~ ERROR cannot return reference to local data `x` f() }; diff --git a/src/test/ui/span/issue-11925.stderr b/src/test/ui/span/issue-11925.stderr index 46e2a41b3c34d..57f75234720f8 100644 --- a/src/test/ui/span/issue-11925.stderr +++ b/src/test/ui/span/issue-11925.stderr @@ -1,15 +1,9 @@ -error[E0597]: `x` does not live long enough - --> $DIR/issue-11925.rs:8:36 +error[E0515]: cannot return reference to local data `x` + --> $DIR/issue-11925.rs:8:35 | -LL | let f = to_fn_once(move|| &x); //~ ERROR does not live long enough - | ^ - | | - | borrowed value does not live long enough - | `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | let f = to_fn_once(move|| &x); //~ ERROR cannot return reference to local data `x` + | ^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/span/issue-15480.nll.stderr b/src/test/ui/span/issue-15480.nll.stderr deleted file mode 100644 index 23ee2256dd85b..0000000000000 --- a/src/test/ui/span/issue-15480.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-15480.rs:5:10 - | -LL | &id(3) - | ^^^^^ creates a temporary which is freed while still in use -LL | ]; - | - temporary value is freed at the end of this statement -... -LL | for &&x in &v { - | -- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/issue-15480.rs b/src/test/ui/span/issue-15480.rs index c1024234094b6..b286d94178a1e 100644 --- a/src/test/ui/span/issue-15480.rs +++ b/src/test/ui/span/issue-15480.rs @@ -4,7 +4,7 @@ fn main() { let v = vec![ &id(3) ]; - //~^^ ERROR borrowed value does not live long enough + //~^^ ERROR temporary value dropped while borrowed for &&x in &v { println!("{}", x + 3); diff --git a/src/test/ui/span/issue-15480.stderr b/src/test/ui/span/issue-15480.stderr index c5e3899faca49..23ee2256dd85b 100644 --- a/src/test/ui/span/issue-15480.stderr +++ b/src/test/ui/span/issue-15480.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-15480.rs:5:10 | LL | &id(3) - | ^^^^^ temporary value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use LL | ]; - | - temporary value dropped here while still borrowed + | - temporary value is freed at the end of this statement ... -LL | } - | - temporary value needs to live until here +LL | for &&x in &v { + | -- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr b/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr deleted file mode 100644 index 4696945814586..0000000000000 --- a/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:10:5 - | -LL | y.borrow().clone() - | ^--------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | } - | - - | | - | `y` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `y` does not live long enough - --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:17:9 - | -LL | y.borrow().clone() - | ^--------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` - | | - | `y` dropped here while still borrowed - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr b/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr index f18f0da3199f0..4696945814586 100644 --- a/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr +++ b/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr @@ -2,21 +2,32 @@ error[E0597]: `y` does not live long enough --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:10:5 | LL | y.borrow().clone() - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | } - | - `y` dropped here while still borrowed + | - + | | + | `y` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `y` does not live long enough --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:17:9 | LL | y.borrow().clone() - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | }; - | -- borrowed value needs to live until here + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` | | | `y` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr b/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr deleted file mode 100644 index 809e60a8c8aac..0000000000000 --- a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-child-has-items-via-parent.rs:28:18 - | -LL | _d = D_Child(&d1); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_Child` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr b/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr index ad90fcd54d44b..809e60a8c8aac 100644 --- a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr +++ b/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr @@ -1,13 +1,16 @@ error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-child-has-items-via-parent.rs:28:19 + --> $DIR/issue-24805-dropck-child-has-items-via-parent.rs:28:18 | LL | _d = D_Child(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_Child` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr b/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr deleted file mode 100644 index 2e217066915d3..0000000000000 --- a/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:37:26 - | -LL | _d = D_HasSelfMethod(&d1); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasSelfMethod` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:43:33 - | -LL | _d = D_HasMethodWithSelfArg(&d1); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasMethodWithSelfArg` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:49:20 - | -LL | _d = D_HasType(&d1); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasType` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr b/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr index 3de40149287e0..2e217066915d3 100644 --- a/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr +++ b/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr @@ -1,32 +1,41 @@ error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:37:27 + --> $DIR/issue-24805-dropck-trait-has-items.rs:37:26 | LL | _d = D_HasSelfMethod(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasSelfMethod` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:43:34 + --> $DIR/issue-24805-dropck-trait-has-items.rs:43:33 | LL | _d = D_HasMethodWithSelfArg(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasMethodWithSelfArg` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:49:21 + --> $DIR/issue-24805-dropck-trait-has-items.rs:49:20 | LL | _d = D_HasType(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasType` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 3 previous errors diff --git a/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr b/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr deleted file mode 100644 index 18a3dc9e6defa..0000000000000 --- a/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24895-copy-clone-dropck.rs:27:14 - | -LL | d2 = D(S(&d1, "inner"), "d2"); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-24895-copy-clone-dropck.stderr b/src/test/ui/span/issue-24895-copy-clone-dropck.stderr index 91859194318bd..18a3dc9e6defa 100644 --- a/src/test/ui/span/issue-24895-copy-clone-dropck.stderr +++ b/src/test/ui/span/issue-24895-copy-clone-dropck.stderr @@ -1,12 +1,15 @@ error[E0597]: `d1` does not live long enough - --> $DIR/issue-24895-copy-clone-dropck.rs:27:15 + --> $DIR/issue-24895-copy-clone-dropck.rs:27:14 | LL | d2 = D(S(&d1, "inner"), "d2"); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/span/issue-25199.nll.stderr b/src/test/ui/span/issue-25199.nll.stderr deleted file mode 100644 index d70a4afc1bf34..0000000000000 --- a/src/test/ui/span/issue-25199.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `container` does not live long enough - --> $DIR/issue-25199.rs:70:27 - | -LL | let test = Test{test: &container}; - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `container` dropped here while still borrowed - | borrow might be used here, when `container` is dropped and runs the destructor for type `Container<'_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-25199.rs b/src/test/ui/span/issue-25199.rs index 4ef57457ca340..ed690443d4ddb 100644 --- a/src/test/ui/span/issue-25199.rs +++ b/src/test/ui/span/issue-25199.rs @@ -71,5 +71,4 @@ fn main() { //~^ ERROR `container` does not live long enough println!("container.v[30]: {:?}", container.v.v[30]); container.store(test); - //~^ ERROR `container` does not live long enough } diff --git a/src/test/ui/span/issue-25199.stderr b/src/test/ui/span/issue-25199.stderr index 135d8150c34ed..d70a4afc1bf34 100644 --- a/src/test/ui/span/issue-25199.stderr +++ b/src/test/ui/span/issue-25199.stderr @@ -1,25 +1,15 @@ error[E0597]: `container` does not live long enough - --> $DIR/issue-25199.rs:70:28 + --> $DIR/issue-25199.rs:70:27 | LL | let test = Test{test: &container}; - | ^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `container` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `container` does not live long enough - --> $DIR/issue-25199.rs:73:5 - | -LL | container.store(test); - | ^^^^^^^^^ borrowed value does not live long enough -LL | //~^ ERROR `container` does not live long enough -LL | } - | - `container` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `container` dropped here while still borrowed + | borrow might be used here, when `container` is dropped and runs the destructor for type `Container<'_>` -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-26656.nll.stderr b/src/test/ui/span/issue-26656.nll.stderr deleted file mode 100644 index 1e939c484fb7b..0000000000000 --- a/src/test/ui/span/issue-26656.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `ticking` does not live long enough - --> $DIR/issue-26656.rs:40:35 - | -LL | zook.button = B::BigRedButton(&ticking); - | ^^^^^^^^ borrowed value does not live long enough -LL | } - | - - | | - | `ticking` dropped here while still borrowed - | borrow might be used here, when `zook` is dropped and runs the `Drop` code for type `Zook` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-26656.stderr b/src/test/ui/span/issue-26656.stderr index ba2befb90a9c1..1e939c484fb7b 100644 --- a/src/test/ui/span/issue-26656.stderr +++ b/src/test/ui/span/issue-26656.stderr @@ -1,12 +1,15 @@ error[E0597]: `ticking` does not live long enough - --> $DIR/issue-26656.rs:40:36 + --> $DIR/issue-26656.rs:40:35 | LL | zook.button = B::BigRedButton(&ticking); - | ^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^ borrowed value does not live long enough LL | } - | - `ticking` dropped here while still borrowed + | - + | | + | `ticking` dropped here while still borrowed + | borrow might be used here, when `zook` is dropped and runs the `Drop` code for type `Zook` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/span/issue-29106.nll.stderr b/src/test/ui/span/issue-29106.nll.stderr deleted file mode 100644 index 3b403de12d536..0000000000000 --- a/src/test/ui/span/issue-29106.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:16:26 - | -LL | y = Arc::new(Foo(&x)); - | ^^ borrowed value does not live long enough -LL | } - | - - | | - | `x` dropped here while still borrowed - | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::sync::Arc` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:23:25 - | -LL | y = Rc::new(Foo(&x)); - | ^^ borrowed value does not live long enough -LL | } - | - - | | - | `x` dropped here while still borrowed - | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::rc::Rc` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-29106.stderr b/src/test/ui/span/issue-29106.stderr index bb2f8462246b1..3b403de12d536 100644 --- a/src/test/ui/span/issue-29106.stderr +++ b/src/test/ui/span/issue-29106.stderr @@ -1,22 +1,28 @@ error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:16:27 + --> $DIR/issue-29106.rs:16:26 | LL | y = Arc::new(Foo(&x)); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } - | - `x` dropped here while still borrowed + | - + | | + | `x` dropped here while still borrowed + | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::sync::Arc` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:23:26 + --> $DIR/issue-29106.rs:23:25 | LL | y = Rc::new(Foo(&x)); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } - | - `x` dropped here while still borrowed + | - + | | + | `x` dropped here while still borrowed + | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::rc::Rc` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-36537.nll.stderr b/src/test/ui/span/issue-36537.nll.stderr deleted file mode 100644 index edb804e850e2c..0000000000000 --- a/src/test/ui/span/issue-36537.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/issue-36537.rs:5:9 - | -LL | p = &a; - | ^^^^^^ borrowed value does not live long enough -... -LL | } - | - `a` dropped here while still borrowed -LL | p.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-36537.stderr b/src/test/ui/span/issue-36537.stderr index d3bcbb25add3c..edb804e850e2c 100644 --- a/src/test/ui/span/issue-36537.stderr +++ b/src/test/ui/span/issue-36537.stderr @@ -1,14 +1,13 @@ error[E0597]: `a` does not live long enough - --> $DIR/issue-36537.rs:5:14 + --> $DIR/issue-36537.rs:5:9 | LL | p = &a; - | ^ borrowed value does not live long enough + | ^^^^^^ borrowed value does not live long enough ... LL | } | - `a` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | p.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/issue-40157.nll.stderr b/src/test/ui/span/issue-40157.nll.stderr deleted file mode 100644 index 0b365c3f7b6b3..0000000000000 --- a/src/test/ui/span/issue-40157.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `foo` does not live long enough - --> $DIR/issue-40157.rs:2:53 - | -LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });} - | ------------------------^^^--------- - | | | | - | | | `foo` dropped here while still borrowed - | | borrowed value does not live long enough - | borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-40157.stderr b/src/test/ui/span/issue-40157.stderr index 55fc8d8ee5f56..0b365c3f7b6b3 100644 --- a/src/test/ui/span/issue-40157.stderr +++ b/src/test/ui/span/issue-40157.stderr @@ -2,13 +2,11 @@ error[E0597]: `foo` does not live long enough --> $DIR/issue-40157.rs:2:53 | LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });} - | -----------------------------------------------^^^---------------------- - | | | | - | | | `foo` dropped here while still borrowed - | | borrowed value does not live long enough - | borrowed value needs to live until here - | - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + | ------------------------^^^--------- + | | | | + | | | `foo` dropped here while still borrowed + | | borrowed value does not live long enough + | borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/issue28498-reject-ex1.nll.stderr b/src/test/ui/span/issue28498-reject-ex1.nll.stderr deleted file mode 100644 index 86e2d8c56b08f..0000000000000 --- a/src/test/ui/span/issue28498-reject-ex1.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue28498-reject-ex1.rs:34:29 - | -LL | foo.data[0].1.set(Some(&foo.data[1])); - | ^^^^^^^^ -... -LL | } - | - - | | - | here, drop of `foo` needs exclusive access to `foo.data`, because the type `Foo>` implements the `Drop` trait - | borrow might be used here, when `foo` is dropped and runs the `Drop` code for type `Foo` - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/span/issue28498-reject-ex1.rs b/src/test/ui/span/issue28498-reject-ex1.rs index 05104d1cdc020..4d1b4125503b6 100644 --- a/src/test/ui/span/issue28498-reject-ex1.rs +++ b/src/test/ui/span/issue28498-reject-ex1.rs @@ -32,7 +32,6 @@ fn main() { foo.data.push(Concrete(0, Cell::new(None))); foo.data[0].1.set(Some(&foo.data[1])); - //~^ ERROR `foo.data` does not live long enough + //~^ ERROR borrow may still be in use when destructor runs foo.data[1].1.set(Some(&foo.data[0])); - //~^ ERROR `foo.data` does not live long enough } diff --git a/src/test/ui/span/issue28498-reject-ex1.stderr b/src/test/ui/span/issue28498-reject-ex1.stderr index 8daef82f8bbd8..86e2d8c56b08f 100644 --- a/src/test/ui/span/issue28498-reject-ex1.stderr +++ b/src/test/ui/span/issue28498-reject-ex1.stderr @@ -1,25 +1,17 @@ -error[E0597]: `foo.data` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue28498-reject-ex1.rs:34:29 | LL | foo.data[0].1.set(Some(&foo.data[1])); - | ^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^ ... LL | } - | - `foo.data` dropped here while still borrowed + | - + | | + | here, drop of `foo` needs exclusive access to `foo.data`, because the type `Foo>` implements the `Drop` trait + | borrow might be used here, when `foo` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: consider using a `let` binding to create a longer lived value -error[E0597]: `foo.data` does not live long enough - --> $DIR/issue28498-reject-ex1.rs:36:29 - | -LL | foo.data[1].1.set(Some(&foo.data[0])); - | ^^^^^^^^ borrowed value does not live long enough -LL | //~^ ERROR `foo.data` does not live long enough -LL | } - | - `foo.data` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr b/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr deleted file mode 100644 index 3273b51ba0f04..0000000000000 --- a/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-lifetime-param.rs:34:19 - | -LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `first_dropped` dropped here while still borrowed - | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-lifetime-param.rs b/src/test/ui/span/issue28498-reject-lifetime-param.rs index 062636af3f1e3..9bc01766be564 100644 --- a/src/test/ui/span/issue28498-reject-lifetime-param.rs +++ b/src/test/ui/span/issue28498-reject-lifetime-param.rs @@ -29,8 +29,7 @@ fn main() { last_dropped = ScribbleOnDrop(format!("last")); first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped); - //~^ ERROR `last_dropped` does not live long enough + foo0 = Foo(0, &last_dropped); // OK foo1 = Foo(1, &first_dropped); //~^ ERROR `first_dropped` does not live long enough diff --git a/src/test/ui/span/issue28498-reject-lifetime-param.stderr b/src/test/ui/span/issue28498-reject-lifetime-param.stderr index 0e51729f8d6ba..1dcb40e5d9cb7 100644 --- a/src/test/ui/span/issue28498-reject-lifetime-param.stderr +++ b/src/test/ui/span/issue28498-reject-lifetime-param.stderr @@ -1,25 +1,17 @@ -error[E0597]: `last_dropped` does not live long enough - --> $DIR/issue28498-reject-lifetime-param.rs:32:20 - | -LL | foo0 = Foo(0, &last_dropped); - | ^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `last_dropped` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-lifetime-param.rs:34:20 + --> $DIR/issue28498-reject-lifetime-param.rs:33:19 | LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `first_dropped` dropped here while still borrowed + | - + | | + | `first_dropped` dropped here while still borrowed + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr b/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr deleted file mode 100644 index ae08e3e5e6c5c..0000000000000 --- a/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-passed-to-fn.rs:36:19 - | -LL | foo1 = Foo(1, &first_dropped, Box::new(callback)); - | ^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `first_dropped` dropped here while still borrowed - | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-passed-to-fn.rs b/src/test/ui/span/issue28498-reject-passed-to-fn.rs index 27a757e850bdc..c59de5df41170 100644 --- a/src/test/ui/span/issue28498-reject-passed-to-fn.rs +++ b/src/test/ui/span/issue28498-reject-passed-to-fn.rs @@ -31,8 +31,7 @@ fn main() { last_dropped = ScribbleOnDrop(format!("last")); first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped, Box::new(callback)); - //~^ ERROR `last_dropped` does not live long enough + foo0 = Foo(0, &last_dropped, Box::new(callback)); // OK foo1 = Foo(1, &first_dropped, Box::new(callback)); //~^ ERROR `first_dropped` does not live long enough diff --git a/src/test/ui/span/issue28498-reject-passed-to-fn.stderr b/src/test/ui/span/issue28498-reject-passed-to-fn.stderr index 80533c79f10fd..214a6f6d65ca5 100644 --- a/src/test/ui/span/issue28498-reject-passed-to-fn.stderr +++ b/src/test/ui/span/issue28498-reject-passed-to-fn.stderr @@ -1,25 +1,17 @@ -error[E0597]: `last_dropped` does not live long enough - --> $DIR/issue28498-reject-passed-to-fn.rs:34:20 - | -LL | foo0 = Foo(0, &last_dropped, Box::new(callback)); - | ^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `last_dropped` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-passed-to-fn.rs:36:20 + --> $DIR/issue28498-reject-passed-to-fn.rs:35:19 | LL | foo1 = Foo(1, &first_dropped, Box::new(callback)); - | ^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `first_dropped` dropped here while still borrowed + | - + | | + | `first_dropped` dropped here while still borrowed + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr b/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr deleted file mode 100644 index 600fd539fe4d0..0000000000000 --- a/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-trait-bound.rs:36:19 - | -LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `first_dropped` dropped here while still borrowed - | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-trait-bound.rs b/src/test/ui/span/issue28498-reject-trait-bound.rs index 3ea67d1662d56..8813180c8919f 100644 --- a/src/test/ui/span/issue28498-reject-trait-bound.rs +++ b/src/test/ui/span/issue28498-reject-trait-bound.rs @@ -31,8 +31,7 @@ fn main() { last_dropped = ScribbleOnDrop(format!("last")); first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped); - //~^ ERROR `last_dropped` does not live long enough + foo0 = Foo(0, &last_dropped); // OK foo1 = Foo(1, &first_dropped); //~^ ERROR `first_dropped` does not live long enough diff --git a/src/test/ui/span/issue28498-reject-trait-bound.stderr b/src/test/ui/span/issue28498-reject-trait-bound.stderr index 3ce4dd9fdd684..d4fe291bef398 100644 --- a/src/test/ui/span/issue28498-reject-trait-bound.stderr +++ b/src/test/ui/span/issue28498-reject-trait-bound.stderr @@ -1,25 +1,17 @@ -error[E0597]: `last_dropped` does not live long enough - --> $DIR/issue28498-reject-trait-bound.rs:34:20 - | -LL | foo0 = Foo(0, &last_dropped); - | ^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `last_dropped` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-trait-bound.rs:36:20 + --> $DIR/issue28498-reject-trait-bound.rs:35:19 | LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `first_dropped` dropped here while still borrowed + | - + | | + | `first_dropped` dropped here while still borrowed + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/mut-arg-hint.nll.stderr b/src/test/ui/span/mut-arg-hint.nll.stderr deleted file mode 100644 index e0fa3c3a1e6f5..0000000000000 --- a/src/test/ui/span/mut-arg-hint.nll.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference - --> $DIR/mut-arg-hint.rs:3:9 - | -LL | fn foo(mut a: &String) { - | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` -LL | a.push_str("bar"); //~ ERROR cannot borrow immutable borrowed content - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference - --> $DIR/mut-arg-hint.rs:8:5 - | -LL | pub fn foo<'a>(mut a: &'a String) { - | ---------- help: consider changing this to be a mutable reference: `&'a mut String` -LL | a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference - --> $DIR/mut-arg-hint.rs:15:9 - | -LL | pub fn foo(mut a: &String) { - | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` -LL | a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/mut-arg-hint.rs b/src/test/ui/span/mut-arg-hint.rs index 3d46613aa7ac9..d7ff1f0de4180 100644 --- a/src/test/ui/span/mut-arg-hint.rs +++ b/src/test/ui/span/mut-arg-hint.rs @@ -1,18 +1,18 @@ trait B { fn foo(mut a: &String) { - a.push_str("bar"); //~ ERROR cannot borrow immutable borrowed content + a.push_str("bar"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference } } pub fn foo<'a>(mut a: &'a String) { - a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content + a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference } struct A {} impl A { pub fn foo(mut a: &String) { - a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content + a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/span/mut-arg-hint.stderr b/src/test/ui/span/mut-arg-hint.stderr index ea6fc8bee637b..4ef13fb7bc3af 100644 --- a/src/test/ui/span/mut-arg-hint.stderr +++ b/src/test/ui/span/mut-arg-hint.stderr @@ -1,26 +1,26 @@ -error[E0596]: cannot borrow immutable borrowed content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:3:9 | LL | fn foo(mut a: &String) { - | ------- use `&mut String` here to make mutable -LL | a.push_str("bar"); //~ ERROR cannot borrow immutable borrowed content - | ^ cannot borrow as mutable + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | a.push_str("bar"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable borrowed content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:8:5 | LL | pub fn foo<'a>(mut a: &'a String) { - | ---------- use `&'a mut String` here to make mutable -LL | a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content - | ^ cannot borrow as mutable + | ---------- help: consider changing this to be a mutable reference: `&'a mut String` +LL | a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable borrowed content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:15:9 | LL | pub fn foo(mut a: &String) { - | ------- use `&mut String` here to make mutable -LL | a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content - | ^ cannot borrow as mutable + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 3 previous errors diff --git a/src/test/ui/span/mut-ptr-cant-outlive-ref.nll.stderr b/src/test/ui/span/mut-ptr-cant-outlive-ref.nll.stderr deleted file mode 100644 index d3ba848fe6bb7..0000000000000 --- a/src/test/ui/span/mut-ptr-cant-outlive-ref.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `b` does not live long enough - --> $DIR/mut-ptr-cant-outlive-ref.rs:8:15 - | -LL | p = &*b; - | ^ borrowed value does not live long enough -LL | } - | - `b` dropped here while still borrowed -LL | //~^^ ERROR `b` does not live long enough -LL | p.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr b/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr index f6cf568a8d2bf..d3ba848fe6bb7 100644 --- a/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr +++ b/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr @@ -5,9 +5,9 @@ LL | p = &*b; | ^ borrowed value does not live long enough LL | } | - `b` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | //~^^ ERROR `b` does not live long enough +LL | p.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/range-2.nll.stderr b/src/test/ui/span/range-2.nll.stderr deleted file mode 100644 index 8ca8156b0830c..0000000000000 --- a/src/test/ui/span/range-2.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/range-2.rs:7:9 - | -LL | let r = { - | - borrow later stored here -... -LL | &a..&b - | ^^ borrowed value does not live long enough -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `b` does not live long enough - --> $DIR/range-2.rs:7:13 - | -LL | let r = { - | - borrow later stored here -... -LL | &a..&b - | ^^ borrowed value does not live long enough -LL | }; - | - `b` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/range-2.stderr b/src/test/ui/span/range-2.stderr index 7d0edd6971ceb..8ca8156b0830c 100644 --- a/src/test/ui/span/range-2.stderr +++ b/src/test/ui/span/range-2.stderr @@ -1,24 +1,24 @@ error[E0597]: `a` does not live long enough - --> $DIR/range-2.rs:7:10 + --> $DIR/range-2.rs:7:9 | +LL | let r = { + | - borrow later stored here +... LL | &a..&b - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `a` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `b` does not live long enough - --> $DIR/range-2.rs:7:14 + --> $DIR/range-2.rs:7:13 | +LL | let r = { + | - borrow later stored here +... LL | &a..&b - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `b` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error: aborting due to 2 previous errors diff --git a/src/test/ui/span/regionck-unboxed-closure-lifetimes.nll.stderr b/src/test/ui/span/regionck-unboxed-closure-lifetimes.nll.stderr deleted file mode 100644 index 8e9cd59515443..0000000000000 --- a/src/test/ui/span/regionck-unboxed-closure-lifetimes.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/regionck-unboxed-closure-lifetimes.rs:8:21 - | -LL | let c_ref = &c; - | ^^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed -LL | f.use_mut(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr b/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr index b3f09669f5fc7..8e9cd59515443 100644 --- a/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr +++ b/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr @@ -1,14 +1,13 @@ error[E0597]: `c` does not live long enough - --> $DIR/regionck-unboxed-closure-lifetimes.rs:8:22 + --> $DIR/regionck-unboxed-closure-lifetimes.rs:8:21 | LL | let c_ref = &c; - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } | - `c` dropped here while still borrowed LL | f.use_mut(); -LL | } - | - borrowed value needs to live until here + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr deleted file mode 100644 index 2be2d0ff7b5ad..0000000000000 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:12:27 - | -LL | let ss: &isize = &id(1); - | ^^^^^ creates a temporary which is freed while still in use -... -LL | } - | - temporary value is freed at the end of this statement -LL | } - | - borrow might be used here, when `blah` is dropped and runs the destructor for type `std::boxed::Box` - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs index 9ca352a07fcec..13e651fa56b8f 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs @@ -10,7 +10,7 @@ fn main() { let blah; { let ss: &isize = &id(1); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed blah = box ss as Box; } } diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr index 8a853e7ce59de..2be2d0ff7b5ad 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr @@ -1,14 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:12:27 | LL | let ss: &isize = &id(1); - | ^^^^^ temporary value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use ... LL | } - | - temporary value dropped here while still borrowed + | - temporary value is freed at the end of this statement LL | } - | - temporary value needs to live until here + | - borrow might be used here, when `blah` is dropped and runs the destructor for type `std::boxed::Box` + | + = note: consider using a `let` binding to create a longer lived value error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr b/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr deleted file mode 100644 index 2e584d9a884f1..0000000000000 --- a/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `tmp0` does not live long enough - --> $DIR/regions-close-over-type-parameter-2.rs:23:20 - | -LL | let tmp1 = &tmp0; - | ^^^^^ borrowed value does not live long enough -LL | repeater3(tmp1) - | --------------- borrow later captured here by trait object -LL | }; - | - `tmp0` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/regions-close-over-type-parameter-2.stderr b/src/test/ui/span/regions-close-over-type-parameter-2.stderr index 5ee155c1d1818..2e584d9a884f1 100644 --- a/src/test/ui/span/regions-close-over-type-parameter-2.stderr +++ b/src/test/ui/span/regions-close-over-type-parameter-2.stderr @@ -1,13 +1,12 @@ error[E0597]: `tmp0` does not live long enough - --> $DIR/regions-close-over-type-parameter-2.rs:23:21 + --> $DIR/regions-close-over-type-parameter-2.rs:23:20 | LL | let tmp1 = &tmp0; - | ^^^^ borrowed value does not live long enough + | ^^^^^ borrowed value does not live long enough LL | repeater3(tmp1) + | --------------- borrow later captured here by trait object LL | }; - | -- borrowed value needs to live until here - | | - | `tmp0` dropped here while still borrowed + | - `tmp0` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr b/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr deleted file mode 100644 index 42df668529749..0000000000000 --- a/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/regions-escape-loop-via-variable.rs:11:13 - | -LL | let x = 1 + *p; - | -- borrow later used here -LL | p = &x; - | ^^ borrowed value does not live long enough -LL | } - | - `x` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/regions-escape-loop-via-variable.stderr b/src/test/ui/span/regions-escape-loop-via-variable.stderr index e3870db0c668e..42df668529749 100644 --- a/src/test/ui/span/regions-escape-loop-via-variable.stderr +++ b/src/test/ui/span/regions-escape-loop-via-variable.stderr @@ -1,13 +1,12 @@ error[E0597]: `x` does not live long enough - --> $DIR/regions-escape-loop-via-variable.rs:11:14 + --> $DIR/regions-escape-loop-via-variable.rs:11:13 | +LL | let x = 1 + *p; + | -- borrow later used here LL | p = &x; - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } | - `x` dropped here while still borrowed -LL | //~^^ ERROR `x` does not live long enough -LL | } - | - borrowed value needs to live until here error: aborting due to previous error diff --git a/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr b/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr deleted file mode 100644 index e07fb72778210..0000000000000 --- a/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:5:11 - | -LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here -LL | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed - | ^ use of borrowed `x` -LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed -LL | _y.push(&mut z); - | -- borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:6:21 - | -LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here -LL | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed -LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed - | ^ use of borrowed `x` -LL | _y.push(&mut z); - | -- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/regions-escape-loop-via-vec.rs:7:17 - | -LL | _y.push(&mut z); - | -- ^^^^^^ borrowed value does not live long enough - | | - | borrow later used here -... -LL | } - | - `z` dropped here while still borrowed - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:9:9 - | -LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here -... -LL | _y.push(&mut z); - | -- borrow later used here -LL | //~^ ERROR `z` does not live long enough -LL | x += 1; //~ ERROR cannot assign - | ^^^^^^ use of borrowed `x` - -error: aborting due to 4 previous errors - -Some errors occurred: E0503, E0597. -For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/span/regions-escape-loop-via-vec.rs b/src/test/ui/span/regions-escape-loop-via-vec.rs index 52f3dc37c9019..1fceb09696770 100644 --- a/src/test/ui/span/regions-escape-loop-via-vec.rs +++ b/src/test/ui/span/regions-escape-loop-via-vec.rs @@ -6,7 +6,7 @@ fn broken() { let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed _y.push(&mut z); //~^ ERROR `z` does not live long enough - x += 1; //~ ERROR cannot assign + x += 1; //~ ERROR cannot use `x` because it was mutably borrowed } } diff --git a/src/test/ui/span/regions-escape-loop-via-vec.stderr b/src/test/ui/span/regions-escape-loop-via-vec.stderr index 09a7123d8f04e..0b70fe8cd20ac 100644 --- a/src/test/ui/span/regions-escape-loop-via-vec.stderr +++ b/src/test/ui/span/regions-escape-loop-via-vec.stderr @@ -1,41 +1,49 @@ -error[E0597]: `z` does not live long enough - --> $DIR/regions-escape-loop-via-vec.rs:7:22 - | -LL | _y.push(&mut z); - | ^ borrowed value does not live long enough -... -LL | } - | - `z` dropped here while still borrowed -LL | } - | - borrowed value needs to live until here - error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:5:11 | LL | let mut _y = vec![&mut x]; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed | ^ use of borrowed `x` +LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed +LL | _y.push(&mut z); + | -- borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:6:13 + --> $DIR/regions-escape-loop-via-vec.rs:6:21 | LL | let mut _y = vec![&mut x]; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | while x < 10 { //~ ERROR cannot use `x` because it was mutably borrowed LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed - | ^^^^^ use of borrowed `x` + | ^ use of borrowed `x` +LL | _y.push(&mut z); + | -- borrow later used here -error[E0506]: cannot assign to `x` because it is borrowed +error[E0597]: `z` does not live long enough + --> $DIR/regions-escape-loop-via-vec.rs:7:17 + | +LL | _y.push(&mut z); + | -- ^^^^^^ borrowed value does not live long enough + | | + | borrow later used here +... +LL | } + | - `z` dropped here while still borrowed + +error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:9:9 | LL | let mut _y = vec![&mut x]; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here ... -LL | x += 1; //~ ERROR cannot assign - | ^^^^^^ assignment to borrowed `x` occurs here +LL | _y.push(&mut z); + | -- borrow later used here +LL | //~^ ERROR `z` does not live long enough +LL | x += 1; //~ ERROR cannot use `x` because it was mutably borrowed + | ^^^^^^ use of borrowed `x` error: aborting due to 4 previous errors -Some errors occurred: E0503, E0506, E0597. +Some errors occurred: E0503, E0597. For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/span/regions-infer-borrow-scope-within-loop.nll.stderr b/src/test/ui/span/regions-infer-borrow-scope-within-loop.nll.stderr deleted file mode 100644 index fd67c65c4e917..0000000000000 --- a/src/test/ui/span/regions-infer-borrow-scope-within-loop.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `*x` does not live long enough - --> $DIR/regions-infer-borrow-scope-within-loop.rs:13:20 - | -LL | y = borrow(&*x); - | ^^^ borrowed value does not live long enough -... -LL | } - | - `*x` dropped here while still borrowed -LL | assert!(*y != 0); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr b/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr index 94abbcef035a5..fd67c65c4e917 100644 --- a/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr +++ b/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr @@ -1,14 +1,13 @@ error[E0597]: `*x` does not live long enough - --> $DIR/regions-infer-borrow-scope-within-loop.rs:13:21 + --> $DIR/regions-infer-borrow-scope-within-loop.rs:13:20 | LL | y = borrow(&*x); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } | - `*x` dropped here while still borrowed LL | assert!(*y != 0); -LL | } - | - borrowed value needs to live until here + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr b/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr deleted file mode 100644 index 65d10c1305b8c..0000000000000 --- a/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-ensures-scoping.rs:16:17 - | -LL | let bad = { - | --- borrow later stored here -LL | let x = 1; -LL | let y = &x; - | ^^ borrowed value does not live long enough -... -LL | }; - | - `x` dropped here while still borrowed - -error[E0597]: `y` does not live long enough - --> $DIR/send-is-not-static-ensures-scoping.rs:20:22 - | -LL | let bad = { - | --- borrow later stored here -... -LL | scoped(|| { - | -- value captured here -LL | let _z = y; - | ^ borrowed value does not live long enough -... -LL | }; - | - `y` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/send-is-not-static-ensures-scoping.stderr b/src/test/ui/span/send-is-not-static-ensures-scoping.stderr index 47026284fb150..65d10c1305b8c 100644 --- a/src/test/ui/span/send-is-not-static-ensures-scoping.stderr +++ b/src/test/ui/span/send-is-not-static-ensures-scoping.stderr @@ -1,28 +1,28 @@ error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-ensures-scoping.rs:16:18 + --> $DIR/send-is-not-static-ensures-scoping.rs:16:17 | +LL | let bad = { + | --- borrow later stored here +LL | let x = 1; LL | let y = &x; - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `y` does not live long enough --> $DIR/send-is-not-static-ensures-scoping.rs:20:22 | +LL | let bad = { + | --- borrow later stored here +... LL | scoped(|| { - | -- capture occurs here + | -- value captured here LL | let _z = y; | ^ borrowed value does not live long enough ... LL | }; - | - borrowed value only lives until here -... -LL | } - | - borrowed value needs to live until here + | - `y` dropped here while still borrowed error: aborting due to 2 previous errors diff --git a/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr b/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr deleted file mode 100644 index bcd07e1164777..0000000000000 --- a/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:11:20 - | -LL | let lock = { - | ---- borrow later stored here -LL | let x = 1; -LL | Mutex::new(&x) - | ^^ borrowed value does not live long enough -LL | }; - | - `x` dropped here while still borrowed - -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:21:21 - | -LL | let lock = { - | ---- borrow later stored here -LL | let x = 1; -LL | RwLock::new(&x) - | ^^ borrowed value does not live long enough -LL | }; - | - `x` dropped here while still borrowed - -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:31:25 - | -LL | let (_tx, rx) = { - | --- borrow later used here -... -LL | let _ = tx.send(&x); - | ^^ borrowed value does not live long enough -LL | (tx, rx) -LL | }; - | - `x` dropped here while still borrowed - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/send-is-not-static-std-sync-2.stderr b/src/test/ui/span/send-is-not-static-std-sync-2.stderr index 4172731745ec3..bcd07e1164777 100644 --- a/src/test/ui/span/send-is-not-static-std-sync-2.stderr +++ b/src/test/ui/span/send-is-not-static-std-sync-2.stderr @@ -1,36 +1,36 @@ error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:11:21 + --> $DIR/send-is-not-static-std-sync-2.rs:11:20 | +LL | let lock = { + | ---- borrow later stored here +LL | let x = 1; LL | Mutex::new(&x) - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:21:22 + --> $DIR/send-is-not-static-std-sync-2.rs:21:21 | +LL | let lock = { + | ---- borrow later stored here +LL | let x = 1; LL | RwLock::new(&x) - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:31:26 + --> $DIR/send-is-not-static-std-sync-2.rs:31:25 | +LL | let (_tx, rx) = { + | --- borrow later used here +... LL | let _ = tx.send(&x); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | (tx, rx) LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error: aborting due to 3 previous errors diff --git a/src/test/ui/span/send-is-not-static-std-sync.nll.stderr b/src/test/ui/span/send-is-not-static-std-sync.nll.stderr deleted file mode 100644 index 54960c16405d5..0000000000000 --- a/src/test/ui/span/send-is-not-static-std-sync.nll.stderr +++ /dev/null @@ -1,72 +0,0 @@ -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/send-is-not-static-std-sync.rs:13:10 - | -LL | *lock.lock().unwrap() = &*y; - | --- borrow of `*y` occurs here -LL | drop(y); //~ ERROR cannot move out - | ^ move out of `y` occurs here -... -LL | *lock.lock().unwrap() = &z; - | ---- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:16:33 - | -LL | *lock.lock().unwrap() = &z; - | ^^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -LL | //~^^ ERROR `z` does not live long enough -LL | lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` => needs explicit use) - | ---- borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/send-is-not-static-std-sync.rs:27:10 - | -LL | *lock.write().unwrap() = &*y; - | --- borrow of `*y` occurs here -LL | drop(y); //~ ERROR cannot move out - | ^ move out of `y` occurs here -... -LL | *lock.write().unwrap() = &z; - | ---- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:30:34 - | -LL | *lock.write().unwrap() = &z; - | ^^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -LL | //~^^ ERROR `z` does not live long enough -LL | lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z` => needs explicit use) - | ---- borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/send-is-not-static-std-sync.rs:43:10 - | -LL | tx.send(&*y); - | --- borrow of `*y` occurs here -LL | drop(y); //~ ERROR cannot move out - | ^ move out of `y` occurs here -... -LL | tx.send(&z).unwrap(); - | -- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:46:17 - | -LL | tx.send(&z).unwrap(); - | ^^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -... -LL | } - | - borrow might be used here, when `tx` is dropped and runs the `Drop` code for type `std::sync::mpsc::Sender` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 6 previous errors - -Some errors occurred: E0505, E0597. -For more information about an error, try `rustc --explain E0505`. diff --git a/src/test/ui/span/send-is-not-static-std-sync.stderr b/src/test/ui/span/send-is-not-static-std-sync.stderr index 74c2bad24dea2..54960c16405d5 100644 --- a/src/test/ui/span/send-is-not-static-std-sync.stderr +++ b/src/test/ui/span/send-is-not-static-std-sync.stderr @@ -1,59 +1,70 @@ -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:16:34 - | -LL | *lock.lock().unwrap() = &z; - | ^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here - error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:13:10 | LL | *lock.lock().unwrap() = &*y; - | -- borrow of `*y` occurs here + | --- borrow of `*y` occurs here LL | drop(y); //~ ERROR cannot move out | ^ move out of `y` occurs here +... +LL | *lock.lock().unwrap() = &z; + | ---- borrow later used here error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:30:35 + --> $DIR/send-is-not-static-std-sync.rs:16:33 | -LL | *lock.write().unwrap() = &z; - | ^ borrowed value does not live long enough +LL | *lock.lock().unwrap() = &z; + | ^^ borrowed value does not live long enough LL | } | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | //~^^ ERROR `z` does not live long enough +LL | lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` => needs explicit use) + | ---- borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:27:10 | LL | *lock.write().unwrap() = &*y; - | -- borrow of `*y` occurs here + | --- borrow of `*y` occurs here LL | drop(y); //~ ERROR cannot move out | ^ move out of `y` occurs here +... +LL | *lock.write().unwrap() = &z; + | ---- borrow later used here error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:46:18 + --> $DIR/send-is-not-static-std-sync.rs:30:34 | -LL | tx.send(&z).unwrap(); - | ^ borrowed value does not live long enough +LL | *lock.write().unwrap() = &z; + | ^^ borrowed value does not live long enough LL | } | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | //~^^ ERROR `z` does not live long enough +LL | lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z` => needs explicit use) + | ---- borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:43:10 | LL | tx.send(&*y); - | -- borrow of `*y` occurs here + | --- borrow of `*y` occurs here LL | drop(y); //~ ERROR cannot move out | ^ move out of `y` occurs here +... +LL | tx.send(&z).unwrap(); + | -- borrow later used here + +error[E0597]: `z` does not live long enough + --> $DIR/send-is-not-static-std-sync.rs:46:17 + | +LL | tx.send(&z).unwrap(); + | ^^ borrowed value does not live long enough +LL | } + | - `z` dropped here while still borrowed +... +LL | } + | - borrow might be used here, when `tx` is dropped and runs the `Drop` code for type `std::sync::mpsc::Sender` + | + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 6 previous errors diff --git a/src/test/ui/span/slice-borrow.nll.stderr b/src/test/ui/span/slice-borrow.nll.stderr deleted file mode 100644 index 84d0c847b7bdc..0000000000000 --- a/src/test/ui/span/slice-borrow.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/slice-borrow.rs:6:28 - | -LL | let x: &[isize] = &vec![1, 2, 3, 4, 5]; - | ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use -... -LL | } - | - temporary value is freed at the end of this statement -LL | y.use_ref(); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/slice-borrow.rs b/src/test/ui/span/slice-borrow.rs index 23e53039e9453..38cd7acbdfa13 100644 --- a/src/test/ui/span/slice-borrow.rs +++ b/src/test/ui/span/slice-borrow.rs @@ -4,7 +4,7 @@ fn main() { let y; { let x: &[isize] = &vec![1, 2, 3, 4, 5]; - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed y = &x[1..]; } y.use_ref(); diff --git a/src/test/ui/span/slice-borrow.stderr b/src/test/ui/span/slice-borrow.stderr index a03cac58e2ea8..84d0c847b7bdc 100644 --- a/src/test/ui/span/slice-borrow.stderr +++ b/src/test/ui/span/slice-borrow.stderr @@ -1,17 +1,17 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/slice-borrow.rs:6:28 | LL | let x: &[isize] = &vec![1, 2, 3, 4, 5]; - | ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use ... LL | } - | - temporary value dropped here while still borrowed + | - temporary value is freed at the end of this statement LL | y.use_ref(); -LL | } - | - temporary value needs to live until here + | - borrow later used here | + = note: consider using a `let` binding to create a longer lived value = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr b/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr deleted file mode 100644 index c5e2ca2e28f39..0000000000000 --- a/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `c2` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:117:24 - | -LL | c1.v[0].v.set(Some(&c2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c2` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `c1` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:119:24 - | -LL | c2.v[0].v.set(Some(&c1)); - | ^^^ borrowed value does not live long enough -LL | //~^ ERROR `c1` does not live long enough -LL | } - | - - | | - | `c1` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr b/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr index 1eee88ad21af5..c5e2ca2e28f39 100644 --- a/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr +++ b/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr @@ -1,24 +1,28 @@ error[E0597]: `c2` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:117:25 + --> $DIR/vec-must-not-hide-type-from-dropck.rs:117:24 | LL | c1.v[0].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c2` dropped here while still borrowed + | - + | | + | `c2` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:119:25 + --> $DIR/vec-must-not-hide-type-from-dropck.rs:119:24 | LL | c2.v[0].v.set(Some(&c1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | //~^ ERROR `c1` does not live long enough LL | } - | - `c1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `c1` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` error: aborting due to 2 previous errors diff --git a/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr b/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr deleted file mode 100644 index 684e784531325..0000000000000 --- a/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:17:12 - | -LL | v.push(&x); - | ^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `x` dropped here while still borrowed - | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `y` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:19:12 - | -LL | v.push(&y); - | ^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `y` dropped here while still borrowed - | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/vec_refs_data_with_early_death.stderr b/src/test/ui/span/vec_refs_data_with_early_death.stderr index 65fd6b50643ad..684e784531325 100644 --- a/src/test/ui/span/vec_refs_data_with_early_death.stderr +++ b/src/test/ui/span/vec_refs_data_with_early_death.stderr @@ -1,24 +1,30 @@ error[E0597]: `x` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:17:13 + --> $DIR/vec_refs_data_with_early_death.rs:17:12 | LL | v.push(&x); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } - | - `x` dropped here while still borrowed + | - + | | + | `x` dropped here while still borrowed + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `y` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:19:13 + --> $DIR/vec_refs_data_with_early_death.rs:19:12 | LL | v.push(&y); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } - | - `y` dropped here while still borrowed + | - + | | + | `y` dropped here while still borrowed + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/span/wf-method-late-bound-regions.nll.stderr b/src/test/ui/span/wf-method-late-bound-regions.nll.stderr deleted file mode 100644 index 6b0b008208f17..0000000000000 --- a/src/test/ui/span/wf-method-late-bound-regions.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `pointer` does not live long enough - --> $DIR/wf-method-late-bound-regions.rs:20:18 - | -LL | let dangling = { - | -------- borrow later stored here -LL | let pointer = Box::new(42); -LL | f2.xmute(&pointer) - | ^^^^^^^^ borrowed value does not live long enough -LL | }; - | - `pointer` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/wf-method-late-bound-regions.stderr b/src/test/ui/span/wf-method-late-bound-regions.stderr index a30e0f4d7e0ed..6b0b008208f17 100644 --- a/src/test/ui/span/wf-method-late-bound-regions.stderr +++ b/src/test/ui/span/wf-method-late-bound-regions.stderr @@ -1,13 +1,13 @@ error[E0597]: `pointer` does not live long enough - --> $DIR/wf-method-late-bound-regions.rs:20:19 + --> $DIR/wf-method-late-bound-regions.rs:20:18 | +LL | let dangling = { + | -------- borrow later stored here +LL | let pointer = Box::new(42); LL | f2.xmute(&pointer) - | ^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^ borrowed value does not live long enough LL | }; | - `pointer` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error: aborting due to previous error diff --git a/src/test/ui/static/static-drop-scope.nll.stderr b/src/test/ui/static/static-drop-scope.nll.stderr deleted file mode 100644 index df6383b4fc222..0000000000000 --- a/src/test/ui/static/static-drop-scope.nll.stderr +++ /dev/null @@ -1,72 +0,0 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:9:60 - | -LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^ statics cannot evaluate destructors - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-drop-scope.rs:9:60 - | -LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); - | ------^^^^^^^^- - | | | | - | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use - | using this value as a static requires that borrow lasts for `'static` - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:13:59 - | -LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^ constants cannot evaluate destructors - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-drop-scope.rs:13:59 - | -LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); - | ------^^^^^^^^- - | | | | - | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use - | using this value as a constant requires that borrow lasts for `'static` - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:17:28 - | -LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1; - | ^^^^^^^^^^^^^ statics cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:20:27 - | -LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1; - | ^^^^^^^^^^^^^ constants cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:23:24 - | -LL | const fn const_drop(_: T) {} - | ^ constant functions cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:27:5 - | -LL | (x, ()).1 - | ^^^^^^^ constant functions cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:31:34 - | -LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1; - | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:36:43 - | -LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1; - | ^^^^^^^^^^^ constants cannot evaluate destructors - -error: aborting due to 10 previous errors - -Some errors occurred: E0493, E0716. -For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/static/static-drop-scope.rs b/src/test/ui/static/static-drop-scope.rs index e5a9f2a405644..0de28d5469b38 100644 --- a/src/test/ui/static/static-drop-scope.rs +++ b/src/test/ui/static/static-drop-scope.rs @@ -8,11 +8,11 @@ impl Drop for WithDtor { static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); //~^ ERROR destructors cannot be evaluated at compile-time -//~| ERROR borrowed value does not live long enoug +//~| ERROR temporary value dropped while borrowed const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); //~^ ERROR destructors cannot be evaluated at compile-time -//~| ERROR borrowed value does not live long enoug +//~| ERROR temporary value dropped while borrowed static EARLY_DROP_S: i32 = (WithDtor, 0).1; //~^ ERROR destructors cannot be evaluated at compile-time diff --git a/src/test/ui/static/static-drop-scope.stderr b/src/test/ui/static/static-drop-scope.stderr index 3e3032eb4fb60..df6383b4fc222 100644 --- a/src/test/ui/static/static-drop-scope.stderr +++ b/src/test/ui/static/static-drop-scope.stderr @@ -4,15 +4,15 @@ error[E0493]: destructors cannot be evaluated at compile-time LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); | ^^^^^^^^ statics cannot evaluate destructors -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-drop-scope.rs:9:60 | LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | ------^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a static requires that borrow lasts for `'static` error[E0493]: destructors cannot be evaluated at compile-time --> $DIR/static-drop-scope.rs:13:59 @@ -20,15 +20,15 @@ error[E0493]: destructors cannot be evaluated at compile-time LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); | ^^^^^^^^ constants cannot evaluate destructors -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-drop-scope.rs:13:59 | LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | ------^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a constant requires that borrow lasts for `'static` error[E0493]: destructors cannot be evaluated at compile-time --> $DIR/static-drop-scope.rs:17:28 @@ -68,5 +68,5 @@ LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1; error: aborting due to 10 previous errors -Some errors occurred: E0493, E0597. +Some errors occurred: E0493, E0716. For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/static/static-lifetime-bound.nll.stderr b/src/test/ui/static/static-lifetime-bound.nll.stderr deleted file mode 100644 index 9a8a344cbd87e..0000000000000 --- a/src/test/ui/static/static-lifetime-bound.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning: unnecessary lifetime parameter `'a` - --> $DIR/static-lifetime-bound.rs:1:6 - | -LL | fn f<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a` - | ^^^^^^^^^^^ - | - = help: you can use the `'static` lifetime directly, in place of `'a` - -error[E0597]: `x` does not live long enough - --> $DIR/static-lifetime-bound.rs:5:7 - | -LL | f(&x); //~ERROR does not live long enough - | --^^- - | | | - | | borrowed value does not live long enough - | argument requires that `x` is borrowed for `'static` -LL | } - | - `x` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/static/static-lifetime-bound.stderr b/src/test/ui/static/static-lifetime-bound.stderr index dc8e83610d4b6..9a8a344cbd87e 100644 --- a/src/test/ui/static/static-lifetime-bound.stderr +++ b/src/test/ui/static/static-lifetime-bound.stderr @@ -7,14 +7,15 @@ LL | fn f<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a = help: you can use the `'static` lifetime directly, in place of `'a` error[E0597]: `x` does not live long enough - --> $DIR/static-lifetime-bound.rs:5:8 + --> $DIR/static-lifetime-bound.rs:5:7 | LL | f(&x); //~ERROR does not live long enough - | ^ borrowed value does not live long enough + | --^^- + | | | + | | borrowed value does not live long enough + | argument requires that `x` is borrowed for `'static` LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `x` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/static/static-reference-to-fn-2.nll.stderr b/src/test/ui/static/static-reference-to-fn-2.nll.stderr deleted file mode 100644 index 2e00c9491d7ca..0000000000000 --- a/src/test/ui/static/static-reference-to-fn-2.nll.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-reference-to-fn-2.rs:18:22 - | -LL | fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { - | ----- has type `&mut StateMachineIter<'1>` -LL | self_.statefn = &id(state2 as StateMachineFunc); - | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | | - | | creates a temporary which is freed while still in use - | assignment requires that borrow lasts for `'1` - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-reference-to-fn-2.rs:24:22 - | -LL | fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { - | ----- has type `&mut StateMachineIter<'1>` -LL | self_.statefn = &id(state3 as StateMachineFunc); - | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | | - | | creates a temporary which is freed while still in use - | assignment requires that borrow lasts for `'1` - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-reference-to-fn-2.rs:30:22 - | -LL | fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { - | ----- has type `&mut StateMachineIter<'1>` -LL | self_.statefn = &id(finished as StateMachineFunc); - | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | | - | | creates a temporary which is freed while still in use - | assignment requires that borrow lasts for `'1` - -error[E0515]: cannot return value referencing temporary value - --> $DIR/static-reference-to-fn-2.rs:40:5 - | -LL | / StateMachineIter { -LL | | statefn: &id(state1 as StateMachineFunc) - | | ------------------------------ temporary value created here -LL | | //~^ ERROR borrowed value does not live long enough -LL | | } - | |_____^ returns a value referencing data owned by the current function - -error: aborting due to 4 previous errors - -Some errors occurred: E0515, E0716. -For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/static/static-reference-to-fn-2.rs b/src/test/ui/static/static-reference-to-fn-2.rs index 8e66532cad917..6693667c091b3 100644 --- a/src/test/ui/static/static-reference-to-fn-2.rs +++ b/src/test/ui/static/static-reference-to-fn-2.rs @@ -16,19 +16,19 @@ impl<'a> Iterator for StateMachineIter<'a> { fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { self_.statefn = &id(state2 as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed return Some("state1"); } fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { self_.statefn = &id(state3 as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed return Some("state2"); } fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { self_.statefn = &id(finished as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed return Some("state3"); } @@ -38,8 +38,8 @@ fn finished(_: &mut StateMachineIter) -> Option<(&'static str)> { fn state_iter() -> StateMachineIter<'static> { StateMachineIter { + //~^ ERROR cannot return value referencing temporary value statefn: &id(state1 as StateMachineFunc) - //~^ ERROR borrowed value does not live long enough } } diff --git a/src/test/ui/static/static-reference-to-fn-2.stderr b/src/test/ui/static/static-reference-to-fn-2.stderr index d94913c7e2224..c66427cd21e86 100644 --- a/src/test/ui/static/static-reference-to-fn-2.stderr +++ b/src/test/ui/static/static-reference-to-fn-2.stderr @@ -1,71 +1,47 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:18:22 | +LL | fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(state2 as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 17:1... - --> $DIR/static-reference-to-fn-2.rs:17:1 - | -LL | / fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { -LL | | self_.statefn = &id(state2 as StateMachineFunc); -LL | | //~^ ERROR borrowed value does not live long enough -LL | | return Some("state1"); -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:24:22 | +LL | fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(state3 as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 23:1... - --> $DIR/static-reference-to-fn-2.rs:23:1 - | -LL | / fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { -LL | | self_.statefn = &id(state3 as StateMachineFunc); -LL | | //~^ ERROR borrowed value does not live long enough -LL | | return Some("state2"); -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:30:22 | +LL | fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(finished as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 29:1... - --> $DIR/static-reference-to-fn-2.rs:29:1 - | -LL | / fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { -LL | | self_.statefn = &id(finished as StateMachineFunc); -LL | | //~^ ERROR borrowed value does not live long enough -LL | | return Some("state3"); -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough - --> $DIR/static-reference-to-fn-2.rs:41:19 - | -LL | statefn: &id(state1 as StateMachineFunc) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +error[E0515]: cannot return value referencing temporary value + --> $DIR/static-reference-to-fn-2.rs:40:5 + | +LL | / StateMachineIter { +LL | | //~^ ERROR cannot return value referencing temporary value +LL | | statefn: &id(state1 as StateMachineFunc) + | | ------------------------------ temporary value created here +LL | | } + | |_____^ returns a value referencing data owned by the current function error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0515, E0716. +For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/static/static-region-bound.nll.stderr b/src/test/ui/static/static-region-bound.nll.stderr deleted file mode 100644 index 0a5686051cda4..0000000000000 --- a/src/test/ui/static/static-region-bound.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-region-bound.rs:10:14 - | -LL | let x = &id(3); //~ ERROR borrowed value does not live long enough - | ^^^^^ creates a temporary which is freed while still in use -LL | f(x); - | ---- argument requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/static/static-region-bound.rs b/src/test/ui/static/static-region-bound.rs index ee411370d15fa..f133133b33650 100644 --- a/src/test/ui/static/static-region-bound.rs +++ b/src/test/ui/static/static-region-bound.rs @@ -7,6 +7,6 @@ fn f(_: T) {} fn main() { let x: Box<_> = box 3; f(x); - let x = &id(3); //~ ERROR borrowed value does not live long enough + let x = &id(3); //~ ERROR temporary value dropped while borrowed f(x); } diff --git a/src/test/ui/static/static-region-bound.stderr b/src/test/ui/static/static-region-bound.stderr index 611f47ddfde75..398d63dc117c6 100644 --- a/src/test/ui/static/static-region-bound.stderr +++ b/src/test/ui/static/static-region-bound.stderr @@ -1,14 +1,13 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-region-bound.rs:10:14 | -LL | let x = &id(3); //~ ERROR borrowed value does not live long enough - | ^^^^^ temporary value does not live long enough +LL | let x = &id(3); //~ ERROR temporary value dropped while borrowed + | ^^^^^ creates a temporary which is freed while still in use LL | f(x); + | ---- argument requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/std-uncopyable-atomics.nll.stderr b/src/test/ui/std-uncopyable-atomics.nll.stderr deleted file mode 100644 index 0a5e7c64b1a83..0000000000000 --- a/src/test/ui/std-uncopyable-atomics.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:9:13 - | -LL | let x = *&x; //~ ERROR: cannot move out of borrowed content - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:11:13 - | -LL | let x = *&x; //~ ERROR: cannot move out of borrowed content - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:13:13 - | -LL | let x = *&x; //~ ERROR: cannot move out of borrowed content - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:15:13 - | -LL | let x = *&x; //~ ERROR: cannot move out of borrowed content - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/std-uncopyable-atomics.stderr b/src/test/ui/std-uncopyable-atomics.stderr index ecf9963c145f2..0a5e7c64b1a83 100644 --- a/src/test/ui/std-uncopyable-atomics.stderr +++ b/src/test/ui/std-uncopyable-atomics.stderr @@ -5,7 +5,7 @@ LL | let x = *&x; //~ ERROR: cannot move out of borrowed content | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:11:13 @@ -14,7 +14,7 @@ LL | let x = *&x; //~ ERROR: cannot move out of borrowed content | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:13:13 @@ -23,7 +23,7 @@ LL | let x = *&x; //~ ERROR: cannot move out of borrowed content | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:15:13 @@ -32,7 +32,7 @@ LL | let x = *&x; //~ ERROR: cannot move out of borrowed content | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error: aborting due to 4 previous errors diff --git a/src/test/ui/thread-local-in-ctfe.nll.stderr b/src/test/ui/thread-local-in-ctfe.nll.stderr deleted file mode 100644 index c5cca9d25c19b..0000000000000 --- a/src/test/ui/thread-local-in-ctfe.nll.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:6:17 - | -LL | static B: u32 = A; - | ^ - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:9:18 - | -LL | static C: &u32 = &A; - | ^^ - -warning[E0712]: thread-local variable borrowed past end of function - --> $DIR/thread-local-in-ctfe.rs:9:18 - | -LL | static C: &u32 = &A; - | ^^- end of enclosing function is here - | | - | thread-local variables cannot be borrowed beyond the end of the function - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:12:16 - | -LL | const D: u32 = A; - | ^ - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:15:17 - | -LL | const E: &u32 = &A; - | ^^ - -warning[E0712]: thread-local variable borrowed past end of function - --> $DIR/thread-local-in-ctfe.rs:15:17 - | -LL | const E: &u32 = &A; - | ^^- end of enclosing function is here - | | - | thread-local variables cannot be borrowed beyond the end of the function - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:19:5 - | -LL | A - | ^ - -error: aborting due to 5 previous errors - -Some errors occurred: E0625, E0712. -For more information about an error, try `rustc --explain E0625`. diff --git a/src/test/ui/thread-local-in-ctfe.rs b/src/test/ui/thread-local-in-ctfe.rs index 313d39de36b6a..7ca1a2e7e90c2 100644 --- a/src/test/ui/thread-local-in-ctfe.rs +++ b/src/test/ui/thread-local-in-ctfe.rs @@ -8,12 +8,18 @@ static B: u32 = A; static C: &u32 = &A; //~^ ERROR thread-local statics cannot be accessed at compile-time +//~| WARNING thread-local variable borrowed past end of function +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future const D: u32 = A; //~^ ERROR thread-local statics cannot be accessed at compile-time const E: &u32 = &A; //~^ ERROR thread-local statics cannot be accessed at compile-time +//~| WARNING thread-local variable borrowed past end of function +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future const fn f() -> u32 { A diff --git a/src/test/ui/thread-local-in-ctfe.stderr b/src/test/ui/thread-local-in-ctfe.stderr index abeb2a3e0dee5..aed99bdd9fc6a 100644 --- a/src/test/ui/thread-local-in-ctfe.stderr +++ b/src/test/ui/thread-local-in-ctfe.stderr @@ -10,24 +10,47 @@ error[E0625]: thread-local statics cannot be accessed at compile-time LL | static C: &u32 = &A; | ^^ +warning[E0712]: thread-local variable borrowed past end of function + --> $DIR/thread-local-in-ctfe.rs:9:18 + | +LL | static C: &u32 = &A; + | ^^- end of enclosing function is here + | | + | thread-local variables cannot be borrowed beyond the end of the function + | + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:12:16 + --> $DIR/thread-local-in-ctfe.rs:15:16 | LL | const D: u32 = A; | ^ error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:15:17 + --> $DIR/thread-local-in-ctfe.rs:18:17 | LL | const E: &u32 = &A; | ^^ +warning[E0712]: thread-local variable borrowed past end of function + --> $DIR/thread-local-in-ctfe.rs:18:17 + | +LL | const E: &u32 = &A; + | ^^- end of enclosing function is here + | | + | thread-local variables cannot be borrowed beyond the end of the function + | + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:19:5 + --> $DIR/thread-local-in-ctfe.rs:25:5 | LL | A | ^ error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0625`. +Some errors occurred: E0625, E0712. +For more information about an error, try `rustc --explain E0625`. diff --git a/src/test/ui/thread-local-mutation.nll.stderr b/src/test/ui/thread-local-mutation.nll.stderr deleted file mode 100644 index 0a3664b0d9d40..0000000000000 --- a/src/test/ui/thread-local-mutation.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0594]: cannot assign to immutable static item `S` - --> $DIR/thread-local-mutation.rs:11:5 - | -LL | S = "after"; //~ ERROR cannot assign to immutable - | ^^^^^^^^^^^ cannot assign - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/thread-local-mutation.stderr b/src/test/ui/thread-local-mutation.stderr index bf298523e1b73..0a3664b0d9d40 100644 --- a/src/test/ui/thread-local-mutation.stderr +++ b/src/test/ui/thread-local-mutation.stderr @@ -1,8 +1,8 @@ -error[E0594]: cannot assign to immutable thread-local static item +error[E0594]: cannot assign to immutable static item `S` --> $DIR/thread-local-mutation.rs:11:5 | LL | S = "after"; //~ ERROR cannot assign to immutable - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ cannot assign error: aborting due to previous error diff --git a/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr b/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr deleted file mode 100644 index 6092a9dc10d3c..0000000000000 --- a/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `person` does not live long enough - --> $DIR/trait-coercion-generic-regions.rs:17:24 - | -LL | let person: &str = &person; //~ ERROR `person` does not live long enough - | ^^^^^^^ - | | - | borrowed value does not live long enough - | assignment requires that `person` is borrowed for `'static` -LL | let s: Box> = Box::new(Struct { person: person }); -LL | } - | - `person` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/traits/trait-coercion-generic-regions.stderr b/src/test/ui/traits/trait-coercion-generic-regions.stderr index 23c2a72743eea..6092a9dc10d3c 100644 --- a/src/test/ui/traits/trait-coercion-generic-regions.stderr +++ b/src/test/ui/traits/trait-coercion-generic-regions.stderr @@ -1,13 +1,14 @@ error[E0597]: `person` does not live long enough - --> $DIR/trait-coercion-generic-regions.rs:17:25 + --> $DIR/trait-coercion-generic-regions.rs:17:24 | LL | let person: &str = &person; //~ ERROR `person` does not live long enough - | ^^^^^^ borrowed value does not live long enough + | ^^^^^^^ + | | + | borrowed value does not live long enough + | assignment requires that `person` is borrowed for `'static` LL | let s: Box> = Box::new(Struct { person: person }); LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `person` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.nll.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.nll.stderr deleted file mode 100644 index 8b86dd9a4c92a..0000000000000 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference - --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:6:5 - | -LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` -LL | *t //~ ERROR - | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference - --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:10:6 - | -LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` -LL | {*t} //~ ERROR - | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr index a3995b7edefae..8b86dd9a4c92a 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr @@ -1,19 +1,19 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:6:5 | LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- use `&'a mut &'a mut i32` here to make mutable + | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` LL | *t //~ ERROR - | ^^ assignment into an immutable reference + | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:10:6 | LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- use `&'a mut &'a mut i32` here to make mutable + | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` LL | {*t} //~ ERROR - | ^^ assignment into an immutable reference + | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr deleted file mode 100644 index 0e996902d621d..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/unboxed-closure-illegal-move.rs:15:31 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured variable in an `Fn` closure - -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/unboxed-closure-illegal-move.rs:19:35 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured variable in an `FnMut` closure - -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/unboxed-closure-illegal-move.rs:28:36 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured variable in an `Fn` closure - -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/unboxed-closure-illegal-move.rs:32:40 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured variable in an `FnMut` closure - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr index ae83242d5349a..0e996902d621d 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr @@ -1,34 +1,34 @@ -error[E0507]: cannot move out of captured outer variable in an `Fn` closure +error[E0507]: cannot move out of captured variable in an `Fn` closure --> $DIR/unboxed-closure-illegal-move.rs:15:31 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure -error[E0507]: cannot move out of captured outer variable in an `FnMut` closure +error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/unboxed-closure-illegal-move.rs:19:35 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured outer variable in an `FnMut` closure + | ^ cannot move out of captured variable in an `FnMut` closure -error[E0507]: cannot move out of captured outer variable in an `Fn` closure +error[E0507]: cannot move out of captured variable in an `Fn` closure --> $DIR/unboxed-closure-illegal-move.rs:28:36 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure -error[E0507]: cannot move out of captured outer variable in an `FnMut` closure +error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/unboxed-closure-illegal-move.rs:32:40 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move - | ^ cannot move out of captured outer variable in an `FnMut` closure + | ^ cannot move out of captured variable in an `FnMut` closure error: aborting due to 4 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.nll.stderr deleted file mode 100644 index 51a0a6e575646..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.nll.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:9:13 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -LL | move || x = 1; //~ ERROR cannot assign - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:10:17 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -LL | move || x = 1; //~ ERROR cannot assign -LL | move || set(&mut x); //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:11:13 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | move || x = 1; //~ ERROR cannot assign - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:12:17 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | move || set(&mut x); //~ ERROR cannot borrow - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:13:8 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || x = 1; //~ ERROR cannot assign - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:15:12 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || set(&mut x); //~ ERROR cannot assign - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:16:8 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || x = 1; //~ ERROR cannot assign - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:18:12 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || set(&mut x); //~ ERROR cannot assign - | ^^^^^^ cannot borrow as mutable - -error: aborting due to 8 previous errors - -Some errors occurred: E0594, E0596. -For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs index 5d59cecf99ae6..3eba9c4d431a2 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs @@ -11,9 +11,7 @@ fn main() { move || x = 1; //~ ERROR cannot assign move || set(&mut x); //~ ERROR cannot borrow || x = 1; //~ ERROR cannot assign - // FIXME: this should be `cannot borrow` (issue #18330) - || set(&mut x); //~ ERROR cannot assign + || set(&mut x); //~ ERROR cannot borrow || x = 1; //~ ERROR cannot assign - // FIXME: this should be `cannot borrow` (issue #18330) - || set(&mut x); //~ ERROR cannot assign + || set(&mut x); //~ ERROR cannot borrow } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr index 1865e2486f14e..be092e0c796d5 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr @@ -1,69 +1,75 @@ -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:13:5 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:9:13 | LL | let x = 0; - | - help: make this binding mutable: `mut x` -... -LL | || x = 1; //~ ERROR cannot assign - | ^^ cannot borrow mutably + | - help: consider changing this to be mutable: `mut x` +LL | move || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:15:5 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:10:17 | LL | let x = 0; - | - help: make this binding mutable: `mut x` -... -LL | || set(&mut x); //~ ERROR cannot assign - | ^^ cannot borrow mutably + | - help: consider changing this to be mutable: `mut x` +LL | move || x = 1; //~ ERROR cannot assign +LL | move || set(&mut x); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:16:5 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:11:13 | LL | let x = 0; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... -LL | || x = 1; //~ ERROR cannot assign - | ^^ cannot borrow mutably +LL | move || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:18:5 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:12:17 | LL | let x = 0; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... -LL | || set(&mut x); //~ ERROR cannot assign - | ^^ cannot borrow mutably +LL | move || set(&mut x); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure - --> $DIR/unboxed-closure-immutable-capture.rs:9:13 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:13:8 | LL | let x = 0; - | - help: consider making `x` mutable: `mut x` -LL | move || x = 1; //~ ERROR cannot assign - | ^^^^^ + | - help: consider changing this to be mutable: `mut x` +... +LL | || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign -error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:10:22 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:14:12 | -LL | move || set(&mut x); //~ ERROR cannot borrow - | ^ +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || set(&mut x); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure - --> $DIR/unboxed-closure-immutable-capture.rs:11:13 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:15:8 | LL | let x = 0; - | - help: consider making `x` mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... -LL | move || x = 1; //~ ERROR cannot assign - | ^^^^^ +LL | || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign -error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:12:22 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:16:12 | -LL | move || set(&mut x); //~ ERROR cannot borrow - | ^ +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || set(&mut x); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable error: aborting due to 8 previous errors -Some errors occurred: E0594, E0595, E0596. +Some errors occurred: E0594, E0596. For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr deleted file mode 100644 index 1c55a6bb08eb5..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/unboxed-closure-region.rs:8:12 - | -LL | let _f = { - | -- borrow later stored here -LL | let x = 0; -LL | || x //~ ERROR `x` does not live long enough - | -- ^ borrowed value does not live long enough - | | - | value captured here -LL | }; - | - `x` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.stderr b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr index a0f009c0689c9..1c55a6bb08eb5 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr @@ -1,15 +1,15 @@ error[E0597]: `x` does not live long enough --> $DIR/unboxed-closure-region.rs:8:12 | +LL | let _f = { + | -- borrow later stored here +LL | let x = 0; LL | || x //~ ERROR `x` does not live long enough | -- ^ borrowed value does not live long enough | | - | capture occurs here + | value captured here LL | }; - | - borrowed value only lives until here -LL | _f; -LL | } - | - borrowed value needs to live until here + | - `x` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr deleted file mode 100644 index a47d33d29e158..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/unboxed-closures-borrow-conflict.rs:9:14 - | -LL | let f = || x += 1; - | -- - borrow occurs due to use of `x` in closure - | | - | borrow of `x` occurs here -LL | let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed - | ^ use of borrowed `x` -LL | f; - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr index 461eebc59c029..a47d33d29e158 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr @@ -1,10 +1,14 @@ error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/unboxed-closures-borrow-conflict.rs:9:9 + --> $DIR/unboxed-closures-borrow-conflict.rs:9:14 | LL | let f = || x += 1; - | -- borrow of `x` occurs here + | -- - borrow occurs due to use of `x` in closure + | | + | borrow of `x` occurs here LL | let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed - | ^^ use of borrowed `x` + | ^ use of borrowed `x` +LL | f; + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr deleted file mode 100644 index 1749c20b582b0..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error[E0597]: `factorial` does not live long enough - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:15:17 - | -LL | let f = |x: u32| -> u32 { - | --------------- value captured here -LL | let g = factorial.as_ref().unwrap(); - | ^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `factorial` dropped here while still borrowed - | borrow might be used here, when `factorial` is dropped and runs the destructor for type `std::option::Option u32>>` - -error[E0506]: cannot assign to `factorial` because it is borrowed - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:20:5 - | -LL | let f = |x: u32| -> u32 { - | --------------- borrow of `factorial` occurs here -LL | let g = factorial.as_ref().unwrap(); - | --------- borrow occurs due to use in closure -... -LL | factorial = Some(Box::new(f)); - | ^^^^^^^^^ - | | - | assignment to borrowed `factorial` occurs here - | borrow later used here - -error[E0597]: `factorial` does not live long enough - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:28:17 - | -LL | let mut factorial: Option u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` -LL | -LL | let f = |x: u32| -> u32 { - | --------------- value captured here -LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` -LL | let g = factorial.as_ref().unwrap(); - | ^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `factorial` dropped here while still borrowed - -error[E0506]: cannot assign to `factorial` because it is borrowed - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:32:5 - | -LL | let mut factorial: Option u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` -LL | -LL | let f = |x: u32| -> u32 { - | --------------- borrow of `factorial` occurs here -LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` -LL | let g = factorial.as_ref().unwrap(); - | --------- borrow occurs due to use in closure -... -LL | factorial = Some(Box::new(f)); - | ^^^^^^^^^ assignment to borrowed `factorial` occurs here - -error: aborting due to 4 previous errors - -Some errors occurred: E0506, E0597. -For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs index b72482a712118..82dc536bb5693 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs @@ -18,18 +18,20 @@ fn a() { }; factorial = Some(Box::new(f)); + //~^ ERROR cannot assign to `factorial` because it is borrowed } fn b() { let mut factorial: Option u32 + 'static>> = None; let f = |x: u32| -> u32 { - //~^ ERROR closure may outlive the current function, but it borrows `factorial` let g = factorial.as_ref().unwrap(); + //~^ ERROR `factorial` does not live long enough if x == 0 {1} else {x * g(x-1)} }; factorial = Some(Box::new(f)); + //~^ ERROR cannot assign to `factorial` because it is borrowed } fn main() { } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr index 85d98c18d7ffd..434818ca9289a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr @@ -2,29 +2,59 @@ error[E0597]: `factorial` does not live long enough --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:15:17 | LL | let f = |x: u32| -> u32 { - | --------------- capture occurs here + | --------------- value captured here LL | let g = factorial.as_ref().unwrap(); | ^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - borrowed value dropped before borrower + | - + | | + | `factorial` dropped here while still borrowed + | borrow might be used here, when `factorial` is dropped and runs the destructor for type `std::option::Option u32>>` + +error[E0506]: cannot assign to `factorial` because it is borrowed + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:20:5 | - = note: values in a scope are dropped in the opposite order they are created +LL | let f = |x: u32| -> u32 { + | --------------- borrow of `factorial` occurs here +LL | let g = factorial.as_ref().unwrap(); + | --------- borrow occurs due to use in closure +... +LL | factorial = Some(Box::new(f)); + | ^^^^^^^^^ + | | + | assignment to borrowed `factorial` occurs here + | borrow later used here -error[E0373]: closure may outlive the current function, but it borrows `factorial`, which is owned by the current function - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:26:13 +error[E0597]: `factorial` does not live long enough + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:28:17 | +LL | let mut factorial: Option u32 + 'static>> = None; + | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | LL | let f = |x: u32| -> u32 { - | ^^^^^^^^^^^^^^^ may outlive borrowed value `factorial` -LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` + | --------------- value captured here LL | let g = factorial.as_ref().unwrap(); - | --------- `factorial` is borrowed here -help: to force the closure to take ownership of `factorial` (and any other referenced variables), use the `move` keyword + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `factorial` dropped here while still borrowed + +error[E0506]: cannot assign to `factorial` because it is borrowed + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:33:5 | -LL | let f = move |x: u32| -> u32 { - | ^^^^^^^^^^^^^^^^^^^^ +LL | let mut factorial: Option u32 + 'static>> = None; + | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | +LL | let f = |x: u32| -> u32 { + | --------------- borrow of `factorial` occurs here +LL | let g = factorial.as_ref().unwrap(); + | --------- borrow occurs due to use in closure +... +LL | factorial = Some(Box::new(f)); + | ^^^^^^^^^ assignment to borrowed `factorial` occurs here -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors -Some errors occurred: E0373, E0597. -For more information about an error, try `rustc --explain E0373`. +Some errors occurred: E0506, E0597. +For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr deleted file mode 100644 index 89ac402b5e02b..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `tick1` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:17:9 - | -LL | let tick1 = || { - | ----- help: consider changing this to be mutable: `mut tick1` -... -LL | tick1(); - | ^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `tick2` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:20:5 - | -LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` - | ----- help: consider changing this to be mutable: `mut tick2` -... -LL | tick2(); //~ ERROR cannot borrow - | ^^^^^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs index aaa692c109f69..6401b5e01fcd9 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs @@ -11,10 +11,9 @@ fn main() { }; // In turn, tick2 must be inferred to FnMut so that it can call - // tick1, but we forgot the mut. The error message we currently - // get seems... suboptimal. - let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` - tick1(); + // tick1, but we forgot the mut. + let tick2 = || { + tick1(); //~ ERROR cannot borrow `tick1` as mutable }; tick2(); //~ ERROR cannot borrow diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr index bc839d7b53622..11759995008ab 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr @@ -1,22 +1,21 @@ -error[E0595]: closure cannot assign to immutable local variable `tick1` - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:16:17 +error[E0596]: cannot borrow `tick1` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:16:9 | LL | let tick1 = || { - | ----- help: make this binding mutable: `mut tick1` + | ----- help: consider changing this to be mutable: `mut tick1` ... -LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` - | ^^ cannot borrow mutably +LL | tick1(); //~ ERROR cannot borrow `tick1` as mutable + | ^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable local variable `tick2` as mutable - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:20:5 +error[E0596]: cannot borrow `tick2` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:19:5 | -LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` - | ----- help: make this binding mutable: `mut tick2` +LL | let tick2 = || { + | ----- help: consider changing this to be mutable: `mut tick2` ... LL | tick2(); //~ ERROR cannot borrow - | ^^^^^ cannot borrow mutably + | ^^^^^ cannot borrow as mutable error: aborting due to 2 previous errors -Some errors occurred: E0595, E0596. -For more information about an error, try `rustc --explain E0595`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.nll.stderr deleted file mode 100644 index 9c0a71e73f522..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:7:5 - | -LL | let tick = || counter += 1; - | ---- help: consider changing this to be mutable: `mut tick` -LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable - | ^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs index de3f9839d2664..5c0ceb23d614c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs @@ -4,5 +4,5 @@ fn main() { let mut counter = 0; let tick = || counter += 1; - tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + tick(); //~ ERROR cannot borrow `tick` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr index d4d285275e9e2..7b57ac69ed112 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `tick` as mutable +error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:7:5 | LL | let tick = || counter += 1; - | ---- help: make this binding mutable: `mut tick` -LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable - | ^^^^ cannot borrow mutably + | ---- help: consider changing this to be mutable: `mut tick` +LL | tick(); //~ ERROR cannot borrow `tick` as mutable, as it is not declared as mutable + | ^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr deleted file mode 100644 index fa3426a1f7096..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:7:5 - | -LL | let tick = move || counter += 1; - | ---- help: consider changing this to be mutable: `mut tick` -LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable - | ^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs index b011c5a58bc3e..144a674ac589e 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs @@ -4,5 +4,5 @@ fn main() { let mut counter = 0; let tick = move || counter += 1; - tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + tick(); //~ ERROR cannot borrow `tick` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr index 2137f9904ce16..afb3ead143e0a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `tick` as mutable +error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:7:5 | LL | let tick = move || counter += 1; - | ---- help: make this binding mutable: `mut tick` -LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable - | ^^^^ cannot borrow mutably + | ---- help: consider changing this to be mutable: `mut tick` +LL | tick(); //~ ERROR cannot borrow `tick` as mutable, as it is not declared as mutable + | ^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.nll.stderr deleted file mode 100644 index 9b2f1cd4ae339..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.nll.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0594]: cannot assign to `n`, as it is not declared as mutable - --> $DIR/unboxed-closures-mutate-upvar.rs:15:9 - | -LL | let n = 0; - | - help: consider changing this to be mutable: `mut n` -LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign -LL | n += 1; - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `n`, as it is not declared as mutable - --> $DIR/unboxed-closures-mutate-upvar.rs:32:9 - | -LL | let n = 0; - | - help: consider changing this to be mutable: `mut n` -... -LL | n += 1; //~ ERROR cannot assign - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `n`, as it is not declared as mutable - --> $DIR/unboxed-closures-mutate-upvar.rs:46:9 - | -LL | let n = 0; - | - help: consider changing this to be mutable: `mut n` -LL | let mut f = to_fn(move || { -LL | n += 1; //~ ERROR cannot assign - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure - --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 - | -LL | n += 1; //~ ERROR cannot assign - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/unboxed-closures-mutate-upvar.rs:52:23 - | -LL | let mut f = to_fn(move || { - | _______________________^ -LL | | n += 1; //~ ERROR cannot assign -LL | | }); - | |_____^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs index 3bea9226f2115..57e6d30658ce5 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs @@ -11,8 +11,8 @@ fn to_fn_mut>(f: F) -> F { f } fn a() { let n = 0; - let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign - n += 1; + let mut f = to_fn_mut(|| { + n += 1; //~ ERROR cannot assign to `n`, as it is not declared as mutable }); } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr index 99fc287b1eefa..f4e71d68e1313 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr @@ -1,44 +1,37 @@ -error[E0595]: closure cannot assign to immutable local variable `n` - --> $DIR/unboxed-closures-mutate-upvar.rs:14:27 +error[E0594]: cannot assign to `n`, as it is not declared as mutable + --> $DIR/unboxed-closures-mutate-upvar.rs:15:9 | LL | let n = 0; - | - help: make this binding mutable: `mut n` -LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign - | ^^ cannot borrow mutably + | - help: consider changing this to be mutable: `mut n` +LL | let mut f = to_fn_mut(|| { +LL | n += 1; //~ ERROR cannot assign to `n`, as it is not declared as mutable + | ^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `n`, as it is not declared as mutable --> $DIR/unboxed-closures-mutate-upvar.rs:32:9 | LL | let n = 0; - | - help: consider making `n` mutable: `mut n` + | - help: consider changing this to be mutable: `mut n` ... LL | n += 1; //~ ERROR cannot assign - | ^^^^^^ + | ^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `n`, as it is not declared as mutable --> $DIR/unboxed-closures-mutate-upvar.rs:46:9 | +LL | let n = 0; + | - help: consider changing this to be mutable: `mut n` +LL | let mut f = to_fn(move || { LL | n += 1; //~ ERROR cannot assign - | ^^^^^^ - | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference - --> $DIR/unboxed-closures-mutate-upvar.rs:45:23 - | -LL | let mut f = to_fn(move || { - | _______________________^ -LL | | n += 1; //~ ERROR cannot assign -LL | | }); - | |_____^ + | ^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 | LL | n += 1; //~ ERROR cannot assign - | ^^^^^^ + | ^^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/unboxed-closures-mutate-upvar.rs:52:23 | LL | let mut f = to_fn(move || { @@ -49,5 +42,4 @@ LL | | }); error: aborting due to 4 previous errors -Some errors occurred: E0594, E0595. -For more information about an error, try `rustc --explain E0594`. +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr deleted file mode 100644 index 2f83a6485cdd7..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:14:9 - | -LL | counter += 1; - | ^^^^^^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:13:10 - | -LL | call(|| { - | __________^ -LL | | counter += 1; -LL | | //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure -LL | | //[mir]~^^ ERROR cannot assign to `counter` -LL | | }); - | |_____^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr deleted file mode 100644 index 293f59ff4b27a..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:14:9 - | -LL | counter += 1; - | ^^^^^^^^^^^^ - | -help: consider changing this closure to take self by mutable reference - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:13:10 - | -LL | call(|| { - | __________^ -LL | | counter += 1; -LL | | //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure -LL | | //[mir]~^^ ERROR cannot assign to `counter` -LL | | }); - | |_____^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0387`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs index a5dcb57d33a61..174ad245d59fe 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Test that a by-ref `FnMut` closure gets an error when it tries to // mutate a value. @@ -12,7 +9,6 @@ fn main() { let mut counter = 0; call(|| { counter += 1; - //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure - //[mir]~^^ ERROR cannot assign to `counter` + //~^ ERROR cannot assign to `counter` }); } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr similarity index 61% rename from src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr rename to src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr index 2f83a6485cdd7..ae5183a8ff677 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr @@ -1,17 +1,16 @@ error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:14:9 + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:11:9 | LL | counter += 1; | ^^^^^^^^^^^^ cannot assign | help: consider changing this to accept closures that implement `FnMut` - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:13:10 + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:10:10 | LL | call(|| { | __________^ LL | | counter += 1; -LL | | //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure -LL | | //[mir]~^^ ERROR cannot assign to `counter` +LL | | //~^ ERROR cannot assign to `counter` LL | | }); | |_____^ diff --git a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr deleted file mode 100644 index 830f6bc993dfe..0000000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `*self` as mutable more than once at a time - --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:22:21 - | -LL | (self.func)(self, arg) - | ----------- ^^^^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr index f881d1982a5f5..830f6bc993dfe 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr @@ -2,10 +2,10 @@ error[E0499]: cannot borrow `*self` as mutable more than once at a time --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:22:21 | LL | (self.func)(self, arg) - | ----------- ^^^^ - first borrow ends here - | | | - | | second mutable borrow occurs here + | ----------- ^^^^ second mutable borrow occurs here + | | | first mutable borrow occurs here + | first borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr b/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr deleted file mode 100644 index 29d161fe150e7..0000000000000 --- a/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr +++ /dev/null @@ -1,70 +0,0 @@ -error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0`) - --> $DIR/union-borrow-move-parent-sibling.rs:15:13 - | -LL | let a = &mut u.x.0; - | ---------- mutable borrow occurs here (via `u.x.0`) -LL | let b = &u.y; //~ ERROR cannot borrow `u.y` - | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0` -- occurs here -LL | use_borrow(a); - | - mutable borrow later used here - | - = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0` - -error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:22:13 - | -LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - | - move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = u.x.0; - | ----- value moved here -LL | let b = u.y; //~ ERROR use of moved value: `u.y` - | ^^^ value used here after move - -error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0.0`) - --> $DIR/union-borrow-move-parent-sibling.rs:28:13 - | -LL | let a = &mut (u.x.0).0; - | -------------- mutable borrow occurs here (via `u.x.0.0`) -LL | let b = &u.y; //~ ERROR cannot borrow `u.y` - | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0.0` -- occurs here -LL | use_borrow(a); - | - mutable borrow later used here - | - = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0.0` - -error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:35:13 - | -LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - | - move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = (u.x.0).0; - | --------- value moved here -LL | let b = u.y; //~ ERROR use of moved value: `u.y` - | ^^^ value used here after move - -error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `*u.y`) - --> $DIR/union-borrow-move-parent-sibling.rs:41:13 - | -LL | let a = &mut *u.y; - | --------- mutable borrow occurs here (via `*u.y`) -LL | let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) - | ^^^^ immutable borrow of `u.x` -- which overlaps with `*u.y` -- occurs here -LL | use_borrow(a); - | - mutable borrow later used here - | - = note: `u.x` is a field of the union `U`, so it overlaps the field `*u.y` - -error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:48:13 - | -LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - | - move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = *u.y; - | ---- value moved here -LL | let b = u.x; //~ ERROR use of moved value: `u.x` - | ^^^ value used here after move - -error: aborting due to 6 previous errors - -Some errors occurred: E0382, E0502. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.rs b/src/test/ui/union/union-borrow-move-parent-sibling.rs index 43abbd374fcf1..1b6052f10ba4a 100644 --- a/src/test/ui/union/union-borrow-move-parent-sibling.rs +++ b/src/test/ui/union/union-borrow-move-parent-sibling.rs @@ -12,27 +12,27 @@ fn use_borrow(_: &T) {} unsafe fn parent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut u.x.0; - let b = &u.y; //~ ERROR cannot borrow `u.y` + let b = &u.y; //~ ERROR cannot borrow `u` (via `u.y`) use_borrow(a); } unsafe fn parent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = u.x.0; - let b = u.y; //~ ERROR use of moved value: `u.y` + let b = u.y; //~ ERROR use of moved value: `u` } unsafe fn grandparent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut (u.x.0).0; - let b = &u.y; //~ ERROR cannot borrow `u.y` + let b = &u.y; //~ ERROR cannot borrow `u` (via `u.y`) use_borrow(a); } unsafe fn grandparent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = (u.x.0).0; - let b = u.y; //~ ERROR use of moved value: `u.y` + let b = u.y; //~ ERROR use of moved value: `u` } unsafe fn deref_sibling_borrow() { @@ -45,7 +45,7 @@ unsafe fn deref_sibling_borrow() { unsafe fn deref_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = *u.y; - let b = u.x; //~ ERROR use of moved value: `u.x` + let b = u.x; //~ ERROR use of moved value: `u` } diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.stderr b/src/test/ui/union/union-borrow-move-parent-sibling.stderr index 9058707e50516..4ab40cdfd06b5 100644 --- a/src/test/ui/union/union-borrow-move-parent-sibling.stderr +++ b/src/test/ui/union/union-borrow-move-parent-sibling.stderr @@ -1,65 +1,68 @@ -error[E0502]: cannot borrow `u.y` as immutable because `u.x.0` is also borrowed as mutable - --> $DIR/union-borrow-move-parent-sibling.rs:15:14 +error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0`) + --> $DIR/union-borrow-move-parent-sibling.rs:15:13 | LL | let a = &mut u.x.0; - | ----- mutable borrow occurs here -LL | let b = &u.y; //~ ERROR cannot borrow `u.y` - | ^^^ immutable borrow occurs here + | ---------- mutable borrow occurs here (via `u.x.0`) +LL | let b = &u.y; //~ ERROR cannot borrow `u` (via `u.y`) + | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0` -- occurs here LL | use_borrow(a); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here + | + = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0` -error[E0382]: use of moved value: `u.y` - --> $DIR/union-borrow-move-parent-sibling.rs:22:9 +error[E0382]: use of moved value: `u` + --> $DIR/union-borrow-move-parent-sibling.rs:22:13 | +LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + | - move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = u.x.0; - | - value moved here -LL | let b = u.y; //~ ERROR use of moved value: `u.y` - | ^ value used here after move - | - = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait + | ----- value moved here +LL | let b = u.y; //~ ERROR use of moved value: `u` + | ^^^ value used here after move -error[E0502]: cannot borrow `u.y` as immutable because `u.x.0.0` is also borrowed as mutable - --> $DIR/union-borrow-move-parent-sibling.rs:28:14 +error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0.0`) + --> $DIR/union-borrow-move-parent-sibling.rs:28:13 | LL | let a = &mut (u.x.0).0; - | --------- mutable borrow occurs here -LL | let b = &u.y; //~ ERROR cannot borrow `u.y` - | ^^^ immutable borrow occurs here + | -------------- mutable borrow occurs here (via `u.x.0.0`) +LL | let b = &u.y; //~ ERROR cannot borrow `u` (via `u.y`) + | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0.0` -- occurs here LL | use_borrow(a); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here + | + = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0.0` -error[E0382]: use of moved value: `u.y` - --> $DIR/union-borrow-move-parent-sibling.rs:35:9 +error[E0382]: use of moved value: `u` + --> $DIR/union-borrow-move-parent-sibling.rs:35:13 | +LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + | - move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = (u.x.0).0; - | - value moved here -LL | let b = u.y; //~ ERROR use of moved value: `u.y` - | ^ value used here after move - | - = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait + | --------- value moved here +LL | let b = u.y; //~ ERROR use of moved value: `u` + | ^^^ value used here after move -error[E0502]: cannot borrow `u` (via `u.x`) as immutable because `u` is also borrowed as mutable (via `*u.y`) - --> $DIR/union-borrow-move-parent-sibling.rs:41:14 +error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `*u.y`) + --> $DIR/union-borrow-move-parent-sibling.rs:41:13 | LL | let a = &mut *u.y; - | ---- mutable borrow occurs here (via `*u.y`) + | --------- mutable borrow occurs here (via `*u.y`) LL | let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) - | ^^^ immutable borrow of `u.x` -- which overlaps with `*u.y` -- occurs here + | ^^^^ immutable borrow of `u.x` -- which overlaps with `*u.y` -- occurs here LL | use_borrow(a); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here + | + = note: `u.x` is a field of the union `U`, so it overlaps the field `*u.y` -error[E0382]: use of moved value: `u.x` - --> $DIR/union-borrow-move-parent-sibling.rs:48:9 +error[E0382]: use of moved value: `u` + --> $DIR/union-borrow-move-parent-sibling.rs:48:13 | +LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + | - move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = *u.y; - | - value moved here -LL | let b = u.x; //~ ERROR use of moved value: `u.x` - | ^ value used here after move - | - = note: move occurs because `u.x` has type `[type error]`, which does not implement the `Copy` trait + | ---- value moved here +LL | let b = u.x; //~ ERROR use of moved value: `u` + | ^^^ value used here after move error: aborting due to 6 previous errors diff --git a/src/test/ui/unop-move-semantics.nll.stderr b/src/test/ui/unop-move-semantics.nll.stderr deleted file mode 100644 index 58953d55b1fba..0000000000000 --- a/src/test/ui/unop-move-semantics.nll.stderr +++ /dev/null @@ -1,52 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/unop-move-semantics.rs:8:5 - | -LL | fn move_then_borrow + Clone>(x: T) { - | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | !x; - | - value moved here -LL | -LL | x.clone(); //~ ERROR: use of moved value - | ^ value borrowed here after move - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/unop-move-semantics.rs:15:6 - | -LL | let m = &x; - | -- borrow of `x` occurs here -... -LL | !x; //~ ERROR: cannot move out of `x` because it is borrowed - | ^ move out of `x` occurs here -... -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/unop-move-semantics.rs:17:6 - | -LL | let n = &mut y; - | ------ borrow of `y` occurs here -... -LL | !y; //~ ERROR: cannot move out of `y` because it is borrowed - | ^ move out of `y` occurs here -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0507]: cannot move out of borrowed content - --> $DIR/unop-move-semantics.rs:24:6 - | -LL | !*m; //~ ERROR: cannot move out of borrowed content - | ^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/unop-move-semantics.rs:26:6 - | -LL | !*n; //~ ERROR: cannot move out of borrowed content - | ^^ cannot move out of borrowed content - -error: aborting due to 5 previous errors - -Some errors occurred: E0382, E0505, E0507. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/unop-move-semantics.rs b/src/test/ui/unop-move-semantics.rs index 24bd89d4c39ce..80f737e6c4e7a 100644 --- a/src/test/ui/unop-move-semantics.rs +++ b/src/test/ui/unop-move-semantics.rs @@ -5,7 +5,7 @@ use std::ops::Not; fn move_then_borrow + Clone>(x: T) { !x; - x.clone(); //~ ERROR: use of moved value + x.clone(); //~ ERROR: borrow of moved value } fn move_borrowed>(x: T, mut y: T) { diff --git a/src/test/ui/unop-move-semantics.stderr b/src/test/ui/unop-move-semantics.stderr index 65d2967c61ee8..bef272df49125 100644 --- a/src/test/ui/unop-move-semantics.stderr +++ b/src/test/ui/unop-move-semantics.stderr @@ -1,31 +1,38 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/unop-move-semantics.rs:8:5 | +LL | fn move_then_borrow + Clone>(x: T) { + | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | !x; | - value moved here LL | -LL | x.clone(); //~ ERROR: use of moved value - | ^ value used here after move - | - = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait +LL | x.clone(); //~ ERROR: borrow of moved value + | ^ value borrowed here after move error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/unop-move-semantics.rs:15:6 | LL | let m = &x; - | - borrow of `x` occurs here + | -- borrow of `x` occurs here ... LL | !x; //~ ERROR: cannot move out of `x` because it is borrowed | ^ move out of `x` occurs here +... +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/unop-move-semantics.rs:17:6 | LL | let n = &mut y; - | - borrow of `y` occurs here + | ------ borrow of `y` occurs here ... LL | !y; //~ ERROR: cannot move out of `y` because it is borrowed | ^ move out of `y` occurs here +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0507]: cannot move out of borrowed content --> $DIR/unop-move-semantics.rs:24:6 diff --git a/src/test/ui/unsized-locals/borrow-after-move.nll.stderr b/src/test/ui/unsized-locals/borrow-after-move.nll.stderr deleted file mode 100644 index 010e182674b75..0000000000000 --- a/src/test/ui/unsized-locals/borrow-after-move.nll.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:20:24 - | -LL | let y = *x; - | -- value moved here -LL | drop_unsized(y); -LL | println!("{}", &x); - | ^^ value borrowed here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `y` - --> $DIR/borrow-after-move.rs:22:24 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | drop_unsized(y); - | - value moved here -... -LL | println!("{}", &y); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:30:24 - | -LL | let y = *x; - | -- value moved here -LL | y.foo(); -LL | println!("{}", &x); - | ^^ value borrowed here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `y` - --> $DIR/borrow-after-move.rs:32:24 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | y.foo(); - | - value moved here -... -LL | println!("{}", &y); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:39:24 - | -LL | x.foo(); - | - value moved here -LL | println!("{}", &x); - | ^^ value borrowed here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/unsized-locals/borrow-after-move.rs b/src/test/ui/unsized-locals/borrow-after-move.rs index 587a2180c1558..3299fdf3a9ce8 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.rs +++ b/src/test/ui/unsized-locals/borrow-after-move.rs @@ -18,9 +18,9 @@ fn main() { let y = *x; drop_unsized(y); println!("{}", &x); - //~^ERROR use of moved value + //~^ERROR borrow of moved value println!("{}", &y); - //~^ERROR use of moved value + //~^ERROR borrow of moved value } { @@ -28,15 +28,15 @@ fn main() { let y = *x; y.foo(); println!("{}", &x); - //~^ERROR use of moved value + //~^ERROR borrow of moved value println!("{}", &y); - //~^ERROR use of moved value + //~^ERROR borrow of moved value } { let x = "hello".to_owned().into_boxed_str(); x.foo(); println!("{}", &x); - //~^ERROR use of moved value + //~^ERROR borrow of moved value } } diff --git a/src/test/ui/unsized-locals/borrow-after-move.stderr b/src/test/ui/unsized-locals/borrow-after-move.stderr index 8eea01f25c865..010e182674b75 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.stderr +++ b/src/test/ui/unsized-locals/borrow-after-move.stderr @@ -1,54 +1,54 @@ -error[E0382]: use of moved value: `x` - --> $DIR/borrow-after-move.rs:20:25 +error[E0382]: borrow of moved value: `x` + --> $DIR/borrow-after-move.rs:20:24 | LL | let y = *x; - | - value moved here + | -- value moved here LL | drop_unsized(y); LL | println!("{}", &x); - | ^ value used here after move + | ^^ value borrowed here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `y` - --> $DIR/borrow-after-move.rs:22:25 +error[E0382]: borrow of moved value: `y` + --> $DIR/borrow-after-move.rs:22:24 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | drop_unsized(y); | - value moved here ... LL | println!("{}", &y); - | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/borrow-after-move.rs:30:25 +error[E0382]: borrow of moved value: `x` + --> $DIR/borrow-after-move.rs:30:24 | LL | let y = *x; - | - value moved here + | -- value moved here LL | y.foo(); LL | println!("{}", &x); - | ^ value used here after move + | ^^ value borrowed here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `y` - --> $DIR/borrow-after-move.rs:32:25 +error[E0382]: borrow of moved value: `y` + --> $DIR/borrow-after-move.rs:32:24 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | y.foo(); | - value moved here ... LL | println!("{}", &y); - | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/borrow-after-move.rs:39:25 +error[E0382]: borrow of moved value: `x` + --> $DIR/borrow-after-move.rs:39:24 | LL | x.foo(); | - value moved here LL | println!("{}", &x); - | ^ value used here after move + | ^^ value borrowed here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait diff --git a/src/test/ui/unsized-locals/double-move.nll.stderr b/src/test/ui/unsized-locals/double-move.nll.stderr deleted file mode 100644 index c0c3e436f535b..0000000000000 --- a/src/test/ui/unsized-locals/double-move.nll.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:20:22 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | drop_unsized(y); - | - value moved here -LL | drop_unsized(y); //~ERROR use of moved value - | ^ value used here after move - -error[E0382]: use of moved value: `x` - --> $DIR/double-move.rs:26:22 - | -LL | let _y = *x; - | -- value moved here -LL | drop_unsized(x); //~ERROR use of moved value - | ^ value used here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:32:18 - | -LL | let x = "hello".to_owned().into_boxed_str(); - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | drop_unsized(x); - | - value moved here -LL | let _y = *x; //~ERROR use of moved value - | ^^ value used here after move - -error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:39:9 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | y.foo(); - | - value moved here -LL | y.foo(); //~ERROR use of moved value - | ^ value used here after move - -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:45:9 - | -LL | let _y = *x; - | -- value moved here -LL | x.foo(); //~ERROR use of moved value - | ^ value used here after move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:51:18 - | -LL | x.foo(); - | - value moved here -LL | let _y = *x; //~ERROR use of moved value - | ^^ value used here after move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/unsized-locals/double-move.stderr b/src/test/ui/unsized-locals/double-move.stderr index 1009e913b7b67..c0c3e436f535b 100644 --- a/src/test/ui/unsized-locals/double-move.stderr +++ b/src/test/ui/unsized-locals/double-move.stderr @@ -1,60 +1,60 @@ error[E0382]: use of moved value: `y` --> $DIR/double-move.rs:20:22 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | drop_unsized(y); | - value moved here LL | drop_unsized(y); //~ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x` --> $DIR/double-move.rs:26:22 | LL | let _y = *x; - | -- value moved here + | -- value moved here LL | drop_unsized(x); //~ERROR use of moved value - | ^ value used here after move + | ^ value used here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:32:13 + --> $DIR/double-move.rs:32:18 | +LL | let x = "hello".to_owned().into_boxed_str(); + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | drop_unsized(x); | - value moved here LL | let _y = *x; //~ERROR use of moved value - | ^^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^^ value used here after move error[E0382]: use of moved value: `y` --> $DIR/double-move.rs:39:9 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | y.foo(); | - value moved here LL | y.foo(); //~ERROR use of moved value | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `*x` --> $DIR/double-move.rs:45:9 | LL | let _y = *x; - | -- value moved here + | -- value moved here LL | x.foo(); //~ERROR use of moved value | ^ value used here after move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:51:13 + --> $DIR/double-move.rs:51:18 | LL | x.foo(); | - value moved here LL | let _y = *x; //~ERROR use of moved value - | ^^ value used here after move + | ^^ value used here after move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait diff --git a/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr b/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr deleted file mode 100644 index a94414ef5603b..0000000000000 --- a/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0508]: cannot move out of type `[u8]`, a non-copy slice - --> $DIR/unsized-exprs2.rs:22:19 - | -LL | udrop::<[u8]>(foo()[..]); - | ^^^^^^^^^ cannot move out of here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/unsized-locals/unsized-exprs2.rs b/src/test/ui/unsized-locals/unsized-exprs2.rs index 3fb5a002e0e3c..534439aa6c41c 100644 --- a/src/test/ui/unsized-locals/unsized-exprs2.rs +++ b/src/test/ui/unsized-locals/unsized-exprs2.rs @@ -20,5 +20,5 @@ impl std::ops::Add for A<[u8]> { fn main() { udrop::<[u8]>(foo()[..]); - //~^ERROR cannot move out of indexed content + //~^ERROR cannot move out of type `[u8]`, a non-copy slice } diff --git a/src/test/ui/unsized-locals/unsized-exprs2.stderr b/src/test/ui/unsized-locals/unsized-exprs2.stderr index d7cb4bffb483d..a94414ef5603b 100644 --- a/src/test/ui/unsized-locals/unsized-exprs2.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs2.stderr @@ -1,9 +1,9 @@ -error[E0507]: cannot move out of indexed content +error[E0508]: cannot move out of type `[u8]`, a non-copy slice --> $DIR/unsized-exprs2.rs:22:19 | LL | udrop::<[u8]>(foo()[..]); - | ^^^^^^^^^ cannot move out of indexed content + | ^^^^^^^^^ cannot move out of here error: aborting due to previous error -For more information about this error, try `rustc --explain E0507`. +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/use/use-after-move-based-on-type.nll.stderr b/src/test/ui/use/use-after-move-based-on-type.nll.stderr deleted file mode 100644 index 8160ada9d62ea..0000000000000 --- a/src/test/ui/use/use-after-move-based-on-type.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/use-after-move-based-on-type.rs:4:20 - | -LL | let x = "Hello!".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = x; - | - value moved here -LL | println!("{}", x); //~ ERROR use of moved value - | ^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/use/use-after-move-based-on-type.rs b/src/test/ui/use/use-after-move-based-on-type.rs index fc8ea6f79eb87..ba7aa0345e19c 100644 --- a/src/test/ui/use/use-after-move-based-on-type.rs +++ b/src/test/ui/use/use-after-move-based-on-type.rs @@ -1,5 +1,5 @@ fn main() { let x = "Hello!".to_string(); let _y = x; - println!("{}", x); //~ ERROR use of moved value + println!("{}", x); //~ ERROR borrow of moved value } diff --git a/src/test/ui/use/use-after-move-based-on-type.stderr b/src/test/ui/use/use-after-move-based-on-type.stderr index 2282cdfad14dd..49b2610efda29 100644 --- a/src/test/ui/use/use-after-move-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-based-on-type.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/use-after-move-based-on-type.rs:4:20 | +LL | let x = "Hello!".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = x; - | -- value moved here -LL | println!("{}", x); //~ ERROR use of moved value - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | - value moved here +LL | println!("{}", x); //~ ERROR borrow of moved value + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.nll.stderr b/src/test/ui/use/use-after-move-implicity-coerced-object.nll.stderr deleted file mode 100644 index e16bca380679f..0000000000000 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `n` - --> $DIR/use-after-move-implicity-coerced-object.rs:28:13 - | -LL | let n: Box<_> = box Number { n: 42 }; - | - move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | let mut l: Box<_> = box List { list: Vec::new() }; -LL | l.push(n); - | - value moved here -LL | let x = n.to_string(); - | ^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.rs b/src/test/ui/use/use-after-move-implicity-coerced-object.rs index e43506916644a..2e465ee896268 100644 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.rs +++ b/src/test/ui/use/use-after-move-implicity-coerced-object.rs @@ -26,5 +26,5 @@ fn main() { let mut l: Box<_> = box List { list: Vec::new() }; l.push(n); let x = n.to_string(); - //~^ ERROR: use of moved value: `n` + //~^ ERROR: borrow of moved value: `n` } diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr index babff9be25241..e16bca380679f 100644 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr +++ b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr @@ -1,12 +1,13 @@ -error[E0382]: use of moved value: `n` +error[E0382]: borrow of moved value: `n` --> $DIR/use-after-move-implicity-coerced-object.rs:28:13 | +LL | let n: Box<_> = box Number { n: 42 }; + | - move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait +LL | let mut l: Box<_> = box List { list: Vec::new() }; LL | l.push(n); | - value moved here LL | let x = n.to_string(); - | ^ value used here after move - | - = note: move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr b/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr deleted file mode 100644 index 4119741d805cd..0000000000000 --- a/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `self` - --> $DIR/use-after-move-self-based-on-type.rs:12:16 - | -LL | pub fn foo(self) -> isize { - | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait -LL | self.bar(); - | ---- value moved here -LL | return self.x; //~ ERROR use of moved value: `self.x` - | ^^^^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/use/use-after-move-self-based-on-type.rs b/src/test/ui/use/use-after-move-self-based-on-type.rs index 4d84ae9b27173..9325834954f52 100644 --- a/src/test/ui/use/use-after-move-self-based-on-type.rs +++ b/src/test/ui/use/use-after-move-self-based-on-type.rs @@ -9,7 +9,7 @@ impl Drop for S { impl S { pub fn foo(self) -> isize { self.bar(); - return self.x; //~ ERROR use of moved value: `self.x` + return self.x; //~ ERROR use of moved value: `self` } pub fn bar(self) {} diff --git a/src/test/ui/use/use-after-move-self-based-on-type.stderr b/src/test/ui/use/use-after-move-self-based-on-type.stderr index a3acc1aad0f00..a0e69f2b1d14a 100644 --- a/src/test/ui/use/use-after-move-self-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-self-based-on-type.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `self.x` +error[E0382]: use of moved value: `self` --> $DIR/use-after-move-self-based-on-type.rs:12:16 | +LL | pub fn foo(self) -> isize { + | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait LL | self.bar(); | ---- value moved here -LL | return self.x; //~ ERROR use of moved value: `self.x` +LL | return self.x; //~ ERROR use of moved value: `self` | ^^^^^^ value used here after move - | - = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-self.nll.stderr b/src/test/ui/use/use-after-move-self.nll.stderr deleted file mode 100644 index e2ce3690cb904..0000000000000 --- a/src/test/ui/use/use-after-move-self.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `self` - --> $DIR/use-after-move-self.rs:10:16 - | -LL | pub fn foo(self) -> isize { - | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait -LL | self.bar(); - | ---- value moved here -LL | return *self.x; //~ ERROR use of moved value: `*self.x` - | ^^^^^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/use/use-after-move-self.rs b/src/test/ui/use/use-after-move-self.rs index 1337d61a6d8e8..a6f6c45573d0a 100644 --- a/src/test/ui/use/use-after-move-self.rs +++ b/src/test/ui/use/use-after-move-self.rs @@ -7,7 +7,7 @@ struct S { impl S { pub fn foo(self) -> isize { self.bar(); - return *self.x; //~ ERROR use of moved value: `*self.x` + return *self.x; //~ ERROR use of moved value: `self` } pub fn bar(self) {} diff --git a/src/test/ui/use/use-after-move-self.stderr b/src/test/ui/use/use-after-move-self.stderr index 3cb77acaf3dd4..47bc308aca15f 100644 --- a/src/test/ui/use/use-after-move-self.stderr +++ b/src/test/ui/use/use-after-move-self.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `*self.x` +error[E0382]: use of moved value: `self` --> $DIR/use-after-move-self.rs:10:16 | +LL | pub fn foo(self) -> isize { + | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait LL | self.bar(); | ---- value moved here -LL | return *self.x; //~ ERROR use of moved value: `*self.x` +LL | return *self.x; //~ ERROR use of moved value: `self` | ^^^^^^^ value used here after move - | - = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/variance/variance-issue-20533.nll.stderr b/src/test/ui/variance/variance-issue-20533.nll.stderr deleted file mode 100644 index 469adaf6f0eed..0000000000000 --- a/src/test/ui/variance/variance-issue-20533.nll.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/variance-issue-20533.rs:28:14 - | -LL | let x = foo(&a); - | -- borrow of `a` occurs here -LL | drop(a); //~ ERROR cannot move out of `a` - | ^ move out of `a` occurs here -LL | drop(x); - | - borrow later used here - -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/variance-issue-20533.rs:34:14 - | -LL | let x = bar(&a); - | -- borrow of `a` occurs here -LL | drop(a); //~ ERROR cannot move out of `a` - | ^ move out of `a` occurs here -LL | drop(x); - | - borrow later used here - -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/variance-issue-20533.rs:40:14 - | -LL | let x = baz(&a); - | -- borrow of `a` occurs here -LL | drop(a); //~ ERROR cannot move out of `a` - | ^ move out of `a` occurs here -LL | drop(x); - | - borrow later used here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/variance/variance-issue-20533.stderr b/src/test/ui/variance/variance-issue-20533.stderr index 27aca3401f92e..469adaf6f0eed 100644 --- a/src/test/ui/variance/variance-issue-20533.stderr +++ b/src/test/ui/variance/variance-issue-20533.stderr @@ -2,25 +2,31 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:28:14 | LL | let x = foo(&a); - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | drop(a); //~ ERROR cannot move out of `a` | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:34:14 | LL | let x = bar(&a); - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | drop(a); //~ ERROR cannot move out of `a` | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:40:14 | LL | let x = baz(&a); - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | drop(a); //~ ERROR cannot move out of `a` | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr b/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr deleted file mode 100644 index c77be26f01938..0000000000000 --- a/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `xs` as mutable more than once at a time - --> $DIR/vec-mut-iter-borrow.rs:5:9 - | -LL | for x in &mut xs { - | ------- - | | - | first mutable borrow occurs here - | first borrow later used here -LL | xs.push(1) //~ ERROR cannot borrow `xs` - | ^^ second mutable borrow occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/vec/vec-mut-iter-borrow.stderr b/src/test/ui/vec/vec-mut-iter-borrow.stderr index 9b4b56737915a..c77be26f01938 100644 --- a/src/test/ui/vec/vec-mut-iter-borrow.stderr +++ b/src/test/ui/vec/vec-mut-iter-borrow.stderr @@ -2,10 +2,10 @@ error[E0499]: cannot borrow `xs` as mutable more than once at a time --> $DIR/vec-mut-iter-borrow.rs:5:9 | LL | for x in &mut xs { - | -- - | || - | |first borrow ends here - | first mutable borrow occurs here + | ------- + | | + | first mutable borrow occurs here + | first borrow later used here LL | xs.push(1) //~ ERROR cannot borrow `xs` | ^^ second mutable borrow occurs here diff --git a/src/test/ui/walk-struct-literal-with.nll.stderr b/src/test/ui/walk-struct-literal-with.nll.stderr deleted file mode 100644 index 2263747607b9c..0000000000000 --- a/src/test/ui/walk-struct-literal-with.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `start` - --> $DIR/walk-struct-literal-with.rs:16:20 - | -LL | let start = Mine{test:"Foo".to_string(), other_val:0}; - | ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait -LL | let end = Mine{other_val:1, ..start.make_string_bar()}; - | ----- value moved here -LL | println!("{}", start.test); //~ ERROR use of moved value: `start.test` - | ^^^^^^^^^^ value borrowed here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/walk-struct-literal-with.rs b/src/test/ui/walk-struct-literal-with.rs index 31dfd58fa98d2..ee1a77eb9a48a 100644 --- a/src/test/ui/walk-struct-literal-with.rs +++ b/src/test/ui/walk-struct-literal-with.rs @@ -13,5 +13,5 @@ impl Mine{ fn main(){ let start = Mine{test:"Foo".to_string(), other_val:0}; let end = Mine{other_val:1, ..start.make_string_bar()}; - println!("{}", start.test); //~ ERROR use of moved value: `start.test` + println!("{}", start.test); //~ ERROR borrow of moved value: `start` } diff --git a/src/test/ui/walk-struct-literal-with.stderr b/src/test/ui/walk-struct-literal-with.stderr index 9362301b4081d..f879145881da7 100644 --- a/src/test/ui/walk-struct-literal-with.stderr +++ b/src/test/ui/walk-struct-literal-with.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `start.test` +error[E0382]: borrow of moved value: `start` --> $DIR/walk-struct-literal-with.rs:16:20 | +LL | let start = Mine{test:"Foo".to_string(), other_val:0}; + | ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait LL | let end = Mine{other_val:1, ..start.make_string_bar()}; | ----- value moved here -LL | println!("{}", start.test); //~ ERROR use of moved value: `start.test` - | ^^^^^^^^^^ value used here after move - | - = note: move occurs because `start` has type `Mine`, which does not implement the `Copy` trait +LL | println!("{}", start.test); //~ ERROR borrow of moved value: `start` + | ^^^^^^^^^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/wasm-custom-section-relocations.stderr b/src/test/ui/wasm-custom-section-relocations.stderr deleted file mode 100644 index 272dd8d524d68..0000000000000 --- a/src/test/ui/wasm-custom-section-relocations.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: statics with a custom `#[link_section]` must be a simple list of bytes on the wasm target with no extra levels of indirection such as references - --> $DIR/wasm-custom-section-relocations.rs:4:1 - | -LL | pub static A: &[u8] = &[1]; //~ ERROR: no extra levels of indirection - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: statics with a custom `#[link_section]` must be a simple list of bytes on the wasm target with no extra levels of indirection such as references - --> $DIR/wasm-custom-section-relocations.rs:13:1 - | -LL | pub static D: &usize = &C; //~ ERROR: no extra levels of indirection - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr b/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr deleted file mode 100644 index 21ac2031d0408..0000000000000 --- a/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:22:5 - | -LL | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^^^^^--^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `four` - --> $DIR/wf-misc-methods-issue-28609.rs:36:5 - | -LL | s.bomb = Some(&four); //~ ERROR does not live long enough - | ----- `four` is borrowed here -LL | &s - | ^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `four` - --> $DIR/wf-misc-methods-issue-28609.rs:43:5 - | -LL | s.bomb = Some(&four); //~ ERROR does not live long enough - | ----- `four` is borrowed here -LL | &*s - | ^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:53:5 - | -LL | s << &mut 3 //~ ERROR does not live long enough - | ^^^^^^^^^^- - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:58:5 - | -LL | s.shl(&mut 3) //~ ERROR does not live long enough - | ^^^^^^^^^^^-^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:63:5 - | -LL | S2::shl(s, &mut 3) //~ ERROR does not live long enough - | ^^^^^^^^^^^^^^^^-^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/wf/wf-misc-methods-issue-28609.rs b/src/test/ui/wf/wf-misc-methods-issue-28609.rs index 505d7d75d5398..050f866e1c813 100644 --- a/src/test/ui/wf/wf-misc-methods-issue-28609.rs +++ b/src/test/ui/wf/wf-misc-methods-issue-28609.rs @@ -19,7 +19,7 @@ impl<'a, 'b> S<'a, 'b> { fn return_dangling_pointer_inherent(s: S2) -> &u32 { let s = s; - s.transmute_inherent(&mut 42) //~ ERROR does not live long enough + s.transmute_inherent(&mut 42) //~ ERROR cannot return value referencing temporary value } impl<'a, 'b> Deref for S<'a, 'b> { @@ -32,15 +32,15 @@ impl<'a, 'b> Deref for S<'a, 'b> { fn return_dangling_pointer_coerce(s: S2) -> &u32 { let four = 4; let mut s = s; - s.bomb = Some(&four); //~ ERROR does not live long enough - &s + s.bomb = Some(&four); + &s //~ ERROR cannot return value referencing local variable `four` } fn return_dangling_pointer_unary_op(s: S2) -> &u32 { let four = 4; let mut s = s; - s.bomb = Some(&four); //~ ERROR does not live long enough - &*s + s.bomb = Some(&four); + &*s //~ ERROR cannot return value referencing local variable `four` } impl<'a, 'b> Shl<&'b u32> for S<'a, 'b> { @@ -50,17 +50,17 @@ impl<'a, 'b> Shl<&'b u32> for S<'a, 'b> { fn return_dangling_pointer_binary_op(s: S2) -> &u32 { let s = s; - s << &mut 3 //~ ERROR does not live long enough + s << &mut 3 //~ ERROR cannot return value referencing temporary value } fn return_dangling_pointer_method(s: S2) -> &u32 { let s = s; - s.shl(&mut 3) //~ ERROR does not live long enough + s.shl(&mut 3) //~ ERROR cannot return value referencing temporary value } fn return_dangling_pointer_ufcs(s: S2) -> &u32 { let s = s; - S2::shl(s, &mut 3) //~ ERROR does not live long enough + S2::shl(s, &mut 3) //~ ERROR cannot return value referencing temporary value } fn main() { diff --git a/src/test/ui/wf/wf-misc-methods-issue-28609.stderr b/src/test/ui/wf/wf-misc-methods-issue-28609.stderr index 46dc4dc8870da..b15acf37cb40c 100644 --- a/src/test/ui/wf/wf-misc-methods-issue-28609.stderr +++ b/src/test/ui/wf/wf-misc-methods-issue-28609.stderr @@ -1,111 +1,55 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:22:31 - | -LL | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough - | ^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 20:1... - --> $DIR/wf-misc-methods-issue-28609.rs:20:1 - | -LL | / fn return_dangling_pointer_inherent(s: S2) -> &u32 { -LL | | let s = s; -LL | | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough -LL | | } - | |_^ +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:22:5 + | +LL | s.transmute_inherent(&mut 42) //~ ERROR cannot return value referencing temporary value + | ^^^^^^^^^^^^^^^^^^^^^^^^^^--^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: `four` does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:35:20 - | -LL | s.bomb = Some(&four); //~ ERROR does not live long enough - | ^^^^ borrowed value does not live long enough -LL | &s -LL | } - | - borrowed value only lives until here +error[E0515]: cannot return value referencing local variable `four` + --> $DIR/wf-misc-methods-issue-28609.rs:36:5 | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 32:1... - --> $DIR/wf-misc-methods-issue-28609.rs:32:1 - | -LL | / fn return_dangling_pointer_coerce(s: S2) -> &u32 { -LL | | let four = 4; -LL | | let mut s = s; -LL | | s.bomb = Some(&four); //~ ERROR does not live long enough -LL | | &s -LL | | } - | |_^ +LL | s.bomb = Some(&four); + | ----- `four` is borrowed here +LL | &s //~ ERROR cannot return value referencing local variable `four` + | ^^ returns a value referencing data owned by the current function -error[E0597]: `four` does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:42:20 - | -LL | s.bomb = Some(&four); //~ ERROR does not live long enough - | ^^^^ borrowed value does not live long enough -LL | &*s -LL | } - | - borrowed value only lives until here +error[E0515]: cannot return value referencing local variable `four` + --> $DIR/wf-misc-methods-issue-28609.rs:43:5 | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 39:1... - --> $DIR/wf-misc-methods-issue-28609.rs:39:1 - | -LL | / fn return_dangling_pointer_unary_op(s: S2) -> &u32 { -LL | | let four = 4; -LL | | let mut s = s; -LL | | s.bomb = Some(&four); //~ ERROR does not live long enough -LL | | &*s -LL | | } - | |_^ +LL | s.bomb = Some(&four); + | ----- `four` is borrowed here +LL | &*s //~ ERROR cannot return value referencing local variable `four` + | ^^^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:53:15 - | -LL | s << &mut 3 //~ ERROR does not live long enough - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 51:1... - --> $DIR/wf-misc-methods-issue-28609.rs:51:1 - | -LL | / fn return_dangling_pointer_binary_op(s: S2) -> &u32 { -LL | | let s = s; -LL | | s << &mut 3 //~ ERROR does not live long enough -LL | | } - | |_^ +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:53:5 + | +LL | s << &mut 3 //~ ERROR cannot return value referencing temporary value + | ^^^^^^^^^^- + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:58:16 - | -LL | s.shl(&mut 3) //~ ERROR does not live long enough - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 56:1... - --> $DIR/wf-misc-methods-issue-28609.rs:56:1 - | -LL | / fn return_dangling_pointer_method(s: S2) -> &u32 { -LL | | let s = s; -LL | | s.shl(&mut 3) //~ ERROR does not live long enough -LL | | } - | |_^ +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:58:5 + | +LL | s.shl(&mut 3) //~ ERROR cannot return value referencing temporary value + | ^^^^^^^^^^^-^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:63:21 - | -LL | S2::shl(s, &mut 3) //~ ERROR does not live long enough - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 61:1... - --> $DIR/wf-misc-methods-issue-28609.rs:61:1 - | -LL | / fn return_dangling_pointer_ufcs(s: S2) -> &u32 { -LL | | let s = s; -LL | | S2::shl(s, &mut 3) //~ ERROR does not live long enough -LL | | } - | |_^ +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:63:5 + | +LL | S2::shl(s, &mut 3) //~ ERROR cannot return value referencing temporary value + | ^^^^^^^^^^^^^^^^-^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/writing-to-immutable-vec.nll.stderr b/src/test/ui/writing-to-immutable-vec.nll.stderr deleted file mode 100644 index 6ec56f90ca47a..0000000000000 --- a/src/test/ui/writing-to-immutable-vec.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable - --> $DIR/writing-to-immutable-vec.rs:3:5 - | -LL | let v: Vec = vec![1, 2, 3]; - | - help: consider changing this to be mutable: `mut v` -LL | v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable - | ^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/writing-to-immutable-vec.rs b/src/test/ui/writing-to-immutable-vec.rs index ad2bf33fc20ba..dbcc3f0bbe98c 100644 --- a/src/test/ui/writing-to-immutable-vec.rs +++ b/src/test/ui/writing-to-immutable-vec.rs @@ -1,4 +1,4 @@ fn main() { let v: Vec = vec![1, 2, 3]; - v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable + v[1] = 4; //~ ERROR cannot borrow `v` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/writing-to-immutable-vec.stderr b/src/test/ui/writing-to-immutable-vec.stderr index 3a99186b46f6a..1fc3c18dc26ef 100644 --- a/src/test/ui/writing-to-immutable-vec.stderr +++ b/src/test/ui/writing-to-immutable-vec.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `v` as mutable +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable --> $DIR/writing-to-immutable-vec.rs:3:5 | LL | let v: Vec = vec![1, 2, 3]; - | - help: make this binding mutable: `mut v` -LL | v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable - | ^ cannot borrow mutably + | - help: consider changing this to be mutable: `mut v` +LL | v[1] = 4; //~ ERROR cannot borrow `v` as mutable, as it is not declared as mutable + | ^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index bac41a7c57904..0dfc24b2bca26 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1837,10 +1837,11 @@ impl<'test> TestCx<'test> { match self.config.compare_mode { Some(CompareMode::Nll) => { - rustc.args(&["-Zborrowck=migrate", "-Ztwo-phase-borrows"]); + // FIXME(#56993) use -Zborrowck=mir + rustc.args(&["-Zborrowck=migrate"]); } Some(CompareMode::Polonius) => { - rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]); + rustc.args(&["-Zpolonius", "-Zborrowck=mir"]); } None => {} }