From 5ca2d08013845975cdb10c8d282552b42c5c9e09 Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Mon, 21 Sep 2020 08:42:07 +0100 Subject: [PATCH] Bump MSRV to 1.36.0 --- .github/workflows/ci.yml | 8 +-- CHANGELOG.md | 3 ++ README.md | 2 +- schemars/Cargo.toml | 2 +- schemars/build.rs | 72 ++++++--------------------- schemars/src/json_schema_impls/mod.rs | 1 - schemars/src/visit.rs | 1 - schemars/tests/nonzero_ints.rs | 31 ++++++------ 8 files changed, 38 insertions(+), 82 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5504048..c6ef792 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: ci: @@ -8,13 +8,13 @@ jobs: strategy: matrix: rust: - - 1.32.0 + - 1.36.0 - stable - beta - nightly include: - - rust: 1.32.0 - test_features: "--features impl_json_schema,chrono,indexmap,either,uuid" + - rust: 1.36.0 + test_features: "--all-features" - rust: stable test_features: "--all-features" - rust: beta diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e0d24..7abb93d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ - `SchemaSettings` no longer implements `PartialEq` - `SchemaGenerator::into_definitions()` - this has been superseded by `SchemaGenerator::take_definitions()` +### Changed (**BREAKING CHANGES**): +- Minimum supported rust version is now 1.36.0 + ### Fixed: - **BREAKING CHANGE** unknown items in `#[schemars(...)]` attributes now cause a compilation error (https://github.com/GREsau/schemars/issues/18) diff --git a/README.md b/README.md index 7f57132..1a2831e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![CI Build](https://img.shields.io/github/workflow/status/GREsau/schemars/CI?logo=GitHub)](https://github.com/GREsau/schemars/actions) [![Crates.io](https://img.shields.io/crates/v/schemars)](https://crates.io/crates/schemars) [![Docs](https://docs.rs/schemars/badge.svg)](https://docs.rs/schemars) -[![rustc 1.32+](https://img.shields.io/badge/schemars-rustc_1.32+-lightgray.svg)](https://blog.rust-lang.org/2019/01/17/Rust-1.32.0.html) +[![rustc 1.36+](https://img.shields.io/badge/schemars-rustc_1.36+-lightgray.svg)](https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html) Generate JSON Schema documents from Rust code diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 60f091e..de6c19b 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -16,7 +16,7 @@ build = "build.rs" schemars_derive = { version = "=0.8.0-alpha-4", optional = true, path = "../schemars_derive" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -dyn-clone = "= 1.0.1" +dyn-clone = "1.0" chrono = { version = "0.4", default-features = false, optional = true } indexmap = { version = "1.2", features=["serde-1"], optional = true } diff --git a/schemars/build.rs b/schemars/build.rs index e432deb..6f704fe 100644 --- a/schemars/build.rs +++ b/schemars/build.rs @@ -1,67 +1,25 @@ use std::env; -use std::process::Command; -use std::str::{self, FromStr}; // Based on https://github.com/serde-rs/serde/blob/master/serde/build.rs fn main() { - let minor = match rustc_minor_version() { - Some(minor) => minor, - None => return, - }; - let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // Atomic types, and non-zero signed integers stabilized in Rust 1.34: - // https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations - if minor >= 34 { - println!("cargo:rustc-cfg=num_nonzero_signed"); - - // Whitelist of archs that support std::sync::atomic module. Ideally we - // would use #[cfg(target_has_atomic = "...")] but it is not stable yet. - // Instead this is based on rustc's src/librustc_target/spec/*.rs. - let has_atomic64 = target.starts_with("x86_64") - || target.starts_with("i686") - || target.starts_with("aarch64") - || target.starts_with("powerpc64") - || target.starts_with("sparc64") - || target.starts_with("mips64el"); - let has_atomic32 = has_atomic64 || emscripten; - if has_atomic64 { - println!("cargo:rustc-cfg=std_atomic64"); - } - if has_atomic32 { - println!("cargo:rustc-cfg=std_atomic"); - } + // Whitelist of archs that support std::sync::atomic module. Ideally we + // would use #[cfg(target_has_atomic = "...")] but it is not stable yet. + // Instead this is based on rustc's src/librustc_target/spec/*.rs. + let has_atomic64 = target.starts_with("x86_64") + || target.starts_with("i686") + || target.starts_with("aarch64") + || target.starts_with("powerpc64") + || target.starts_with("sparc64") + || target.starts_with("mips64el"); + let has_atomic32 = has_atomic64 || emscripten; + if has_atomic64 { + println!("cargo:rustc-cfg=std_atomic64"); + } + if has_atomic32 { + println!("cargo:rustc-cfg=std_atomic"); } } - -fn rustc_minor_version() -> Option { - let rustc = match env::var_os("RUSTC") { - Some(rustc) => rustc, - None => return None, - }; - - let output = match Command::new(rustc).arg("--version").output() { - Ok(output) => output, - Err(_) => return None, - }; - - let version = match str::from_utf8(&output.stdout) { - Ok(version) => version, - Err(_) => return None, - }; - - let mut pieces = version.split('.'); - if pieces.next() != Some("rustc 1") { - return None; - } - - let next = match pieces.next() { - Some(next) => next, - None => return None, - }; - - u32::from_str(next).ok() -} diff --git a/schemars/src/json_schema_impls/mod.rs b/schemars/src/json_schema_impls/mod.rs index f0a311a..d6d6d16 100644 --- a/schemars/src/json_schema_impls/mod.rs +++ b/schemars/src/json_schema_impls/mod.rs @@ -55,7 +55,6 @@ mod ffi; #[cfg(feature = "indexmap")] mod indexmap; mod maps; -#[cfg(num_nonzero_signed)] mod nonzero_signed; mod nonzero_unsigned; mod primitives; diff --git a/schemars/src/visit.rs b/schemars/src/visit.rs index a041e16..30d7d2a 100644 --- a/schemars/src/visit.rs +++ b/schemars/src/visit.rs @@ -1,5 +1,4 @@ use crate::schema::{RootSchema, Schema, SchemaObject, SingleOrVec}; -use std::fmt::Debug; /// TODO document pub trait Visitor { diff --git a/schemars/tests/nonzero_ints.rs b/schemars/tests/nonzero_ints.rs index 42460d9..d282186 100644 --- a/schemars/tests/nonzero_ints.rs +++ b/schemars/tests/nonzero_ints.rs @@ -1,21 +1,18 @@ mod util; -#[cfg(num_nonzero_signed)] -mod nonzero_ints { - use super::*; - use schemars::JsonSchema; - use util::*; +use super::*; +use schemars::JsonSchema; +use util::*; - #[derive(Debug, JsonSchema)] - struct MyStruct { - unsigned: u32, - nonzero_unsigned: std::num::NonZeroU32, - signed: i32, - nonzero_signed: std::num::NonZeroI32, - } - - #[test] - fn nonzero_ints() -> TestResult { - test_default_generated_schema::("nonzero_ints") - } +#[derive(Debug, JsonSchema)] +struct MyStruct { + unsigned: u32, + nonzero_unsigned: std::num::NonZeroU32, + signed: i32, + nonzero_signed: std::num::NonZeroI32, +} + +#[test] +fn nonzero_ints() -> TestResult { + test_default_generated_schema::("nonzero_ints") }