Skip to content

Commit

Permalink
Auto merge of rust-lang#2979 - rust-lang:rustup2023-07-13, r=RalfJung
Browse files Browse the repository at this point in the history
Automatic sync from rustc
  • Loading branch information
bors committed Jul 13, 2023
2 parents 5085fe3 + 461baf2 commit ad9b7b5
Show file tree
Hide file tree
Showing 176 changed files with 449 additions and 480 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
err.eager_subdiagnostic(
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
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()
Expand All @@ -1135,10 +1135,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&& self.infcx.predicate_must_hold_modulo_regions(&o)
{
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 \
your desired behavior",
"clone().".to_string(),
".clone()".to_string(),
Applicability::MaybeIncorrect,
);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ pub(crate) enum CaptureReasonSuggest<'tcx> {
#[suggestion(
borrowck_suggest_create_freash_reborrow,
applicability = "maybe-incorrect",
code = "as_mut().",
code = ".as_mut()",
style = "verbose"
)]
FreshReborrow {
Expand Down
19 changes: 1 addition & 18 deletions compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,14 @@ impl<'tcx> Cx<'tcx> {

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);

// Now apply adjustments, if any.
if self.apply_adjustments {
for adjustment in self.typeck_results.expr_adjustments(hir_expr) {
trace!(?expr, ?adjustment);
let span = expr.span;
expr = self.apply_adjustment(
hir_expr,
expr,
adjustment,
adjustment_span.unwrap_or(span),
);
expr = self.apply_adjustment(hir_expr, expr, adjustment, span);
}
}

Expand Down Expand Up @@ -274,7 +264,6 @@ impl<'tcx> Cx<'tcx> {
fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> {
let tcx = self.tcx;
let expr_ty = self.typeck_results().expr_ty(expr);
let expr_span = expr.span;
let temp_lifetime =
self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id);

Expand All @@ -283,17 +272,11 @@ impl<'tcx> Cx<'tcx> {
hir::ExprKind::MethodCall(segment, receiver, ref args, fn_span) => {
// Rewrite a.b(c) into UFCS form like Trait::b(a, c)
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);
let args = std::iter::once(receiver)
.chain(args.iter())
.map(|expr| self.mirror_expr(expr))
.collect();
self.adjustment_span = old_adjustment_span;
ExprKind::Call {
ty: expr.ty,
fun: self.thir.exprs.push(expr),
Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_mir_build/src/thir/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use rustc_hir::Node;
use rustc_middle::middle::region;
use rustc_middle::thir::*;
use rustc_middle::ty::{self, RvalueScopes, Ty, TyCtxt};
use rustc_span::Span;

pub(crate) fn thir_body(
tcx: TyCtxt<'_>,
Expand Down Expand Up @@ -62,14 +61,6 @@ struct Cx<'tcx> {
typeck_results: &'tcx ty::TypeckResults<'tcx>,
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`
apply_adjustments: bool,

Expand Down Expand Up @@ -110,7 +101,6 @@ impl<'tcx> Cx<'tcx> {
typeck_results,
rvalue_scopes: &typeck_results.rvalue_scopes,
body_owner: def.to_def_id(),
adjustment_span: None,
apply_adjustments: hir
.attrs(hir_id)
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Config {
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) {
Expand Down
11 changes: 5 additions & 6 deletions src/bootstrap/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ impl Step for ExpandYamlAnchors {
try_run(
builder,
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
)
.unwrap();
);
}

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand All @@ -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 let Err(e) = builder.try_run(cmd) {
if builder.try_run(cmd).is_err() {
let mut failures = builder.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd));
return Err(e);
return false;
}
} else {
builder.run(cmd);
}
Ok(())
true
}

#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down
36 changes: 16 additions & 20 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ const MIR_OPT_BLESS_TARGET_MAPPING: &[(&str, &str)] = &[
// 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 let Err(e) = builder.try_run(cmd) {
if builder.try_run(cmd).is_err() {
let mut failures = builder.delayed_failures.borrow_mut();
failures.push(format!("{:?}", cmd));
return Err(e);
return false;
}
} else {
builder.run(cmd);
}
Ok(())
true
}

fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool {
Expand Down Expand Up @@ -187,8 +187,7 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
try_run(
builder,
builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")),
)
.unwrap();
);
}

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand Down Expand Up @@ -241,8 +240,7 @@ impl Step for HtmlCheck {
builder.default_doc(&[]);
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)))
.unwrap();
try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
}
}

Expand Down Expand Up @@ -288,8 +286,7 @@ impl Step for Cargotest {
.args(builder.config.test_args())
.env("RUSTC", builder.rustc(compiler))
.env("RUSTDOC", builder.rustdoc(compiler)),
)
.unwrap();
);
}
}

Expand Down Expand Up @@ -855,7 +852,7 @@ impl Step for RustdocTheme {
util::lld_flag_no_threads(self.compiler.host.contains("windows")),
);
}
try_run(builder, &mut cmd).unwrap();
try_run(builder, &mut cmd);
}
}

Expand Down Expand Up @@ -1106,7 +1103,7 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy`
}

builder.info("tidy check");
try_run(builder, &mut cmd).unwrap();
try_run(builder, &mut cmd);

builder.ensure(ExpandYamlAnchors);

Expand Down Expand Up @@ -1154,8 +1151,7 @@ impl Step for ExpandYamlAnchors {
try_run(
builder,
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
)
.unwrap();
);
}

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand Down Expand Up @@ -1948,7 +1944,7 @@ impl BookTest {
compiler.host,
);
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
} else {
ToolState::TestFail
Expand Down Expand Up @@ -2106,7 +2102,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
cmd.arg("--test-args").arg(test_args);

if builder.config.verbose_tests {
try_run(builder, &mut cmd).is_ok()
try_run(builder, &mut cmd)
} else {
try_run_quiet(builder, &mut cmd)
}
Expand Down Expand Up @@ -2134,7 +2130,7 @@ impl Step for RustcGuide {

let src = builder.src.join(relative_path);
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
} else {
ToolState::TestFail
Expand Down Expand Up @@ -2684,7 +2680,7 @@ impl Step for 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.
// 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 compiler = builder.compiler(0, host);
Expand Down Expand Up @@ -2756,7 +2752,7 @@ impl Step for TierCheck {
}

builder.info("platform support check");
try_run(builder, &mut cargo.into()).unwrap();
try_run(builder, &mut cargo.into());
}
}

Expand Down Expand Up @@ -2836,7 +2832,7 @@ impl Step for RustInstaller {
cmd.env("CARGO", &builder.initial_cargo);
cmd.env("RUSTC", &builder.initial_rustc);
cmd.env("TMP_DIR", &tmpdir);
try_run(builder, &mut cmd).unwrap();
try_run(builder, &mut cmd);
}

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
136dab66142115d9de16b4cfe2d8395d71a8ab6d
33a2c2487ac5d9927830ea4c1844335c6b9f77db
2 changes: 1 addition & 1 deletion src/tools/miri/tests/fail/box-cell-alias.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/box-cell-alias.rs:LL:CC
|
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
| this error occurs as part of retag at ALLOC[0x0..0x1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/illegal_read7.rs:LL:CC
|
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
| this error occurs as part of two-phase retag at ALLOC[0x0..0x4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/interior_mut1.rs:LL:CC
|
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
| this error occurs as part of retag at ALLOC[0x0..0x4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/interior_mut2.rs:LL:CC
|
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
| this error occurs as part of retag at ALLOC[0x0..0x4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
--> $DIR/shared_rw_borrows_are_weak1.rs:LL:CC
|
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
| this error occurs as part of two-phase retag at ALLOC[0x0..0x4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ help: the accessed tag <TAG> later transitioned to Frozen due to a reborrow (act
--> $DIR/fnentry_invalidation.rs:LL:CC
|
LL | x.do_bad();
| ^^^^^^^^^^
| ^
= help: this transition corresponds to a loss of write permissions
= note: BACKTRACE (of the first span):
= note: inside `main` at $DIR/fnentry_invalidation.rs:LL:CC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,8 @@ LL | fn add(&mut self, n: u64) -> u64 {
help: the accessed tag <TAG> was created here, in the initial state Reserved
--> $DIR/write-during-2phase.rs:LL:CC
|
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 | | });
| |______^
LL | let _res = f.add(unsafe {
| ^
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
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/array-slice-vec/vec-mut-iter-borrow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | for x in &mut xs {
| first mutable borrow occurs here
| first borrow later used here
LL | xs.push(1)
| ^^^^^^^^^^ second mutable borrow occurs here
| ^^ second mutable borrow occurs here

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/async-await/clone-suggestion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ note: `into_future` takes ownership of the receiver `self`, which moves `f`
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
LL | f.clone().await;
| ++++++++
| ++++++++

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/async-await/issue-61452.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
--> $DIR/issue-61452.rs:4:5
|
LL | x.take();
| ^^^^^^^^ cannot borrow as mutable
| ^ cannot borrow as mutable
|
help: consider changing this to be mutable
|
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/async-await/issues/issue-61187.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0596]: cannot borrow `data` as mutable, as it is not declared as mutable
--> $DIR/issue-61187.rs:6:5
|
LL | data.reverse();
| ^^^^^^^^^^^^^^ cannot borrow as mutable
| ^^^^ cannot borrow as mutable
|
help: consider changing this to be mutable
|
Expand Down
Loading

0 comments on commit ad9b7b5

Please sign in to comment.