You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiling playground v0.0.1 (/playground)
error[E0422]: cannot find struct, variant or union type `Unknown` in this scope
--> src/lib.rs:34:9
|
34 | #[async_trait]
| ^^^^^^^^^^^^^^ not found in this scope
|
help: possible candidates are found in other modules, you can import them into scope
|
Note that it marks the macro invocation itself. Making the change that is commented (i.e. adding a redundant () around Vec<()> will make it report the error correctly:
error[E0422]: cannot find struct, variant or union type `Unknown` in this scope
--> src/lib.rs:42:17
|
42 | Unknown{}.foo()
| ^^^^^^^ not found in this scope
|
help: possible candidates are found in other modules, you can import them into scope
|
error[E0107]: wrong number of type arguments: expected 2, found 1
error: aborting due to previous error
That doesn't even point to the async_trait use at all (which makes it quite difficult to diagnose).
Again, adding the () around Vec<()> fixes the reporting:
error[E0107]: wrong number of type arguments: expected 2, found 1
--> src/lib.rs:36:26
|
36 | type Value = Result<(Vec<()>)>;
| ^^^^^^^^^^^^^^^^^ expected 2 type arguments
error: aborting due to previous error
The text was updated successfully, but these errors were encountered:
Both of these are a consequence of this compiler bug: rust-lang/rust#43081. It would be better not to nest attribute macro invocations on items until that is fixed.
Confirmed fixed in rustc master. The error from the above repro looks like:
error[E0422]: cannot find struct, variant or union type `Unknown` in this scope --> src/main.rs:42:17 |42 | Unknown{}.foo() | ^^^^^^^ not found in this scope |help: consider importing one of these items |2 | use core::fmt::rt::v1::Alignment::Unknown; |2 | use std::fmt::rt::v1::Alignment::Unknown; |error[E0107]: wrong number of type arguments: expected 2, found 1 --> src/main.rs:36:26 |36 | type Value = Result<Vec<()>>; | ^^^^^^^^^^^^^^^ expected 2 type arguments
Note: not sure if this is a compiler bug or an async_trait bug.
This code reports an error incorrectly:
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f5fbf51f00d3755d6bc3a025e75f3d30
It reports the error as:
Note that it marks the macro invocation itself. Making the change that is commented (i.e. adding a redundant
()
aroundVec<()>
will make it report the error correctly:It does this even worse for some other errors. If you replace that
Unknown{}.foo()
withtodo!()
(https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=95645128b3ff65057921bbd952f0005b) you'll get this error:That doesn't even point to the async_trait use at all (which makes it quite difficult to diagnose).
Again, adding the
()
aroundVec<()>
fixes the reporting:The text was updated successfully, but these errors were encountered: