-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Describe the bug
Right now
To Reproduce
Attempting to compile something where Result is aliased to something with a different signature (which I feel is a common pattern), fails to compile bc the proc macro generates code that uses that type, rather than the std::result::Result. For example this code:
use parquet_derive::ParquetRecordReader;
#[derive(Debug)]
enum MyInternalError {
IForgotSomething,
ExpectecNotEmpty,
}
pub type Result = std::result::Result<(), MyInternalError>;
#[derive(Debug, ParquetRecordReader)]
struct MyRecord {
name: String,
age: u32,
}
fn main() {
println!("Hello, world!");
}Fails to compile (cargo b) with this error (minor edits to remove some paths...)
error[E0107]: type alias takes 0 generic arguments but 2 generic arguments were supplied
--> src/main.rs:13:17
|
13 | #[derive(Debug, ParquetRecordReader)]
| ^^^^^^^^^^^^^^^^^^^ expected 0 generic arguments
|
note: type alias defined here, with 0 generic parameters
--> src/main.rs:11:10
|
11 | pub type Result = std::result::Result<(), MyInternalError>;
| ^^^^^^
= note: this error originates in the derive macro `ParquetRecordReader` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0053]: method `read_from_row_group` has an incompatible type for trait
--> src/main.rs:13:17
|
13 | #[derive(Debug, ParquetRecordReader)]
| ^^^^^^^^^^^^^^^^^^^ expected `ParquetError`, found `MyInternalError`
|
= note: expected signature `fn(&mut Vec<_>, &mut dyn RowGroupReader, _) -> std::result::Result<_, ParquetError>`
found signature `fn(&mut Vec<_>, &mut dyn RowGroupReader, _) -> std::result::Result<_, MyInternalError>`
= note: this error originates in the derive macro `ParquetRecordReader` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> src/main.rs:13:17
|
13 | #[derive(Debug, ParquetRecordReader)]
| ^^^^^^^^^^^^^^^^^^^
| |
| expected `MyInternalError`, found `ParquetError`
| arguments to this enum variant are incorrect
|
help: the type constructed contains `ParquetError` due to the type of the argument passed
--> src/main.rs:13:17
|
13 | #[derive(Debug, ParquetRecordReader)]
| ^^^^^^^^^^^^^^^^^^^ this argument influences the type of `Err`
note: tuple variant defined here
--> $HOME/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:537:5
|
537 | Err(#[stable(feature = "rust1", since = "1.0.0")] E),
| ^^^
= note: this error originates in the derive macro `ParquetRecordReader` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: `?` couldn't convert the error to `MyInternalError`
--> src/main.rs:13:35
|
13 | #[derive(Debug, ParquetRecordReader)]
| ------------------^
| | |
| | the trait `From<ParquetError>` is not implemented for `MyInternalError`
| this can't be annotated with `?` because it has type `Result<_, ParquetError>`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the trait `FromResidual<std::result::Result<Infallible, E>>` is implemented for `std::result::Result<T, F>`
= note: required for `std::result::Result<(), MyInternalError>` to implement `FromResidual<std::result::Result<Infallible, ParquetError>>`
= note: this error originates in the derive macro `ParquetRecordReader` (in Nightly builds, run with -Z macro-backtrace for more info)
Some errors have detailed explanations: E0053, E0107, E0277, E0308.
For more information about an error, try `rustc --explain E0053`.
error: could not compile `parquet_derive_test` (bin "parquet_derive_test") due to 4 previous errors
Expected behavior
Succesful compilation.
Additional context
None that I am aware of.