From cbe932801892da06688b53638622be1c8a1c8974 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 11 Nov 2022 03:19:02 +0000 Subject: Do not need to account for overflow in predicate_can_apply --- src/test/ui/traits/predicate_can_apply-hang.rs | 6 ++++++ src/test/ui/traits/predicate_can_apply-hang.stderr | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/test/ui/traits/predicate_can_apply-hang.rs create mode 100644 src/test/ui/traits/predicate_can_apply-hang.stderr (limited to 'src') diff --git a/src/test/ui/traits/predicate_can_apply-hang.rs b/src/test/ui/traits/predicate_can_apply-hang.rs new file mode 100644 index 00000000000..5f01645da52 --- /dev/null +++ b/src/test/ui/traits/predicate_can_apply-hang.rs @@ -0,0 +1,6 @@ +fn f(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq { + //~^ ERROR can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B` + x +} + +fn main() {} diff --git a/src/test/ui/traits/predicate_can_apply-hang.stderr b/src/test/ui/traits/predicate_can_apply-hang.stderr new file mode 100644 index 00000000000..49fe63b412a --- /dev/null +++ b/src/test/ui/traits/predicate_can_apply-hang.stderr @@ -0,0 +1,21 @@ +error[E0277]: can't compare `Vec<[[[B; 1]; 1]; 1]>` with `B` + --> $DIR/predicate_can_apply-hang.rs:1:38 + | +LL | fn f(x: Vec<[[[B; 1]; 1]; 1]>) -> impl PartialEq { + | ^^^^^^^^^^^^^^^^^ no implementation for `Vec<[[[B; 1]; 1]; 1]> == B` +LL | +LL | x + | - return type was inferred to be `Vec<[[[B; 1]; 1]; 1]>` here + | + = help: the trait `PartialEq` is not implemented for `Vec<[[[B; 1]; 1]; 1]>` + = help: the following other types implement trait `PartialEq`: + as PartialEq>> + as PartialEq<&[U; N]>> + as PartialEq<&[U]>> + as PartialEq<&mut [U]>> + as PartialEq<[U; N]>> + as PartialEq<[U]>> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5 From 9decfff6f87d3e5760fd61375c3d27fa45a83e52 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 18 Nov 2022 17:23:10 +0000 Subject: Add fatal overflow test --- src/test/ui/typeck/hang-in-overflow.rs | 19 +++++++++++++++++++ src/test/ui/typeck/hang-in-overflow.stderr | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/test/ui/typeck/hang-in-overflow.rs create mode 100644 src/test/ui/typeck/hang-in-overflow.stderr (limited to 'src') diff --git a/src/test/ui/typeck/hang-in-overflow.rs b/src/test/ui/typeck/hang-in-overflow.rs new file mode 100644 index 00000000000..a8330c9b65c --- /dev/null +++ b/src/test/ui/typeck/hang-in-overflow.rs @@ -0,0 +1,19 @@ +// normalize-stderr-test "the requirement `.*`" -> "the requirement `...`" +// normalize-stderr-test "required for `.*` to implement `.*`" -> "required for `...` to implement `...`" +// normalize-stderr-test: ".*the full type name has been written to.*\n" -> "" + +// Currently this fatally aborts instead of hanging. +// Make sure at least that this doesn't turn into a hang. + +fn f() { + foo::<_>(); + //~^ ERROR overflow evaluating the requirement +} + +fn foo() +where + Vec<[[[B; 1]; 1]; 1]>: PartialEq, +{ +} + +fn main() {} diff --git a/src/test/ui/typeck/hang-in-overflow.stderr b/src/test/ui/typeck/hang-in-overflow.stderr new file mode 100644 index 00000000000..7a7b85b19b4 --- /dev/null +++ b/src/test/ui/typeck/hang-in-overflow.stderr @@ -0,0 +1,22 @@ +error[E0275]: overflow evaluating the requirement `...` + --> $DIR/hang-in-overflow.rs:9:5 + | +LL | foo::<_>(); + | ^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`hang_in_overflow`) + = note: required for `...` to implement `...` + = note: 127 redundant requirements hidden + = note: required for `...` to implement `...` +note: required by a bound in `foo` + --> $DIR/hang-in-overflow.rs:15:28 + | +LL | fn foo() + | --- required by a bound in this +LL | where +LL | Vec<[[[B; 1]; 1]; 1]>: PartialEq, + | ^^^^^^^^^^^^ required by this bound in `foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. -- cgit 1.4.1-3-g733a5