Skip to content

Commit

Permalink
tracing: use fully qualified names in macros for items exported from …
Browse files Browse the repository at this point in the history
…std prelude (tokio-rs#2621)

Currently, in many places, macros do not use fully qualified names for
items exported from the prelude. This means that naming collisions
(`struct Some`) or the removal of the std library prelude will cause
compilation errors.

- Identify and use fully qualified names in macros were we previously
  assumed the Rust std prelude. We use `::core` rather than `::std`.
- Add
  [`no_implicit_prelude`](https://doc.rust-lang.org/reference/names/preludes.html#the-no_implicit_prelude-attribute)
  to `tracing/tests/macros.rs`. I'm unsure if this is giving us good
  coverage - can we improve on this approach? I'm not confident I've
  caught everything.
  • Loading branch information
hlbarber authored and kaffarell committed May 22, 2024
1 parent c64fedb commit 9966cfe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tracing-subscriber/src/fmt/fmt_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ macro_rules! with_event_from_span {
#[allow(unused)]
let mut iter = fs.iter();
let v = [$(
(&iter.next().unwrap(), Some(&$value as &dyn field::Value)),
(&iter.next().unwrap(), ::core::option::Option::Some(&$value as &dyn field::Value)),
)*];
let vs = fs.value_set(&v);
let $event = Event::new_child_of($id, meta, &vs);
Expand Down

0 comments on commit 9966cfe

Please sign in to comment.