Skip to content

Commit a663840

Browse files
committed
Auto merge of rust-lang#84840 - Dylan-DPC:rollup-uzk7w0h, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#84072 (Allow setting `target_family` to multiple values, and implement `target_family="wasm"`) - rust-lang#84744 (Add ErrorKind::OutOfMemory) - rust-lang#84784 (Add help message to suggest const for unused type param) - rust-lang#84811 (RustDoc: Fix bounds linking trait.Foo instead of traitalias.Foo) - rust-lang#84818 (suggestion for unit enum variant when matched with a patern) - rust-lang#84832 (Do not print visibility in external traits) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c2fc5c3 + 3538ff6 commit a663840

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

std/src/io/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ pub enum ErrorKind {
186186
/// This means that the operation can never succeed.
187187
#[stable(feature = "unsupported_error", since = "1.53.0")]
188188
Unsupported,
189+
190+
/// An operation could not be completed, because it failed
191+
/// to allocate enough memory.
192+
#[stable(feature = "out_of_memory_error", since = "1.53.0")]
193+
OutOfMemory,
189194
}
190195

191196
impl ErrorKind {
@@ -210,6 +215,7 @@ impl ErrorKind {
210215
ErrorKind::Other => "other os error",
211216
ErrorKind::UnexpectedEof => "unexpected end of file",
212217
ErrorKind::Unsupported => "unsupported",
218+
ErrorKind::OutOfMemory => "out of memory",
213219
}
214220
}
215221
}

std/src/sys/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
149149
libc::ETIMEDOUT => ErrorKind::TimedOut,
150150
libc::EEXIST => ErrorKind::AlreadyExists,
151151
libc::ENOSYS => ErrorKind::Unsupported,
152+
libc::ENOMEM => ErrorKind::OutOfMemory,
152153

153154
// These two constants can have the same value on some systems,
154155
// but different values on others, so we can't use a match

std/src/sys/wasi/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
7777
wasi::ERRNO_EXIST => AlreadyExists,
7878
wasi::ERRNO_AGAIN => WouldBlock,
7979
wasi::ERRNO_NOSYS => Unsupported,
80+
wasi::ERRNO_NOMEM => OutOfMemory,
8081
_ => Other,
8182
}
8283
}

std/src/sys/windows/c.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ pub const ERROR_FILE_NOT_FOUND: DWORD = 2;
168168
pub const ERROR_PATH_NOT_FOUND: DWORD = 3;
169169
pub const ERROR_ACCESS_DENIED: DWORD = 5;
170170
pub const ERROR_INVALID_HANDLE: DWORD = 6;
171+
pub const ERROR_NOT_ENOUGH_MEMORY: DWORD = 8;
172+
pub const ERROR_OUTOFMEMORY: DWORD = 14;
171173
pub const ERROR_NO_MORE_FILES: DWORD = 18;
172174
pub const ERROR_HANDLE_EOF: DWORD = 38;
173175
pub const ERROR_FILE_EXISTS: DWORD = 80;

std/src/sys/windows/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
7171
c::ERROR_PATH_NOT_FOUND => return ErrorKind::NotFound,
7272
c::ERROR_NO_DATA => return ErrorKind::BrokenPipe,
7373
c::ERROR_INVALID_PARAMETER => return ErrorKind::InvalidInput,
74+
c::ERROR_NOT_ENOUGH_MEMORY | c::ERROR_OUTOFMEMORY => return ErrorKind::OutOfMemory,
7475
c::ERROR_SEM_TIMEOUT
7576
| c::WAIT_TIMEOUT
7677
| c::ERROR_DRIVER_CANCEL_TIMEOUT

0 commit comments

Comments
 (0)