Skip to content

Commit

Permalink
Fix warnings about trait objects requiring 'dyn' keyword
Browse files Browse the repository at this point in the history
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
  • Loading branch information
d-e-s-o authored and ryzhyk committed Sep 5, 2019
1 parent e55892f commit 47f0596
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rust/template/differential_datalog/program.rs
Expand Up @@ -181,7 +181,7 @@ pub struct Program<V: Val> {
/// set, adding new collections. Note that the transformer can only be applied in the top scope
/// (`Child<'a, Worker<Allocator>, TS>`), as we currently don't have a way to ensure that the
/// transformer in monotonic and thus it may not converge if used in a nested scope.
pub type TransformerFunc<V> = fn() -> Box<for<'a> Fn(&mut FnvHashMap<RelId, Collection<Child<'a, Worker<Allocator>, TS>,V,Weight>>)>;
pub type TransformerFunc<V> = fn() -> Box<dyn for<'a> Fn(&mut FnvHashMap<RelId, Collection<Child<'a, Worker<Allocator>, TS>,V,Weight>>)>;

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

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

/// Function type used to filter a relation
/// (see `XForm*::Filter`).
Expand Down
8 changes: 4 additions & 4 deletions rust/template/src/valmap.rs
Expand Up @@ -33,7 +33,7 @@ impl DeltaMap {
DeltaMap{map: BTreeMap::default()}
}

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

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

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

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

0 comments on commit 47f0596

Please sign in to comment.