Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5c73519

Browse files
committed
chains cleanup
1 parent a955f1c commit 5c73519

File tree

77 files changed

+1109
-1202
lines changed

Some content is hidden

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

77 files changed

+1109
-1202
lines changed

‎compiler/rustc_ast_lowering/src/index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
164164
fn visit_item(&mut self, i: &'hir Item<'hir>) {
165165
debug_assert_eq!(i.owner_id, self.owner);
166166
self.with_parent(i.hir_id(), |this| {
167-
if let ItemKind::Struct(_, _, struct_def) = &i.kind{
167+
if let ItemKind::Struct(_, _, struct_def) = &i.kind
168168
// If this is a tuple or unit-like struct, register the constructor.
169-
if let Some(ctor_hir_id) = struct_def.ctor_hir_id(){
170-
this.insert(i.span, ctor_hir_id,Node::Ctor(struct_def));
171-
}
169+
&& let Some(ctor_hir_id) = struct_def.ctor_hir_id()
170+
{
171+
this.insert(i.span, ctor_hir_id,Node::Ctor(struct_def));
172172
}
173173
intravisit::walk_item(this, i);
174174
});

‎compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -640,16 +640,16 @@ impl<'a> AstValidator<'a> {
640640
return;
641641
}
642642

643-
if let Some(header) = fk.header(){
644-
if let Const::Yes(const_span) = header.constness{
645-
letmut spans = variadic_spans.clone();
646-
spans.push(const_span);
647-
self.dcx().emit_err(errors::ConstAndCVariadic{
648-
spans,
649-
const_span,
650-
variadic_spans: variadic_spans.clone(),
651-
});
652-
}
643+
if let Some(header) = fk.header()
644+
&& let Const::Yes(const_span) = header.constness
645+
{
646+
letmut spans = variadic_spans.clone();
647+
spans.push(const_span);
648+
self.dcx().emit_err(errors::ConstAndCVariadic{
649+
spans,
650+
const_span,
651+
variadic_spans: variadic_spans.clone(),
652+
});
653653
}
654654

655655
match (fk.ctxt(), fk.header()) {

‎compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -630,16 +630,11 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
630630
.iter()
631631
.filter(|(f1, f2)| features.enabled(*f1) && features.enabled(*f2))
632632
{
633-
if let Some((f1_name, f1_span)) = enabled_features.clone().find(|(name, _)| name == f1) {
634-
if let Some((f2_name, f2_span)) = enabled_features.clone().find(|(name, _)| name == f2)
635-
{
636-
let spans = vec![f1_span, f2_span];
637-
sess.dcx().emit_err(errors::IncompatibleFeatures {
638-
spans,
639-
f1: f1_name,
640-
f2: f2_name,
641-
});
642-
}
633+
if let Some((f1_name, f1_span)) = enabled_features.clone().find(|(name, _)| name == f1)
634+
&& let Some((f2_name, f2_span)) = enabled_features.clone().find(|(name, _)| name == f2)
635+
{
636+
let spans = vec![f1_span, f2_span];
637+
sess.dcx().emit_err(errors::IncompatibleFeatures { spans, f1: f1_name, f2: f2_name });
643638
}
644639
}
645640
}

‎compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,10 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
572572
}
573573

574574
fn maybe_print_trailing_comment(&mut self, span: rustc_span::Span, next_pos: Option<BytePos>) {
575-
if let Some(cmnts) = self.comments_mut(){
576-
if let Some(cmnt) = cmnts.trailing_comment(span, next_pos){
577-
self.print_comment(cmnt);
578-
}
575+
if let Some(cmnts) = self.comments_mut()
576+
&& let Some(cmnt) = cmnts.trailing_comment(span, next_pos)
577+
{
578+
self.print_comment(cmnt);
579579
}
580580
}
581581

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 155 additions & 160 deletions
Large diffs are not rendered by default.

‎compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -917,30 +917,29 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
917917

918918
if let TerminatorKind::Call { destination, target: Some(block), args, .. } =
919919
&terminator.kind
920+
&& let Some(dest) = destination.as_local()
920921
{
921-
if let Some(dest) = destination.as_local() {
922-
debug!(
923-
"was_captured_by_trait_object: target={:?} dest={:?} args={:?}",
924-
target, dest, args
925-
);
926-
// Check if one of the arguments to this function is the target place.
927-
let found_target = args.iter().any(|arg| {
928-
if let Operand::Move(place) = arg.node {
929-
if let Some(potential) = place.as_local() {
930-
potential == target
931-
} else {
932-
false
933-
}
922+
debug!(
923+
"was_captured_by_trait_object: target={:?} dest={:?} args={:?}",
924+
target, dest, args
925+
);
926+
// Check if one of the arguments to this function is the target place.
927+
let found_target = args.iter().any(|arg| {
928+
if let Operand::Move(place) = arg.node {
929+
if let Some(potential) = place.as_local() {
930+
potential == target
934931
} else {
935932
false
936933
}
937-
});
938-
939-
// If it is, follow this to the next block and update the target.
940-
if found_target {
941-
target = dest;
942-
queue.push(block.start_location());
934+
} else {
935+
false
943936
}
937+
});
938+
939+
// If it is, follow this to the next block and update the target.
940+
if found_target {
941+
target = dest;
942+
queue.push(block.start_location());
944943
}
945944
}
946945
}

‎compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -266,48 +266,44 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
266266
args,
267267
..
268268
} = &terminator.kind
269+
&& let ty::FnDef(id, _) = *const_.ty().kind()
269270
{
270-
if let ty::FnDef(id, _) = *const_.ty().kind() {
271-
debug!("add_moved_or_invoked_closure_note: id={:?}", id);
272-
if self.infcx.tcx.is_lang_item(self.infcx.tcx.parent(id), LangItem::FnOnce) {
273-
let closure = match args.first() {
274-
Some(Spanned {
275-
node: Operand::Copy(place) | Operand::Move(place), ..
276-
}) if target == place.local_or_deref_local() => {
277-
place.local_or_deref_local().unwrap()
278-
}
279-
_ => return false,
280-
};
271+
debug!("add_moved_or_invoked_closure_note: id={:?}", id);
272+
if self.infcx.tcx.is_lang_item(self.infcx.tcx.parent(id), LangItem::FnOnce) {
273+
let closure = match args.first() {
274+
Some(Spanned { node: Operand::Copy(place) | Operand::Move(place), .. })
275+
if target == place.local_or_deref_local() =>
276+
{
277+
place.local_or_deref_local().unwrap()
278+
}
279+
_ => return false,
280+
};
281281

282-
debug!("add_moved_or_invoked_closure_note: closure={:?}", closure);
283-
if let ty::Closure(did, _) = self.body.local_decls[closure].ty.kind() {
284-
let did = did.expect_local();
285-
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
286-
diag.subdiagnostic(OnClosureNote::InvokedTwice {
287-
place_name: &ty::place_to_string_for_capture(
288-
self.infcx.tcx,
289-
hir_place,
290-
),
291-
span: *span,
292-
});
293-
return true;
294-
}
282+
debug!("add_moved_or_invoked_closure_note: closure={:?}", closure);
283+
if let ty::Closure(did, _) = self.body.local_decls[closure].ty.kind() {
284+
let did = did.expect_local();
285+
if let Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
286+
diag.subdiagnostic(OnClosureNote::InvokedTwice {
287+
place_name: &ty::place_to_string_for_capture(self.infcx.tcx, hir_place),
288+
span: *span,
289+
});
290+
return true;
295291
}
296292
}
297293
}
298294
}
299295

300296
// Check if we are just moving a closure after it has been invoked.
301-
if let Some(target) = target{
302-
if let ty::Closure(did, _) = self.body.local_decls[target].ty.kind(){
303-
let did = did.expect_local();
304-
iflet Some((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did){
305-
diag.subdiagnostic(OnClosureNote::MovedTwice {
306-
place_name:&ty::place_to_string_for_capture(self.infcx.tcx, hir_place),
307-
span:*span,
308-
});
309-
returntrue;
310-
}
297+
if let Some(target) = target
298+
&& let ty::Closure(did, _) = self.body.local_decls[target].ty.kind()
299+
{
300+
let did = did.expect_local();
301+
ifletSome((span, hir_place)) = self.infcx.tcx.closure_kind_origin(did) {
302+
diag.subdiagnostic(OnClosureNote::MovedTwice{
303+
place_name:&ty::place_to_string_for_capture(self.infcx.tcx, hir_place),
304+
span:*span,
305+
});
306+
returntrue;
311307
}
312308
}
313309
false

‎compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -126,36 +126,35 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
126126
.statements
127127
.get(location.statement_index)
128128
.map(|stmt| &stmt.kind)
129+
&& let Some(local) = place.as_local()
129130
{
130-
if let Some(local) = place.as_local() {
131-
let local_decl = &self.body.local_decls[local];
132-
// opt_match_place is the
133-
// match_span is the span of the expression being matched on
134-
// match *x.y { ... } match_place is Some(*x.y)
135-
// ^^^^ match_span is the span of *x.y
136-
//
137-
// opt_match_place is None for let [mut] x = ... statements,
138-
// whether or not the right-hand side is a place expression
139-
if let LocalInfo::User(BindingForm::Var(VarBindingForm {
140-
opt_match_place: Some((opt_match_place, match_span)),
141-
binding_mode: _,
142-
opt_ty_info: _,
143-
pat_span: _,
144-
})) = *local_decl.local_info()
145-
{
146-
let stmt_source_info = self.body.source_info(location);
147-
self.append_binding_error(
148-
grouped_errors,
149-
kind,
150-
original_path,
151-
*move_from,
152-
local,
153-
opt_match_place,
154-
match_span,
155-
stmt_source_info.span,
156-
);
157-
return;
158-
}
131+
let local_decl = &self.body.local_decls[local];
132+
// opt_match_place is the
133+
// match_span is the span of the expression being matched on
134+
// match *x.y { ... } match_place is Some(*x.y)
135+
// ^^^^ match_span is the span of *x.y
136+
//
137+
// opt_match_place is None for let [mut] x = ... statements,
138+
// whether or not the right-hand side is a place expression
139+
if let LocalInfo::User(BindingForm::Var(VarBindingForm {
140+
opt_match_place: Some((opt_match_place, match_span)),
141+
binding_mode: _,
142+
opt_ty_info: _,
143+
pat_span: _,
144+
})) = *local_decl.local_info()
145+
{
146+
let stmt_source_info = self.body.source_info(location);
147+
self.append_binding_error(
148+
grouped_errors,
149+
kind,
150+
original_path,
151+
*move_from,
152+
local,
153+
opt_match_place,
154+
match_span,
155+
stmt_source_info.span,
156+
);
157+
return;
159158
}
160159
}
161160

‎compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,15 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
528528
// match_adt_and_segment in this case.
529529
Res::Def(DefKind::TyAlias, _) => (),
530530
_ => {
531-
if let Some(last_segment) = path.segments.last(){
532-
if let Some(highlight) = self.match_adt_and_segment(
531+
if let Some(last_segment) = path.segments.last()
532+
&& let Some(highlight) = self.match_adt_and_segment(
533533
args,
534534
needle_fr,
535535
last_segment,
536536
search_stack,
537-
){
538-
returnSome(highlight);
539-
}
537+
)
538+
{
539+
returnSome(highlight);
540540
}
541541
}
542542
}

‎compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
822822
continue;
823823
}
824824

825-
if let Some(propagated_outlives_requirements) = &mut propagated_outlives_requirements{
826-
if self.try_promote_type_test(infcx, type_test, propagated_outlives_requirements){
827-
continue;
828-
}
825+
if let Some(propagated_outlives_requirements) = &mut propagated_outlives_requirements
826+
&& self.try_promote_type_test(infcx, type_test, propagated_outlives_requirements)
827+
{
828+
continue;
829829
}
830830

831831
// Type-test failed. Report the error.
@@ -1479,40 +1479,36 @@ impl<'tcx> RegionInferenceContext<'tcx> {
14791479
shorter_fr: RegionVid,
14801480
propagated_outlives_requirements: &mut Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
14811481
) -> RegionRelationCheckResult {
1482-
if let Some(propagated_outlives_requirements) = propagated_outlives_requirements{
1482+
if let Some(propagated_outlives_requirements) = propagated_outlives_requirements
14831483
// Shrink `longer_fr` until we find a non-local region (if we do).
14841484
// We'll call it `fr-` -- it's ever so slightly smaller than
14851485
// `longer_fr`.
1486-
if let Some(fr_minus) = self.universal_region_relations.non_local_lower_bound(longer_fr)
1487-
{
1488-
debug!("try_propagate_universal_region_error: fr_minus={:?}", fr_minus);
1486+
&& let Some(fr_minus) = self.universal_region_relations.non_local_lower_bound(longer_fr)
1487+
{
1488+
debug!("try_propagate_universal_region_error: fr_minus={:?}", fr_minus);
14891489

1490-
let blame_span_category = self.find_outlives_blame_span(
1491-
longer_fr,
1492-
NllRegionVariableOrigin::FreeRegion,
1493-
shorter_fr,
1494-
);
1490+
let blame_span_category = self.find_outlives_blame_span(
1491+
longer_fr,
1492+
NllRegionVariableOrigin::FreeRegion,
1493+
shorter_fr,
1494+
);
14951495

1496-
// Grow `shorter_fr` until we find some non-local regions. (We
1497-
// always will.) We'll call them `shorter_fr+` -- they're ever
1498-
// so slightly larger than `shorter_fr`.
1499-
let shorter_fr_plus =
1500-
self.universal_region_relations.non_local_upper_bounds(shorter_fr);
1501-
debug!(
1502-
"try_propagate_universal_region_error: shorter_fr_plus={:?}",
1503-
shorter_fr_plus
1504-
);
1505-
for fr in shorter_fr_plus {
1506-
// Push the constraint `fr-: shorter_fr+`
1507-
propagated_outlives_requirements.push(ClosureOutlivesRequirement {
1508-
subject: ClosureOutlivesSubject::Region(fr_minus),
1509-
outlived_free_region: fr,
1510-
blame_span: blame_span_category.1.span,
1511-
category: blame_span_category.0,
1512-
});
1513-
}
1514-
return RegionRelationCheckResult::Propagated;
1496+
// Grow `shorter_fr` until we find some non-local regions. (We
1497+
// always will.) We'll call them `shorter_fr+` -- they're ever
1498+
// so slightly larger than `shorter_fr`.
1499+
let shorter_fr_plus =
1500+
self.universal_region_relations.non_local_upper_bounds(shorter_fr);
1501+
debug!("try_propagate_universal_region_error: shorter_fr_plus={:?}", shorter_fr_plus);
1502+
for fr in shorter_fr_plus {
1503+
// Push the constraint `fr-: shorter_fr+`
1504+
propagated_outlives_requirements.push(ClosureOutlivesRequirement {
1505+
subject: ClosureOutlivesSubject::Region(fr_minus),
1506+
outlived_free_region: fr,
1507+
blame_span: blame_span_category.1.span,
1508+
category: blame_span_category.0,
1509+
});
15151510
}
1511+
return RegionRelationCheckResult::Propagated;
15161512
}
15171513

15181514
RegionRelationCheckResult::Error
@@ -2085,11 +2081,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20852081
let locations = self.scc_values.locations_outlived_by(scc);
20862082
for location in locations {
20872083
let bb = &body[location.block];
2088-
if let Some(terminator) = &bb.terminator{
2084+
if let Some(terminator) = &bb.terminator
20892085
// terminator of a loop should be TerminatorKind::FalseUnwind
2090-
if let TerminatorKind::FalseUnwind { .. } = terminator.kind{
2091-
returnSome(location);
2092-
}
2086+
&& let TerminatorKind::FalseUnwind { .. } = terminator.kind
2087+
{
2088+
returnSome(location);
20932089
}
20942090
}
20952091
None

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /