Merge pull request #2284 from mejrs/rust160

Rust 1.60
This commit is contained in:
David Hewitt 2022-04-08 07:45:15 +01:00 committed by GitHub
commit 209221890c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

View File

@ -16,22 +16,26 @@ impl BytesExtractor {
BytesExtractor {}
}
pub fn from_bytes(&mut self, bytes: &PyBytes) -> PyResult<usize> {
#[staticmethod]
pub fn from_bytes(bytes: &PyBytes) -> PyResult<usize> {
let byte_vec: Vec<u8> = bytes.extract()?;
Ok(byte_vec.len())
}
pub fn from_str(&mut self, string: &PyString) -> PyResult<usize> {
#[staticmethod]
pub fn from_str(string: &PyString) -> PyResult<usize> {
let rust_string: String = string.extract()?;
Ok(rust_string.len())
}
pub fn from_str_lossy(&mut self, string: &PyString) -> usize {
#[staticmethod]
pub fn from_str_lossy(string: &PyString) -> usize {
let rust_string_lossy: String = string.to_string_lossy().to_string();
rust_string_lossy.len()
}
pub fn from_buffer(&mut self, buf: &PyAny) -> PyResult<usize> {
#[staticmethod]
pub fn from_buffer(buf: &PyAny) -> PyResult<usize> {
let buf = PyBuffer::<u8>::get(buf)?;
Ok(buf.item_count())
}

View File

@ -47,6 +47,7 @@ fn _test_compile_errors() {
tests_rust_1_56(&t);
tests_rust_1_57(&t);
tests_rust_1_58(&t);
tests_rust_1_60(&t);
#[rustversion::since(1.49)]
fn tests_rust_1_49(t: &trybuild::TestCases) {
@ -79,7 +80,6 @@ fn _test_compile_errors() {
#[rustversion::since(1.58)]
fn tests_rust_1_58(t: &trybuild::TestCases) {
t.compile_fail("tests/ui/invalid_pyfunctions.rs");
t.compile_fail("tests/ui/invalid_pymethod_receiver.rs");
t.compile_fail("tests/ui/invalid_pymethods.rs");
t.compile_fail("tests/ui/missing_clone.rs");
t.compile_fail("tests/ui/not_send.rs");
@ -91,6 +91,14 @@ fn _test_compile_errors() {
#[rustversion::before(1.58)]
fn tests_rust_1_58(_t: &trybuild::TestCases) {}
#[rustversion::since(1.60)]
fn tests_rust_1_60(t: &trybuild::TestCases) {
t.compile_fail("tests/ui/invalid_pymethod_receiver.rs");
}
#[rustversion::before(1.60)]
fn tests_rust_1_60(_t: &trybuild::TestCases) {}
}
#[cfg(feature = "nightly")]

View File

@ -9,6 +9,6 @@ error[E0277]: the trait bound `i32: From<&PyCell<MyClass>>` is not satisfied
<i32 as From<bool>>
<i32 as From<i16>>
<i32 as From<i8>>
and 2 others
and 71 others
= note: required because of the requirements on the impl of `Into<i32>` for `&PyCell<MyClass>`
= note: required because of the requirements on the impl of `TryFrom<&PyCell<MyClass>>` for `i32`