about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rustdoc-gui/src/lib2/lib.rs158
-rw-r--r--src/test/rustdoc-gui/type-declation-overflow.goml15
-rw-r--r--src/test/rustdoc-ui/z-help.stdout2
-rw-r--r--src/test/ui/chalkify/bugs/async.rs11
-rw-r--r--src/test/ui/chalkify/bugs/async.stderr76
-rw-r--r--src/test/ui/mir/issue-106062.rs26
-rw-r--r--src/test/ui/mir/issue-106062.stderr16
-rw-r--r--src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs21
-rw-r--r--src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr23
-rw-r--r--src/test/ui/rfc-2397-do-not-recommend/unstable-feature.rs7
-rw-r--r--src/test/ui/rfc-2397-do-not-recommend/unstable-feature.stderr12
11 files changed, 322 insertions, 45 deletions
diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs
index 24aecc70d65..34e67d9d254 100644
--- a/src/test/rustdoc-gui/src/lib2/lib.rs
+++ b/src/test/rustdoc-gui/src/lib2/lib.rs
@@ -183,3 +183,161 @@ impl ItemInfoAlignmentTest {
     #[deprecated]
     pub fn bar() {}
 }
+
+pub mod scroll_traits {
+    use std::iter::*;
+
+    /// Shamelessly (partially) copied from `std::iter::Iterator`.
+    /// It allows us to check that the scroll is working as expected on "hidden" items.
+    pub trait Iterator {
+        type Item;
+
+        fn next(&mut self) -> Option<Self::Item>;
+        fn size_hint(&self) -> (usize, Option<usize>);
+        fn count(self) -> usize
+        where
+            Self: Sized;
+        fn last(self) -> Option<Self::Item>
+        where
+            Self: Sized;
+        fn advance_by(&mut self, n: usize) -> Result<(), usize>;
+        fn nth(&mut self, n: usize) -> Option<Self::Item>;
+        fn step_by(self, step: usize) -> StepBy<Self>
+        where
+            Self: Sized;
+        fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter>
+        where
+            Self: Sized,
+            U: IntoIterator<Item = Self::Item>;
+        fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter>
+        where
+            Self: Sized,
+            U: IntoIterator;
+        fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
+        where
+            Self: Sized,
+            Self::Item: Clone;
+        fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
+        where
+            Self: Sized,
+            G: FnMut() -> Self::Item;
+        fn map<B, F>(self, f: F) -> Map<Self, F>
+        where
+            Self: Sized,
+            F: FnMut(Self::Item) -> B;
+        fn for_each<F>(self, f: F)
+        where
+            Self: Sized,
+            F: FnMut(Self::Item);
+        fn filter<P>(self, predicate: P) -> Filter<Self, P>
+        where
+            Self: Sized,
+            P: FnMut(&Self::Item) -> bool;
+        fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
+        where
+            Self: Sized,
+            F: FnMut(Self::Item) -> Option<B>;
+        fn enumerate(self) -> Enumerate<Self>
+        where
+            Self: Sized;
+        fn peekable(self) -> Peekable<Self>
+        where
+            Self: Sized;
+        fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
+        where
+            Self: Sized,
+            P: FnMut(&Self::Item) -> bool;
+        fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
+        where
+            Self: Sized,
+            P: FnMut(&Self::Item) -> bool;
+        fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
+        where
+            Self: Sized,
+            P: FnMut(Self::Item) -> Option<B>;
+        fn skip(self, n: usize) -> Skip<Self>
+        where
+            Self: Sized;
+        fn take(self, n: usize) -> Take<Self>
+        where
+            Self: Sized;
+        fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
+        where
+            Self: Sized,
+            F: FnMut(&mut St, Self::Item) -> Option<B>;
+        fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
+        where
+            Self: Sized,
+            U: IntoIterator,
+            F: FnMut(Self::Item) -> U;
+        fn flatten(self) -> Flatten<Self>
+        where
+            Self: Sized,
+            Self::Item: IntoIterator;
+        fn fuse(self) -> Fuse<Self>
+        where
+            Self: Sized;
+        fn inspect<F>(self, f: F) -> Inspect<Self, F>
+        where
+            Self: Sized,
+            F: FnMut(&Self::Item);
+        fn by_ref(&mut self) -> &mut Self
+        where
+            Self: Sized;
+        fn collect<B: FromIterator<Self::Item>>(self) -> B
+        where
+            Self: Sized;
+        fn collect_into<E: Extend<Self::Item>>(self, collection: &mut E) -> &mut E
+        where
+            Self: Sized;
+        fn partition<B, F>(self, f: F) -> (B, B)
+        where
+            Self: Sized,
+            B: Default + Extend<Self::Item>,
+            F: FnMut(&Self::Item) -> bool;
+        fn partition_in_place<'a, T: 'a, P>(mut self, predicate: P) -> usize
+        where
+            Self: Sized + DoubleEndedIterator<Item = &'a mut T>,
+            P: FnMut(&T) -> bool;
+        fn is_partitioned<P>(mut self, mut predicate: P) -> bool
+        where
+            Self: Sized,
+            P: FnMut(Self::Item) -> bool;
+        fn fold<B, F>(mut self, init: B, mut f: F) -> B
+        where
+            Self: Sized,
+            F: FnMut(B, Self::Item) -> B;
+        fn reduce<F>(mut self, f: F) -> Option<Self::Item>
+        where
+            Self: Sized,
+            F: FnMut(Self::Item, Self::Item) -> Self::Item;
+        fn all<F>(&mut self, f: F) -> bool
+        where
+            Self: Sized,
+            F: FnMut(Self::Item) -> bool;
+        fn any<F>(&mut self, f: F) -> bool
+        where
+            Self: Sized,
+            F: FnMut(Self::Item) -> bool;
+        fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
+        where
+            Self: Sized,
+            P: FnMut(&Self::Item) -> bool;
+        fn find_map<B, F>(&mut self, f: F) -> Option<B>
+        where
+            Self: Sized,
+            F: FnMut(Self::Item) -> Option<B>;
+        fn position<P>(&mut self, predicate: P) -> Option<usize>
+        where
+            Self: Sized,
+            P: FnMut(Self::Item) -> bool;
+        /// We will scroll to "string" to ensure it scrolls as expected.
+        fn this_is_a_method_with_a_long_name_returning_something() -> String;
+    }
+
+    /// This one doesn't have hidden items (because there are too many) so we can also confirm that it
+    /// scrolls as expected.
+    pub trait TraitWithLongItemsName {
+        fn this_is_a_method_with_a_long_name_returning_something() -> String;
+    }
+}
diff --git a/src/test/rustdoc-gui/type-declation-overflow.goml b/src/test/rustdoc-gui/type-declation-overflow.goml
index 9b60bc04738..644429c014c 100644
--- a/src/test/rustdoc-gui/type-declation-overflow.goml
+++ b/src/test/rustdoc-gui/type-declation-overflow.goml
@@ -59,3 +59,18 @@ goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLon
 compare-elements-position-false: (".main-heading h1", ".main-heading .out-of-band", ("y"))
 goto: "file://" + |DOC_PATH| + "/lib2/index.html"
 compare-elements-position-false: (".main-heading h1", ".main-heading .out-of-band", ("y"))
+
+// Now we will check that the scrolling is working.
+// First on an item with "hidden methods".
+goto: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.Iterator.html"
+
+click: ".item-decl .type-contents-toggle"
+assert-property: (".item-decl > pre", {"scrollLeft": 0})
+scroll-to: "//*[@class='item-decl']//details/a[text()='String']"
+assert-property-false: (".item-decl > pre", {"scrollLeft": 0})
+
+// Then on an item without "hidden methods".
+goto: "file://" + |DOC_PATH| + "/lib2/scroll_traits/trait.TraitWithLongItemsName.html"
+assert-property: (".item-decl > pre", {"scrollLeft": 0})
+scroll-to: "//*[@class='item-decl']//code/a[text()='String']"
+assert-property-false: (".item-decl > pre", {"scrollLeft": 0})
diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout
index 537dc92be19..43f30f3d6e8 100644
--- a/src/test/rustdoc-ui/z-help.stdout
+++ b/src/test/rustdoc-ui/z-help.stdout
@@ -1,4 +1,4 @@
-    -Z                          allow-features=val -- only allow the listed language features to be enabled in code (space separated)
+    -Z                          allow-features=val -- only allow the listed language features to be enabled in code (comma separated)
     -Z                       always-encode-mir=val -- encode MIR of all functions into the crate metadata (default: no)
     -Z                            asm-comments=val -- generate comments into the assembly (may change behavior) (default: no)
     -Z                       assert-incr-state=val -- assert that the incremental cache is in given state: either `loaded` or `not-loaded`.
diff --git a/src/test/ui/chalkify/bugs/async.rs b/src/test/ui/chalkify/bugs/async.rs
index ed0f5dc9bd3..86ce42631b4 100644
--- a/src/test/ui/chalkify/bugs/async.rs
+++ b/src/test/ui/chalkify/bugs/async.rs
@@ -1,6 +1,13 @@
 // check-fail
-// known-bug: unknown
-// compile-flags: -Z trait-solver=chalk --edition=2021
+// known-bug
+// unset-rustc-env:RUST_BACKTRACE
+// compile-flags:-Z trait-solver=chalk --edition=2021
+// error-pattern:stack backtrace:
+// failure-status:101
+// normalize-stderr-test "note: .*" -> ""
+// normalize-stderr-test "thread 'rustc' .*" -> ""
+// normalize-stderr-test "  .*\n" -> ""
+// normalize-stderr-test "DefId([^)]*)" -> "..."
 
 fn main() -> () {}
 
diff --git a/src/test/ui/chalkify/bugs/async.stderr b/src/test/ui/chalkify/bugs/async.stderr
index eda867f4159..7e2466dece4 100644
--- a/src/test/ui/chalkify/bugs/async.stderr
+++ b/src/test/ui/chalkify/bugs/async.stderr
@@ -1,48 +1,40 @@
-error[E0277]: `[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future
-  --> $DIR/async.rs:7:29
-   |
-LL |   async fn foo(x: u32) -> u32 {
-   |  _____________________________-
-LL | |     x
-LL | | }
-   | | ^
-   | | |
-   | |_`[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future
-   |   required by a bound introduced by this call
-   |
-   = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:7:29: 9:2]`
-   = note: [async fn body@$DIR/async.rs:7:29: 9:2] must be a future or must implement `IntoFuture` to be awaited
-note: required by a bound in `identity_future`
-  --> $SRC_DIR/core/src/future/mod.rs:LL:COL
-
-error[E0277]: the size for values of type `<[async fn body@$DIR/async.rs:7:29: 9:2] as Future>::Output` cannot be known at compilation time
-  --> $DIR/async.rs:7:29
-   |
-LL |   async fn foo(x: u32) -> u32 {
-   |  _____________________________^
-LL | |     x
-LL | | }
-   | |_^ doesn't have a size known at compile-time
-   |
-   = help: the trait `Sized` is not implemented for `<[async fn body@$DIR/async.rs:7:29: 9:2] as Future>::Output`
-note: required by a bound in `identity_future`
-  --> $SRC_DIR/core/src/future/mod.rs:LL:COL
-
-error[E0277]: `[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future
-  --> $DIR/async.rs:7:25
-   |
+error[E0277]: `[async fn body@$DIR/async.rs:14:29: 16:2]` is not a future
+LL |LL | |LL | | }
+
+
+error[E0277]: the size for values of type `<[async fn body@$DIR/async.rs:14:29: 16:2] as Future>::Output` cannot be known at compilation time
+LL |LL | |LL | | }
+
+
+error[E0277]: `[async fn body@$DIR/async.rs:14:29: 16:2]` is not a future
 LL | async fn foo(x: u32) -> u32 {
-   |                         ^^^ `[async fn body@$DIR/async.rs:7:29: 9:2]` is not a future
-   |
-   = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:7:29: 9:2]`
-   = note: [async fn body@$DIR/async.rs:7:29: 9:2] must be a future or must implement `IntoFuture` to be awaited
-
-error[E0280]: the requirement `<[async fn body@$DIR/async.rs:7:29: 9:2] as Future>::Output == u32` is not satisfied
-  --> $DIR/async.rs:7:25
-   |
+
+error: internal compiler error: compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:1114:25: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [[async fn body@$DIR/async.rs:14:29: 16:2]], def_id: ...), _use_mk_alias_ty_instead: () }, Term::Ty(u32)), []), depth=0)`
 LL | async fn foo(x: u32) -> u32 {
-   |                         ^^^
 
+
+stack backtrace:
+
+
+
+
+
+
+
+
+
+query stack during panic:
+#0 [typeck] type-checking `foo`
+#1 [thir_body] building THIR for `foo`
+#2 [mir_built] building MIR for `foo`
+#3 [unsafety_check_result] unsafety-checking `foo`
+#4 [mir_const] preparing `foo` for borrow checking
+#5 [mir_promoted] processing MIR for `foo`
+#6 [mir_borrowck] borrow-checking `foo`
+#7 [type_of] computing type of `foo::{opaque#0}`
+#8 [check_mod_item_types] checking item types in top-level module
+#9 [analysis] running analysis passes on this crate
+end of query stack
 error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/mir/issue-106062.rs b/src/test/ui/mir/issue-106062.rs
new file mode 100644
index 00000000000..621ba566ee3
--- /dev/null
+++ b/src/test/ui/mir/issue-106062.rs
@@ -0,0 +1,26 @@
+// edition:2018
+
+use std::{future::Future, marker::PhantomData};
+
+fn spawn<T>(future: T) -> PhantomData<T::Output>
+where
+    T: Future,
+{
+    loop {}
+}
+
+#[derive(Debug)]
+struct IncomingServer {}
+impl IncomingServer {
+    async fn connection_handler(handler: impl Sized) -> Result<Ok, std::io::Error> {
+        //~^ ERROR expected type, found variant `Ok` [E0573]
+        loop {}
+    }
+    async fn spawn(&self, request_handler: impl Sized) {
+        async move {
+            spawn(Self::connection_handler(&request_handler));
+        };
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/mir/issue-106062.stderr b/src/test/ui/mir/issue-106062.stderr
new file mode 100644
index 00000000000..2f6524d03e0
--- /dev/null
+++ b/src/test/ui/mir/issue-106062.stderr
@@ -0,0 +1,16 @@
+error[E0573]: expected type, found variant `Ok`
+  --> $DIR/issue-106062.rs:15:64
+   |
+LL |     async fn connection_handler(handler: impl Sized) -> Result<Ok, std::io::Error> {
+   |                                                                ^^ not a type
+   |
+help: try using the variant's enum
+   |
+LL |     async fn connection_handler(handler: impl Sized) -> Result<core::result::Result, std::io::Error> {
+   |                                                                ~~~~~~~~~~~~~~~~~~~~
+LL |     async fn connection_handler(handler: impl Sized) -> Result<std::result::Result, std::io::Error> {
+   |                                                                ~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0573`.
diff --git a/src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs b/src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs
new file mode 100644
index 00000000000..5053c115b45
--- /dev/null
+++ b/src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs
@@ -0,0 +1,21 @@
+#![feature(do_not_recommend)]
+
+pub trait Foo {
+}
+
+impl Foo for i32 {
+}
+
+pub trait Bar {
+}
+
+#[do_not_recommend]
+impl<T: Foo> Bar for T {
+}
+
+fn stuff<T: Bar>(_: T) {}
+
+fn main() {
+    stuff(1u8);
+    //~^ the trait bound `u8: Foo` is not satisfied
+}
diff --git a/src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr b/src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr
new file mode 100644
index 00000000000..2749add82ac
--- /dev/null
+++ b/src/test/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr
@@ -0,0 +1,23 @@
+error[E0277]: the trait bound `u8: Foo` is not satisfied
+  --> $DIR/feature-gate-do_not_recommend.rs:19:11
+   |
+LL |     stuff(1u8);
+   |     ----- ^^^ the trait `Foo` is not implemented for `u8`
+   |     |
+   |     required by a bound introduced by this call
+   |
+   = help: the trait `Foo` is implemented for `i32`
+note: required for `u8` to implement `Bar`
+  --> $DIR/feature-gate-do_not_recommend.rs:13:14
+   |
+LL | impl<T: Foo> Bar for T {
+   |              ^^^     ^
+note: required by a bound in `stuff`
+  --> $DIR/feature-gate-do_not_recommend.rs:16:13
+   |
+LL | fn stuff<T: Bar>(_: T) {}
+   |             ^^^ required by this bound in `stuff`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/rfc-2397-do-not-recommend/unstable-feature.rs b/src/test/ui/rfc-2397-do-not-recommend/unstable-feature.rs
new file mode 100644
index 00000000000..b816c4a19da
--- /dev/null
+++ b/src/test/ui/rfc-2397-do-not-recommend/unstable-feature.rs
@@ -0,0 +1,7 @@
+#[do_not_recommend]
+//~^ ERROR the `#[do_not_recommend]` attribute is an experimental feature
+trait Foo {
+}
+
+fn main() {
+}
diff --git a/src/test/ui/rfc-2397-do-not-recommend/unstable-feature.stderr b/src/test/ui/rfc-2397-do-not-recommend/unstable-feature.stderr
new file mode 100644
index 00000000000..425d7e4bca0
--- /dev/null
+++ b/src/test/ui/rfc-2397-do-not-recommend/unstable-feature.stderr
@@ -0,0 +1,12 @@
+error[E0658]: the `#[do_not_recommend]` attribute is an experimental feature
+  --> $DIR/unstable-feature.rs:1:1
+   |
+LL | #[do_not_recommend]
+   | ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #51992 <https://github.com/rust-lang/rust/issues/51992> for more information
+   = help: add `#![feature(do_not_recommend)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.