Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,14 @@ macro_rules! stack_pin_init {
(let $var:ident $(: $t:ty)? = $val:expr) => {
let val = $val;
let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit());
let mut $var = match $crate::__internal::StackInit::init($var, val) {
// The `Infallible` error type is what requires the initializer to be infallible. It has
// to be annotated here rather than in the `Err` arm below, because binding a value of an
// uninhabited type makes everything following it unreachable.
let res: ::core::result::Result<_, ::core::convert::Infallible> =
$crate::__internal::StackInit::init($var, val);
let mut $var = match res {
Ok(res) => res,
Err(x) => {
let x: ::core::convert::Infallible = x;
match x {}
}
Err(x) => match x {},
};
};
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/compile-fail/init/no_error_coercion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ error[E0277]: `?` couldn't convert the error to `std::alloc::AllocError`
19 | | }? AllocError)
| | ^
| | |
| |______________________the trait `From<Infallible>` is not implemented for `std::alloc::AllocError`
| this can't be annotated with `?` because it has type `Result<_, Infallible>`
| |______________________the trait `From<!>` is not implemented for `std::alloc::AllocError`
| this can't be annotated with `?` because it has type `Result<_, !>`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= note: this error originates in the macro `init` (in Nightly builds, run with -Z macro-backtrace for more info)
2 changes: 1 addition & 1 deletion tests/ui/compile-fail/pin_data/missing_pin.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ error[E0277]: the trait bound `impl PinInit<usize>: Init<usize, _>` is not satis
| |__________- required by a bound introduced by this call
|
help: the trait `Init<usize, _>` is not implemented for `impl PinInit<usize>`
but trait `Init<impl PinInit<usize>, Infallible>` is implemented for it
but trait `Init<impl PinInit<usize>, !>` is implemented for it
--> src/lib.rs
|
| unsafe impl<T> Init<T> for T {}
Expand Down