mod find_use;
+#[derive(Debug)]
pub(in crate::borrow_check) enum BorrowExplanation {
UsedLater(LaterUseKind, Span),
UsedLaterInLoop(LaterUseKind, Span),
Unexplained,
}
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
pub(in crate::borrow_check) enum LaterUseKind {
TraitCapture,
ClosureCapture,
should_note_order,
} => {
let local_decl = &body.local_decls[dropped_local];
- let (dtor_desc, type_desc) = match local_decl.ty.sty {
+ let (dtor_desc, type_desc) = match local_decl.ty.kind {
// If type is an ADT that implements Drop, then
// simplify output by reporting just the ADT name.
ty::Adt(adt, _substs) if adt.has_dtor(tcx) && !adt.is_box() => (
if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place {
if let Place {
base: PlaceBase::Local(borrowed_local),
- projection: None,
+ projection: box [],
} = place {
if body.local_decls[*borrowed_local].name.is_some()
&& local != *borrowed_local
Operand::Constant(c) => c.span,
Operand::Copy(Place {
base: PlaceBase::Local(l),
- projection: None,
+ projection: box [],
}) |
Operand::Move(Place {
base: PlaceBase::Local(l),
- projection: None,
+ projection: box [],
}) => {
let local_decl = &self.body.local_decls[*l];
if local_decl.name.is_none() {
// it which simplifies the termination logic.
let mut queue = vec![location];
let mut target = if let Some(&Statement {
- kind: StatementKind::Assign(Place {
+ kind: StatementKind::Assign(box(Place {
base: PlaceBase::Local(local),
- projection: None,
- }, _),
+ projection: box [],
+ }, _)),
..
}) = stmt
{
debug!("was_captured_by_trait_object: stmt={:?}", stmt);
// The only kind of statement that we care about is assignments...
- if let StatementKind::Assign(place, box rvalue) = &stmt.kind {
+ if let StatementKind::Assign(box(place, rvalue)) = &stmt.kind {
let into = match place.local_or_deref_local() {
Some(into) => into,
None => {
Rvalue::Use(operand) => match operand {
Operand::Copy(Place {
base: PlaceBase::Local(from),
- projection: None,
+ projection: box [],
})
| Operand::Move(Place {
base: PlaceBase::Local(from),
- projection: None,
+ projection: box [],
})
if *from == target =>
{
) => match operand {
Operand::Copy(Place {
base: PlaceBase::Local(from),
- projection: None,
+ projection: box [],
})
| Operand::Move(Place {
base: PlaceBase::Local(from),
- projection: None,
+ projection: box [],
})
if *from == target =>
{
debug!("was_captured_by_trait_object: ty={:?}", ty);
// Check the type for a trait object.
- return match ty.sty {
+ return match ty.kind {
// `&dyn Trait`
ty::Ref(_, ty, _) if ty.is_trait() => true,
// `Box<dyn Trait>`
if let TerminatorKind::Call {
destination: Some((Place {
base: PlaceBase::Local(dest),
- projection: None,
+ projection: box [],
}, block)),
args,
..
let found_target = args.iter().any(|arg| {
if let Operand::Move(Place {
base: PlaceBase::Local(potential),
- projection: None,
+ projection: box [],
}) = arg {
*potential == target
} else {