diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
commit | 94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch) | |
tree | 2b827afe6a05f3538db3f7803a88c4587fe85648 /src/test/ui/coercion | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip |
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/coercion')
-rw-r--r-- | src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr | 2 | ||||
-rw-r--r-- | src/test/ui/coercion/coerce-to-bang.stderr | 10 | ||||
-rw-r--r-- | src/test/ui/coercion/coercion-missing-tail-expected-type.stderr | 4 | ||||
-rw-r--r-- | src/test/ui/coercion/issue-101066.rs | 16 | ||||
-rw-r--r-- | src/test/ui/coercion/issue-36007.rs | 20 |
5 files changed, 44 insertions, 8 deletions
diff --git a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr index 36551e5af..5cbdef218 100644 --- a/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr +++ b/src/test/ui/coercion/coerce-reborrow-multi-arg-fail.stderr @@ -12,7 +12,7 @@ note: function defined here --> $DIR/coerce-reborrow-multi-arg-fail.rs:1:4 | LL | fn test<T>(_a: T, _b: T) {} - | ^^^^ ----- ----- + | ^^^^ ----- error: aborting due to previous error diff --git a/src/test/ui/coercion/coerce-to-bang.stderr b/src/test/ui/coercion/coerce-to-bang.stderr index add8f14cf..1207dc7e7 100644 --- a/src/test/ui/coercion/coerce-to-bang.stderr +++ b/src/test/ui/coercion/coerce-to-bang.stderr @@ -12,7 +12,7 @@ note: function defined here --> $DIR/coerce-to-bang.rs:3:4 | LL | fn foo(x: usize, y: !, z: usize) { } - | ^^^ -------- ---- -------- + | ^^^ ---- error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:18:13 @@ -28,7 +28,7 @@ note: function defined here --> $DIR/coerce-to-bang.rs:3:4 | LL | fn foo(x: usize, y: !, z: usize) { } - | ^^^ -------- ---- -------- + | ^^^ ---- error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:26:12 @@ -44,7 +44,7 @@ note: function defined here --> $DIR/coerce-to-bang.rs:3:4 | LL | fn foo(x: usize, y: !, z: usize) { } - | ^^^ -------- ---- -------- + | ^^^ ---- error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:36:12 @@ -60,7 +60,7 @@ note: function defined here --> $DIR/coerce-to-bang.rs:3:4 | LL | fn foo(x: usize, y: !, z: usize) { } - | ^^^ -------- ---- -------- + | ^^^ ---- error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:45:12 @@ -76,7 +76,7 @@ note: function defined here --> $DIR/coerce-to-bang.rs:3:4 | LL | fn foo(x: usize, y: !, z: usize) { } - | ^^^ -------- ---- -------- + | ^^^ ---- error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:50:21 diff --git a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr index a4843bca5..4c04bb113 100644 --- a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr +++ b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr @@ -6,7 +6,7 @@ LL | fn plus_one(x: i32) -> i32 { | | | implicitly returns `()` as its body has no tail or `return` expression LL | x + 1; - | - help: remove this semicolon + | - help: remove this semicolon to return this value error[E0308]: mismatched types --> $DIR/coercion-missing-tail-expected-type.rs:8:13 @@ -16,7 +16,7 @@ LL | fn foo() -> Result<u8, u64> { | | | implicitly returns `()` as its body has no tail or `return` expression LL | Ok(1); - | - help: remove this semicolon + | - help: remove this semicolon to return this value | = note: expected enum `Result<u8, u64>` found unit type `()` diff --git a/src/test/ui/coercion/issue-101066.rs b/src/test/ui/coercion/issue-101066.rs new file mode 100644 index 000000000..b658ed1e9 --- /dev/null +++ b/src/test/ui/coercion/issue-101066.rs @@ -0,0 +1,16 @@ +// check-pass + +use std::convert::TryFrom; + +pub trait FieldElement { + type Integer: TryFrom<usize, Error = std::num::TryFromIntError>; + + fn valid_integer_try_from<N>(i: N) -> Result<Self::Integer, ()> + where + Self::Integer: TryFrom<N>, + { + Self::Integer::try_from(i).map_err(|_| ()) + } +} + +fn main() {} diff --git a/src/test/ui/coercion/issue-36007.rs b/src/test/ui/coercion/issue-36007.rs new file mode 100644 index 000000000..78812df87 --- /dev/null +++ b/src/test/ui/coercion/issue-36007.rs @@ -0,0 +1,20 @@ +// check-pass +#![feature(coerce_unsized, unsize)] + +use std::marker::Unsize; +use std::ops::CoerceUnsized; + +struct Foo<T: ?Sized>(Box<T>); + +impl<T> CoerceUnsized<Foo<dyn Baz>> for Foo<T> where T: Unsize<dyn Baz> {} + +struct Bar; + +trait Baz {} + +impl Baz for Bar {} + +fn main() { + let foo = Foo(Box::new(Bar)); + let foobar: Foo<Bar> = foo; +} |