Skip to content

Commit

Permalink
chore: rust version update (#5405)
Browse files Browse the repository at this point in the history
* chore: update rust toolchain to latest release

The rust build-image is failing because it has too old a rust
version:

    package `anstyle v0.3.5` cannot be built because it requires
    rustc 1.64.0 or newer, while the currently active rustc version
    is 1.63.

Update the build chain to the latest version.

* chore: fix-ups suggested by clippy

After updating the rust toolchain clippy had a number of suggestions
to improve the code. These suggestions have been applied.

* chore: make generate

* chore: more clippy errors

* chore: make generate

* chore: more clippy issues

* chore: make generate
  • Loading branch information
mhilton authored Apr 5, 2023
1 parent f83a24a commit 6dc8054
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 45 deletions.
2 changes: 1 addition & 1 deletion libflux/flux-core/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl Database {
Error::Message(format!("Unable to read path `{}`: {}", package, err))
})?
.path();
let path = path.strip_prefix(&filesystem_root).map_err(|err| {
let path = path.strip_prefix(filesystem_root).map_err(|err| {
Error::Message(format!(
"Unable to strip prefix `{}` of `{}`: {}",
filesystem_root.display(),
Expand Down
4 changes: 2 additions & 2 deletions libflux/flux-core/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ impl<'input> Parser<'input> {
};
}

match (&t.lit).parse::<i64>() {
match t.lit.parse::<i64>() {
Err(_e) => {
self.errs.push(format!(
"invalid integer literal \"{}\": value out of range",
Expand All @@ -1714,7 +1714,7 @@ impl<'input> Parser<'input> {
fn parse_float_literal(&mut self) -> Result<FloatLit, TokenError> {
let t = self.expect(TokenType::Float);

let value = (&t.lit).parse::<f64>();
let value = t.lit.parse::<f64>();

match value {
Ok(value) => Ok(FloatLit {
Expand Down
6 changes: 1 addition & 5 deletions libflux/flux-core/src/parser/strconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ pub fn parse_text(lit: &str) -> Result<String, String> {
let mut chars = lit.chars();
while let Some(c) = chars.next() {
match c {
'\\' => {
if let Err(e) = push_unescaped_string(&mut s, &mut chars) {
return Err(e);
}
}
'\\' => push_unescaped_string(&mut s, &mut chars)?,
// this char can have any byte length
_ => s.extend_from_slice(c.to_string().as_bytes()),
}
Expand Down
4 changes: 2 additions & 2 deletions libflux/flux-core/src/scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ impl<'a> Scanner<'a> {
end_offset: data_len,
start_pos: Position {
line: self.cur_line as u32,
column: column as u32,
column,
},
end_pos: Position {
line: self.cur_line as u32,
column: column as u32,
column,
},
comments: vec![],
}
Expand Down
8 changes: 4 additions & 4 deletions libflux/flux-core/src/semantic/flatbuffers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub fn build_sem_packages<'a>(
sem_pkgs: crate::semantic::bootstrap::SemanticPackageMap,
) -> flatbuffers::WIPOffset<fbsemantic::PackageList<'a>> {
let packages: Vec<_> = sem_pkgs
.into_iter()
.map(|(_, pkg)| serialize_pkg_into(&pkg, builder).unwrap())
.into_values()
.map(|pkg| serialize_pkg_into(&pkg, builder).unwrap())
.collect::<Vec<_>>();
let packages = builder.create_vector(packages.as_slice());

Expand Down Expand Up @@ -53,9 +53,9 @@ pub fn serialize_pkg_into<'a>(
}

/// Serializes a [`semantic::nodes::Package`] into an existing builder.
fn serialize<'a, 'b>(
fn serialize<'a>(
semantic_pkg: &semantic::nodes::Package,
builder: &'b mut flatbuffers::FlatBufferBuilder<'a>,
builder: &mut flatbuffers::FlatBufferBuilder<'a>,
) -> Result<flatbuffers::WIPOffset<fbsemantic::Package<'a>>> {
let mut v = SerializingVisitor::with_builder(builder);
walk::walk(&mut v, walk::Node::Package(semantic_pkg));
Expand Down
4 changes: 2 additions & 2 deletions libflux/flux-core/src/semantic/flatbuffers/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ impl From<fb::Argument<'_>> for Option<(String, MonoType, bool, bool)> {
}
}

pub fn finish_serialize<'a, 'b, S>(
builder: &'a mut flatbuffers::FlatBufferBuilder<'b>,
pub fn finish_serialize<'a, S>(
builder: &'a mut flatbuffers::FlatBufferBuilder<'_>,
offset: flatbuffers::WIPOffset<S>,
) -> &'a [u8] {
builder.finish(offset, None);
Expand Down
16 changes: 8 additions & 8 deletions libflux/flux-core/src/semantic/formatter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ impl Formatter {
}

fn write_string(&mut self, s: &str) {
(&mut self.builder).push_str(s);
self.builder.push_str(s);
}

fn write_rune(&mut self, c: char) {
(&mut self.builder).push(c);
self.builder.push(c);
}

fn write_indent(&mut self) {
for _ in 0..self.indentation {
(&mut self.builder).push_str(INDENT_BYTES);
self.builder.push_str(INDENT_BYTES);
}
}
fn indent(&mut self) {
Expand Down Expand Up @@ -222,7 +222,7 @@ impl Formatter {
true => ",\n",
false => ", ",
};
for (i, c) in (&n.vars).iter().enumerate() {
for (i, c) in n.vars.iter().enumerate() {
if i != 0 {
self.write_string(sep);
if multiline {
Expand Down Expand Up @@ -325,7 +325,7 @@ impl Formatter {
true => ",\n",
false => ", ",
};
for (i, item) in (&n.elements).iter().enumerate() {
for (i, item) in n.elements.iter().enumerate() {
if i != 0 {
self.write_string(sep);
if multiline {
Expand Down Expand Up @@ -356,7 +356,7 @@ impl Formatter {
false => ", ",
};
if !n.elements.is_empty() {
for (i, item) in (&n.elements).iter().enumerate() {
for (i, item) in n.elements.iter().enumerate() {
if i != 0 {
self.write_string(sep);
if multiline {
Expand Down Expand Up @@ -501,7 +501,7 @@ impl Formatter {
true => ",\n",
false => ", ",
};
for (i, property) in (&n.properties).iter().enumerate() {
for (i, property) in n.properties.iter().enumerate() {
if i != 0 {
self.write_string(sep);
if multiline {
Expand Down Expand Up @@ -534,7 +534,7 @@ impl Formatter {
} else {
sep = ", ";
}
for (i, function_parameter) in (&n.params).iter().enumerate() {
for (i, function_parameter) in n.params.iter().enumerate() {
if i != 0 {
self.write_string(sep);
if multiline {
Expand Down
4 changes: 2 additions & 2 deletions libflux/flux-core/src/semantic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ impl PackageExports {

/// Returns an iterator over exported bindings in this package
pub fn into_bindings(self) -> impl Iterator<Item = (Symbol, PolyType)> {
self.values.into_iter().map(|(_, v)| (v.symbol, v.typ))
self.values.into_values().map(|v| (v.symbol, v.typ))
}

/// Returns an iterator over exported bindings in this package
pub fn bindings_iter(&self) -> impl Iterator<Item = (&Symbol, &PolyType)> + '_ {
self.values.iter().map(|(_, v)| (&v.symbol, &v.typ))
self.values.values().map(|v| (&v.symbol, &v.typ))
}
}

Expand Down
7 changes: 1 addition & 6 deletions libflux/flux-core/src/semantic/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,12 +1178,7 @@ impl FunctionExpr {

#[allow(missing_docs)]
pub fn pipe(&self) -> Option<&FunctionParameter> {
for p in &self.params {
if p.is_pipe {
return Some(p);
}
}
None
self.params.iter().find(|&p| p.is_pipe)
}
#[allow(missing_docs)]
pub fn defaults(&self) -> Vec<&FunctionParameter> {
Expand Down
4 changes: 2 additions & 2 deletions libflux/flux/src/cffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pub unsafe extern "C" fn flux_merge_ast_pkgs(

/// flux_analyze is a C-compatible wrapper around the analyze() function below
///
/// Note that Box<T> is used to indicate we are receiving/returning a C pointer and also
/// Note that `Box<T>` is used to indicate we are receiving/returning a C pointer and also
/// transferring ownership.
///
/// # Safety
Expand Down Expand Up @@ -379,7 +379,7 @@ pub unsafe extern "C" fn flux_analyze(
}

/// flux_find_var_type() is a C-compatible wrapper around the find_var_type() function below.
/// Note that Box<T> is used to indicate we are receiving/returning a C pointer and also
/// Note that `Box<T>` is used to indicate we are receiving/returning a C pointer and also
/// transferring ownership.
///
/// # Safety
Expand Down
20 changes: 10 additions & 10 deletions libflux/go/libflux/buildinfo.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ var sourceHashes = map[string]string{
"libflux/flux-core/src/bin/README.md": "c1245a4938c923d065647b4dc4f7e19486e85c93d868ef2f7f47ddff62ec81df",
"libflux/flux-core/src/bin/analyze_query_log.rs": "39e671b867268e1d8c244325205d7b2493aba337033f1112b1fb59555778fe9d",
"libflux/flux-core/src/bin/fluxdoc.rs": "1f06347f18eace128124b3bcde236584575060b2c5c1e67ae2617db6caf1a5dc",
"libflux/flux-core/src/db.rs": "a7be134ca32c8e802d83fb18e8849803925e04ff72dfc33ff4d491b680b41dcd",
"libflux/flux-core/src/db.rs": "7e9f2d2a732dd3336d24ff9a58deca9f7e91df93ca310826ea376bb3aaead2cb",
"libflux/flux-core/src/doc/example.rs": "29008d7fbf26e612107827551d6fb41f725b5973fbd617e0f04b087eff596fd2",
"libflux/flux-core/src/doc/mod.rs": "64941b878e1dda70be8b1b03e0bb850ea644755e8045b0b6f648c8af9b2f4dc6",
"libflux/flux-core/src/errors.rs": "05f6c3b6db7a4d479e8e5bfa12cecefddcc6657ce40b8979f548c8ccc4149f8b",
"libflux/flux-core/src/formatter/mod.rs": "6aaf87b945bbbfd8acc7a680aae6d3f4c84f8964a9ed6cb50b99122bb240fd45",
"libflux/flux-core/src/lib.rs": "487c5b2db051f7ed5276c566a9a6b2ee75d6a13459443cf94b51b6d90d20edd2",
"libflux/flux-core/src/map.rs": "342c1cc111d343f01b97f38be10a9f1097bdd57cdc56f55e92fd3ed5028e6973",
"libflux/flux-core/src/parser/mod.rs": "ba2e151626f38ecab7f04108fce2c7f046de5a99ddebd79bfc4b8c6a0d58d1c8",
"libflux/flux-core/src/parser/strconv.rs": "3bc4e4d5084ab121fb361be8530a67746ca050f5f706137f5820926cff900c5c",
"libflux/flux-core/src/scanner/mod.rs": "da94027f407f62ddb057153422efbf654cc397e81657ae5c7743166df0c821d8",
"libflux/flux-core/src/parser/mod.rs": "2d6b2c6b86b2921e8e68b6588f4c873632a7eaa1e645f3167efbf14aa3b4da58",
"libflux/flux-core/src/parser/strconv.rs": "6f03299d6669ae9fe17ec674d3aea6d8c95cb87753649f851ca39424abcb739d",
"libflux/flux-core/src/scanner/mod.rs": "eb7afb2eff162080046ddda7d1e9d01ffd4ec3a165bbcc95a001bf7edefa5e9c",
"libflux/flux-core/src/scanner/scanner.rl": "34e1f306994b8f69d0551110ce22efa75e0081b7c5f498ad293a739970bbcbc2",
"libflux/flux-core/src/scanner/scanner_generated.rs": "d917184e05832393cb1ee3133723181a7eac31b259782ac3f1af56bf68a25ed4",
"libflux/flux-core/src/scanner/token.rs": "4269721a053e8456e9a7983a72190ed86cd671d016e1d187d6772e1720f932e1",
Expand All @@ -41,16 +41,16 @@ var sourceHashes = map[string]string{
"libflux/flux-core/src/semantic/check.rs": "4fb5164785b6e7e6a26bb91a46f8045e90da0251e8f60842146aee8971eb3491",
"libflux/flux-core/src/semantic/convert.rs": "6801a6f21107d8fa1f7125966451b4dde008732a5f29a319c943d9bd026ba47f",
"libflux/flux-core/src/semantic/env.rs": "0d6295a88dae8eaaed12ee20a8d218616683e8d45a776966e0cab02be2760fd0",
"libflux/flux-core/src/semantic/flatbuffers/mod.rs": "4f4570ded6a7201c538f06f6c1f689bfa81beb98d77640df4b684d67c51fc9f8",
"libflux/flux-core/src/semantic/flatbuffers/mod.rs": "49ff0c257a8382a09d9716ab32b1ce9a2374bc2bbd2067f0886f114a87357d20",
"libflux/flux-core/src/semantic/flatbuffers/semantic_generated.rs": "295c79c5d0c9c9054d88f14ba30d5e3c80e4529973d7470457a1d8752b35ac8e",
"libflux/flux-core/src/semantic/flatbuffers/types.rs": "7dc317616643d8713048e7e0ea701c5a48b8945a222efa5f542e3beb7a29a126",
"libflux/flux-core/src/semantic/formatter/mod.rs": "03fa713818a5e70d99b7c1f9fdd9a330fdbac66830357d0f9df60451974ebdec",
"libflux/flux-core/src/semantic/flatbuffers/types.rs": "445a10f5c66395bc6aaeb5a9ef0949145461bfc0cb110fdb0d0ec1a768b00468",
"libflux/flux-core/src/semantic/formatter/mod.rs": "f9758877f7242998ed71f13ff71ed6e3fa3af497d2acf9df1853872b371bf12a",
"libflux/flux-core/src/semantic/fresh.rs": "18cb879ece9052682c9dda8117c23acd1f63c0325feaa1aef9a53db4f17d2d69",
"libflux/flux-core/src/semantic/fs.rs": "ae886648b20fc1e50d3c75418a9d62bb5102e93958e1bbdbf008066be4eb3909",
"libflux/flux-core/src/semantic/import.rs": "4bfa02fc96b4de3d913dbec622f0907307b4a15fe9dd4283d9cb86c6f0d18655",
"libflux/flux-core/src/semantic/infer.rs": "b6d18c94b58da27aebb5828f6471768ccc52e679a1356c6a38d0f3cd01a06dce",
"libflux/flux-core/src/semantic/mod.rs": "b13b01a7f2514d2390f413003dbc355f1361e4a7e4edb45c331d037ed6dc49d3",
"libflux/flux-core/src/semantic/nodes.rs": "cc488f68b082dbd9c2e90029e4312f4a38dd835a90d34a5dd9773ba691403e6d",
"libflux/flux-core/src/semantic/mod.rs": "c152ca3a24b73b80238316b003ec6acfb098bd4b60fecae308a38586a0bfbfe3",
"libflux/flux-core/src/semantic/nodes.rs": "75579f9e46d890f5a6c531eaba62343d11e6e24def787ec667568829f76c678b",
"libflux/flux-core/src/semantic/sub.rs": "8bc05ffff0990facea2130e0faf5a837f8663d59996ff85869c6e631ac654553",
"libflux/flux-core/src/semantic/symbols.rs": "f061d57fe4ef7f23d0adad80d43fe1c8ae92d5e25a0da4b81e21b8087e30d253",
"libflux/flux-core/src/semantic/types.rs": "2e3ee9dc324778b3c2b033af148650983f01e830f83546c7f1089fd2bdf7e6a6",
Expand All @@ -62,7 +62,7 @@ var sourceHashes = map[string]string{
"libflux/flux/Cargo.toml": "308c541b31f6ef25094ed4a4c2fddaf38244b0632b93c1f44b2ee4b4209d479c",
"libflux/flux/FLUXDOC.md": "92e6dd8043bd87b4924e09aa28fb5346630aee1214de28ea2c8fc0687cad0785",
"libflux/flux/build.rs": "31dcb1e825555e56b4d959244c4ea630b1d32ccddc1f8615620e0c23552d914f",
"libflux/flux/src/cffi.rs": "de2fc6176cc106b41826f37b2538f8617bc9485eafe098fa2e8008e0ddddb4e3",
"libflux/flux/src/cffi.rs": "d490e117f0e46386dee9fa35cc19209a07d1d57d7db352ab216b4d6fea1536a0",
"libflux/flux/src/lib.rs": "af2f62a02ec08ee476121e035c6587e31c1b6d5d4912ccace1e2e9ae019ad9c1",
"libflux/flux/templates/base.html": "a818747b9621828bb96b94291c60922db54052bbe35d5e354f8e589d2a4ebd02",
"libflux/flux/templates/home.html": "f9927514dd42ca7271b4817ad1ca33ec79c03a77a783581b4dcafabd246ebf3f",
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.63"
channel = "1.68"
components = ["rustfmt", "clippy"]
targets = [
"wasm32-unknown-unknown",
Expand Down

0 comments on commit 6dc8054

Please sign in to comment.