1
Fork 0

Allow trait method paths to satisfy const Fn bounds

This commit is contained in:
Deadbeef 2022-12-28 08:55:01 +00:00
parent 6a4624d73b
commit 983606d367
6 changed files with 100 additions and 13 deletions

View file

@ -1374,6 +1374,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
FutureCandidate => {}
// FnDef where the function is const
FnPointerCandidate { is_const: true } => {}
FnPointerCandidate { is_const: false } => {
if let ty::FnDef(def_id, _) = obligation.self_ty().skip_binder().kind() && tcx.trait_of_item(*def_id).is_some() {
// Trait methods are not seen as const unless the trait is implemented as const.
// We do not filter that out in here, but nested obligations will be needed to confirm this.
} else {
continue
}
}
ConstDestructCandidate(_) => {}
_ => {
// reject all other types of candidates