summaryrefslogtreecommitdiffstats
path: root/tests/ui/methods
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/ui/methods
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/methods')
-rw-r--r--tests/ui/methods/inherent-bound-in-probe.rs49
-rw-r--r--tests/ui/methods/inherent-bound-in-probe.stderr38
-rw-r--r--tests/ui/methods/method-call-lifetime-args-fail.stderr31
-rw-r--r--tests/ui/methods/method-call-lifetime-args.stderr5
4 files changed, 106 insertions, 17 deletions
diff --git a/tests/ui/methods/inherent-bound-in-probe.rs b/tests/ui/methods/inherent-bound-in-probe.rs
new file mode 100644
index 000000000..81a99ca01
--- /dev/null
+++ b/tests/ui/methods/inherent-bound-in-probe.rs
@@ -0,0 +1,49 @@
+// normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
+
+// Fixes #110131
+//
+// The issue is that we were constructing an `ImplDerived` cause code for the
+// `&'a T: IntoIterator<Item = &'a u8>` obligation for `Helper::new`, which is
+// incorrect because derived obligations are only expected to come from *traits*.
+
+struct SeqBuffer<'a, T>
+where
+ &'a T: IntoIterator<Item = &'a u8>,
+{
+ iter: <&'a T as IntoIterator>::IntoIter,
+}
+
+struct Helper<'a, T>
+where
+ &'a T: IntoIterator<Item = &'a u8>,
+{
+ buf: SeqBuffer<'a, T>,
+}
+
+impl<'a, T> Helper<'a, T>
+where
+ &'a T: IntoIterator<Item = &'a u8>,
+{
+ fn new(sq: &'a T) -> Self {
+ loop {}
+ }
+}
+
+struct BitReaderWrapper<T>(T);
+
+impl<'a, T> IntoIterator for &'a BitReaderWrapper<T>
+where
+ &'a T: IntoIterator<Item = &'a u8>,
+{
+ type Item = u32;
+
+ type IntoIter = Helper<'a, T>;
+ //~^ ERROR `Helper<'a, T>` is not an iterator
+
+ fn into_iter(self) -> Self::IntoIter {
+ Helper::new(&self.0)
+ //~^ ERROR overflow evaluating the requirement `&_: IntoIterator`
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/methods/inherent-bound-in-probe.stderr b/tests/ui/methods/inherent-bound-in-probe.stderr
new file mode 100644
index 000000000..ff03a7edb
--- /dev/null
+++ b/tests/ui/methods/inherent-bound-in-probe.stderr
@@ -0,0 +1,38 @@
+error[E0277]: `Helper<'a, T>` is not an iterator
+ --> $DIR/inherent-bound-in-probe.rs:40:21
+ |
+LL | type IntoIter = Helper<'a, T>;
+ | ^^^^^^^^^^^^^ `Helper<'a, T>` is not an iterator
+ |
+ = help: the trait `Iterator` is not implemented for `Helper<'a, T>`
+note: required by a bound in `std::iter::IntoIterator::IntoIter`
+ --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
+
+error[E0275]: overflow evaluating the requirement `&_: IntoIterator`
+ --> $DIR/inherent-bound-in-probe.rs:44:17
+ |
+LL | Helper::new(&self.0)
+ | ^^^
+ |
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_bound_in_probe`)
+note: required for `&BitReaderWrapper<_>` to implement `IntoIterator`
+ --> $DIR/inherent-bound-in-probe.rs:34:13
+ |
+LL | impl<'a, T> IntoIterator for &'a BitReaderWrapper<T>
+ | ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
+LL | where
+LL | &'a T: IntoIterator<Item = &'a u8>,
+ | ------------- unsatisfied trait bound introduced here
+ = note: 126 redundant requirements hidden
+ = note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<...>>>>>` to implement `IntoIterator`
+ = note: the full type name has been written to '$TEST_BUILD_DIR/methods/inherent-bound-in-probe/inherent-bound-in-probe.long-type-hash.txt'
+note: required by a bound in `Helper<'a, T>`
+ --> $DIR/inherent-bound-in-probe.rs:25:25
+ |
+LL | &'a T: IntoIterator<Item = &'a u8>,
+ | ^^^^^^^^^^^^^ required by this bound in `Helper<'a, T>`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0275, E0277.
+For more information about an error, try `rustc --explain E0275`.
diff --git a/tests/ui/methods/method-call-lifetime-args-fail.stderr b/tests/ui/methods/method-call-lifetime-args-fail.stderr
index 34526256f..645d8b8d1 100644
--- a/tests/ui/methods/method-call-lifetime-args-fail.stderr
+++ b/tests/ui/methods/method-call-lifetime-args-fail.stderr
@@ -30,7 +30,7 @@ note: method defined here, with 2 lifetime parameters: `'a`, `'b`
LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
| ^^^^^ -- --
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:27:15
|
LL | S::late::<'static>(S, &0, &0);
@@ -42,7 +42,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
| ^^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:29:15
|
LL | S::late::<'static, 'static>(S, &0, &0);
@@ -54,7 +54,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
| ^^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:31:15
|
LL | S::late::<'static, 'static, 'static>(S, &0, &0);
@@ -66,7 +66,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
| ^^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:34:21
|
LL | S::late_early::<'static, 'static>(S, &0);
@@ -78,7 +78,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} }
| ^^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:36:21
|
LL | S::late_early::<'static, 'static, 'static>(S, &0);
@@ -90,7 +90,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} }
| ^^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:40:24
|
LL | S::late_implicit::<'static>(S, &0, &0);
@@ -102,7 +102,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_implicit(self, _: &u8, _: &u8) {}
| ^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:42:24
|
LL | S::late_implicit::<'static, 'static>(S, &0, &0);
@@ -114,7 +114,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_implicit(self, _: &u8, _: &u8) {}
| ^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:44:24
|
LL | S::late_implicit::<'static, 'static, 'static>(S, &0, &0);
@@ -126,7 +126,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_implicit(self, _: &u8, _: &u8) {}
| ^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:47:30
|
LL | S::late_implicit_early::<'static, 'static>(S, &0);
@@ -138,7 +138,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} }
| ^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:49:30
|
LL | S::late_implicit_early::<'static, 'static, 'static>(S, &0);
@@ -150,7 +150,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} }
| ^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:52:35
|
LL | S::late_implicit_self_early::<'static, 'static>(&S);
@@ -162,7 +162,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} }
| ^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:54:35
|
LL | S::late_implicit_self_early::<'static, 'static, 'static>(&S);
@@ -174,7 +174,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} }
| ^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:57:28
|
LL | S::late_unused_early::<'static, 'static>(S);
@@ -186,7 +186,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} }
| ^^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args-fail.rs:59:28
|
LL | S::late_unused_early::<'static, 'static, 'static>(S);
@@ -232,4 +232,5 @@ LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
error: aborting due to 18 previous errors
-For more information about this error, try `rustc --explain E0107`.
+Some errors have detailed explanations: E0107, E0794.
+For more information about an error, try `rustc --explain E0107`.
diff --git a/tests/ui/methods/method-call-lifetime-args.stderr b/tests/ui/methods/method-call-lifetime-args.stderr
index 64ae79e9b..b215d5832 100644
--- a/tests/ui/methods/method-call-lifetime-args.stderr
+++ b/tests/ui/methods/method-call-lifetime-args.stderr
@@ -1,4 +1,4 @@
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args.rs:9:15
|
LL | S::late::<'static>(S, &0, &0);
@@ -10,7 +10,7 @@ note: the late bound lifetime parameter is introduced here
LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
| ^^
-error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
+error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
--> $DIR/method-call-lifetime-args.rs:11:24
|
LL | S::late_implicit::<'static>(S, &0, &0);
@@ -24,3 +24,4 @@ LL | fn late_implicit(self, _: &u8, _: &u8) {}
error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0794`.