Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(libflux): build on rust 1.78 #5484

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libflux/flux-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "flux-core"
version = "0.154.0"
rust-version = "1.68"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errrrrrrrr this says 1.68 but the PR title says 1.78?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH WAIT this is msrv isn't it, i thought i was looking at rust-toolchain.toml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version that we build with (from rust-toolchain.toml) is 1.68. I didn't really want to change that. As I understand it this sets the minimum supported version for the crate. Though we build with 1.68 it seems others are building influxdb with newer versions (#5479) so we want to support those too.

authors = ["Flux Team <[email protected]>"]
edition = "2021"

Expand Down
6 changes: 3 additions & 3 deletions libflux/flux-core/src/semantic/flatbuffers/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl From<fb::PolyType<'_>> for Option<PolyType> {
for value in c.iter() {
let constraint: Option<(BoundTvar, Kind)> = value.into();
let (tv, kind) = constraint?;
cons.entry(tv).or_insert_with(Vec::new).push(kind);
cons.entry(tv).or_default().push(kind);
}
Some(PolyType {
vars,
Expand Down Expand Up @@ -350,9 +350,9 @@ where
builder.finished_data()
}

pub fn deserialize<'a, T: 'a, S>(buf: &'a [u8]) -> S
pub fn deserialize<'a, T, S>(buf: &'a [u8]) -> S
where
T: flatbuffers::Follow<'a> + flatbuffers::Verifiable,
T: flatbuffers::Follow<'a> + flatbuffers::Verifiable + 'a,
S: std::convert::From<T::Inner>,
{
flatbuffers::root::<T>(buf).unwrap().into()
Expand Down
4 changes: 2 additions & 2 deletions libflux/flux-core/src/semantic/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,8 @@ impl VariableAssgn {
//
// Note these variables are fixed after generalization
// and so it is safe to update these nodes in place.
self.vars = p.vars.clone();
self.cons = p.cons.clone();
self.vars.clone_from(&p.vars);
self.cons.clone_from(&p.cons);

// Update the type environment
infer.add(self.id.name.clone(), p);
Expand Down
24 changes: 12 additions & 12 deletions libflux/flux-core/src/semantic/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ where
}

#[allow(clippy::too_many_arguments, clippy::type_complexity)]
pub(crate) fn merge4<A: ?Sized, B: ?Sized, C: ?Sized, D: ?Sized>(
pub(crate) fn merge4<A, B, C, D>(
a_original: &A,
a: Option<A::Owned>,
b_original: &B,
Expand All @@ -442,10 +442,10 @@ pub(crate) fn merge4<A: ?Sized, B: ?Sized, C: ?Sized, D: ?Sized>(
d: Option<D::Owned>,
) -> Option<(A::Owned, B::Owned, C::Owned, D::Owned)>
where
A: ToOwned,
B: ToOwned,
C: ToOwned,
D: ToOwned,
A: ToOwned + ?Sized,
B: ToOwned + ?Sized,
C: ToOwned + ?Sized,
D: ToOwned + ?Sized,
{
let a_b_c = merge3(a_original, a, b_original, b, c_original, c);
merge_fn(
Expand All @@ -465,7 +465,7 @@ where
.map(|((a, b, c), d)| (a, b, c, d))
}

pub(crate) fn merge3<A: ?Sized, B: ?Sized, C: ?Sized>(
pub(crate) fn merge3<A, B, C>(
a_original: &A,
a: Option<A::Owned>,
b_original: &B,
Expand All @@ -474,9 +474,9 @@ pub(crate) fn merge3<A: ?Sized, B: ?Sized, C: ?Sized>(
c: Option<C::Owned>,
) -> Option<(A::Owned, B::Owned, C::Owned)>
where
A: ToOwned,
B: ToOwned,
C: ToOwned,
A: ToOwned + ?Sized,
B: ToOwned + ?Sized,
C: ToOwned + ?Sized,
{
let a_b = merge(a_original, a, b_original, b);
merge_fn(
Expand All @@ -492,15 +492,15 @@ where

/// Merges two values using `f` if either or both them is `Some(..)`.
/// If both are `None`, `None` is returned.
pub(crate) fn merge<A: ?Sized, B: ?Sized>(
pub(crate) fn merge<A, B>(
a_original: &A,
a: Option<A::Owned>,
b_original: &B,
b: Option<B::Owned>,
) -> Option<(A::Owned, B::Owned)>
where
A: ToOwned,
B: ToOwned,
A: ToOwned + ?Sized,
B: ToOwned + ?Sized,
{
merge_fn(a_original, A::to_owned, a, b_original, B::to_owned, b)
}
Expand Down
10 changes: 6 additions & 4 deletions libflux/flux-core/src/semantic/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ fn collect_record(record: &Record) -> (RefMonoTypeVecMap<'_, RecordLabel>, Optio

let mut fields = record.fields();
for field in &mut fields {
a.entry(&field.k).or_insert_with(Vec::new).push(&field.v);
a.entry(&field.k).or_default().push(&field.v);
}
(a, fields.tail())
}
Expand Down Expand Up @@ -1804,7 +1804,7 @@ impl PartialEq<&str> for Label {

impl PartialOrd for Label {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.name().partial_cmp(other.0.name())
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -1955,10 +1955,10 @@ impl<T> Function<T> {
self.opt.len() + self.req.len() + self.pipe.is_some() as usize
}

pub(crate) fn parameter<Q: ?Sized>(&self, key: &Q) -> Option<&T>
pub(crate) fn parameter<Q>(&self, key: &Q) -> Option<&T>
where
String: Borrow<Q> + Ord,
Q: Ord,
Q: Ord + ?Sized,
{
self.req
.get(key)
Expand Down Expand Up @@ -2189,8 +2189,10 @@ impl Function {
pub(crate) trait TypeLike {
type Error;
fn typ(&self) -> &MonoType;
#[allow(dead_code)]
fn into_type(self) -> MonoType;
fn error(&self, error: Error) -> Self::Error;
#[allow(dead_code)]
fn location(&self) -> crate::ast::SourceLocation;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to keep these methods around in the trait definition if they're not used anywhere? I have zero context for this trait, so feel free to ignore me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly because I didn't want to mess with the code any more than I have to. I don't really know much about how this library works, other than it having a scarily brittle build process for interfacing with the go part of the system.

}

Expand Down
1 change: 1 addition & 0 deletions libflux/flux-core/src/semantic/walk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ macro_rules! mk_node {

/// Recursively visits children of a node given a Visitor.
/// Nodes are visited in depth-first order.
#[allow(clippy::needless_lifetimes)]
pub fn $walk<'a, T>(v: &mut T, $($mut)? node: $name<'a>)
where
T: ?Sized + $visitor $(<$visitor_lt>)?,
Expand Down
1 change: 1 addition & 0 deletions libflux/flux/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "flux"
version = "0.154.0"
rust-version = "1.68"
authors = ["Flux Team <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion libflux/flux/src/cffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ from(bucket: v.bucket)
// Safety: both parameters are valid
let err = unsafe { flux_ast_get_error(pkg, options) }.unwrap();
// Safety: pkg is a valid pointer allocated just above
unsafe { Box::from_raw(pkg) }; // Free the AST
unsafe { drop(Box::from_raw(pkg)) }; // Free the AST
let msg = err.message.to_string_lossy();
assert!(
msg.contains("incomplete utf-8 byte sequence from index 0"),
Expand Down