Skip to content

Commit

Permalink
[rust] update to 1.47.0 and cargo to nightly-2020-10-09
Browse files Browse the repository at this point in the history
Closes: diem#6693
  • Loading branch information
rexhoffman authored and bors-libra committed Nov 16, 2020
1 parent 5cbd9be commit afcfddf
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 127 deletions.
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cargo-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2020-07-08
nightly-2020-10-09
2 changes: 1 addition & 1 deletion common/proptest-helpers/src/unit_tests/repeat_vec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ where

fn remove_all(&mut self, logical_indexes: impl IntoIterator<Item = usize>) {
let mut logical_indexes: Vec<_> = logical_indexes.into_iter().collect();
logical_indexes.sort();
logical_indexes.sort_unstable();
logical_indexes.dedup();

let new_items = {
Expand Down
6 changes: 3 additions & 3 deletions config/management/operational/src/validator_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,15 @@ pub fn strip_address(address: &NetworkAddress) -> NetworkAddress {
let protocols = address
.as_slice()
.iter()
.filter(|protocol| match protocol {
.filter(|protocol| {
matches!(protocol,
Protocol::Dns(_)
| Protocol::Dns4(_)
| Protocol::Dns6(_)
| Protocol::Ip4(_)
| Protocol::Ip6(_)
| Protocol::Memory(_)
| Protocol::Tcp(_) => true,
_ => false,
| Protocol::Tcp(_))
})
.cloned()
.collect::<Vec<_>>();
Expand Down
2 changes: 1 addition & 1 deletion consensus/safety-rules/src/safety_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl SafetyRules {

if let Some(public_key) = self.execution_public_key.as_ref() {
execution_signature
.ok_or_else(|| Error::VoteProposalSignatureNotFound)?
.ok_or(Error::VoteProposalSignatureNotFound)?
.verify(vote_proposal, public_key)
.map_err(|error| Error::InternalError(error.to_string()))?;
}
Expand Down
15 changes: 3 additions & 12 deletions language/compiler/ir-to-bytecode/syntax/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,20 +361,14 @@ fn get_name_len(text: &str) -> usize {
return 0;
}
text.chars()
.position(|c| match c {
'a'..='z' | 'A'..='Z' | '$' | '_' | '0'..='9' => false,
_ => true,
})
.position(|c| !matches!(c, 'a'..='z' | 'A'..='Z' | '$' | '_' | '0'..='9'))
.unwrap_or_else(|| text.len())
}

fn get_decimal_number(text: &str) -> (Tok, usize) {
let len = text
.chars()
.position(|c| match c {
'0'..='9' => false,
_ => true,
})
.position(|c| !matches!(c, '0'..='9'))
.unwrap_or_else(|| text.len());
let rest = &text[len..];
if rest.starts_with("u8") {
Expand All @@ -391,10 +385,7 @@ fn get_decimal_number(text: &str) -> (Tok, usize) {
// Return the length of the substring containing characters in [0-9a-fA-F].
fn get_hex_digits_len(text: &str) -> usize {
text.chars()
.position(|c| match c {
'a'..='f' | 'A'..='F' | '0'..='9' => false,
_ => true,
})
.position(|c| !matches!(c, 'a'..='f' | 'A'..='F' | '0'..='9'))
.unwrap_or_else(|| text.len())
}

Expand Down
5 changes: 1 addition & 4 deletions language/compiler/src/unit_tests/testutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ macro_rules! instr_count {
.code
.code
.iter()
.filter(|ins| match ins {
$instr => true,
_ => false,
})
.filter(|ins| matches!(ins, $instr))
.count();
};
}
Expand Down
5 changes: 1 addition & 4 deletions language/move-core/types/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ enum Token {

impl Token {
fn is_whitespace(&self) -> bool {
match self {
Self::Whitespace(_) => true,
_ => false,
}
matches!(self, Self::Whitespace(_))
}
}

Expand Down
24 changes: 9 additions & 15 deletions language/move-lang/src/cfgir/constant_fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,15 @@ fn optimize_exp(e: &mut Exp) -> bool {
E::ModuleCall(mcall) => optimize_exp(&mut mcall.arguments),
E::Builtin(_, e) | E::Freeze(e) | E::Dereference(e) | E::Borrow(_, e, _) => optimize_exp(e),

E::Pack(_, _, fields) => {
let results = fields
.iter_mut()
.map(|(_, _, e)| optimize_exp(e))
.collect::<Vec<_>>();
results.into_iter().any(|changed| changed)
}

E::ExpList(es) => {
let results = es
.iter_mut()
.map(|item| optimize_exp_item(item))
.collect::<Vec<_>>();
results.into_iter().any(|changed| changed)
}
E::Pack(_, _, fields) => fields
.iter_mut()
.map(|(_, _, e)| optimize_exp(e))
.any(|changed| changed),

E::ExpList(es) => es
.iter_mut()
.map(|item| optimize_exp_item(item))
.any(|changed| changed),

//************************************
// Foldable cases
Expand Down
2 changes: 2 additions & 0 deletions language/move-lang/src/cfgir/inline_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ fn find_single_target_labels(start: Label, blocks: &BasicBlocks) -> BTreeSet<Lab
.collect()
}

#[allow(clippy::needless_collect)]
fn inline_single_target_blocks(
single_jump_targets: &BTreeSet<Label>,
start: Label,
blocks: &mut BasicBlocks,
) -> bool {
//cleanup of needless_collect would result in mut and non mut borrows, and compilation warning.
let labels_vec = blocks.keys().cloned().collect::<Vec<_>>();
let mut labels = labels_vec.into_iter();
let mut next = labels.next();
Expand Down
8 changes: 4 additions & 4 deletions language/move-lang/src/hlir/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ impl Exp {

impl UnannotatedExp_ {
pub fn is_unit(&self) -> bool {
match self {
matches!(
self,
UnannotatedExp_::Unit {
trailing: _trailing,
} => true,
_ => false,
}
}
)
}
}

Expand Down
17 changes: 4 additions & 13 deletions language/move-lang/src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,20 +428,14 @@ fn find_token(file: &'static str, text: &str, start_offset: usize) -> Result<(To
// checks on the first character.
fn get_name_len(text: &str) -> usize {
text.chars()
.position(|c| match c {
'a'..='z' | 'A'..='Z' | '_' | '0'..='9' => false,
_ => true,
})
.position(|c| !matches!(c, 'a'..='z' | 'A'..='Z' | '_' | '0'..='9'))
.unwrap_or_else(|| text.len())
}

fn get_decimal_number(text: &str) -> (Tok, usize) {
let len = text
.chars()
.position(|c| match c {
'0'..='9' => false,
_ => true,
})
.position(|c| !matches!(c, '0'..='9'))
.unwrap_or_else(|| text.len());
let rest = &text[len..];
if rest.starts_with("u8") {
Expand All @@ -457,11 +451,8 @@ fn get_decimal_number(text: &str) -> (Tok, usize) {

// Return the length of the substring containing characters in [0-9a-fA-F].
fn get_hex_digits_len(text: &str) -> usize {
text.find(|c| match c {
'a'..='f' | 'A'..='F' | '0'..='9' => false,
_ => true,
})
.unwrap_or_else(|| text.len())
text.find(|c| !matches!(c, 'a'..='f' | 'A'..='F' | '0'..='9'))
.unwrap_or_else(|| text.len())
}

// Return the length of the quoted string, or None if there is no closing quote.
Expand Down
4 changes: 1 addition & 3 deletions language/move-lang/src/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ impl Address {
let len = result.len();
if len < ADDRESS_LENGTH {
result.reverse();
for _ in len..ADDRESS_LENGTH {
result.push(0);
}
result.resize(ADDRESS_LENGTH, 0);
result.reverse();
}

Expand Down
6 changes: 2 additions & 4 deletions language/move-lang/src/typing/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,10 +1168,8 @@ fn exp_inner(context: &mut Context, sp!(eloc, ne_): N::Exp) -> T::Exp {
}

NE::DerefBorrow(ndotted) => {
assert!(match ndotted {
sp!(_, N::ExpDotted_::Exp(_)) => false,
_ => true,
});
assert!(!matches!(ndotted, sp!(_, N::ExpDotted_::Exp(_))));

let (edotted, inner_ty) = exp_dotted(context, "dot access", ndotted);
let ederefborrow = exp_dotted_to_owned_value(context, eloc, edotted, inner_ty);
(ederefborrow.ty, ederefborrow.exp.value)
Expand Down
2 changes: 1 addition & 1 deletion language/move-prover/spec-lang/src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4235,7 +4235,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo
}
EA::Exp_::Call(maccess, type_params, args) => {
// Need to make a &[&Exp] out of args.
let args = args.value.iter().map(|e| e).collect_vec();
let args = args.value.iter().collect_vec();
self.translate_fun_call(
expected_type,
&loc,
Expand Down
14 changes: 7 additions & 7 deletions language/vm/src/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1774,14 +1774,14 @@ impl CompiledModule {

/// Returns the number of items of a specific `IndexKind`.
pub fn kind_count(&self, kind: IndexKind) -> usize {
precondition!(match kind {
precondition!(!matches!(
kind,
IndexKind::LocalPool
| IndexKind::CodeDefinition
| IndexKind::FieldDefinition
| IndexKind::TypeParameter
| IndexKind::MemberCount => false,
_ => true,
});
| IndexKind::CodeDefinition
| IndexKind::FieldDefinition
| IndexKind::TypeParameter
| IndexKind::MemberCount
));
self.as_inner().kind_count(kind)
}

Expand Down
1 change: 1 addition & 0 deletions language/vm/src/unit_tests/deserializer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
use move_core_types::vm_status::StatusCode;

#[test]
#[allow(clippy::same_item_push)]
fn malformed_simple() {
// empty binary
let mut binary = vec![];
Expand Down
Loading

0 comments on commit afcfddf

Please sign in to comment.