@@ -7,7 +7,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
7
7
use rustc_middle:: ty:: TyCtxt ;
8
8
use rustc_span:: def_id:: DefId ;
9
9
use rustc_span:: sym;
10
- use rustc_span:: symbol:: Symbol ;
10
+ use rustc_span:: symbol:: { kw , Symbol } ;
11
11
use serde:: ser:: { Serialize , SerializeSeq , SerializeStruct , Serializer } ;
12
12
use thin_vec:: ThinVec ;
13
13
@@ -163,6 +163,15 @@ pub(crate) fn build_index<'tcx>(
163
163
) -> Option < RenderTypeId > {
164
164
let Cache { ref paths, ref external_paths, ref exact_paths, .. } = * cache;
165
165
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
+ ) ) ,
166
175
RenderTypeId :: DefId ( defid) => {
167
176
if let Some ( & ( ref fqp, item_type) ) =
168
177
paths. get ( & defid) . or_else ( || external_paths. get ( & defid) )
@@ -765,9 +774,8 @@ fn get_index_type_id(
765
774
bounds. get ( 0 ) . map ( |b| RenderTypeId :: DefId ( b. trait_ . def_id ( ) ) )
766
775
}
767
776
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) ,
771
779
// The type parameters are converted to generics in `simplify_fn_type`
772
780
clean:: Slice ( _) => Some ( RenderTypeId :: Primitive ( clean:: PrimitiveType :: Slice ) ) ,
773
781
clean:: Array ( _, _) => Some ( RenderTypeId :: Primitive ( clean:: PrimitiveType :: Array ) ) ,
@@ -833,28 +841,14 @@ fn simplify_fn_type<'tcx, 'a>(
833
841
}
834
842
835
843
// 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_)
849
848
} else {
850
- arg
849
+ ( false , arg)
851
850
} ;
852
851
853
- // strip references from the argument type
854
- while let Type :: BorrowedRef { type_, .. } = & * arg {
855
- arg = & * type_;
856
- }
857
-
858
852
// If this argument is a type parameter and not a trait bound or a type, we need to look
859
853
// for its bounds.
860
854
if let Type :: Generic ( arg_s) = * arg {
@@ -1027,6 +1021,27 @@ fn simplify_fn_type<'tcx, 'a>(
1027
1021
bindings : Some ( ty_bindings) ,
1028
1022
generics : Some ( ty_generics) ,
1029
1023
} ) ;
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) ) ;
1030
1045
} else {
1031
1046
// This is not a type parameter. So for example if we have `T, U: Option<T>`, and we're
1032
1047
// looking at `Option`, we enter this "else" condition, otherwise if it's `T`, we don't.
0 commit comments