Skip to content

Commit bf6e9b6

Browse files
authored
Rollup merge of #143997 - Coder-256:stable-mir-macro-hygiene, r=oli-obk
Use $crate in macros for rustc_public (aka stable_mir) This makes `#[macro_use] extern crate rustc_public` unnecessary (which brings all of `rustc_public`'s macros into scope for the entire crate); instead, now you can simply use `rustc_public::run!()`.
2 parents ce0ca25 + c6e1b21 commit bf6e9b6

File tree

1 file changed

+9
-9
lines changed
  • compiler/rustc_public/src/rustc_internal

1 file changed

+9
-9
lines changed

compiler/rustc_public/src/rustc_internal/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ where
144144
#[macro_export]
145145
macro_rules! run {
146146
($args:expr, $callback_fn:ident) => {
147-
run_driver!($args, || $callback_fn())
147+
$crate::run_driver!($args, || $callback_fn())
148148
};
149149
($args:expr, $callback:expr) => {
150-
run_driver!($args, $callback)
150+
$crate::run_driver!($args, $callback)
151151
};
152152
}
153153

@@ -158,10 +158,10 @@ macro_rules! run {
158158
#[macro_export]
159159
macro_rules! run_with_tcx {
160160
($args:expr, $callback_fn:ident) => {
161-
run_driver!($args, |tcx| $callback_fn(tcx), with_tcx)
161+
$crate::run_driver!($args, |tcx| $callback_fn(tcx), with_tcx)
162162
};
163163
($args:expr, $callback:expr) => {
164-
run_driver!($args, $callback, with_tcx)
164+
$crate::run_driver!($args, $callback, with_tcx)
165165
};
166166
}
167167

@@ -191,11 +191,11 @@ macro_rules! run_driver {
191191
use rustc_public::CompilerError;
192192
use std::ops::ControlFlow;
193193

194-
pub struct StableMir<B = (), C = (), F = fn($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C>>
194+
pub struct StableMir<B = (), C = (), F = fn($($crate::optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C>>
195195
where
196196
B: Send,
197197
C: Send,
198-
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
198+
F: FnOnce($($crate::optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
199199
{
200200
callback: Option<F>,
201201
result: Option<ControlFlow<B, C>>,
@@ -205,7 +205,7 @@ macro_rules! run_driver {
205205
where
206206
B: Send,
207207
C: Send,
208-
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
208+
F: FnOnce($($crate::optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
209209
{
210210
/// Creates a new `StableMir` instance, with given test_function and arguments.
211211
pub fn new(callback: F) -> Self {
@@ -240,7 +240,7 @@ macro_rules! run_driver {
240240
where
241241
B: Send,
242242
C: Send,
243-
F: FnOnce($(optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
243+
F: FnOnce($($crate::optional!($with_tcx TyCtxt))?) -> ControlFlow<B, C> + Send,
244244
{
245245
/// Called after analysis. Return value instructs the compiler whether to
246246
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
@@ -251,7 +251,7 @@ macro_rules! run_driver {
251251
) -> Compilation {
252252
if let Some(callback) = self.callback.take() {
253253
rustc_internal::run(tcx, || {
254-
self.result = Some(callback($(optional!($with_tcx tcx))?));
254+
self.result = Some(callback($($crate::optional!($with_tcx tcx))?));
255255
})
256256
.unwrap();
257257
if self.result.as_ref().is_some_and(|val| val.is_continue()) {

0 commit comments

Comments
 (0)