Skip to content

Commit

Permalink
Make rust happy
Browse files Browse the repository at this point in the history
  • Loading branch information
mejrs committed Jul 2, 2022
1 parent 126e193 commit 8317e47
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/impl_/frompyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ pub fn failed_to_extract_enum(
);
for ((variant_name, error_name), error) in variant_names.iter().zip(error_names).zip(errors) {
use std::fmt::Write;

err_msg.push('\n');
write!(
&mut err_msg,
"- variant {variant_name} ({error_name}): {error_msg}",
"\n- variant {variant_name} ({error_name}): {error_msg}",
variant_name = variant_name,
error_name = error_name,
error_msg = extract_traceback(py, error.clone_ref(py)),
Expand All @@ -36,7 +34,7 @@ fn extract_traceback(py: Python<'_>, mut error: PyErr) -> String {

let mut error_msg = error.to_string();
while let Some(cause) = error.cause(py) {
write!(&mut error_msg, ", caused by {}", cause).unwrap();
write!(&mut error_msg, ", caused by {}", cause).unwrap();
error = cause
}
error_msg
Expand Down
3 changes: 3 additions & 0 deletions tests/test_compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ fn _test_compile_errors() {
t.compile_fail("tests/ui/invalid_pymethod_receiver.rs");
t.compile_fail("tests/ui/invalid_result_conversion.rs");
t.compile_fail("tests/ui/missing_intopy.rs");

// Only run this with these features to avoid different outputs
#[cfg(all(feature = "full", not(feature = "abi3")))]
t.compile_fail("tests/ui/missing_clone.rs");
}

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/abi3_nativetype_inheritance.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ error[E0277]: the trait bound `PyDict: PyClass` is not satisfied
5 | #[pyclass(extends=PyDict)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyDict`
|
= help: the trait `PyClass` is implemented for `TestClass`
= note: required because of the requirements on the impl of `PyClassBaseType` for `PyDict`
= note: this error originates in the attribute macro `pyclass` (in Nightly builds, run with -Z macro-backtrace for more info)

Expand All @@ -13,6 +14,7 @@ error[E0277]: the trait bound `PyDict: PyClass` is not satisfied
5 | #[pyclass(extends=PyDict)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyDict`
|
= help: the trait `PyClass` is implemented for `TestClass`
= note: required because of the requirements on the impl of `PyClassBaseType` for `PyDict`
note: required by a bound in `PyRefMut`
--> src/pycell.rs
Expand All @@ -27,6 +29,7 @@ error[E0277]: the trait bound `PyDict: PyClass` is not satisfied
5 | #[pyclass(extends=PyDict)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyDict`
|
= help: the trait `PyClass` is implemented for `TestClass`
= note: required because of the requirements on the impl of `PyClassBaseType` for `PyDict`
note: required by a bound in `ThreadCheckerInherited`
--> src/impl_/pyclass.rs
Expand Down

0 comments on commit 8317e47

Please sign in to comment.