Auto merge of #2979 - rust-lang:rustup2023-07-13, r=RalfJung

Automatic sync from rustc
This commit is contained in:
bors 2023-07-13 06:45:56 +00:00
commit ad9b7b56a4
176 changed files with 449 additions and 480 deletions

View File

@ -1121,7 +1121,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.eager_subdiagnostic( err.eager_subdiagnostic(
&self.infcx.tcx.sess.parse_sess.span_diagnostic, &self.infcx.tcx.sess.parse_sess.span_diagnostic,
CaptureReasonSuggest::FreshReborrow { CaptureReasonSuggest::FreshReborrow {
span: fn_call_span.shrink_to_lo(), span: move_span.shrink_to_hi(),
}); });
} }
if let Some(clone_trait) = tcx.lang_items().clone_trait() if let Some(clone_trait) = tcx.lang_items().clone_trait()
@ -1135,10 +1135,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&& self.infcx.predicate_must_hold_modulo_regions(&o) && self.infcx.predicate_must_hold_modulo_regions(&o)
{ {
err.span_suggestion_verbose( err.span_suggestion_verbose(
fn_call_span.shrink_to_lo(), move_span.shrink_to_hi(),
"you can `clone` the value and consume it, but this might not be \ "you can `clone` the value and consume it, but this might not be \
your desired behavior", your desired behavior",
"clone().".to_string(), ".clone()".to_string(),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} }

View File

@ -398,7 +398,7 @@ pub(crate) enum CaptureReasonSuggest<'tcx> {
#[suggestion( #[suggestion(
borrowck_suggest_create_freash_reborrow, borrowck_suggest_create_freash_reborrow,
applicability = "maybe-incorrect", applicability = "maybe-incorrect",
code = "as_mut().", code = ".as_mut()",
style = "verbose" style = "verbose"
)] )]
FreshReborrow { FreshReborrow {

View File

@ -41,11 +41,6 @@ impl<'tcx> Cx<'tcx> {
let mut expr = self.make_mirror_unadjusted(hir_expr); let mut expr = self.make_mirror_unadjusted(hir_expr);
let adjustment_span = match self.adjustment_span {
Some((hir_id, span)) if hir_id == hir_expr.hir_id => Some(span),
_ => None,
};
trace!(?expr.ty); trace!(?expr.ty);
// Now apply adjustments, if any. // Now apply adjustments, if any.
@ -53,12 +48,7 @@ impl<'tcx> Cx<'tcx> {
for adjustment in self.typeck_results.expr_adjustments(hir_expr) { for adjustment in self.typeck_results.expr_adjustments(hir_expr) {
trace!(?expr, ?adjustment); trace!(?expr, ?adjustment);
let span = expr.span; let span = expr.span;
expr = self.apply_adjustment( expr = self.apply_adjustment(hir_expr, expr, adjustment, span);
hir_expr,
expr,
adjustment,
adjustment_span.unwrap_or(span),
);
} }
} }
@ -274,7 +264,6 @@ impl<'tcx> Cx<'tcx> {
fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> { fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let expr_ty = self.typeck_results().expr_ty(expr); let expr_ty = self.typeck_results().expr_ty(expr);
let expr_span = expr.span;
let temp_lifetime = let temp_lifetime =
self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id); self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id);
@ -283,17 +272,11 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::MethodCall(segment, receiver, ref args, fn_span) => { hir::ExprKind::MethodCall(segment, receiver, ref args, fn_span) => {
// Rewrite a.b(c) into UFCS form like Trait::b(a, c) // Rewrite a.b(c) into UFCS form like Trait::b(a, c)
let expr = self.method_callee(expr, segment.ident.span, None); let expr = self.method_callee(expr, segment.ident.span, None);
// When we apply adjustments to the receiver, use the span of
// the overall method call for better diagnostics. args[0]
// is guaranteed to exist, since a method call always has a receiver.
let old_adjustment_span =
self.adjustment_span.replace((receiver.hir_id, expr_span));
info!("Using method span: {:?}", expr.span); info!("Using method span: {:?}", expr.span);
let args = std::iter::once(receiver) let args = std::iter::once(receiver)
.chain(args.iter()) .chain(args.iter())
.map(|expr| self.mirror_expr(expr)) .map(|expr| self.mirror_expr(expr))
.collect(); .collect();
self.adjustment_span = old_adjustment_span;
ExprKind::Call { ExprKind::Call {
ty: expr.ty, ty: expr.ty,
fun: self.thir.exprs.push(expr), fun: self.thir.exprs.push(expr),

View File

@ -16,7 +16,6 @@ use rustc_hir::Node;
use rustc_middle::middle::region; use rustc_middle::middle::region;
use rustc_middle::thir::*; use rustc_middle::thir::*;
use rustc_middle::ty::{self, RvalueScopes, Ty, TyCtxt}; use rustc_middle::ty::{self, RvalueScopes, Ty, TyCtxt};
use rustc_span::Span;
pub(crate) fn thir_body( pub(crate) fn thir_body(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
@ -62,14 +61,6 @@ struct Cx<'tcx> {
typeck_results: &'tcx ty::TypeckResults<'tcx>, typeck_results: &'tcx ty::TypeckResults<'tcx>,
rvalue_scopes: &'tcx RvalueScopes, rvalue_scopes: &'tcx RvalueScopes,
/// When applying adjustments to the expression
/// with the given `HirId`, use the given `Span`,
/// instead of the usual span. This is used to
/// assign the span of an overall method call
/// (e.g. `my_val.foo()`) to the adjustment expressions
/// for the receiver.
adjustment_span: Option<(HirId, Span)>,
/// False to indicate that adjustments should not be applied. Only used for `custom_mir` /// False to indicate that adjustments should not be applied. Only used for `custom_mir`
apply_adjustments: bool, apply_adjustments: bool,
@ -110,7 +101,6 @@ impl<'tcx> Cx<'tcx> {
typeck_results, typeck_results,
rvalue_scopes: &typeck_results.rvalue_scopes, rvalue_scopes: &typeck_results.rvalue_scopes,
body_owner: def.to_def_id(), body_owner: def.to_def_id(),
adjustment_span: None,
apply_adjustments: hir apply_adjustments: hir
.attrs(hir_id) .attrs(hir_id)
.iter() .iter()

View File

@ -188,7 +188,7 @@ impl Config {
patchelf.args(&["--set-interpreter", dynamic_linker.trim_end()]); patchelf.args(&["--set-interpreter", dynamic_linker.trim_end()]);
} }
self.try_run(patchelf.arg(fname)).unwrap(); let _ = self.try_run(patchelf.arg(fname));
} }
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) { fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {

View File

@ -27,8 +27,7 @@ impl Step for ExpandYamlAnchors {
try_run( try_run(
builder, builder,
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src), &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
) );
.unwrap();
} }
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@ -40,17 +39,17 @@ impl Step for ExpandYamlAnchors {
} }
} }
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> { fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
if !builder.fail_fast { if !builder.fail_fast {
if let Err(e) = builder.try_run(cmd) { if builder.try_run(cmd).is_err() {
let mut failures = builder.delayed_failures.borrow_mut(); let mut failures = builder.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd)); failures.push(format!("{:?}", cmd));
return Err(e); return false;
} }
} else { } else {
builder.run(cmd); builder.run(cmd);
} }
Ok(()) true
} }
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]

View File

@ -48,17 +48,17 @@ const MIR_OPT_BLESS_TARGET_MAPPING: &[(&str, &str)] = &[
// build for, so there is no entry for "aarch64-apple-darwin" here. // build for, so there is no entry for "aarch64-apple-darwin" here.
]; ];
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> { fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
if !builder.fail_fast { if !builder.fail_fast {
if let Err(e) = builder.try_run(cmd) { if builder.try_run(cmd).is_err() {
let mut failures = builder.delayed_failures.borrow_mut(); let mut failures = builder.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd)); failures.push(format!("{:?}", cmd));
return Err(e); return false;
} }
} else { } else {
builder.run(cmd); builder.run(cmd);
} }
Ok(()) true
} }
fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool { fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
@ -187,8 +187,7 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
try_run( try_run(
builder, builder,
builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")), builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")),
) );
.unwrap();
} }
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@ -241,8 +240,7 @@ impl Step for HtmlCheck {
builder.default_doc(&[]); builder.default_doc(&[]);
builder.ensure(crate::doc::Rustc::new(builder.top_stage, self.target, builder)); builder.ensure(crate::doc::Rustc::new(builder.top_stage, self.target, builder));
try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target))) try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
.unwrap();
} }
} }
@ -288,8 +286,7 @@ impl Step for Cargotest {
.args(builder.config.test_args()) .args(builder.config.test_args())
.env("RUSTC", builder.rustc(compiler)) .env("RUSTC", builder.rustc(compiler))
.env("RUSTDOC", builder.rustdoc(compiler)), .env("RUSTDOC", builder.rustdoc(compiler)),
) );
.unwrap();
} }
} }
@ -855,7 +852,7 @@ impl Step for RustdocTheme {
util::lld_flag_no_threads(self.compiler.host.contains("windows")), util::lld_flag_no_threads(self.compiler.host.contains("windows")),
); );
} }
try_run(builder, &mut cmd).unwrap(); try_run(builder, &mut cmd);
} }
} }
@ -1106,7 +1103,7 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy`
} }
builder.info("tidy check"); builder.info("tidy check");
try_run(builder, &mut cmd).unwrap(); try_run(builder, &mut cmd);
builder.ensure(ExpandYamlAnchors); builder.ensure(ExpandYamlAnchors);
@ -1154,8 +1151,7 @@ impl Step for ExpandYamlAnchors {
try_run( try_run(
builder, builder,
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src), &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
) );
.unwrap();
} }
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@ -1948,7 +1944,7 @@ impl BookTest {
compiler.host, compiler.host,
); );
let _time = util::timeit(&builder); let _time = util::timeit(&builder);
let toolstate = if try_run(builder, &mut rustbook_cmd).is_ok() { let toolstate = if try_run(builder, &mut rustbook_cmd) {
ToolState::TestPass ToolState::TestPass
} else { } else {
ToolState::TestFail ToolState::TestFail
@ -2106,7 +2102,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
cmd.arg("--test-args").arg(test_args); cmd.arg("--test-args").arg(test_args);
if builder.config.verbose_tests { if builder.config.verbose_tests {
try_run(builder, &mut cmd).is_ok() try_run(builder, &mut cmd)
} else { } else {
try_run_quiet(builder, &mut cmd) try_run_quiet(builder, &mut cmd)
} }
@ -2134,7 +2130,7 @@ impl Step for RustcGuide {
let src = builder.src.join(relative_path); let src = builder.src.join(relative_path);
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook); let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)).is_ok() { let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
ToolState::TestPass ToolState::TestPass
} else { } else {
ToolState::TestFail ToolState::TestFail
@ -2684,7 +2680,7 @@ impl Step for Bootstrap {
.current_dir(builder.src.join("src/bootstrap/")); .current_dir(builder.src.join("src/bootstrap/"));
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible. // NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
// Use `python -m unittest` manually if you want to pass arguments. // Use `python -m unittest` manually if you want to pass arguments.
try_run(builder, &mut check_bootstrap).unwrap(); try_run(builder, &mut check_bootstrap);
let host = builder.config.build; let host = builder.config.build;
let compiler = builder.compiler(0, host); let compiler = builder.compiler(0, host);
@ -2756,7 +2752,7 @@ impl Step for TierCheck {
} }
builder.info("platform support check"); builder.info("platform support check");
try_run(builder, &mut cargo.into()).unwrap(); try_run(builder, &mut cargo.into());
} }
} }
@ -2836,7 +2832,7 @@ impl Step for RustInstaller {
cmd.env("CARGO", &builder.initial_cargo); cmd.env("CARGO", &builder.initial_cargo);
cmd.env("RUSTC", &builder.initial_rustc); cmd.env("RUSTC", &builder.initial_rustc);
cmd.env("TMP_DIR", &tmpdir); cmd.env("TMP_DIR", &tmpdir);
try_run(builder, &mut cmd).unwrap(); try_run(builder, &mut cmd);
} }
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

View File

@ -1 +1 @@
136dab66142115d9de16b4cfe2d8395d71a8ab6d 33a2c2487ac5d9927830ea4c1844335c6b9f77db

View File

@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/box-cell-alias.rs:LL:CC --> $DIR/box-cell-alias.rs:LL:CC
| |
LL | unsafe { (*ptr).set(20) }; LL | unsafe { (*ptr).set(20) };
| ^^^^^^^^^^^^^^ | ^^^^^^
| | | |
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location | trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of retag at ALLOC[0x0..0x1] | this error occurs as part of retag at ALLOC[0x0..0x1]

View File

@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/illegal_read7.rs:LL:CC --> $DIR/illegal_read7.rs:LL:CC
| |
LL | let _val = *x.get_mut(); LL | let _val = *x.get_mut();
| ^^^^^^^^^^^ | ^
| | | |
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location | trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of two-phase retag at ALLOC[0x0..0x4] | this error occurs as part of two-phase retag at ALLOC[0x0..0x4]

View File

@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/interior_mut1.rs:LL:CC --> $DIR/interior_mut1.rs:LL:CC
| |
LL | let _val = *inner_shr.get(); LL | let _val = *inner_shr.get();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^
| | | |
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location | trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of retag at ALLOC[0x0..0x4] | this error occurs as part of retag at ALLOC[0x0..0x4]

View File

@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/interior_mut2.rs:LL:CC --> $DIR/interior_mut2.rs:LL:CC
| |
LL | let _val = *inner_shr.get(); LL | let _val = *inner_shr.get();
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^
| | | |
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location | trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of retag at ALLOC[0x0..0x4] | this error occurs as part of retag at ALLOC[0x0..0x4]

View File

@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/shared_rw_borrows_are_weak1.rs:LL:CC --> $DIR/shared_rw_borrows_are_weak1.rs:LL:CC
| |
LL | y.get_mut(); LL | y.get_mut();
| ^^^^^^^^^^^ | ^
| | | |
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location | trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of two-phase retag at ALLOC[0x0..0x4] | this error occurs as part of two-phase retag at ALLOC[0x0..0x4]

View File

@ -21,7 +21,7 @@ help: the accessed tag <TAG> later transitioned to Frozen due to a reborrow (act
--> $DIR/fnentry_invalidation.rs:LL:CC --> $DIR/fnentry_invalidation.rs:LL:CC
| |
LL | x.do_bad(); LL | x.do_bad();
| ^^^^^^^^^^ | ^
= help: this transition corresponds to a loss of write permissions = help: this transition corresponds to a loss of write permissions
= note: BACKTRACE (of the first span): = note: BACKTRACE (of the first span):
= note: inside `main` at $DIR/fnentry_invalidation.rs:LL:CC = note: inside `main` at $DIR/fnentry_invalidation.rs:LL:CC

View File

@ -10,14 +10,7 @@ help: the accessed tag <TAG> was created here, in the initial state Reserved
--> $DIR/write-during-2phase.rs:LL:CC --> $DIR/write-during-2phase.rs:LL:CC
| |
LL | let _res = f.add(unsafe { LL | let _res = f.add(unsafe {
| ________________^ | ^
LL | | let n = f.0;
LL | | // This is the access at fault, but it's not immediately apparent because
LL | | // the reference that got invalidated is not under a Protector.
LL | | *inner = 42;
LL | | n
LL | | });
| |______^
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x0..0x8] help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x0..0x8]
--> $DIR/write-during-2phase.rs:LL:CC --> $DIR/write-during-2phase.rs:LL:CC
| |

View File

@ -7,7 +7,7 @@ LL | for x in &mut xs {
| first mutable borrow occurs here | first mutable borrow occurs here
| first borrow later used here | first borrow later used here
LL | xs.push(1) LL | xs.push(1)
| ^^^^^^^^^^ second mutable borrow occurs here | ^^ second mutable borrow occurs here
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> $DIR/issue-61452.rs:4:5 --> $DIR/issue-61452.rs:4:5
| |
LL | x.take(); LL | x.take();
| ^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `data` as mutable, as it is not declared as mutable
--> $DIR/issue-61187.rs:6:5 --> $DIR/issue-61187.rs:6:5
| |
LL | data.reverse(); LL | data.reverse();
| ^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -27,7 +27,7 @@ LL | x
| - value moved here | - value moved here
LL | + LL | +
LL | x.clone(); LL | x.clone();
| ^^^^^^^^^ value borrowed here after move | ^ value borrowed here after move
| |
help: consider cloning the value if the performance cost is acceptable help: consider cloning the value if the performance cost is acceptable
| |

View File

@ -9,7 +9,7 @@ LL | let y = x;
| ^ move out of `x` occurs here | ^ move out of `x` occurs here
LL | LL |
LL | r.use_ref(); LL | r.use_ref();
| ----------- borrow later used here | - borrow later used here
error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
--> $DIR/borrow-tuple-fields.rs:18:13 --> $DIR/borrow-tuple-fields.rs:18:13
@ -19,7 +19,7 @@ LL | let a = &x.0;
LL | let b = &mut x.0; LL | let b = &mut x.0;
| ^^^^^^^^ mutable borrow occurs here | ^^^^^^^^ mutable borrow occurs here
LL | a.use_ref(); LL | a.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error[E0499]: cannot borrow `x.0` as mutable more than once at a time error[E0499]: cannot borrow `x.0` as mutable more than once at a time
--> $DIR/borrow-tuple-fields.rs:23:13 --> $DIR/borrow-tuple-fields.rs:23:13
@ -29,7 +29,7 @@ LL | let a = &mut x.0;
LL | let b = &mut x.0; LL | let b = &mut x.0;
| ^^^^^^^^ second mutable borrow occurs here | ^^^^^^^^ second mutable borrow occurs here
LL | a.use_ref(); LL | a.use_ref();
| ----------- first borrow later used here | - first borrow later used here
error[E0505]: cannot move out of `x` because it is borrowed error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/borrow-tuple-fields.rs:28:13 --> $DIR/borrow-tuple-fields.rs:28:13
@ -41,7 +41,7 @@ LL | let r = &x.0;
LL | let y = x; LL | let y = x;
| ^ move out of `x` occurs here | ^ move out of `x` occurs here
LL | r.use_ref(); LL | r.use_ref();
| ----------- borrow later used here | - borrow later used here
error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable
--> $DIR/borrow-tuple-fields.rs:33:13 --> $DIR/borrow-tuple-fields.rs:33:13
@ -51,7 +51,7 @@ LL | let a = &x.0;
LL | let b = &mut x.0; LL | let b = &mut x.0;
| ^^^^^^^^ mutable borrow occurs here | ^^^^^^^^ mutable borrow occurs here
LL | a.use_ref(); LL | a.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error[E0499]: cannot borrow `x.0` as mutable more than once at a time error[E0499]: cannot borrow `x.0` as mutable more than once at a time
--> $DIR/borrow-tuple-fields.rs:38:13 --> $DIR/borrow-tuple-fields.rs:38:13
@ -61,7 +61,7 @@ LL | let a = &mut x.0;
LL | let b = &mut x.0; LL | let b = &mut x.0;
| ^^^^^^^^ second mutable borrow occurs here | ^^^^^^^^ second mutable borrow occurs here
LL | a.use_mut(); LL | a.use_mut();
| ----------- first borrow later used here | - first borrow later used here
error: aborting due to 6 previous errors error: aborting due to 6 previous errors

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
--> $DIR/borrowck-argument.rs:10:5 --> $DIR/borrowck-argument.rs:10:5
| |
LL | arg.mutate(); LL | arg.mutate();
| ^^^^^^^^^^^^ cannot borrow as mutable | ^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |
@ -13,7 +13,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
--> $DIR/borrowck-argument.rs:15:9 --> $DIR/borrowck-argument.rs:15:9
| |
LL | arg.mutate(); LL | arg.mutate();
| ^^^^^^^^^^^^ cannot borrow as mutable | ^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |
@ -24,7 +24,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
--> $DIR/borrowck-argument.rs:21:9 --> $DIR/borrowck-argument.rs:21:9
| |
LL | arg.mutate(); LL | arg.mutate();
| ^^^^^^^^^^^^ cannot borrow as mutable | ^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |
@ -35,7 +35,7 @@ error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable
--> $DIR/borrowck-argument.rs:32:17 --> $DIR/borrowck-argument.rs:32:17
| |
LL | (|arg: S| { arg.mutate() })(s); LL | (|arg: S| { arg.mutate() })(s);
| ^^^^^^^^^^^^ cannot borrow as mutable | ^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -2,7 +2,7 @@ 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 --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:15:5
| |
LL | x.printme(); LL | x.printme();
| ^^^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -2,7 +2,7 @@ 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 --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5
| |
LL | a.foo(); LL | a.foo();
| ^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -2,11 +2,11 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time
--> $DIR/borrowck-borrow-mut-object-twice.rs:13:5 --> $DIR/borrowck-borrow-mut-object-twice.rs:13:5
| |
LL | let y = x.f1(); LL | let y = x.f1();
| ------ first mutable borrow occurs here | - first mutable borrow occurs here
LL | x.f2(); LL | x.f2();
| ^^^^^^ second mutable borrow occurs here | ^ second mutable borrow occurs here
LL | y.use_ref(); LL | y.use_ref();
| ----------- first borrow later used here | - first borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -58,7 +58,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref.rs:72:5 --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:72:5
| |
LL | x.set(0, 0); LL | x.set(0, 0);
| ^^^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>` = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>`
@ -66,7 +66,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref.rs:76:5 --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:76:5
| |
LL | x.set(0, 0); LL | x.set(0, 0);
| ^^^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>` = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>`
@ -74,7 +74,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref.rs:84:5 --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:84:5
| |
LL | x.y_mut() LL | x.y_mut()
| ^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>` = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>`
@ -82,7 +82,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref.rs:88:5 --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:88:5
| |
LL | x.y_mut() LL | x.y_mut()
| ^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>` = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>`
@ -90,7 +90,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref.rs:92:6 --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:92:6
| |
LL | *x.y_mut() = 3; LL | *x.y_mut() = 3;
| ^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>` = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>`
@ -98,7 +98,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref.rs:96:6 --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:96:6
| |
LL | *x.y_mut() = 3; LL | *x.y_mut() = 3;
| ^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>` = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>`
@ -106,7 +106,7 @@ error[E0596]: cannot borrow data in an `Rc` as mutable
--> $DIR/borrowck-borrow-overloaded-auto-deref.rs:100:6 --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:100:6
| |
LL | *x.y_mut() = 3; LL | *x.y_mut() = 3;
| ^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>` = help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `Rc<Point>`

View File

@ -7,7 +7,7 @@ LL | buggy_map.insert(42, &*Box::new(1));
| creates a temporary value which is freed while still in use | creates a temporary value which is freed while still in use
... ...
LL | buggy_map.insert(43, &*tmp); LL | buggy_map.insert(43, &*tmp);
| --------------------------- borrow later used here | --------- borrow later used here
| |
help: consider using a `let` binding to create a longer lived value help: consider using a `let` binding to create a longer lived value
| |

View File

@ -6,7 +6,7 @@ LL | let p = &this.x;
LL | &mut this.x; LL | &mut this.x;
| ^^^^^^^^^^^ mutable borrow occurs here | ^^^^^^^^^^^ mutable borrow occurs here
LL | p.use_ref(); LL | p.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -45,7 +45,7 @@ error[E0503]: cannot use `f.x` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:37:9 --> $DIR/borrowck-describe-lvalue.rs:37:9
| |
LL | let x = f.x(); LL | let x = f.x();
| ----- `f` is borrowed here | - `f` is borrowed here
LL | f.x; LL | f.x;
| ^^^ use of borrowed `f` | ^^^ use of borrowed `f`
LL | drop(x); LL | drop(x);
@ -55,7 +55,7 @@ error[E0503]: cannot use `g.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:44:9 --> $DIR/borrowck-describe-lvalue.rs:44:9
| |
LL | let x = g.x(); LL | let x = g.x();
| ----- `g` is borrowed here | - `g` is borrowed here
LL | g.0; LL | g.0;
| ^^^ use of borrowed `g` | ^^^ use of borrowed `g`
LL | drop(x); LL | drop(x);
@ -75,7 +75,7 @@ error[E0503]: cannot use `e.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:59:20 --> $DIR/borrowck-describe-lvalue.rs:59:20
| |
LL | let x = e.x(); LL | let x = e.x();
| ----- `e` is borrowed here | - `e` is borrowed here
LL | match e { LL | match e {
LL | Baz::X(value) => value LL | Baz::X(value) => value
| ^^^^^ use of borrowed `e` | ^^^^^ use of borrowed `e`
@ -97,7 +97,7 @@ error[E0503]: cannot use `f.x` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:74:9 --> $DIR/borrowck-describe-lvalue.rs:74:9
| |
LL | let x = f.x(); LL | let x = f.x();
| ----- `*f` is borrowed here | - `*f` is borrowed here
LL | f.x; LL | f.x;
| ^^^ use of borrowed `*f` | ^^^ use of borrowed `*f`
LL | drop(x); LL | drop(x);
@ -107,7 +107,7 @@ error[E0503]: cannot use `g.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:81:9 --> $DIR/borrowck-describe-lvalue.rs:81:9
| |
LL | let x = g.x(); LL | let x = g.x();
| ----- `*g` is borrowed here | - `*g` is borrowed here
LL | g.0; LL | g.0;
| ^^^ use of borrowed `*g` | ^^^ use of borrowed `*g`
LL | drop(x); LL | drop(x);
@ -127,7 +127,7 @@ error[E0503]: cannot use `e.0` because it was mutably borrowed
--> $DIR/borrowck-describe-lvalue.rs:96:20 --> $DIR/borrowck-describe-lvalue.rs:96:20
| |
LL | let x = e.x(); LL | let x = e.x();
| ----- `*e` is borrowed here | - `*e` is borrowed here
LL | match *e { LL | match *e {
LL | Baz::X(value) => value LL | Baz::X(value) => value
| ^^^^^ use of borrowed `*e` | ^^^^^ use of borrowed `*e`

View File

@ -18,15 +18,13 @@ error[E0500]: closure requires unique access to `f` but it is already borrowed
| |
LL | f.foo( LL | f.foo(
| - --- first borrow later used by call | - --- first borrow later used by call
| _____|
| | | |
LL | | | borrow occurs here
LL | | |a| { LL |
| | ^^^ closure construction occurs here LL | |a| {
LL | | f.n.insert(*a); | ^^^ closure construction occurs here
| | --- second borrow occurs due to use of `f` in closure LL | f.n.insert(*a);
LL | | }) | --- second borrow occurs due to use of `f` in closure
| |__________- borrow occurs here
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -6,7 +6,7 @@ LL | Some(ref _y) => {
LL | let _a = x; LL | let _a = x;
| ^ move out of `x` occurs here | ^ move out of `x` occurs here
LL | _y.use_ref(); LL | _y.use_ref();
| ------------ borrow later used here | -- borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -7,7 +7,7 @@ LL | }
LL | borrow_mut(&mut *v); LL | borrow_mut(&mut *v);
| ^^^^^^^ mutable borrow occurs here | ^^^^^^^ mutable borrow occurs here
LL | _w.use_ref(); LL | _w.use_ref();
| ------------ immutable borrow later used here | -- immutable borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -6,7 +6,7 @@ LL | let _w = &v;
LL | borrow_mut(&mut *v); LL | borrow_mut(&mut *v);
| ^^^^^^^ mutable borrow occurs here | ^^^^^^^ mutable borrow occurs here
LL | _w.use_ref(); LL | _w.use_ref();
| ------------ immutable borrow later used here | -- immutable borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -12,7 +12,7 @@ LL | println!("v={}", *v);
| -- move occurs due to use in closure | -- move occurs due to use in closure
LL | }); LL | });
LL | w.use_ref(); LL | w.use_ref();
| ----------- borrow later used here | - borrow later used here
error[E0505]: cannot move out of `v` because it is borrowed error[E0505]: cannot move out of `v` because it is borrowed
--> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19
@ -28,7 +28,7 @@ LL | println!("v={}", *v);
| -- move occurs due to use in closure | -- move occurs due to use in closure
LL | }); LL | });
LL | w.use_ref(); LL | w.use_ref();
| ----------- borrow later used here | - borrow later used here
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -8,7 +8,7 @@ LL | let w = &v;
LL | take(v); LL | take(v);
| ^ move out of `v` occurs here | ^ move out of `v` occurs here
LL | w.use_ref(); LL | w.use_ref();
| ----------- borrow later used here | - borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `x`
LL | let x = Foo(Box::new(3)); LL | let x = Foo(Box::new(3));
| - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait | - 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 LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur
| - ^^^^^^^^^ value borrowed here after move | - ^ value borrowed here after move
| | | |
| value moved here | value moved here
| |

View File

@ -17,7 +17,7 @@ LL | let q = &mut p;
| ------ mutable borrow occurs here | ------ mutable borrow occurs here
... ...
LL | p.times(3); LL | p.times(3);
| ^^^^^^^^^^ immutable borrow occurs here | ^ immutable borrow occurs here
LL | LL |
LL | *q + 3; // OK to use the new alias `q` LL | *q + 3; // OK to use the new alias `q`
| -- mutable borrow later used here | -- mutable borrow later used here

View File

@ -4,12 +4,10 @@ error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immuta
LL | p.blockm(|| { LL | p.blockm(|| {
| - ------ ^^ mutable borrow occurs here | - ------ ^^ mutable borrow occurs here
| | | | | |
| _____| immutable borrow later used by call | | immutable borrow later used by call
| | | immutable borrow occurs here
LL | | p.x = 10; LL | p.x = 10;
| | --- second borrow occurs due to use of `p` in closure | --- second borrow occurs due to use of `p` in closure
LL | | })
| |______- immutable borrow occurs here
error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-loan-rcvr.rs:34:5 --> $DIR/borrowck-loan-rcvr.rs:34:5
@ -17,7 +15,7 @@ error[E0502]: cannot borrow `p` as immutable because it is also borrowed as muta
LL | let l = &mut p; LL | let l = &mut p;
| ------ mutable borrow occurs here | ------ mutable borrow occurs here
LL | p.impurem(); LL | p.impurem();
| ^^^^^^^^^^^ immutable borrow occurs here | ^ immutable borrow occurs here
LL | LL |
LL | l.x += 1; LL | l.x += 1;
| -------- mutable borrow later used here | -------- mutable borrow later used here

View File

@ -9,7 +9,7 @@ LL |
LL | let z = *a; LL | let z = *a;
| ^^ move out of `*a` occurs here | ^^ move out of `*a` occurs here
LL | b.use_ref(); LL | b.use_ref();
| ----------- borrow later used here | - borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -9,7 +9,7 @@ LL | let t1 = t0;
| ^^ move out of `t0` occurs here | ^^ move out of `t0` occurs here
LL | *t1 = 22; LL | *t1 = 22;
LL | p.use_ref(); LL | p.use_ref();
| ----------- borrow later used here | - borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,9 +2,8 @@ error[E0507]: cannot move out of an `Rc`
--> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:4:14 --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:4:14
| |
LL | let _x = Rc::new(vec![1, 2]).into_iter(); LL | let _x = Rc::new(vec![1, 2]).into_iter();
| ^^^^^^^^^^^^^^^^^^^^----------- | ^^^^^^^^^^^^^^^^^^^ ----------- value moved due to this method call
| | | | |
| | value moved due to this method call
| move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait | move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait
| |
note: `into_iter` takes ownership of the receiver `self`, which moves value note: `into_iter` takes ownership of the receiver `self`, which moves value

View File

@ -5,9 +5,8 @@ LL | 1 => { addr.push(&mut x); }
| ^^^^^^ second mutable borrow occurs here | ^^^^^^ second mutable borrow occurs here
LL | 2 => { addr.push(&mut x); } LL | 2 => { addr.push(&mut x); }
LL | _ => { addr.push(&mut x); } LL | _ => { addr.push(&mut x); }
| ----------------- | ---- ------ first mutable borrow occurs here
| | | | |
| | first mutable borrow occurs here
| first borrow later used here | first borrow later used here
error[E0499]: cannot borrow `x` as mutable more than once at a time error[E0499]: cannot borrow `x` as mutable more than once at a time
@ -16,18 +15,16 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time
LL | 2 => { addr.push(&mut x); } LL | 2 => { addr.push(&mut x); }
| ^^^^^^ second mutable borrow occurs here | ^^^^^^ second mutable borrow occurs here
LL | _ => { addr.push(&mut x); } LL | _ => { addr.push(&mut x); }
| ----------------- | ---- ------ first mutable borrow occurs here
| | | | |
| | first mutable borrow occurs here
| first borrow later used here | first borrow later used here
error[E0499]: cannot borrow `x` as mutable more than once at a time error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30 --> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30
| |
LL | _ => { addr.push(&mut x); } LL | _ => { addr.push(&mut x); }
| ----------^^^^^^- | ---- ^^^^^^ `x` was mutably borrowed here in the previous iteration of the loop
| | | | |
| | `x` was mutably borrowed here in the previous iteration of the loop
| first borrow used here, in later iteration of loop | first borrow used here, in later iteration of loop
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@ -7,7 +7,7 @@ LL | let mut t2 = &mut t0;
| ^^^^^^^ mutable borrow occurs here | ^^^^^^^ mutable borrow occurs here
LL | **t2 += 1; // Mutates `*t0` LL | **t2 += 1; // Mutates `*t0`
LL | p.use_ref(); LL | p.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error[E0499]: cannot borrow `t0` as mutable more than once at a time error[E0499]: cannot borrow `t0` as mutable more than once at a time
--> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18 --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18
@ -18,7 +18,7 @@ LL | let mut t2 = &mut t0;
| ^^^^^^^ second mutable borrow occurs here | ^^^^^^^ second mutable borrow occurs here
LL | **t2 += 1; // Mutates `*t0` but not through `*p` LL | **t2 += 1; // Mutates `*t0` but not through `*p`
LL | p.use_mut(); LL | p.use_mut();
| ----------- first borrow later used here | - first borrow later used here
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -2,21 +2,21 @@ error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immut
--> $DIR/borrowck-object-lifetime.rs:20:13 --> $DIR/borrowck-object-lifetime.rs:20:13
| |
LL | let y = x.borrowed(); LL | let y = x.borrowed();
| ------------ immutable borrow occurs here | - immutable borrow occurs here
LL | let z = x.mut_borrowed(); LL | let z = x.mut_borrowed();
| ^^^^^^^^^^^^^^^^ mutable borrow occurs here | ^^^^^^^^^^^^^^^^ mutable borrow occurs here
LL | y.use_ref(); LL | y.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-object-lifetime.rs:26:13 --> $DIR/borrowck-object-lifetime.rs:26:13
| |
LL | let y = x.borrowed(); LL | let y = x.borrowed();
| ------------ immutable borrow occurs here | - immutable borrow occurs here
LL | let z = &mut x; LL | let z = &mut x;
| ^^^^^^ mutable borrow occurs here | ^^^^^^ mutable borrow occurs here
LL | y.use_ref(); LL | y.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -6,7 +6,7 @@ LL | let p = &mut f[&s];
LL | let q = &f[&s]; LL | let q = &f[&s];
| ^ immutable borrow occurs here | ^ immutable borrow occurs here
LL | p.use_mut(); LL | p.use_mut();
| ----------- mutable borrow later used here | - mutable borrow later used here
error[E0499]: cannot borrow `*f` as mutable more than once at a time error[E0499]: cannot borrow `*f` as mutable more than once at a time
--> $DIR/borrowck-overloaded-index-autoderef.rs:43:18 --> $DIR/borrowck-overloaded-index-autoderef.rs:43:18
@ -16,7 +16,7 @@ LL | let p = &mut f[&s];
LL | let q = &mut f[&s]; LL | let q = &mut f[&s];
| ^ second mutable borrow occurs here | ^ second mutable borrow occurs here
LL | p.use_mut(); LL | p.use_mut();
| ----------- first borrow later used here | - first borrow later used here
error[E0499]: cannot borrow `f.foo` as mutable more than once at a time error[E0499]: cannot borrow `f.foo` as mutable more than once at a time
--> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18
@ -26,7 +26,7 @@ LL | let p = &mut f.foo[&s];
LL | let q = &mut f.foo[&s]; LL | let q = &mut f.foo[&s];
| ^^^^^ second mutable borrow occurs here | ^^^^^ second mutable borrow occurs here
LL | p.use_mut(); LL | p.use_mut();
| ----------- first borrow later used here | - first borrow later used here
error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-overloaded-index-autoderef.rs:65:18 --> $DIR/borrowck-overloaded-index-autoderef.rs:65:18
@ -36,7 +36,7 @@ LL | let p = &f.foo[&s];
LL | let q = &mut f.foo[&s]; LL | let q = &mut f.foo[&s];
| ^^^^^ mutable borrow occurs here | ^^^^^ mutable borrow occurs here
LL | p.use_ref(); LL | p.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error[E0506]: cannot assign to `f.foo` because it is borrowed error[E0506]: cannot assign to `f.foo` because it is borrowed
--> $DIR/borrowck-overloaded-index-autoderef.rs:71:5 --> $DIR/borrowck-overloaded-index-autoderef.rs:71:5
@ -46,7 +46,7 @@ LL | let p = &f.foo[&s];
LL | f.foo = g; LL | f.foo = g;
| ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed | ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed
LL | p.use_ref(); LL | p.use_ref();
| ----------- borrow later used here | - borrow later used here
error[E0506]: cannot assign to `*f` because it is borrowed error[E0506]: cannot assign to `*f` because it is borrowed
--> $DIR/borrowck-overloaded-index-autoderef.rs:77:5 --> $DIR/borrowck-overloaded-index-autoderef.rs:77:5
@ -56,7 +56,7 @@ LL | let p = &f.foo[&s];
LL | *f = g; LL | *f = g;
| ^^^^^^ `*f` is assigned to here but it was already borrowed | ^^^^^^ `*f` is assigned to here but it was already borrowed
LL | p.use_ref(); LL | p.use_ref();
| ----------- borrow later used here | - borrow later used here
error[E0506]: cannot assign to `f.foo` because it is borrowed error[E0506]: cannot assign to `f.foo` because it is borrowed
--> $DIR/borrowck-overloaded-index-autoderef.rs:83:5 --> $DIR/borrowck-overloaded-index-autoderef.rs:83:5
@ -66,7 +66,7 @@ LL | let p = &mut f.foo[&s];
LL | f.foo = g; LL | f.foo = g;
| ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed | ^^^^^^^^^ `f.foo` is assigned to here but it was already borrowed
LL | p.use_mut(); LL | p.use_mut();
| ----------- borrow later used here | - borrow later used here
error[E0506]: cannot assign to `*f` because it is borrowed error[E0506]: cannot assign to `*f` because it is borrowed
--> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5
@ -76,7 +76,7 @@ LL | let p = &mut f.foo[&s];
LL | *f = g; LL | *f = g;
| ^^^^^^ `*f` is assigned to here but it was already borrowed | ^^^^^^ `*f` is assigned to here but it was already borrowed
LL | p.use_mut(); LL | p.use_mut();
| ----------- borrow later used here | - borrow later used here
error: aborting due to 8 previous errors error: aborting due to 8 previous errors

View File

@ -8,7 +8,7 @@ LL | let z = &x;
| ^^ immutable borrow occurs here | ^^ immutable borrow occurs here
... ...
LL | y.use_mut(); LL | y.use_mut();
| ----------- mutable borrow later used here | - mutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21 --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21
@ -20,7 +20,7 @@ LL | let z = &mut x;
| ^^^^^^ mutable borrow occurs here | ^^^^^^ mutable borrow occurs here
... ...
LL | y.use_ref(); LL | y.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error[E0499]: cannot borrow `x` as mutable more than once at a time error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17 --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17
@ -32,7 +32,7 @@ LL | let z = &mut x;
| ^^^^^^ second mutable borrow occurs here | ^^^^^^ second mutable borrow occurs here
... ...
LL | y.use_mut(); LL | y.use_mut();
| ----------- first borrow later used here | - first borrow later used here
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@ -7,7 +7,7 @@ LL | swap(&mut t0, &mut t1);
| ^^^^^^^ mutable borrow occurs here | ^^^^^^^ mutable borrow occurs here
LL | *t1 = 22; LL | *t1 = 22;
LL | p.use_ref(); LL | p.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -6,7 +6,7 @@ LL | let ra = &mut u.s.a;
LL | let b = u.c; LL | let b = u.c;
| ^^^ use of borrowed `u.s.a` | ^^^ use of borrowed `u.s.a`
LL | ra.use_mut(); LL | ra.use_mut();
| ------------ borrow later used here | -- borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -6,7 +6,7 @@ LL | let w = &mut v;
LL | borrow(&*v); LL | borrow(&*v);
| ^^^ immutable borrow occurs here | ^^^ immutable borrow occurs here
LL | w.use_mut(); LL | w.use_mut();
| ----------- mutable borrow later used here | - mutable borrow later used here
error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-uniq-via-lend.rs:53:12 --> $DIR/borrowck-uniq-via-lend.rs:53:12
@ -16,7 +16,7 @@ LL | x = &mut v;
LL | borrow(&*v); LL | borrow(&*v);
| ^^^ immutable borrow occurs here | ^^^ immutable borrow occurs here
LL | x.use_mut(); LL | x.use_mut();
| ----------- mutable borrow later used here | - mutable borrow later used here
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -5,9 +5,8 @@ LL | let vb: &mut [isize] = &mut v;
| ------ first mutable borrow occurs here | ------ first mutable borrow occurs here
... ...
LL | v.push(tail[0] + tail[1]); LL | v.push(tail[0] + tail[1]);
| ^^^^^^^-------^^^^^^^^^^^ | ^ ------- first borrow later used here
| | | | |
| | first borrow later used here
| second mutable borrow occurs here | second mutable borrow occurs here
error: aborting due to previous error error: aborting due to previous error

View File

@ -8,7 +8,7 @@ LL | vec[0] = Box::new(4);
| ^^^^^^ `vec[_]` is assigned to here but it was already borrowed | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed
LL | LL |
LL | _a.use_ref(); LL | _a.use_ref();
| ------------ borrow later used here | -- borrow later used here
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:23:13 --> $DIR/borrowck-vec-pattern-nesting.rs:23:13
@ -20,7 +20,7 @@ LL | vec[0] = Box::new(4);
| ^^^^^^ `vec[_]` is assigned to here but it was already borrowed | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed
LL | LL |
LL | _b.use_ref(); LL | _b.use_ref();
| ------------ borrow later used here | -- borrow later used here
error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice
--> $DIR/borrowck-vec-pattern-nesting.rs:34:11 --> $DIR/borrowck-vec-pattern-nesting.rs:34:11

View File

@ -0,0 +1,11 @@
// run-rustfix
#[derive(Clone)]
struct Foo;
impl Foo {
fn foo(self) {}
}
fn main() {
let foo = &Foo;
(*foo).clone().foo(); //~ ERROR cannot move out
}

View File

@ -0,0 +1,11 @@
// run-rustfix
#[derive(Clone)]
struct Foo;
impl Foo {
fn foo(self) {}
}
fn main() {
let foo = &Foo;
(*foo).foo(); //~ ERROR cannot move out
}

View File

@ -0,0 +1,21 @@
error[E0507]: cannot move out of `*foo` which is behind a shared reference
--> $DIR/clone-span-on-try-operator.rs:10:5
|
LL | (*foo).foo();
| ^^^^^^ ----- `*foo` moved due to this method call
| |
| move occurs because `*foo` has type `Foo`, which does not implement the `Copy` trait
|
note: `Foo::foo` takes ownership of the receiver `self`, which moves `*foo`
--> $DIR/clone-span-on-try-operator.rs:6:12
|
LL | fn foo(self) {}
| ^^^^
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
LL | (*foo).clone().foo();
| ++++++++
error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.

View File

@ -5,7 +5,7 @@ LL | let helpers = [vec![], vec![]];
| ------- move occurs because `helpers` has type `[Vec<&i64>; 2]`, which does not implement the `Copy` trait | ------- move occurs because `helpers` has type `[Vec<&i64>; 2]`, which does not implement the `Copy` trait
LL | LL |
LL | HelperStruct { helpers, is_empty: helpers[0].is_empty() } LL | HelperStruct { helpers, is_empty: helpers[0].is_empty() }
| ------- ^^^^^^^^^^^^^^^^^^^^^ value borrowed here after move | ------- ^^^^^^^^^^ value borrowed here after move
| | | |
| value moved here | value moved here

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow data in a `&` reference as mutable
--> $DIR/index-mut-help-with-impl.rs:9:5 --> $DIR/index-mut-help-with-impl.rs:9:5
| |
LL | Index::index(&v, 1..2).make_ascii_uppercase(); LL | Index::index(&v, 1..2).make_ascii_uppercase();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,13 +2,10 @@ error[E0596]: cannot borrow data in an index of `HashMap<&str, String>` as mutab
--> $DIR/index-mut-help.rs:10:5 --> $DIR/index-mut-help.rs:10:5
| |
LL | map["peter"].clear(); LL | map["peter"].clear();
| ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^^^^^^^^^ cannot borrow as mutable
| |
= help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>` = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>`
help: to modify a `HashMap<&str, String>` use `.get_mut()` = help: to modify a `HashMap<&str, String>`, use `.get_mut()`, `.insert()` or the entry API
|
LL | map.get_mut("peter").map(|val| val.clear());
| ~~~~~~~~~ ~~~~~~~~~~~~~~~ +
error[E0594]: cannot assign to data in an index of `HashMap<&str, String>` error[E0594]: cannot assign to data in an index of `HashMap<&str, String>`
--> $DIR/index-mut-help.rs:11:5 --> $DIR/index-mut-help.rs:11:5

View File

@ -26,9 +26,8 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time
--> $DIR/issue-109271-pass-self-into-closure.rs:21:12 --> $DIR/issue-109271-pass-self-into-closure.rs:21:12
| |
LL | v.call(|(), this: &mut S| v.set()); LL | v.call(|(), this: &mut S| v.set());
| -------^^^^^^^^^^^^^^^^^^--------- | - ---- ^^^^^^^^^^^^^^^^^^ - second borrow occurs due to use of `v` in closure
| | | | | | | | |
| | | | second borrow occurs due to use of `v` in closure
| | | second mutable borrow occurs here | | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
@ -66,18 +65,11 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time
LL | v.call(|(), this: &mut S| { LL | v.call(|(), this: &mut S| {
| - ---- ^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here | - ---- ^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | |
| _____| first borrow later used by call | | first borrow later used by call
| | | first mutable borrow occurs here
LL | | ...
LL | | LL | v.set();
LL | | | - second borrow occurs due to use of `v` in closure
LL | | _ = v;
LL | | v.set();
| | - second borrow occurs due to use of `v` in closure
... |
LL | | _ = v.add(3);
LL | | });
| |______- first mutable borrow occurs here
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable stati
--> $DIR/issue-42344.rs:4:5 --> $DIR/issue-42344.rs:4:5
| |
LL | TAB[0].iter_mut(); LL | TAB[0].iter_mut();
| ^^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^^^ cannot borrow as mutable
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,7 +2,7 @@ error[E0502]: cannot borrow `heap` as immutable because it is also borrowed as m
--> $DIR/issue-47646.rs:9:30 --> $DIR/issue-47646.rs:9:30
| |
LL | let borrow = heap.peek_mut(); LL | let borrow = heap.peek_mut();
| --------------- mutable borrow occurs here | ---- mutable borrow occurs here
LL | LL |
LL | match (borrow, ()) { LL | match (borrow, ()) {
| ------------ a temporary with access to the mutable borrow is created here ... | ------------ a temporary with access to the mutable borrow is created here ...

View File

@ -4,7 +4,7 @@ error[E0499]: cannot borrow `*bar` as mutable more than once at a time
LL | Some(baz) => { LL | Some(baz) => {
| --- first mutable borrow occurs here | --- first mutable borrow occurs here
LL | bar.take(); LL | bar.take();
| ^^^^^^^^^^ second mutable borrow occurs here | ^^^ second mutable borrow occurs here
LL | drop(baz); LL | drop(baz);
| --- first borrow later used here | --- first borrow later used here

View File

@ -2,7 +2,7 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed
--> $DIR/issue-81365-10.rs:21:9 --> $DIR/issue-81365-10.rs:21:9
| |
LL | let first = &self.deref().target_field; LL | let first = &self.deref().target_field;
| ------------ `self.container_field` is borrowed here | ---- `self.container_field` is borrowed here
LL | self.container_field = true; LL | self.container_field = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed
LL | first; LL | first;

View File

@ -2,7 +2,7 @@ error[E0506]: cannot assign to `self.container_field` because it is borrowed
--> $DIR/issue-81365-5.rs:28:9 --> $DIR/issue-81365-5.rs:28:9
| |
LL | let first = self.get(); LL | let first = self.get();
| ---------- `self.container_field` is borrowed here | ---- `self.container_field` is borrowed here
LL | self.container_field = true; LL | self.container_field = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self.container_field` is assigned to here but it was already borrowed
LL | first; LL | first;

View File

@ -7,7 +7,7 @@ LL | for v in self.0.values() {
| | help: use mutable method: `values_mut()` | | help: use mutable method: `values_mut()`
| this iterator yields `&` references | this iterator yields `&` references
LL | v.flush(); LL | v.flush();
| ^^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^ `v` is a `&` reference, so the data it refers to cannot be borrowed as mutable
error: aborting due to previous error error: aborting due to previous error

View File

@ -7,7 +7,7 @@ LL | match heap.peek_mut() {
| first mutable borrow occurs here | first mutable borrow occurs here
| a temporary with access to the first borrow is created here ... | a temporary with access to the first borrow is created here ...
LL | Some(_) => { heap.pop(); }, LL | Some(_) => { heap.pop(); },
| ^^^^^^^^^^ second mutable borrow occurs here | ^^^^ second mutable borrow occurs here
... ...
LL | } LL | }
| - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<PeekMut<'_, i32>>` | - ... and the first borrow might be used here, when that temporary is dropped and runs the destructor for type `Option<PeekMut<'_, i32>>`

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference
--> $DIR/issue-85765.rs:5:5 --> $DIR/issue-85765.rs:5:5
| |
LL | rofl.push(Vec::new()); LL | rofl.push(Vec::new());
| ^^^^^^^^^^^^^^^^^^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| |
help: consider changing this binding's type help: consider changing this binding's type
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference
--> $DIR/issue-91206.rs:13:5 --> $DIR/issue-91206.rs:13:5
| |
LL | inner.clear(); LL | inner.clear();
| ^^^^^^^^^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| |
help: consider specifying this binding's type help: consider specifying this binding's type
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
--> $DIR/issue-93078.rs:11:9 --> $DIR/issue-93078.rs:11:9
| |
LL | self.modify(); LL | self.modify();
| ^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^ cannot borrow as mutable
| |
= note: as `Self` may be unsized, this call attempts to take `&mut &mut self` = note: as `Self` may be unsized, this call attempts to take `&mut &mut self`
= note: however, `&mut self` expands to `self: &mut Self`, therefore `self` cannot be borrowed mutably = note: however, `&mut self` expands to `self: &mut Self`, therefore `self` cannot be borrowed mutably

View File

@ -4,23 +4,23 @@ error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
LL | let v = Vec::new(); LL | let v = Vec::new();
| ^ not mutable | ^ not mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
LL | v.push(0); LL | v.push(0);
| --------- cannot borrow as mutable | - cannot borrow as mutable
| |
= note: ...and 5 other attempted mutable borrows = note: ...and 5 other attempted mutable borrows
help: consider changing this to be mutable help: consider changing this to be mutable

View File

@ -47,7 +47,7 @@ error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
--> $DIR/mut-borrow-of-mut-ref.rs:34:5 --> $DIR/mut-borrow-of-mut-ref.rs:34:5
| |
LL | f.bar(); LL | f.bar();
| ^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
| |
help: consider making the binding mutable help: consider making the binding mutable
| |

View File

@ -6,7 +6,7 @@ LL | let first = &mut void;
LL | let second = &mut void; LL | let second = &mut void;
| ^^^^^^^^^ second mutable borrow occurs here | ^^^^^^^^^ second mutable borrow occurs here
LL | first.use_mut(); LL | first.use_mut();
| --------------- first borrow later used here | ----- first borrow later used here
error[E0499]: cannot borrow `inner_void` as mutable more than once at a time error[E0499]: cannot borrow `inner_void` as mutable more than once at a time
--> $DIR/mut-borrow-outside-loop.rs:15:28 --> $DIR/mut-borrow-outside-loop.rs:15:28
@ -17,7 +17,7 @@ LL | let inner_second = &mut inner_void;
| ^^^^^^^^^^^^^^^ second mutable borrow occurs here | ^^^^^^^^^^^^^^^ second mutable borrow occurs here
LL | inner_second.use_mut(); LL | inner_second.use_mut();
LL | inner_first.use_mut(); LL | inner_first.use_mut();
| --------------------- first borrow later used here | ----------- first borrow later used here
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -2,9 +2,8 @@ error[E0507]: cannot move out of `*cb` which is behind a mutable reference
--> $DIR/suggest-as-ref-on-mut-closure.rs:7:5 --> $DIR/suggest-as-ref-on-mut-closure.rs:7:5
| |
LL | cb.map(|cb| cb()); LL | cb.map(|cb| cb());
| ^^^-------------- | ^^ -------------- `*cb` moved due to this method call
| | | | |
| | `*cb` moved due to this method call
| help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents | help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
| move occurs because `*cb` has type `Option<&mut dyn FnMut()>`, which does not implement the `Copy` trait | move occurs because `*cb` has type `Option<&mut dyn FnMut()>`, which does not implement the `Copy` trait
| |

View File

@ -2,9 +2,8 @@ error[E0499]: cannot borrow `*self` as mutable more than once at a time
--> $DIR/suggest-local-var-double-mut.rs:12:22 --> $DIR/suggest-local-var-double-mut.rs:12:22
| |
LL | self.foo(self.bar()); LL | self.foo(self.bar());
| ---------^^^^^^^^^^- | ---- --- ^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
| |

View File

@ -2,7 +2,7 @@ error[E0502]: cannot borrow `vec` as immutable because it is also borrowed as mu
--> $DIR/suggest-local-var-for-vector.rs:3:9 --> $DIR/suggest-local-var-for-vector.rs:3:9
| |
LL | vec[vec.len() - 1] = 123; LL | vec[vec.len() - 1] = 123;
| ----^^^^^^^^^----- | ----^^^-----------
| | | | | |
| | immutable borrow occurs here | | immutable borrow occurs here
| mutable borrow occurs here | mutable borrow occurs here

View File

@ -2,9 +2,8 @@ error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as im
--> $DIR/suggest-local-var-imm-and-mut.rs:12:22 --> $DIR/suggest-local-var-imm-and-mut.rs:12:22
| |
LL | self.foo(self.bar()); LL | self.foo(self.bar());
| ---------^^^^^^^^^^- | ---- --- ^^^^^^^^^^ mutable borrow occurs here
| | | | | | |
| | | mutable borrow occurs here
| | immutable borrow later used by call | | immutable borrow later used by call
| immutable borrow occurs here | immutable borrow occurs here

View File

@ -2,7 +2,7 @@ error[E0502]: cannot borrow `vec` as immutable because it is also borrowed as mu
--> $DIR/suggest-storing-local-var-for-vector.rs:3:9 --> $DIR/suggest-storing-local-var-for-vector.rs:3:9
| |
LL | vec[vec.len() - 1] = 123; LL | vec[vec.len() - 1] = 123;
| ----^^^^^^^^^----- | ----^^^-----------
| | | | | |
| | immutable borrow occurs here | | immutable borrow occurs here
| mutable borrow occurs here | mutable borrow occurs here

View File

@ -2,9 +2,8 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time
--> $DIR/two-phase-across-loop.rs:17:22 --> $DIR/two-phase-across-loop.rs:17:22
| |
LL | strings.push(foo.get_string()); LL | strings.push(foo.get_string());
| -------------^^^^^^^^^^^^^^^^- | ------- ^^^ `foo` was mutably borrowed here in the previous iteration of the loop
| | | | |
| | `foo` was mutably borrowed here in the previous iteration of the loop
| first borrow used here, in later iteration of loop | first borrow used here, in later iteration of loop
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,17 +2,12 @@ error[E0502]: cannot borrow `vec` as mutable because it is also borrowed as immu
--> $DIR/two-phase-cannot-nest-mut-self-calls.rs:14:9 --> $DIR/two-phase-cannot-nest-mut-self-calls.rs:14:9
| |
LL | vec.get({ LL | vec.get({
| - --- immutable borrow later used by call | --- --- immutable borrow later used by call
| _____|
| | | |
LL | | | immutable borrow occurs here
LL | | vec.push(2); LL |
| | ^^^^^^^^^^^ mutable borrow occurs here LL | vec.push(2);
LL | | | ^^^^^^^^^^^ mutable borrow occurs here
LL | |
LL | | 0
LL | | });
| |______- immutable borrow occurs here
error: aborting due to previous error error: aborting due to previous error

View File

@ -12,9 +12,8 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time
--> $DIR/two-phase-multi-mut.rs:11:16 --> $DIR/two-phase-multi-mut.rs:11:16
| |
LL | foo.method(&mut foo); LL | foo.method(&mut foo);
| -----------^^^^^^^^- | --- ------ ^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here

View File

@ -7,7 +7,7 @@ LL | v[0].push_str({
| first mutable borrow occurs here | first mutable borrow occurs here
LL | LL |
LL | v.push(format!("foo")); LL | v.push(format!("foo"));
| ^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here | ^ second mutable borrow occurs here
error: aborting due to previous error error: aborting due to previous error

View File

@ -13,7 +13,7 @@ error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as im
--> $DIR/two-phase-surprise-no-conflict.rs:57:17 --> $DIR/two-phase-surprise-no-conflict.rs:57:17
| |
LL | self.hash_expr(&self.cx_mut.body(eid).value); LL | self.hash_expr(&self.cx_mut.body(eid).value);
| ^^^^^---------^^---------------------^^^^^^^ | ^^^^^---------^^-----------^^^^^^^^^^^^^^^^^
| | | | | | | |
| | | immutable borrow occurs here | | | immutable borrow occurs here
| | immutable borrow later used by call | | immutable borrow later used by call
@ -23,9 +23,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:119:51 --> $DIR/two-phase-surprise-no-conflict.rs:119:51
| |
LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut)));
| ----------------------------------------------^^^^^^^^^^^^^^^^^--- | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
@ -33,9 +32,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:122:54 --> $DIR/two-phase-surprise-no-conflict.rs:122:54
| |
LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| -------------------------------------------------^^^^^^^^^^^^^^^^^--- | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
@ -43,9 +41,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:125:53 --> $DIR/two-phase-surprise-no-conflict.rs:125:53
| |
LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut)));
| ------------------------------------------------^^^^^^^^^^^^^^^^^--- | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
@ -53,9 +50,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:128:44 --> $DIR/two-phase-surprise-no-conflict.rs:128:44
| |
LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut));
| ---------------------------------------^^^^^^^^^^^^^^^^^-- | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
@ -106,9 +102,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:154:54 --> $DIR/two-phase-surprise-no-conflict.rs:154:54
| |
LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| -------------------------------------------------^^^^^^^^^^^^^^^^^--- | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
@ -129,9 +124,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:158:53 --> $DIR/two-phase-surprise-no-conflict.rs:158:53
| |
LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut)));
| ------------------------------------------------^^^^^^^^^^^^^^^^^--- | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
@ -149,9 +143,8 @@ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time
--> $DIR/two-phase-surprise-no-conflict.rs:162:44 --> $DIR/two-phase-surprise-no-conflict.rs:162:44
| |
LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut));
| ---------------------------------------^^^^^^^^^^^^^^^^^-- | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here

View File

@ -4,7 +4,7 @@ error[E0505]: cannot move out of `alloc` because it is borrowed
LL | let alloc = Alloc {}; LL | let alloc = Alloc {};
| ----- binding `alloc` declared here | ----- binding `alloc` declared here
LL | let boxed = Box::new_in(10, alloc.by_ref()); LL | let boxed = Box::new_in(10, alloc.by_ref());
| -------------- borrow of `alloc` occurs here | ----- borrow of `alloc` occurs here
LL | let theref = Box::leak(boxed); LL | let theref = Box::leak(boxed);
LL | drop(alloc); LL | drop(alloc);
| ^^^^^ move out of `alloc` occurs here | ^^^^^ move out of `alloc` occurs here

View File

@ -12,7 +12,7 @@ error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable
LL | let s = std::io::stdin(); LL | let s = std::io::stdin();
| - help: consider changing this to be mutable: `mut s` | - help: consider changing this to be mutable: `mut s`
LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^ cannot borrow as mutable
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -7,7 +7,7 @@ LL | let z = &mut x;
| ^^^^^^ second mutable borrow occurs here | ^^^^^^ second mutable borrow occurs here
LL | z.use_mut(); LL | z.use_mut();
LL | y.use_mut(); LL | y.use_mut();
| ----------- first borrow later used here | - first borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -2,9 +2,8 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time
--> $DIR/one_line.rs:3:12 --> $DIR/one_line.rs:3:12
| |
LL | v.push(v.pop().unwrap()); LL | v.push(v.pop().unwrap());
| -------^^^^^^^---------- | - ---- ^ second mutable borrow occurs here
| | | | | | |
| | | second mutable borrow occurs here
| | first borrow later used by call | | first borrow later used by call
| first mutable borrow occurs here | first mutable borrow occurs here
| |

View File

@ -2,7 +2,7 @@ error[E0381]: used binding `s` isn't initialized
--> $DIR/const-generic-default-wont-borrowck.rs:2:26 --> $DIR/const-generic-default-wont-borrowck.rs:2:26
| |
LL | let s: &'static str; s.len() LL | let s: &'static str; s.len()
| - ^^^^^^^ `*s` used here but it isn't initialized | - ^ `*s` used here but it isn't initialized
| | | |
| binding declared here but left uninitialized | binding declared here but left uninitialized
| |

View File

@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*self.0` as mutable, as it is behind a `&` referenc
--> $DIR/issue-109141.rs:6:9 --> $DIR/issue-109141.rs:6:9
| |
LL | self.0.iter_mut() LL | self.0.iter_mut()
| ^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| |
help: consider changing this to be a mutable reference help: consider changing this to be a mutable reference
| |

View File

@ -2,7 +2,7 @@ error: overly complex generic constant
--> $DIR/issue-67375.rs:7:17 --> $DIR/issue-67375.rs:7:17
| |
LL | inner: [(); { [|_: &T| {}; 0].len() }], LL | inner: [(); { [|_: &T| {}; 0].len() }],
| ^^---------------------^^ | ^^---------------^^^^^^^^
| | | |
| pointer casts are not allowed in generic constants | pointer casts are not allowed in generic constants
| |

View File

@ -11,7 +11,7 @@ error[E0658]: mutable references are not allowed in constants
--> $DIR/const_let_assign3.rs:14:5 --> $DIR/const_let_assign3.rs:14:5
| |
LL | s.foo(3); LL | s.foo(3);
| ^^^^^^^^ | ^
| |
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

View File

@ -19,9 +19,8 @@ error[E0502]: cannot borrow `self` as mutable because it is also borrowed as imm
--> $DIR/issue-34126.rs:6:18 --> $DIR/issue-34126.rs:6:18
| |
LL | self.run(&mut self); LL | self.run(&mut self);
| ---------^^^^^^^^^- | ---- --- ^^^^^^^^^ mutable borrow occurs here
| | | | | | |
| | | mutable borrow occurs here
| | immutable borrow later used by call | | immutable borrow later used by call
| immutable borrow occurs here | immutable borrow occurs here

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `f.v` as mutable, as `f` is not declared as mutable
--> $DIR/issue-35937.rs:7:5 --> $DIR/issue-35937.rs:7:5
| |
LL | f.v.push("cat".to_string()); LL | f.v.push("cat".to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` referenc
--> $DIR/issue-38147-1.rs:17:9 --> $DIR/issue-38147-1.rs:17:9
| |
LL | self.s.push('x'); LL | self.s.push('x');
| ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| |
help: consider changing this to be a mutable reference help: consider changing this to be a mutable reference
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` referenc
--> $DIR/issue-38147-2.rs:9:9 --> $DIR/issue-38147-2.rs:9:9
| |
LL | self.s.push('x'); LL | self.s.push('x');
| ^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |
@ -13,7 +13,7 @@ error[E0596]: cannot borrow `*self.longer_name` as mutable, as it is behind a `&
--> $DIR/issue-38147-2.rs:12:9 --> $DIR/issue-38147-2.rs:12:9
| |
LL | self.longer_name.push(13); LL | self.longer_name.push(13);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^^^^^^^^^^^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` referenc
--> $DIR/issue-38147-3.rs:7:9 --> $DIR/issue-38147-3.rs:7:9
| |
LL | self.s.push('x'); LL | self.s.push('x');
| ^^^^^^^^^^^^^^^^ cannot borrow as mutable | ^^^^^^ cannot borrow as mutable
| |
help: consider changing this to be mutable help: consider changing this to be mutable
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference
--> $DIR/issue-38147-4.rs:6:5 --> $DIR/issue-38147-4.rs:6:5
| |
LL | f.s.push('x'); LL | f.s.push('x');
| ^^^^^^^^^^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| |
help: consider changing this to be a mutable reference help: consider changing this to be a mutable reference
| |

View File

@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference
--> $DIR/issue-40823.rs:3:5 --> $DIR/issue-40823.rs:3:5
| |
LL | buf.iter_mut(); LL | buf.iter_mut();
| ^^^^^^^^^^^^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable | ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable
| |
help: consider changing this to be a mutable reference help: consider changing this to be a mutable reference
| |

View File

@ -4,7 +4,7 @@ error[E0505]: cannot move out of `a` because it is borrowed
LL | let a = "".to_string(); LL | let a = "".to_string();
| - binding `a` declared here | - binding `a` declared here
LL | let b: Vec<&str> = a.lines().collect(); LL | let b: Vec<&str> = a.lines().collect();
| --------- borrow of `a` occurs here | - borrow of `a` occurs here
LL | drop(a); LL | drop(a);
| ^ move out of `a` occurs here | ^ move out of `a` occurs here
LL | for s in &b { LL | for s in &b {

View File

@ -2,7 +2,7 @@ error[E0515]: cannot return value referencing local variable `raw_lines`
--> $DIR/drop-with-active-borrows-2.rs:3:5 --> $DIR/drop-with-active-borrows-2.rs:3:5
| |
LL | raw_lines.iter().map(|l| l.trim()).collect() LL | raw_lines.iter().map(|l| l.trim()).collect()
| ----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | | |
| returns a value referencing data owned by the current function | returns a value referencing data owned by the current function
| `raw_lines` is borrowed here | `raw_lines` is borrowed here

View File

@ -2,7 +2,7 @@ error[E0161]: cannot move a value of type `dyn Bar`
--> $DIR/E0161.rs:16:5 --> $DIR/E0161.rs:16:5
| |
LL | x.f(); LL | x.f();
| ^^^^^ the size of `dyn Bar` cannot be statically determined | ^ the size of `dyn Bar` cannot be statically determined
error: aborting due to previous error error: aborting due to previous error

View File

@ -7,7 +7,7 @@ LL | let mut a = &mut i;
| ^^^^^^ second mutable borrow occurs here | ^^^^^^ second mutable borrow occurs here
LL | a.use_mut(); LL | a.use_mut();
LL | x.use_mut(); LL | x.use_mut();
| ----------- first borrow later used here | - first borrow later used here
error: aborting due to previous error error: aborting due to previous error

View File

@ -6,7 +6,7 @@ LL | let ref y = a;
LL | bar(a); LL | bar(a);
| ^^^^^^ mutable borrow occurs here | ^^^^^^ mutable borrow occurs here
LL | y.use_ref(); LL | y.use_ref();
| ----------- immutable borrow later used here | - immutable borrow later used here
error: aborting due to previous error error: aborting due to previous error

Some files were not shown because too many files have changed in this diff Show More