Skip to content

Conversation

bvanjoi
Copy link
Contributor

@bvanjoi bvanjoi commented Jun 28, 2025

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 28, 2025
@petrochenkov
Copy link
Contributor

I don't understand why this works and how it fixes the issue.
The LookAheadMacroDefinition are inserted for all macro definitions, regardless of whether it's macro or macro_rules, and nothing is done for use items.
The reversed rib walk in fn apply_pattern_bindings can also encounter arbitrary ribs before encountering a LookAheadMacroDefinition.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2025
@petrochenkov
Copy link
Contributor

Also "shallow" -> "shadow" in the PR/commit messages and file names.

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Jul 1, 2025

The reversed rib walk in fn apply_pattern_bindings can also encounter arbitrary ribs before encountering a LookAheadMacroDefinition.

There may be a bug if LookAheadMacroDefinition fails to apply correctly.

I don't understand why this works and how it fixes the issue.

LookAheadMacroDefinition stores the macro expansion result and serves as a fallback in resolve_ident_in_lexical_scope, ensuring it takes the correct resolution path:

// The ident resolves to a type parameter or local variable.
return Some(LexicalScopeBinding::Res(self.validate_res_from_ribs(
i,
rib_ident,
*res,
finalize.map(|finalize| finalize.path_span),
*original_rib_ident_def,
ribs,
)));

@bvanjoi bvanjoi changed the title fresh binding should shallow the def after expand fresh binding should shadow the def in expand Jul 1, 2025
@bvanjoi
Copy link
Contributor Author

bvanjoi commented Jul 1, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 1, 2025
@petrochenkov
Copy link
Contributor

@bvanjoi
Are you sure this cannot successfully resolve some names that should not be resolved?
(I started reviewing yesterday, but it was late so I'll finish today or on Monday.)

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Jul 12, 2025

Are you sure this cannot successfully resolve some names that should not be resolved?

I need to test this with additional cases across different rib contexts. @rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 26, 2025
@rust-log-analyzer

This comment has been minimized.

Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 14, 2025
resolve: Introduce `RibKind::Block`

to avoid confusing module items, blocks with items, and blocks without items.

Addresses rust-lang#143141 (comment) and rust-lang#143141 (comment).

A couple of related cleanups are also added on top.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
resolve: Introduce `RibKind::Block`

to avoid confusing module items, blocks with items, and blocks without items.

Addresses rust-lang#143141 (comment) and rust-lang#143141 (comment).

A couple of related cleanups are also added on top.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
resolve: Introduce `RibKind::Block`

to avoid confusing module items, blocks with items, and blocks without items.

Addresses rust-lang#143141 (comment) and rust-lang#143141 (comment).

A couple of related cleanups are also added on top.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 15, 2025
resolve: Introduce `RibKind::Block`

to avoid confusing module items, blocks with items, and blocks without items.

Addresses rust-lang#143141 (comment) and rust-lang#143141 (comment).

A couple of related cleanups are also added on top.
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #145065 - petrochenkov:riblock, r=davidtwco

resolve: Introduce `RibKind::Block`

to avoid confusing module items, blocks with items, and blocks without items.

Addresses #143141 (comment) and #143141 (comment).

A couple of related cleanups are also added on top.
@bvanjoi
Copy link
Contributor Author

bvanjoi commented Aug 16, 2025

Could you also add a test case demonstrating what happens with this example?

This refers to the fn a in the main block. I think this case should throw an error like a is not accessible in this block scope, correct?

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Aug 16, 2025

Additionally, what would be the expected behavior for this particular case?

fn f_with_macro_export() {
    let d = 10;

    {
        #[macro_export]
        macro_rules! m {
            () => {
               d 
            };
        }
        use crate::m;
        m!(); // compile success
    }

    use crate::m;
    m!(); // Should this case compile successfully? Note that it currently throws a 'not found' error in the master branch
}

@petrochenkov
Copy link
Contributor

petrochenkov commented Aug 16, 2025

Could you also add a test case demonstrating what happens with this example?

This refers to the fn a in the main block. I think this case should throw an error like a is not accessible in this block scope, correct?

Yes, some error like that.
Technically it should do that even if m is exported from a different crate, but implementing that would have a really bad cost/benefit ratio.

@petrochenkov
Copy link
Contributor

petrochenkov commented Aug 16, 2025

Additionally, what would be the expected behavior for this particular case?

I'd expect it to be ok, d is in scope at m's definition site (and alive at point of use).

@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2025

This PR was rebased onto a different master commit! Check out the changes with our range-diff.

@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2025

This PR was rebased onto a different master commit! Check out the changes with our range-diff.

@rust-log-analyzer

This comment has been minimized.

github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 18, 2025
resolve: Introduce `RibKind::Block`

to avoid confusing module items, blocks with items, and blocks without items.

Addresses rust-lang/rust#143141 (comment) and rust-lang/rust#143141 (comment).

A couple of related cleanups are also added on top.
@bors

This comment was marked as resolved.

@rustbot
Copy link
Collaborator

rustbot commented Aug 24, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Aug 24, 2025

Technically it should do that even if m is exported from a different crate

These changes have wide-ranging implications. Could you please review whether the modifications in tests/ui/hygiene/{legacy_interaction, wrap_unhygienic_example}.rs produce the expected behavior?

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1274 |   macro_rules! debug {
     |   ------------------ in this expansion of `debug!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/linked_graph/mod.rs:152:9
     |
 152 |           debug!("graph: add_edge({:?}, {:?}, {:?})", source, target, data);
     |           ----------------------------------------------------------------- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1274 |   macro_rules! debug {
     |   ------------------ in this expansion of `debug!` (#1)
---
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:214:9
     |
 214 | /         debug!(
 215 | |             "create_scc({:?}) successors={:?}",
 216 | |             self.len(),
 217 | |             &self.all_successors[all_successors_start..all_successors_end],
 218 | |         );
     | |_________- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:410:17
     |
 410 |                   trace!("find_state(r = {node:?} in state {:?})", self.node_states[node]);
     |                   ------------------------------------------------------------------------ in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:484:13
     |
 484 |               trace!("Compressing {node:?} down to {previous_node:?} with state {assigned_state:?}");
     |               -------------------------------------------------------------------------------------- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
  20 |   macro_rules! span {
     |   ----------------- in this expansion of `::tracing::span!` (#2)
...
  58 |               static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  __________________________________________________________________-
  59 | |                 name: $name,
  60 | |                 kind: $crate::metadata::Kind::SPAN,
  61 | |                 target: $target,
  62 | |                 level: $lvl,
  63 | |                 fields: $($fields)*
  64 | |             };
     | |_____________- in this macro invocation (#3)
...
2123 |   macro_rules! callsite2 {
     |   ---------------------- in this expansion of `$crate::callsite2!` (#3)
...
2160 |                   callsite: &CALLSITE,
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:509:5
     |
 509 |       #[instrument(skip(self, initial), level = "trace")]
     |       ---------------------------------------------------
     |       |
     |       in this attribute macro expansion (#1)
     |       in this macro invocation (#2)
     |
---
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:511:9
     |
 511 |           trace!("Walk unvisited node: {initial:?}");
     |           ------------------------------------------ in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:558:13
     |
 558 | /             trace!(
 559 | |                 "Visiting {node:?} at depth {depth:?}, annotation: {current_component_annotation:?}"
 560 | |             );
     | |_____________- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2123 |   macro_rules! callsite2 {
     |   ---------------------- in this expansion of `$crate::callsite2!` (#3)
...
2160 |                   callsite: &CALLSITE,
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:566:21
     |
 566 |                       trace!(?depth, ?node);
     |                       --------------------- in this macro invocation (#1)

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2224:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
...
2224 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:566:21
     |
 566 |                       trace!(?depth, ?node);
     |                       --------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2262:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
     |   in this expansion of `$crate::valueset!` (#5)
...
2223 | /         $crate::valueset!(
2224 | |             @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
2225 | |             $next,
2226 | |             $($rest)*
2227 | |         )
     | |_________- in this macro invocation (#5)
...
2262 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:566:21
     |
 566 |                       trace!(?depth, ?node);
     |                       --------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2123 |   macro_rules! callsite2 {
     |   ---------------------- in this expansion of `$crate::callsite2!` (#3)
...
2160 |                   callsite: &CALLSITE,
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:596:17
     |
 596 |                   trace!(?node, ?successor_node);
     |                   ------------------------------ in this macro invocation (#1)

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2224:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
...
2224 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:596:17
     |
 596 |                   trace!(?node, ?successor_node);
     |                   ------------------------------ in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2262:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
     |   in this expansion of `$crate::valueset!` (#5)
...
2223 | /         $crate::valueset!(
2224 | |             @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
2225 | |             $next,
2226 | |             $($rest)*
2227 | |         )
     | |_________- in this macro invocation (#5)
...
2262 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:596:17
     |
 596 |                   trace!(?node, ?successor_node);
     |                   ------------------------------ in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0425]: cannot find value `CALLSITE` in this scope
---
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:607:25
     |
 607 | /                         trace!(
 608 | |                             "Cycle found from {node:?}, minimum depth: {successor_min_depth:?}, annotation: {successor_annotation:?}"
 609 | |                         );
     | |_________________________- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2123 |   macro_rules! callsite2 {
     |   ---------------------- in this expansion of `$crate::callsite2!` (#3)
...
2160 |                   callsite: &CALLSITE,
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:613:29
     |
 613 |   ...                   trace!(?node, ?successor_min_depth);
     |                         ----------------------------------- in this macro invocation (#1)

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2224:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
...
2224 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:613:29
     |
 613 |   ...                   trace!(?node, ?successor_min_depth);
     |                         ----------------------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2262:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
     |   in this expansion of `$crate::valueset!` (#5)
...
2223 | /         $crate::valueset!(
2224 | |             @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
2225 | |             $next,
2226 | |             $($rest)*
2227 | |         )
     | |_________- in this macro invocation (#5)
...
2262 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:613:29
     |
 613 |   ...                   trace!(?node, ?successor_min_depth);
     |                         ----------------------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0425]: cannot find value `CALLSITE` in this scope
---
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:625:25
     |
 625 | / ...   trace!(
 626 | | ...       "Complete; {node:?} is root of complete-visited SCC idx {successor_scc_index:?} with annotation {successor_annotation:?}"
 627 | | ...   );
     | |_______- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2123 |   macro_rules! callsite2 {
     |   ---------------------- in this expansion of `$crate::callsite2!` (#3)
...
2160 |                   callsite: &CALLSITE,
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:630:25
     |
 630 |                           trace!(?node, ?successor_scc_index);
     |                           ----------------------------------- in this macro invocation (#1)

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2224:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
...
2224 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:630:25
     |
 630 |                           trace!(?node, ?successor_scc_index);
     |                           ----------------------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2262:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
     |   in this expansion of `$crate::valueset!` (#5)
...
2223 | /         $crate::valueset!(
2224 | |             @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
2225 | |             $next,
2226 | |             $($rest)*
2227 | |         )
     | |_________- in this macro invocation (#5)
...
2262 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:630:25
     |
 630 |                           trace!(?node, ?successor_scc_index);
     |                           ----------------------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0425]: cannot find value `CALLSITE` in this scope
---
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:637:25
     |
 637 |                           trace!("Recursing down into {successor_node:?} at depth {depth:?}");
     |                           ------------------------------------------------------------------- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2123 |   macro_rules! callsite2 {
     |   ---------------------- in this expansion of `$crate::callsite2!` (#3)
...
2160 |                   callsite: &CALLSITE,
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:638:25
     |
 638 |                           trace!(?depth, ?successor_node);
     |                           ------------------------------- in this macro invocation (#1)

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2224:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
...
2224 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:638:25
     |
 638 |                           trace!(?depth, ?successor_node);
     |                           ------------------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0423]: expected function, found macro `debug`
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2262:43
     |
 584 |   macro_rules! event {
     |   ------------------ in this expansion of `$crate::event!` (#2)
...
 673 |               })($crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
     |                  ------------------------------------------------------------ in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
...
1207 | /         $crate::event!(
1208 | |             target: module_path!(),
1209 | |             $crate::Level::TRACE,
1210 | |             { ?$($k).+, $($field)*}
1211 | |         )
     | |_________- in this macro invocation (#2)
...
2180 |   macro_rules! valueset {
     |   ---------------------
     |   |
     |   in this expansion of `$crate::valueset!` (#3)
     |   in this expansion of `$crate::valueset!` (#4)
     |   in this expansion of `$crate::valueset!` (#5)
...
2223 | /         $crate::valueset!(
2224 | |             @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
2225 | |             $next,
2226 | |             $($rest)*
2227 | |         )
     | |_________- in this macro invocation (#5)
...
2262 |               @ { $($out),*, (&$next, Some(&debug(&$($k).+) as &dyn Value)) },
     |                                             ^^^^^ not a function
...
2325 |               $fields.value_set($crate::valueset!(
     |  _______________________________-
2326 | |                 @ { },
2327 | |                 iter.next().expect("FieldSet corrupted (this is a bug)"),
2328 | |                 $($kvs)+
2329 | |             ))
     | |_____________- in this macro invocation (#4)
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:638:25
     |
 638 |                           trace!(?depth, ?successor_node);
     |                           ------------------------------- in this macro invocation (#1)
     |
help: consider importing this function instead
    -->  compiler/rustc_data_structures/src/graph/scc/mod.rs:11:1
     |
  11 + use tracing::field::debug;
     |

error[E0425]: cannot find value `CALLSITE` in this scope
---
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1087 |   macro_rules! trace {
     |   ------------------ in this expansion of `trace!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:657:13
     |
 657 |               trace!("Finished walk from {node:?} with annotation: {current_component_annotation:?}");
     |               --------------------------------------------------------------------------------------- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1274 |   macro_rules! debug {
     |   ------------------ in this expansion of `debug!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/graph/scc/mod.rs:687:17
     |
 687 |                   debug!("Creating SCC rooted in {node:?} with successor {:?}", frame.successor_node);
     |                   ----------------------------------------------------------------------------------- in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1274 |   macro_rules! debug {
     |   ------------------ in this expansion of `debug!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/obligation_forest/mod.rs:350:13
     |
 350 |               debug!("register_obligation_at: ignoring already done obligation: {:?}", obligation);
     |               ------------------------------------------------------------------------------------ in this macro invocation (#1)

error[E0425]: cannot find value `CALLSITE` in this scope
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.37/src/macros.rs:2160:28
     |
 584 |   macro_rules! event {
     |   ------------------
     |   |
     |   in this expansion of `$crate::event!` (#2)
     |   in this expansion of `$crate::event!` (#3)
...
 644 |           static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
     |  ______________________________________________________________-
 645 | |             name: $crate::__macro_support::concat!(
 646 | |                 "event ",
 647 | |                 file!(),
...    |
 654 | |             fields: $($fields)*
 655 | |         };
     | |_________- in this macro invocation (#4)
...
 683 | /         $crate::event!(
 684 | |             target: $target,
 685 | |             $lvl,
 686 | |             { message = format_args!($($arg)+), $($fields)* }
 687 | |         )
     | |_________- in this macro invocation (#3)
...
1691 |   macro_rules! warn {
     |   ----------------- in this expansion of `warn!` (#1)
---
     |                              ^^^^^^^^ not found in this scope
     |
    ::: compiler/rustc_data_structures/src/profiling.rs:666:17
     |
 666 | /                 warn!(
 667 | |                     "Unknown self-profiler events specified: {}. Available options are: {}.",
 668 | |                     unknown_events.join(", "),
 669 | |                     EVENT_FILTERS_BY_NAME
...    |
 673 | |                         .join(", ")
 674 | |                 );
     | |_________________- in this macro invocation (#1)

[RUSTC-TIMING] writeable test:false 0.948
[RUSTC-TIMING] ppv_lite86 test:false 0.482

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Aug 24, 2025

Reduce for #143141 (comment)

macro_rules! m2 {
    () => {{
        static B: i32 = S;
        42
    }};
}

macro_rules! m {
    () => {
        static S: i32 = m2!();
    };
}

fn main() {
    m!();
}

@bvanjoi
Copy link
Contributor Author

bvanjoi commented Aug 24, 2025

Using lexical scope at macro definition sites presents problematic outcomes:

  1. ​If we adopt this behavior:​​ Risk significant regression, including failure to compile stage2 of the compiler due to tracing crate failures. Additional affected cases exist in tests/ui/hygiene/{wrap_unhygienic_example, legacy_interaction}.rs.

  2. ​If we reject this behavior:​​ The example from fresh binding should shadow the def in expand #143141 (comment) would compile successfully, which contradicts previous discussion.

This behavior is related to the changes: https://github.com/rust-lang/rust/pull/143141/files#diff-c046507afdba3b0705638f53fffa156cbad72ed17aa01d96d7bd1cc10b8d9bceR454-R483

What do you think? Should we introduce this change as a lint instead? @petrochenkov

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 25, 2025
@@ -20,9 +19,9 @@ extern crate legacy_interaction;
mod def_site {
// Unless this macro opts out of hygiene, it should resolve the same wherever it is invoked.
pub macro m2() {
::legacy_interaction::m!();
::legacy_interaction::m!(); //~ ERROR cannot find function `g` in this scope
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look correct.
g is an item, so it should be found at call site, not at def site, because m! is not a macro 2.0.

macro_rules use https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.mixed_site so only local variables and labels are looked up at definition site (and $crate, but we are not talking about it here).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same with wrap_unhygienic_example.rs.

@petrochenkov
Copy link
Contributor

Should we introduce this change as a lint instead?

We'll definitely need a crater run and possibly a lint in the end.

But at this point we probably rather need some more or less formal model of the rules that we want to achieve.
At both call site (including code coming from the macro itself) and at def site local variables and items can interleave, so it needs to be clarified what are the priorities.
I.e. what is the search order here.

#![allow(unused)]

fn f() {
    let a = 0;
    {
        fn a() {}
        {
            let a = 0;
            {
                fn a() {}
                
                #[macro_export]
                macro_rules! mac {
                    () => {
                        let a = 0;
                        {
                            fn a() {}
                            {
                                let a = 0;
                                {
                                    a; // use
                                }
                            }
                        }
                    };
                }
            }
        }
    }
}

fn main() {
    let a = 0;
    {
        fn a() {}
        {
            let a = 0;
            {
                mac!();
            }
        }
    }
}

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hygiene of used macro item is weird.
5 participants