about summary refs log tree commit diff
path: root/src/test/rustdoc
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2018-10-28 15:33:27 -0400
committerAaron Hill <aa1ronham@gmail.com>2018-10-28 15:33:27 -0400
commit20aa7513835b26256664f409c36611a9bc3b88e4 (patch)
tree7a52f961ba97f844a423e8fe834d4a0e8ba2645c /src/test/rustdoc
parent4f5cfa611d392e87166dfe053ca253c3e822d835 (diff)
downloadrust-20aa7513835b26256664f409c36611a9bc3b88e4.tar.gz
rust-20aa7513835b26256664f409c36611a9bc3b88e4.zip
Choose predicates without inference variables over those with them
Fixes #54705

When constructing synthetic auto trait impls, we may come across
multiple predicates involving the same type, trait, and substitutions.
Since we can only display one of these, we pick the one with the 'most
strict' lifetime paramters. This ensures that the impl we render the
user is actually valid (that is, a struct matching that impl will
actually implement the auto trait in question).

This commit exapnds the definition of 'more strict' to take into account
inference variables. We always choose a predicate without inference
variables over a predicate with inference variables.
Diffstat (limited to 'src/test/rustdoc')
-rw-r--r--src/test/rustdoc/issue-54705.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/rustdoc/issue-54705.rs b/src/test/rustdoc/issue-54705.rs
new file mode 100644
index 00000000000..ccc939657a1
--- /dev/null
+++ b/src/test/rustdoc/issue-54705.rs
@@ -0,0 +1,40 @@
+// 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 ScopeHandle<'scope> {}
+
+
+
+// @has issue_54705/struct.ScopeFutureContents.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'scope, S> \
+// Send for ScopeFutureContents<'scope, S> where S: Sync"
+//
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<'scope, S> \
+// Sync for ScopeFutureContents<'scope, S> where S: Sync"
+pub struct ScopeFutureContents<'scope, S>
+    where S: ScopeHandle<'scope>,
+{
+    dummy: &'scope S,
+    this: Box<ScopeFuture<'scope, S>>,
+}
+
+struct ScopeFuture<'scope, S>
+    where S: ScopeHandle<'scope>,
+{
+    contents: ScopeFutureContents<'scope, S>,
+}
+
+unsafe impl<'scope, S> Send for ScopeFuture<'scope, S>
+    where S: ScopeHandle<'scope>,
+{}
+unsafe impl<'scope, S> Sync for ScopeFuture<'scope, S>
+    where S: ScopeHandle<'scope>,
+{}