Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 如何找到宏的位置';板条箱之间用什么?_Debugging_Macros_Rust - Fatal编程技术网

Debugging 如何找到宏的位置';板条箱之间用什么?

Debugging 如何找到宏的位置';板条箱之间用什么?,debugging,macros,rust,Debugging,Macros,Rust,当宏在板条箱之间引起死机(直接或间接)时,使用宏的代码行不包括在回溯跟踪中 这使得不可能知道是哪个宏的使用导致了恐慌 也就是说,如果一个宏在许多地方使用,您就找不到要关注的代码行 我遇到了这个问题,因为我的测试直接在一个单独的测试环境中进行,并且使用他们测试的代码作为一个板条箱 例如下面的例子 tests/tests.rs extern crate test_macro; #[test] fn main() { let file: Vec<u8> = Vec::new();

当宏在板条箱之间引起死机(直接或间接)时,使用宏的代码行不包括在回溯跟踪中

这使得不可能知道是哪个宏的使用导致了恐慌

也就是说,如果一个宏在许多地方使用,您就找不到要关注的代码行

我遇到了这个问题,因为我的测试直接在一个单独的测试环境中进行,并且使用他们测试的代码作为一个板条箱

例如下面的例子

tests/tests.rs

extern crate test_macro;
#[test]
fn main() {
    let file: Vec<u8> = Vec::new();
    test_macro::decode_main(&*file).unwrap();
}
use ::std::io;

macro_rules! read_exact {
    ($f:expr, $r:expr) => {
        io::Read::read_exact($f, $r).unwrap()
    }
}

fn decode_blocks<R: io::Read>(mut file: R) -> Result<(), io::Error> {
    let mut bhead: [u8; 320] = [0; 320];
    read_exact!(&mut file, &mut bhead);  // <-- this line isn't in the backtrace
    Ok(())
}

pub fn decode_main<R: io::Read>(mut file: R) -> Result<(), io::Error> {
    decode_blocks(file)?;
    Ok(())
}
电话:

RUST_BACKTRACE=1 cargo test
提供回溯跟踪:

                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:737
  11:     0x562061ffd7da - test_macro::decode_blocks::h391253710f990761
                        at /src/test_macro/src/lib.rs:5
  12:     0x562061ffd5ca - test_macro::decode_main::h43b3b33b47640ea4
                        at /src/test_macro/src/lib.rs:16
  13:     0x562061fff1ad - tests::main::hc17f25ef21544d0b
                        at /src/test_macro/tests/tests.rs:5
  14:     0x56206200d54e - <F as test::FnBox<T>>::call_box::h04563d623b7ebdf9
at/buildslave/rust buildbot/slave/stable dist rustc linux/build/src/libcore/result.rs:737
11:0x562061ffd7da-测试_宏::解码_块::h391253710f990761
at/src/test_macro/src/lib.rs:5
12:0x562061ffd5ca-测试_宏::解码_主::H43B33B47640EA4
at/src/test_macro/src/lib.rs:16
13:0x562061fff1ad-测试::主::hc17f25ef21544d0b
at/src/test\u宏/tests/tests.rs:5
14:0x56206200d54e-::呼叫盒::h04563d623b7ebdf9
注意,第11行不包括在内



使用防锈剂稳定1.15。报告这是一个bug。

听起来像个bug……哪个版本的编译器?对我有效()@Chris Emerson,确认它在简单情况下有效。。。。在更复杂的测试用例中再次确认失败,这需要一些时间来简化。更新,这只发生在板条箱之间。编辑问题,包括工作示例和git回购。