Skip to content

Commit dfc7bc0

Browse files
committed
Work around prelude redundant import warnings
rust-lang/rust#117772 warning: the item `String` is imported redundantly --> src/ensure.rs:2:5 | 2 | use alloc::string::String; | ^^^^^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13 | 115 | pub use super::v1::*; | --------- the item `String` is already defined here | = note: `#[warn(unused_imports)]` on by default warning: the item `Box` is imported redundantly --> src/error.rs:7:5 | 7 | use alloc::boxed::Box; | ^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13 | 115 | pub use super::v1::*; | --------- the item `Box` is already defined here warning: the item `Box` is imported redundantly --> src/ptr.rs:1:5 | 1 | use alloc::boxed::Box; | ^^^^^^^^^^^^^^^^^ | ::: nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:115:13 | 115 | pub use super::v1::*; | --------- the item `Box` is already defined here
1 parent 6e4f86b commit dfc7bc0

File tree

6 files changed

+12
-3
lines changed

6 files changed

+12
-3
lines changed

src/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use self::ChainState::*;
22
use crate::StdError;
33

44
#[cfg(feature = "std")]
5-
use alloc::vec;
5+
use alloc::vec::{self, Vec};
66

77
#[cfg(feature = "std")]
88
pub(crate) use crate::Chain;

src/fmt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl ErrorImpl {
4343
#[cfg(any(std_backtrace, feature = "backtrace"))]
4444
{
4545
use crate::backtrace::BacktraceStatus;
46+
use alloc::string::ToString;
4647

4748
let backtrace = unsafe { Self::backtrace(this) };
4849
if let BacktraceStatus::Captured = backtrace.status() {
@@ -102,6 +103,7 @@ where
102103
#[cfg(test)]
103104
mod tests {
104105
use super::*;
106+
use alloc::string::String;
105107

106108
#[test]
107109
fn one_digit() {

src/kind.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ use core::fmt::{Debug, Display};
4949

5050
#[cfg(feature = "std")]
5151
use crate::StdError;
52+
#[cfg(feature = "std")]
53+
use alloc::boxed::Box;
5254

5355
pub struct Adhoc;
5456

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
#![doc(html_root_url = "https://docs.rs/anyhow/1.0.79")]
210210
#![cfg_attr(error_generic_member_access, feature(error_generic_member_access))]
211211
#![cfg_attr(doc_cfg, feature(doc_cfg))]
212-
#![cfg_attr(not(feature = "std"), no_std)]
212+
#![no_std]
213213
#![deny(dead_code, unused_imports, unused_mut)]
214214
#![cfg_attr(
215215
not(anyhow_no_unsafe_op_in_unsafe_fn_lint),
@@ -247,6 +247,9 @@ compile_error!("Build script probe failed to compile.");
247247

248248
extern crate alloc;
249249

250+
#[cfg(feature = "std")]
251+
extern crate std;
252+
250253
#[macro_use]
251254
mod backtrace;
252255
mod chain;

src/wrapper.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use crate::StdError;
22
use core::fmt::{self, Debug, Display};
33

4+
#[cfg(feature = "std")]
5+
use alloc::boxed::Box;
6+
47
#[cfg(error_generic_member_access)]
58
use std::error::Request;
69

tests/test_repr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mod drop;
44

55
use self::drop::{DetectDrop, Flag};
66
use anyhow::Error;
7-
use std::marker::Unpin;
87
use std::mem;
98

109
#[test]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy