Skip to content

Commit 0411f25

Browse files
committed
Move error::Error trait from libstd to liballoc
1 parent c7d4df0 commit 0411f25

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/libstd/error.rs renamed to src/liballoc/error.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313
// coherence challenge (e.g., specialization, neg impls, etc) we can
1414
// reconsider what crate these items belong in.
1515

16+
use core::any::TypeId;
1617
use core::array;
18+
use core::cell;
19+
use core::char;
20+
use core::fmt::{self, Debug, Display};
21+
use core::mem::transmute;
22+
use core::num;
23+
use core::str;
1724

1825
use crate::alloc::{AllocErr, LayoutErr, CannotReallocInPlace};
19-
use crate::any::TypeId;
2026
use crate::borrow::Cow;
21-
use crate::cell;
22-
use crate::char;
23-
use crate::fmt::{self, Debug, Display};
24-
use crate::mem::transmute;
25-
use crate::num;
26-
use crate::str;
27-
use crate::string;
27+
use crate::boxed::Box;
28+
use crate::string::{self, String};
2829

2930
/// `Error` is a trait representing the basic expectations for error values,
3031
/// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
@@ -38,9 +39,9 @@ use crate::string;
3839
/// provide its own errors while also revealing some of the implementation for
3940
/// debugging via [`source`] chains.
4041
///
41-
/// [`Result<T, E>`]: ../result/enum.Result.html
42-
/// [`Display`]: ../fmt/trait.Display.html
43-
/// [`Debug`]: ../fmt/trait.Debug.html
42+
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
43+
/// [`Display`]: ../../std/fmt/trait.Display.html
44+
/// [`Debug`]: ../../std/fmt/trait.Debug.html
4445
/// [`source`]: trait.Error.html#method.source
4546
#[stable(feature = "rust1", since = "1.0.0")]
4647
pub trait Error: Debug + Display {
@@ -52,7 +53,7 @@ pub trait Error: Debug + Display {
5253
///
5354
/// To obtain error description as a string, use `to_string()`.
5455
///
55-
/// [`Display`]: ../fmt/trait.Display.html
56+
/// [`Display`]: ../../std/fmt/trait.Display.html
5657
///
5758
/// # Examples
5859
///
@@ -891,7 +892,7 @@ impl dyn Error + Send + Sync {
891892
#[cfg(test)]
892893
mod tests {
893894
use super::Error;
894-
use crate::fmt;
895+
use core::fmt;
895896

896897
#[derive(Debug, PartialEq)]
897898
struct A;

src/liballoc/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@
7777
#![feature(allocator_api)]
7878
#![feature(allow_internal_unstable)]
7979
#![feature(arbitrary_self_types)]
80+
#![feature(array_error_internals)]
8081
#![feature(box_into_raw_non_null)]
8182
#![feature(box_patterns)]
8283
#![feature(box_syntax)]
8384
#![feature(cfg_target_has_atomic)]
85+
#![feature(char_error_internals)]
8486
#![feature(coerce_unsized)]
8587
#![feature(const_generic_impls_guard)]
8688
#![feature(const_generics)]
@@ -93,9 +95,11 @@
9395
#![feature(fmt_internals)]
9496
#![feature(fn_traits)]
9597
#![feature(fundamental)]
98+
#![feature(int_error_internals)]
9699
#![feature(internal_uninit_const)]
97100
#![feature(lang_items)]
98101
#![feature(libc)]
102+
#![feature(never_type)]
99103
#![feature(nll)]
100104
#![feature(optin_builtin_traits)]
101105
#![feature(pattern)]
@@ -167,6 +171,8 @@ pub mod str;
167171
pub mod string;
168172
pub mod vec;
169173

174+
pub mod error;
175+
170176
#[cfg(not(test))]
171177
mod std {
172178
pub use core::ops; // RangeFull

src/libstd/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ pub use core::hint;
447447
#[stable(feature = "core_array", since = "1.36.0")]
448448
pub use core::array;
449449

450+
#[stable(feature = "rust1", since = "1.0.0")]
451+
pub use alloc_crate::error;
452+
450453
pub mod f32;
451454
pub mod f64;
452455

@@ -455,7 +458,6 @@ pub mod thread;
455458
pub mod ascii;
456459
pub mod collections;
457460
pub mod env;
458-
pub mod error;
459461
pub mod ffi;
460462
pub mod fs;
461463
pub mod io;

0 commit comments

Comments
 (0)