Do not allow Drop impl on foreign fundamental types
This commit is contained in:
parent
40336865fe
commit
fd934c99bc
10 changed files with 51 additions and 18 deletions
|
@ -47,9 +47,11 @@ impl<'tcx> Checker<'tcx> {
|
|||
}
|
||||
|
||||
fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
|
||||
// Destructors only work on nominal types.
|
||||
if let ty::Adt(..) | ty::Error(_) = tcx.type_of(impl_did).kind() {
|
||||
return;
|
||||
// Destructors only work on local ADT types.
|
||||
match tcx.type_of(impl_did).kind() {
|
||||
ty::Adt(def, _) if def.did().is_local() => return,
|
||||
ty::Error(_) => return,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let sp = match tcx.hir().expect_item(impl_did).kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue