From e3f01b2b6ff177359504e42a99665a8abc388cb7 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 19 Jan 2022 00:40:05 -0800 Subject: [PATCH] never type is const Drop --- .../src/traits/select/candidate_assembly.rs | 2 +- .../rustc_trait_selection/src/traits/select/confirmation.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 20297518a59..77db3bd2692 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -932,7 +932,6 @@ fn assemble_const_drop_candidates( | ty::Bound(..) | ty::Param(_) | ty::Placeholder(_) - | ty::Never | ty::Foreign(_) | ty::Projection(_) => { // We don't know if these are `~const Drop`, at least @@ -951,6 +950,7 @@ fn assemble_const_drop_candidates( | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(_) + | ty::Never | ty::Array(..) | ty::Slice(_) | ty::Closure(..) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 9d62614031c..35aebd9900f 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -1103,6 +1103,7 @@ fn confirm_const_drop_candidate( let tcx = self.tcx(); let self_ty = self.infcx.shallow_resolve(obligation.self_ty()); + // Skip binder here (*) let nested_tys = match *self_ty.skip_binder().kind() { ty::Bool | ty::Char @@ -1116,7 +1117,7 @@ fn confirm_const_drop_candidate( | ty::Ref(..) | ty::FnDef(..) | ty::FnPtr(_) - | ty::Projection(_) => vec![], + | ty::Never => vec![], ty::Adt(def, substs) => def.all_fields().map(|f| f.ty(tcx, substs)).collect(), @@ -1138,8 +1139,8 @@ fn confirm_const_drop_candidate( | ty::Bound(_, _) | ty::Param(_) | ty::Placeholder(_) - | ty::Never | ty::Foreign(_) + | ty::Projection(_) | ty::Infer(_) => { unreachable!(); } @@ -1165,6 +1166,7 @@ fn confirm_const_drop_candidate( obligation.param_env, cause.clone(), obligation.recursion_depth + 1, + // Rebinding here (*) self_ty .rebind(ty::TraitPredicate { trait_ref: ty::TraitRef {