about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-05 03:43:08 +0000
committerbors <bors@rust-lang.org>2023-08-05 03:43:08 +0000
commitfca59ab5f0e7df7d816bed77a32abc0045ebe80b (patch)
tree7cecb4fcb84be7647ce77a95d4047223804f13d9 /tests
parent90f0b24ad3e7fc0dc0e419c9da30d74629cd5736 (diff)
parent3222084f58f8b9a88ce9d5c162ab25e52a193cf6 (diff)
downloadrust-fca59ab5f0e7df7d816bed77a32abc0045ebe80b.tar.gz
rust-fca59ab5f0e7df7d816bed77a32abc0045ebe80b.zip
Auto merge of #114492 - compiler-errors:rollup-lp4sfla, r=compiler-errors
Rollup of 5 pull requests

Successful merges:

 - #114287 (update overflow handling in the new trait solver)
 - #114475 (Migrate GUI colors test to original CSS color format)
 - #114482 (Fix ui-fulldeps missing the `internal_features` lint on stage 0)
 - #114490 (Fix a typo in the error reporting for sealed traits.)
 - #114491 (Rename issue #114423 test files to include context)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc-gui/run-on-hover.goml12
-rw-r--r--tests/ui/dyn-star/param-env-region-infer.current.stderr2
-rw-r--r--tests/ui/dyn-star/param-env-region-infer.next.stderr30
-rw-r--r--tests/ui/dyn-star/param-env-region-infer.rs9
-rw-r--r--tests/ui/privacy/sealed-traits/sealed-trait-local.stderr2
-rw-r--r--tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.rs32
-rw-r--r--tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.stderr23
-rw-r--r--tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.rs69
-rw-r--r--tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.stderr16
-rw-r--r--tests/ui/traits/new-solver/overflow/global-cache.rs23
-rw-r--r--tests/ui/traits/new-solver/overflow/global-cache.stderr16
-rw-r--r--tests/ui/typeck/issue-114423-ice-regression-in-suggestion.rs (renamed from tests/ui/typeck/issue-114423.rs)0
-rw-r--r--tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr (renamed from tests/ui/typeck/issue-114423.stderr)12
13 files changed, 198 insertions, 48 deletions
diff --git a/tests/rustdoc-gui/run-on-hover.goml b/tests/rustdoc-gui/run-on-hover.goml
index b5fc49eacac..1f87febcec6 100644
--- a/tests/rustdoc-gui/run-on-hover.goml
+++ b/tests/rustdoc-gui/run-on-hover.goml
@@ -33,22 +33,22 @@ define-function: (
 
 call-function: ("check-run-button", {
     "theme": "ayu",
-    "color": "rgb(120, 135, 151)",
+    "color": "#788797",
     "background": "rgba(57, 175, 215, 0.09)",
-    "hover_color": "rgb(197, 197, 197)",
+    "hover_color": "#c5c5c5",
     "hover_background": "rgba(57, 175, 215, 0.37)",
 })
 call-function: ("check-run-button", {
     "theme": "dark",
-    "color": "rgb(222, 222, 222)",
+    "color": "#dedede",
     "background": "rgba(78, 139, 202, 0.2)",
-    "hover_color": "rgb(222, 222, 222)",
+    "hover_color": "#dedede",
     "hover_background": "rgb(78, 139, 202)",
 })
 call-function: ("check-run-button", {
     "theme": "light",
-    "color": "rgb(245, 245, 245)",
+    "color": "#f5f5f5",
     "background": "rgba(78, 139, 202, 0.2)",
-    "hover_color": "rgb(245, 245, 245)",
+    "hover_color": "#f5f5f5",
     "hover_background": "rgb(78, 139, 202)",
 })
diff --git a/tests/ui/dyn-star/param-env-region-infer.current.stderr b/tests/ui/dyn-star/param-env-region-infer.current.stderr
index 902053ecfef..b982be45196 100644
--- a/tests/ui/dyn-star/param-env-region-infer.current.stderr
+++ b/tests/ui/dyn-star/param-env-region-infer.current.stderr
@@ -1,5 +1,5 @@
 error[E0282]: type annotations needed
-  --> $DIR/param-env-region-infer.rs:18:10
+  --> $DIR/param-env-region-infer.rs:19:10
    |
 LL |     t as _
    |          ^ cannot infer type
diff --git a/tests/ui/dyn-star/param-env-region-infer.next.stderr b/tests/ui/dyn-star/param-env-region-infer.next.stderr
deleted file mode 100644
index 28aec533a00..00000000000
--- a/tests/ui/dyn-star/param-env-region-infer.next.stderr
+++ /dev/null
@@ -1,30 +0,0 @@
-error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}`
-  --> $DIR/param-env-region-infer.rs:16:60
-   |
-LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a {
-   |                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...which requires type-checking `make_dyn_star`...
-  --> $DIR/param-env-region-infer.rs:16:1
-   |
-LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: ...which requires computing layout of `make_dyn_star::{opaque#0}`...
-   = note: ...which requires normalizing `make_dyn_star::{opaque#0}`...
-   = note: ...which again requires computing type of `make_dyn_star::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in top-level module
-  --> $DIR/param-env-region-infer.rs:10:1
-   |
-LL | / #![feature(dyn_star, pointer_like_trait)]
-LL | | #![allow(incomplete_features)]
-LL | |
-LL | | use std::fmt::Debug;
-...  |
-LL | |
-LL | | fn main() {}
-   | |____________^
-   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/dyn-star/param-env-region-infer.rs b/tests/ui/dyn-star/param-env-region-infer.rs
index 537473abc3a..50dec94d25b 100644
--- a/tests/ui/dyn-star/param-env-region-infer.rs
+++ b/tests/ui/dyn-star/param-env-region-infer.rs
@@ -1,9 +1,10 @@
-// revisions: current next
-// Need `-Zdeduplicate-diagnostics=yes` because the number of cycle errors
-// emitted is for some horrible reason platform-specific.
-//[next] compile-flags: -Ztrait-solver=next -Zdeduplicate-diagnostics=yes
+// revisions: current
 // incremental
 
+// FIXME(-Ztrait-solver=next): THis currently results in unstable query results:
+// `normalizes-to(opaque, opaque)` changes from `Maybe(Ambiguous)` to `Maybe(Overflow)`
+// once the hidden type of the opaque is already defined to be itself.
+
 // checks that we don't ICE if there are region inference variables in the environment
 // when computing `PointerLike` builtin candidates.
 
diff --git a/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr
index d1052ce3508..5f8076fc84d 100644
--- a/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr
+++ b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr
@@ -9,7 +9,7 @@ note: required by a bound in `Sealed`
    |
 LL |     pub trait Sealed: self::b::Hidden {
    |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
-   = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a::b::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
+   = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `a::b::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
 
 error: aborting due to previous error
 
diff --git a/tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.rs b/tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.rs
new file mode 100644
index 00000000000..fcafdcf637a
--- /dev/null
+++ b/tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.rs
@@ -0,0 +1,32 @@
+// compile-flags: -Ztrait-solver=next
+
+// Proving `W<?0>: Trait` instantiates `?0` with `(W<?1>, W<?2>)` and then
+// proves `W<?1>: Trait` and `W<?2>: Trait`, resulting in a coinductive cycle.
+//
+// Proving coinductive cycles runs until we reach a fixpoint. This fixpoint is
+// never reached here and each step doubles the amount of nested obligations.
+//
+// This previously caused a hang in the trait solver, see
+// https://github.com/rust-lang/trait-system-refactor-initiative/issues/13.
+
+#![feature(rustc_attrs)]
+
+#[rustc_coinductive]
+trait Trait {}
+
+struct W<T>(T);
+
+impl<T, U> Trait for W<(W<T>, W<U>)>
+where
+    W<T>: Trait,
+    W<U>: Trait,
+{
+}
+
+fn impls<T: Trait>() {}
+
+fn main() {
+    impls::<W<_>>();
+    //~^ ERROR type annotations needed
+    //~| ERROR overflow evaluating the requirement
+}
diff --git a/tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.stderr b/tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.stderr
new file mode 100644
index 00000000000..7d3535e1f01
--- /dev/null
+++ b/tests/ui/traits/new-solver/coinduction/fixpoint-exponential-growth.stderr
@@ -0,0 +1,23 @@
+error[E0282]: type annotations needed
+  --> $DIR/fixpoint-exponential-growth.rs:29:5
+   |
+LL |     impls::<W<_>>();
+   |     ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls`
+
+error[E0275]: overflow evaluating the requirement `W<_>: Trait`
+  --> $DIR/fixpoint-exponential-growth.rs:29:5
+   |
+LL |     impls::<W<_>>();
+   |     ^^^^^^^^^^^^^
+   |
+   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`fixpoint_exponential_growth`)
+note: required by a bound in `impls`
+  --> $DIR/fixpoint-exponential-growth.rs:26:13
+   |
+LL | fn impls<T: Trait>() {}
+   |             ^^^^^ required by this bound in `impls`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0275, E0282.
+For more information about an error, try `rustc --explain E0275`.
diff --git a/tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.rs b/tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.rs
new file mode 100644
index 00000000000..0cd14f05c8d
--- /dev/null
+++ b/tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.rs
@@ -0,0 +1,69 @@
+// compile-flags: -Ztrait-solver=next
+#![feature(rustc_attrs)]
+
+// This test is incredibly subtle. At its core the goal is to get a coinductive cycle,
+// which, depending on its root goal, either holds or errors. We achieve this by getting
+// incomplete inference via a `ParamEnv` candidate in the `A<T>` impl and required
+// inference from an `Impl` candidate in the `B<T>` impl.
+//
+// To make global cache accesses stronger than the guidance from the where-bounds, we add
+// another coinductive cycle from `A<T>: Trait<U, V, D>` to `A<T>: Trait<U, D, V>` and only
+// constrain `D` directly. This means that any candidates which rely on `V` only make
+// progress in the second iteration, allowing a cache access in the first iteration to take
+// precedence.
+//
+// tl;dr: our caching of coinductive cycles was broken and this is a regression
+// test for that.
+
+#[rustc_coinductive]
+trait Trait<T: ?Sized, V: ?Sized, D: ?Sized> {}
+struct A<T: ?Sized>(*const T);
+struct B<T: ?Sized>(*const T);
+
+trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
+impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, u8> for T {}
+impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i8> for T {}
+impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i16> for T {}
+
+trait ImplGuidance<T: ?Sized, V: ?Sized> {}
+impl<T: ?Sized> ImplGuidance<u32, u8> for T {}
+impl<T: ?Sized> ImplGuidance<i32, i8> for T {}
+
+impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for A<T>
+where
+    T: IncompleteGuidance<U, V>,
+    A<T>: Trait<U, D, V>,
+    B<T>: Trait<U, V, D>,
+    (): ToU8<D>,
+{
+}
+
+trait ToU8<T: ?Sized> {}
+impl ToU8<u8> for () {}
+
+impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for B<T>
+where
+    T: ImplGuidance<U, V>,
+    A<T>: Trait<U, V, D>,
+{
+}
+
+fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {}
+
+fn with_bound<X>()
+where
+    X: IncompleteGuidance<i32, u8>,
+    X: IncompleteGuidance<u32, i8>,
+    X: IncompleteGuidance<u32, i16>,
+{
+    impls_trait::<B<X>, _, _, _>(); // entering the cycle from `B` works
+
+    // entering the cycle from `A` fails, but would work if we were to use the cache
+    // result of `B<X>`.
+    impls_trait::<A<X>, _, _, _>();
+    //~^ ERROR the trait bound `A<X>: Trait<_, _, _>` is not satisfied
+}
+
+fn main() {
+    with_bound::<u32>();
+}
diff --git a/tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.stderr b/tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.stderr
new file mode 100644
index 00000000000..f1871ff0564
--- /dev/null
+++ b/tests/ui/traits/new-solver/coinduction/incompleteness-unstable-result.stderr
@@ -0,0 +1,16 @@
+error[E0277]: the trait bound `A<X>: Trait<_, _, _>` is not satisfied
+  --> $DIR/incompleteness-unstable-result.rs:63:19
+   |
+LL |     impls_trait::<A<X>, _, _, _>();
+   |                   ^^^^ the trait `Trait<_, _, _>` is not implemented for `A<X>`
+   |
+   = help: the trait `Trait<U, V, D>` is implemented for `A<T>`
+note: required by a bound in `impls_trait`
+  --> $DIR/incompleteness-unstable-result.rs:51:28
+   |
+LL | fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {}
+   |                            ^^^^^^^^^^^^^^ required by this bound in `impls_trait`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/traits/new-solver/overflow/global-cache.rs b/tests/ui/traits/new-solver/overflow/global-cache.rs
new file mode 100644
index 00000000000..adc03da04a8
--- /dev/null
+++ b/tests/ui/traits/new-solver/overflow/global-cache.rs
@@ -0,0 +1,23 @@
+// compile-flags: -Ztrait-solver=next
+
+// Check that we consider the reached depth of global cache
+// entries when detecting overflow. We would otherwise be unstable
+// wrt to incremental compilation.
+#![recursion_limit = "9"]
+
+trait Trait {}
+
+struct Inc<T>(T);
+
+impl<T: Trait> Trait for Inc<T> {}
+impl Trait for () {}
+
+fn impls_trait<T: Trait>() {}
+
+type Four<T> = Inc<Inc<Inc<Inc<T>>>>;
+
+fn main() {
+    impls_trait::<Four<Four<()>>>();
+    impls_trait::<Four<Four<Four<Four<()>>>>>();
+    //~^ ERROR overflow evaluating the requirement
+}
diff --git a/tests/ui/traits/new-solver/overflow/global-cache.stderr b/tests/ui/traits/new-solver/overflow/global-cache.stderr
new file mode 100644
index 00000000000..f3b86a083ad
--- /dev/null
+++ b/tests/ui/traits/new-solver/overflow/global-cache.stderr
@@ -0,0 +1,16 @@
+error[E0275]: overflow evaluating the requirement `Inc<Inc<Inc<Inc<Inc<Inc<Inc<...>>>>>>>: Trait`
+  --> $DIR/global-cache.rs:21:5
+   |
+LL |     impls_trait::<Four<Four<Four<Four<()>>>>>();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "18"]` attribute to your crate (`global_cache`)
+note: required by a bound in `impls_trait`
+  --> $DIR/global-cache.rs:15:19
+   |
+LL | fn impls_trait<T: Trait>() {}
+   |                   ^^^^^ required by this bound in `impls_trait`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/typeck/issue-114423.rs b/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.rs
index da2dae1c46b..da2dae1c46b 100644
--- a/tests/ui/typeck/issue-114423.rs
+++ b/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.rs
diff --git a/tests/ui/typeck/issue-114423.stderr b/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr
index c20a4391297..4ccfacfb005 100644
--- a/tests/ui/typeck/issue-114423.stderr
+++ b/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr
@@ -1,23 +1,23 @@
 error[E0425]: cannot find value `e` in this scope
-  --> $DIR/issue-114423.rs:7:51
+  --> $DIR/issue-114423-ice-regression-in-suggestion.rs:7:51
    |
 LL |     let (r, alone_in_path, b): (f32, f32, f32) = (e.clone(), e.clone());
    |                                                   ^ not found in this scope
 
 error[E0425]: cannot find value `e` in this scope
-  --> $DIR/issue-114423.rs:7:62
+  --> $DIR/issue-114423-ice-regression-in-suggestion.rs:7:62
    |
 LL |     let (r, alone_in_path, b): (f32, f32, f32) = (e.clone(), e.clone());
    |                                                              ^ not found in this scope
 
 error[E0425]: cannot find value `g` in this scope
-  --> $DIR/issue-114423.rs:11:22
+  --> $DIR/issue-114423-ice-regression-in-suggestion.rs:11:22
    |
 LL |     let _ = RGB { r, g, b };
    |                      ^ help: a local variable with a similar name exists: `b`
 
 error[E0308]: mismatched types
-  --> $DIR/issue-114423.rs:7:50
+  --> $DIR/issue-114423-ice-regression-in-suggestion.rs:7:50
    |
 LL |     let (r, alone_in_path, b): (f32, f32, f32) = (e.clone(), e.clone());
    |                                ---------------   ^^^^^^^^^^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 2 elements
@@ -28,7 +28,7 @@ LL |     let (r, alone_in_path, b): (f32, f32, f32) = (e.clone(), e.clone());
               found tuple `(f32, f32)`
 
 error[E0560]: struct `RGB` has no field named `r`
-  --> $DIR/issue-114423.rs:11:19
+  --> $DIR/issue-114423-ice-regression-in-suggestion.rs:11:19
    |
 LL |     let _ = RGB { r, g, b };
    |                   ^ `RGB` does not have this field
@@ -36,7 +36,7 @@ LL |     let _ = RGB { r, g, b };
    = note: all struct fields are already assigned
 
 error[E0308]: mismatched types
-  --> $DIR/issue-114423.rs:11:25
+  --> $DIR/issue-114423-ice-regression-in-suggestion.rs:11:25
    |
 LL |     let _ = RGB { r, g, b };
    |                         ^ expected `f64`, found `f32`