-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Trying to produce artefacts for stable mir json on test code of a cargo project via cargo test panics.
Reproducer
cd stable-mir-json
cargo build --release && cargo run --bin cargo_stable_mir_json -- $PWD
cd ..
cargo new --lib smir-test-fail
cd smir-test-fail
RUSTC=~/.stable-mir-json/release.sh cargo testThe test fails with:
thread 'rustc' panicked at src/printer.rs:688:13:
assertion failed: kind.unwrap().is_fn_ptr()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Which is from line 688 of stable_mir_json::printer introduced in this PR:
//-snip-
GlobalAlloc::Function(inst) => {
assert!(kind.unwrap().is_fn_ptr()); // <-- line 688
entry.or_insert(AllocInfo::Function(inst));
}
//-snip-Printing kind and inst gives
Some(RigidTy(Ref(Region { kind: ReErased }, Ty { id: 116, kind: RigidTy(Adt(AdtDef(DefId { id: 30, name: "tests::test::TestDescAndFn" }), GenericArgs([]))) }, Not)))
Instance { kind: Shim, def: "_ZN4core3ops8function6FnOnce9call_once17h4aa4ff19edd7fd65E", args: GenericArgs([Type(Ty { id: 103, kind: RigidTy(Closure(ClosureDef(DefId { id: 17, name: "tests::it_works::{closure#0}" }), GenericArgs([Type(Ty { id: 106, kind: RigidTy(Int(I8)) }), Type(Ty { id: 117, kind: RigidTy(FnPtr(Binder { value: FnSig { inputs_and_output: [Ty { id: 2, kind: RigidTy(Tuple([])) }, Ty { id: 64, kind: RigidTy(Adt(AdtDef(DefId { id: 23, name: "std::result::Result" }), GenericArgs([Type(Ty { id: 2, kind: RigidTy(Tuple([])) }), Type(Ty { id: 15, kind: RigidTy(Adt(AdtDef(DefId { id: 4, name: "std::string::String" }), GenericArgs([]))) })]))) }], c_variadic: false, safety: Safe, abi: RustCall }, bound_vars: [] })) }), Type(Ty { id: 2, kind: RigidTy(Tuple([])) })]))) }), Type(Ty { id: 2, kind: RigidTy(Tuple([])) })]) }
which is from the #[test] attribute, which is a compiler built in.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working