Merge pull request #365 from str4d/rust-1.51

Bump MSRV to Rust 1.51.0
This commit is contained in:
str4d 2021-03-27 09:41:50 +13:00 committed by GitHub
commit de87dcfbcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 85 additions and 60 deletions

View File

@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0
toolchain: 1.51.0
override: true
- name: Fetch path to Zcash parameters
@ -56,7 +56,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0
toolchain: 1.51.0
override: true
- name: Add target
run: rustup target add ${{ matrix.target }}
@ -79,7 +79,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0
toolchain: 1.51.0
override: true
# Build benchmarks to prevent bitrot
- name: Build benchmarks
@ -89,20 +89,20 @@ jobs:
args: --all --benches
clippy:
name: Clippy (1.47.0)
name: Clippy (1.51.0)
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0
toolchain: 1.51.0
components: clippy
override: true
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
name: Clippy (1.47.0)
name: Clippy (1.51.0)
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --all-targets -- -D warnings
@ -176,7 +176,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: 1.51.0
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
@ -199,7 +199,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.47.0
toolchain: 1.51.0
override: true
# cargo fmt does not build the code, and running it in a fresh clone of

View File

@ -17,6 +17,9 @@
//! [Section 7.6.1: Equihash.]: https://zips.z.cash/protocol/protocol.pdf#equihash
//! [BK16]: https://www.internetsociety.org/sites/default/files/blogs-media/equihash-asymmetric-proof-of-work-based-generalized-birthday-problem.pdf
// Catch documentation errors caused by code changes.
#![deny(broken_intra_doc_links)]
mod verify;
#[cfg(test)]

View File

@ -1 +1 @@
1.47.0
1.51.0

View File

@ -6,6 +6,8 @@ and this library adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- MSRV is now 1.51.0.
## [0.5.0] - 2021-03-26
### Added

View File

@ -4,7 +4,7 @@
//! light clients.
// Catch documentation errors caused by code changes.
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]
pub mod address;
pub mod data_api;

View File

@ -138,10 +138,10 @@ impl TransactionRequest {
///
/// Returns None if the payment request is empty.
pub fn to_uri<P: consensus::Parameters>(&self, params: &P) -> Option<String> {
fn payment_params<'a>(
payment: &'a Payment,
fn payment_params(
payment: &Payment,
payment_index: Option<usize>,
) -> impl IntoIterator<Item = String> + 'a {
) -> impl IntoIterator<Item = String> + '_ {
std::iter::empty()
.chain(render::amount_param(payment.amount, payment_index))
.chain(
@ -447,31 +447,34 @@ mod parse {
}
/// Parses and consumes the leading "zcash:\[address\]" from a ZIP 321 URI.
pub fn lead_addr<'a, P: consensus::Parameters>(
params: &'a P,
) -> impl Fn(&str) -> IResult<&str, Option<IndexedParam>> + 'a {
pub fn lead_addr<P: consensus::Parameters>(
params: &P,
) -> impl Fn(&str) -> IResult<&str, Option<IndexedParam>> + '_ {
move |input: &str| {
map_opt(preceded(tag("zcash:"), take_until("?")), |addr_str| {
if addr_str == "" {
Some(None) // no address is ok, so wrap in `Some`
} else {
// `decode` returns `None` on error, which we want to
// then cause `map_opt` to fail.
RecipientAddress::decode(params, addr_str).map(|a| {
Some(IndexedParam {
param: Param::Addr(a),
payment_index: 0,
map_opt(
preceded(tag("zcash:"), take_until("?")),
|addr_str: &str| {
if addr_str.is_empty() {
Some(None) // no address is ok, so wrap in `Some`
} else {
// `decode` returns `None` on error, which we want to
// then cause `map_opt` to fail.
RecipientAddress::decode(params, addr_str).map(|a| {
Some(IndexedParam {
param: Param::Addr(a),
payment_index: 0,
})
})
})
}
})(input)
}
},
)(input)
}
}
/// The primary parser for <name>=<value> query-string parameter pair.
pub fn zcashparam<'a, P: consensus::Parameters>(
params: &'a P,
) -> impl Fn(&str) -> IResult<&str, IndexedParam> + 'a {
pub fn zcashparam<P: consensus::Parameters>(
params: &P,
) -> impl Fn(&str) -> IResult<&str, IndexedParam> + '_ {
move |input| {
map_res(
separated_pair(indexed_name, char('='), recognize(qchars)),
@ -519,7 +522,7 @@ mod parse {
}
/// Parses a value in decimal ZEC.
pub fn parse_amount<'a>(input: &'a str) -> IResult<&'a str, Amount> {
pub fn parse_amount(input: &str) -> IResult<&str, Amount> {
map_res(
tuple((
digit1,
@ -583,7 +586,7 @@ mod parse {
.map_err(|e| e.to_string()),
"memo" => memo_from_base64(value)
.map(|m| Param::Memo(m))
.map(Param::Memo)
.map_err(|e| format!("Decoded memo was invalid: {:?}", e)),
other if other.starts_with("req-") => {

View File

@ -6,6 +6,8 @@ and this library adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- MSRV is now 1.51.0.
## [0.3.0] - 2021-03-26
This release contains a major refactor of the APIs to leverage the new Data

View File

@ -29,6 +29,9 @@
//! [`CompactBlock`]: zcash_client_backend::proto::compact_formats::CompactBlock
//! [`init_cache_database`]: crate::chain::init::init_cache_database
// Catch documentation errors caused by code changes.
#![deny(broken_intra_doc_links)]
use std::collections::HashMap;
use std::fmt;
use std::path::Path;

View File

@ -758,8 +758,8 @@ pub fn insert_witness<'a, P>(
}
/// Removes old incremental witnesses up to the given block height.
pub fn prune_witnesses<'a, P>(
stmts: &mut DataConnStmtCache<'a, P>,
pub fn prune_witnesses<P>(
stmts: &mut DataConnStmtCache<'_, P>,
below_height: BlockHeight,
) -> Result<(), SqliteClientError> {
stmts
@ -770,8 +770,8 @@ pub fn prune_witnesses<'a, P>(
/// Marks notes that have not been mined in transactions
/// as expired, up to the given block height.
pub fn update_expired_notes<'a, P>(
stmts: &mut DataConnStmtCache<'a, P>,
pub fn update_expired_notes<P>(
stmts: &mut DataConnStmtCache<'_, P>,
height: BlockHeight,
) -> Result<(), SqliteClientError> {
stmts.stmt_update_expired.execute(&[u32::from(height)])?;

View File

@ -1,2 +1,5 @@
// Catch documentation errors caused by code changes.
#![deny(broken_intra_doc_links)]
pub mod consensus;
pub mod transparent;

View File

@ -1,6 +1,9 @@
//! Chain history library for Zcash
//!
//! To be used in zebra and via FFI bindings in zcashd
// Catch documentation errors caused by code changes.
#![deny(broken_intra_doc_links)]
#![warn(missing_docs)]
mod entry;

View File

@ -155,8 +155,10 @@ impl NodeData {
/// Read from the byte representation.
pub fn read<R: std::io::Read>(consensus_branch_id: u32, r: &mut R) -> std::io::Result<Self> {
let mut data = Self::default();
data.consensus_branch_id = consensus_branch_id;
let mut data = NodeData {
consensus_branch_id,
..Default::default()
};
r.read_exact(&mut data.subtree_commitment)?;
data.start_time = r.read_u32::<LittleEndian>()?;
data.end_time = r.read_u32::<LittleEndian>()?;

View File

@ -138,14 +138,12 @@ impl Tree {
pub fn append_leaf(&mut self, new_leaf: NodeData) -> Result<Vec<EntryLink>, Error> {
let root = self.root;
let new_leaf_link = self.push(new_leaf.into());
let mut appended = Vec::new();
appended.push(new_leaf_link);
let mut appended = vec![new_leaf_link];
let mut peaks = Vec::new();
self.get_peaks(root, &mut peaks)?;
let mut merge_stack = Vec::new();
merge_stack.push(new_leaf_link);
let mut merge_stack = vec![new_leaf_link];
// Scan the peaks right-to-left, merging together equal-sized adjacent
// complete subtrees. After this, merge_stack only contains peaks of

View File

@ -6,6 +6,8 @@ and this library adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- MSRV is now 1.51.0.
## [0.5.0] - 2021-03-26
### Added

View File

@ -5,7 +5,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
// Catch documentation errors caused by code changes.
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]
pub mod block;
pub mod consensus;

View File

@ -6,6 +6,8 @@ and this library adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- MSRV is now 1.51.0.
## [0.5.0] - 2021-03-26
### Added

View File

@ -19,15 +19,16 @@ where
assert_eq!(rho.len(), 256);
assert_eq!(r.len(), 256);
let mut image = vec![];
image.push(Boolean::constant(true));
image.push(Boolean::constant(false));
image.push(Boolean::constant(true));
image.push(Boolean::constant(true));
image.push(Boolean::constant(false));
image.push(Boolean::constant(false));
image.push(Boolean::constant(false));
image.push(Boolean::constant(false));
let mut image = vec![
Boolean::constant(true),
Boolean::constant(false),
Boolean::constant(true),
Boolean::constant(true),
Boolean::constant(false),
Boolean::constant(false),
Boolean::constant(false),
Boolean::constant(false),
];
image.extend(a_pk.iter().cloned());
image.extend(value.iter().cloned());
image.extend(rho.iter().cloned());

View File

@ -20,11 +20,12 @@ where
assert_eq!(x.len(), 252);
assert_eq!(y.len(), 256);
let mut image = vec![];
image.push(Boolean::constant(a));
image.push(Boolean::constant(b));
image.push(Boolean::constant(c));
image.push(Boolean::constant(d));
let mut image = vec![
Boolean::constant(a),
Boolean::constant(b),
Boolean::constant(c),
Boolean::constant(d),
];
image.extend(x.iter().cloned());
image.extend(y.iter().cloned());

View File

@ -5,7 +5,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
// Catch documentation errors caused by code changes.
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]
use bellman::groth16::{prepare_verifying_key, Parameters, PreparedVerifyingKey, VerifyingKey};
use bls12_381::Bls12;