Skip to content

Commit

Permalink
Update the version of Rust
Browse files Browse the repository at this point in the history
- Upgrade to Rust `1.58.0`
- Update code to align with the newer coding conventions.
  - Clean up linting and compiler warnings.
- Pin `pip<21.0` and `setuptools<=50.3.2` in `libindy/ci/ubuntu.dockerfile` to resolve build/test issues on ubuntu 16.04.

Signed-off-by: Wade Barnes <wade@neoterictech.ca>
  • Loading branch information
WadeBarnes committed Jan 19, 2022
1 parent 113b79c commit 1cdd4df
Show file tree
Hide file tree
Showing 42 changed files with 35 additions and 201 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile.cd
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def iosTesting() {
//FIXME We downgrade rust for iOS build as 1.46.0 forces building cdylib crate that causes linking errors.
//FIXME See https://github.com/rust-lang/rust/issues/79373 for details.
//FIXME It is fixed in nightly already and we will switch to 1.49 after it is released.
sh "rustup default 1.45.0"
sh "rustup default 1.58.0"

setupRustIOS()
setupBrewPackages()
Expand Down Expand Up @@ -1456,7 +1456,7 @@ def shell(command) {
}

def setupRust() {
shell("rustup default 1.46.0")
shell("rustup default 1.58.0")
}

def androidPublishing() {
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def iosTesting() {
//FIXME We downgrade rust for iOS build as 1.46.0 forces building cdylib crate that causes linking errors.
//FIXME See https://github.com/rust-lang/rust/issues/79373 for details.
//FIXME It is fixed in nightly already and we will switch to 1.49 after it is released.
sh "rustup default 1.45.0"
sh "rustup default 1.58.0"

setupRustIOS()
setupBrewPackages()
Expand Down Expand Up @@ -666,7 +666,7 @@ def shell(command) {
}

def setupRust() {
shell("rustup default 1.46.0")
shell("rustup default 1.58.0")
}

def setupBrewPackages() {
Expand Down
2 changes: 1 addition & 1 deletion ci/ga-ios-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ -z "${LIBINDY_POD_VERSION}" ]; then
fi

if [ -z "${RUST_VER}" ]; then
export RUST_VER=1.45.2
export RUST_VER=1.58.0
echo "ERROR: RUST_VER environment variable not specified, using $RUST_VER"
fi

Expand Down
2 changes: 2 additions & 0 deletions cli/src/command_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ impl ParamMetadata {
}
}

// Turn off "error: field is never read: `dynamic_completion_type`" warning
#[allow(dead_code)]
#[derive(Debug)]
pub struct CommandMetadata {
name: &'static str,
Expand Down
2 changes: 1 addition & 1 deletion cli/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ macro_rules! unwrap_or_return {
match $result {
Some(res) => res,
None => return $err
};
}
}
}
2 changes: 1 addition & 1 deletion libindy/ci/alpine.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM alpine:3.12

ARG UID=1000
ARG GID=1000
ARG RUST_VER="1.45.2"
ARG RUST_VER="1.58.0"
ARG INDYSDK_PATH=/home/indy/indy-sdk

ENV RUST_LOG=warning
Expand Down
2 changes: 1 addition & 1 deletion libindy/ci/centos.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RUN wget https://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-mav
RUN sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
RUN yum install -y apache-maven

ENV RUST_ARCHIVE=rust-1.46.0-x86_64-unknown-linux-gnu.tar.gz
ENV RUST_ARCHIVE=rust-1.58.0-x86_64-unknown-linux-gnu.tar.gz
ENV RUST_DOWNLOAD_URL=https://static.rust-lang.org/dist/$RUST_ARCHIVE

RUN mkdir -p /rust
Expand Down
6 changes: 3 additions & 3 deletions libindy/ci/ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs

RUN pip3 install -U \
pip \
setuptools \
'pip<21.0' \
'setuptools<=50.3.2' \
virtualenv \
twine==1.15.0 \
plumbum==1.6.7 six==1.12.0 \
Expand Down Expand Up @@ -62,7 +62,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN useradd -ms /bin/bash -u $uid indy
USER indy

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.46.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.58.0
ENV PATH /home/indy/.cargo/bin:$PATH

RUN cargo install cargo-deb
Expand Down
2 changes: 1 addition & 1 deletion libindy/ci/ubuntu18.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUN apt-get install -y wget
RUN useradd -ms /bin/bash -u $uid indy
USER indy

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.46.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain 1.58.0
ENV PATH /home/indy/.cargo/bin:$PATH

RUN cargo install cargo-deb
Expand Down
2 changes: 1 addition & 1 deletion libindy/ci/wrappers/wrapper-base.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:18.04

ARG RUST_VER=1.46.0
ARG RUST_VER=1.58.0

RUN apt-get update && \
apt-get install -y \
Expand Down
4 changes: 2 additions & 2 deletions libindy/indy-api-types/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl fmt::Display for IndyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut first = true;

for cause in Fail::iter_chain(self.inner.as_ref()) {
for cause in <dyn Fail>::iter_chain(self.inner.as_ref()) {
if first {
first = false;
writeln!(f, "Error: {}", cause)?;
Expand Down Expand Up @@ -225,7 +225,7 @@ impl From<log::SetLoggerError> for IndyError {
#[cfg(feature = "casting_errors")]
impl From<UrsaCryptoError> for IndyError {
fn from(err: UrsaCryptoError) -> Self {
let message = format!("UrsaCryptoError: {}", Fail::iter_causes(&err).map(|e| e.to_string()).collect::<String>());
let message = format!("UrsaCryptoError: {}", <dyn Fail>::iter_causes(&err).map(|e| e.to_string()).collect::<String>());

match err.kind() {
UrsaCryptoErrorKind::InvalidState => IndyError::from_msg(IndyErrorKind::InvalidState, message),
Expand Down
2 changes: 1 addition & 1 deletion libindy/src/commands/non_secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ impl NonSecretsCommandExecutor {
}
}

#[serde(rename_all = "camelCase")]
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchRecords {
pub total_count: Option<usize>,
pub records: Option<Vec<WalletRecord>>
Expand Down
4 changes: 2 additions & 2 deletions libindy/src/domain/cache.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[serde(rename_all = "camelCase")]
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PurgeOptions {
pub max_age: Option<i32>,
}

#[serde(rename_all = "camelCase")]
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GetCacheOptions {
pub no_cache: Option<bool>, // Skip usage of cache,
pub no_update: Option<bool>, // Use only cached data, do not try to update.
Expand Down
2 changes: 1 addition & 1 deletion libindy/src/domain/ledger/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub struct TxnMetadata {
pub creation_time: u64,
}

#[serde(tag = "op")]
#[derive(Deserialize, Debug)]
#[serde(tag = "op")]
pub enum Message<T> {
#[serde(rename = "REQNACK")]
ReqNACK(Response),
Expand Down
2 changes: 1 addition & 1 deletion libindy/src/services/pool/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ pub struct SimpleRequest {
pub req_id: u64,
}

#[serde(tag = "op")]
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "op")]
pub enum Message {
#[serde(rename = "CONSISTENCY_PROOF")]
ConsistencyProof(ConsistencyProof),
Expand Down
4 changes: 2 additions & 2 deletions libindy/src/utils/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ macro_rules! unwrap_opt_or_return {
match $opt {
Some(val) => val,
None => return $err
};
}
}
}

Expand All @@ -70,6 +70,6 @@ macro_rules! unwrap_or_return {
match $result {
Ok(res) => res,
Err(_) => return $err
};
}
}
}
2 changes: 1 addition & 1 deletion libindy/tests/utils/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ pub struct WalletRecord {
pub tags: Option<HashMap<String, String>>
}

#[serde(rename_all = "camelCase")]
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchRecords {
pub total_count: Option<i32>,
pub records: Option<Vec<WalletRecord>>
Expand Down
1 change: 0 additions & 1 deletion libnullpay/src/libindy/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub fn build_get_txn_request(


extern {
#[no_mangle]
pub fn indy_build_get_txn_request(command_handle: i32,
submitter_did: *const c_char,
ledger_type: *const c_char,
Expand Down
1 change: 0 additions & 1 deletion libnullpay/src/libindy/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ pub fn get_logger() -> Result<(*const c_void, Option<EnabledCB>, Option<LogCB>,
}

extern {
#[no_mangle]
pub fn indy_get_logger(context: *mut *const c_void, enabled_cb_p: *mut Option<EnabledCB>, log_cb_p: *mut Option<LogCB>, flush_cb_p: *mut Option<FlushCB>) -> ErrorCode;
}
2 changes: 0 additions & 2 deletions libnullpay/src/libindy/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ pub fn list_payment_addresses(wallet_handle: i32,
}

extern {
#[no_mangle]
pub fn indy_register_payment_method(
command_handle: i32,
payment_method: *const c_char,
Expand All @@ -182,7 +181,6 @@ extern {
verify_with_address: Option<VerifyWithAddressCB>,
cb: Option<extern fn(command_handle_: i32, err: ErrorCode)>) -> ErrorCode;

#[no_mangle]
fn indy_list_payment_addresses(command_handle: i32,
wallet_handle: i32,
cb: Option<extern fn(command_handle_: i32,
Expand Down
2 changes: 1 addition & 1 deletion vcx/ci/test.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN curl -fsOSL $LIBINDY_DOWNLOAD_URL \
&& apt-get -f install

# Install Rust
ENV RUST_ARCHIVE=rust-1.20.0-x86_64-unknown-linux-gnu.tar.gz
ENV RUST_ARCHIVE=rust-1.58.0-x86_64-unknown-linux-gnu.tar.gz
ENV RUST_DOWNLOAD_URL=https://static.rust-lang.org/dist/$RUST_ARCHIVE

RUN mkdir -p /rust
Expand Down
2 changes: 1 addition & 1 deletion vcx/ci/ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ARG uid=1000
RUN useradd -ms /bin/bash -u $uid vcx
USER vcx

ARG RUST_VER="1.46.0"
ARG RUST_VER="1.58.0"
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUST_VER
ENV PATH /home/vcx/.cargo/bin:$PATH

Expand Down
2 changes: 1 addition & 1 deletion vcx/dummy-cloud-agent/src/domain/a2a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ pub struct SendMessages {
pub uids: Vec<String>,
}

#[serde(untagged)]
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum MessageDetail {
ConnectionRequestRedirect(ConnectionRequestRedirectMessageDetail),
ConnectionRequestAnswer(ConnectionRequestAnswerMessageDetail),
Expand Down
2 changes: 1 addition & 1 deletion vcx/libvcx/build_scripts/ios/mac/mac.01.libindy.setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fi

if [[ $RUSTUP_VERSION =~ ^'rustup ' ]]; then
rustup update
rustup default 1.46.0
rustup default 1.58.0
rustup component add rls-preview rust-analysis rust-src
echo "Using rustc version $(rustc --version)"
rustup target add aarch64-apple-ios x86_64-apple-ios
Expand Down
4 changes: 2 additions & 2 deletions vcx/libvcx/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl fmt::Display for VcxError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut first = true;

for cause in Fail::iter_chain(&self.inner) {
for cause in dyn Fail::iter_chain(&self.inner) {
if first {
first = false;
writeln!(f, "Error: {}", cause)?;
Expand Down Expand Up @@ -426,7 +426,7 @@ pub fn set_current_error(err: &VcxError) {
let error_json = json!({
"error": err.kind().to_string(),
"message": err.to_string(),
"cause": Fail::find_root_cause(err).to_string(),
"cause": dyn Fail::find_root_cause(err).to_string(),
"backtrace": err.backtrace().map(|bt| bt.to_string())
}).to_string();
error.replace(Some(CStringUtils::string_to_cstring(error_json)));
Expand Down
2 changes: 1 addition & 1 deletion vcx/libvcx/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ pub struct MessageSent {
pub uids: Vec<String>,
}

#[serde(untagged)]
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum MessageDetail {
ConnectionRequestAnswer(AcceptInviteMessageDetails),
ConnectionRequestRedirect(RedirectConnectionMessageDetails),
Expand Down
2 changes: 1 addition & 1 deletion vcx/libvcx/src/utils/libindy/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ pub struct Request {
pub endorser: Option<String>
}

#[serde(tag = "op")]
#[derive(Deserialize, Debug)]
#[serde(tag = "op")]
pub enum Response {
#[serde(rename = "REQNACK")]
ReqNACK(Reject),
Expand Down
4 changes: 2 additions & 2 deletions wrappers/rust/indy-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ fn find_dir(dir_name: Option<String>, use_static: bool) {
fn find_pkg(use_static: bool) {
match pkg_config::Config::new().statik(use_static).probe("libindy") {
Ok(_) => println!("cargo:warning=Libindy found in pkgcfg tree."),
Err(e) => panic!(format!("Error: {:?}", e)),
Err(e) => panic!("Error: {:?}", e),
}
}

#[cfg(target_env = "msvc")]
fn find_pkg(_use_static: bool) {
match vcpkg::Config::new().emit_includes(true).lib_name("libindy").probe("indy") {
Ok(_) => println!("cargo:warning=Libindy found in vcpkg tree."),
Err(e) => panic!(format!("Error: {:?}", e)),
Err(e) => panic!("Error: {:?}", e),
}
}
Loading

0 comments on commit 1cdd4df

Please sign in to comment.