5
5
use std:: ops:: ControlFlow ;
6
6
7
7
use base_db:: CrateId ;
8
- use chalk_ir:: { cast:: Cast , Mutability , TyKind , UniverseIndex , WhereClause } ;
8
+ use chalk_ir:: { cast:: Cast , UniverseIndex , WithKind } ;
9
9
use hir_def:: {
10
10
data:: { adt:: StructFlags , ImplData } ,
11
11
nameres:: DefMap ,
@@ -16,7 +16,6 @@ use hir_expand::name::Name;
16
16
use intern:: sym;
17
17
use rustc_hash:: { FxHashMap , FxHashSet } ;
18
18
use smallvec:: { smallvec, SmallVec } ;
19
- use span:: Edition ;
20
19
use stdx:: never;
21
20
use triomphe:: Arc ;
22
21
@@ -25,12 +24,14 @@ use crate::{
25
24
db:: HirDatabase ,
26
25
error_lifetime, from_chalk_trait_id, from_foreign_def_id,
27
26
infer:: { unify:: InferenceTable , Adjust , Adjustment , OverloadedDeref , PointerCast } ,
27
+ lang_items:: is_box,
28
28
primitive:: { FloatTy , IntTy , UintTy } ,
29
29
to_chalk_trait_id,
30
30
utils:: all_super_traits,
31
- AdtId , Canonical , CanonicalVarKinds , DebruijnIndex , DynTyExt , ForeignDefId , Goal , Guidance ,
32
- InEnvironment , Interner , Scalar , Solution , Substitution , TraitEnvironment , TraitRef ,
33
- TraitRefExt , Ty , TyBuilder , TyExt ,
31
+ AdtId , Canonical , CanonicalVarKinds , DebruijnIndex , DynTyExt , ForeignDefId , GenericArgData ,
32
+ Goal , Guidance , InEnvironment , Interner , Mutability , Scalar , Solution , Substitution ,
33
+ TraitEnvironment , TraitRef , TraitRefExt , Ty , TyBuilder , TyExt , TyKind , VariableKind ,
34
+ WhereClause ,
34
35
} ;
35
36
36
37
/// This is used as a key for indexing impls.
@@ -1146,17 +1147,30 @@ fn iterate_trait_method_candidates(
1146
1147
' traits: for & t in traits_in_scope {
1147
1148
let data = db. trait_data ( t) ;
1148
1149
1149
- // Traits annotated with `#[rustc_skip_array_during_method_dispatch ]` are skipped during
1150
+ // Traits annotated with `#[rustc_skip_during_method_dispatch ]` are skipped during
1150
1151
// method resolution, if the receiver is an array, and we're compiling for editions before
1151
1152
// 2021.
1152
1153
// This is to make `[a].into_iter()` not break code with the new `IntoIterator` impl for
1153
1154
// arrays.
1154
1155
if data. skip_array_during_method_dispatch
1155
- && matches ! ( self_ty. kind( Interner ) , chalk_ir :: TyKind :: Array ( ..) )
1156
+ && matches ! ( self_ty. kind( Interner ) , TyKind :: Array ( ..) )
1156
1157
{
1157
1158
// FIXME: this should really be using the edition of the method name's span, in case it
1158
1159
// comes from a macro
1159
- if db. crate_graph ( ) [ krate] . edition < Edition :: Edition2021 {
1160
+ if !db. crate_graph ( ) [ krate] . edition . at_least_2021 ( ) {
1161
+ continue ;
1162
+ }
1163
+ }
1164
+ if data. skip_boxed_slice_during_method_dispatch
1165
+ && matches ! (
1166
+ self_ty. kind( Interner ) , TyKind :: Adt ( AdtId ( def) , subst)
1167
+ if is_box( table. db, * def)
1168
+ && matches!( subst. at( Interner , 0 ) . assert_ty_ref( Interner ) . kind( Interner ) , TyKind :: Slice ( ..) )
1169
+ )
1170
+ {
1171
+ // FIXME: this should really be using the edition of the method name's span, in case it
1172
+ // comes from a macro
1173
+ if !db. crate_graph ( ) [ krate] . edition . at_least_2024 ( ) {
1160
1174
continue ;
1161
1175
}
1162
1176
}
@@ -1619,15 +1633,11 @@ fn generic_implements_goal(
1619
1633
let kinds =
1620
1634
binders. iter ( ) . cloned ( ) . chain ( trait_ref. substitution . iter ( Interner ) . skip ( 1 ) . map ( |it| {
1621
1635
let vk = match it. data ( Interner ) {
1622
- chalk_ir:: GenericArgData :: Ty ( _) => {
1623
- chalk_ir:: VariableKind :: Ty ( chalk_ir:: TyVariableKind :: General )
1624
- }
1625
- chalk_ir:: GenericArgData :: Lifetime ( _) => chalk_ir:: VariableKind :: Lifetime ,
1626
- chalk_ir:: GenericArgData :: Const ( c) => {
1627
- chalk_ir:: VariableKind :: Const ( c. data ( Interner ) . ty . clone ( ) )
1628
- }
1636
+ GenericArgData :: Ty ( _) => VariableKind :: Ty ( chalk_ir:: TyVariableKind :: General ) ,
1637
+ GenericArgData :: Lifetime ( _) => VariableKind :: Lifetime ,
1638
+ GenericArgData :: Const ( c) => VariableKind :: Const ( c. data ( Interner ) . ty . clone ( ) ) ,
1629
1639
} ;
1630
- chalk_ir :: WithKind :: new ( vk, UniverseIndex :: ROOT )
1640
+ WithKind :: new ( vk, UniverseIndex :: ROOT )
1631
1641
} ) ) ;
1632
1642
let binders = CanonicalVarKinds :: from_iter ( Interner , kinds) ;
1633
1643
0 commit comments