about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-06 01:53:58 +0000
committerbors <bors@rust-lang.org>2018-08-06 01:53:58 +0000
commitaa1e6db70900cf5d11a843bc4234de0548677aba (patch)
tree84330e513f53e39adc19ecae49a64c843a658a44 /src/test
parente9fa9f5a6a7dede07b71987b893065f290b7acf7 (diff)
parent7e77d19905ebfcc76c19301587baf2c53acf2fd9 (diff)
downloadrust-aa1e6db70900cf5d11a843bc4234de0548677aba.tar.gz
rust-aa1e6db70900cf5d11a843bc4234de0548677aba.zip
Auto merge of #53002 - QuietMisdreavus:brother-may-i-have-some-loops, r=pnkfelix
make `everybody_loops` preserve item declarations

First half of https://github.com/rust-lang/rust/issues/52545.

`everybody_loops` is used by rustdoc to ensure we don't contain erroneous references to platform APIs if one of its uses is pulled in by `#[doc(cfg)]`. However, you can also implement traits for public types inside of functions. This is used by Diesel (probably others, but they were the example that was reported) to get around a recent macro hygiene fix, which has caused their crate to fail to document. While this won't make the traits show up in documentation (that step comes later), it will at least allow files to be generated.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rustdoc/traits-in-bodies.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/rustdoc/traits-in-bodies.rs b/src/test/rustdoc/traits-in-bodies.rs
new file mode 100644
index 00000000000..3acf4af5fd2
--- /dev/null
+++ b/src/test/rustdoc/traits-in-bodies.rs
@@ -0,0 +1,29 @@
+// 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.
+
+//prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it
+//didn't see that `SomeStruct` implemented `Clone`
+
+//FIXME(misdreavus): whenever rustdoc shows traits impl'd inside bodies, make sure this test
+//reflects that
+
+pub struct Bounded<T: Clone>(T);
+
+pub struct SomeStruct;
+
+fn asdf() -> Bounded<SomeStruct> {
+    impl Clone for SomeStruct {
+        fn clone(&self) -> SomeStruct {
+            SomeStruct
+        }
+    }
+
+    Bounded(SomeStruct)
+}