-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit a better error for abi3 inheritance
- Loading branch information
Showing
5 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use pyo3::exceptions::PyException; | ||
use pyo3::prelude::*; | ||
|
||
#[pyclass(extends=PyException)] | ||
#[derive(Clone)] | ||
struct MyException { | ||
code: u32, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0277]: the trait bound `PyException: PyClassBaseType` is not satisfied | ||
--> tests/diagnostic_namespace/abi3_inheritance.rs:4:19 | ||
| | ||
4 | #[pyclass(extends=PyException)] | ||
| ^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyException`, which is required by `PyException: PyClassBaseType` | ||
| | ||
= note: with the `abi3` feature enabled native types cannot be subclassed | ||
= help: the trait `PyClassBaseType` is implemented for `PyAny` | ||
= note: required for `PyException` to implement `PyClassBaseType` | ||
note: required by a bound in `PyClassImpl::BaseType` | ||
--> src/impl_/pyclass.rs | ||
| | ||
| type BaseType: PyTypeInfo + PyClassBaseType; | ||
| ^^^^^^^^^^^^^^^ required by this bound in `PyClassImpl::BaseType` | ||
|
||
error[E0277]: the trait bound `PyException: PyClass` is not satisfied | ||
--> tests/diagnostic_namespace/abi3_inheritance.rs:4:1 | ||
| | ||
4 | #[pyclass(extends=PyException)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyException`, which is required by `PyException: PyClassBaseType` | ||
| | ||
= help: the trait `PyClass` is implemented for `MyException` | ||
= note: required for `PyException` to implement `PyClassBaseType` | ||
= note: this error originates in the attribute macro `pyclass` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters