Skip to content

Commit 6d246f0

Browse files
committed
Auto merge of #91253 - matthiaskrgr:rollup-dnlcjmr, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #91169 (Change cg_ssa's get_param to borrow the builder mutably) - #91176 (If the thread does not get the lock in the short term, yield the CPU) - #91212 (Fix ICE due to out-of-bounds statement index when reporting borrowck error) - #91225 (Fix invalid scrollbar display on source code page) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 454cc5f + a9710de commit 6d246f0

File tree

8 files changed

+58
-14
lines changed

8 files changed

+58
-14
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
447447
// check if the RHS is from desugaring
448448
let opt_assignment_rhs_span =
449449
self.body.find_assignments(local).first().map(|&location| {
450-
let stmt = &self.body[location.block].statements
451-
[location.statement_index];
452-
match stmt.kind {
453-
mir::StatementKind::Assign(box (
454-
_,
455-
mir::Rvalue::Use(mir::Operand::Copy(place)),
456-
)) => {
457-
self.body.local_decls[place.local].source_info.span
458-
}
459-
_ => self.body.source_info(location).span,
450+
if let Some(mir::Statement {
451+
source_info: _,
452+
kind:
453+
mir::StatementKind::Assign(box (
454+
_,
455+
mir::Rvalue::Use(mir::Operand::Copy(place)),
456+
)),
457+
}) = self.body[location.block]
458+
.statements
459+
.get(location.statement_index)
460+
{
461+
self.body.local_decls[place.local].source_info.span
462+
} else {
463+
self.body.source_info(location).span
460464
}
461465
});
462466
match opt_assignment_rhs_span.and_then(|s| s.desugaring_kind()) {

Diff for: compiler/rustc_codegen_gcc/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl<'a, 'gcc, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
1414
// TODO(antoyo)
1515
}
1616

17-
fn get_param(&self, index: usize) -> Self::Value {
17+
fn get_param(&mut self, index: usize) -> Self::Value {
1818
self.cx.current_func.borrow().expect("current func")
1919
.get_param(index as i32)
2020
.to_rvalue()

Diff for: compiler/rustc_codegen_llvm/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
607607
fn_abi.apply_attrs_callsite(self, callsite)
608608
}
609609

610-
fn get_param(&self, index: usize) -> Self::Value {
610+
fn get_param(&mut self, index: usize) -> Self::Value {
611611
llvm::get_param(self.llfn(), index as c_uint)
612612
}
613613
}

Diff for: compiler/rustc_codegen_ssa/src/traits/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ use rustc_target::abi::call::FnAbi;
44

55
pub trait AbiBuilderMethods<'tcx>: BackendTypes {
66
fn apply_attrs_callsite(&mut self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, callsite: Self::Value);
7-
fn get_param(&self, index: usize) -> Self::Value;
7+
fn get_param(&mut self, index: usize) -> Self::Value;
88
}

Diff for: library/std/src/sys/hermit/mutex.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,17 @@ impl<T> Spinlock<T> {
4646
#[inline]
4747
fn obtain_lock(&self) {
4848
let ticket = self.queue.fetch_add(1, Ordering::SeqCst) + 1;
49+
let mut counter: u16 = 0;
4950
while self.dequeue.load(Ordering::SeqCst) != ticket {
50-
hint::spin_loop();
51+
counter += 1;
52+
if counter < 100 {
53+
hint::spin_loop();
54+
} else {
55+
counter = 0;
56+
unsafe {
57+
abi::yield_now();
58+
}
59+
}
5160
}
5261
}
5362

Diff for: src/librustdoc/html/static/css/rustdoc.css

+4
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ nav.sub {
305305
overflow-y: scroll;
306306
}
307307

308+
.rustdoc.source .sidebar {
309+
overflow-y: auto;
310+
}
311+
308312
/* Improve the scrollbar display on firefox */
309313
* {
310314
scrollbar-width: initial;

Diff for: src/test/ui/borrowck/issue-91206.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct TestClient;
2+
3+
impl TestClient {
4+
fn get_inner_ref(&self) -> &Vec<usize> {
5+
todo!()
6+
}
7+
}
8+
9+
fn main() {
10+
let client = TestClient;
11+
let inner = client.get_inner_ref();
12+
//~^ HELP consider changing this to be a mutable reference
13+
inner.clear();
14+
//~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596]
15+
}

Diff for: src/test/ui/borrowck/issue-91206.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference
2+
--> $DIR/issue-91206.rs:13:5
3+
|
4+
LL | let inner = client.get_inner_ref();
5+
| ----- help: consider changing this to be a mutable reference: `&mut Vec<usize>`
6+
LL |
7+
LL | inner.clear();
8+
| ^^^^^^^^^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0596`.

0 commit comments

Comments
 (0)