diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-07-18 19:06:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-18 19:06:03 +0200 |
| commit | 994e2e4facccdbd3e56a3e9d3eec5ba69681e023 (patch) | |
| tree | d231ec08937c224d4b322f6118c4df18809206cb /compiler/rustc_ty_utils/src | |
| parent | 1b07da1d5218b9a48dfdbacb4fec66e2d21b65e1 (diff) | |
| parent | d1b4b458c0584f80cf8c202110d2e3846b2abe58 (diff) | |
| download | rust-994e2e4facccdbd3e56a3e9d3eec5ba69681e023.tar.gz rust-994e2e4facccdbd3e56a3e9d3eec5ba69681e023.zip | |
Rollup merge of #113824 - lcnr:exhaustive-match, r=wesleywiser
a small `fn needs_drop` refactor I am generally a fan of exhaustively matching on `TyKind` once we care about more than 1 variant
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/needs_drop.rs | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 3e6dfc1304f..e173bba49be 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -96,7 +96,7 @@ where return Some(Err(AlwaysRequiresDrop)); } - let components = match needs_drop_components(ty, &tcx.data_layout) { + let components = match needs_drop_components(tcx, ty) { Err(e) => return Some(Err(e)), Ok(components) => components, }; @@ -160,7 +160,7 @@ where queue_type(self, required); } } - ty::Array(..) | ty::Alias(..) | ty::Param(_) => { + ty::Alias(..) | ty::Array(..) | ty::Placeholder(_) | ty::Param(_) => { if ty == component { // Return the type to the caller: they may be able // to normalize further than we can. @@ -172,7 +172,31 @@ where queue_type(self, component); } } - _ => return Some(Err(AlwaysRequiresDrop)), + + ty::Foreign(_) | ty::Dynamic(..) => { + return Some(Err(AlwaysRequiresDrop)); + } + + ty::Bool + | ty::Char + | ty::Int(_) + | ty::Uint(_) + | ty::Float(_) + | ty::Str + | ty::Slice(_) + | ty::Ref(..) + | ty::RawPtr(..) + | ty::FnDef(..) + | ty::FnPtr(..) + | ty::Tuple(_) + | ty::Bound(..) + | ty::GeneratorWitness(..) + | ty::GeneratorWitnessMIR(..) + | ty::Never + | ty::Infer(_) + | ty::Error(_) => { + bug!("unexpected type returned by `needs_drop_components`: {component}") + } } } } |
