Skip to content
/ rust Public
forked from rust-lang/rust

Commit

Permalink
Move error::Error trait from libstd to liballoc
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Aug 30, 2019
1 parent c7d4df0 commit 0411f25
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
27 changes: 14 additions & 13 deletions src/libstd/error.rs → src/liballoc/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
// coherence challenge (e.g., specialization, neg impls, etc) we can
// reconsider what crate these items belong in.

use core::any::TypeId;
use core::array;
use core::cell;
use core::char;
use core::fmt::{self, Debug, Display};
use core::mem::transmute;
use core::num;
use core::str;

use crate::alloc::{AllocErr, LayoutErr, CannotReallocInPlace};
use crate::any::TypeId;
use crate::borrow::Cow;
use crate::cell;
use crate::char;
use crate::fmt::{self, Debug, Display};
use crate::mem::transmute;
use crate::num;
use crate::str;
use crate::string;
use crate::boxed::Box;
use crate::string::{self, String};

/// `Error` is a trait representing the basic expectations for error values,
/// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
Expand All @@ -38,9 +39,9 @@ use crate::string;
/// provide its own errors while also revealing some of the implementation for
/// debugging via [`source`] chains.
///
/// [`Result<T, E>`]: ../result/enum.Result.html
/// [`Display`]: ../fmt/trait.Display.html
/// [`Debug`]: ../fmt/trait.Debug.html
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
/// [`Display`]: ../../std/fmt/trait.Display.html
/// [`Debug`]: ../../std/fmt/trait.Debug.html
/// [`source`]: trait.Error.html#method.source
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Error: Debug + Display {
Expand All @@ -52,7 +53,7 @@ pub trait Error: Debug + Display {
///
/// To obtain error description as a string, use `to_string()`.
///
/// [`Display`]: ../fmt/trait.Display.html
/// [`Display`]: ../../std/fmt/trait.Display.html
///
/// # Examples
///
Expand Down Expand Up @@ -891,7 +892,7 @@ impl dyn Error + Send + Sync {
#[cfg(test)]
mod tests {
use super::Error;
use crate::fmt;
use core::fmt;

#[derive(Debug, PartialEq)]
struct A;
Expand Down
6 changes: 6 additions & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@
#![feature(allocator_api)]
#![feature(allow_internal_unstable)]
#![feature(arbitrary_self_types)]
#![feature(array_error_internals)]
#![feature(box_into_raw_non_null)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(cfg_target_has_atomic)]
#![feature(char_error_internals)]
#![feature(coerce_unsized)]
#![feature(const_generic_impls_guard)]
#![feature(const_generics)]
Expand All @@ -93,9 +95,11 @@
#![feature(fmt_internals)]
#![feature(fn_traits)]
#![feature(fundamental)]
#![feature(int_error_internals)]
#![feature(internal_uninit_const)]
#![feature(lang_items)]
#![feature(libc)]
#![feature(never_type)]
#![feature(nll)]
#![feature(optin_builtin_traits)]
#![feature(pattern)]
Expand Down Expand Up @@ -167,6 +171,8 @@ pub mod str;
pub mod string;
pub mod vec;

pub mod error;

#[cfg(not(test))]
mod std {
pub use core::ops; // RangeFull
Expand Down
4 changes: 3 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ pub use core::hint;
#[stable(feature = "core_array", since = "1.36.0")]
pub use core::array;

#[stable(feature = "rust1", since = "1.0.0")]
pub use alloc_crate::error;

pub mod f32;
pub mod f64;

Expand All @@ -455,7 +458,6 @@ pub mod thread;
pub mod ascii;
pub mod collections;
pub mod env;
pub mod error;
pub mod ffi;
pub mod fs;
pub mod io;
Expand Down

0 comments on commit 0411f25

Please sign in to comment.