rust/src/test
bors 82cf3a4486 Auto merge of #66314 - GuillaumeGomez:move-error-codes, r=Centril
Move error codes

Works towards #66210.

r? @Centril

Oh btw, for the ones interested, I used this python script to get all error codes content sorted into one final file:

<details>

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

def get_error_codes(error_codes, f_path):
    with open(f_path) as f:
        short_mode = False
        lines = f.read().split("\n")
        i = 0
        while i < len(lines):
            line = lines[i]
            if not short_mode and line.startswith("E0") and line.endswith(": r##\""):
                error = line
                error += "\n"
                i += 1
                while i < len(lines):
                    line = lines[i]
                    error += line
                    if line.endswith("\"##,"):
                        break
                    error += "\n"
                    i += 1
                error_codes["long"].append(error)
            elif line == ';':
                short_mode = True
            elif short_mode is True and len(line) > 0 and line != "}":
                error_codes["short"].append(line)
                while i + 1 < len(lines):
                    line = lines[i + 1].strip()
                    if not line.startswith("//"):
                        break
                    parts = line.split("//")
                    if len(parts) < 2:
                        break
                    if parts[1].strip().startswith("E0"):
                        break
                    error_codes["short"][-1] += "\n"
                    error_codes["short"][-1] += lines[i + 1]
                    i += 1
            i += 1

def loop_dirs(error_codes, cur_dir):
    for entry in listdir(cur_dir):
        f = join(cur_dir, entry)
        if isfile(f) and entry == "error_codes.rs":
            get_error_codes(error_codes, f)
        elif isdir(f) and not entry.startswith("librustc_error_codes"):
            loop_dirs(error_codes, f)

def get_error_code(err):
    x = err.split(",")
    if len(x) < 2:
        return err
    x = x[0]
    if x.strip().startswith("//"):
        x = x.split("//")[1].strip()
    return x.strip()

def write_into_file(error_codes, f_path):
    with open(f_path, "w") as f:
        f.write("// Error messages for EXXXX errors.  Each message should start and end with a\n")
        f.write("// new line, and be wrapped to 80 characters.  In vim you can `:set tw=80` and\n")
        f.write("// use `gq` to wrap paragraphs. Use `:set tw=0` to disable.\n\n")
        f.write("syntax::register_diagnostics! {\n\n")
        error_codes["long"].sort()
        for i in error_codes["long"]:
            f.write(i)
            f.write("\n\n")
        f.write(";\n")
        error_codes["short"] = sorted(error_codes["short"], key=lambda err: get_error_code(err))
        for i in error_codes["short"]:
            f.write(i)
            f.write("\n")
        f.write("}\n")

error_codes = {
    "long": [],
    "short": []
}
loop_dirs(error_codes, "src")
write_into_file(error_codes, "src/librustc_error_codes/src/error_codes.rs")
```
</details>

And to move the error codes into their own files:

<details>

```python
import os

try:
    os.mkdir("src/librustc_error_codes/error_codes")
except OSError:
    print("Seems like folder already exist, moving on!")
data = ''
with open("src/librustc_error_codes/error_codes.rs") as f:
    x = f.read().split('\n')
    i = 0
    short_part = False
    while i < len(x):
        line = x[i]
        if short_part is False and line.startswith('E0') and line.endswith(': r##"'):
            err_code = line.split(':')[0]
            i += 1
            content = ''
            while i < len(x):
                if x[i] == '"##,':
                    break
                content += x[i]
                content += '\n'
                i += 1
            f_path = "src/librustc_error_codes/error_codes/{}.md".format(err_code)
            with open(f_path, "w") as ff:
                ff.write(content)
            data += '{}: include_str!("./error_codes/{}.md"),'.format(err_code, err_code)
        elif short_part is False and line == ';':
            short_part is True
            data += ';\n'
        else:
            data += line
            data += '\n'
        i += 1
with open("src/librustc_error_codes/error_codes.rs", "w") as f:
    f.write(data)
```
</details>
2019-11-14 14:11:38 +00:00
..
assembly
auxiliary
codegen Do not require extra LLVM backends for x.py test to pass 2019-11-04 16:54:34 +03:00
codegen-units Update test output. 2019-10-25 14:52:39 +02:00
compile-fail Bless less verbose error messages 2019-11-13 10:44:14 -08:00
debuginfo fix debuginfo/issue22656 with LLDB 8 2019-09-18 10:42:55 -04:00
incremental Rollup merge of #66216 - wesleywiser:const_prop_codegen_improvements, r=oli-obk 2019-11-10 09:27:17 +09:00
mir-opt Auto merge of #66233 - cjgillot:constkind, r=oli-obk 2019-11-14 04:54:51 +00:00
pretty Fix a previously forgotten pretty-printing test after a change to the pretty-printing mechanism. 2019-10-28 18:43:59 +01:00
run-fail [const-prop] Handle MIR Rvalue::Aggregates 2019-10-18 06:29:57 -04:00
run-make Upgrade Emscripten targets to use upstream LLVM backend 2019-10-16 17:06:48 -07:00
run-make-fulldeps Add a callback that allows compiler consumers to override queries. 2019-11-11 19:29:34 +01:00
run-pass-valgrind
rustdoc Auto merge of #66211 - kinnison:kinnison/fix-66159, r=GuillaumeGomez 2019-11-13 23:22:03 +00:00
rustdoc-js
rustdoc-js-std
rustdoc-ui Rollup merge of #66166 - GuillaumeGomez:rename-rustdoc-to-doc, r=QuietMisdreavus 2019-11-13 22:09:13 +09:00
rustfix
ui Auto merge of #66314 - GuillaumeGomez:move-error-codes, r=Centril 2019-11-14 14:11:38 +00:00
ui-fulldeps Add warning annotations to ignore-stage1 ui-fulldeps tests 2019-11-10 21:00:59 +01:00
COMPILER_TESTS.md