summaryrefslogtreecommitdiff
path: root/tests/ui/coercion
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-10 10:15:37 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-17 10:57:52 +0000
commit94f549502f4bf6fae35f17c823924f041217c8f4 (patch)
tree4b8fa126b69cb8f5ca9004849a9aff16fce0b5eb /tests/ui/coercion
parente23ae72ac7a393961886ea62df065ebb6def7d51 (diff)
Use subtyping instead of equality, since method resolution also uses subtyping
Diffstat (limited to 'tests/ui/coercion')
-rw-r--r--tests/ui/coercion/coerce-issue-49593-box-never.fallback.stderr11
-rw-r--r--tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr8
-rw-r--r--tests/ui/coercion/coerce-issue-49593-box-never.rs9
3 files changed, 20 insertions, 8 deletions
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.fallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never.fallback.stderr
new file mode 100644
index 00000000000..e9b43d6145c
--- /dev/null
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.fallback.stderr
@@ -0,0 +1,11 @@
+error[E0277]: the trait bound `(): std::error::Error` is not satisfied
+ --> $DIR/coerce-issue-49593-box-never.rs:19:5
+ |
+LL | Box::<_ /* ! */>::new(x)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
+ |
+ = note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
index 0d98fa93e5a..1215f5f9d88 100644
--- a/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
@@ -1,13 +1,13 @@
error[E0277]: the trait bound `(): std::error::Error` is not satisfied
- --> $DIR/coerce-issue-49593-box-never.rs:18:53
+ --> $DIR/coerce-issue-49593-box-never.rs:19:5
|
-LL | /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
- | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
+LL | Box::<_ /* ! */>::new(x)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
|
= note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>`
error[E0277]: the trait bound `(): std::error::Error` is not satisfied
- --> $DIR/coerce-issue-49593-box-never.rs:23:49
+ --> $DIR/coerce-issue-49593-box-never.rs:24:49
|
LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.rs b/tests/ui/coercion/coerce-issue-49593-box-never.rs
index 19a2c036fbc..f93fbb70dce 100644
--- a/tests/ui/coercion/coerce-issue-49593-box-never.rs
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.rs
@@ -1,7 +1,6 @@
//@ revisions: nofallback fallback
//@ ignore-windows - the number of `Error` impls is platform-dependent
-//@[fallback] check-pass
-//@[nofallback] check-fail
+//@check-fail
#![feature(never_type)]
#![cfg_attr(fallback, feature(never_type_fallback))]
@@ -15,8 +14,10 @@ fn raw_ptr_box<T>(t: T) -> *mut T {
}
fn foo(x: !) -> Box<dyn Error> {
- /* *mut $0 is coerced to Box<dyn Error> here */ Box::<_ /* ! */>::new(x)
- //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
+ // Subtyping during method resolution will generate new inference vars and
+ // subtype them. Thus fallback will not fall back to `!`, but `()` instead.
+ Box::<_ /* ! */>::new(x)
+ //~^ ERROR trait bound `(): std::error::Error` is not satisfied
}
fn foo_raw_ptr(x: !) -> *mut dyn Error {