Skip to content

Commit b0fec0d

Browse files
authored
Merge pull request #22791 from Veykril/lukaswirth/push-lnrnonstwsns
Enable auto trait inference
2 parents 7fd49a4 + 0aaeef2 commit b0fec0d

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

crates/hir-ty/src/next_solver/interner.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use std::{fmt, ops::ControlFlow};
44

5+
use either::Either;
56
use intern::{Interned, InternedRef, InternedSliceRef, impl_internable};
67
use macros::GenericTypeVisitable;
78
use rustc_abi::ReprOptions;
@@ -597,20 +598,17 @@ impl<'db> inherent::AdtDef<DbInterner<'db>> for AdtDef {
597598
interner: DbInterner<'db>,
598599
) -> EarlyBinder<DbInterner<'db>, impl IntoIterator<Item = Ty<'db>>> {
599600
let db = interner.db();
600-
// FIXME: this is disabled just to match the behavior with chalk right now
601-
let _field_tys = |id: VariantId| {
602-
db.field_types(id).iter().map(|(_, ty)| ty.ty().skip_binder()).collect::<Vec<_>>()
603-
};
604-
let field_tys = |_id: VariantId| vec![];
605-
let tys: Vec<_> = match self.def_id() {
606-
hir_def::AdtId::StructId(id) => field_tys(id.into()),
607-
hir_def::AdtId::UnionId(id) => field_tys(id.into()),
608-
hir_def::AdtId::EnumId(id) => id
609-
.enum_variants(db)
610-
.variants
611-
.values()
612-
.flat_map(|&(variant_id, _)| field_tys(variant_id.into()))
613-
.collect(),
601+
let field_tys =
602+
|id: VariantId| db.field_types(id).iter().map(|(_, ty)| ty.ty().skip_binder());
603+
let tys = match self.def_id() {
604+
hir_def::AdtId::StructId(id) => Either::Left(field_tys(id.into())),
605+
hir_def::AdtId::UnionId(id) => Either::Left(field_tys(id.into())),
606+
hir_def::AdtId::EnumId(id) => Either::Right(
607+
id.enum_variants(db)
608+
.variants
609+
.values()
610+
.flat_map(move |&(variant_id, _)| field_tys(variant_id.into())),
611+
),
614612
};
615613

616614
EarlyBinder::bind(tys)

crates/hir-ty/src/tests/traits.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4763,21 +4763,21 @@ fn f<T: Send, U>() {
47634763
Struct::<T>::IS_SEND;
47644764
//^^^^^^^^^^^^^^^^^^^^Yes
47654765
Struct::<U>::IS_SEND;
4766-
//^^^^^^^^^^^^^^^^^^^^Yes
4766+
//^^^^^^^^^^^^^^^^^^^^{unknown}
47674767
Struct::<*const T>::IS_SEND;
4768-
//^^^^^^^^^^^^^^^^^^^^^^^^^^^Yes
4768+
//^^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown}
47694769
Enum::<T>::IS_SEND;
47704770
//^^^^^^^^^^^^^^^^^^Yes
47714771
Enum::<U>::IS_SEND;
4772-
//^^^^^^^^^^^^^^^^^^Yes
4772+
//^^^^^^^^^^^^^^^^^^{unknown}
47734773
Enum::<*const T>::IS_SEND;
4774-
//^^^^^^^^^^^^^^^^^^^^^^^^^Yes
4774+
//^^^^^^^^^^^^^^^^^^^^^^^^^{unknown}
47754775
Union::<T>::IS_SEND;
47764776
//^^^^^^^^^^^^^^^^^^^Yes
47774777
Union::<U>::IS_SEND;
4778-
//^^^^^^^^^^^^^^^^^^^Yes
4778+
//^^^^^^^^^^^^^^^^^^^{unknown}
47794779
Union::<*const T>::IS_SEND;
4780-
//^^^^^^^^^^^^^^^^^^^^^^^^^^Yes
4780+
//^^^^^^^^^^^^^^^^^^^^^^^^^^{unknown}
47814781
PhantomData::<T>::IS_SEND;
47824782
//^^^^^^^^^^^^^^^^^^^^^^^^^Yes
47834783
PhantomData::<U>::IS_SEND;

0 commit comments

Comments
 (0)