Skip to content

Commit 2cfcd42

Browse files
author
ed sandberg
committed
replace macro usage for BasicBlock and AssertMessage. All traces of basic_json_impl have been removed.
1 parent 6776f47 commit 2cfcd42

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/analyz/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,12 @@ impl<'tcx> ToJson<'tcx> for mir::PlaceElem<'tcx> {
306306
}
307307
}
308308

309-
basic_json_impl!(mir::BasicBlock);
310-
311309
impl ToJson<'_> for mir::Field {
312310
fn to_json(&self, _mir: &mut MirState) -> serde_json::Value {
313311
json!(self.index())
314312
}
315313
}
316314

317-
basic_json_impl!(mir::AssertMessage<'a>, 'a);
318-
319315
impl<'tcx> ToJson<'tcx> for mir::Operand<'tcx> {
320316
fn to_json(&self, mir: &mut MirState<'_, 'tcx>) -> serde_json::Value {
321317
match self {

src/analyz/to_json.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
22
use rustc_hir::def::CtorKind;
33
use rustc_hir::Mutability;
4-
use rustc_middle::mir::{BinOp, Body, CastKind, interpret, NullOp, UnOp};
4+
use rustc_middle::mir::{AssertMessage, BasicBlock, BinOp, Body, CastKind, interpret, NullOp, UnOp};
55
use rustc_middle::ty::{self, DynKind, FloatTy, IntTy, TyCtxt, UintTy};
66
use rustc_session::Session;
77
use rustc_span::Span;
@@ -10,6 +10,7 @@ use rustc_target::spec::abi::Abi;
1010
use serde_json;
1111
use std::collections::BTreeMap;
1212
use std::collections::{HashMap, HashSet, hash_map};
13+
use std::fmt::Write;
1314
use std::hash::{Hash, Hasher};
1415
use std::ops::Deref;
1516
use std::mem;
@@ -400,28 +401,23 @@ impl<'tcx, K, V> ToJson<'tcx> for BTreeMap<K, V>
400401
}
401402
}
402403

403-
#[macro_export]
404-
macro_rules! basic_json_impl {
405-
($n : path) => {
406-
impl ToJson<'_> for $n {
407-
fn to_json(&self, _ : &mut MirState) -> serde_json::Value {
404+
impl<'a> ToJson<'_> for AssertMessage<'a> {
405+
fn to_json(&self, _: &mut MirState) -> serde_json::Value {
408406
let mut s = String::new();
409407
write!(&mut s, "{:?}", self).unwrap();
410408
json!(s)
411409
}
412410
}
413-
};
414-
($n : path, $lt : tt) => {
415-
impl<$lt> ToJson<'_> for $n {
416-
fn to_json(&self, _ : &mut MirState) -> serde_json::Value {
411+
412+
impl ToJson<'_> for BasicBlock {
413+
fn to_json(&self, _: &mut MirState) -> serde_json::Value {
417414
let mut s = String::new();
418415
write!(&mut s, "{:?}", self).unwrap();
419416
json!(s)
420417
}
421418
}
422419

423-
};
424-
}
420+
// enum handlers
425421

426422
impl ToJson<'_> for Abi {
427423
fn to_json(&self, _: &mut MirState) -> serde_json::Value {
@@ -562,6 +558,8 @@ impl ToJson<'_> for UintTy {
562558
}
563559
}
564560

561+
// end enum handlers
562+
565563
impl ToJson<'_> for UnOp {
566564
fn to_json(&self, _: &mut MirState) -> serde_json::Value {
567565
match self {

0 commit comments

Comments
 (0)