Skip to content

Commit 1f20966

Browse files
committed
Fix CI problems
1 parent 8f5585a commit 1f20966

File tree

3 files changed

+40
-44
lines changed

3 files changed

+40
-44
lines changed

Diff for: compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs

+37-41
Original file line numberDiff line numberDiff line change
@@ -515,68 +515,64 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
515515

516516
err.buffer(&mut self.errors_buffer);
517517
}
518-
518+
519519
/// User cannot make signature of a trait mutable without changing the
520520
/// trait. So we find if this error belongs to a trait and if so we move
521-
/// suggestion to the trait or disable it if it is out of scope of this crate
521+
/// suggestion to the trait or disable it if it is out of scope of this crate
522522
fn is_error_in_trait(&self, local: Local) -> (bool, Option<Span>) {
523523
if self.body.local_kind(local) != LocalKind::Arg {
524524
return (false, None);
525525
}
526526
let hir_map = self.infcx.tcx.hir();
527527
let my_def = self.body.source.def_id();
528528
let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap());
529-
let td = if let Some(a) = self.infcx.tcx.impl_of_method(my_def).and_then(|x| {
530-
self.infcx.tcx.trait_id_of_impl(x)
531-
}) {
529+
let td = if let Some(a) =
530+
self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
531+
{
532532
a
533533
} else {
534534
return (false, None);
535535
};
536-
(true, td.as_local().and_then(|tld| {
537-
let h = hir_map.local_def_id_to_hir_id(tld);
538-
match hir_map.find(h) {
539-
Some(Node::Item(hir::Item {
540-
kind: hir::ItemKind::Trait(
541-
_, _, _, _,
542-
items
543-
),
544-
..
545-
})) => {
546-
let mut f_in_trait_opt = None;
547-
for hir::TraitItemRef { id: fi, kind: k, .. } in *items {
548-
let hi = fi.hir_id();
549-
if !matches!(k, hir::AssocItemKind::Fn { .. }) {
550-
continue;
551-
}
552-
if hir_map.name(hi) != hir_map.name(my_hir) {
553-
continue;
536+
(
537+
true,
538+
td.as_local().and_then(|tld| {
539+
let h = hir_map.local_def_id_to_hir_id(tld);
540+
match hir_map.find(h) {
541+
Some(Node::Item(hir::Item {
542+
kind: hir::ItemKind::Trait(_, _, _, _, items),
543+
..
544+
})) => {
545+
let mut f_in_trait_opt = None;
546+
for hir::TraitItemRef { id: fi, kind: k, .. } in *items {
547+
let hi = fi.hir_id();
548+
if !matches!(k, hir::AssocItemKind::Fn { .. }) {
549+
continue;
550+
}
551+
if hir_map.name(hi) != hir_map.name(my_hir) {
552+
continue;
553+
}
554+
f_in_trait_opt = Some(hi);
555+
break;
554556
}
555-
f_in_trait_opt = Some(hi);
556-
break;
557-
}
558-
f_in_trait_opt.and_then(|f_in_trait| {
559-
match hir_map.find(f_in_trait) {
557+
f_in_trait_opt.and_then(|f_in_trait| match hir_map.find(f_in_trait) {
560558
Some(Node::TraitItem(hir::TraitItem {
561-
kind: hir::TraitItemKind::Fn(hir::FnSig {
562-
decl: hir::FnDecl {
563-
inputs,
564-
..
565-
},
566-
..
567-
}, _),
559+
kind:
560+
hir::TraitItemKind::Fn(
561+
hir::FnSig { decl: hir::FnDecl { inputs, .. }, .. },
562+
_,
563+
),
568564
..
569565
})) => {
570566
let hir::Ty { span, .. } = inputs[local.index() - 1];
571567
Some(span)
572-
},
568+
}
573569
_ => None,
574-
}
575-
})
570+
})
571+
}
572+
_ => None,
576573
}
577-
_ => None
578-
}
579-
}))
574+
}),
575+
)
580576
}
581577

582578
// point to span of upvar making closure call require mutable borrow

Diff for: src/test/ui/suggestions/issue-68049-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ struct Test(u32);
44

55
unsafe impl GlobalAlloc for Test {
66
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
7-
self.0 += 1;
7+
self.0 += 1; //~ ERROR cannot assign
88
0 as *mut u8
99
}
1010

Diff for: src/test/ui/suggestions/issue-68049-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ struct Test1(i32);
66

77
impl Hello for Test1 {
88
fn example(&self, input: &i32) { // should not suggest here
9-
*input = self.0;
9+
*input = self.0; //~ ERROR cannot assign
1010
}
1111
}
1212

1313
struct Test2(i32);
1414

1515
impl Hello for Test2 {
1616
fn example(&self, input: &i32) { // should not suggest here
17-
self.0 += *input;
17+
self.0 += *input; //~ ERROR cannot assign
1818
}
1919
}
2020

0 commit comments

Comments
 (0)