You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: fix.rs
    path of file: ./repos/foundry/crates/config/src
    
    the code of the file until where you have to start completion: //! Helpers to automatically fix configuration warnings

use crate::{Config, Warning};
use figment::providers::Env;
use std::{
    fs, io,
    ops::{Deref, DerefMut},
    path::{Path, PathBuf},
};

/// A convenience wrapper around a TOML document and the path it was read from
struct TomlFile {
    doc: toml_edit::Document,
    path: PathBuf,
}

impl TomlFile {
    fn open(path: impl AsRef<Path>) -> Result<Self, Box<dyn std::error::Error>> {
        let path = path.as_ref().to_owned();
        let doc = fs::read_to_string(&path)?.parse()?;
        Ok(Self { doc, path })
    }
    fn doc(&self) -> &toml_edit::Document {
        &self.doc
    }
    fn doc_mut(&mut self) -> &mut toml_edit::Document {
        &mut self.doc
    }
    fn path(&self) -> &Path {
        self.path.as_ref()
    }
    fn save(&self) -> io::Result<()> {
        fs::write(self.path(), self.doc().to_string())
    }
}

impl Deref for TomlFile {
    type Target = toml_edit::Document;
    fn deref(&self) -> &Self::Target {
        self.doc()
    }
}

impl DerefMut for TomlFile {
    fn deref_mut(&mut self) -> &mut Self::Target {
        self.doc_mut()
    }
}

/// The error emitted when failing to insert a profile into [profile]
#[derive(Debug)]
struct InsertProfileError {
    pub message: String,
    pub value: toml_edit::Item,
}

impl std::fmt::Dis
    
pub fn fix_tomls() -> Vec<Warning> {
    let mut warnings = vec![];

    let tomls = {
        let mut tomls = vec![];
        if let Some(global_toml) = Config::foundry_dir_toml().filter(|p| p.exists()) {
            tomls.push(global_toml);
        }
        let local_toml = PathBuf::from(
            Env::var("FOUNDRY_CONFIG").unwrap_or_else(|| Config::FILE_NAME.to_string()),
        );
        if local_toml.exists() {
            tomls.push(local_toml);
        } else {
            warnings.push(Warning::NoLocalToml(local_toml));
        }
        tomls
    };

    for toml in tomls {
        let mut toml_file = match TomlFile::open(&toml) {
            Ok(toml_file) => toml_file,
            Err(err) => {
                warnings.push(Warning::CouldNotReadToml { path: toml, err: err.to_string() });
                continue
            }
        };

        let results = fix_toml_non_strict_profiles(&mut toml_file);
        let was_edited = results.iter().any(|(_, res)| res.is_ok());
        for (profile, err) in results
            .into_iter()
            .filter_map(|(profile, res)| res.err().map(|err| (profile, err.message)))
        {
            warnings.push(Warning::CouldNotFixProfile {
                path: toml_file.path().into(),
                profile,
                err,
            })
        }

        if was_edited {
            if let Err(err) = toml_file.save() {
                warnings.push(Warning::CouldNotWriteToml {
                    path: toml_file.path().into(),
                    err: err.to_string(),
                });
            }
        }
    }

    warnings
}