Bug 1530028 - Remove now-unnecessary NsresultExt trait, r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D20880

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-02-25 00:23:17 +00:00
Родитель 16c1dcf80f
Коммит f4b66e3031
13 изменённых файлов: 17 добавлений и 31 удалений

Просмотреть файл

@ -8,7 +8,7 @@ extern crate nsstring;
extern crate xpcom;
use libc::{c_double, int64_t, uint16_t};
use nserror::{nsresult, NsresultExt, NS_OK};
use nserror::{nsresult, NS_OK};
use nsstring::{nsACString, nsAString, nsCString, nsString};
use xpcom::{getter_addrefs, interfaces::nsIVariant, RefPtr};

Просмотреть файл

@ -4,7 +4,7 @@
use libc::uint16_t;
use nserror::{
nsresult, NsresultExt, NS_ERROR_FAILURE, NS_ERROR_NOT_IMPLEMENTED, NS_ERROR_NO_INTERFACE,
nsresult, NS_ERROR_FAILURE, NS_ERROR_NOT_IMPLEMENTED, NS_ERROR_NO_INTERFACE,
NS_ERROR_NULL_POINTER, NS_ERROR_UNEXPECTED,
};
use nsstring::nsCString;

Просмотреть файл

@ -4,7 +4,6 @@
use error::KeyValueError;
use libc::int32_t;
use nserror::NsresultExt;
use nsstring::nsString;
use rkv::OwnedValue;
use storage_variant::{

Просмотреть файл

@ -7,7 +7,7 @@ extern crate xpcom;
use crossbeam_utils::atomic::AtomicCell;
use error::KeyValueError;
use moz_task::Task;
use nserror::{nsresult, NsresultExt, NS_ERROR_FAILURE};
use nserror::{nsresult, NS_ERROR_FAILURE};
use nsstring::nsCString;
use owned_value::owned_to_variant;
use rkv::{Manager, OwnedValue, Rkv, SingleStore, StoreError, StoreOptions, Value};

Просмотреть файл

@ -242,7 +242,7 @@ infallible_impl_tmpl = """\
pub unsafe fn %(name)s(&self) -> %(realtype)s {
let mut result = <%(realtype)s as ::std::default::Default>::default();
let _rv = ((*self.vtable).%(name)s)(self, &mut result);
debug_assert!(::nserror::NsresultExt::succeeded(_rv));
debug_assert!(_rv.suceeded());
result
}
"""

Просмотреть файл

@ -13,7 +13,7 @@ use std::os::raw::c_char;
use std::ptr;
use std::ffi::{CStr, CString};
use xpcom::interfaces;
use nserror::{NsresultExt, nsresult, NS_OK};
use nserror::{nsresult, NS_OK};
#[no_mangle]
pub unsafe extern fn Rust_ObserveFromRust() -> *const interfaces::nsIObserverService {

Просмотреть файл

@ -12,7 +12,7 @@ extern crate nsstring;
#[macro_use]
extern crate xpcom;
use nserror::{nsresult, NsresultExt, NS_OK};
use nserror::{nsresult, NS_OK};
use nsstring::{nsACString, nsCString};
use std::{
ptr,

Просмотреть файл

@ -7,30 +7,19 @@ use nsstring::{nsCString, nsACString};
/// as the C++ equivalent.
#[repr(transparent)]
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct nsresult(pub u32);
/// An extension trait that adds methods to `nsresult` types.
pub trait NsresultExt {
fn failed(self) -> bool;
fn succeeded(self) -> bool;
fn to_result(self) -> Result<(), nsresult>;
/// Get a printable name for the nsresult error code. This function returns
/// a nsCString<'static>, which implements `Display`.
fn error_name(self) -> nsCString;
}
impl NsresultExt for nsresult {
fn failed(self) -> bool {
impl nsresult {
pub fn failed(self) -> bool {
(self.0 >> 31) != 0
}
fn succeeded(self) -> bool {
pub fn succeeded(self) -> bool {
!self.failed()
}
fn to_result(self) -> Result<(), nsresult> {
pub fn to_result(self) -> Result<(), nsresult> {
if self.failed() {
Err(self)
} else {
@ -38,7 +27,9 @@ impl NsresultExt for nsresult {
}
}
fn error_name(self) -> nsCString {
/// Get a printable name for the nsresult error code. This function returns
/// a nsCString<'static>, which implements `Display`.
pub fn error_name(self) -> nsCString {
let mut cstr = nsCString::new();
unsafe {
Gecko_GetErrorName(self, &mut *cstr);

Просмотреть файл

@ -8,7 +8,6 @@ use {
GetterAddrefs
};
use interfaces::nsISupports;
use nserror::NsresultExt;
#[repr(C)]
#[derive(Copy, Clone, Eq, PartialEq)]

Просмотреть файл

@ -13,6 +13,6 @@ pub extern crate libc;
pub use nsstring::{nsACString, nsAString, nsCString, nsString};
pub use nserror::{nsresult, NsresultExt, NS_ERROR_NO_INTERFACE, NS_OK};
pub use nserror::{nsresult, NS_ERROR_NO_INTERFACE, NS_OK};
pub use std::ops::Deref;

Просмотреть файл

@ -9,7 +9,7 @@ use std::marker::PhantomData;
use std::cell::Cell;
use std::sync::atomic::{self, AtomicUsize, Ordering};
use nserror::{NsresultExt, nsresult, NS_OK};
use nserror::{nsresult, NS_OK};
use libc;

Просмотреть файл

@ -4,7 +4,6 @@
use std::ffi::CStr;
use std::ptr;
use nserror::NsresultExt;
use {
RefPtr,
GetterAddrefs,

Просмотреть файл

@ -619,9 +619,7 @@ fn xpcom(init: DeriveInput) -> Result<Tokens, Box<Error>> {
{
let mut ga = ::xpcom::GetterAddrefs::<T>::new();
unsafe {
if ::xpcom::reexports::NsresultExt::succeeded(
self.QueryInterface(&T::IID, ga.void_ptr()),
) {
if self.QueryInterface(&T::IID, ga.void_ptr()).succeeded() {
ga.refptr()
} else {
None