File tree 3 files changed +52
-1
lines changed
compiler/rustc_middle/src/ty
src/test/ui/impl-trait/in-trait
3 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -430,7 +430,9 @@ impl<'tcx> TyCtxt<'tcx> {
430
430
( ty:: Projection ( _) , ty:: Projection ( _) ) => {
431
431
diag. note ( "an associated type was expected, but a different one was found" ) ;
432
432
}
433
- ( ty:: Param ( p) , ty:: Projection ( proj) ) | ( ty:: Projection ( proj) , ty:: Param ( p) ) => {
433
+ ( ty:: Param ( p) , ty:: Projection ( proj) ) | ( ty:: Projection ( proj) , ty:: Param ( p) )
434
+ if self . def_kind ( proj. item_def_id ) != DefKind :: ImplTraitPlaceholder =>
435
+ {
434
436
let generics = self . generics_of ( body_owner_def_id) ;
435
437
let p_span = self . def_span ( generics. type_param ( p, self ) . def_id ) ;
436
438
if !sp. contains ( p_span) {
Original file line number Diff line number Diff line change
1
+ // FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not.
2
+ // But we fixed an ICE anyways.
3
+
4
+ #![ feature( specialization) ]
5
+ #![ feature( return_position_impl_trait_in_trait) ]
6
+ #![ allow( incomplete_features) ]
7
+
8
+ trait Foo {
9
+ fn bar ( & self ) -> impl Sized ;
10
+ }
11
+
12
+ default impl < U > Foo for U
13
+ where
14
+ U : Copy ,
15
+ {
16
+ fn bar ( & self ) -> U {
17
+ //~^ ERROR method `bar` has an incompatible type for trait
18
+ * self
19
+ }
20
+ }
21
+
22
+ impl Foo for i32 { }
23
+
24
+ fn main ( ) {
25
+ 1i32 . bar ( ) ;
26
+ }
Original file line number Diff line number Diff line change
1
+ error[E0053]: method `bar` has an incompatible type for trait
2
+ --> $DIR/specialization-broken.rs:16:22
3
+ |
4
+ LL | default impl<U> Foo for U
5
+ | - this type parameter
6
+ ...
7
+ LL | fn bar(&self) -> U {
8
+ | ^
9
+ | |
10
+ | expected associated type, found type parameter `U`
11
+ | help: change the output type to match the trait: `impl Sized`
12
+ |
13
+ note: type in trait
14
+ --> $DIR/specialization-broken.rs:9:22
15
+ |
16
+ LL | fn bar(&self) -> impl Sized;
17
+ | ^^^^^^^^^^
18
+ = note: expected fn pointer `fn(&U) -> impl Sized`
19
+ found fn pointer `fn(&U) -> U`
20
+
21
+ error: aborting due to previous error
22
+
23
+ For more information about this error, try `rustc --explain E0053`.
You can’t perform that action at this time.
0 commit comments