Skip to content

Commit f1aa0d4

Browse files
authored
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 <eliza@buoyant.io>
1 parent e05d1c8 commit f1aa0d4

23 files changed

+94
-149
lines changed

tracing-core/src/callsite.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub use self::inner::{rebuild_interest_cache, register};
6767
#[cfg(feature = "std")]
6868
mod inner {
6969
use super::*;
70+
use lazy_static::lazy_static;
7071
use std::sync::RwLock;
7172
use std::vec::Vec;
7273

tracing-core/src/collect.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ pub trait Collect: 'static {
239239
/// but values for them won't be recorded at this time.
240240
///
241241
/// ```rust,ignore
242-
/// #[macro_use]
243-
/// extern crate tracing;
242+
/// # use tracing::span;
244243
///
245244
/// let mut span = span!("my_span", foo = 3, bar, baz);
246245
///

tracing-core/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,6 @@ macro_rules! metadata {
274274
};
275275
}
276276

277-
// std uses lazy_static from crates.io
278-
#[cfg(feature = "std")]
279-
#[macro_use]
280-
extern crate lazy_static;
281-
282277
// Facade module: `no_std` uses spinlocks, `std` uses the mutexes in the standard library
283278
#[cfg(not(feature = "std"))]
284279
#[doc(hidden)]

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/global_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/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]: self#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
@@ -929,9 +929,6 @@
929929
while_true
930930
)]
931931

932-
#[macro_use]
933-
extern crate cfg_if;
934-
935932
#[cfg(feature = "log")]
936933
#[doc(hidden)]
937934
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]

0 commit comments

Comments
 (0)