diff options
| author | Lukas Markeffsky <@> | 2024-03-18 22:28:29 +0100 |
|---|---|---|
| committer | Lukas Markeffsky <@> | 2024-03-18 22:28:29 +0100 |
| commit | 99efae342e8581d12f9017affba2a229a2cfa152 (patch) | |
| tree | eda41541756992ca6db4a3457fad478d527b4ad4 /compiler/rustc_trait_selection/src | |
| parent | ee66acbea856f12694ea7c8033769a371a754ae3 (diff) | |
| download | rust-99efae342e8581d12f9017affba2a229a2cfa152.tar.gz rust-99efae342e8581d12f9017affba2a229a2cfa152.zip | |
address nits
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/mod.rs | 13 |
2 files changed, 13 insertions, 9 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs index e7e8ff66e3e..faf8c55c475 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs @@ -168,10 +168,11 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>( // "best effort" optimization and `sized_constraint` may return `Some`, even // if the ADT is sized for all possible args. ty::Adt(def, args) => { - let sized_crit = def.sized_constraint(ecx.tcx()); - Ok(sized_crit.map_or_else(Vec::new, |ty| { - vec![ty::Binder::dummy(ty.instantiate(ecx.tcx(), args))] - })) + if let Some(sized_crit) = def.sized_constraint(ecx.tcx()) { + Ok(vec![ty::Binder::dummy(sized_crit.instantiate(ecx.tcx(), args))]) + } else { + Ok(vec![]) + } } } } diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index a84acf67657..f930b758e42 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2118,11 +2118,14 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ), ty::Adt(def, args) => { - let sized_crit = def.sized_constraint(self.tcx()); - // (*) binder moved here - Where(obligation.predicate.rebind( - sized_crit.map_or_else(Vec::new, |ty| vec![ty.instantiate(self.tcx(), args)]), - )) + if let Some(sized_crit) = def.sized_constraint(self.tcx()) { + // (*) binder moved here + Where( + obligation.predicate.rebind(vec![sized_crit.instantiate(self.tcx(), args)]), + ) + } else { + Where(ty::Binder::dummy(Vec::new())) + } } ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => None, |
