Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove *all* extern crate statements #1738

Merged
merged 6 commits into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tracing-core/src/callsite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub use self::inner::{rebuild_interest_cache, register};
#[cfg(feature = "std")]
mod inner {
use super::*;
use lazy_static::lazy_static;
use std::sync::RwLock;
use std::vec::Vec;

Expand Down
3 changes: 1 addition & 2 deletions tracing-core/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ pub trait Collect: 'static {
/// but values for them won't be recorded at this time.
///
/// ```rust,ignore
/// #[macro_use]
/// extern crate tracing;
/// # use tracing::span;
///
/// let mut span = span!("my_span", foo = 3, bar, baz);
///
Expand Down
5 changes: 0 additions & 5 deletions tracing-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,6 @@ macro_rules! metadata {
};
}

// std uses lazy_static from crates.io
#[cfg(feature = "std")]
#[macro_use]
extern crate lazy_static;

// Facade module: `no_std` uses spinlocks, `std` uses the mutexes in the standard library
#[cfg(not(feature = "std"))]
#[doc(hidden)]
Expand Down
4 changes: 0 additions & 4 deletions tracing-serde/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ tracing-serde = "0.1"
Next, add this to your crate:

```rust
#[macro_use]
extern crate tracing;
extern crate tracing_serde;

use tracing_serde::AsSerde;
```

Expand Down
3 changes: 0 additions & 3 deletions tracing/benches/global_subscriber.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
extern crate criterion;
extern crate tracing;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tracing::Level;

Expand Down
3 changes: 0 additions & 3 deletions tracing/benches/subscriber.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
extern crate criterion;
extern crate tracing;

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use tracing::Level;

Expand Down
2 changes: 1 addition & 1 deletion tracing/src/level_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub use tracing_core::{metadata::ParseLevelFilterError, LevelFilter};
/// [module-level documentation]: self#compile-time-filters
pub const STATIC_MAX_LEVEL: LevelFilter = MAX_LEVEL;

cfg_if! {
cfg_if::cfg_if! {
if #[cfg(all(not(debug_assertions), feature = "release_max_level_off"))] {
const MAX_LEVEL: LevelFilter = LevelFilter::OFF;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_error"))] {
Expand Down
3 changes: 0 additions & 3 deletions tracing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,6 @@
while_true
)]

#[macro_use]
extern crate cfg_if;

#[cfg(feature = "log")]
#[doc(hidden)]
pub use log;
Expand Down
1 change: 0 additions & 1 deletion tracing/test-log-support/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate log;
use log::{LevelFilter, Log, Metadata, Record};
use std::sync::{Arc, Mutex};

Expand Down
6 changes: 1 addition & 5 deletions tracing/test-log-support/tests/log_no_trace.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#[macro_use]
extern crate tracing;
extern crate test_log_support;

use test_log_support::Test;
use tracing::Level;
use tracing::{error, info, span, trace, warn, Level};

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
Expand Down
6 changes: 1 addition & 5 deletions tracing/test-log-support/tests/log_with_trace.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#[macro_use]
extern crate tracing;
extern crate test_log_support;

use test_log_support::Test;
use tracing::Level;
use tracing::{error, info, span, trace, warn, Level};
use tracing_core::span::Current;

pub struct NopCollector;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#[macro_use]
extern crate tracing;
extern crate test_log_support;

use test_log_support::Test;
use tracing::Level;
use tracing::{error, info, span, trace, warn, Level};

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#[macro_use]
extern crate tracing;
extern crate test_log_support;

use test_log_support::Test;
use tracing::Level;
use tracing::{error, info, span, trace, warn, Level};

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#[macro_use]
extern crate tracing;
extern crate test_log_support;

use test_log_support::Test;
use tracing::Level;
use tracing::{error, info, span, trace, warn, Level};

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
Expand Down
6 changes: 1 addition & 5 deletions tracing/test-log-support/tests/span_lifecycle_is_trace.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#[macro_use]
extern crate tracing;
extern crate test_log_support;

use test_log_support::Test;
use tracing::Level;
use tracing::{error, info, span, trace, warn, Level};

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[test]
Expand Down
5 changes: 1 addition & 4 deletions tracing/test_static_max_level_features/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#[macro_use]
extern crate tracing;

use std::sync::{Arc, Mutex};
use tracing::span::{Attributes, Record};
use tracing::{span, Collect, Event, Id, Level, Metadata};
use tracing::{debug, error, info, span, trace, warn, Collect, Event, Id, Level, Metadata};
use tracing_core::span::Current;

struct State {
Expand Down
13 changes: 5 additions & 8 deletions tracing/tests/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
// The alternative would be for each of these tests to be defined in a separate
// file, which is :(
#![cfg(feature = "std")]

#[macro_use]
extern crate tracing;
use tracing::{
collect::{with_default, Collect, Interest},
field::display,
Expand All @@ -34,7 +31,7 @@ fn event_macros_dont_infinite_loop() {

fn enabled(&self, meta: &Metadata<'_>) -> bool {
assert!(meta.fields().iter().any(|f| f.name() == "foo"));
event!(Level::TRACE, bar = false);
tracing::event!(Level::TRACE, bar = false);
true
}

Expand All @@ -48,7 +45,7 @@ fn event_macros_dont_infinite_loop() {

fn event(&self, event: &Event<'_>) {
assert!(event.metadata().fields().iter().any(|f| f.name() == "foo"));
event!(Level::TRACE, baz = false);
tracing::event!(Level::TRACE, baz = false);
}

fn enter(&self, _: &Id) {}
Expand All @@ -61,7 +58,7 @@ fn event_macros_dont_infinite_loop() {
}

with_default(TestCollector, || {
event!(Level::TRACE, foo = false);
tracing::event!(Level::TRACE, foo = false);
})
}

Expand All @@ -85,7 +82,7 @@ fn boxed_collector() {

with_default(collector, || {
let from = "my span";
let span = span!(
let span = tracing::span!(
Level::TRACE,
"foo",
bar = format_args!("hello from {}", from)
Expand Down Expand Up @@ -123,7 +120,7 @@ fn arced_collector() {
// Test using a clone of the `Arc`ed collector
with_default(collector.clone(), || {
let from = "my span";
let span = span!(
let span = tracing::span!(
Level::TRACE,
"foo",
bar = format_args!("hello from {}", from)
Expand Down
33 changes: 17 additions & 16 deletions tracing/tests/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
// The alternative would be for each of these tests to be defined in a separate
// file, which is :(
#![cfg(feature = "std")]

#[macro_use]
extern crate tracing;
mod support;

use self::support::*;

use tracing::{
collect::with_default,
debug, error,
field::{debug, display},
Level,
info, trace, warn, Level,
};

macro_rules! event_without_message {
Expand Down Expand Up @@ -61,13 +59,16 @@ event_without_message! {nonzeroi32_event_without_message: std::num::NonZeroI32::
fn event_with_message() {
let (collector, handle) = collector::mock()
.event(event::mock().with_fields(field::mock("message").with_value(
&tracing::field::debug(format_args!("hello from my event! yak shaved = {:?}", true)),
&tracing::field::debug(format_args!(
"hello from my tracing::event! yak shaved = {:?}",
true
)),
)))
.done()
.run_with_handle();

with_default(collector, || {
debug!("hello from my event! yak shaved = {:?}", true);
debug!("hello from my tracing::event! yak shaved = {:?}", true);
});

handle.assert_finished();
Expand Down Expand Up @@ -155,7 +156,7 @@ fn one_with_everything() {
.run_with_handle();

with_default(collector, || {
event!(
tracing::event!(
target: "whatever",
Level::ERROR,
{ foo = 666, bar = false, like_a_butterfly = 42.0 },
Expand All @@ -181,7 +182,7 @@ fn moved_field() {
.run_with_handle();
with_default(collector, || {
let from = "my event";
event!(Level::INFO, foo = display(format!("hello from {}", from)))
tracing::event!(Level::INFO, foo = display(format!("hello from {}", from)))
});

handle.assert_finished();
Expand All @@ -202,7 +203,7 @@ fn dotted_field_name() {
.done()
.run_with_handle();
with_default(collector, || {
event!(Level::INFO, foo.bar = true, foo.baz = false);
tracing::event!(Level::INFO, foo.bar = true, foo.baz = false);
});

handle.assert_finished();
Expand All @@ -224,7 +225,7 @@ fn borrowed_field() {
with_default(collector, || {
let from = "my event";
let mut message = format!("hello from {}", from);
event!(Level::INFO, foo = display(&message));
tracing::event!(Level::INFO, foo = display(&message));
message.push_str(", which happened!");
});

Expand Down Expand Up @@ -286,7 +287,7 @@ fn display_shorthand() {
.done()
.run_with_handle();
with_default(collector, || {
event!(Level::TRACE, my_field = %"hello world");
tracing::event!(Level::TRACE, my_field = %"hello world");
});

handle.assert_finished();
Expand All @@ -306,7 +307,7 @@ fn debug_shorthand() {
.done()
.run_with_handle();
with_default(collector, || {
event!(Level::TRACE, my_field = ?"hello world");
tracing::event!(Level::TRACE, my_field = ?"hello world");
});

handle.assert_finished();
Expand All @@ -327,7 +328,7 @@ fn both_shorthands() {
.done()
.run_with_handle();
with_default(collector, || {
event!(Level::TRACE, display_field = %"hello world", debug_field = ?"hello world");
tracing::event!(Level::TRACE, display_field = %"hello world", debug_field = ?"hello world");
});

handle.assert_finished();
Expand All @@ -343,8 +344,8 @@ fn explicit_child() {
.run_with_handle();

with_default(collector, || {
let foo = span!(Level::TRACE, "foo");
event!(parent: foo.id(), Level::TRACE, "bar");
let foo = tracing::span!(Level::TRACE, "foo");
tracing::event!(parent: foo.id(), Level::TRACE, "bar");
});

handle.assert_finished();
Expand All @@ -364,7 +365,7 @@ fn explicit_child_at_levels() {
.run_with_handle();

with_default(collector, || {
let foo = span!(Level::TRACE, "foo");
let foo = tracing::span!(Level::TRACE, "foo");
trace!(parent: foo.id(), "a");
debug!(parent: foo.id(), "b");
info!(parent: foo.id(), "c");
Expand Down
4 changes: 1 addition & 3 deletions tracing/tests/filter_caching_is_lexically_scoped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
#[cfg(not(feature = "std"))]
extern crate std;

#[macro_use]
extern crate tracing;
mod support;

use self::support::*;
use tracing::Level;
use tracing::{span, Level};

use std::sync::{
atomic::{AtomicUsize, Ordering},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

#[cfg(not(feature = "std"))]
extern crate std;

#[macro_use]
extern crate tracing;
mod support;

use self::support::*;
use tracing::Level;
use tracing::{span, Level};

use std::sync::{
atomic::{AtomicUsize, Ordering},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
#[cfg(not(feature = "std"))]
extern crate std;

#[macro_use]
extern crate tracing;
use tracing::{span, Level};
mod support;

use self::support::*;
use tracing::Level;

use std::sync::{
atomic::{AtomicUsize, Ordering},
Expand Down
7 changes: 4 additions & 3 deletions tracing/tests/macros.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#![deny(warnings)]
use tracing::Level;
use tracing::{
callsite, debug, debug_span, error, error_span, event, info, info_span, span, trace,
trace_span, warn, warn_span, Level,
};

#[macro_use]
extern crate tracing;
// Tests that macros work across various invocation syntax.
//
// These are quite repetitive, and _could_ be generated by a macro. However,
Expand Down
Loading