@@ -7,7 +7,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
77use rustc_middle:: ty:: TyCtxt ;
88use rustc_span:: def_id:: DefId ;
99use rustc_span:: sym;
10- use rustc_span:: symbol:: Symbol ;
10+ use rustc_span:: symbol:: { kw , Symbol } ;
1111use serde:: ser:: { Serialize , SerializeSeq , SerializeStruct , Serializer } ;
1212use thin_vec:: ThinVec ;
1313
@@ -163,6 +163,15 @@ pub(crate) fn build_index<'tcx>(
163163 ) -> Option < RenderTypeId > {
164164 let Cache { ref paths, ref external_paths, ref exact_paths, .. } = * cache;
165165 match id {
166+ RenderTypeId :: Mut => Some ( insert_into_map (
167+ primitives,
168+ kw:: Mut ,
169+ lastpathid,
170+ crate_paths,
171+ ItemType :: Keyword ,
172+ & [ kw:: Mut ] ,
173+ None ,
174+ ) ) ,
166175 RenderTypeId :: DefId ( defid) => {
167176 if let Some ( & ( ref fqp, item_type) ) =
168177 paths. get ( & defid) . or_else ( || external_paths. get ( & defid) )
@@ -765,9 +774,8 @@ fn get_index_type_id(
765774 bounds. get ( 0 ) . map ( |b| RenderTypeId :: DefId ( b. trait_ . def_id ( ) ) )
766775 }
767776 clean:: Primitive ( p) => Some ( RenderTypeId :: Primitive ( p) ) ,
768- clean:: BorrowedRef { ref type_, .. } | clean:: RawPointer ( _, ref type_) => {
769- get_index_type_id ( type_, rgen)
770- }
777+ clean:: BorrowedRef { .. } => Some ( RenderTypeId :: Primitive ( clean:: PrimitiveType :: Reference ) ) ,
778+ clean:: RawPointer ( _, ref type_) => get_index_type_id ( type_, rgen) ,
771779 // The type parameters are converted to generics in `simplify_fn_type`
772780 clean:: Slice ( _) => Some ( RenderTypeId :: Primitive ( clean:: PrimitiveType :: Slice ) ) ,
773781 clean:: Array ( _, _) => Some ( RenderTypeId :: Primitive ( clean:: PrimitiveType :: Array ) ) ,
@@ -833,28 +841,14 @@ fn simplify_fn_type<'tcx, 'a>(
833841 }
834842
835843 // First, check if it's "Self".
836- let mut is_self = false ;
837- let mut arg = if let Some ( self_) = self_ {
838- match & * arg {
839- Type :: BorrowedRef { type_, .. } if type_. is_self_type ( ) => {
840- is_self = true ;
841- self_
842- }
843- type_ if type_. is_self_type ( ) => {
844- is_self = true ;
845- self_
846- }
847- arg => arg,
848- }
844+ let ( is_self, arg) = if let Some ( self_) = self_
845+ && arg. is_self_type ( )
846+ {
847+ ( true , self_)
849848 } else {
850- arg
849+ ( false , arg)
851850 } ;
852851
853- // strip references from the argument type
854- while let Type :: BorrowedRef { type_, .. } = & * arg {
855- arg = & * type_;
856- }
857-
858852 // If this argument is a type parameter and not a trait bound or a type, we need to look
859853 // for its bounds.
860854 if let Type :: Generic ( arg_s) = * arg {
@@ -1027,6 +1021,27 @@ fn simplify_fn_type<'tcx, 'a>(
10271021 bindings : Some ( ty_bindings) ,
10281022 generics : Some ( ty_generics) ,
10291023 } ) ;
1024+ } else if let Type :: BorrowedRef { lifetime : _, mutability, ref type_ } = * arg {
1025+ let mut ty_generics = Vec :: new ( ) ;
1026+ if mutability. is_mut ( ) {
1027+ ty_generics. push ( RenderType {
1028+ id : Some ( RenderTypeId :: Mut ) ,
1029+ generics : None ,
1030+ bindings : None ,
1031+ } ) ;
1032+ }
1033+ simplify_fn_type (
1034+ self_,
1035+ generics,
1036+ & type_,
1037+ tcx,
1038+ recurse + 1 ,
1039+ & mut ty_generics,
1040+ rgen,
1041+ is_return,
1042+ cache,
1043+ ) ;
1044+ res. push ( get_index_type ( arg, ty_generics, rgen) ) ;
10301045 } else {
10311046 // This is not a type parameter. So for example if we have `T, U: Option<T>`, and we're
10321047 // looking at `Option`, we enter this "else" condition, otherwise if it's `T`, we don't.
0 commit comments