Auto merge of #133527 - matthiaskrgr:rollup-kyre1df, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #132979 (use `--exact` on `--skip` to avoid unintended substring matches)
 - #133248 (CI: split x86_64-msvc-ext job)
 - #133449 (std: expose `const_io_error!` as `const_error!`)
 - #133453 (Commit license-metadata.json to git and check it's correct in CI)
 - #133457 (miri: implement `TlsFree`)
 - #133493 (do not constrain infer vars in `find_best_leaf_obligation`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors
2024-11-27 07:38:21 +00:00
79 changed files with 752 additions and 434 deletions
+1
View File
@@ -28,6 +28,7 @@ path = [
"COPYRIGHT",
"INSTALL.md",
"LICENSE-APACHE",
"license-metadata.json",
"LICENSE-MIT",
"README.md",
"RELEASES.md",
@@ -346,12 +346,21 @@ fn find_best_leaf_obligation<'tcx>(
consider_ambiguities: bool,
) -> PredicateObligation<'tcx> {
let obligation = infcx.resolve_vars_if_possible(obligation.clone());
// FIXME: we use a probe here as the `BestObligation` visitor does not
// check whether it uses candidates which get shadowed by where-bounds.
//
// We should probably fix the visitor to not do so instead, as this also
// means the leaf obligation may be incorrect.
infcx
.visit_proof_tree(obligation.clone().into(), &mut BestObligation {
obligation: obligation.clone(),
consider_ambiguities,
.fudge_inference_if_ok(|| {
infcx
.visit_proof_tree(obligation.clone().into(), &mut BestObligation {
obligation: obligation.clone(),
consider_ambiguities,
})
.break_value()
.ok_or(())
})
.break_value()
.unwrap_or(obligation)
}
+1 -1
View File
@@ -3020,7 +3020,7 @@ fn create_dir_all(&self, path: &Path) -> io::Result<()> {
match path.parent() {
Some(p) => self.create_dir_all(p)?,
None => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Uncategorized,
"failed to create whole tree",
));
@@ -41,7 +41,7 @@ pub fn try_with_capacity(capacity: usize) -> io::Result<Self> {
match Box::try_new_uninit_slice(capacity) {
Ok(buf) => Ok(Self { buf, pos: 0, filled: 0, initialized: 0 }),
Err(_) => {
Err(io::const_io_error!(ErrorKind::OutOfMemory, "failed to allocate read buffer"))
Err(io::const_error!(ErrorKind::OutOfMemory, "failed to allocate read buffer"))
}
}
}
+2 -2
View File
@@ -96,7 +96,7 @@ pub fn new(inner: W) -> BufWriter<W> {
pub(crate) fn try_new_buffer() -> io::Result<Vec<u8>> {
Vec::try_with_capacity(DEFAULT_BUF_SIZE).map_err(|_| {
io::const_io_error!(ErrorKind::OutOfMemory, "failed to allocate write buffer")
io::const_error!(ErrorKind::OutOfMemory, "failed to allocate write buffer")
})
}
@@ -238,7 +238,7 @@ fn drop(&mut self) {
match r {
Ok(0) => {
return Err(io::const_io_error!(
return Err(io::const_error!(
ErrorKind::WriteZero,
"failed to write the buffered data",
));
+2 -2
View File
@@ -304,7 +304,7 @@ fn seek(&mut self, style: SeekFrom) -> io::Result<u64> {
self.pos = n;
Ok(self.pos)
}
None => Err(io::const_io_error!(
None => Err(io::const_error!(
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
)),
@@ -446,7 +446,7 @@ fn reserve_and_pad<A: Allocator>(
buf_len: usize,
) -> io::Result<usize> {
let pos: usize = (*pos_mut).try_into().map_err(|_| {
io::const_io_error!(
io::const_error!(
ErrorKind::InvalidInput,
"cursor position exceeds maximum possible vector length",
)
+40 -27
View File
@@ -76,31 +76,31 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[allow(dead_code)]
impl Error {
pub(crate) const INVALID_UTF8: Self =
const_io_error!(ErrorKind::InvalidData, "stream did not contain valid UTF-8");
const_error!(ErrorKind::InvalidData, "stream did not contain valid UTF-8");
pub(crate) const READ_EXACT_EOF: Self =
const_io_error!(ErrorKind::UnexpectedEof, "failed to fill whole buffer");
const_error!(ErrorKind::UnexpectedEof, "failed to fill whole buffer");
pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_io_error!(
pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_error!(
ErrorKind::NotFound,
"The number of hardware threads is not known for the target platform"
);
pub(crate) const UNSUPPORTED_PLATFORM: Self =
const_io_error!(ErrorKind::Unsupported, "operation not supported on this platform");
const_error!(ErrorKind::Unsupported, "operation not supported on this platform");
pub(crate) const WRITE_ALL_EOF: Self =
const_io_error!(ErrorKind::WriteZero, "failed to write whole buffer");
const_error!(ErrorKind::WriteZero, "failed to write whole buffer");
pub(crate) const ZERO_TIMEOUT: Self =
const_io_error!(ErrorKind::InvalidInput, "cannot set a 0 duration timeout");
const_error!(ErrorKind::InvalidInput, "cannot set a 0 duration timeout");
}
#[stable(feature = "rust1", since = "1.0.0")]
impl From<alloc::ffi::NulError> for Error {
/// Converts a [`alloc::ffi::NulError`] into a [`Error`].
fn from(_: alloc::ffi::NulError) -> Error {
const_io_error!(ErrorKind::InvalidInput, "data provided contains a nul byte")
const_error!(ErrorKind::InvalidInput, "data provided contains a nul byte")
}
}
@@ -151,27 +151,38 @@ enum ErrorData<C> {
// (For the sake of being explicit: the alignment requirement here only matters
// if `error/repr_bitpacked.rs` is in use — for the unpacked repr it doesn't
// matter at all)
#[doc(hidden)]
#[unstable(feature = "io_const_error_internals", issue = "none")]
#[repr(align(4))]
#[derive(Debug)]
pub(crate) struct SimpleMessage {
kind: ErrorKind,
message: &'static str,
pub struct SimpleMessage {
pub kind: ErrorKind,
pub message: &'static str,
}
impl SimpleMessage {
pub(crate) const fn new(kind: ErrorKind, message: &'static str) -> Self {
Self { kind, message }
}
}
/// Creates and returns an `io::Error` for a given `ErrorKind` and constant
/// message. This doesn't allocate.
pub(crate) macro const_io_error($kind:expr, $message:expr $(,)?) {
$crate::io::error::Error::from_static_message({
const MESSAGE_DATA: $crate::io::error::SimpleMessage =
$crate::io::error::SimpleMessage::new($kind, $message);
&MESSAGE_DATA
})
/// Creates a new I/O error from a known kind of error and a string literal.
///
/// Contrary to [`Error::new`], this macro does not allocate and can be used in
/// `const` contexts.
///
/// # Example
/// ```
/// #![feature(io_const_error)]
/// use std::io::{const_error, Error, ErrorKind};
///
/// const FAIL: Error = const_error!(ErrorKind::Unsupported, "tried something that never works");
///
/// fn not_here() -> Result<(), Error> {
/// Err(FAIL)
/// }
/// ```
#[rustc_macro_transparency = "semitransparent"]
#[unstable(feature = "io_const_error", issue = "133448")]
#[allow_internal_unstable(hint_must_use, io_const_error_internals)]
pub macro const_error($kind:expr, $message:expr $(,)?) {
$crate::hint::must_use($crate::io::Error::from_static_message(
const { &$crate::io::SimpleMessage { kind: $kind, message: $message } },
))
}
// As with `SimpleMessage`: `#[repr(align(4))]` here is just because
@@ -592,13 +603,15 @@ fn _new(kind: ErrorKind, error: Box<dyn error::Error + Send + Sync>) -> Error {
///
/// This function does not allocate.
///
/// You should not use this directly, and instead use the `const_io_error!`
/// macro: `io::const_io_error!(ErrorKind::Something, "some_message")`.
/// You should not use this directly, and instead use the `const_error!`
/// macro: `io::const_error!(ErrorKind::Something, "some_message")`.
///
/// This function should maybe change to `from_static_message<const MSG: &'static
/// str>(kind: ErrorKind)` in the future, when const generics allow that.
#[inline]
pub(crate) const fn from_static_message(msg: &'static SimpleMessage) -> Error {
#[doc(hidden)]
#[unstable(feature = "io_const_error_internals", issue = "none")]
pub const fn from_static_message(msg: &'static SimpleMessage) -> Error {
Self { repr: Repr::new_simple_message(msg) }
}
+5 -5
View File
@@ -1,4 +1,4 @@
use super::{Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage, const_io_error};
use super::{Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage, const_error};
use crate::assert_matches::assert_matches;
use crate::mem::size_of;
use crate::sys::decode_error_kind;
@@ -60,7 +60,7 @@ impl error::Error for TestError {}
#[test]
fn test_const() {
const E: Error = const_io_error!(ErrorKind::NotFound, "hello");
const E: Error = const_error!(ErrorKind::NotFound, "hello");
assert_eq!(E.kind(), ErrorKind::NotFound);
assert_eq!(E.to_string(), "hello");
@@ -110,13 +110,13 @@ macro_rules! check_simple_msg {
}};
}
let not_static = const_io_error!(Uncategorized, "not a constant!");
let not_static = const_error!(Uncategorized, "not a constant!");
check_simple_msg!(not_static, Uncategorized, "not a constant!");
const CONST: Error = const_io_error!(NotFound, "definitely a constant!");
const CONST: Error = const_error!(NotFound, "definitely a constant!");
check_simple_msg!(CONST, NotFound, "definitely a constant!");
static STATIC: Error = const_io_error!(BrokenPipe, "a constant, sort of!");
static STATIC: Error = const_error!(BrokenPipe, "a constant, sort of!");
check_simple_msg!(STATIC, BrokenPipe, "a constant, sort of!");
}
+5 -2
View File
@@ -301,12 +301,15 @@
pub use core::io::{BorrowedBuf, BorrowedCursor};
use core::slice::memchr;
pub(crate) use error::const_io_error;
#[stable(feature = "bufwriter_into_parts", since = "1.56.0")]
pub use self::buffered::WriterPanicked;
#[unstable(feature = "raw_os_error_ty", issue = "107792")]
pub use self::error::RawOsError;
#[doc(hidden)]
#[unstable(feature = "io_const_error_internals", issue = "none")]
pub use self::error::SimpleMessage;
#[unstable(feature = "io_const_error", issue = "133448")]
pub use self::error::const_error;
#[stable(feature = "is_terminal", since = "1.70.0")]
pub use self::stdio::IsTerminal;
pub(crate) use self::stdio::attempt_print_to_stderr;
+2 -2
View File
@@ -225,12 +225,12 @@ fn take_eof() {
impl Read for R {
fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
Err(io::const_io_error!(io::ErrorKind::Other, ""))
Err(io::const_error!(io::ErrorKind::Other, ""))
}
}
impl BufRead for R {
fn fill_buf(&mut self) -> io::Result<&[u8]> {
Err(io::const_io_error!(io::ErrorKind::Other, ""))
Err(io::const_error!(io::ErrorKind::Other, ""))
}
fn consume(&mut self, _amt: usize) {}
}
+2
View File
@@ -340,6 +340,7 @@
#![feature(fmt_internals)]
#![feature(hasher_prefixfree_extras)]
#![feature(hashmap_internals)]
#![feature(hint_must_use)]
#![feature(ip)]
#![feature(lazy_get)]
#![feature(maybe_uninit_slice)]
@@ -410,6 +411,7 @@
// Only for const-ness:
// tidy-alphabetical-start
#![feature(const_collections_with_hasher)]
#![feature(io_const_error)]
#![feature(thread_local_internals)]
// tidy-alphabetical-end
//
+1 -1
View File
@@ -84,6 +84,6 @@ fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T>
}
}
Err(last_err.unwrap_or_else(|| {
io::const_io_error!(ErrorKind::InvalidInput, "could not resolve to any addresses")
io::const_error!(ErrorKind::InvalidInput, "could not resolve to any addresses")
}))
}
+1 -3
View File
@@ -203,9 +203,7 @@ pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
pub fn send_to<A: ToSocketAddrs>(&self, buf: &[u8], addr: A) -> io::Result<usize> {
match addr.to_socket_addrs()?.next() {
Some(addr) => self.0.send_to(buf, &addr),
None => {
Err(io::const_io_error!(ErrorKind::InvalidInput, "no addresses to send data to"))
}
None => Err(io::const_error!(ErrorKind::InvalidInput, "no addresses to send data to")),
}
}
+4 -4
View File
@@ -30,14 +30,14 @@ pub(super) fn sockaddr_un(path: &Path) -> io::Result<(libc::sockaddr_un, libc::s
let bytes = path.as_os_str().as_bytes();
if bytes.contains(&0) {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"paths must not contain interior null bytes",
));
}
if bytes.len() >= addr.sun_path.len() {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"path must be shorter than SUN_LEN",
));
@@ -119,7 +119,7 @@ pub(super) fn from_parts(
// linux returns zero bytes of address
len = SUN_PATH_OFFSET as libc::socklen_t; // i.e., zero-length address
} else if addr.sun_family != libc::AF_UNIX as libc::sa_family_t {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"file descriptor did not correspond to a Unix socket",
));
@@ -273,7 +273,7 @@ fn from_abstract_name<N>(name: N) -> crate::io::Result<Self>
addr.sun_family = libc::AF_UNIX as libc::sa_family_t;
if name.len() + 1 > addr.sun_path.len() {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"abstract socket name must be shorter than SUN_LEN",
));
+2 -3
View File
@@ -261,7 +261,7 @@ fn advise(&self, offset: u64, len: u64, advice: u8) -> io::Result<()> {
a if a == wasi::ADVICE_DONTNEED.raw() => wasi::ADVICE_DONTNEED,
a if a == wasi::ADVICE_NOREUSE.raw() => wasi::ADVICE_NOREUSE,
_ => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"invalid parameter 'advice'",
));
@@ -560,6 +560,5 @@ pub fn symlink_path<P: AsRef<Path>, U: AsRef<Path>>(old_path: P, new_path: U) ->
}
fn osstr2str(f: &OsStr) -> io::Result<&str> {
f.to_str()
.ok_or_else(|| io::const_io_error!(io::ErrorKind::Uncategorized, "input must be utf-8"))
f.to_str().ok_or_else(|| io::const_error!(io::ErrorKind::Uncategorized, "input must be utf-8"))
}
+1 -1
View File
@@ -101,7 +101,7 @@ pub(crate) fn set_no_inherit(&self) -> io::Result<()> {
#[cfg(target_vendor = "uwp")]
pub(crate) fn set_no_inherit(&self) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Unavailable on UWP"))
Err(io::const_error!(io::ErrorKind::Unsupported, "Unavailable on UWP"))
}
}
+1 -1
View File
@@ -3581,7 +3581,7 @@ fn description(&self) -> &str {
pub fn absolute<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
let path = path.as_ref();
if path.as_os_str().is_empty() {
Err(io::const_io_error!(io::ErrorKind::InvalidInput, "cannot make an empty path absolute",))
Err(io::const_error!(io::ErrorKind::InvalidInput, "cannot make an empty path absolute",))
} else {
sys::path::absolute(path)
}
@@ -11,7 +11,7 @@
const MAX_STACK_ALLOCATION: usize = 32;
const NUL_ERR: io::Error =
io::const_io_error!(io::ErrorKind::InvalidInput, "file name contained an unexpected NUL byte");
io::const_error!(io::ErrorKind::InvalidInput, "file name contained an unexpected NUL byte");
#[inline]
pub fn run_path_with_cstr<T>(path: &Path, f: &dyn Fn(&CStr) -> io::Result<T>) -> io::Result<T> {
+7 -9
View File
@@ -294,7 +294,7 @@ fn get_access_mode(&self) -> io::Result<i32> {
(false, _, true) => Ok(O_WRONLY | O_APPEND),
(true, _, true) => Ok(O_RDWR | O_APPEND),
(false, false, false) => {
Err(io::const_io_error!(ErrorKind::InvalidInput, "invalid access mode"))
Err(io::const_error!(ErrorKind::InvalidInput, "invalid access mode"))
}
}
}
@@ -304,18 +304,16 @@ fn get_creation_mode(&self) -> io::Result<i32> {
(true, false) => {}
(false, false) => {
if self.truncate || self.create || self.create_new {
return Err(io::const_io_error!(
ErrorKind::InvalidInput,
"invalid creation mode",
));
return Err(
io::const_error!(ErrorKind::InvalidInput, "invalid creation mode",),
);
}
}
(_, true) => {
if self.truncate && !self.create_new {
return Err(io::const_io_error!(
ErrorKind::InvalidInput,
"invalid creation mode",
));
return Err(
io::const_error!(ErrorKind::InvalidInput, "invalid creation mode",),
);
}
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ pub fn unsupported<T>() -> crate::io::Result<T> {
}
pub fn unsupported_err() -> crate::io::Error {
crate::io::const_io_error!(
crate::io::const_error!(
crate::io::ErrorKind::Unsupported,
"operation not supported on HermitCore yet",
)
+2 -2
View File
@@ -87,7 +87,7 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul
loop {
let elapsed = start.elapsed();
if elapsed >= timeout {
return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out"));
return Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out"));
}
let timeout = timeout - elapsed;
@@ -114,7 +114,7 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul
// for POLLHUP rather than read readiness
if pollfd.revents & netc::POLLHUP != 0 {
let e = self.take_error()?.unwrap_or_else(|| {
io::const_io_error!(
io::const_error!(
io::ErrorKind::Uncategorized,
"no error set after POLLHUP",
)
+1 -1
View File
@@ -41,7 +41,7 @@ pub unsafe fn new_with_coreid(
unsafe {
drop(Box::from_raw(p));
}
Err(io::const_io_error!(io::ErrorKind::Uncategorized, "Unable to create thread!"))
Err(io::const_error!(io::ErrorKind::Uncategorized, "Unable to create thread!"))
} else {
Ok(Thread { tid: tid })
};
+2 -2
View File
@@ -48,7 +48,7 @@ pub fn unsupported<T>() -> crate::io::Result<T> {
}
pub fn unsupported_err() -> crate::io::Error {
crate::io::const_io_error!(ErrorKind::Unsupported, "operation not supported on SGX yet")
crate::io::const_error!(ErrorKind::Unsupported, "operation not supported on SGX yet")
}
/// This function is used to implement various functions that doesn't exist,
@@ -59,7 +59,7 @@ pub fn unsupported_err() -> crate::io::Error {
pub fn sgx_ineffective<T>(v: T) -> crate::io::Result<T> {
static SGX_INEFFECTIVE_ERROR: AtomicBool = AtomicBool::new(false);
if SGX_INEFFECTIVE_ERROR.load(Ordering::Relaxed) {
Err(crate::io::const_io_error!(
Err(crate::io::const_error!(
ErrorKind::Uncategorized,
"operation can't be trusted to have any effect on SGX",
))
+5 -8
View File
@@ -303,7 +303,7 @@ fn cstr(path: &Path) -> io::Result<CString> {
if !path.starts_with(br"\") {
// Relative paths aren't supported
return Err(crate::io::const_io_error!(
return Err(crate::io::const_error!(
crate::io::ErrorKind::Unsupported,
"relative path is not supported on this platform",
));
@@ -314,10 +314,7 @@ fn cstr(path: &Path) -> io::Result<CString> {
let wrapped_path = [SAFE_PREFIX, &path, &[0]].concat();
CString::from_vec_with_nul(wrapped_path).map_err(|_| {
crate::io::const_io_error!(
io::ErrorKind::InvalidInput,
"path provided contains a nul byte",
)
crate::io::const_error!(io::ErrorKind::InvalidInput, "path provided contains a nul byte",)
})
}
@@ -512,7 +509,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
pub fn unlink(p: &Path) -> io::Result<()> {
if stat(p)?.file_type().is_dir() {
Err(io::const_io_error!(io::ErrorKind::IsADirectory, "is a directory"))
Err(io::const_error!(io::ErrorKind::IsADirectory, "is a directory"))
} else {
error::SolidError::err_if_negative(unsafe { abi::SOLID_FS_Unlink(cstr(p)?.as_ptr()) })
.map_err(|e| e.as_io_error())?;
@@ -542,7 +539,7 @@ pub fn rmdir(p: &Path) -> io::Result<()> {
.map_err(|e| e.as_io_error())?;
Ok(())
} else {
Err(io::const_io_error!(io::ErrorKind::NotADirectory, "not a directory"))
Err(io::const_error!(io::ErrorKind::NotADirectory, "not a directory"))
}
}
@@ -570,7 +567,7 @@ pub fn remove_dir_all(path: &Path) -> io::Result<()> {
pub fn readlink(p: &Path) -> io::Result<PathBuf> {
// This target doesn't support symlinks
stat(p)?;
Err(io::const_io_error!(io::ErrorKind::InvalidInput, "not a symbolic link"))
Err(io::const_error!(io::ErrorKind::InvalidInput, "not a symbolic link"))
}
pub fn symlink(_original: &Path, _link: &Path) -> io::Result<()> {
+1 -1
View File
@@ -175,7 +175,7 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul
};
match n {
0 => Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")),
0 => Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out")),
_ => {
let can_write = writefds.num_fds != 0;
if !can_write {
+1 -1
View File
@@ -204,7 +204,7 @@ pub unsafe fn unsetenv(n: &OsStr) -> io::Result<()> {
/// In kmclib, `setenv` and `unsetenv` don't always set `errno`, so this
/// function just returns a generic error.
fn cvt_env(t: c_int) -> io::Result<c_int> {
if t == -1 { Err(io::const_io_error!(io::ErrorKind::Uncategorized, "failure")) } else { Ok(t) }
if t == -1 { Err(io::const_error!(io::ErrorKind::Uncategorized, "failure")) } else { Ok(t) }
}
pub fn temp_dir() -> PathBuf {
+14 -16
View File
@@ -13,7 +13,7 @@
use r_efi::protocols::{device_path, device_path_to_text, shell};
use crate::ffi::{OsStr, OsString};
use crate::io::{self, const_io_error};
use crate::io::{self, const_error};
use crate::mem::{MaybeUninit, size_of};
use crate::os::uefi::env::boot_services;
use crate::os::uefi::ffi::{OsStrExt, OsStringExt};
@@ -30,7 +30,7 @@
unsafe extern "efiapi" fn(_: r_efi::efi::Handle, _: ...) -> r_efi::efi::Status;
const BOOT_SERVICES_UNAVAILABLE: io::Error =
const_io_error!(io::ErrorKind::Other, "Boot Services are no longer available");
const_error!(io::ErrorKind::Other, "Boot Services are no longer available");
/// Locates Handles with a particular Protocol GUID.
///
@@ -114,7 +114,7 @@ pub(crate) fn open_protocol<T>(
Err(crate::io::Error::from_raw_os_error(r.as_usize()))
} else {
NonNull::new(unsafe { protocol.assume_init() })
.ok_or(const_io_error!(io::ErrorKind::Other, "null protocol"))
.ok_or(const_error!(io::ErrorKind::Other, "null protocol"))
}
}
@@ -134,7 +134,7 @@ pub(crate) fn create_event(
if r.is_error() {
Err(crate::io::Error::from_raw_os_error(r.as_usize()))
} else {
NonNull::new(event).ok_or(const_io_error!(io::ErrorKind::Other, "null protocol"))
NonNull::new(event).ok_or(const_error!(io::ErrorKind::Other, "null protocol"))
}
}
@@ -155,10 +155,8 @@ pub(crate) unsafe fn close_event(evt: NonNull<crate::ffi::c_void>) -> io::Result
///
/// Note: Some protocols need to be manually freed. It is the caller's responsibility to do so.
pub(crate) fn image_handle_protocol<T>(protocol_guid: Guid) -> io::Result<NonNull<T>> {
let system_handle = uefi::env::try_image_handle().ok_or(io::const_io_error!(
io::ErrorKind::NotFound,
"Protocol not found in Image handle"
))?;
let system_handle = uefi::env::try_image_handle()
.ok_or(io::const_error!(io::ErrorKind::NotFound, "Protocol not found in Image handle"))?;
open_protocol(system_handle, protocol_guid)
}
@@ -178,7 +176,7 @@ fn path_to_text(
};
let path = os_string_from_raw(path_ptr)
.ok_or(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid path"))?;
.ok_or(io::const_error!(io::ErrorKind::InvalidData, "Invalid path"))?;
if let Some(boot_services) = crate::os::uefi::env::boot_services() {
let boot_services: NonNull<r_efi::efi::BootServices> = boot_services.cast();
@@ -213,7 +211,7 @@ fn path_to_text(
}
}
Err(io::const_io_error!(io::ErrorKind::NotFound, "No device path to text protocol found"))
Err(io::const_error!(io::ErrorKind::NotFound, "No device path to text protocol found"))
}
/// Gets RuntimeServices.
@@ -234,7 +232,7 @@ fn inner(
) -> io::Result<DevicePath> {
let path_vec = p.encode_wide().chain(Some(0)).collect::<Vec<u16>>();
if path_vec[..path_vec.len() - 1].contains(&0) {
return Err(const_io_error!(
return Err(const_error!(
io::ErrorKind::InvalidInput,
"strings passed to UEFI cannot contain NULs",
));
@@ -243,9 +241,9 @@ fn inner(
let path =
unsafe { ((*protocol.as_ptr()).convert_text_to_device_path)(path_vec.as_ptr()) };
NonNull::new(path).map(DevicePath).ok_or_else(|| {
const_io_error!(io::ErrorKind::InvalidFilename, "Invalid Device Path")
})
NonNull::new(path)
.map(DevicePath)
.ok_or_else(|| const_error!(io::ErrorKind::InvalidFilename, "Invalid Device Path"))
}
static LAST_VALID_HANDLE: AtomicPtr<crate::ffi::c_void> =
@@ -271,7 +269,7 @@ fn inner(
}
}
io::Result::Err(const_io_error!(
io::Result::Err(const_error!(
io::ErrorKind::NotFound,
"DevicePathFromText Protocol not found"
))
@@ -326,7 +324,7 @@ pub(crate) unsafe fn create(protocol: T, mut guid: r_efi::efi::Guid) -> io::Resu
};
let handle = NonNull::new(handle)
.ok_or(io::const_io_error!(io::ErrorKind::Uncategorized, "found null handle"))?;
.ok_or(io::const_error!(io::ErrorKind::Uncategorized, "found null handle"))?;
Ok(Self { guid, handle, protocol })
}
+1 -1
View File
@@ -95,7 +95,7 @@ pub const fn unsupported<T>() -> std_io::Result<T> {
#[inline]
pub const fn unsupported_err() -> std_io::Error {
std_io::const_io_error!(std_io::ErrorKind::Unsupported, "operation not supported on UEFI",)
std_io::const_error!(std_io::ErrorKind::Unsupported, "operation not supported on UEFI",)
}
pub fn decode_error_kind(code: RawOsError) -> crate::io::ErrorKind {
+6 -6
View File
@@ -131,7 +131,7 @@ pub fn getcwd() -> io::Result<PathBuf> {
let path_ptr = unsafe { ((*shell.as_ptr()).get_cur_dir)(crate::ptr::null_mut()) };
helpers::os_string_from_raw(path_ptr)
.map(PathBuf::from)
.ok_or(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid path"))
.ok_or(io::const_error!(io::ErrorKind::InvalidData, "Invalid path"))
}
None => {
let mut t = current_exe()?;
@@ -147,7 +147,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> {
let shell = helpers::open_shell().ok_or(unsupported_err())?;
let mut p = helpers::os_string_to_raw(p.as_os_str())
.ok_or(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid path"))?;
.ok_or(io::const_error!(io::ErrorKind::InvalidData, "Invalid path"))?;
let r = unsafe { ((*shell.as_ptr()).set_cur_dir)(crate::ptr::null_mut(), p.as_mut_ptr()) };
if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) }
@@ -290,15 +290,15 @@ pub(crate) fn get(key: &OsStr) -> Option<OsString> {
pub(crate) fn set(key: &OsStr, val: &OsStr) -> io::Result<()> {
let mut key_ptr = helpers::os_string_to_raw(key)
.ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?;
.ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?;
let mut val_ptr = helpers::os_string_to_raw(val)
.ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?;
.ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?;
unsafe { set_raw(key_ptr.as_mut_ptr(), val_ptr.as_mut_ptr()) }
}
pub(crate) fn unset(key: &OsStr) -> io::Result<()> {
let mut key_ptr = helpers::os_string_to_raw(key)
.ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?;
.ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?;
unsafe { set_raw(key_ptr.as_mut_ptr(), crate::ptr::null_mut()) }
}
@@ -328,7 +328,7 @@ pub(crate) fn get_all() -> io::Result<Vec<(OsString, OsString)>> {
});
// SAFETY: val.add(start) is always NULL terminated
let val = unsafe { get_raw(shell, val.add(start)) }
.ok_or(io::const_io_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?;
.ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?;
vars.push((key, val));
start = i + 1;
+4 -4
View File
@@ -307,7 +307,7 @@ mod uefi_command_internal {
use super::super::helpers;
use crate::ffi::{OsStr, OsString};
use crate::io::{self, const_io_error};
use crate::io::{self, const_error};
use crate::mem::MaybeUninit;
use crate::os::uefi::env::{boot_services, image_handle, system_table};
use crate::os::uefi::ffi::{OsStrExt, OsStringExt};
@@ -328,7 +328,7 @@ impl Image {
pub fn load_image(p: &OsStr) -> io::Result<Self> {
let path = helpers::DevicePath::from_text(p)?;
let boot_services: NonNull<r_efi::efi::BootServices> = boot_services()
.ok_or_else(|| const_io_error!(io::ErrorKind::NotFound, "Boot Services not found"))?
.ok_or_else(|| const_error!(io::ErrorKind::NotFound, "Boot Services not found"))?
.cast();
let mut child_handle: MaybeUninit<r_efi::efi::Handle> = MaybeUninit::uninit();
let image_handle = image_handle();
@@ -369,7 +369,7 @@ pub fn start_image(&mut self) -> io::Result<r_efi::efi::Status> {
}
let boot_services: NonNull<r_efi::efi::BootServices> = boot_services()
.ok_or_else(|| const_io_error!(io::ErrorKind::NotFound, "Boot Services not found"))?
.ok_or_else(|| const_error!(io::ErrorKind::NotFound, "Boot Services not found"))?
.cast();
let mut exit_data_size: usize = 0;
let mut exit_data: MaybeUninit<*mut u16> = MaybeUninit::uninit();
@@ -583,7 +583,7 @@ pub fn utf8(&self) -> io::Result<Vec<u8>> {
OsString::from_wide(&self._buffer)
.into_string()
.map(Into::into)
.map_err(|_| const_io_error!(io::ErrorKind::Other, "utf8 conversion failed"))
.map_err(|_| const_error!(io::ErrorKind::Other, "utf8 conversion failed"))
}
extern "efiapi" fn reset(
+13 -13
View File
@@ -559,7 +559,7 @@ pub fn created(&self) -> io::Result<SystemTime> {
return if (ext.stx_mask & libc::STATX_BTIME) != 0 {
SystemTime::new(ext.stx_btime.tv_sec, ext.stx_btime.tv_nsec as i64)
} else {
Err(io::const_io_error!(
Err(io::const_error!(
io::ErrorKind::Unsupported,
"creation time is not available for the filesystem",
))
@@ -567,7 +567,7 @@ pub fn created(&self) -> io::Result<SystemTime> {
}
}
Err(io::const_io_error!(
Err(io::const_error!(
io::ErrorKind::Unsupported,
"creation time is not available on this platform \
currently",
@@ -1272,7 +1272,7 @@ pub fn lock(&self) -> io::Result<()> {
target_vendor = "apple",
)))]
pub fn lock(&self) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "lock() not supported"))
Err(io::const_error!(io::ErrorKind::Unsupported, "lock() not supported"))
}
#[cfg(any(
@@ -1293,7 +1293,7 @@ pub fn lock_shared(&self) -> io::Result<()> {
target_vendor = "apple",
)))]
pub fn lock_shared(&self) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "lock_shared() not supported"))
Err(io::const_error!(io::ErrorKind::Unsupported, "lock_shared() not supported"))
}
#[cfg(any(
@@ -1320,7 +1320,7 @@ pub fn try_lock(&self) -> io::Result<bool> {
target_vendor = "apple",
)))]
pub fn try_lock(&self) -> io::Result<bool> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "try_lock() not supported"))
Err(io::const_error!(io::ErrorKind::Unsupported, "try_lock() not supported"))
}
#[cfg(any(
@@ -1347,7 +1347,7 @@ pub fn try_lock_shared(&self) -> io::Result<bool> {
target_vendor = "apple",
)))]
pub fn try_lock_shared(&self) -> io::Result<bool> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "try_lock_shared() not supported"))
Err(io::const_error!(io::ErrorKind::Unsupported, "try_lock_shared() not supported"))
}
#[cfg(any(
@@ -1368,7 +1368,7 @@ pub fn unlock(&self) -> io::Result<()> {
target_vendor = "apple",
)))]
pub fn unlock(&self) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "unlock() not supported"))
Err(io::const_error!(io::ErrorKind::Unsupported, "unlock() not supported"))
}
pub fn truncate(&self, size: u64) -> io::Result<()> {
@@ -1459,11 +1459,11 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
)))]
let to_timespec = |time: Option<SystemTime>| match time {
Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts),
Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!(
Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_error!(
io::ErrorKind::InvalidInput,
"timestamp is too large to set as a file time"
)),
Some(_) => Err(io::const_io_error!(
Some(_) => Err(io::const_error!(
io::ErrorKind::InvalidInput,
"timestamp is too small to set as a file time"
)),
@@ -1476,7 +1476,7 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
// the same as for Redox.
// `futimens` and `UTIME_OMIT` are a work in progress for vxworks.
let _ = times;
Err(io::const_io_error!(
Err(io::const_error!(
io::ErrorKind::Unsupported,
"setting file times not supported",
))
@@ -1515,7 +1515,7 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
weak!(fn futimens(c_int, *const libc::timespec) -> c_int);
match futimens.get() {
Some(futimens) => futimens(self.as_raw_fd(), times.as_ptr()),
None => return Err(io::const_io_error!(
None => return Err(io::const_error!(
io::ErrorKind::Unsupported,
"setting file times requires Android API level >= 19",
)),
@@ -2090,7 +2090,7 @@ pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
#[cfg(target_os = "vxworks")]
pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
let (_, _, _) = (path, uid, gid);
Err(io::const_io_error!(io::ErrorKind::Unsupported, "lchown not supported by vxworks"))
Err(io::const_error!(io::ErrorKind::Unsupported, "lchown not supported by vxworks"))
}
#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
@@ -2101,7 +2101,7 @@ pub fn chroot(dir: &Path) -> io::Result<()> {
#[cfg(target_os = "vxworks")]
pub fn chroot(dir: &Path) -> io::Result<()> {
let _ = dir;
Err(io::const_io_error!(io::ErrorKind::Unsupported, "chroot not supported by vxworks"))
Err(io::const_error!(io::ErrorKind::Unsupported, "chroot not supported by vxworks"))
}
pub use remove_dir_impl::remove_dir_all;
+1 -1
View File
@@ -1,6 +1,6 @@
macro_rules! unimpl {
() => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Unsupported,
"No networking available on L4Re.",
));
+2 -2
View File
@@ -190,7 +190,7 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul
loop {
let elapsed = start.elapsed();
if elapsed >= timeout {
return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out"));
return Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out"));
}
let timeout = timeout - elapsed;
@@ -225,7 +225,7 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul
// for POLLHUP or POLLERR rather than read readiness
if pollfd.revents & (libc::POLLHUP | libc::POLLERR) != 0 {
let e = self.take_error()?.unwrap_or_else(|| {
io::const_io_error!(
io::const_error!(
io::ErrorKind::Uncategorized,
"no error set after POLLHUP",
)
+11 -12
View File
@@ -258,7 +258,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
use crate::env;
use crate::io::ErrorKind;
let exe_path = env::args().next().ok_or(io::const_io_error!(
let exe_path = env::args().next().ok_or(io::const_error!(
ErrorKind::NotFound,
"an executable path was not found because no arguments were provided through argv"
))?;
@@ -284,7 +284,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
}
}
}
Err(io::const_io_error!(ErrorKind::NotFound, "an executable path was not found"))
Err(io::const_error!(ErrorKind::NotFound, "an executable path was not found"))
}
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
@@ -340,7 +340,7 @@ fn sysctl() -> io::Result<PathBuf> {
0,
))?;
if path_len <= 1 {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Uncategorized,
"KERN_PROC_PATHNAME sysctl returned zero-length string",
));
@@ -363,7 +363,7 @@ fn procfs() -> io::Result<PathBuf> {
if curproc_exe.is_file() {
return crate::fs::read_link(curproc_exe);
}
Err(io::const_io_error!(
Err(io::const_error!(
io::ErrorKind::Uncategorized,
"/proc/curproc/exe doesn't point to regular file.",
))
@@ -382,10 +382,9 @@ pub fn current_exe() -> io::Result<PathBuf> {
cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_len, ptr::null_mut(), 0))?;
argv.set_len(argv_len as usize);
if argv[0].is_null() {
return Err(io::const_io_error!(
io::ErrorKind::Uncategorized,
"no current exe available",
));
return Err(
io::const_error!(io::ErrorKind::Uncategorized, "no current exe available",),
);
}
let argv0 = CStr::from_ptr(argv[0]).to_bytes();
if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') {
@@ -405,7 +404,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
))]
pub fn current_exe() -> io::Result<PathBuf> {
match crate::fs::read_link("/proc/self/exe") {
Err(ref e) if e.kind() == io::ErrorKind::NotFound => Err(io::const_io_error!(
Err(ref e) if e.kind() == io::ErrorKind::NotFound => Err(io::const_error!(
io::ErrorKind::Uncategorized,
"no /proc/self/exe available. Is /proc mounted?",
)),
@@ -476,7 +475,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
);
if result != libc::B_OK {
use crate::io::ErrorKind;
Err(io::const_io_error!(ErrorKind::Uncategorized, "Error getting executable path"))
Err(io::const_error!(ErrorKind::Uncategorized, "Error getting executable path"))
} else {
// find_path adds the null terminator.
let name = CStr::from_ptr(name.as_ptr()).to_bytes();
@@ -493,7 +492,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
#[cfg(target_os = "l4re")]
pub fn current_exe() -> io::Result<PathBuf> {
use crate::io::ErrorKind;
Err(io::const_io_error!(ErrorKind::Unsupported, "Not yet implemented!"))
Err(io::const_error!(ErrorKind::Unsupported, "Not yet implemented!"))
}
#[cfg(target_os = "vxworks")]
@@ -523,7 +522,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
use crate::env;
use crate::io::ErrorKind;
let exe_path = env::args().next().ok_or(io::const_io_error!(
let exe_path = env::args().next().ok_or(io::const_error!(
ErrorKind::Uncategorized,
"an executable path was not found because no arguments were provided through argv"
))?;
@@ -18,7 +18,7 @@ pub fn spawn(
let envp = self.capture_env();
if self.saw_nul() {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"nul byte found in provided data",
));
@@ -38,7 +38,7 @@ pub fn output(&mut self) -> io::Result<(ExitStatus, Vec<u8>, Vec<u8>)> {
pub fn exec(&mut self, default: Stdio) -> io::Error {
if self.saw_nul() {
return io::const_io_error!(
return io::const_error!(
io::ErrorKind::InvalidInput,
"nul byte found in provided data",
);
@@ -185,7 +185,7 @@ pub fn wait(&mut self) -> io::Result<ExitStatus> {
))?;
}
if actual != 1 {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidData,
"Failed to get exit status of process",
));
@@ -222,7 +222,7 @@ pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
))?;
}
if actual != 1 {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidData,
"Failed to get exit status of process",
));
@@ -61,7 +61,7 @@ pub fn spawn(
let envp = self.capture_env();
if self.saw_nul() {
return Err(io::const_io_error!(
return Err(io::const_error!(
ErrorKind::InvalidInput,
"nul byte found in provided data",
));
@@ -175,7 +175,7 @@ pub fn output(&mut self) -> io::Result<(ExitStatus, Vec<u8>, Vec<u8>)> {
// allowed to exist in dead code), but it sounds bad, so we go out of our
// way to avoid that all-together.
#[cfg(any(target_os = "tvos", target_os = "watchos"))]
const ERR_APPLE_TV_WATCH_NO_FORK_EXEC: Error = io::const_io_error!(
const ERR_APPLE_TV_WATCH_NO_FORK_EXEC: Error = io::const_error!(
ErrorKind::Unsupported,
"`fork`+`exec`-based process spawning is not supported on this target",
);
@@ -218,7 +218,7 @@ unsafe fn do_fork(&mut self) -> Result<pid_t, io::Error> {
} else if delay < MAX_FORKSPAWN_SLEEP {
thread::sleep(delay);
} else {
return Err(io::const_io_error!(
return Err(io::const_error!(
ErrorKind::WouldBlock,
"forking returned EBADF too often",
));
@@ -235,7 +235,7 @@ pub fn exec(&mut self, default: Stdio) -> io::Error {
let envp = self.capture_env();
if self.saw_nul() {
return io::const_io_error!(ErrorKind::InvalidInput, "nul byte found in provided data",);
return io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data",);
}
match self.setup_io(default, true) {
@@ -561,7 +561,7 @@ unsafe fn retrying_libc_posix_spawnp(
} else if delay < MAX_FORKSPAWN_SLEEP {
thread::sleep(delay);
} else {
return Err(io::const_io_error!(
return Err(io::const_error!(
ErrorKind::WouldBlock,
"posix_spawnp returned EBADF too often",
));
@@ -22,7 +22,7 @@ pub fn spawn(
let envp = self.capture_env();
if self.saw_nul() {
return Err(io::const_io_error!(
return Err(io::const_error!(
ErrorKind::InvalidInput,
"nul byte found in provided data",
));
+2 -2
View File
@@ -469,7 +469,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
unsafe {
use libc::_syspage_ptr;
if _syspage_ptr.is_null() {
Err(io::const_io_error!(io::ErrorKind::NotFound, "No syspage available"))
Err(io::const_error!(io::ErrorKind::NotFound, "No syspage available"))
} else {
let cpus = (*_syspage_ptr).num_cpu;
NonZero::new(cpus as usize)
@@ -509,7 +509,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
}
} else {
// FIXME: implement on Redox, l4re
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))
Err(io::const_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))
}
}
}
+1 -1
View File
@@ -96,7 +96,7 @@ const fn new(tv_sec: i64, tv_nsec: i64) -> Result<Timespec, io::Error> {
if tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC as i64 {
Ok(unsafe { Self::new_unchecked(tv_sec, tv_nsec) })
} else {
Err(io::const_io_error!(io::ErrorKind::InvalidData, "Invalid timestamp"))
Err(io::const_error!(io::ErrorKind::InvalidData, "Invalid timestamp"))
}
}
+2 -2
View File
@@ -96,11 +96,11 @@ pub fn getenv(_: &OsStr) -> Option<OsString> {
}
pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform"))
Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform"))
}
pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform"))
Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform"))
}
pub fn temp_dir() -> PathBuf {
+3 -4
View File
@@ -496,7 +496,7 @@ pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> {
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
let to_timestamp = |time: Option<SystemTime>| match time {
Some(time) if let Some(ts) = time.to_wasi_timestamp() => Ok(ts),
Some(_) => Err(io::const_io_error!(
Some(_) => Err(io::const_error!(
io::ErrorKind::InvalidInput,
"timestamp is too large to set as a file time"
)),
@@ -764,8 +764,7 @@ pub fn __wasilibc_find_relpath(
}
pub fn osstr2str(f: &OsStr) -> io::Result<&str> {
f.to_str()
.ok_or_else(|| io::const_io_error!(io::ErrorKind::Uncategorized, "input must be utf-8"))
f.to_str().ok_or_else(|| io::const_error!(io::ErrorKind::Uncategorized, "input must be utf-8"))
}
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
@@ -811,7 +810,7 @@ fn remove_dir_all_recursive(parent: &WasiFd, path: &Path) -> io::Result<()> {
for entry in ReadDir::new(fd, dummy_root) {
let entry = entry?;
let path = crate::str::from_utf8(&entry.name).map_err(|_| {
io::const_io_error!(io::ErrorKind::Uncategorized, "invalid utf-8 file name found")
io::const_error!(io::ErrorKind::Uncategorized, "invalid utf-8 file name found")
})?;
let result: io::Result<()> = try {
+1 -1
View File
@@ -117,7 +117,7 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul
loop {
let elapsed = start.elapsed();
if elapsed >= timeout {
return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out"));
return Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out"));
}
let timeout = timeout - elapsed;
+2 -2
View File
@@ -327,7 +327,7 @@ pub(crate) fn make_bat_command_line(
force_quotes: bool,
) -> io::Result<Vec<u16>> {
const INVALID_ARGUMENT_ERROR: io::Error =
io::const_io_error!(io::ErrorKind::InvalidInput, r#"batch file arguments are invalid"#);
io::const_error!(io::ErrorKind::InvalidInput, r#"batch file arguments are invalid"#);
// Set the start of the command line to `cmd.exe /c "`
// It is necessary to surround the command in an extra pair of quotes,
// hence the trailing quote here. It will be closed after all arguments
@@ -340,7 +340,7 @@ pub(crate) fn make_bat_command_line(
// Windows file names cannot contain a `"` character or end with `\\`.
// If the script name does then return an error.
if script.contains(&(b'"' as u16)) || script.last() == Some(&(b'\\' as u16)) {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"Windows file names may not contain `\"` or end with `\\`"
));
+8 -12
View File
@@ -677,7 +677,7 @@ fn readlink(&self) -> io::Result<PathBuf> {
)
}
_ => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Uncategorized,
"Unsupported reparse point type",
));
@@ -718,7 +718,7 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
|| times.modified.map_or(false, is_zero)
|| times.created.map_or(false, is_zero)
{
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"Cannot set file timestamp to 0",
));
@@ -728,7 +728,7 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
|| times.modified.map_or(false, is_max)
|| times.created.map_or(false, is_max)
{
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"Cannot set file timestamp to 0xFFFF_FFFF_FFFF_FFFF",
));
@@ -1305,10 +1305,9 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
#[cfg(target_vendor = "uwp")]
pub fn link(_original: &Path, _link: &Path) -> io::Result<()> {
return Err(io::const_io_error!(
io::ErrorKind::Unsupported,
"hard link are not supported on UWP",
));
return Err(
io::const_error!(io::ErrorKind::Unsupported, "hard link are not supported on UWP",),
);
}
pub fn stat(path: &Path) -> io::Result<FileAttr> {
@@ -1495,7 +1494,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> {
let bytes = unsafe { OsStr::from_encoded_bytes_unchecked(&abs_path[2..]) };
r"\??\UNC\".encode_utf16().chain(bytes.encode_wide()).collect()
} else {
return Err(io::const_io_error!(io::ErrorKind::InvalidInput, "path is not valid"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, "path is not valid"));
}
};
// Defined inline so we don't have to mess about with variable length buffer.
@@ -1512,10 +1511,7 @@ pub struct MountPointBuffer {
}
let data_len = 12 + (abs_path.len() * 2);
if data_len > u16::MAX as usize {
return Err(io::const_io_error!(
io::ErrorKind::InvalidInput,
"`original` path is too long"
));
return Err(io::const_error!(io::ErrorKind::InvalidInput, "`original` path is too long"));
}
let data_len = data_len as u16;
let mut header = MountPointBuffer {
+1 -1
View File
@@ -183,7 +183,7 @@ fn inner(s: &OsStr) -> crate::io::Result<Vec<u16>> {
maybe_result.extend(s.encode_wide());
if unrolled_find_u16s(0, &maybe_result).is_some() {
return Err(crate::io::const_io_error!(
return Err(crate::io::const_error!(
ErrorKind::InvalidInput,
"strings passed to WinAPI cannot contain NULs",
));
+1 -1
View File
@@ -267,7 +267,7 @@ pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Resul
};
match count {
0 => Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")),
0 => Err(io::const_error!(io::ErrorKind::TimedOut, "connection timed out")),
_ => {
if writefds.fd_count != 1 {
if let Some(e) = self.take_error()? {
+6 -7
View File
@@ -144,7 +144,7 @@ fn as_ref(&self) -> &OsStr {
pub(crate) fn ensure_no_nuls<T: AsRef<OsStr>>(str: T) -> io::Result<T> {
if str.as_ref().encode_wide().any(|b| b == 0) {
Err(io::const_io_error!(ErrorKind::InvalidInput, "nul byte found in provided data"))
Err(io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data"))
} else {
Ok(str)
}
@@ -439,10 +439,9 @@ fn resolve_exe<'a>(
) -> io::Result<Vec<u16>> {
// Early return if there is no filename.
if exe_path.is_empty() || path::has_trailing_slash(exe_path) {
return Err(io::const_io_error!(
io::ErrorKind::InvalidInput,
"program path has no file name",
));
return Err(
io::const_error!(io::ErrorKind::InvalidInput, "program path has no file name",),
);
}
// Test if the file name has the `exe` extension.
// This does a case-insensitive `ends_with`.
@@ -492,7 +491,7 @@ fn resolve_exe<'a>(
}
}
// If we get here then the executable cannot be found.
Err(io::const_io_error!(io::ErrorKind::NotFound, "program not found"))
Err(io::const_error!(io::ErrorKind::NotFound, "program not found"))
}
// Calls `f` for every path that should be used to find an executable.
@@ -921,7 +920,7 @@ fn make_proc_thread_attribute_list(
// a null pointer to retrieve the required size.
let mut required_size = 0;
let Ok(attribute_count) = attributes.len().try_into() else {
return Err(io::const_io_error!(
return Err(io::const_error!(
ErrorKind::InvalidInput,
"maximum number of ProcThreadAttributes exceeded",
));
+4 -4
View File
@@ -107,7 +107,7 @@ fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> i
if data[0] >> 6 != 0b10 {
// not a continuation byte - reject
incomplete_utf8.len = 0;
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidData,
"Windows stdio in console mode does not support writing non-UTF-8 byte sequences",
));
@@ -129,7 +129,7 @@ fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> i
return Ok(1);
}
Err(_) => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidData,
"Windows stdio in console mode does not support writing non-UTF-8 byte sequences",
));
@@ -153,7 +153,7 @@ fn write(handle_id: u32, data: &[u8], incomplete_utf8: &mut IncompleteUtf8) -> i
incomplete_utf8.len = 1;
return Ok(1);
} else {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidData,
"Windows stdio in console mode does not support writing non-UTF-8 byte sequences",
));
@@ -392,7 +392,7 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result<usize> {
};
if result == 0 {
// We can't really do any better than forget all data and return an error.
Err(io::const_io_error!(
Err(io::const_error!(
io::ErrorKind::InvalidData,
"Windows stdin in console mode does not support non-UTF-16 input; \
encountered unpaired surrogate",
+2 -3
View File
@@ -107,7 +107,7 @@ macro_rules! try_opt {
($e:expr, $msg:expr) => {
match $e {
Some(r) => r,
None => return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &$msg)),
None => return Err(io::const_error!(io::ErrorKind::InvalidInput, &$msg)),
}
};
}
@@ -123,7 +123,6 @@ impl TryFrom<(&str, u16)> for LookupHost {
type Error = io::Error;
fn try_from(v: (&str, u16)) -> io::Result<LookupHost> {
lookup(v.0, v.1)
.map_err(|_e| io::const_io_error!(io::ErrorKind::InvalidInput, &"DNS failure"))
lookup(v.0, v.1).map_err(|_e| io::const_error!(io::ErrorKind::InvalidInput, &"DNS failure"))
}
}
+16 -20
View File
@@ -9,7 +9,7 @@
macro_rules! unimpl {
() => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Unsupported,
&"This function is not yet implemented",
));
@@ -71,7 +71,7 @@ fn bind_inner(addr: &mut SocketAddr) -> io::Result<u16> {
0,
4096,
) else {
return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Invalid response"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Invalid response"));
};
// The first four bytes should be zero upon success, and will be nonzero
@@ -80,16 +80,13 @@ fn bind_inner(addr: &mut SocketAddr) -> io::Result<u16> {
if response[0] != 0 || valid == 0 {
let errcode = response[1];
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_io_error!(io::ErrorKind::ResourceBusy, &"Socket in use"));
return Err(io::const_error!(io::ErrorKind::ResourceBusy, &"Socket in use"));
} else if errcode == NetError::Invalid as u8 {
return Err(io::const_io_error!(
io::ErrorKind::AddrNotAvailable,
&"Invalid address"
));
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, &"Invalid address"));
} else if errcode == NetError::LibraryError as u8 {
return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error"));
return Err(io::const_error!(io::ErrorKind::Other, &"Library error"));
} else {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Other,
&"Unable to connect or internal error"
));
@@ -130,16 +127,15 @@ pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
if receive_request.raw[0] != 0 {
// error case
if receive_request.raw[1] == NetError::TimedOut as u8 {
return Err(io::const_io_error!(io::ErrorKind::TimedOut, &"accept timed out",));
return Err(io::const_error!(io::ErrorKind::TimedOut, &"accept timed out",));
} else if receive_request.raw[1] == NetError::WouldBlock as u8 {
return Err(io::const_io_error!(
io::ErrorKind::WouldBlock,
&"accept would block",
));
return Err(
io::const_error!(io::ErrorKind::WouldBlock, &"accept would block",),
);
} else if receive_request.raw[1] == NetError::LibraryError as u8 {
return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error"));
return Err(io::const_error!(io::ErrorKind::Other, &"Library error"));
} else {
return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",));
return Err(io::const_error!(io::ErrorKind::Other, &"library error",));
}
} else {
// accept successful
@@ -163,7 +159,7 @@ pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
port,
)
} else {
return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",));
return Err(io::const_error!(io::ErrorKind::Other, &"library error",));
};
// replenish the listener
@@ -175,7 +171,7 @@ pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
Ok((TcpStream::from_listener(stream_fd, self.local.port(), port, addr), addr))
}
} else {
Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unable to accept"))
Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unable to accept"))
}
}
@@ -192,7 +188,7 @@ pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {
services::net_server(),
services::NetBlockingScalar::StdSetTtlTcp(self.fd.load(Ordering::Relaxed), ttl).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|_| ())
}
@@ -201,7 +197,7 @@ pub fn ttl(&self) -> io::Result<u32> {
services::net_server(),
services::NetBlockingScalar::StdGetTtlTcp(self.fd.load(Ordering::Relaxed)).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|res| res[0] as _)?)
}
+20 -26
View File
@@ -10,7 +10,7 @@
macro_rules! unimpl {
() => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Unsupported,
&"This function is not yet implemented",
));
@@ -96,7 +96,7 @@ pub fn connect_timeout(addr: &SocketAddr, duration: Duration) -> io::Result<TcpS
0,
4096,
) else {
return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Invalid response"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Invalid response"));
};
// The first four bytes should be zero upon success, and will be nonzero
@@ -106,14 +106,11 @@ pub fn connect_timeout(addr: &SocketAddr, duration: Duration) -> io::Result<TcpS
// errcode is a u8 but stuck in a u16 where the upper byte is invalid. Mask & decode accordingly.
let errcode = response[0];
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_io_error!(io::ErrorKind::ResourceBusy, &"Socket in use",));
return Err(io::const_error!(io::ErrorKind::ResourceBusy, &"Socket in use",));
} else if errcode == NetError::Unaddressable as u8 {
return Err(io::const_io_error!(
io::ErrorKind::AddrNotAvailable,
&"Invalid address",
));
return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, &"Invalid address",));
} else {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
&"Unable to connect or internal error",
));
@@ -199,7 +196,7 @@ fn read_or_peek(&self, buf: &mut [u8], op: ReadOrPeek) -> io::Result<usize> {
self.read_timeout.load(Ordering::Relaxed) as usize,
data_to_read,
) else {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
&"Library failure: wrong message type or messaging error"
));
@@ -215,14 +212,14 @@ fn read_or_peek(&self, buf: &mut [u8], op: ReadOrPeek) -> io::Result<usize> {
if result[0] != 0 {
if result[1] == 8 {
// timed out
return Err(io::const_io_error!(io::ErrorKind::TimedOut, &"Timeout",));
return Err(io::const_error!(io::ErrorKind::TimedOut, &"Timeout",));
}
if result[1] == 9 {
// would block
return Err(io::const_io_error!(io::ErrorKind::WouldBlock, &"Would block",));
return Err(io::const_error!(io::ErrorKind::WouldBlock, &"Would block",));
}
}
Err(io::const_io_error!(io::ErrorKind::Other, &"recv_slice failure"))
Err(io::const_error!(io::ErrorKind::Other, &"recv_slice failure"))
}
}
@@ -261,23 +258,20 @@ pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
self.write_timeout.load(Ordering::Relaxed) as usize,
buf_len,
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Internal error")))?;
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Internal error")))?;
if send_request.raw[0] != 0 {
if send_request.raw[4] == 8 {
// timed out
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::BrokenPipe,
&"Timeout or connection closed",
));
} else if send_request.raw[4] == 9 {
// would block
return Err(io::const_io_error!(io::ErrorKind::WouldBlock, &"Would block",));
return Err(io::const_error!(io::ErrorKind::WouldBlock, &"Would block",));
} else {
return Err(io::const_io_error!(
io::ErrorKind::InvalidInput,
&"Error when sending",
));
return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Error when sending",));
}
}
Ok(u32::from_le_bytes([
@@ -310,7 +304,7 @@ pub fn socket_addr(&self) -> io::Result<SocketAddr> {
0,
0,
) else {
return Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Internal error"));
return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Internal error"));
};
let mut i = get_addr.raw.iter();
match *i.next().unwrap() {
@@ -330,7 +324,7 @@ pub fn socket_addr(&self) -> io::Result<SocketAddr> {
}
Ok(SocketAddr::V6(SocketAddrV6::new(new_addr.into(), self.local_port, 0, 0)))
}
_ => Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Internal error")),
_ => Err(io::const_error!(io::ErrorKind::InvalidInput, &"Internal error")),
}
}
@@ -339,7 +333,7 @@ pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
services::net_server(),
services::NetBlockingScalar::StdTcpStreamShutdown(self.fd, how).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|_| ())
}
@@ -361,7 +355,7 @@ pub fn set_nodelay(&self, enabled: bool) -> io::Result<()> {
services::net_server(),
services::NetBlockingScalar::StdSetNodelay(self.fd, enabled).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|_| ())
}
@@ -370,7 +364,7 @@ pub fn nodelay(&self) -> io::Result<bool> {
services::net_server(),
services::NetBlockingScalar::StdGetNodelay(self.fd).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|res| res[0] != 0)?)
}
@@ -382,7 +376,7 @@ pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {
services::net_server(),
services::NetBlockingScalar::StdSetTtlTcp(self.fd, ttl).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|_| ())
}
@@ -391,7 +385,7 @@ pub fn ttl(&self) -> io::Result<u32> {
services::net_server(),
services::NetBlockingScalar::StdGetTtlTcp(self.fd).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|res| res[0] as _)?)
}
+22 -28
View File
@@ -11,7 +11,7 @@
macro_rules! unimpl {
() => {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Unsupported,
&"This function is not yet implemented",
));
@@ -72,16 +72,16 @@ pub fn bind(socketaddr: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
if response[0] != 0 || valid == 0 {
let errcode = response[1];
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_io_error!(io::ErrorKind::ResourceBusy, &"Socket in use"));
return Err(io::const_error!(io::ErrorKind::ResourceBusy, &"Socket in use"));
} else if errcode == NetError::Invalid as u8 {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
&"Port can't be 0 or invalid address"
));
} else if errcode == NetError::LibraryError as u8 {
return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error"));
return Err(io::const_error!(io::ErrorKind::Other, &"Library error"));
} else {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Other,
&"Unable to connect or internal error"
));
@@ -98,13 +98,13 @@ pub fn bind(socketaddr: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
nonblocking: Cell::new(false),
});
}
Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Invalid response"))
Err(io::const_error!(io::ErrorKind::InvalidInput, &"Invalid response"))
}
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
match self.remote.get() {
Some(dest) => Ok(dest),
None => Err(io::const_io_error!(io::ErrorKind::NotConnected, &"No peer specified")),
None => Err(io::const_error!(io::ErrorKind::NotConnected, &"No peer specified")),
}
}
@@ -141,16 +141,13 @@ fn recv_inner(&self, buf: &mut [u8], do_peek: bool) -> io::Result<(usize, Socket
if receive_request.raw[0] != 0 {
// error case
if receive_request.raw[1] == NetError::TimedOut as u8 {
return Err(io::const_io_error!(io::ErrorKind::TimedOut, &"recv timed out",));
return Err(io::const_error!(io::ErrorKind::TimedOut, &"recv timed out",));
} else if receive_request.raw[1] == NetError::WouldBlock as u8 {
return Err(io::const_io_error!(
io::ErrorKind::WouldBlock,
&"recv would block",
));
return Err(io::const_error!(io::ErrorKind::WouldBlock, &"recv would block",));
} else if receive_request.raw[1] == NetError::LibraryError as u8 {
return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error"));
return Err(io::const_error!(io::ErrorKind::Other, &"Library error"));
} else {
return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",));
return Err(io::const_error!(io::ErrorKind::Other, &"library error",));
}
} else {
let rr = &receive_request.raw;
@@ -173,7 +170,7 @@ fn recv_inner(&self, buf: &mut [u8], do_peek: bool) -> io::Result<(usize, Socket
port,
)
} else {
return Err(io::const_io_error!(io::ErrorKind::Other, &"library error",));
return Err(io::const_error!(io::ErrorKind::Other, &"library error",));
};
for (&s, d) in rr[22..22 + rxlen as usize].iter().zip(buf.iter_mut()) {
*d = s;
@@ -181,7 +178,7 @@ fn recv_inner(&self, buf: &mut [u8], do_peek: bool) -> io::Result<(usize, Socket
Ok((rxlen as usize, addr))
}
} else {
Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unable to recv"))
Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unable to recv"))
}
}
@@ -211,7 +208,7 @@ pub fn send(&self, buf: &[u8]) -> io::Result<usize> {
if let Some(addr) = self.remote.get() {
self.send_to(buf, &addr)
} else {
Err(io::const_io_error!(io::ErrorKind::NotConnected, &"No remote specified"))
Err(io::const_error!(io::ErrorKind::NotConnected, &"No remote specified"))
}
}
@@ -282,22 +279,19 @@ pub fn send_to(&self, buf: &[u8], addr: &SocketAddr) -> io::Result<usize> {
if response[0] != 0 || valid == 0 {
let errcode = response[1];
if errcode == NetError::SocketInUse as u8 {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::ResourceBusy,
&"Socket in use"
));
} else if errcode == NetError::Invalid as u8 {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
&"Socket not valid"
));
} else if errcode == NetError::LibraryError as u8 {
return Err(io::const_io_error!(
io::ErrorKind::Other,
&"Library error"
));
return Err(io::const_error!(io::ErrorKind::Other, &"Library error"));
} else {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::Other,
&"Unable to connect"
));
@@ -309,7 +303,7 @@ pub fn send_to(&self, buf: &[u8], addr: &SocketAddr) -> io::Result<usize> {
}
Err(crate::os::xous::ffi::Error::ServerQueueFull) => {
if now.elapsed() >= write_timeout {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::WouldBlock,
&"Write timed out"
));
@@ -318,7 +312,7 @@ pub fn send_to(&self, buf: &[u8], addr: &SocketAddr) -> io::Result<usize> {
crate::thread::yield_now();
}
}
_ => return Err(io::const_io_error!(io::ErrorKind::Other, &"Library error")),
_ => return Err(io::const_error!(io::ErrorKind::Other, &"Library error")),
}
}
}
@@ -372,7 +366,7 @@ pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {
services::net_server(),
services::NetBlockingScalar::StdSetTtlUdp(self.fd, ttl).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|_| ())
}
@@ -381,7 +375,7 @@ pub fn ttl(&self) -> io::Result<u32> {
services::net_server(),
services::NetBlockingScalar::StdGetTtlUdp(self.fd).into(),
)
.or(Err(io::const_io_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value")))
.map(|res| res[0] as _)?)
}
+2 -2
View File
@@ -115,11 +115,11 @@ pub fn getenv(varname: &OsStr) -> Option<OsString> {
}
pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform"))
Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform"))
}
pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> {
Err(io::const_io_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform"))
Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform"))
}
pub fn temp_dir() -> PathBuf {
+1 -1
View File
@@ -328,7 +328,7 @@ pub(crate) fn absolute(path: &Path) -> io::Result<PathBuf> {
if prefix.map(|x| x.is_verbatim()).unwrap_or(false) {
// NULs in verbatim paths are rejected for consistency.
if path.as_encoded_bytes().contains(&0) {
return Err(io::const_io_error!(
return Err(io::const_error!(
io::ErrorKind::InvalidInput,
"strings passed to WinAPI cannot contain NULs",
));
+1 -1
View File
@@ -5,7 +5,7 @@
use crate::path::Path;
use crate::sys_common::ignore_notfound;
pub(crate) const NOT_FILE_ERROR: Error = io::const_io_error!(
pub(crate) const NOT_FILE_ERROR: Error = io::const_error!(
ErrorKind::InvalidInput,
"the source path is neither a regular file nor a symlink to a regular file",
);
+2 -2
View File
@@ -122,7 +122,7 @@ pub fn sockaddr_to_addr(storage: &c::sockaddr_storage, len: usize) -> io::Result
*(storage as *const _ as *const c::sockaddr_in6)
})))
}
_ => Err(io::const_io_error!(ErrorKind::InvalidInput, "invalid argument")),
_ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")),
}
}
@@ -185,7 +185,7 @@ macro_rules! try_opt {
($e:expr, $msg:expr) => {
match $e {
Some(r) => r,
None => return Err(io::const_io_error!(io::ErrorKind::InvalidInput, $msg)),
None => return Err(io::const_error!(io::ErrorKind::InvalidInput, $msg)),
}
};
}
+269
View File
@@ -0,0 +1,269 @@
{
"files": {
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"directories": [],
"files": [
"analyzer-decls.h",
"malloc-macro.h"
],
"license": {
"copyright": [
"2000-2024 Free Software Foundation, Inc"
],
"spdx": "GPL-2.0-only"
},
"type": "group"
}
],
"license": {
"copyright": [
"2007-2011 Atheros Communications Inc",
"2011-2012,2017 Qualcomm Atheros, Inc",
"2016-2017 Erik Stromdahl <erik.stromdahl@gmail.com>"
],
"spdx": "ISC"
},
"name": "c-c++-common/analyzer",
"type": "directory"
}
],
"license": {
"copyright": [
"2000-2024 Free Software Foundation, Inc"
],
"spdx": "GPL-2.0-only"
},
"name": "gcc/testsuite",
"type": "directory"
},
{
"license": {
"copyright": [
"2000-2024 Free Software Foundation, Inc"
],
"spdx": "GCC-exception-3.1"
},
"name": "libstdc++-v3/config/os/aix/os_defines.h",
"type": "file"
}
],
"license": {
"copyright": [
"1997-2024 Free Software Foundation, Inc"
],
"spdx": "GPL-3.0-or-later"
},
"name": "src/gcc",
"type": "directory"
},
{
"children": [
{
"license": {
"copyright": [
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR MIT"
},
"name": "noscript.css",
"type": "file"
},
{
"license": {
"copyright": [
"Nicolas Gallagher and Jonathan Neal"
],
"spdx": "MIT"
},
"name": "normalize.css",
"type": "file"
}
],
"license": {
"copyright": [
"2016 Ike Ku, Jessica Stokes and Leon Guan",
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR MIT"
},
"name": "src/librustdoc/html/static/css",
"type": "directory"
},
{
"children": [
{
"license": {
"copyright": [
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR MIT"
},
"name": "README.txt",
"type": "file"
},
{
"directories": [],
"files": [
"FiraSans-LICENSE.txt",
"FiraSans-Medium.woff2",
"FiraSans-Regular.woff2"
],
"license": {
"copyright": [
"2014, Mozilla Foundation",
"2014, Telefonica S.A"
],
"spdx": "OFL-1.1"
},
"type": "group"
},
{
"directories": [],
"files": [
"NanumBarunGothic-LICENSE.txt",
"NanumBarunGothic.ttf.woff2"
],
"license": {
"copyright": [
"2010 NAVER Corporation"
],
"spdx": "OFL-1.1"
},
"type": "group"
}
],
"license": {
"copyright": [
"2010, 2012, 2014-2023, Adobe Systems Incorporated"
],
"spdx": "OFL-1.1"
},
"name": "src/librustdoc/html/static/fonts",
"type": "directory"
},
{
"license": {
"copyright": [
"2003-2019 University of Illinois at Urbana-Champaign",
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 WITH LLVM-exception AND (Apache-2.0 OR MIT)"
},
"name": "compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp",
"type": "file"
},
{
"children": [],
"license": {
"copyright": [
"2014 Alex Crichton",
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR MIT"
},
"name": "library/backtrace",
"type": "directory"
},
{
"license": {
"copyright": [
"1991-2024 Unicode, Inc"
],
"spdx": "Unicode-3.0"
},
"name": "library/core/src/unicode/unicode_data.rs",
"type": "file"
},
{
"children": [],
"license": {
"copyright": [
"2019 The Crossbeam Project Developers",
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR MIT"
},
"name": "library/std/src/sync/mpmc",
"type": "directory"
},
{
"license": {
"copyright": [
"2016 The Fuchsia Authors",
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "BSD-2-Clause AND (Apache-2.0 OR MIT)"
},
"name": "library/std/src/sys/sync/mutex/fuchsia.rs",
"type": "file"
},
{
"children": [],
"license": {
"copyright": [
"Rust on Embedded Devices Working Group",
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR CC-BY-SA-4.0 OR MIT"
},
"name": "src/doc/embedded-book",
"type": "directory"
},
{
"children": [],
"license": {
"copyright": [
"2014 Jorge Aparicio",
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR MIT"
},
"name": "src/doc/rust-by-example",
"type": "directory"
},
{
"license": {
"copyright": [
"2014-2021 Knut Sveidqvist"
],
"spdx": "MIT"
},
"name": "src/doc/rustc-dev-guide/mermaid.min.js",
"type": "file"
},
{
"children": [],
"license": {
"copyright": [
"2003-2019 University of Illinois at Urbana-Champaign",
"2003-2019 by the contributors listed in CREDITS.TXT (https://github.com/rust-lang/llvm-project/blob/7738295178045041669876bf32b0543ec8319a5c/llvm/CREDITS.TXT)",
"2010 Apple Inc"
],
"spdx": "Apache-2.0 WITH LLVM-exception AND NCSA"
},
"name": "src/llvm-project",
"type": "directory"
}
],
"license": {
"copyright": [
"The Rust Project Developers (see https://thanks.rust-lang.org)"
],
"spdx": "Apache-2.0 OR MIT"
},
"name": ".",
"type": "directory"
}
],
"type": "root"
}
}
+2 -4
View File
@@ -181,8 +181,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
panic!("REUSE is required to collect the license metadata");
};
// Temporary location, it will be moved to src/etc once it's accurate.
let dest = builder.out.join("license-metadata.json");
let dest = builder.src.join("license-metadata.json");
let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata);
cmd.env("REUSE_EXE", reuse);
@@ -209,8 +208,7 @@ fn make_run(run: RunConfig<'_>) {
}
fn run(self, builder: &Builder<'_>) -> Self::Output {
let license_metadata = builder.ensure(CollectLicenseMetadata);
let license_metadata = builder.src.join("license-metadata.json");
let dest = builder.out.join("COPYRIGHT.html");
let dest_libstd = builder.out.join("COPYRIGHT-library.html");
+34 -7
View File
@@ -3469,7 +3469,6 @@ fn run(self, builder: &Builder<'_>) {
// FIXME remove once vendoring is handled
.arg("--skip-test")
.arg("testsuite.extended_sysroot");
cargo.args(builder.config.test_args());
cargo.into_cmd().run(builder);
}
@@ -3664,14 +3663,42 @@ fn run(self, builder: &Builder<'_>) {
&[],
);
cargo_run.arg("--");
if builder.config.args().is_empty() {
// By default, exclude tests that take longer than ~1m.
cargo_run.arg("--skip-huge");
} else {
cargo_run.args(builder.config.args());
if !matches!(env::var("FLOAT_PARSE_TESTS_NO_SKIP_HUGE").as_deref(), Ok("1") | Ok("true")) {
cargo_run.args(["--", "--skip-huge"]);
}
cargo_run.into_cmd().run(builder);
}
}
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
pub struct CollectLicenseMetadata;
impl Step for CollectLicenseMetadata {
type Output = PathBuf;
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/collect-license-metadata")
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(CollectLicenseMetadata);
}
fn run(self, builder: &Builder<'_>) -> Self::Output {
let Some(reuse) = &builder.config.reuse else {
panic!("REUSE is required to collect the license metadata");
};
let dest = builder.src.join("license-metadata.json");
let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata);
cmd.env("REUSE_EXE", reuse);
cmd.env("DEST", &dest);
cmd.env("ONLY_CHECK", "1");
cmd.run(builder);
dest
}
}
+1
View File
@@ -915,6 +915,7 @@ macro_rules! describe {
test::HtmlCheck,
test::RustInstaller,
test::TestFloatParse,
test::CollectLicenseMetadata,
// Run bootstrap close to the end as it's unlikely to fail
test::Bootstrap,
// Run run-make last, since these won't pass without make on Windows
@@ -63,6 +63,7 @@ ENV SCRIPT \
/scripts/validate-toolstate.sh && \
/scripts/validate-error-codes.sh && \
reuse --include-submodules lint && \
python3 ../x.py test collect-license-metadata && \
# Runs checks to ensure that there are no issues in our JS code.
es-check es2019 ../src/librustdoc/html/static/js/*.js && \
eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/*.js && \
+15 -7
View File
@@ -48,7 +48,7 @@ runners:
envs:
env-x86_64-apple-tests: &env-x86_64-apple-tests
SCRIPT: ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc
SCRIPT: ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
MACOSX_DEPLOYMENT_TARGET: 10.12
@@ -384,13 +384,12 @@ auto:
SCRIPT: make ci-msvc
<<: *job-windows-8c
- image: x86_64-msvc-ext
# x86_64-msvc-ext is split into multiple jobs to run tests in parallel.
- image: x86_64-msvc-ext1
env:
SCRIPT: python x.py --stage 2 test src/tools/cargotest src/tools/cargo && src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh x.py /tmp/toolstate/toolstates.json windows
HOST_TARGET: x86_64-pc-windows-msvc
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-lld --save-toolstates=/tmp/toolstate/toolstates.json
DEPLOY_TOOLSTATES_JSON: toolstates-windows.json
<<: *job-windows-8c
SCRIPT: python x.py --stage 2 test src/tools/cargotest src/tools/cargo
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-lld
<<: *job-windows
# Temporary builder to workaround CI issues
# See <https://github.com/rust-lang/rust/issues/127883>
@@ -406,6 +405,15 @@ auto:
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-lld
<<: *job-windows
# Run `checktools.sh` and upload the toolstate file.
- image: x86_64-msvc-ext3
env:
SCRIPT: src/ci/docker/host-x86_64/x86_64-gnu-tools/checktools.sh x.py /tmp/toolstate/toolstates.json windows
HOST_TARGET: x86_64-pc-windows-msvc
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-lld --save-toolstates=/tmp/toolstate/toolstates.json
DEPLOY_TOOLSTATES_JSON: toolstates-windows.json
<<: *job-windows
# 32/64-bit MinGW builds.
#
# We are using MinGW with POSIX threads since LLVM requires
+29 -10
View File
@@ -4,7 +4,7 @@
use std::path::PathBuf;
use anyhow::Error;
use anyhow::{Context, Error};
use crate::licenses::LicensesInterner;
@@ -12,10 +12,12 @@
///
/// You should probably let `bootstrap` execute this program instead of running it directly.
///
/// Run `x.py run collect-license-metadata`
/// * Run `x.py run collect-license-metadata` to re-regenerate the file.
/// * Run `x.py test collect-license-metadata` to check if the file you have is correct.
fn main() -> Result<(), Error> {
let reuse_exe: PathBuf = std::env::var_os("REUSE_EXE").expect("Missing REUSE_EXE").into();
let dest: PathBuf = std::env::var_os("DEST").expect("Missing DEST").into();
let only_check = std::env::var_os("ONLY_CHECK").is_some();
let mut interner = LicensesInterner::new();
let paths = crate::reuse::collect(&reuse_exe, &mut interner)?;
@@ -23,15 +25,32 @@ fn main() -> Result<(), Error> {
let mut tree = crate::path_tree::build(paths);
tree.simplify();
if let Some(parent) = dest.parent() {
std::fs::create_dir_all(parent)?;
let output = serde_json::json!({
"files": crate::path_tree::expand_interned_licenses(tree, &interner)
});
if only_check {
println!("loading existing license information");
let existing = std::fs::read_to_string(&dest).with_context(|| {
format!("Failed to read existing license JSON at {}", dest.display())
})?;
let existing_json: serde_json::Value =
serde_json::from_str(&existing).with_context(|| {
format!("Failed to read existing license JSON at {}", dest.display())
})?;
if existing_json != output {
eprintln!("The existing {} file is out of date.", dest.display());
eprintln!("Run ./x run collect-license-metadata to update it.");
anyhow::bail!("The existing {} file doesn't match what REUSE reports.", dest.display());
}
println!("license information matches");
} else {
if let Some(parent) = dest.parent() {
std::fs::create_dir_all(parent)?;
}
std::fs::write(&dest, &serde_json::to_vec_pretty(&output)?)?;
println!("license information written to {}", dest.display());
}
std::fs::write(
&dest,
&serde_json::to_vec_pretty(&serde_json::json!({
"files": crate::path_tree::expand_interned_licenses(tree, &interner),
}))?,
)?;
Ok(())
}
@@ -10,10 +10,10 @@ pub(crate) fn collect(
reuse_exe: &Path,
interner: &mut LicensesInterner,
) -> Result<Vec<(PathBuf, LicenseId)>, Error> {
eprintln!("gathering license information from REUSE");
println!("gathering license information from REUSE (this might take a minute...)");
let start = Instant::now();
let raw = &obtain_spdx_document(reuse_exe)?;
eprintln!("finished gathering the license information from REUSE in {:.2?}", start.elapsed());
println!("finished gathering the license information from REUSE in {:.2?}", start.elapsed());
let document = spdx_rs::parsers::spdx_from_tag_value(&raw)?;
+8
View File
@@ -57,6 +57,10 @@ fn main() -> Result<(), Error> {
dependencies: collected_cargo_metadata,
};
let output = template.render()?;
// Git stores text files with \n, but this file may contain \r\n in files
// copied from dependencies. Normalise them before we write them out, for
// consistency.
let output = output.replace("\r\n", "\n");
std::fs::write(&dest_file, output)?;
// Output libstd subset file
@@ -65,6 +69,10 @@ fn main() -> Result<(), Error> {
dependencies: library_collected_cargo_metadata,
};
let output = template.render()?;
// Git stores text files with \n, but this file may contain \r\n in files
// copied from dependencies. Normalise them before we write them out, for
// consistency.
let output = output.replace("\r\n", "\n");
std::fs::write(&libstd_dest_file, output)?;
Ok(())
@@ -382,6 +382,14 @@ fn emulate_foreign_item_inner(
// Return success (`1`).
this.write_int(1, dest)?;
}
"TlsFree" => {
let [key] = this.check_shim(abi, ExternAbi::System { unwind: false }, link_name, args)?;
let key = u128::from(this.read_scalar(key)?.to_u32()?);
this.machine.tls.delete_tls_key(key)?;
// Return success (`1`).
this.write_int(1, dest)?;
}
// Access to command-line arguments
"GetCommandLineW" => {
@@ -0,0 +1,18 @@
//@only-target: windows # this directly tests windows-only functions
use std::ffi::c_void;
use std::ptr;
extern "system" {
fn TlsAlloc() -> u32;
fn TlsSetValue(key: u32, val: *mut c_void) -> bool;
fn TlsGetValue(key: u32) -> *mut c_void;
fn TlsFree(key: u32) -> bool;
}
fn main() {
let key = unsafe { TlsAlloc() };
assert!(unsafe { TlsSetValue(key, ptr::without_provenance_mut(1)) });
assert_eq!(unsafe { TlsGetValue(key).addr() }, 1);
assert!(unsafe { TlsFree(key) });
}
-15
View File
@@ -1,15 +0,0 @@
//@ known-bug: rust-lang/rust#129444
//@ compile-flags: -Znext-solver=coherence
trait Trait {
type Assoc;
}
struct W<T: Trait>(*mut T);
impl<T: ?Trait> Trait for W<W<W<T>>> {}
trait NoOverlap {}
impl<T: Trait<W<T>>> NoOverlap for T {}
impl<T: Trait<Assoc = u32>> NoOverlap for W<T> {}
@@ -0,0 +1,20 @@
// A regression test for #129444. This previously ICE'd as
// computing the best obligation for one ambiguous obligation
// added spurious inference constraints which caused another
// candidate to pass.
trait Trait {
type Assoc;
}
struct W<T: Trait>(*mut T);
impl<T> Trait for W<W<W<T>>> {}
//~^ ERROR the trait bound `W<W<T>>: Trait` is not satisfied
//~| ERROR the trait bound `W<T>: Trait` is not satisfied
//~| ERROR the trait bound `T: Trait` is not satisfied
//~| ERROR not all trait items implemented, missing: `Assoc`
trait NoOverlap {}
impl<T: Trait> NoOverlap for T {}
impl<T: Trait<Assoc = u32>> NoOverlap for W<T> {}
//~^ ERROR conflicting implementations of trait `NoOverlap` for type `W<W<W<W<_>>>>`
fn main() {}
@@ -0,0 +1,69 @@
error[E0277]: the trait bound `W<W<T>>: Trait` is not satisfied
--> $DIR/best-obligation-ICE.rs:10:19
|
LL | impl<T> Trait for W<W<W<T>>> {}
| ^^^^^^^^^^ the trait `Trait` is not implemented for `W<W<T>>`
|
note: required by a bound in `W`
--> $DIR/best-obligation-ICE.rs:9:13
|
LL | struct W<T: Trait>(*mut T);
| ^^^^^ required by this bound in `W`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | impl<T> Trait for W<W<W<T>>> where W<W<T>>: Trait {}
| ++++++++++++++++++++
error[E0277]: the trait bound `W<T>: Trait` is not satisfied
--> $DIR/best-obligation-ICE.rs:10:19
|
LL | impl<T> Trait for W<W<W<T>>> {}
| ^^^^^^^^^^ the trait `Trait` is not implemented for `W<T>`
|
note: required by a bound in `W`
--> $DIR/best-obligation-ICE.rs:9:13
|
LL | struct W<T: Trait>(*mut T);
| ^^^^^ required by this bound in `W`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | impl<T> Trait for W<W<W<T>>> where W<T>: Trait {}
| +++++++++++++++++
error[E0277]: the trait bound `T: Trait` is not satisfied
--> $DIR/best-obligation-ICE.rs:10:19
|
LL | impl<T> Trait for W<W<W<T>>> {}
| ^^^^^^^^^^ the trait `Trait` is not implemented for `T`
|
note: required by a bound in `W`
--> $DIR/best-obligation-ICE.rs:9:13
|
LL | struct W<T: Trait>(*mut T);
| ^^^^^ required by this bound in `W`
help: consider restricting type parameter `T`
|
LL | impl<T: Trait> Trait for W<W<W<T>>> {}
| +++++++
error[E0046]: not all trait items implemented, missing: `Assoc`
--> $DIR/best-obligation-ICE.rs:10:1
|
LL | type Assoc;
| ---------- `Assoc` from trait
...
LL | impl<T> Trait for W<W<W<T>>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation
error[E0119]: conflicting implementations of trait `NoOverlap` for type `W<W<W<W<_>>>>`
--> $DIR/best-obligation-ICE.rs:18:1
|
LL | impl<T: Trait> NoOverlap for T {}
| ------------------------------ first implementation here
LL | impl<T: Trait<Assoc = u32>> NoOverlap for W<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<_>>>>`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0046, E0119, E0277.
For more information about an error, try `rustc --explain E0046`.
@@ -1,35 +1,11 @@
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
--> $DIR/unsized_coercion.rs:15:17
--> $DIR/unsized_coercion.rs:14:17
|
LL | let x = hello();
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Trait`
error[E0308]: mismatched types
--> $DIR/unsized_coercion.rs:19:5
|
LL | fn hello() -> Box<impl Trait> {
| ---------------
| | |
| | the expected opaque type
| expected `Box<impl Trait>` because of return type
...
LL | Box::new(1u32)
| ^^^^^^^^^^^^^^ types differ
|
= note: expected struct `Box<impl Trait>`
found struct `Box<u32>`
error: aborting due to 1 previous error
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
--> $DIR/unsized_coercion.rs:12:1
|
LL | fn hello() -> Box<impl Trait> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Trait`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
For more information about this error, try `rustc --explain E0277`.
+1 -2
View File
@@ -10,13 +10,12 @@ trait Trait {}
impl Trait for u32 {}
fn hello() -> Box<impl Trait> {
//[next]~^ ERROR the size for values of type `dyn Trait` cannot be known at compilation time
if true {
let x = hello();
//[next]~^ ERROR: the size for values of type `dyn Trait` cannot be known at compilation time
let y: Box<dyn Trait> = x;
}
Box::new(1u32) //[next]~ ERROR: mismatched types
Box::new(1u32)
}
fn main() {}
@@ -1,35 +1,11 @@
error[E0277]: the trait bound `dyn Send: Trait` is not satisfied
--> $DIR/unsized_coercion3.rs:14:17
--> $DIR/unsized_coercion3.rs:13:17
|
LL | let x = hello();
| ^^^^^^^ the trait `Trait` is not implemented for `dyn Send`
|
= help: the trait `Trait` is implemented for `u32`
error[E0308]: mismatched types
--> $DIR/unsized_coercion3.rs:19:5
|
LL | fn hello() -> Box<impl Trait + ?Sized> {
| ------------------------
| | |
| | the expected opaque type
| expected `Box<impl Trait + ?Sized>` because of return type
...
LL | Box::new(1u32)
| ^^^^^^^^^^^^^^ types differ
|
= note: expected struct `Box<impl Trait + ?Sized>`
found struct `Box<u32>`
error: aborting due to 1 previous error
error[E0277]: the trait bound `dyn Send: Trait` is not satisfied
--> $DIR/unsized_coercion3.rs:11:1
|
LL | fn hello() -> Box<impl Trait + ?Sized> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `dyn Send`
|
= help: the trait `Trait` is implemented for `u32`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
For more information about this error, try `rustc --explain E0277`.
@@ -1,5 +1,5 @@
error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time
--> $DIR/unsized_coercion3.rs:16:32
--> $DIR/unsized_coercion3.rs:15:32
|
LL | let y: Box<dyn Send> = x;
| ^ doesn't have a size known at compile-time
-2
View File
@@ -9,7 +9,6 @@ trait Trait {}
impl Trait for u32 {}
fn hello() -> Box<impl Trait + ?Sized> {
//[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied
if true {
let x = hello();
//[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied
@@ -17,7 +16,6 @@ fn hello() -> Box<impl Trait + ?Sized> {
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
}
Box::new(1u32)
//[next]~^ ERROR: mismatched types
}
fn main() {}
@@ -14,13 +14,7 @@ fn main() {
fn weird0() -> impl Sized + !Sized {}
//~^ ERROR the trait bound `(): !Sized` is not satisfied
//~| ERROR the trait bound `(): !Sized` is not satisfied
//~| ERROR the trait bound `(): !Sized` is not satisfied
fn weird1() -> impl !Sized + Sized {}
//~^ ERROR the trait bound `(): !Sized` is not satisfied
//~| ERROR the trait bound `(): !Sized` is not satisfied
//~| ERROR the trait bound `(): !Sized` is not satisfied
fn weird2() -> impl !Sized {}
//~^ ERROR the trait bound `(): !Sized` is not satisfied
//~| ERROR the trait bound `(): !Sized` is not satisfied
//~| ERROR the trait bound `(): !Sized` is not satisfied
@@ -5,53 +5,17 @@ LL | fn weird0() -> impl Sized + !Sized {}
| ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:15:36
|
LL | fn weird0() -> impl Sized + !Sized {}
| ^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:15:1
|
LL | fn weird0() -> impl Sized + !Sized {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
--> $DIR/opaque-type-unsatisfied-bound.rs:17:16
|
LL | fn weird1() -> impl !Sized + Sized {}
| ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:19:36
|
LL | fn weird1() -> impl !Sized + Sized {}
| ^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:19:1
|
LL | fn weird1() -> impl !Sized + Sized {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:23:16
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
|
LL | fn weird2() -> impl !Sized {}
| ^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:23:28
|
LL | fn weird2() -> impl !Sized {}
| ^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `(): !Sized` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:23:1
|
LL | fn weird2() -> impl !Sized {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied
--> $DIR/opaque-type-unsatisfied-bound.rs:12:13
|
@@ -66,6 +30,6 @@ note: required by a bound in `consume`
LL | fn consume(_: impl Trait) {}
| ^^^^^ required by this bound in `consume`
error: aborting due to 10 previous errors
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.
@@ -4,7 +4,5 @@
fn produce() -> impl !Fn<(u32,)> {}
//~^ ERROR the trait bound `(): !Fn(u32)` is not satisfied
//~| ERROR the trait bound `(): !Fn(u32)` is not satisfied
//~| ERROR the trait bound `(): !Fn(u32)` is not satisfied
fn main() {}
@@ -4,18 +4,6 @@ error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied
LL | fn produce() -> impl !Fn<(u32,)> {}
| ^^^^^^^^^^^^^^^^ the trait bound `(): !Fn(u32)` is not satisfied
error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:34
|
LL | fn produce() -> impl !Fn<(u32,)> {}
| ^^ the trait bound `(): !Fn(u32)` is not satisfied
error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:1
|
LL | fn produce() -> impl !Fn<(u32,)> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Fn(u32)` is not satisfied
error: aborting due to 3 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.