From 90128c30a0a69b1587bdf3d3d8a8de0750653aa0 Mon Sep 17 00:00:00 2001 From: ouz-a Date: Sat, 19 Nov 2022 22:43:12 +0300 Subject: [PATCH 1/3] revert-overflow --- .../src/traits/project.rs | 16 ----------- src/test/ui/issues/issue-23122-2.stderr | 8 +++++- src/test/ui/recursion/issue-83150.stderr | 4 +-- src/test/ui/recursion/issue-95134.rs | 28 ------------------- src/test/ui/recursion/issue-95134.stderr | 7 ----- 5 files changed, 8 insertions(+), 55 deletions(-) delete mode 100644 src/test/ui/recursion/issue-95134.rs delete mode 100644 src/test/ui/recursion/issue-95134.stderr diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 528b98cf4a1c0..30fa469f85734 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -566,22 +566,6 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> { .flatten() .unwrap_or_else(|| ty.super_fold_with(self).into()) }; - // For cases like #95134 we would like to catch overflows early - // otherwise they slip away and cause ICE. - let recursion_limit = self.tcx().recursion_limit(); - if !recursion_limit.value_within_limit(self.depth) - // HACK: Don't overflow when running cargo doc see #100991 - && !self.tcx().sess.opts.actually_rustdoc - { - let obligation = Obligation::with_depth( - self.selcx.tcx(), - self.cause.clone(), - recursion_limit.0, - self.param_env, - ty, - ); - self.selcx.infcx().err_ctxt().report_overflow_error(&obligation, true); - } debug!( ?self.depth, ?ty, diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index f6cda3de5c763..33af86918e08c 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,10 +1,16 @@ -error[E0275]: overflow evaluating the requirement `::Next` +error[E0275]: overflow evaluating the requirement `<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` --> $DIR/issue-23122-2.rs:10:17 | LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) +note: required for `GetNext<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` + --> $DIR/issue-23122-2.rs:9:15 + | +LL | impl Next for GetNext { + | ^^^^ ^^^^^^^^^^ + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2/issue-23122-2.long-type-2230235837754269907.txt' error: aborting due to previous error diff --git a/src/test/ui/recursion/issue-83150.stderr b/src/test/ui/recursion/issue-83150.stderr index a67bfd018a2b5..4d00a70831377 100644 --- a/src/test/ui/recursion/issue-83150.stderr +++ b/src/test/ui/recursion/issue-83150.stderr @@ -9,11 +9,9 @@ LL | func(&mut iter.map(|x| x + 1)) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0275]: overflow evaluating the requirement ` as Iterator>::Item` +error[E0275]: overflow evaluating the requirement `Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>: Iterator` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) - = note: required for `Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:12:24: 12:27]>` to implement `Iterator` - = note: 64 redundant requirements hidden = note: required for `&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>` to implement `Iterator` = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/issue-83150/issue-83150.long-type-hash.txt' diff --git a/src/test/ui/recursion/issue-95134.rs b/src/test/ui/recursion/issue-95134.rs deleted file mode 100644 index adc9c6ee2d967..0000000000000 --- a/src/test/ui/recursion/issue-95134.rs +++ /dev/null @@ -1,28 +0,0 @@ -// build-fail -// compile-flags: -Copt-level=0 -//~^^ ERROR overflow evaluating the requirement - -pub fn encode_num(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { - if n > 15 { - encode_num(n / 16, &mut writer)?; - } - Ok(()) -} - -pub trait ExampleWriter { - type Error; -} - -impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T { - type Error = T::Error; -} - -struct EmptyWriter; - -impl ExampleWriter for EmptyWriter { - type Error = (); -} - -fn main() { - encode_num(69, &mut EmptyWriter).unwrap(); -} diff --git a/src/test/ui/recursion/issue-95134.stderr b/src/test/ui/recursion/issue-95134.stderr deleted file mode 100644 index 57a498694b7c1..0000000000000 --- a/src/test/ui/recursion/issue-95134.stderr +++ /dev/null @@ -1,7 +0,0 @@ -error[E0275]: overflow evaluating the requirement `::Error` - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_95134`) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. From 07158effd3268d8ea3431a0b6e8a9b572cb944b9 Mon Sep 17 00:00:00 2001 From: ouz-a Date: Sat, 19 Nov 2022 23:03:14 +0300 Subject: [PATCH 2/3] re-add test and bless --- src/test/ui/issues/issue-23122-2.stderr | 2 +- src/test/ui/recursion/issue-95134.rs | 30 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/recursion/issue-95134.rs diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index 33af86918e08c..dd97bcc7b3e73 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -10,7 +10,7 @@ note: required for `GetNext<<<<<<... as Next>::Next as Next>::Next as Next>::Nex | LL | impl Next for GetNext { | ^^^^ ^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2/issue-23122-2.long-type-2230235837754269907.txt' + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2/issue-23122-2.long-type-3976323088118947840.txt' error: aborting due to previous error diff --git a/src/test/ui/recursion/issue-95134.rs b/src/test/ui/recursion/issue-95134.rs new file mode 100644 index 0000000000000..fdc4d53698143 --- /dev/null +++ b/src/test/ui/recursion/issue-95134.rs @@ -0,0 +1,30 @@ +// build-fail +// known-bug: #95134 +// compile-flags: -Copt-level=0 +// failure-status: 101 +// dont-check-compiler-stderr + +pub fn encode_num(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { + if n > 15 { + encode_num(n / 16, &mut writer)?; + } + Ok(()) +} + +pub trait ExampleWriter { + type Error; +} + +impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T { + type Error = T::Error; +} + +struct EmptyWriter; + +impl ExampleWriter for EmptyWriter { + type Error = (); +} + +fn main() { + encode_num(69, &mut EmptyWriter).unwrap(); +} From 701970e0b8941537f3b34381d2cc98940c4e71db Mon Sep 17 00:00:00 2001 From: ouz-a Date: Sat, 19 Nov 2022 23:26:42 +0300 Subject: [PATCH 3/3] fix test err --- src/test/ui/issues/issue-23122-2.rs | 1 + src/test/ui/issues/issue-23122-2.stderr | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/ui/issues/issue-23122-2.rs b/src/test/ui/issues/issue-23122-2.rs index 95e1f60d8b029..338789c2e8719 100644 --- a/src/test/ui/issues/issue-23122-2.rs +++ b/src/test/ui/issues/issue-23122-2.rs @@ -1,3 +1,4 @@ +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" trait Next { type Next: Next; } diff --git a/src/test/ui/issues/issue-23122-2.stderr b/src/test/ui/issues/issue-23122-2.stderr index dd97bcc7b3e73..5828e027b5903 100644 --- a/src/test/ui/issues/issue-23122-2.stderr +++ b/src/test/ui/issues/issue-23122-2.stderr @@ -1,16 +1,16 @@ error[E0275]: overflow evaluating the requirement `<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:10:17 + --> $DIR/issue-23122-2.rs:11:17 | LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) note: required for `GetNext<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` - --> $DIR/issue-23122-2.rs:9:15 + --> $DIR/issue-23122-2.rs:10:15 | LL | impl Next for GetNext { | ^^^^ ^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2/issue-23122-2.long-type-3976323088118947840.txt' + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-23122-2/issue-23122-2.long-type-hash.txt' error: aborting due to previous error