diff --git a/Cargo.lock b/Cargo.lock index 3acd27383..827aab3e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "cast" -version = "0.2.3" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" dependencies = [ "rustc_version", ] @@ -297,12 +297,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "core-foundation" version = "0.7.0" @@ -598,18 +592,6 @@ dependencies = [ "syn", ] -[[package]] -name = "derive_more" -version = "0.99.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b1b72f1263f214c0f823371768776c4f5841b942c9883aa8e5ec584fd0ba6" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "diff" version = "0.1.12" @@ -1816,23 +1798,13 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc_version" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ "semver", ] -[[package]] -name = "rustc_version_runtime" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4076135c155c07b05e4ab54ba0834aca3fc6a5a01610a2339f5ef3223cf8dee5" -dependencies = [ - "rustc_version", - "semver", -] - [[package]] name = "rustpython" version = "0.1.2" @@ -1882,7 +1854,6 @@ name = "rustpython-common" version = "0.0.0" dependencies = [ "cfg-if 1.0.0", - "derive_more", "hexf-parse", "lexical-core", "lock_api", @@ -2038,7 +2009,7 @@ dependencies = [ "rand 0.8.3", "rand_core 0.6.2", "result-like", - "rustc_version_runtime", + "rustc_version", "rustpython-ast", "rustpython-bytecode", "rustpython-common", @@ -2161,18 +2132,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "0.9.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "serde" diff --git a/common/Cargo.toml b/common/Cargo.toml index 833a392d8..09ca92116 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -19,6 +19,5 @@ cfg-if = "1.0" once_cell = "1.4.1" siphasher = "0.3" rand = "0.8" -derive_more = "0.99.9" volatile = "0.3" radium = "0.6" diff --git a/common/src/borrow.rs b/common/src/borrow.rs index 00a0b4771..d738c4b02 100644 --- a/common/src/borrow.rs +++ b/common/src/borrow.rs @@ -4,7 +4,19 @@ use crate::lock::{ }; use std::ops::{Deref, DerefMut}; -#[derive(Debug, derive_more::From)] +macro_rules! impl_from { + ($lt:lifetime, $gen:ident, $t:ty, $($var:ident($from:ty),)*) => { + $( + impl<$lt, $gen: ?Sized> From<$from> for $t { + fn from(t: $from) -> Self { + Self::$var(t) + } + } + )* + }; +} + +#[derive(Debug)] pub enum BorrowedValue<'a, T: ?Sized> { Ref(&'a T), MuLock(PyMutexGuard<'a, T>), @@ -12,6 +24,13 @@ pub enum BorrowedValue<'a, T: ?Sized> { ReadLock(PyRwLockReadGuard<'a, T>), MappedReadLock(PyMappedRwLockReadGuard<'a, T>), } +impl_from!('a, T, BorrowedValue<'a, T>, + Ref(&'a T), + MuLock(PyMutexGuard<'a, T>), + MappedMuLock(PyImmutableMappedMutexGuard<'a, T>), + ReadLock(PyRwLockReadGuard<'a, T>), + MappedReadLock(PyMappedRwLockReadGuard<'a, T>), +); impl<'a, T: ?Sized> BorrowedValue<'a, T> { pub fn map(s: Self, f: F) -> BorrowedValue<'a, U> @@ -45,7 +64,7 @@ impl Deref for BorrowedValue<'_, T> { } } -#[derive(Debug, derive_more::From)] +#[derive(Debug)] pub enum BorrowedValueMut<'a, T: ?Sized> { RefMut(&'a mut T), MuLock(PyMutexGuard<'a, T>), @@ -53,6 +72,13 @@ pub enum BorrowedValueMut<'a, T: ?Sized> { WriteLock(PyRwLockWriteGuard<'a, T>), MappedWriteLock(PyMappedRwLockWriteGuard<'a, T>), } +impl_from!('a, T, BorrowedValueMut<'a, T>, + RefMut(&'a mut T), + MuLock(PyMutexGuard<'a, T>), + MappedMuLock(PyMappedMutexGuard<'a, T>), + WriteLock(PyRwLockWriteGuard<'a, T>), + MappedWriteLock(PyMappedRwLockWriteGuard<'a, T>), +); impl<'a, T: ?Sized> BorrowedValueMut<'a, T> { pub fn map(s: Self, f: F) -> BorrowedValueMut<'a, U> diff --git a/vm/Cargo.toml b/vm/Cargo.toml index d191d1cf1..a452bcdbb 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -54,7 +54,6 @@ rustpython-bytecode = { path = "../bytecode", version = "0.1.2" } rustpython-jit = { path = "../jit", optional = true, version = "0.1.2" } rustpython-pylib = { path = "pylib-crate", optional = true, version = "0.1.0" } serde = { version = "1.0.66", features = ["derive"] } -rustc_version_runtime = "0.2.0" puruspe = "0.1" caseless = "0.2.1" chrono = { version = "0.4", features = ["wasmbind"] } @@ -159,3 +158,4 @@ wasm-bindgen = "0.2" [build-dependencies] itertools = "0.10.0" +rustc_version = "0.4" diff --git a/vm/build.rs b/vm/build.rs index 1ad01760b..c1daf2eb4 100644 --- a/vm/build.rs +++ b/vm/build.rs @@ -12,6 +12,10 @@ fn main() { ); println!("cargo:rustc-env=RUSTPYTHON_GIT_TAG={}", git_tag()); println!("cargo:rustc-env=RUSTPYTHON_GIT_BRANCH={}", git_branch()); + println!( + "cargo:rustc-env=RUSTC_VERSION={}", + rustc_version::version().unwrap() + ); println!( "cargo:rustc-env=RUSTPYTHON_TARGET_TRIPLE={}", diff --git a/vm/src/version.rs b/vm/src/version.rs index d2935d107..32952cb6b 100644 --- a/vm/src/version.rs +++ b/vm/src/version.rs @@ -59,8 +59,7 @@ pub fn get_version_number() -> String { } pub fn get_compiler() -> String { - let rustc_version = rustc_version_runtime::version_meta(); - format!("rustc {}", rustc_version.semver) + format!("rustc {}", env!("RUSTC_VERSION")) } pub fn get_build_info() -> String {