Skip to content

Put back "try with rustc --explain E0XXX" #48041

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
GuillaumeGomez opened this issue Feb 6, 2018 · 6 comments
Closed

Put back "try with rustc --explain E0XXX" #48041

GuillaumeGomez opened this issue Feb 6, 2018 · 6 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

This sentence has been removed here in this PR. However, I think it's quite useful considering the amount of extra information it provides.

cc @rust-lang/compiler

@kennytm kennytm added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Feb 6, 2018
@estebank
Copy link
Contributor

estebank commented Feb 6, 2018

I would like to wait for a bit until we have a good story and coverage around -Zteach (at least on nightly). I think that's going to be more useful than always suggesting --explain E0XXX.

@GuillaumeGomez
Copy link
Member Author

The old "--explain" suggestion system was a bit heavy. By rewording it, it might be better than what it was. However, -Zteach seems to be a potential great replacement in the future. I think that at first, we should put back --explain while waiting for -Zteach to be complete. What do you think about this?

@estebank
Copy link
Contributor

estebank commented Feb 6, 2018

I think it is reasonable to go that way. I don't know if there was any conversation before removal. I would be very much in favor of having a single note suggesting using --explain generically though. I wouldn't want to add 2 more lines per error with a code, it is redundant and would get old very quickly. It'd be even great if there were a way to silence it (which makes me go back to the increasing need of having a rustc.toml config file somewhere...).

@GuillaumeGomez
Copy link
Member Author

I was thinking about just adding a line at the end of errors. Something like: "You got error(s), if you want more explanations about this/them, try with rustc --explain E0XXX" (XXX being one of the errors reported).

@nikomatsakis
Copy link
Contributor

I like the idea of putting it as part of the final "here's how many errors you got" message.

@GuillaumeGomez
Copy link
Member Author

I'll write a PR and we'll iterate about the formulation then.

@GuillaumeGomez GuillaumeGomez self-assigned this Feb 7, 2018
bors added a commit that referenced this issue Feb 26, 2018
Rustc explain

Fixes #48041.

To make the review easier, I separated tests update to code update. Also, I used this script to generate new ui tests stderr:

```python
from os import listdir
from os.path import isdir, isfile, join

PATH = "src/test/ui"

def do_something(path):
    files = [join(path, f) for f in listdir(path)]

    for f in files:
        if isdir(f):
            do_something(f)
            continue
        if not isfile(f) or not f.endswith(".stderr"):
            continue
        x = open(f, "r")
        content = x.read().strip()
        if "error[E" not in content:
            continue
        errors = dict()
        for y in content.splitlines():
            if y.startswith("error[E"):
                errors[y[6:11]] = True
        errors = sorted(errors.keys())
        if len(errors) < 1:
            print("weird... {}".format(f))
            continue
        if len(errors) > 1:
            content += "\n\nYou've got a few errors: {}".format(", ".join(errors))
            content += "\nIf you want more information on an error, try using \"rustc --explain {}\"".format(errors[0])
        else:
            content += "\n\nIf you want more information on this error, try using \"rustc --explain {}\"".format(errors[0])
        content += "\n"
        x = open(f, "w")
        x.write(content)

do_something(PATH)
```
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants