Merge some if
s.
For more concise code.
This commit is contained in:
parent
3b6af9a451
commit
5331280a2b
@ -37,8 +37,7 @@ fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location: Location) {
|
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location: Location) {
|
||||||
if context.is_borrow() {
|
if context.is_borrow() && util::is_disaligned(self.tcx, self.body, self.param_env, *place) {
|
||||||
if util::is_disaligned(self.tcx, self.body, self.param_env, *place) {
|
|
||||||
let def_id = self.body.source.instance.def_id();
|
let def_id = self.body.source.instance.def_id();
|
||||||
if let Some(impl_def_id) = self.tcx.impl_of_method(def_id)
|
if let Some(impl_def_id) = self.tcx.impl_of_method(def_id)
|
||||||
&& self.tcx.is_builtin_derived(impl_def_id)
|
&& self.tcx.is_builtin_derived(impl_def_id)
|
||||||
@ -46,15 +45,9 @@ fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location:
|
|||||||
// If we ever reach here it means that the generated derive
|
// If we ever reach here it means that the generated derive
|
||||||
// code is somehow doing an unaligned reference, which it
|
// code is somehow doing an unaligned reference, which it
|
||||||
// shouldn't do.
|
// shouldn't do.
|
||||||
span_bug!(
|
span_bug!(self.source_info.span, "builtin derive created an unaligned reference");
|
||||||
self.source_info.span,
|
|
||||||
"builtin derive created an unaligned reference"
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
self.tcx
|
self.tcx.dcx().emit_err(errors::UnalignedPackedRef { span: self.source_info.span });
|
||||||
.dcx()
|
|
||||||
.emit_err(errors::UnalignedPackedRef { span: self.source_info.span });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1182,15 +1182,13 @@ fn elaborate_coroutine_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
|||||||
source_info,
|
source_info,
|
||||||
kind: TerminatorKind::Drop { place, target, unwind, replace: _ },
|
kind: TerminatorKind::Drop { place, target, unwind, replace: _ },
|
||||||
} => {
|
} => {
|
||||||
if let Some(local) = place.as_local() {
|
if let Some(local) = place.as_local()
|
||||||
if local == SELF_ARG {
|
&& local == SELF_ARG
|
||||||
|
{
|
||||||
(target, unwind, source_info)
|
(target, unwind, source_info)
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user