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
This produces an error on the penultimate line in rust analyzer: expected <impl EmptyFoo as Foo>::A, found (). This is confusing, since the associated type A of trait Foo for any type implementing EmptyFoois(). It conflicts with rustc, which compiles and runs the code without error.
If the parameter type for foo is just Self::A (and we pass () as the parameter), there is no error.
The text was updated successfully, but these errors were encountered:
The same issue occurs without the unstable trait aliases feature, so it affects stable rust.
Artemis21
changed the title
Error when rustc reports none, related to associated types on trait aliases
Error when rustc reports none, related to associated types on supertraits/trait aliases
Oct 15, 2022
We haven't implemented trait aliases properly (#2773). #2773 (comment) describes how we currently handle them, but it differs from the correct semantics.
That said, we should be able to deduce the associated type in both snippets (even with our current handling of trait aliases). I think this is on chalk but need to investigate further.
I'm seeing something similar, I think, with the latest nightly: rustc 1.70.0-nightly (4087deacc 2023-04-12)
fnno_alias() -> impl nom::Parser<(),(),()>{
|_| todo!()}traitUnitParserAlias = nom::Parser<(),(),()>;fnalias() -> implUnitParserAlias{
|_| todo!()}letmut ok = no_alias();
ok.parse(());letmut nope = alias();
nope.parse(());// this `parse` method compiles fine, but isn't found by rust-analyzer
Notice how rust-analyzer can't tell that parse is an &mut method in the second example (there's no underline); it also doesn't auto-complete or display documentation on hover or offer go-to-definition.
Explicitly using a supertrait as suggested by the previous implementation seems to avoid the analysis failure:
rust-analyzer version:
0.3.1238-standalone
and also1.66.0-nightly (a6b7274 2022-10-10)
rustc version:
rustc 1.66.0-nightly (a6b7274a4 2022-10-10)
This produces an error on the penultimate line in rust analyzer:
expected <impl EmptyFoo as Foo>::A, found ()
. This is confusing, since the associated typeA
of traitFoo
for any type implementingEmptyFoo
is()
. It conflicts with rustc, which compiles and runs the code without error.If the parameter type for
foo
is justSelf::A
(and we pass()
as the parameter), there is no error.The text was updated successfully, but these errors were encountered: