@@ -156,7 +156,7 @@ mod method_non_parametric_trait_impl {
156156 struct S1 ;
157157 #[ derive( Debug , Clone , Copy ) ]
158158 struct S2 ;
159- #[ derive( Debug , Clone , Copy ) ]
159+ #[ derive( Debug , Clone , Copy , Default ) ]
160160 struct S3 ;
161161
162162 trait MyTrait < A > {
@@ -196,6 +196,18 @@ mod method_non_parametric_trait_impl {
196196 }
197197 }
198198
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+
199211 impl < I > MyTrait < I > for MyPair < I , S1 > {
200212 // MyTrait<I>::m1
201213 fn m1 ( self ) -> I {
@@ -279,11 +291,14 @@ mod method_non_parametric_trait_impl {
279291 pub fn f ( ) {
280292 let thing_s1 = MyThing { a : S1 } ;
281293 let thing_s2 = MyThing { a : S2 } ;
294+ let thing_s3 = MyThing { a : S3 } ;
282295
283296 // Tests for method resolution
284297
285298 println ! ( "{:?}" , thing_s1. m1( ) ) ; // $ MISSING: method=MyThing<S1>::m1
286299 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) ;
287302
288303 let p1 = MyPair { p1 : S1 , p2 : S1 } ;
289304 println ! ( "{:?}" , p1. m1( ) ) ; // $ MISSING: method=MyTrait<I>::m1
@@ -1073,6 +1088,42 @@ mod borrowed_typed {
10731088 }
10741089}
10751090
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+
10761127fn main ( ) {
10771128 field_access:: f ( ) ;
10781129 method_impl:: f ( ) ;
0 commit comments