Closed cjhopman closed 4 years ago
Both of these are a consequence of this compiler bug: https://github.com/rust-lang/rust/issues/43081. It would be better not to nest attribute macro invocations on items until that is fixed.
This will be fixed by https://github.com/rust-lang/rust/pull/72306
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: