diff options
| author | bors <bors@rust-lang.org> | 2020-01-11 03:03:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-11 03:03:42 +0000 |
| commit | 88d1109600660d1acb471e85631e1ea349843fd9 (patch) | |
| tree | f661e1f13a4af426e1884d557299cf0f40319da4 /src/libstd | |
| parent | e6217972644588a3be4fecb85b195f17b0220047 (diff) | |
| parent | 04a340f61f937b24262b517770afd08db783ac69 (diff) | |
| download | rust-88d1109600660d1acb471e85631e1ea349843fd9.tar.gz rust-88d1109600660d1acb471e85631e1ea349843fd9.zip | |
Auto merge of #68115 - Centril:rollup-e2fszdv, r=Centril
Rollup of 8 pull requests Successful merges: - #67666 (make use of pointer::is_null) - #67806 (Extract `rustc_ast_passes`, move gating, & refactor linting) - #68043 (Add some missing timers) - #68074 (Add `llvm-skip-rebuild` flag to `x.py`) - #68079 (Clarify suggestion for E0013) - #68084 (Do not ICE on unicode next point) - #68102 (Inline some conversion methods around OsStr) - #68106 (Fix issue with using `self` module via indirection) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/error.rs | 2 | ||||
| -rw-r--r-- | src/libstd/ffi/os_str.rs | 2 | ||||
| -rw-r--r-- | src/libstd/path.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/hermit/os.rs | 9 | ||||
| -rw-r--r-- | src/libstd/sys/hermit/thread_local.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/sgx/abi/tls.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 10 | ||||
| -rw-r--r-- | src/libstd/sys/vxworks/os.rs | 7 | ||||
| -rw-r--r-- | src/libstd/sys/wasi/os.rs | 11 | ||||
| -rw-r--r-- | src/libstd/sys/windows/os.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys_common/os_str_bytes.rs | 1 |
11 files changed, 34 insertions, 21 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 1407fe27715..b480581e21b 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -250,6 +250,7 @@ impl From<String> for Box<dyn Error + Send + Sync> { /// assert!( /// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error)) /// ``` + #[inline] fn from(err: String) -> Box<dyn Error + Send + Sync> { struct StringError(String); @@ -317,6 +318,7 @@ impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> { /// assert!( /// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error)) /// ``` + #[inline] fn from(err: &str) -> Box<dyn Error + Send + Sync + 'a> { From::from(String::from(err)) } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 4c308327b83..77da97219b1 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -615,6 +615,7 @@ impl OsStr { /// assert!(!os_str.is_empty()); /// ``` #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[inline] pub fn is_empty(&self) -> bool { self.inner.inner.is_empty() } @@ -965,6 +966,7 @@ impl AsRef<OsStr> for OsStr { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<OsStr> for OsString { + #[inline] fn as_ref(&self) -> &OsStr { self } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index fbbdc1ddac2..a703cb748e0 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1475,6 +1475,7 @@ impl From<OsString> for PathBuf { /// Converts a `OsString` into a `PathBuf` /// /// This conversion does not allocate or copy memory. + #[inline] fn from(s: OsString) -> PathBuf { PathBuf { inner: s } } @@ -1535,7 +1536,7 @@ impl fmt::Debug for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl ops::Deref for PathBuf { type Target = Path; - + #[inline] fn deref(&self) -> &Path { Path::new(&self.inner) } @@ -2655,6 +2656,7 @@ impl AsRef<Path> for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<Path> for str { + #[inline] fn as_ref(&self) -> &Path { Path::new(self) } @@ -2669,6 +2671,7 @@ impl AsRef<Path> for String { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<Path> for PathBuf { + #[inline] fn as_ref(&self) -> &Path { self } diff --git a/src/libstd/sys/hermit/os.rs b/src/libstd/sys/hermit/os.rs index 5999fdd4f8d..78eabf8f81e 100644 --- a/src/libstd/sys/hermit/os.rs +++ b/src/libstd/sys/hermit/os.rs @@ -6,7 +6,6 @@ use crate::io; use crate::marker::PhantomData; use crate::memchr; use crate::path::{self, PathBuf}; -use crate::ptr; use crate::str; use crate::sync::Mutex; use crate::sys::hermit::abi; @@ -77,13 +76,17 @@ pub fn init_environment(env: *const *const i8) { unsafe { ENV = Some(Mutex::new(HashMap::new())); + if env.is_null() { + return; + } + let mut guard = ENV.as_ref().unwrap().lock().unwrap(); let mut environ = env; - while environ != ptr::null() && *environ != ptr::null() { + while !(*environ).is_null() { if let Some((key, value)) = parse(CStr::from_ptr(*environ).to_bytes()) { guard.insert(key, value); } - environ = environ.offset(1); + environ = environ.add(1); } } diff --git a/src/libstd/sys/hermit/thread_local.rs b/src/libstd/sys/hermit/thread_local.rs index ba967c7676c..c6f8adb2162 100644 --- a/src/libstd/sys/hermit/thread_local.rs +++ b/src/libstd/sys/hermit/thread_local.rs @@ -18,14 +18,14 @@ static KEYS_LOCK: Mutex = Mutex::new(); static mut LOCALS: *mut BTreeMap<Key, *mut u8> = ptr::null_mut(); unsafe fn keys() -> &'static mut BTreeMap<Key, Option<Dtor>> { - if KEYS == ptr::null_mut() { + if KEYS.is_null() { KEYS = Box::into_raw(Box::new(BTreeMap::new())); } &mut *KEYS } unsafe fn locals() -> &'static mut BTreeMap<Key, *mut u8> { - if LOCALS == ptr::null_mut() { + if LOCALS.is_null() { LOCALS = Box::into_raw(Box::new(BTreeMap::new())); } &mut *LOCALS diff --git a/src/libstd/sys/sgx/abi/tls.rs b/src/libstd/sys/sgx/abi/tls.rs index 81a766e367d..2b0485c4f03 100644 --- a/src/libstd/sys/sgx/abi/tls.rs +++ b/src/libstd/sys/sgx/abi/tls.rs @@ -70,7 +70,7 @@ impl<'a> Drop for ActiveTls<'a> { any_non_null_dtor = false; for (value, dtor) in TLS_KEY_IN_USE.iter().filter_map(&value_with_destructor) { let value = value.replace(ptr::null_mut()); - if value != ptr::null_mut() { + if !value.is_null() { any_non_null_dtor = true; unsafe { dtor(value) } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index b277b3d5899..91f7d1524cc 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -480,11 +480,13 @@ pub fn env() -> Env { let _guard = env_lock(); let mut environ = *environ(); let mut result = Vec::new(); - while environ != ptr::null() && *environ != ptr::null() { - if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { - result.push(key_value); + if !environ.is_null() { + while !(*environ).is_null() { + if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { + result.push(key_value); + } + environ = environ.add(1); } - environ = environ.offset(1); } return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData }; } diff --git a/src/libstd/sys/vxworks/os.rs b/src/libstd/sys/vxworks/os.rs index d4219154499..1fadf716135 100644 --- a/src/libstd/sys/vxworks/os.rs +++ b/src/libstd/sys/vxworks/os.rs @@ -7,7 +7,6 @@ use crate::marker::PhantomData; use crate::mem; use crate::memchr; use crate::path::{self, Path, PathBuf}; -use crate::ptr; use crate::slice; use crate::str; use crate::sys::cvt; @@ -226,15 +225,15 @@ pub fn env() -> Env { unsafe { let _guard = env_lock(); let mut environ = *environ(); - if environ == ptr::null() { + if environ.is_null() { panic!("os::env() failure getting env string from OS: {}", io::Error::last_os_error()); } let mut result = Vec::new(); - while *environ != ptr::null() { + while !(*environ).is_null() { if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { result.push(key_value); } - environ = environ.offset(1); + environ = environ.add(1); } return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData }; } diff --git a/src/libstd/sys/wasi/os.rs b/src/libstd/sys/wasi/os.rs index 3baec6bf099..8052c0aa8a8 100644 --- a/src/libstd/sys/wasi/os.rs +++ b/src/libstd/sys/wasi/os.rs @@ -6,7 +6,6 @@ use crate::io; use crate::marker::PhantomData; use crate::os::wasi::prelude::*; use crate::path::{self, PathBuf}; -use crate::ptr; use crate::str; use crate::sys::memchr; use crate::sys::{unsupported, Void}; @@ -107,11 +106,13 @@ pub fn env() -> Env { let _guard = env_lock(); let mut environ = libc::environ; let mut result = Vec::new(); - while environ != ptr::null_mut() && *environ != ptr::null_mut() { - if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { - result.push(key_value); + if !environ.is_null() { + while !(*environ).is_null() { + if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { + result.push(key_value); + } + environ = environ.add(1); } - environ = environ.offset(1); } return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData }; } diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index c5354671c98..cc4ae405906 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -43,7 +43,7 @@ pub fn error_string(mut errnum: i32) -> String { ]; module = c::GetModuleHandleW(NTDLL_DLL.as_ptr()); - if module != ptr::null_mut() { + if !module.is_null() { errnum ^= c::FACILITY_NT_BIT as i32; flags = c::FORMAT_MESSAGE_FROM_HMODULE; } diff --git a/src/libstd/sys_common/os_str_bytes.rs b/src/libstd/sys_common/os_str_bytes.rs index eb8a881ec88..e965ea79aa0 100644 --- a/src/libstd/sys_common/os_str_bytes.rs +++ b/src/libstd/sys_common/os_str_bytes.rs @@ -104,6 +104,7 @@ impl Buf { self.inner.shrink_to(min_capacity) } + #[inline] pub fn as_slice(&self) -> &Slice { unsafe { mem::transmute(&*self.inner) } } |
