Skip to content

Commit

Permalink
rust #23856 is fixed on stable
Browse files Browse the repository at this point in the history
The workaround for rust-lang/rust#23856 can now be removed.
  • Loading branch information
ExpHP committed Mar 23, 2019
1 parent 6ff2d31 commit 25af333
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/tasks/cmd/relaxation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use crate::{FailResult, FailOk};
use crate::filetypes::stored_structure::StoredStructure;
use crate::potential::{self, PotentialBuilder, DiffFn, BondDiffFn, DynFlatDiffFn};
use crate::potential::{self, PotentialBuilder, DiffFn, BondDiffFn, FlatDiffFn};
use crate::meta::{self, prelude::*};
use crate::hlist_aliases::*;
use crate::math::basis::{Basis3, EvDirection};
Expand Down Expand Up @@ -614,7 +614,7 @@ fn flat_constrained_position(
// There will be one coordinate for each eigenvector.
fn constrained_diff_fn<'a>(
// operates on 3N coords
flat_3n_diff_fn: &'a mut DynFlatDiffFn<'a>,
flat_3n_diff_fn: &'a mut dyn FlatDiffFn,
// K values, K <= 3N
flat_init_pos: &'a [f64],
// K eigenvectors
Expand Down
11 changes: 4 additions & 7 deletions src/tasks/potential/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ pub trait FlatDiffFn: FnMut(&[f64]) -> FailResult<(f64, Vec<f64>)> {}

impl<F> FlatDiffFn for F where F: FnMut(&[f64]) -> FailResult<(f64, Vec<f64>)> {}

// Type aliases for the trait object types, to work around #23856
pub type DynFlatDiffFn<'a> = dyn FlatDiffFn<Output=FailResult<(f64, Vec<f64>)>> + 'a;

/// This is what gets passed around by very high level code to represent a
/// potential function. Basically:
///
Expand Down Expand Up @@ -125,8 +122,8 @@ pub trait PotentialBuilder<Meta = CommonMeta>
///
/// Because Boxes don't implement `Fn` traits for technical reasons,
/// you will likely need to write `&mut *flat_diff_fn` in order to get
/// a `&mut DynFlatDiffFn`.
fn initialize_flat_diff_fn(&self, init_coords: &Coords, meta: Meta) -> FailResult<Box<DynFlatDiffFn<'static>>>
/// a `&mut dyn FlatDiffFn`.
fn initialize_flat_diff_fn(&self, init_coords: &Coords, meta: Meta) -> FailResult<Box<dyn FlatDiffFn>>
where Meta: Clone + 'static
{
let mut diff_fn = self.initialize_diff_fn(init_coords, meta.clone())?;
Expand Down Expand Up @@ -255,7 +252,7 @@ where Meta: Clone + 'static,
fn initialize_diff_fn(&self, coords: &Coords, meta: Meta) -> FailResult<Box<dyn DiffFn<Meta>>>
{ (**self).initialize_diff_fn(coords, meta) }

fn initialize_flat_diff_fn(&self, coords: &Coords, meta: Meta) -> FailResult<Box<DynFlatDiffFn<'static>>>
fn initialize_flat_diff_fn(&self, coords: &Coords, meta: Meta) -> FailResult<Box<dyn FlatDiffFn>>
{ (**self).initialize_flat_diff_fn(coords, meta) }

fn initialize_bond_diff_fn(&self, init_coords: &Coords, meta: Meta) -> FailResult<Option<Box<dyn BondDiffFn<Meta>>>>
Expand Down Expand Up @@ -511,7 +508,7 @@ impl dyn PotentialBuilder {

pub struct Rsp2MinimizeDiffFnShim {
pub ndim: usize,
pub diff_fn: Box<DynFlatDiffFn<'static>>
pub diff_fn: Box<dyn FlatDiffFn>
}

impl<'a> rsp2_minimize::test::n_dee::OnceDifferentiable for Rsp2MinimizeDiffFnShim {
Expand Down

0 comments on commit 25af333

Please sign in to comment.