Skip to content

Commit

Permalink
Fix warning "Trait objects without explicit 'dyn' are deprecated"
Browse files Browse the repository at this point in the history
'dyn Trait' syntax was introduced in Rust 1.27 and deprecation begun in
recent Rust versions.
  • Loading branch information
intgr authored and bluejekyll committed Oct 7, 2019
1 parent 3044d63 commit f798bba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions examples/fdw-rw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl ForeignRow for MyRow {
}

impl Iterator for CacheFDW {
type Item = Box<ForeignRow>;
type Item = Box<dyn ForeignRow>;
fn next(&mut self) -> Option<Self::Item> {
match self.inner.pop() {
None => None,
Expand Down Expand Up @@ -103,7 +103,7 @@ CREATE FOREIGN TABLE {schema}.mytable (
Some(vec!["key".into()])
}

fn update(&self, new_row: &Tuple, indices: &Tuple) -> Option<Box<ForeignRow>> {
fn update(&self, new_row: &Tuple, indices: &Tuple) -> Option<Box<dyn ForeignRow>> {
let mut c = get_cache().write().unwrap();
let key = indices.get("key");
let value = new_row.get("value");
Expand All @@ -126,12 +126,12 @@ CREATE FOREIGN TABLE {schema}.mytable (
}
}

fn insert(&self, new_row: &Tuple) -> Option<Box<ForeignRow>> {
fn insert(&self, new_row: &Tuple) -> Option<Box<dyn ForeignRow>> {
// Since we only use one field from each, these methods are equivalent
self.update(new_row, new_row)
}

fn delete(&self, indices: &Tuple) -> Option<Box<ForeignRow>> {
fn delete(&self, indices: &Tuple) -> Option<Box<dyn ForeignRow>> {
// TODO: switch to correct memory context
let memory_context = PgAllocator::current_context();

Expand Down
2 changes: 1 addition & 1 deletion examples/fdw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ForeignRow for MyRow {
}

impl Iterator for DefaultFDW {
type Item = Box<ForeignRow>;
type Item = Box<dyn ForeignRow>;
fn next(&mut self) -> Option<Self::Item> {
self.i += 1;
if self.i > 5 {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl MsgCapture {
mem::replace(&mut *msgs, Vec::new())
}
/// Returns a callback for Connection::set_notice_handler()
fn get_handler(&self) -> Box<HandleNotice> {
fn get_handler(&self) -> Box<dyn HandleNotice> {
let msgs = self.msgs.clone();
// HandleNotice trait is implemented for FnMut(DbError)
return Box::new(move |e: DbError| {
Expand Down
10 changes: 5 additions & 5 deletions pg-extend/src/pg_fdw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub type Tuple<'mc> = HashMap<String, pg_datum::PgDatum<'mc>>;
/// is responsible for creating row objects to return data.
/// The object is only active for the lifetime of a query, so it
/// is not an appropriate place to put caching or long-running connections.
pub trait ForeignData: Iterator<Item = Box<ForeignRow>> {
pub trait ForeignData: Iterator<Item = Box<dyn ForeignRow>> {
/// Called when a scan is initiated. Note that any heavy set up
/// such as making connections or allocating memory should not
/// happen in this step, but on the first call to next()
Expand Down Expand Up @@ -61,23 +61,23 @@ pub trait ForeignData: Iterator<Item = Box<ForeignRow>> {
/// specified by index_columns. Do not assume columns present in indices
/// were present in the UPDATE statement.
/// Returns the updated row, or None if no update occured.
fn update<'mc>(&self, _new_row: &Tuple<'mc>, _indices: &Tuple<'mc>) -> Option<Box<ForeignRow>> {
fn update<'mc>(&self, _new_row: &Tuple<'mc>, _indices: &Tuple<'mc>) -> Option<Box<dyn ForeignRow>> {
error!("Table does not support update");
None
}

/// Method for INSERTs. Takes in new_row (which is a mapping of column
/// names to values). Returns the inserted row, or None if no insert
/// occurred.
fn insert<'mc>(&self, _new_row: &Tuple<'mc>) -> Option<Box<ForeignRow>> {
fn insert<'mc>(&self, _new_row: &Tuple<'mc>) -> Option<Box<dyn ForeignRow>> {
error!("Table does not support insert");
None
}

/// Method for DELETEs. Takes in a indices is the same, which consists of columns
/// specified by index_columns.
/// Returns the deleted row, or None if no row was deleted.
fn delete<'mc>(&self, _indices: &Tuple<'mc>) -> Option<Box<ForeignRow>> {
fn delete<'mc>(&self, _indices: &Tuple<'mc>) -> Option<Box<dyn ForeignRow>> {
error!("Table does not support delete");
None
}
Expand Down Expand Up @@ -222,7 +222,7 @@ impl<T: ForeignData> ForeignWrapper<T> {
fn get_field<'mc>(
_memory_context: &'mc PgAllocator,
attr: &pg_sys::FormData_pg_attribute,
row: &'mc ForeignRow,
row: &'mc dyn ForeignRow,
) -> Result<Option<pg_datum::PgDatum<'mc>>, String> {
let name = Self::name_to_string(attr.attname);
// let typ = attr.atttypid;
Expand Down

0 comments on commit f798bba

Please sign in to comment.