From b7ff10378c6fe9eb57aa73e6a68dafcfc18da968 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 14 Apr 2022 21:54:13 -0700 Subject: Update the expected stderr for coerce-issue-49593-box-never. This test's expected stderr now includes a count of the number of types that implment `Error`. This PR introduces two new types, so increment the number by two. --- src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr index 1b1ce67cb0c..99f00034eda 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr +++ b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr @@ -13,7 +13,7 @@ LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x BorrowError BorrowMutError Box - and 43 others + and 45 others = note: required for the cast to the object type `dyn std::error::Error` error[E0277]: the trait bound `(): std::error::Error` is not satisfied @@ -31,7 +31,7 @@ LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x) BorrowError BorrowMutError Box - and 43 others + and 45 others = note: required for the cast to the object type `(dyn std::error::Error + 'static)` error: aborting due to 2 previous errors -- cgit 1.4.1-3-g733a5 From 19ef182655b0ffbaadf859fc774d94bb6fd7e17e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 18 Apr 2022 17:32:25 -0700 Subject: Update the expected stderr for coerce-issue-49593-box-never. --- src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr index 99f00034eda..1b1ce67cb0c 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr +++ b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr @@ -13,7 +13,7 @@ LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x BorrowError BorrowMutError Box - and 45 others + and 43 others = note: required for the cast to the object type `dyn std::error::Error` error[E0277]: the trait bound `(): std::error::Error` is not satisfied @@ -31,7 +31,7 @@ LL | /* *mut $0 is coerced to *mut Error here */ raw_ptr_box::<_ /* ! */>(x) BorrowError BorrowMutError Box - and 45 others + and 43 others = note: required for the cast to the object type `(dyn std::error::Error + 'static)` error: aborting due to 2 previous errors -- cgit 1.4.1-3-g733a5 From ef9a68f2019ff72bc85ff1bb92956141273c476c Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 19 Apr 2022 14:19:50 -0700 Subject: Add ignore-windows to a test. This test has an expected stderr containing text like this: ``` help: the following other types implement trait `std::error::Error`: ... and 43 others ``` However, the number 43 is platform-specific; on Windows, there are two additional types, `InvalidHandleError` and `NullHandleError`, and the number of 45. So for now, disable this test on Windows. --- src/test/ui/coercion/coerce-issue-49593-box-never.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/test') diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never.rs b/src/test/ui/coercion/coerce-issue-49593-box-never.rs index 7a4324bd5ad..16efb65acb2 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never.rs +++ b/src/test/ui/coercion/coerce-issue-49593-box-never.rs @@ -1,4 +1,5 @@ // revisions: nofallback fallback +// ignore-windows - the number of `Error` impls is platform-dependent //[fallback] check-pass //[nofallback] check-fail -- cgit 1.4.1-3-g733a5 From 9d448e849d708cf1bee9065d6dfe70fc7977c3a8 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 19 Apr 2022 14:47:33 -0700 Subject: Update line numbers in the expected output. --- src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr index 1b1ce67cb0c..1daa91f025a 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr +++ b/src/test/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): std::error::Error` is not satisfied - --> $DIR/coerce-issue-49593-box-never.rs:17:53 + --> $DIR/coerce-issue-49593-box-never.rs:18:53 | LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x) | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` @@ -17,7 +17,7 @@ LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x = note: required for the cast to the object type `dyn std::error::Error` error[E0277]: the trait bound `(): std::error::Error` is not satisfied - --> $DIR/coerce-issue-49593-box-never.rs:22:49 + --> $DIR/coerce-issue-49593-box-never.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 `()` -- cgit 1.4.1-3-g733a5 From 839cd04cc44202784436bdd07fd4899f2d67d43a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 26 Apr 2022 09:52:22 -0700 Subject: Add `only-windows` versions of the coerce-issue-49593-box-never test. --- ...issue-49593-box-never-windows.nofallback.stderr | 39 +++++++++++++++ .../coerce-issue-49593-box-never-windows.rs | 58 ++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr create mode 100644 src/test/ui/coercion/coerce-issue-49593-box-never-windows.rs (limited to 'src/test') diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr b/src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr new file mode 100644 index 00000000000..e40e96599fa --- /dev/null +++ b/src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr @@ -0,0 +1,39 @@ +error[E0277]: the trait bound `(): std::error::Error` is not satisfied + --> $DIR/coerce-issue-49593-box-never.rs:18:53 + | +LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x) + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` + | + = help: the following other types implement trait `std::error::Error`: + ! + &'a T + AccessError + AddrParseError + Arc + BorrowError + BorrowMutError + Box + and 45 others + = note: required for the cast to the object type `dyn std::error::Error` + +error[E0277]: the trait bound `(): std::error::Error` is not satisfied + --> $DIR/coerce-issue-49593-box-never.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 `()` + | + = help: the following other types implement trait `std::error::Error`: + ! + &'a T + AccessError + AddrParseError + Arc + BorrowError + BorrowMutError + Box + and 45 others + = note: required for the cast to the object type `(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/src/test/ui/coercion/coerce-issue-49593-box-never-windows.rs b/src/test/ui/coercion/coerce-issue-49593-box-never-windows.rs new file mode 100644 index 00000000000..95d3935caa9 --- /dev/null +++ b/src/test/ui/coercion/coerce-issue-49593-box-never-windows.rs @@ -0,0 +1,58 @@ +// 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) -> *mut T { + panic!() +} + +fn foo(x: !) -> Box { + /* *mut $0 is coerced to Box 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 */ = None; + let mut first_iter = false; + loop { + if !first_iter { + let y: Box + = /* Box<$0> is coerced to Box here */ Box::new(x.unwrap()); + } + + x = Some(S); + first_iter = true; + } + + let mut y : Option = None; + // assert types are equal + mem::swap(&mut x, &mut y); +} + +fn main() { +} -- cgit 1.4.1-3-g733a5 From 531c9373be094ad4e3ee28464dfacbb2fdea50a5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 26 Apr 2022 12:47:24 -0700 Subject: Fix the filename in the expected error message. --- .../coercion/coerce-issue-49593-box-never-windows.nofallback.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr b/src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr index e40e96599fa..ab9cc707aa0 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr +++ b/src/test/ui/coercion/coerce-issue-49593-box-never-windows.nofallback.stderr @@ -1,5 +1,5 @@ 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-windows.rs:18:53 | LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x) | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` @@ -17,7 +17,7 @@ LL | /* *mut $0 is coerced to Box here */ Box::<_ /* ! */>::new(x = note: required for the cast to the object type `dyn std::error::Error` 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-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 `()` -- cgit 1.4.1-3-g733a5