Bump MSRV to 1.36.0

This commit is contained in:
Graham Esau 2020-09-21 08:42:07 +01:00
parent 7a1e02eefd
commit 5ca2d08013
8 changed files with 38 additions and 82 deletions

View file

@ -1,6 +1,6 @@
name: CI name: CI
on: [push, pull_request] on: [push, pull_request, workflow_dispatch]
jobs: jobs:
ci: ci:
@ -8,13 +8,13 @@ jobs:
strategy: strategy:
matrix: matrix:
rust: rust:
- 1.32.0 - 1.36.0
- stable - stable
- beta - beta
- nightly - nightly
include: include:
- rust: 1.32.0 - rust: 1.36.0
test_features: "--features impl_json_schema,chrono,indexmap,either,uuid" test_features: "--all-features"
- rust: stable - rust: stable
test_features: "--all-features" test_features: "--all-features"
- rust: beta - rust: beta

View file

@ -14,6 +14,9 @@
- `SchemaSettings` no longer implements `PartialEq` - `SchemaSettings` no longer implements `PartialEq`
- `SchemaGenerator::into_definitions()` - this has been superseded by `SchemaGenerator::take_definitions()` - `SchemaGenerator::into_definitions()` - this has been superseded by `SchemaGenerator::take_definitions()`
### Changed (**BREAKING CHANGES**):
- Minimum supported rust version is now 1.36.0
### Fixed: ### Fixed:
- **BREAKING CHANGE** unknown items in `#[schemars(...)]` attributes now cause a compilation error (https://github.com/GREsau/schemars/issues/18) - **BREAKING CHANGE** unknown items in `#[schemars(...)]` attributes now cause a compilation error (https://github.com/GREsau/schemars/issues/18)

View file

@ -3,7 +3,7 @@
[![CI Build](https://img.shields.io/github/workflow/status/GREsau/schemars/CI?logo=GitHub)](https://github.com/GREsau/schemars/actions) [![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) [![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) [![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 Generate JSON Schema documents from Rust code

View file

@ -16,7 +16,7 @@ build = "build.rs"
schemars_derive = { version = "=0.8.0-alpha-4", optional = true, path = "../schemars_derive" } schemars_derive = { version = "=0.8.0-alpha-4", optional = true, path = "../schemars_derive" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
dyn-clone = "= 1.0.1" dyn-clone = "1.0"
chrono = { version = "0.4", default-features = false, optional = true } chrono = { version = "0.4", default-features = false, optional = true }
indexmap = { version = "1.2", features=["serde-1"], optional = true } indexmap = { version = "1.2", features=["serde-1"], optional = true }

View file

@ -1,23 +1,11 @@
use std::env; 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 // Based on https://github.com/serde-rs/serde/blob/master/serde/build.rs
fn main() { fn main() {
let minor = match rustc_minor_version() {
Some(minor) => minor,
None => return,
};
let target = env::var("TARGET").unwrap(); let target = env::var("TARGET").unwrap();
let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; 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 // Whitelist of archs that support std::sync::atomic module. Ideally we
// would use #[cfg(target_has_atomic = "...")] but it is not stable yet. // would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
// Instead this is based on rustc's src/librustc_target/spec/*.rs. // Instead this is based on rustc's src/librustc_target/spec/*.rs.
@ -35,33 +23,3 @@ fn main() {
println!("cargo:rustc-cfg=std_atomic"); println!("cargo:rustc-cfg=std_atomic");
} }
} }
}
fn rustc_minor_version() -> Option<u32> {
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()
}

View file

@ -55,7 +55,6 @@ mod ffi;
#[cfg(feature = "indexmap")] #[cfg(feature = "indexmap")]
mod indexmap; mod indexmap;
mod maps; mod maps;
#[cfg(num_nonzero_signed)]
mod nonzero_signed; mod nonzero_signed;
mod nonzero_unsigned; mod nonzero_unsigned;
mod primitives; mod primitives;

View file

@ -1,5 +1,4 @@
use crate::schema::{RootSchema, Schema, SchemaObject, SingleOrVec}; use crate::schema::{RootSchema, Schema, SchemaObject, SingleOrVec};
use std::fmt::Debug;
/// TODO document /// TODO document
pub trait Visitor { pub trait Visitor {

View file

@ -1,7 +1,5 @@
mod util; mod util;
#[cfg(num_nonzero_signed)]
mod nonzero_ints {
use super::*; use super::*;
use schemars::JsonSchema; use schemars::JsonSchema;
use util::*; use util::*;
@ -18,4 +16,3 @@ mod nonzero_ints {
fn nonzero_ints() -> TestResult { fn nonzero_ints() -> TestResult {
test_default_generated_schema::<MyStruct>("nonzero_ints") test_default_generated_schema::<MyStruct>("nonzero_ints")
} }
}