Skip to content

avoid using macro_use #3634

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

Merged
merged 1 commit into from
May 26, 2024
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
5 changes: 2 additions & 3 deletions cargo-miri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#![allow(clippy::useless_format, clippy::derive_partial_eq_without_eq, rustc::internal)]

#[macro_use]
mod util;

mod arg;
mod phases;
mod setup;
mod util;

use std::{env, iter};

use crate::phases::*;
use crate::util::show_error;

/// Returns `true` if our flags look like they may be for rustdoc, i.e., this is cargo calling us to
/// be rustdoc. It's hard to be sure as cargo does not have a RUSTDOC_WRAPPER or an env var that
Expand Down
5 changes: 3 additions & 2 deletions cargo-miri/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ use serde::{Deserialize, Serialize};

pub use crate::arg::*;

pub fn show_error(msg: &impl std::fmt::Display) -> ! {
pub fn show_error_(msg: &impl std::fmt::Display) -> ! {
eprintln!("fatal error: {msg}");
std::process::exit(1)
}

macro_rules! show_error {
($($tt:tt)*) => { crate::util::show_error(&format_args!($($tt)*)) };
($($tt:tt)*) => { crate::util::show_error_(&format_args!($($tt)*)) };
}
pub(crate) use show_error;

/// The information to run a crate with the given environment.
#[derive(Clone, Serialize, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
)]

// Some "regular" crates we want to share with rustc
#[macro_use]
extern crate tracing;

// The rustc crates we need
Expand All @@ -26,6 +25,8 @@ use std::num::NonZero;
use std::path::PathBuf;
use std::str::FromStr;

use tracing::debug;

use rustc_data_structures::sync::Lrc;
use rustc_driver::Compilation;
use rustc_hir::{self as hir, Node};
Expand Down
1 change: 1 addition & 0 deletions src/borrow_tracker/stacked_borrows/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::ops::Range;

use rustc_data_structures::fx::FxHashSet;
use tracing::trace;

use crate::borrow_tracker::{
stacked_borrows::{Item, Permission},
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency/init_once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::sync::EvalContextExtPriv as _;
use super::vector_clock::VClock;
use crate::*;

declare_id!(InitOnceId);
super::sync::declare_id!(InitOnceId);

#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
/// The current status of a one time initialization.
Expand Down
3 changes: 1 addition & 2 deletions src/concurrency/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pub mod data_race;
pub mod init_once;
mod range_object_map;
#[macro_use]
pub mod sync;
pub mod init_once;
pub mod thread;
mod vector_clock;
pub mod weak_memory;
Expand Down
1 change: 1 addition & 0 deletions src/concurrency/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ macro_rules! declare_id {
}
};
}
pub(super) use declare_id;

declare_id!(MutexId);

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

// Some "regular" crates we want to share with rustc
extern crate either;
#[macro_use]
extern crate tracing;

// The rustc crates we need
Expand All @@ -64,7 +63,6 @@ extern crate rustc_data_structures;
extern crate rustc_errors;
extern crate rustc_hir;
extern crate rustc_index;
#[macro_use]
extern crate rustc_middle;
extern crate rustc_session;
extern crate rustc_span;
Expand All @@ -91,6 +89,8 @@ mod range_map;
mod shims;

// Establish a "crate-wide prelude": we often import `crate::*`.
use rustc_middle::{bug, span_bug};
use tracing::{info, trace};

// Make all those symbols available in the same place as our own.
#[doc(no_inline)]
Expand Down