Skip to content

Commit

Permalink
Auto merge of #91253 - matthiaskrgr:rollup-dnlcjmr, r=matthiaskrgr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Nov 26, 2021
2 parents 454cc5f + a9710de commit 6d246f0
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 14 deletions.
24 changes: 14 additions & 10 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Expand Up @@ -447,16 +447,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// check if the RHS is from desugaring
let opt_assignment_rhs_span =
self.body.find_assignments(local).first().map(|&location| {
let stmt = &self.body[location.block].statements
[location.statement_index];
match stmt.kind {
mir::StatementKind::Assign(box (
_,
mir::Rvalue::Use(mir::Operand::Copy(place)),
)) => {
self.body.local_decls[place.local].source_info.span
}
_ => self.body.source_info(location).span,
if let Some(mir::Statement {
source_info: _,
kind:
mir::StatementKind::Assign(box (
_,
mir::Rvalue::Use(mir::Operand::Copy(place)),
)),
}) = self.body[location.block]
.statements
.get(location.statement_index)
{
self.body.local_decls[place.local].source_info.span
} else {
self.body.source_info(location).span
}
});
match opt_assignment_rhs_span.and_then(|s| s.desugaring_kind()) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/abi.rs
Expand Up @@ -14,7 +14,7 @@ impl<'a, 'gcc, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
// TODO(antoyo)
}

fn get_param(&self, index: usize) -> Self::Value {
fn get_param(&mut self, index: usize) -> Self::Value {
self.cx.current_func.borrow().expect("current func")
.get_param(index as i32)
.to_rvalue()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/abi.rs
Expand Up @@ -607,7 +607,7 @@ impl AbiBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
fn_abi.apply_attrs_callsite(self, callsite)
}

fn get_param(&self, index: usize) -> Self::Value {
fn get_param(&mut self, index: usize) -> Self::Value {
llvm::get_param(self.llfn(), index as c_uint)
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/traits/abi.rs
Expand Up @@ -4,5 +4,5 @@ use rustc_target::abi::call::FnAbi;

pub trait AbiBuilderMethods<'tcx>: BackendTypes {
fn apply_attrs_callsite(&mut self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, callsite: Self::Value);
fn get_param(&self, index: usize) -> Self::Value;
fn get_param(&mut self, index: usize) -> Self::Value;
}
11 changes: 10 additions & 1 deletion library/std/src/sys/hermit/mutex.rs
Expand Up @@ -46,8 +46,17 @@ impl<T> Spinlock<T> {
#[inline]
fn obtain_lock(&self) {
let ticket = self.queue.fetch_add(1, Ordering::SeqCst) + 1;
let mut counter: u16 = 0;
while self.dequeue.load(Ordering::SeqCst) != ticket {
hint::spin_loop();
counter += 1;
if counter < 100 {
hint::spin_loop();
} else {
counter = 0;
unsafe {
abi::yield_now();
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Expand Up @@ -305,6 +305,10 @@ nav.sub {
overflow-y: scroll;
}

.rustdoc.source .sidebar {
overflow-y: auto;
}

/* Improve the scrollbar display on firefox */
* {
scrollbar-width: initial;
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/borrowck/issue-91206.rs
@@ -0,0 +1,15 @@
struct TestClient;

impl TestClient {
fn get_inner_ref(&self) -> &Vec<usize> {
todo!()
}
}

fn main() {
let client = TestClient;
let inner = client.get_inner_ref();
//~^ HELP consider changing this to be a mutable reference
inner.clear();
//~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596]
}
12 changes: 12 additions & 0 deletions src/test/ui/borrowck/issue-91206.stderr
@@ -0,0 +1,12 @@
error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference
--> $DIR/issue-91206.rs:13:5
|
LL | let inner = client.get_inner_ref();
| ----- help: consider changing this to be a mutable reference: `&mut Vec<usize>`
LL |
LL | inner.clear();
| ^^^^^^^^^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0596`.

0 comments on commit 6d246f0

Please sign in to comment.