Skip to content

Commit fefe583

Browse files
committed
chore: remove *all* extern crate statements (#1738)
Depends on #1737 This branch removes all remaining `extern crate` statements. Most of these are in old code and were not removed when updating to Rust 2018. Whoops! Our MSRV no longer requires `extern crate`, so we don't need these. The exception is `extern crate` statements for `std` and `alloc`, which are still the way these libraries are included explicitly when building for `no_std` platforms. In some cases, the tests had to explicitly import the `span!` and `event!` macros at every use, because their names conflict with the `span` and `event` modules in the test support code. Oh well. Signed-off-by: Eliza Weisman <[email protected]>
1 parent f186c2e commit fefe583

22 files changed

+93
-146
lines changed

tracing-core/src/callsite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
subscriber::Interest,
1313
};
1414

15-
lazy_static! {
15+
crate::lazy_static! {
1616
static ref REGISTRY: Mutex<Registry> = Mutex::new(Registry {
1717
callsites: Vec::new(),
1818
dispatchers: Vec::new(),

tracing-core/src/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,11 @@ macro_rules! metadata {
225225
};
226226
}
227227

228-
// std uses lazy_static from crates.io
228+
// when `std` is enabled, use the `lazy_static` crate from crates.io
229229
#[cfg(feature = "std")]
230-
#[macro_use]
231-
extern crate lazy_static;
230+
pub(crate) use lazy_static::lazy_static;
232231

233-
// no_std uses vendored version of lazy_static 1.4.0 (4216696) with spin
234-
// This can conflict when included in a project already using std lazy_static
235-
// Remove this module when cargo enables specifying dependencies for no_std
232+
// Facade module: `no_std` uses spinlocks, `std` uses the mutexes in the standard library
236233
#[cfg(not(feature = "std"))]
237234
#[macro_use]
238235
mod lazy_static;

tracing-core/src/subscriber.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ pub trait Subscriber: 'static {
246246
/// but values for them won't be recorded at this time.
247247
///
248248
/// ```rust,ignore
249-
/// #[macro_use]
250-
/// extern crate tracing;
249+
/// # use tracing::span;
251250
///
252251
/// let mut span = span!("my_span", foo = 3, bar, baz);
253252
///

tracing-serde/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ tracing-serde = "0.1"
5353
Next, add this to your crate:
5454

5555
```rust
56-
#[macro_use]
57-
extern crate tracing;
58-
extern crate tracing_serde;
59-
6056
use tracing_serde::AsSerde;
6157
```
6258

tracing/benches/subscriber.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
extern crate criterion;
2-
extern crate tracing;
3-
41
use criterion::{black_box, criterion_group, criterion_main, Criterion};
52
use tracing::Level;
63

tracing/src/level_filters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub use tracing_core::{metadata::ParseLevelFilterError, LevelFilter};
6565
/// [module-level documentation]: ../index.html#compile-time-filters
6666
pub const STATIC_MAX_LEVEL: LevelFilter = MAX_LEVEL;
6767

68-
cfg_if! {
68+
cfg_if::cfg_if! {
6969
if #[cfg(all(not(debug_assertions), feature = "release_max_level_off"))] {
7070
const MAX_LEVEL: LevelFilter = LevelFilter::OFF;
7171
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_error"))] {

tracing/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,6 @@
882882
#[cfg(not(feature = "std"))]
883883
extern crate alloc;
884884

885-
#[macro_use]
886-
extern crate cfg_if;
887-
888885
#[cfg(feature = "log")]
889886
#[doc(hidden)]
890887
pub use log;

tracing/test-log-support/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
extern crate log;
21
use log::{LevelFilter, Log, Metadata, Record};
32
use std::sync::{Arc, Mutex};
43

tracing/test-log-support/tests/log_no_trace.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#[macro_use]
2-
extern crate tracing;
3-
extern crate test_log_support;
4-
51
use test_log_support::Test;
6-
use tracing::Level;
2+
use tracing::{error, info, span, trace, warn, Level};
73

84
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
95
#[test]

tracing/test-log-support/tests/log_with_trace.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
#[macro_use]
2-
extern crate tracing;
3-
extern crate test_log_support;
4-
51
use test_log_support::Test;
6-
use tracing::Level;
2+
use tracing::{error, info, span, trace, warn, Level};
73

84
pub struct NopSubscriber;
95

0 commit comments

Comments
 (0)