From 4e2f8322cc6ee7ef06a1d5718405964e8da14d18 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 27 Apr 2023 16:17:55 -0400 Subject: [PATCH] Build tests with all features Remove mem::forget::() calls in tests which fail to compile when HashMap is provided by hashbrown: info: running `cargo check --all-targets --no-default-features` on aya-obj (11/23) Checking aya-obj v0.1.0 (/home/tamird/src/aya/aya-obj) error[E0505]: cannot move out of `map` because it is borrowed --> aya-obj/src/relocation.rs:594:21 | 578 | let map = fake_legacy_map(1); | --- binding `map` declared here 579 | let maps_by_symbol = HashMap::from([(1, ("test_map", Some(1), &map))]); | ---- borrow of `map` occurs here ... 594 | mem::forget(map); | ^^^ move out of `map` occurs here 595 | } | - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap, &maps::Map)>` error[E0505]: cannot move out of `map_1` because it is borrowed --> aya-obj/src/relocation.rs:655:21 | 632 | let map_1 = fake_legacy_map(1); | ----- binding `map_1` declared here ... 635 | (1, ("test_map_1", Some(1), &map_1)), | ------ borrow of `map_1` occurs here ... 655 | mem::forget(map_1); | ^^^^^ move out of `map_1` occurs here 656 | mem::forget(map_2); 657 | } | - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap, &maps::Map)>` error[E0505]: cannot move out of `map_2` because it is borrowed --> aya-obj/src/relocation.rs:656:21 | 633 | let map_2 = fake_legacy_map(2); | ----- binding `map_2` declared here ... 636 | (2, ("test_map_2", Some(2), &map_2)), | ------ borrow of `map_2` occurs here ... 656 | mem::forget(map_2); | ^^^^^ move out of `map_2` occurs here 657 | } | - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap, &maps::Map)>` error[E0505]: cannot move out of `map` because it is borrowed --> aya-obj/src/relocation.rs:694:21 | 678 | let map = fake_btf_map(1); | --- binding `map` declared here 679 | let maps_by_symbol = HashMap::from([(1, ("test_map", Some(1), &map))]); | ---- borrow of `map` occurs here ... 694 | mem::forget(map); | ^^^ move out of `map` occurs here 695 | } | - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap, &maps::Map)>` error[E0505]: cannot move out of `map_1` because it is borrowed --> aya-obj/src/relocation.rs:755:21 | 732 | let map_1 = fake_btf_map(1); | ----- binding `map_1` declared here ... 735 | (1, ("test_map_1", Some(1), &map_1)), | ------ borrow of `map_1` occurs here ... 755 | mem::forget(map_1); | ^^^^^ move out of `map_1` occurs here 756 | mem::forget(map_2); 757 | } | - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap, &maps::Map)>` error[E0505]: cannot move out of `map_2` because it is borrowed --> aya-obj/src/relocation.rs:756:21 | 733 | let map_2 = fake_btf_map(2); | ----- binding `map_2` declared here ... 736 | (2, ("test_map_2", Some(2), &map_2)), | ------ borrow of `map_2` occurs here ... 756 | mem::forget(map_2); | ^^^^^ move out of `map_2` occurs here 757 | } | - borrow might be used here, when `maps_by_symbol` is dropped and runs the destructor for type `hashbrown::HashMap, &maps::Map)>` For more information about this error, try `rustc --explain E0505`. error: could not compile `aya-obj` due to 6 previous errors warning: build failed, waiting for other jobs to finish... error: process didn't exit successfully: `/home/tamird/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo check --all-targets --manifest-path aya-obj/Cargo.toml --no-default-features` (exit status: 101) --- .github/workflows/build-aya.yml | 2 +- aya-obj/src/relocation.rs | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/build-aya.yml b/.github/workflows/build-aya.yml index c7bc3d9e..4e742c85 100644 --- a/.github/workflows/build-aya.yml +++ b/.github/workflows/build-aya.yml @@ -32,7 +32,7 @@ jobs: - uses: taiki-e/install-action@cargo-hack - name: Check - run: cargo hack check --feature-powerset --ignore-private + run: cargo hack check --all-targets --feature-powerset --ignore-private - uses: Swatinem/rust-cache@v1 - name: Prereqs diff --git a/aya-obj/src/relocation.rs b/aya-obj/src/relocation.rs index 55eccb5a..6422ed38 100644 --- a/aya-obj/src/relocation.rs +++ b/aya-obj/src/relocation.rs @@ -590,8 +590,6 @@ mod test { assert_eq!(fun.instructions[0].src_reg(), BPF_PSEUDO_MAP_FD as u8); assert_eq!(fun.instructions[0].imm, 1); - - mem::forget(map); } #[test] @@ -651,9 +649,6 @@ mod test { assert_eq!(fun.instructions[1].src_reg(), BPF_PSEUDO_MAP_FD as u8); assert_eq!(fun.instructions[1].imm, 2); - - mem::forget(map_1); - mem::forget(map_2); } #[test] @@ -690,8 +685,6 @@ mod test { assert_eq!(fun.instructions[0].src_reg(), BPF_PSEUDO_MAP_FD as u8); assert_eq!(fun.instructions[0].imm, 1); - - mem::forget(map); } #[test] @@ -751,8 +744,5 @@ mod test { assert_eq!(fun.instructions[1].src_reg(), BPF_PSEUDO_MAP_FD as u8); assert_eq!(fun.instructions[1].imm, 2); - - mem::forget(map_1); - mem::forget(map_2); } }