diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13c79504..6049236e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,3 +79,19 @@ jobs: - name: Check run: cargo check --target wasm32-unknown-unknown + + miri: + name: Miri + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@nightly + with: + components: miri + + - name: Test + run: MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-ignore-leaks" cargo miri test diff --git a/tests/header_map.rs b/tests/header_map.rs index f2beba08..9859b0a8 100644 --- a/tests/header_map.rs +++ b/tests/header_map.rs @@ -190,7 +190,7 @@ fn drain_entry() { assert_eq!(vals[1], "world2"); } - assert_eq!(5-2+1, headers.len()); + assert_eq!(5 - 2 + 1, headers.len()); } #[test] @@ -427,7 +427,6 @@ fn value_htab() { HeaderValue::from_str("hello\tworld").unwrap(); } - #[test] fn remove_multiple_a() { let mut headers = HeaderMap::new(); @@ -570,7 +569,8 @@ fn remove_entry_multi_3_others() { } fn remove_all_values(headers: &mut HeaderMap, key: K) -> Vec - where K: IntoHeaderName +where + K: IntoHeaderName, { match headers.entry(key) { Entry::Occupied(e) => e.remove_entry_mult().1.collect(), @@ -629,10 +629,22 @@ fn remove_entry_3_others_b() { } fn remove_values(headers: &mut HeaderMap, key: K) -> Option - where K: IntoHeaderName +where + K: IntoHeaderName, { match headers.entry(key) { Entry::Occupied(e) => Some(e.remove_entry().1), Entry::Vacant(_) => None, } } + +#[test] +fn ensure_miri_sharedreadonly_not_violated() { + let mut headers = HeaderMap::new(); + headers.insert( + HeaderName::from_static("chunky-trailer"), + HeaderValue::from_static("header data"), + ); + + let _foo = &headers.iter().next(); +}