From 13c2bf2b4ff2e2831d2df38261526673ec11ca3c Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 31 May 2022 22:05:04 +0000 Subject: [PATCH] Bug 1770894 - Update mozglue to arrayvec 0.7. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D147475 --- Cargo.lock | 2 +- mozglue/static/rust/Cargo.toml | 2 +- mozglue/static/rust/lib.rs | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9c493498e91..d7ba55a773bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3324,7 +3324,7 @@ dependencies = [ name = "mozglue-static" version = "0.1.0" dependencies = [ - "arrayvec 0.5.2", + "arrayvec 0.7.2", "cc", "mozbuild", "rustc_version", diff --git a/mozglue/static/rust/Cargo.toml b/mozglue/static/rust/Cargo.toml index 1c3336feae53..48b1ca525f80 100644 --- a/mozglue/static/rust/Cargo.toml +++ b/mozglue/static/rust/Cargo.toml @@ -8,7 +8,7 @@ license = "MPL" path = "lib.rs" [dependencies] -arrayvec = "0.5" +arrayvec = "0.7" [build-dependencies] mozbuild = "0.1" diff --git a/mozglue/static/rust/lib.rs b/mozglue/static/rust/lib.rs index 2ac10993130b..9b73b9d153db 100644 --- a/mozglue/static/rust/lib.rs +++ b/mozglue/static/rust/lib.rs @@ -4,7 +4,7 @@ #![cfg_attr(feature = "oom_with_hook", feature(alloc_error_hook))] -use arrayvec::{Array, ArrayString}; +use arrayvec::ArrayString; use std::cmp; use std::ops::Deref; use std::os::raw::c_char; @@ -34,21 +34,21 @@ fn str_truncate_valid(s: &str, mut mid: usize) -> &str { /// Similar to ArrayString, but with terminating nul character. #[derive(Debug, PartialEq)] -struct ArrayCString + Copy> { - inner: ArrayString, +struct ArrayCString { + inner: ArrayString, } -impl, A: Array + Copy> From for ArrayCString { +impl, const CAP: usize> From for ArrayCString { /// Contrary to ArrayString::from, truncates at the closest unicode /// character boundary. /// ``` - /// assert_eq!(ArrayCString::<[_; 4]>::from("éà"), - /// ArrayCString::<[_; 4]>::from("é")); - /// assert_eq!(&*ArrayCString::<[_; 4]>::from("éà"), "é\0"); + /// assert_eq!(ArrayCString::<4>::from("éà"), + /// ArrayCString::<4>::from("é")); + /// assert_eq!(&*ArrayCString::<4>::from("éà"), "é\0"); /// ``` fn from(s: S) -> Self { let s = s.as_ref(); - let len = cmp::min(s.len(), A::CAPACITY - 1); + let len = cmp::min(s.len(), CAP - 1); let mut result = Self { inner: ArrayString::from(str_truncate_valid(s, len)).unwrap(), }; @@ -57,7 +57,7 @@ impl, A: Array + Copy> From for ArrayCString { } } -impl + Copy> Deref for ArrayCString { +impl Deref for ArrayCString { type Target = str; fn deref(&self) -> &str { @@ -85,8 +85,8 @@ fn panic_hook(info: &panic::PanicInfo) { // Copy the message and filename to the stack in order to safely add // a terminating nul character (since rust strings don't come with one // and RustMozCrash wants one). - let message = ArrayCString::<[_; 512]>::from(message); - let filename = ArrayCString::<[_; 512]>::from(filename); + let message = ArrayCString::<512>::from(message); + let filename = ArrayCString::<512>::from(filename); unsafe { RustMozCrash( filename.as_ptr() as *const c_char,