File tree 2 files changed +49
-0
lines changed
2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -2378,6 +2378,7 @@ impl From<ast::FloatTy> for PrimitiveType {
2378
2378
impl Clean < Type > for hir:: Ty {
2379
2379
fn clean ( & self , cx : & DocContext ) -> Type {
2380
2380
use rustc:: hir:: * ;
2381
+
2381
2382
match self . node {
2382
2383
TyKind :: Never => Never ,
2383
2384
TyKind :: Ptr ( ref m) => RawPointer ( m. mutbl . clean ( cx) , box m. ty . clean ( cx) ) ,
@@ -2415,6 +2416,14 @@ impl Clean<Type> for hir::Ty {
2415
2416
if let Some ( bounds) = cx. impl_trait_bounds . borrow_mut ( ) . remove ( & did) {
2416
2417
return ImplTrait ( bounds) ;
2417
2418
}
2419
+ } else if let Def :: Existential ( did) = path. def {
2420
+ // This block is for returned impl trait only.
2421
+ if let Some ( node_id) = cx. tcx . hir . as_local_node_id ( did) {
2422
+ let item = cx. tcx . hir . expect_item ( node_id) ;
2423
+ if let hir:: ItemKind :: Existential ( ref ty) = item. node {
2424
+ return ImplTrait ( ty. bounds . clean ( cx) ) ;
2425
+ }
2426
+ }
2418
2427
}
2419
2428
2420
2429
let mut alias = None ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #![ crate_name = "foo" ]
12
+
13
+ pub trait Foo { }
14
+ pub trait Foo2 { }
15
+
16
+ pub struct Bar ;
17
+
18
+ impl Foo for Bar { }
19
+ impl Foo2 for Bar { }
20
+
21
+ // @!has foo/fn.foo.html '//section[@id="main"]//pre' "x: &\'x impl Foo"
22
+ // @!has foo/fn.foo.html '//section[@id="main"]//pre' "-> &\'x impl Foo {"
23
+ pub fn foo < ' x > ( x : & ' x impl Foo ) -> & ' x impl Foo {
24
+ x
25
+ }
26
+
27
+ // @!has foo/fn.foo2.html '//section[@id="main"]//pre' "x: &\'x impl Foo"
28
+ // @!has foo/fn.foo2.html '//section[@id="main"]//pre' '-> impl Foo2 {'
29
+ pub fn foo2 < ' x > ( _x : & ' x impl Foo ) -> impl Foo2 {
30
+ Bar
31
+ }
32
+
33
+ // @!has foo/fn.foo_foo.html '//section[@id="main"]//pre' '-> impl Foo + Foo2 {'
34
+ pub fn foo_foo ( ) -> impl Foo + Foo2 {
35
+ Bar
36
+ }
37
+
38
+ // @!has foo/fn.foo2.html '//section[@id="main"]//pre' "x: &'x (impl Foo + Foo2)"
39
+ pub fn foo_foo_foo < ' x > ( _x : & ' x ( impl Foo + Foo2 ) ) {
40
+ }
You can’t perform that action at this time.
0 commit comments