From 4cf8d55236390b0f84d7676efa457364aadc6de7 Mon Sep 17 00:00:00 2001 From: Liangfu Chen Date: Mon, 21 Jun 2021 09:57:07 +0800 Subject: [PATCH] [rust] convert error msg to string for panic macro --- rust/tvm-macros/src/util.rs | 2 +- rust/tvm-rt/src/object/object_ptr.rs | 2 +- rust/tvm/src/ir/diagnostics/codespan.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/tvm-macros/src/util.rs b/rust/tvm-macros/src/util.rs index 2a342bcc3453..b02e3f69b671 100644 --- a/rust/tvm-macros/src/util.rs +++ b/rust/tvm-macros/src/util.rs @@ -43,6 +43,6 @@ pub(crate) fn attr_to_str(attr: &syn::Attribute) -> syn::LitStr { .. })) => s, Ok(m) => panic!("Expected a string literal, got {:?}", m), - Err(e) => panic!(e), + Err(e) => panic!("{}", e), } } diff --git a/rust/tvm-rt/src/object/object_ptr.rs b/rust/tvm-rt/src/object/object_ptr.rs index 264d5febd103..64fd6a2218aa 100644 --- a/rust/tvm-rt/src/object/object_ptr.rs +++ b/rust/tvm-rt/src/object/object_ptr.rs @@ -109,7 +109,7 @@ impl Object { let mut index = 0; unsafe { if TVMObjectTypeKey2Index(cstring.as_ptr(), &mut index) != 0 { - panic!(crate::get_last_error()) + panic!("{}", crate::get_last_error()) } } return index; diff --git a/rust/tvm/src/ir/diagnostics/codespan.rs b/rust/tvm/src/ir/diagnostics/codespan.rs index c411c0cd31a7..22e51e4e7396 100644 --- a/rust/tvm/src/ir/diagnostics/codespan.rs +++ b/rust/tvm/src/ir/diagnostics/codespan.rs @@ -191,7 +191,7 @@ fn renderer(state: &mut DiagnosticState, diag_ctx: DiagnosticContext) { let config = codespan_reporting::term::Config::default(); for diagnostic in diag_ctx.diagnostics.clone() { match source_map.source_map.get(&diagnostic.span.source_name) { - Err(err) => panic!(err), + Err(err) => panic!("{}", err), Ok(source) => { state.add_source(source); let diagnostic = state.to_diagnostic(diagnostic);