Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum rustc version error #449

Merged
merged 3 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pull minimum_rustc_version into GlobalConfig
  • Loading branch information
arnaudgolfouse committed May 15, 2023
commit aae727032177ca214d90984cf9710ac8d52bc2e6
9 changes: 9 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pub struct GlobalConfig {
stdout: StandardStream,
stderr: StandardStream,
handlebars: handlebars::Handlebars<'static>,
/// Minimum rustc version supported.
///
/// This will be used to print an error if the user's rustc version is not high enough.
minimum_rustc_version: semver::Version,
}

impl Default for GlobalConfig {
Expand Down Expand Up @@ -48,13 +52,18 @@ impl GlobalConfig {
}
})),
handlebars: make_handlebars_registry(),
minimum_rustc_version: semver::Version::new(1, 65, 0),
}
}

pub fn handlebars(&self) -> &handlebars::Handlebars<'static> {
&self.handlebars
}

pub fn minimum_rustc_version(&self) -> &semver::Version {
&self.minimum_rustc_version
}

pub fn set_level(mut self, level: Option<log::Level>) -> Self {
self.level = level;
self
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ impl Check {
if !(matches!(self.current.source, RustdocSource::Rustdoc(_))
&& matches!(self.baseline.source, RustdocSource::Rustdoc(_)))
{
let rustc_version_needed = rustc_version::Version::new(1, 65, 0);
let rustc_version_needed = config.minimum_rustc_version();
match rustc_version::version() {
Ok(rustc_version) => {
if rustc_version < rustc_version_needed {
if rustc_version < *rustc_version_needed {
let help = "HELP: to use the latest rustc, run `rustup update stable && cargo +stable semver-checks <args>`";
anyhow::bail!("rustc version is not high enough: >={rustc_version_needed} needed, got {rustc_version}\n\n{help}");
}
Expand Down