@@ -156,7 +156,7 @@ mod method_non_parametric_trait_impl {
156
156
struct S1 ;
157
157
#[ derive( Debug , Clone , Copy ) ]
158
158
struct S2 ;
159
- #[ derive( Debug , Clone , Copy ) ]
159
+ #[ derive( Debug , Clone , Copy , Default ) ]
160
160
struct S3 ;
161
161
162
162
trait MyTrait < A > {
@@ -196,6 +196,18 @@ mod method_non_parametric_trait_impl {
196
196
}
197
197
}
198
198
199
+ // Implementation where the type parameter `TD` only occurs in the
200
+ // implemented trait and not the implementing type.
201
+ impl < TD > MyTrait < TD > for MyThing < S3 >
202
+ where
203
+ TD : Default ,
204
+ {
205
+ // MyThing<S3>::m1
206
+ fn m1 ( self ) -> TD {
207
+ TD :: default ( )
208
+ }
209
+ }
210
+
199
211
impl < I > MyTrait < I > for MyPair < I , S1 > {
200
212
// MyTrait<I>::m1
201
213
fn m1 ( self ) -> I {
@@ -279,11 +291,14 @@ mod method_non_parametric_trait_impl {
279
291
pub fn f ( ) {
280
292
let thing_s1 = MyThing { a : S1 } ;
281
293
let thing_s2 = MyThing { a : S2 } ;
294
+ let thing_s3 = MyThing { a : S3 } ;
282
295
283
296
// Tests for method resolution
284
297
285
298
println ! ( "{:?}" , thing_s1. m1( ) ) ; // $ MISSING: method=MyThing<S1>::m1
286
299
println ! ( "{:?}" , thing_s2. m1( ) . a) ; // $ MISSING: method=MyThing<S2>::m1 fieldof=MyThing
300
+ let s3: S3 = thing_s3. m1 ( ) ; // $ MISSING: method=MyThing<S3>::m1
301
+ println ! ( "{:?}" , s3) ;
287
302
288
303
let p1 = MyPair { p1 : S1 , p2 : S1 } ;
289
304
println ! ( "{:?}" , p1. m1( ) ) ; // $ MISSING: method=MyTrait<I>::m1
@@ -1073,6 +1088,42 @@ mod borrowed_typed {
1073
1088
}
1074
1089
}
1075
1090
1091
+ mod encoder {
1092
+ #[ derive( Clone , Debug , Eq , PartialEq , Ord , PartialOrd , Hash ) ]
1093
+ pub struct LinesCodec {
1094
+ is_discarding : bool ,
1095
+ }
1096
+
1097
+ impl LinesCodec {
1098
+ pub fn new ( ) -> LinesCodec {
1099
+ LinesCodec {
1100
+ is_discarding : false ,
1101
+ }
1102
+ }
1103
+ }
1104
+
1105
+ pub trait Encoder < Item > {
1106
+ fn encode ( & mut self , item : Item ) -> bool ;
1107
+ }
1108
+
1109
+ // Implementation where the type parameter `T` only occurs in the
1110
+ // implemented trait and not the implementing type.
1111
+ impl < T > Encoder < T > for LinesCodec
1112
+ where
1113
+ T : AsRef < str > ,
1114
+ {
1115
+ // LinesCodec::encode
1116
+ fn encode ( & mut self , _line : T ) -> bool {
1117
+ "hello" . eq ( _line. as_ref ( ) )
1118
+ }
1119
+ }
1120
+
1121
+ fn lines_encoder ( ) {
1122
+ let mut codec = LinesCodec :: new ( ) ;
1123
+ codec. encode ( "line 1" ) ; // $ method=LinesCodec::encode
1124
+ }
1125
+ }
1126
+
1076
1127
fn main ( ) {
1077
1128
field_access:: f ( ) ;
1078
1129
method_impl:: f ( ) ;
0 commit comments