@@ -167,26 +167,26 @@ enum ProbeResult {
167167/// T`, we could convert it to `*const T`, then autoref to `&*const T`. However, currently we do
168168/// (at most) one of these. Either the receiver has type `T` and we convert it to `&T` (or with
169169/// `mut`), or it has type `*mut T` and we convert it to `*const T`.
170- #[ derive( Debug , PartialEq , Clone ) ]
171- pub enum AutorefOrPtrAdjustment < ' tcx > {
170+ #[ derive( Debug , PartialEq , Copy , Clone ) ]
171+ pub enum AutorefOrPtrAdjustment {
172172 /// Receiver has type `T`, add `&` or `&mut` (it `T` is `mut`), and maybe also "unsize" it.
173173 /// Unsizing is used to convert a `[T; N]` to `[T]`, which only makes sense when autorefing.
174174 Autoref {
175175 mutbl : hir:: Mutability ,
176176
177- /// Indicates that the source expression should be "unsized" to a target type. This should
178- /// probably eventually go away in favor of just coercing method receivers .
179- unsize : Option < Ty < ' tcx > > ,
177+ /// Indicates that the source expression should be "unsized" to a target type.
178+ /// This is special-cased for just arrays unsizing to slices .
179+ unsize : bool ,
180180 } ,
181181 /// Receiver has type `*mut T`, convert to `*const T`
182182 ToConstPtr ,
183183}
184184
185- impl < ' tcx > AutorefOrPtrAdjustment < ' tcx > {
186- fn get_unsize ( & self ) -> Option < Ty < ' tcx > > {
185+ impl AutorefOrPtrAdjustment {
186+ fn get_unsize ( & self ) -> bool {
187187 match self {
188188 AutorefOrPtrAdjustment :: Autoref { mutbl : _, unsize } => * unsize,
189- AutorefOrPtrAdjustment :: ToConstPtr => None ,
189+ AutorefOrPtrAdjustment :: ToConstPtr => false ,
190190 }
191191 }
192192}
@@ -204,7 +204,7 @@ pub struct Pick<'tcx> {
204204
205205 /// Indicates that we want to add an autoref (and maybe also unsize it), or if the receiver is
206206 /// `*mut T`, convert it to `*const T`.
207- pub autoref_or_ptr_adjustment : Option < AutorefOrPtrAdjustment < ' tcx > > ,
207+ pub autoref_or_ptr_adjustment : Option < AutorefOrPtrAdjustment > ,
208208 pub self_ty : Ty < ' tcx > ,
209209}
210210
@@ -1202,7 +1202,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
12021202 pick. autoderefs += 1 ;
12031203 pick. autoref_or_ptr_adjustment = Some ( AutorefOrPtrAdjustment :: Autoref {
12041204 mutbl,
1205- unsize : pick. autoref_or_ptr_adjustment . and_then ( |a| a. get_unsize ( ) ) ,
1205+ unsize : pick. autoref_or_ptr_adjustment . map_or ( false , |a| a. get_unsize ( ) ) ,
12061206 } )
12071207 }
12081208
@@ -1227,10 +1227,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
12271227 self . pick_method ( autoref_ty, unstable_candidates) . map ( |r| {
12281228 r. map ( |mut pick| {
12291229 pick. autoderefs = step. autoderefs ;
1230- pick. autoref_or_ptr_adjustment = Some ( AutorefOrPtrAdjustment :: Autoref {
1231- mutbl,
1232- unsize : step. unsize . then_some ( self_ty) ,
1233- } ) ;
1230+ pick. autoref_or_ptr_adjustment =
1231+ Some ( AutorefOrPtrAdjustment :: Autoref { mutbl, unsize : step. unsize } ) ;
12341232 pick
12351233 } )
12361234 } )
0 commit comments