File tree 3 files changed +39
-1
lines changed
compiler/rustc_middle/src/ty/print
src/test/ui/impl-trait/in-trait
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -927,7 +927,7 @@ pub trait PrettyPrinter<'tcx>:
927
927
// unless we can find out what generator return type it comes from.
928
928
let term = if let Some ( ty) = term. skip_binder ( ) . ty ( )
929
929
&& let ty:: Projection ( proj) = ty. kind ( )
930
- && let assoc = tcx. associated_item ( proj. item_def_id )
930
+ && let Some ( assoc) = tcx. opt_associated_item ( proj. item_def_id )
931
931
&& assoc. trait_container ( tcx) == tcx. lang_items ( ) . gen_trait ( )
932
932
&& assoc. name == rustc_span:: sym:: Return
933
933
{
Original file line number Diff line number Diff line change
1
+ #![ feature( return_position_impl_trait_in_trait) ]
2
+ #![ allow( incomplete_features) ]
3
+
4
+ use std:: fmt:: Display ;
5
+ use std:: ops:: Deref ;
6
+
7
+ trait Foo {
8
+ fn bar ( self ) -> impl Deref < Target = impl Display + ?Sized > ;
9
+ }
10
+
11
+ struct A ;
12
+
13
+ impl Foo for A {
14
+ fn bar ( self ) -> & ' static str {
15
+ "Hello, world"
16
+ }
17
+ }
18
+
19
+ fn foo < T : Foo > ( t : T ) {
20
+ let ( ) = t. bar ( ) ;
21
+ //~^ ERROR mismatched types
22
+ }
23
+
24
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/issue-102571.rs:20:9
3
+ |
4
+ LL | let () = t.bar();
5
+ | ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
6
+ | |
7
+ | expected associated type, found `()`
8
+ |
9
+ = note: expected associated type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
10
+ found unit type `()`
11
+
12
+ error: aborting due to previous error
13
+
14
+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments