Stream: t-compiler/rust-analyzer

Topic: Syntax_Errors


std::Veetaha (Feb 17 2020 at 21:09, on Zulip):

Is this actually expected that we report multiple errors for a single TextUnit in this test here @matklad ?

std::Veetaha (Feb 17 2020 at 21:11, on Zulip):

I would also display the token textual repr itself here instead of R_PAREN etc., but that's another topic...

matklad (Feb 17 2020 at 21:15, on Zulip):

Yes, it is expected

matklad (Feb 17 2020 at 21:16, on Zulip):

More specifically, at this stage it doesn't really makes sense to optimize syntax error representation a lot: as long as there's a red line in the editor, we are all good for the time being

Laurențiu (Feb 17 2020 at 21:18, on Zulip):

I don't see those errors in Code, but they do show up in vim from time to time (cargo check gives better errors when it runs)

Laurențiu (Feb 17 2020 at 21:18, on Zulip):

pasted image

std::Veetaha (Feb 17 2020 at 21:32, on Zulip):

By representation you mean converting R_PAREN to ), right? Because I am currently working on that PR of reshaping SyntaxError.

std::Veetaha (Feb 17 2020 at 21:33, on Zulip):

I mean I am not working of converting R_PAREN -> ), ah...

std::Veetaha (Feb 17 2020 at 22:17, on Zulip):

Hmm, I remember that automatic addition of /// for doc comments worked, or am I drunk? comments.gif

matklad (Feb 17 2020 at 22:18, on Zulip):

It works, but impl changed from ontype handler to a custom Enter keybinding

std::Veetaha (Feb 17 2020 at 22:19, on Zulip):

One big flaw to this, is once I have removed that binding, I cannot add it back

std::Veetaha (Feb 17 2020 at 22:23, on Zulip):

Though, I can add it back via messing with keybindings.json

Benn Sundsrud (Feb 18 2020 at 11:27, on Zulip):

I'm having an issue where ra isn't highlighting certain errors until I safe, e.g. fn foo() -> u32 {} doesn't note that the return type of the block is wrong until save. This is in emacs with lsp-mode. Is this known or something weird with my setup?

Laurențiu (Feb 18 2020 at 11:28, on Zulip):

We run cargo check on project load and when saving a file, but not while typing (as cargo needs the files to be on disk), so most diagnostics will only show up then. There are some diagnostics implemented in rust-analyzer, e.g. parse errors should show up immediately, but not type mismatches.

Benn Sundsrud (Feb 18 2020 at 11:39, on Zulip):

ah k. Good to know it's not my setup, thanks! Also, who's emacs setup was that in the RA changelog posted on reddit, and is their .emacs public somewhere

matklad (Feb 18 2020 at 11:42, on Zulip):

I'd look at Florian Diebold 's emacs config: https://github.com/flodiebold/dotfiles/commit/b412b230ae52eec4a46651c2eb692a42aaa686ea

Florian Diebold (Feb 18 2020 at 12:03, on Zulip):

well, I use a hacked-together spacemacs layer... if you don't use spacemacs, I'd look into rustic

Benn Sundsrud (Feb 18 2020 at 12:04, on Zulip):

I just tried to switch from my rust-mode setup to rustic and trying to get rustfmt to work the way I want on save was not great

Laurențiu (Feb 18 2020 at 12:11, on Zulip):

@matklad do you think we could emit diagnosis for type mismatches if the false positive rate wasn't so large? I guess we already infer the types.

Florian Diebold (Feb 18 2020 at 12:12, on Zulip):

yes, we even already record type mismatches (and use them for one assist)

Florian Diebold (Feb 18 2020 at 12:12, on Zulip):

but the false positive rate is too large (you can see for yourself by running analysis-stats with -v)

Laurențiu (Feb 18 2020 at 12:12, on Zulip):

Maybe by next February, then :smiley:

Florian Diebold (Feb 18 2020 at 12:13, on Zulip):

I kind of hope we'll have a mostly-complete type system by then :thinking:

Laurențiu (Feb 18 2020 at 12:13, on Zulip):

Hmm, which assist is that?

Florian Diebold (Feb 18 2020 at 12:13, on Zulip):

if not merged with rustc, of course

Florian Diebold (Feb 18 2020 at 12:14, on Zulip):

Hmm, which assist is that?

there's a "wrap with Ok" assist that triggers if you forget to wrap your return value in Ok

Laurențiu (Feb 18 2020 at 12:15, on Zulip):

I keep forgetting about these.

Florian Diebold (Feb 18 2020 at 12:15, on Zulip):

we could probably do more of these :thinking:

matklad (Feb 18 2020 at 12:25, on Zulip):

I think we should emit all the errors we can, but hide them being a disable by default feature flag

matklad (Feb 18 2020 at 12:25, on Zulip):

and we probably should do that first for nameres errors

matklad (Feb 18 2020 at 12:25, on Zulip):

really, that's one great question @Laurențiu Nicola , this is a bit of work that we need to do soon!

Kirill Bulatov (Feb 18 2020 at 12:28, on Zulip):

and we probably should do that first for nameres errors

That should also work well with the auto import assist we have: there's a possibility to specify a quickfix for the diagnostics.

Laurențiu (Feb 22 2020 at 16:36, on Zulip):

Florian Diebold said:

but the false positive rate is too large (you can see for yourself by running analysis-stats with -v)

src/db.rs 32:52-32:54: Expected &dyn AstDatabase, got &dyn AstDatabase

src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String
src/codegen/gen_syntax.rs 3:4-3:7: Expected str, got String

I'm not sure what I'm looking at :slight_smile:. gen_syntax.rs 3:4 is inside a doc comment.

Florian Diebold (Feb 22 2020 at 16:49, on Zulip):

that's inside a macro, we don't map the spans correctly there

Laurențiu (Feb 22 2020 at 16:50, on Zulip):

Ah.

Last update: Jul 26 2021 at 12:30UTC