Skip to content

Commit ad9b7b5

Browse files
committed
Auto merge of #2979 - rust-lang:rustup2023-07-13, r=RalfJung
Automatic sync from rustc
2 parents 5085fe3 + 461baf2 commit ad9b7b5

File tree

176 files changed

+449
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+449
-480
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11211121
err.eager_subdiagnostic(
11221122
&self.infcx.tcx.sess.parse_sess.span_diagnostic,
11231123
CaptureReasonSuggest::FreshReborrow {
1124-
span: fn_call_span.shrink_to_lo(),
1124+
span: move_span.shrink_to_hi(),
11251125
});
11261126
}
11271127
if let Some(clone_trait) = tcx.lang_items().clone_trait()
@@ -1135,10 +1135,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11351135
&& self.infcx.predicate_must_hold_modulo_regions(&o)
11361136
{
11371137
err.span_suggestion_verbose(
1138-
fn_call_span.shrink_to_lo(),
1138+
move_span.shrink_to_hi(),
11391139
"you can `clone` the value and consume it, but this might not be \
11401140
your desired behavior",
1141-
"clone().".to_string(),
1141+
".clone()".to_string(),
11421142
Applicability::MaybeIncorrect,
11431143
);
11441144
}

compiler/rustc_borrowck/src/session_diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ pub(crate) enum CaptureReasonSuggest<'tcx> {
398398
#[suggestion(
399399
borrowck_suggest_create_freash_reborrow,
400400
applicability = "maybe-incorrect",
401-
code = "as_mut().",
401+
code = ".as_mut()",
402402
style = "verbose"
403403
)]
404404
FreshReborrow {

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,14 @@ impl<'tcx> Cx<'tcx> {
4141

4242
let mut expr = self.make_mirror_unadjusted(hir_expr);
4343

44-
let adjustment_span = match self.adjustment_span {
45-
Some((hir_id, span)) if hir_id == hir_expr.hir_id => Some(span),
46-
_ => None,
47-
};
48-
4944
trace!(?expr.ty);
5045

5146
// Now apply adjustments, if any.
5247
if self.apply_adjustments {
5348
for adjustment in self.typeck_results.expr_adjustments(hir_expr) {
5449
trace!(?expr, ?adjustment);
5550
let span = expr.span;
56-
expr = self.apply_adjustment(
57-
hir_expr,
58-
expr,
59-
adjustment,
60-
adjustment_span.unwrap_or(span),
61-
);
51+
expr = self.apply_adjustment(hir_expr, expr, adjustment, span);
6252
}
6353
}
6454

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

@@ -283,17 +272,11 @@ impl<'tcx> Cx<'tcx> {
283272
hir::ExprKind::MethodCall(segment, receiver, ref args, fn_span) => {
284273
// Rewrite a.b(c) into UFCS form like Trait::b(a, c)
285274
let expr = self.method_callee(expr, segment.ident.span, None);
286-
// When we apply adjustments to the receiver, use the span of
287-
// the overall method call for better diagnostics. args[0]
288-
// is guaranteed to exist, since a method call always has a receiver.
289-
let old_adjustment_span =
290-
self.adjustment_span.replace((receiver.hir_id, expr_span));
291275
info!("Using method span: {:?}", expr.span);
292276
let args = std::iter::once(receiver)
293277
.chain(args.iter())
294278
.map(|expr| self.mirror_expr(expr))
295279
.collect();
296-
self.adjustment_span = old_adjustment_span;
297280
ExprKind::Call {
298281
ty: expr.ty,
299282
fun: self.thir.exprs.push(expr),

compiler/rustc_mir_build/src/thir/cx/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rustc_hir::Node;
1616
use rustc_middle::middle::region;
1717
use rustc_middle::thir::*;
1818
use rustc_middle::ty::{self, RvalueScopes, Ty, TyCtxt};
19-
use rustc_span::Span;
2019

2120
pub(crate) fn thir_body(
2221
tcx: TyCtxt<'_>,
@@ -62,14 +61,6 @@ struct Cx<'tcx> {
6261
typeck_results: &'tcx ty::TypeckResults<'tcx>,
6362
rvalue_scopes: &'tcx RvalueScopes,
6463

65-
/// When applying adjustments to the expression
66-
/// with the given `HirId`, use the given `Span`,
67-
/// instead of the usual span. This is used to
68-
/// assign the span of an overall method call
69-
/// (e.g. `my_val.foo()`) to the adjustment expressions
70-
/// for the receiver.
71-
adjustment_span: Option<(HirId, Span)>,
72-
7364
/// False to indicate that adjustments should not be applied. Only used for `custom_mir`
7465
apply_adjustments: bool,
7566

@@ -110,7 +101,6 @@ impl<'tcx> Cx<'tcx> {
110101
typeck_results,
111102
rvalue_scopes: &typeck_results.rvalue_scopes,
112103
body_owner: def.to_def_id(),
113-
adjustment_span: None,
114104
apply_adjustments: hir
115105
.attrs(hir_id)
116106
.iter()

src/bootstrap/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl Config {
188188
patchelf.args(&["--set-interpreter", dynamic_linker.trim_end()]);
189189
}
190190

191-
self.try_run(patchelf.arg(fname)).unwrap();
191+
let _ = self.try_run(patchelf.arg(fname));
192192
}
193193

194194
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {

src/bootstrap/run.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ impl Step for ExpandYamlAnchors {
2727
try_run(
2828
builder,
2929
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
30-
)
31-
.unwrap();
30+
);
3231
}
3332

3433
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -40,17 +39,17 @@ impl Step for ExpandYamlAnchors {
4039
}
4140
}
4241

43-
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> {
42+
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
4443
if !builder.fail_fast {
45-
if let Err(e) = builder.try_run(cmd) {
44+
if builder.try_run(cmd).is_err() {
4645
let mut failures = builder.delayed_failures.borrow_mut();
4746
failures.push(format!("{:?}", cmd));
48-
return Err(e);
47+
return false;
4948
}
5049
} else {
5150
builder.run(cmd);
5251
}
53-
Ok(())
52+
true
5453
}
5554

5655
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]

src/bootstrap/test.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ const MIR_OPT_BLESS_TARGET_MAPPING: &[(&str, &str)] = &[
4848
// build for, so there is no entry for "aarch64-apple-darwin" here.
4949
];
5050

51-
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> Result<(), ()> {
51+
fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
5252
if !builder.fail_fast {
53-
if let Err(e) = builder.try_run(cmd) {
53+
if builder.try_run(cmd).is_err() {
5454
let mut failures = builder.delayed_failures.borrow_mut();
5555
failures.push(format!("{:?}", cmd));
56-
return Err(e);
56+
return false;
5757
}
5858
} else {
5959
builder.run(cmd);
6060
}
61-
Ok(())
61+
true
6262
}
6363

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

194193
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -241,8 +240,7 @@ impl Step for HtmlCheck {
241240
builder.default_doc(&[]);
242241
builder.ensure(crate::doc::Rustc::new(builder.top_stage, self.target, builder));
243242

244-
try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)))
245-
.unwrap();
243+
try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
246244
}
247245
}
248246

@@ -288,8 +286,7 @@ impl Step for Cargotest {
288286
.args(builder.config.test_args())
289287
.env("RUSTC", builder.rustc(compiler))
290288
.env("RUSTDOC", builder.rustdoc(compiler)),
291-
)
292-
.unwrap();
289+
);
293290
}
294291
}
295292

@@ -855,7 +852,7 @@ impl Step for RustdocTheme {
855852
util::lld_flag_no_threads(self.compiler.host.contains("windows")),
856853
);
857854
}
858-
try_run(builder, &mut cmd).unwrap();
855+
try_run(builder, &mut cmd);
859856
}
860857
}
861858

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

11081105
builder.info("tidy check");
1109-
try_run(builder, &mut cmd).unwrap();
1106+
try_run(builder, &mut cmd);
11101107

11111108
builder.ensure(ExpandYamlAnchors);
11121109

@@ -1154,8 +1151,7 @@ impl Step for ExpandYamlAnchors {
11541151
try_run(
11551152
builder,
11561153
&mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("check").arg(&builder.src),
1157-
)
1158-
.unwrap();
1154+
);
11591155
}
11601156

11611157
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1948,7 +1944,7 @@ impl BookTest {
19481944
compiler.host,
19491945
);
19501946
let _time = util::timeit(&builder);
1951-
let toolstate = if try_run(builder, &mut rustbook_cmd).is_ok() {
1947+
let toolstate = if try_run(builder, &mut rustbook_cmd) {
19521948
ToolState::TestPass
19531949
} else {
19541950
ToolState::TestFail
@@ -2106,7 +2102,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
21062102
cmd.arg("--test-args").arg(test_args);
21072103

21082104
if builder.config.verbose_tests {
2109-
try_run(builder, &mut cmd).is_ok()
2105+
try_run(builder, &mut cmd)
21102106
} else {
21112107
try_run_quiet(builder, &mut cmd)
21122108
}
@@ -2134,7 +2130,7 @@ impl Step for RustcGuide {
21342130

21352131
let src = builder.src.join(relative_path);
21362132
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
2137-
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)).is_ok() {
2133+
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
21382134
ToolState::TestPass
21392135
} else {
21402136
ToolState::TestFail
@@ -2684,7 +2680,7 @@ impl Step for Bootstrap {
26842680
.current_dir(builder.src.join("src/bootstrap/"));
26852681
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
26862682
// Use `python -m unittest` manually if you want to pass arguments.
2687-
try_run(builder, &mut check_bootstrap).unwrap();
2683+
try_run(builder, &mut check_bootstrap);
26882684

26892685
let host = builder.config.build;
26902686
let compiler = builder.compiler(0, host);
@@ -2756,7 +2752,7 @@ impl Step for TierCheck {
27562752
}
27572753

27582754
builder.info("platform support check");
2759-
try_run(builder, &mut cargo.into()).unwrap();
2755+
try_run(builder, &mut cargo.into());
27602756
}
27612757
}
27622758

@@ -2836,7 +2832,7 @@ impl Step for RustInstaller {
28362832
cmd.env("CARGO", &builder.initial_cargo);
28372833
cmd.env("RUSTC", &builder.initial_rustc);
28382834
cmd.env("TMP_DIR", &tmpdir);
2839-
try_run(builder, &mut cmd).unwrap();
2835+
try_run(builder, &mut cmd);
28402836
}
28412837

28422838
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

src/tools/miri/rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
136dab66142115d9de16b4cfe2d8395d71a8ab6d
1+
33a2c2487ac5d9927830ea4c1844335c6b9f77db

src/tools/miri/tests/fail/box-cell-alias.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
22
--> $DIR/box-cell-alias.rs:LL:CC
33
|
44
LL | unsafe { (*ptr).set(20) };
5-
| ^^^^^^^^^^^^^^
5+
| ^^^^^^
66
| |
77
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
88
| this error occurs as part of retag at ALLOC[0x0..0x1]

src/tools/miri/tests/fail/stacked_borrows/illegal_read7.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
22
--> $DIR/illegal_read7.rs:LL:CC
33
|
44
LL | let _val = *x.get_mut();
5-
| ^^^^^^^^^^^
5+
| ^
66
| |
77
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
88
| this error occurs as part of two-phase retag at ALLOC[0x0..0x4]

src/tools/miri/tests/fail/stacked_borrows/interior_mut1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
22
--> $DIR/interior_mut1.rs:LL:CC
33
|
44
LL | let _val = *inner_shr.get();
5-
| ^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^
66
| |
77
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
88
| this error occurs as part of retag at ALLOC[0x0..0x4]

src/tools/miri/tests/fail/stacked_borrows/interior_mut2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
22
--> $DIR/interior_mut2.rs:LL:CC
33
|
44
LL | let _val = *inner_shr.get();
5-
| ^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^
66
| |
77
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
88
| this error occurs as part of retag at ALLOC[0x0..0x4]

src/tools/miri/tests/fail/stacked_borrows/shared_rw_borrows_are_weak1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to retag from <TAG> for SharedReadWrite permis
22
--> $DIR/shared_rw_borrows_are_weak1.rs:LL:CC
33
|
44
LL | y.get_mut();
5-
| ^^^^^^^^^^^
5+
| ^
66
| |
77
| trying to retag from <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
88
| this error occurs as part of two-phase retag at ALLOC[0x0..0x4]

src/tools/miri/tests/fail/tree_borrows/fnentry_invalidation.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ help: the accessed tag <TAG> later transitioned to Frozen due to a reborrow (act
2121
--> $DIR/fnentry_invalidation.rs:LL:CC
2222
|
2323
LL | x.do_bad();
24-
| ^^^^^^^^^^
24+
| ^
2525
= help: this transition corresponds to a loss of write permissions
2626
= note: BACKTRACE (of the first span):
2727
= note: inside `main` at $DIR/fnentry_invalidation.rs:LL:CC

src/tools/miri/tests/fail/tree_borrows/write-during-2phase.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ LL | fn add(&mut self, n: u64) -> u64 {
99
help: the accessed tag <TAG> was created here, in the initial state Reserved
1010
--> $DIR/write-during-2phase.rs:LL:CC
1111
|
12-
LL | let _res = f.add(unsafe {
13-
| ________________^
14-
LL | | let n = f.0;
15-
LL | | // This is the access at fault, but it's not immediately apparent because
16-
LL | | // the reference that got invalidated is not under a Protector.
17-
LL | | *inner = 42;
18-
LL | | n
19-
LL | | });
20-
| |______^
12+
LL | let _res = f.add(unsafe {
13+
| ^
2114
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x0..0x8]
2215
--> $DIR/write-during-2phase.rs:LL:CC
2316
|

tests/ui/array-slice-vec/vec-mut-iter-borrow.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | for x in &mut xs {
77
| first mutable borrow occurs here
88
| first borrow later used here
99
LL | xs.push(1)
10-
| ^^^^^^^^^^ second mutable borrow occurs here
10+
| ^^ second mutable borrow occurs here
1111

1212
error: aborting due to previous error
1313

tests/ui/async-await/clone-suggestion.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ note: `into_future` takes ownership of the receiver `self`, which moves `f`
1313
help: you can `clone` the value and consume it, but this might not be your desired behavior
1414
|
1515
LL | f.clone().await;
16-
| ++++++++
16+
| ++++++++
1717

1818
error: aborting due to previous error
1919

tests/ui/async-await/issue-61452.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
22
--> $DIR/issue-61452.rs:4:5
33
|
44
LL | x.take();
5-
| ^^^^^^^^ cannot borrow as mutable
5+
| ^ cannot borrow as mutable
66
|
77
help: consider changing this to be mutable
88
|

tests/ui/async-await/issues/issue-61187.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0596]: cannot borrow `data` as mutable, as it is not declared as mutable
22
--> $DIR/issue-61187.rs:6:5
33
|
44
LL | data.reverse();
5-
| ^^^^^^^^^^^^^^ cannot borrow as mutable
5+
| ^^^^ cannot borrow as mutable
66
|
77
help: consider changing this to be mutable
88
|

0 commit comments

Comments
 (0)