summary refs log tree commit diff
path: root/src/test/rustdoc
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-28 17:55:12 +0200
committerGitHub <noreply@github.com>2018-03-28 17:55:12 +0200
commit6ca14660affb3a8eace557f8dfb27a520be38fd8 (patch)
treeed8948c3dbe5dc2e34277930be3b44e9aedf241c /src/test/rustdoc
parentc17ab378e93c1205435f66518621ea05721e37bd (diff)
parent33dceaa24409951dfe7607c580de6fd504932c90 (diff)
downloadrust-6ca14660affb3a8eace557f8dfb27a520be38fd8.tar.gz
rust-6ca14660affb3a8eace557f8dfb27a520be38fd8.zip
Rollup merge of #49427 - Manishearth:rustdoc-impl-trait-extern, r=GuillaumeGomez
Correctly handle impl trait in external items in rustdoc

fixes #49373

r? @QuietMisdreavus
Diffstat (limited to 'src/test/rustdoc')
-rw-r--r--src/test/rustdoc/auxiliary/extern-impl-trait.rs37
-rw-r--r--src/test/rustdoc/extern-impl-trait.rs21
2 files changed, 58 insertions, 0 deletions
diff --git a/src/test/rustdoc/auxiliary/extern-impl-trait.rs b/src/test/rustdoc/auxiliary/extern-impl-trait.rs
new file mode 100644
index 00000000000..ba6c3e95695
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/extern-impl-trait.rs
@@ -0,0 +1,37 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub trait Foo {
+    type Associated;
+}
+
+pub struct X;
+pub struct Y;
+
+
+impl Foo for X {
+    type Associated = ();
+}
+
+impl Foo for Y {
+    type Associated = ();
+}
+
+impl X {
+    pub fn returns_sized<'a>(&'a self) -> impl Foo<Associated=()> + 'a {
+        X
+    }
+}
+
+impl Y {
+    pub fn returns_unsized<'a>(&'a self) -> Box<impl ?Sized + Foo<Associated=()> + 'a> {
+        Box::new(X)
+    }
+}
diff --git a/src/test/rustdoc/extern-impl-trait.rs b/src/test/rustdoc/extern-impl-trait.rs
new file mode 100644
index 00000000000..02a8e962fe1
--- /dev/null
+++ b/src/test/rustdoc/extern-impl-trait.rs
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:extern-impl-trait.rs
+
+#![crate_name = "foo"]
+
+extern crate extern_impl_trait;
+
+// @has 'foo/struct.X.html' '//code' "impl Foo<Associated = ()> + 'a"
+pub use extern_impl_trait::X;
+
+// @has 'foo/struct.Y.html' '//code' "impl ?Sized + Foo<Associated = ()> + 'a"
+pub use extern_impl_trait::Y;