fn can_run_rustfix(&self, config: &Config) -> CargoResult<bool> {
        let to_edition = match self.prepare_for_edition {
            Some(s) => s,
            None => {
                return Message::Fixing {
                    file: self.file.display().to_string(),
                }
                .post()
                .and(Ok(true));
            }
        };
        // Unfortunately determining which cargo targets are being built
        // isn't easy, and each target can be a different edition. The
        // cargo-as-rustc fix wrapper doesn't know anything about the
        // workspace, so it can't check for the `cargo-features` unstable
        // opt-in. As a compromise, this just restricts to the nightly
        // toolchain.
        //
        // Unfortunately this results in a pretty poor error message when
        // multiple jobs run in parallel (the error appears multiple
        // times). Hopefully this doesn't happen often in practice.
        if !to_edition.is_stable() && !config.nightly_features_allowed {
            let message = format!(
                "`{file}` is on the latest edition, but trying to \
                 migrate to edition {to_edition}.\n\
                 Edition {to_edition} is unstable and not allowed in \
                 this release, consider trying the nightly release channel.",
                file = self.file.display(),
                to_edition = to_edition
            );
            return Message::EditionAlreadyEnabled {
                message,
                edition: to_edition.previous().unwrap(),
            }
            .post()
            .and(Ok(false)); // Do not run rustfix for this the edition.
        }
        let from_edition = self.enabled_edition.unwrap_or(Edition::Edition2015);
        if from_edition == to_edition {
            let message = format!(
                "`{}` is already on the latest edition ({}), \
                 unable to migrate further",
                self.file.display(),
                to_edition
            );
            Message::EditionAlreadyEnabled {
                message,
                edition: to_edition,
            }
            .post()
        } else {
            Message::Migrating {
                file: self.file.display().to_string(),
                from_edition,
                to_edition,
            }
            .post()
        }
        .and(Ok(true))
    }
/// Validates the edition, and sends a message indicating what is being
/// done. Returns a flag indicating whether this fix should be run.
Validates the edition, and sends a message indicating what is being
done. Returns a flag indicating whether this fix should be run.
Validates the edition and sends a message indicating what is being done . Returns a flag indicating whether this fix should be run .
fn can_run_rustfix(&self, config: &Config) -> CargoResult<bool> {
        let to_edition = match self.prepare_for_edition {
            Some(s) => s,
            None => {
                return Message::Fixing {
                    file: self.file.display().to_string(),
                }
                .post()
                .and(Ok(true));
            }
        };
        // Unfortunately determining which cargo targets are being built
        // isn't easy, and each target can be a different edition. The
        // cargo-as-rustc fix wrapper doesn't know anything about the
        // workspace, so it can't check for the `cargo-features` unstable
        // opt-in. As a compromise, this just restricts to the nightly
        // toolchain.
        //
        // Unfortunately this results in a pretty poor error message when
        // multiple jobs run in parallel (the error appears multiple
        // times). Hopefully this doesn't happen often in practice.
        if !to_edition.is_stable() && !config.nightly_features_allowed {
            let message = format!(
                "`{file}` is on the latest edition, but trying to \
                 migrate to edition {to_edition}.\n\
                 Edition {to_edition} is unstable and not allowed in \
                 this release, consider trying the nightly release channel.",
                file = self.file.display(),
                to_edition = to_edition
            );
            return Message::EditionAlreadyEnabled {
                message,
                edition: to_edition.previous().unwrap(),
            }
            .post()
            .and(Ok(false)); // Do not run rustfix for this the edition.
        }
        let from_edition = self.enabled_edition.unwrap_or(Edition::Edition2015);
        if from_edition == to_edition {
            let message = format!(
                "`{}` is already on the latest edition ({}), \
                 unable to migrate further",
                self.file.display(),
                to_edition
            );
            Message::EditionAlreadyEnabled {
                message,
                edition: to_edition,
            }
            .post()
        } else {
            Message::Migrating {
                file: self.file.display().to_string(),
                from_edition,
                to_edition,
            }
            .post()
        }
        .and(Ok(true))
    }
fn can_run_rustfix ( & self , config : & Config ) -> CargoResult < bool > { let to_edition = match self . prepare_for_edition { Some ( s ) => s , None => { return Message :: Fixing { file : self . file . display ( ) . to_string ( ) , } . post ( ) . and ( Ok ( true ) ) ; } } ; // Unfortunately determining which cargo targets are being built // isn't easy, and each target can be a different edition. The // cargo-as-rustc fix wrapper doesn't know anything about the // workspace, so it can't check for the `cargo-features` unstable // opt-in. As a compromise, this just restricts to the nightly // toolchain. // // Unfortunately this results in a pretty poor error message when // multiple jobs run in parallel (the error appears multiple // times). Hopefully this doesn't happen often in practice. if ! to_edition . is_stable ( ) && ! config . nightly_features_allowed { let message = format ! ( " \
 \n \
 \
 " file self file display ( ) to_edition to_edition ) ; return Message :: EditionAlreadyEnabled { message , edition : to_edition . previous ( ) . unwrap ( ) , } . post ( ) . and ( Ok ( false ) ) ; // Do not run rustfix for this the edition. } let from_edition = self . enabled_edition . unwrap_or ( Edition :: Edition2015 ) ; if from_edition == to_edition { let message = format ! ( " \
 " self file display ( ) to_edition ) ; Message :: EditionAlreadyEnabled { message , edition : to_edition , } . post ( ) } else { Message :: Migrating { file : self . file . display ( ) . to_string ( ) , from_edition , to_edition , } . post ( ) } . and ( Ok ( true ) ) }
Validates the edition, and sends a message indicating what is being
done.
Validates the edition and sends a message indicating what is being done .
&self
config
&Config
&self
config
&Config