From a698a8dd84ec43c22b47f3ac146ed869dfae56f0 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 28 Feb 2021 18:36:00 +0300 Subject: [PATCH] Update to Rust 1.50 Also run rustfmt, fix new clippy warnings. --- .github/workflows/ci.yml | 6 +-- CHANGELOG.md | 2 +- ci_scripts/docker-coredeps/deps/build_rust.sh | 4 +- rust-toolchain | 2 +- src/constants.rs | 16 ++++++-- src/html.rs | 39 ++++++++----------- src/job.rs | 4 +- src/lot.rs | 8 +++- src/mimeparser.rs | 4 +- src/securejoin/bobstate.rs | 6 ++- src/token.rs | 4 +- 11 files changed, 54 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf2e80b22..a1620a43c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.49.0 + toolchain: 1.50.0 override: true - run: rustup component add rustfmt - uses: actions-rs/cargo@v1 @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.49.0 + toolchain: 1.50.0 components: clippy override: true - uses: actions-rs/clippy-check@v1 @@ -72,7 +72,7 @@ jobs: # macOS disabled due to random failures related to caching #os: [ubuntu-latest, windows-latest, macOS-latest] os: [ubuntu-latest, windows-latest] - rust: [1.49.0] + rust: [1.50.0] experimental: [false] # include: # - os: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8d5d2e1..d3e9081cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,7 +96,7 @@ - try harder on backup opening #2148 -- switch to rust 1.49, update toolchains, deps #2150 #2155 #2165 #2107 +- switch to rust 1.50, update toolchains, deps #2150 #2155 #2165 #2107 #2262 #2271 - improve python bindings #2113 #2115 #2133 #2214 diff --git a/ci_scripts/docker-coredeps/deps/build_rust.sh b/ci_scripts/docker-coredeps/deps/build_rust.sh index 0e40bb1a1..e9d285afa 100755 --- a/ci_scripts/docker-coredeps/deps/build_rust.sh +++ b/ci_scripts/docker-coredeps/deps/build_rust.sh @@ -3,9 +3,9 @@ set -e -x # Install Rust -curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.49.0-x86_64-unknown-linux-gnu -y +curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.50.0-x86_64-unknown-linux-gnu -y export PATH=/root/.cargo/bin:$PATH rustc --version # remove some 300-400 MB that we don't need for automated builds -rm -rf /root/.rustup/toolchains/1.49.0-x86_64-unknown-linux-gnu/share +rm -rf /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-gnu/share diff --git a/rust-toolchain b/rust-toolchain index 7f3a46a84..5a5c7211d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.49.0 +1.50.0 diff --git a/src/constants.rs b/src/constants.rs index 52019567c..11d1953bd 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -32,7 +32,9 @@ impl Default for Blocked { } } -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, +)] #[repr(u8)] pub enum ShowEmails { Off = 0, @@ -46,7 +48,9 @@ impl Default for ShowEmails { } } -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, +)] #[repr(u8)] pub enum MediaQuality { Balanced = 0, @@ -59,7 +63,9 @@ impl Default for MediaQuality { } } -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, +)] #[repr(u8)] pub enum KeyGenType { Default = 0, @@ -73,7 +79,9 @@ impl Default for KeyGenType { } } -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, +)] #[repr(i8)] pub enum VideochatType { Unknown = 0, diff --git a/src/html.rs b/src/html.rs index 4f8999801..1379f10eb 100644 --- a/src/html.rs +++ b/src/html.rs @@ -420,23 +420,16 @@ test some special html-characters as < > and & but also " and &#x let t = TestContext::new().await; let raw = include_bytes!("../test-data/message/apple_cid_jpg.eml"); let test = String::from_utf8_lossy(raw); - assert!(test - .find("Content-Id: <8AE052EF-BC90-486F-BB78-58D3590308EC@fritz.box>") - .is_some()); - assert!(test - .find("cid:8AE052EF-BC90-486F-BB78-58D3590308EC@fritz.box") - .is_some()); + assert!(test.contains("Content-Id: <8AE052EF-BC90-486F-BB78-58D3590308EC@fritz.box>")); + assert!(test.contains("cid:8AE052EF-BC90-486F-BB78-58D3590308EC@fritz.box")); assert!(test.find("data:").is_none()); // parsing converts cid: to data: let parser = HtmlMsgParser::from_bytes(&t.ctx, raw).await.unwrap(); - assert!(parser.html.find("").is_some()); - assert!(parser.html.find("Content-Id:").is_none()); - assert!(parser - .html - .find("data:image/jpeg;base64,/9j/4AAQ") - .is_some()); - assert!(parser.html.find("cid:").is_none()); + assert!(parser.html.contains("")); + assert!(!parser.html.contains("Content-Id:")); + assert!(parser.html.contains("data:image/jpeg;base64,/9j/4AAQ")); + assert!(!parser.html.contains("cid:")); } #[async_std::test] @@ -462,10 +455,10 @@ test some special html-characters as < > and & but also " and &#x assert_ne!(msg.get_from_id(), DC_CONTACT_ID_SELF); assert_eq!(msg.is_dc_message, MessengerMessage::No); assert!(!msg.is_forwarded()); - assert!(msg.get_text().unwrap().find("this is plain").is_some()); + assert!(msg.get_text().unwrap().contains("this is plain")); assert!(msg.has_html()); let html = msg.get_id().get_html(&alice).await.unwrap(); - assert!(html.find("this is html").is_some()); + assert!(html.contains("this is html")); // alice: create chat with bob and forward received html-message there let chat = alice.create_chat_with_contact("", "bob@example.net").await; @@ -476,10 +469,10 @@ test some special html-characters as < > and & but also " and &#x assert_eq!(msg.get_from_id(), DC_CONTACT_ID_SELF); assert_eq!(msg.is_dc_message, MessengerMessage::Yes); assert!(msg.is_forwarded()); - assert!(msg.get_text().unwrap().find("this is plain").is_some()); + assert!(msg.get_text().unwrap().contains("this is plain")); assert!(msg.has_html()); let html = msg.get_id().get_html(&alice).await.unwrap(); - assert!(html.find("this is html").is_some()); + assert!(html.contains("this is html")); // bob: check that bob also got the html-part of the forwarded message let bob = TestContext::new_bob().await; @@ -489,10 +482,10 @@ test some special html-characters as < > and & but also " and &#x assert_ne!(msg.get_from_id(), DC_CONTACT_ID_SELF); assert_eq!(msg.is_dc_message, MessengerMessage::Yes); assert!(msg.is_forwarded()); - assert!(msg.get_text().unwrap().find("this is plain").is_some()); + assert!(msg.get_text().unwrap().contains("this is plain")); assert!(msg.has_html()); let html = msg.get_id().get_html(&bob).await.unwrap(); - assert!(html.find("this is html").is_some()); + assert!(html.contains("this is html")); } #[async_std::test] @@ -529,10 +522,10 @@ test some special html-characters as < > and & but also " and &#x assert_eq!(msg.is_dc_message, MessengerMessage::Yes); assert!(msg.get_showpadlock()); assert!(msg.is_forwarded()); - assert!(msg.get_text().unwrap().find("this is plain").is_some()); + assert!(msg.get_text().unwrap().contains("this is plain")); assert!(msg.has_html()); let html = msg.get_id().get_html(&alice).await.unwrap(); - assert!(html.find("this is html").is_some()); + assert!(html.contains("this is html")); } #[async_std::test] @@ -554,7 +547,7 @@ test some special html-characters as < > and & but also " and &#x assert!(!msg.is_forwarded()); assert!(msg.mime_modified); let html = msg.get_id().get_html(&alice).await.unwrap(); - assert!(html.find("html text").is_some()); + assert!(html.contains("html text")); // let bob receive the message let chat_id = bob.create_chat(&alice).await.id; @@ -564,6 +557,6 @@ test some special html-characters as < > and & but also " and &#x assert!(!msg.is_forwarded()); assert!(msg.mime_modified); let html = msg.get_id().get_html(&bob).await.unwrap(); - assert!(html.find("html text").is_some()); + assert!(html.contains("html text")); } } diff --git a/src/job.rs b/src/job.rs index 86ae59f4b..3efaef58e 100644 --- a/src/job.rs +++ b/src/job.rs @@ -35,7 +35,9 @@ use crate::{scheduler::InterruptInfo, sql}; const JOB_RETRIES: u32 = 17; /// Thread IDs -#[derive(Debug, Display, Copy, Clone, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)] +#[derive( + Debug, Display, Copy, Clone, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, +)] #[repr(i32)] pub(crate) enum Thread { Unknown = 0, diff --git a/src/lot.rs b/src/lot.rs index 3a069e473..7868eea6c 100644 --- a/src/lot.rs +++ b/src/lot.rs @@ -22,7 +22,9 @@ pub struct Lot { } #[repr(u8)] -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql, +)] pub enum Meaning { None = 0, Text1Draft = 1, @@ -67,7 +69,9 @@ impl Lot { } #[repr(i32)] -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql, +)] pub enum LotState { // Default Undefined = 0, diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 77bf86ddb..32ae838ba 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -103,7 +103,9 @@ pub(crate) enum MailinglistType { None, } -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql, +)] #[repr(i32)] pub enum SystemMessage { Unknown = 0, diff --git a/src/securejoin/bobstate.rs b/src/securejoin/bobstate.rs index e0dcc970a..49be4f53b 100644 --- a/src/securejoin/bobstate.rs +++ b/src/securejoin/bobstate.rs @@ -93,8 +93,10 @@ impl<'a> BobStateHandle<'a> { info!(context, "Handling securejoin message for BobStateHandle"); match self.bobstate.handle_message(context, mime_message).await { Ok(Some(stage)) => { - if matches!(stage, BobHandshakeStage::Completed | BobHandshakeStage::Terminated(_)) - { + if matches!( + stage, + BobHandshakeStage::Completed | BobHandshakeStage::Terminated(_) + ) { self.finish_protocol(context).await; } Some(stage) diff --git a/src/token.rs b/src/token.rs index 29716c16c..af4b2df98 100644 --- a/src/token.rs +++ b/src/token.rs @@ -11,7 +11,9 @@ use crate::context::Context; use crate::dc_tools::{dc_create_id, time}; /// Token namespace -#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql)] +#[derive( + Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, ToSql, FromSql, +)] #[repr(i32)] pub enum Namespace { Unknown = 0,