Open
Description
Code
#[pyfunction]
fn return_object(py: Python<'_>, x:PyObject) -> i64 {
let a = x.getattr(py, attr_name: size);
return a;
}
Current output
error: expected identifier, found `:`
--> src/lib.rs:44:34
|
44 | let a = x.getattr(py, attr_name: size);
| ^ expected identifier
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
error: could not compile `tryout-pyo3` (lib) due to previous error
Desired output
error: expected identifier, found `:`
--> src/lib.rs:44:34
|
44 | let a = x.getattr(py, attr_name: size);
| ^^^^^^^^^^^^^^^ you cannot use named arguments
|
help: try passing a value instead?
|
44 | let a = x.getattr(py, size);
error: could not compile `tryout-pyo3` (lib) due to previous error
Rationale and extra context
Many close variations emit really bad diagnostics as well, often referencing type ascription, and all of these variations being really bad causes incredible amounts of thrashing while trying to learn Rust.
Other cases
No response
Anything else?
Note that this suggestion also is wrong, it should be "size"
, because &'static str
(and probably a few other relevant types) implements IntoPy for PyString.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.