Skip to content

Commit 47f0596

Browse files
d-e-s-oryzhyk
authored andcommitted
Fix warnings about trait objects requiring 'dyn' keyword
When using Rust 1.37 a missing 'dyn' in conjunction with a trait object is now emitting a warning (see [Rust issue #61203][issue-61203]), causing all generated programs to warn as well: > warning: trait objects without an explicit `dyn` are deprecated > --> src/valmap.rs:36:34 > | > 36 | pub fn format(&self, w: &mut io::Write) -> io::Result<()> { > | ^^^^^^^^^ help: use `dyn`: `dyn io::Write` > | > = note: #[warn(bare_trait_objects)] on by default Let's remove these warnings by adding this keyword to the uses of trait objects in the project template. [issue-61203]: rust-lang/rust#61203
1 parent e55892f commit 47f0596

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

rust/template/differential_datalog/program.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub struct Program<V: Val> {
181181
/// set, adding new collections. Note that the transformer can only be applied in the top scope
182182
/// (`Child<'a, Worker<Allocator>, TS>`), as we currently don't have a way to ensure that the
183183
/// transformer in monotonic and thus it may not converge if used in a nested scope.
184-
pub type TransformerFunc<V> = fn() -> Box<for<'a> Fn(&mut FnvHashMap<RelId, Collection<Child<'a, Worker<Allocator>, TS>,V,Weight>>)>;
184+
pub type TransformerFunc<V> = fn() -> Box<dyn for<'a> Fn(&mut FnvHashMap<RelId, Collection<Child<'a, Worker<Allocator>, TS>,V,Weight>>)>;
185185

186186
/// Program node is either an individual non-recursive relation, a transformer application or
187187
/// a vector of one or more mutually recursive relations.
@@ -248,7 +248,7 @@ pub struct Relation<V: Val> {
248248
pub type MapFunc<V> = fn(V) -> V;
249249

250250
/// (see `XFormCollection::FlatMap`).
251-
pub type FlatMapFunc<V> = fn(V) -> Option<Box<Iterator<Item=V>>>;
251+
pub type FlatMapFunc<V> = fn(V) -> Option<Box<dyn Iterator<Item=V>>>;
252252

253253
/// Function type used to filter a relation
254254
/// (see `XForm*::Filter`).

rust/template/src/valmap.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl DeltaMap {
3333
DeltaMap{map: BTreeMap::default()}
3434
}
3535

36-
pub fn format(&self, w: &mut io::Write) -> io::Result<()> {
36+
pub fn format(&self, w: &mut dyn io::Write) -> io::Result<()> {
3737
for (relid, relmap) in &self.map {
3838
w.write_fmt(format_args!("{:?}:\n", relid2rel(*relid).unwrap()))?;
3939
for (val, weight) in relmap {
@@ -44,15 +44,15 @@ impl DeltaMap {
4444
Ok(())
4545
}
4646

47-
pub fn format_rel(&mut self, relid: RelId, w: &mut io::Write) -> io::Result<()> {
47+
pub fn format_rel(&mut self, relid: RelId, w: &mut dyn io::Write) -> io::Result<()> {
4848
let map = self.get_rel(relid);
4949
for (val, weight) in map {
5050
w.write_fmt(format_args!("{}: {}\n", *val, *weight))?;
5151
};
5252
Ok(())
5353
}
5454

55-
pub fn format_as_sets(&self, w: &mut io::Write) -> io::Result<()> {
55+
pub fn format_as_sets(&self, w: &mut dyn io::Write) -> io::Result<()> {
5656
for (relid, map) in &self.map {
5757
w.write_fmt(format_args!("{:?}:\n", relid2rel(*relid).unwrap()))?;
5858
for (val,weight) in map {
@@ -64,7 +64,7 @@ impl DeltaMap {
6464
Ok(())
6565
}
6666

67-
pub fn format_rel_as_set(&mut self, relid: RelId, w: &mut io::Write) -> io::Result<()> {
67+
pub fn format_rel_as_set(&mut self, relid: RelId, w: &mut dyn io::Write) -> io::Result<()> {
6868
let map = self.get_rel(relid);
6969
for (val, weight) in map {
7070
w.write_fmt(format_args!("{}\n", *val))?;

0 commit comments

Comments
 (0)