summaryrefslogtreecommitdiff
path: root/tests/ui/coercion
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/coercion')
-rw-r--r--tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr19
-rw-r--r--tests/ui/coercion/coerce-issue-49593-box-never-windows.rs58
-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.stderr12
-rw-r--r--tests/ui/coercion/coerce-issue-49593-box-never.rs20
5 files changed, 27 insertions, 93 deletions
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr b/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr
deleted file mode 100644
index b976f70acf7..00000000000
--- a/tests/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0277]: the trait bound `(): std::error::Error` is not satisfied
- --> $DIR/coerce-issue-49593-box-never-windows.rs:18:53
- |
-LL | /* *mut $0 is coerced to Box<dyn Error> here */ 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-windows.rs:23:49
- |
-LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
- |
- = note: required for the cast from `*mut ()` to `*mut (dyn std::error::Error + 'static)`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never-windows.rs b/tests/ui/coercion/coerce-issue-49593-box-never-windows.rs
deleted file mode 100644
index b317841ab6e..00000000000
--- a/tests/ui/coercion/coerce-issue-49593-box-never-windows.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-//@ revisions: nofallback fallback
-//@ only-windows - the number of `Error` impls is platform-dependent
-//@[fallback] check-pass
-//@[nofallback] check-fail
-
-#![feature(never_type)]
-#![cfg_attr(fallback, feature(never_type_fallback))]
-#![allow(unreachable_code)]
-
-use std::error::Error;
-use std::mem;
-
-fn raw_ptr_box<T>(t: T) -> *mut T {
- panic!()
-}
-
-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
-}
-
-fn foo_raw_ptr(x: !) -> *mut dyn Error {
- /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
- //[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
-}
-
-fn no_coercion(d: *mut dyn Error) -> *mut dyn Error {
- /* an unsize coercion won't compile here, and it is indeed not used
- because there is nothing requiring the _ to be Sized */
- d as *mut _
-}
-
-trait Xyz {}
-struct S;
-struct T;
-impl Xyz for S {}
-impl Xyz for T {}
-
-fn foo_no_never() {
- let mut x /* : Option<S> */ = None;
- let mut first_iter = false;
- loop {
- if !first_iter {
- let y: Box<dyn Xyz>
- = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap());
- }
-
- x = Some(S);
- first_iter = true;
- }
-
- let mut y : Option<S> = None;
- // assert types are equal
- mem::swap(&mut x, &mut y);
-}
-
-fn main() {
-}
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..ef5633f7134
--- /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:18: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..7222af43b01 100644
--- a/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr
@@ -1,16 +1,16 @@
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:18: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:5
|
-LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
+LL | raw_ptr_box::<_ /* ! */>(x)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
|
= note: required for the cast from `*mut ()` to `*mut (dyn std::error::Error + 'static)`
diff --git a/tests/ui/coercion/coerce-issue-49593-box-never.rs b/tests/ui/coercion/coerce-issue-49593-box-never.rs
index 19a2c036fbc..53071be47dc 100644
--- a/tests/ui/coercion/coerce-issue-49593-box-never.rs
+++ b/tests/ui/coercion/coerce-issue-49593-box-never.rs
@@ -1,7 +1,5 @@
//@ 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,18 +13,21 @@ 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 {
- /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x)
+ /* *mut $0 is coerced to *mut Error here */
+ raw_ptr_box::<_ /* ! */>(x)
//[nofallback]~^ ERROR trait bound `(): std::error::Error` is not satisfied
}
fn no_coercion(d: *mut dyn Error) -> *mut dyn Error {
/* an unsize coercion won't compile here, and it is indeed not used
- because there is nothing requiring the _ to be Sized */
+ because there is nothing requiring the _ to be Sized */
d as *mut _
}
@@ -49,10 +50,9 @@ fn foo_no_never() {
first_iter = true;
}
- let mut y : Option<S> = None;
+ let mut y: Option<S> = None;
// assert types are equal
mem::swap(&mut x, &mut y);
}
-fn main() {
-}
+fn main() {}