Bump MSRV to 1.36.0
This commit is contained in:
parent
7a1e02eefd
commit
5ca2d08013
8 changed files with 38 additions and 82 deletions
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[](https://github.com/GREsau/schemars/actions)
|
||||
[](https://crates.io/crates/schemars)
|
||||
[](https://docs.rs/schemars)
|
||||
[](https://blog.rust-lang.org/2019/01/17/Rust-1.32.0.html)
|
||||
[](https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html)
|
||||
|
||||
Generate JSON Schema documents from Rust code
|
||||
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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<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()
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::schema::{RootSchema, Schema, SchemaObject, SingleOrVec};
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// TODO document
|
||||
pub trait Visitor {
|
||||
|
|
|
@ -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::<MyStruct>("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::<MyStruct>("nonzero_ints")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue