Auto merge of #16630 - ShoyuVanilla:fix-closure-kind-inference, r=Veykril

fix: Wrong closure kind deduction for closures with predicates

Completes #16472, fixes #16421

The changed closure kind deduction is mostly simlar to `rustc_hir_typeck/src/closure.rs`.
Porting closure sig deduction from it seems possible too and I'm considering doing it with another PR
This commit is contained in:
bors 2024-02-27 14:41:23 +00:00
commit a3236be9d7
8 changed files with 269 additions and 36 deletions

View file

@ -218,6 +218,15 @@ impl FnTrait {
}
}
pub const fn from_lang_item(lang_item: LangItem) -> Option<Self> {
match lang_item {
LangItem::FnOnce => Some(FnTrait::FnOnce),
LangItem::FnMut => Some(FnTrait::FnMut),
LangItem::Fn => Some(FnTrait::Fn),
_ => None,
}
}
pub const fn to_chalk_ir(self) -> rust_ir::ClosureKind {
match self {
FnTrait::FnOnce => rust_ir::ClosureKind::FnOnce,