E0004
E0005
E0010
E0013
E0015
E0023
E0025
E0026
E0027
E0029
E0030
E0033
E0034
E0038
E0040
E0044
E0045
E0046
E0049
E0050
E0053
E0054
E0055
E0057
E0059
E0060
E0061
E0062
E0063
E0067
E0069
E0070
E0071
E0072
E0075
E0076
E0077
E0080
E0081
E0084
E0091
E0092
E0093
E0094
E0106
E0107
E0109
E0116
E0117
E0118
E0119
E0120
E0121
E0124
E0128
E0130
E0131
E0132
E0133
E0138
E0152
E0158
E0161
E0164
E0170
E0178
E0183
E0184
E0185
E0186
E0191
E0195
E0197
E0198
E0199
E0200
E0201
E0203
E0204
E0206
E0207
E0210
E0212
E0214
E0220
E0221
E0222
E0223
E0224
E0225
E0226
E0227
E0228
E0229
E0230
E0231
E0232
E0252
E0253
E0254
E0255
E0259
E0260
E0261
E0262
E0264
E0267
E0268
E0271
E0275
E0276
E0277
E0282
E0283
E0284
E0307
E0308
E0309
E0310
E0311
E0316
E0317
E0320
E0321
E0322
E0323
E0324
E0325
E0326
E0328
E0364
E0365
E0366
E0367
E0368
E0369
E0370
E0371
E0373
E0374
E0375
E0376
E0377
E0378
E0379
E0380
E0381
E0382
E0384
E0390
E0391
E0392
E0393
E0399
E0401
E0403
E0404
E0405
E0407
E0408
E0409
E0411
E0412
E0415
E0416
E0422
E0423
E0424
E0425
E0426
E0428
E0429
E0430
E0431
E0432
E0433
E0434
E0435
E0436
E0437
E0438
E0445
E0446
E0449
E0451
E0452
E0453
E0454
E0455
E0457
E0458
E0459
E0460
E0461
E0462
E0463
E0464
E0466
E0468
E0469
E0472
E0476
E0478
E0491
E0492
E0493
E0496
E0498
E0499
E0500
E0501
E0502
E0503
E0505
E0506
E0507
E0508
E0509
E0510
E0511
E0512
E0514
E0515
E0516
E0517
E0518
E0519
E0520
E0521
E0522
E0524
E0525
E0527
E0528
E0529
E0530
E0531
E0532
E0533
E0534
E0535
E0536
E0537
E0538
E0539
E0541
E0542
E0543
E0544
E0545
E0546
E0547
E0549
E0550
E0551
E0552
E0554
E0556
E0557
E0559
E0560
E0561
E0562
E0565
E0566
E0567
E0568
E0569
E0570
E0571
E0572
E0573
E0574
E0575
E0576
E0577
E0578
E0579
E0580
E0581
E0582
E0583
E0584
E0585
E0586
E0587
E0588
E0589
E0590
E0591
E0592
E0593
E0594
E0596
E0597
E0599
E0600
E0601
E0602
E0603
E0604
E0605
E0606
E0607
E0608
E0609
E0610
E0614
E0615
E0616
E0617
E0618
E0620
E0621
E0622
E0623
E0624
E0625
E0626
E0627
E0628
E0631
E0634
E0635
E0636
E0637
E0638
E0639
E0640
E0641
E0642
E0643
E0644
E0646
E0647
E0648
E0657
E0658
E0659
E0666
E0667
E0670
E0689
E0690
E0691
E0692
E0693
E0695
E0696
E0697
E0698
E0699
E0700
E0701
E0703
E0704
E0705
E0706
E0708
E0710
E0711
E0712
E0713
E0714
E0715
E0716
E0717
E0718
E0719
E0720
E0722
E0724
E0725
E0726
E0727
E0728
E0729
E0730
E0731
E0732
E0733
E0734
E0735
E0736
E0737
E0739
E0740
E0741
E0742
E0743
E0744
E0745
E0746
E0747
E0748
E0749
E0750
E0751
E0752
E0753
E0754
E0755
E0756
E0757
E0758
E0761
E0762
E0763
E0764
E0765
E0766
E0767
E0768
E0769
E0770
E0771
E0773
E0774
E0775
E0776
E0777
E0778
E0779
E0780
E0781
E0782
E0783
E0784
E0785
E0786
E0787
E0788
E0789
E0790
E0791
E0792
E0793
E0794
-
-
Save MahadMuhammad/8c9d5fc88ea18d8c520937a8071d4185 to your computer and use it in GitHub Desktop.
There are some errors which are not longer emitted by rustc-1.49.0.
Error code | Is Emitted by rustc-1.49.0 | Is Error generated by gccrs | Error support in gccrs | Description |
---|---|---|---|---|
E0001 |
No | Yes | Issue |
Unreachable Pattern in Match Statement |
E0002 |
No | No | - | Empty Match Expression on Non-Empty Type |
E0004 |
Yes | No | Issue |
Non-Exhaustive Patterns: Matching Error |
E0005 |
Yes | Yes | Issue |
Patterns used to bind names must be irrefutable , that is, they must guarantee that a name will be extracted in all cases. |
E0007 |
No | Yes | No | cannot bind by-move with sub-bindings |
E0010 |
Yes | Yes | No | allocations are not allowed in constants |
E0015 |
Yes | Yes | Yes |
A non-const function was called in a const context. |
E0023 |
Yes | Yes | Yes |
Incorrect Number of Fields in Pattern Extraction |
E0026 |
Yes | Yes | Yes |
Non-Existent Field Extraction in Struct Pattern also need to refactor this |
E0027 |
Yes | Yes | Yes |
A pattern for a struct fails to specify a sub-pattern for every one of the struct's fields. |
E0029 |
Yes | Yes | No | Non-Comparable Range Error (Something other than numbers and characters has been used for a range) |
E0030 |
Yes | No | - | Empty Range Pattern Error |
E0033 |
Yes | Yes | No | A trait type has been dereferenced (Internal Compile error in gccrs) |
E0034 |
Yes | Yes | Yes Issue Issue-Fix |
Ambiguous Method Call Error - more than one method has the same prototype |
E0038 |
Yes | Yes | No - Issue |
Traits that are declared as Trait: Sized or which otherwise inherit a constraint of Self:Sized are not object-safe. |
E0040 |
Yes | Yes | No | Explicit use of destructor method |
E0044 |
Yes | No | Issue |
Type or Const Parameters Not Allowed on Foreign Items |
E0045 |
Yes | No | Yes - Issue |
Variadic Parameters Used on Non-C ABI Function |
E0046 |
Yes | Yes | Yes |
Missing Items in Trait Implementation - Issue |
E0049 |
Yes | Yes | No | An attempted implementation of a trait method has the wrong number of type or const parameters - Error Link |
E0050 |
Yes | Yes | No | An attempted implementation of a trait method has the wrong number of function parameters - godbolt-link](https://godbolt.org/z/8Waa3KK19) - [ gccrs error - rustc fine` |
E0053 |
Yes | Yes | Yes |
The parameters of any trait method must match between a trait implementation and the trait definition - method 'x' has an incompatible type for trait 'y' |
E0054 |
Yes | Yes | Yes |
Invalid Cast of Integer to Bool |
E0055 |
Yes | Yes | No - need review | Recursion Limit Exceeded |
E0057 |
Yes | Yes | Issue |
An invalid number of arguments was given when calling a closure - compiler-explorer |
E0059 |
Yes | Yes | No | Incorrect Usage of Angle-Bracket Notation in Function Traits - (Failed to resolve type path error) |
E0060 |
Yes | Yes | No | Variadic Function Requires Minimum Number of Arguments - (likewise same as failed to resolve type path in this scope) |
E0061 |
Yes | Yes | Yes |
Invalid number of arguments was passed when calling a function - unexpected number of arguments x expected y |
E0062 |
Yes | Yes | Issue |
A struct's or struct-like enum variant's field was specified more than once. |
E0063 |
Yes | Yes | Yes - Missing-Location-info-ISSUE - no-fields-in-constructor |
Missing Field in Struct or Struct-like Enum Variant - constructor is missing fields |
E0069 |
Yes | Yes | No - Work on this later | Mismatch between function return type & the value being returned |
E0070 |
Yes | Yes | Yes - Issue |
An assignment operator was used on a non-place expression. |
E0071 |
Yes | Yes | No - Work on this later | A structure-literal syntax was used to create an item that is not a structure or enum variant. |
E0072 |
Yes | Yes | No - Work on this later | A recursive type has infinite size because it doesn't have an indirection. |
E0073 |
Yes | Yes | No - Work on this later | You cannot define a struct (or enum) Foo that requires an instance of Foo in order to make a new Foo value. |
E0074 |
Yes | Yes | No - Work on this later -smid feature | When using the #[simd] attribute on a tuple struct, the components of the tuple struct must all be of a concrete, nongeneric type so the compiler can reason about how to use SIMD with them. |
E0075 |
Yes | Yes | No - Work on this later - simd macro error | A #[simd] attribute was applied to an empty tuple struct. |
E0076 |
Yes | Yes | No - Work on this later - simd macro error | All types in a tuple struct aren't the same when using the #[simd] attribute. |
E0077 |
Yes | Yes | No - Work on this later - simd macro error | A tuple struct's element isn't a machine type when using the #[simd] attribute. |
E0080 |
Yes | Yes | No -Issue-link |
A constant value failed to get evaluated. |
E0081 |
Yes | Yes | No | A discriminant value is present more than once. |
E0093 |
Yes | Yes | Yes |
An unknown intrinsic function was declared. |
E0107 |
Yes | Yes | Yes |
An incorrect number of generic arguments was provided. |
E0116 |
Yes | Yes | NO - Internal compile Error |
An inherent implementation was defined for a type outside the current crate. |
E0124 |
Yes | Yes | Yes |
A struct was declared with two fields having the same name. |
E0133 |
Yes | Yes | Yes |
Unsafe code was used outside of an unsafe function or block. |
E0164 |
Yes | Yes | No - Issue |
Something which is neither a tuple struct nor a tuple variant was used as a pattern. |
E0184 |
Yes | Yes | ICE - Issue |
the trait Copy may not be implemented for this type; the type has a destructor |
E0229 |
Yes | Yes | Yes |
Associated Type Binding Outside of Type Parameter Declaration and Where Clause |
E0267 |
Yes | Yes | Issue |
A loop keyword (break or continue) was used inside a closure but outside of any loop. |
E0268 |
Yes | Yes | Yes |
A loop keyword (break or continue) was used outside of a loop. |
E0271 |
Yes | Yes | Yes |
A type mismatched an associated type of a trait. |
E0277 |
Yes | Yes | Yes |
Type Does Not Implement Expected Trait - the type [{integer}] cannot be indexed by u32 |
E0282 |
Yes | Yes | Yes |
The compiler could not infer a type and asked for a type annotation. |
E0303 |
No | Yes | No - Added as subtask on #2509 | pattern bindings are not allowed after an @ |
E0308 |
Yes | Yes | Yes array-case |
Expected type did not match the received type. |
E0323 |
Yes | Yes | Yes |
An associated const was implemented when another trait item was expected. |
E0324 |
Yes | Yes | Issue - No |
A method was implemented when another trait item was expected. |
E0380 |
Yes | Yes | Yes |
An auto trait was declared with a method or an associated item. |
E0390 |
Yes | No | Issue No (Raise issue- https://godbolt.org/z/Pr3ae4ovP) |
A method or constant was implemented on a primitive type. |
E0391 |
Yes | Yes | Yes |
A type dependency cycle has been encountered. |
E0404 |
Yes | Yes | ICE - Issue |
A type that is not a trait was used in a trait position, such as a bound or impl. |
E0412 |
Yes | Yes | Yes |
A used type name is not in scope. |
E0423 |
Yes | Yes | Yes - Issue |
An identifier was used like a function name or a value was expected and the identifier exists but it belongs to a different namespace. |
E0425 |
Yes | Yes | Yes |
Use of unresolved name |
E0426 |
Yes | Yes | Yes |
An undeclared label was used. |
E0431 |
Yes | Yes | Issue - No |
An invalid self import was made. |
E0433 |
Yes | Yes | Yes |
Failed to resolve. Use of Undeclared Crate, Module, or Type |
E0532 |
Yes | Yes | Yes |
Arm Does Not Match Expected Kind - expected tuple struct or tuple variant, found struct variant |
E0534 |
Yes | Yes | Yes |
The inline attribute was malformed. |
E0535 |
Yes | Yes | Yes |
An unknown argument was given to the inline attribute. |
E0541 |
Yes | Yes | Yes |
An unknown meta item was used. |
E0554 |
Yes | Yes | No | Feature attributes are only allowed on the nightly release channel. |
E0571 |
Yes | Yes | Yes |
A break statement with an argument appeared in a non-loop loop. |
E0572 |
Yes | Yes | YES Issue (ICE) |
A return statement was found outside of a function body. |
E0573 |
Yes | Yes | Issue Yes |
Something other than a type has been used when one was expected. |
E0592 |
Yes | Yes | Yes |
This error occurs when you defined methods or associated functions with same name. |
E0599 |
Yes | Yes | Yes |
This error occurs when a method is used on a type which doesn't implement it: |
E0601 |
Yes | Yes | ICE - Issue |
No main function was found in a binary crate. |
E0603 |
Yes | Yes | Yes |
Use of private item outside scope |
E0604 |
Yes | Yes | Yes |
A cast to char was attempted on a type other than u8 |
E0605 |
Yes | Yes | Need Rust standad library Yes |
An invalid cast was attempted. |
E0606 |
Yes | Yes | Yes |
An incompatible cast was attempted. |
E0607 |
Yes | Yes | No Need rust sl |
A cast between a thin and a fat pointer was attempted. |
E0617 |
Yes | Yes | Yes |
Attempted to pass an invalid type of variable into a variadic function. |
E0618 |
Yes | Yes | No | Attempted to call something which isn't a function nor a method. |
E0620 |
Yes | Yes | Yes |
A cast to an unsized type was attempted. |
E0623 |
Yes | Yes | No - Need rust sl |
A lifetime didn't match what was expected. |
E0635 |
Yes | Yes | Yes |
The #![feature] attribute specified an unknown feature. |
E0641 |
Yes | Yes | No - Need rust sl |
Attempted to cast to/from a pointer with an unknown kind. |
E0658 |
Yes | Yes | Yes mut-ref Top level patterns in le experssion |
An unstable feature was used |
E0703 |
Yes | Yes | [Yes ] |
Invalid ABI (Application Binary Interface) used in the code. |
E0720 |
Yes | Yes | ICE - Issue |
An impl Trait type expands to a recursive type. |
E0753 |
Yes | Yes | Yes |
An inner doc comment was used in an invalid context. |
E0769 |
Yes | Yes | Yes |
A tuple struct or tuple variant was used in a pattern as if it were a struct or struct variant. |
E0781 |
Yes | Yes | No - Need rust sl |
The C-cmse-nonsecure-call ABI can only be used with function pointers. |
E0001
E0002
E0007
E0009
E0014
E0073
E0074
E0087
E0088
E0089
E0090
E0110
E0136
E0137
E0139
E0154
E0162
E0165
E0192
E0193
E0205
E0208
E0211
E0243
E0244
E0251
E0256
E0263
E0281
E0297
E0301
E0302
E0303
E0312
E0329
E0383
E0386
E0387
E0388
E0389
E0398
E0439
E0447
E0448
E0477
E0482
E0495
E0497
E0504
E0523
E0595
E0619
E0632
E0633
E0660
E0661
E0662
E0663
E0664
E0665
E0668
E0669
E0671
E0687
E0688
E0759
E0760
E0772
"""* | |
* Author : Mahad | |
* Created : Jul-26-2023 15:26:59 compiler/rustc_error_codes/src/error_codes/parse.py | |
*""" | |
# This is get the error codes from rustc source code, and getting the codes, in nicely format | |
# This code is probably not the best code, but it's working fine | |
import os | |
import re | |
def check_file_for_sentence(file_path, sentence): | |
with open(file_path, 'r', encoding='utf-8') as file: | |
content = file.read() | |
return sentence not in content | |
def find_files_without_sentence(directory, sentence): | |
non_matching_files = [] | |
for root, _, files in os.walk(directory): | |
for file in files: | |
if file.lower().endswith(".md"): | |
file_path = os.path.join(root, file) | |
if check_file_for_sentence(file_path, sentence): | |
non_matching_files.append(file_path) | |
return non_matching_files | |
def find_files_with_sentence(directory, sentence): | |
matching_files = [] | |
for root, _, files in os.walk(directory): | |
for file in files: | |
if file.lower().endswith(".md"): | |
file_path = os.path.join(root, file) | |
if not check_file_for_sentence(file_path, sentence): | |
matching_files.append(file_path) | |
return matching_files | |
def create_url(error_code): | |
# return "https://doc.rust-lang.org/error-index.html#%s" % error_code | |
# returning file with this format: [`E0139`](https://doc.rust-lang.org/error_codes/E0139.html) | |
# str = "https://doc.rust-lang.org/error_codes/%s.html" % error_code | |
# return "[`%s`](%s)" % (error_code, str) | |
return "[`%s`](https://doc.rust-lang.org/error_codes/%s.html)" % (error_code, error_code) | |
# return f"[`{error_code}`](https://doc.rust-lang.org/error_codes/{error_code}.html)" | |
if __name__ == "__main__": | |
target_directory = "/home/mahad/Desktop/rust/compiler/rustc_error_codes/src/error_codes/" | |
sentence_to_check = "#### Note: this error code is no longer emitted by the compiler." | |
non_matching_files = find_files_without_sentence(target_directory, sentence_to_check) | |
matching_files = find_files_with_sentence(target_directory, sentence_to_check) | |
output_all_files = open("output_all_files.txt", "w") | |
# if not non_matching_files: | |
# if non_matching_files: | |
print("All files contain the sentence.") | |
for file_path in matching_files: | |
# print(file_path) | |
print(re.sub(target_directory, "", file_path).replace(".md", "")) | |
output_all_files.write(re.sub(target_directory, "", file_path).replace(".md", "") + "\n") | |
print("Files without the sentence:") | |
for file_path in non_matching_files: | |
# print(file_path) | |
# printing name of file without extension like E0001 | |
print(re.sub(target_directory, "", file_path).replace(".md", "")) | |
output_all_files.write(re.sub(target_directory, "", file_path).replace(".md", "") + "\n") | |
# print(re.sub(target_directory, "", file_path)) | |
# print(re.sub(target_directory, "", file_path)) | |
print("Total files:", len(non_matching_files) + len(matching_files)) | |
print("Files without the sentence:", len(non_matching_files)) | |
print("Files with the sentence:", len(matching_files)) | |
# Sorting output files | |
output_all_files = open("output_all_files.txt", "r") | |
lines = output_all_files.readlines() | |
lines.sort() | |
output_all_files = open("output_all_files.txt", "w") | |
output_all_files.writelines(lines) | |
# storing this output in a file in sorted order | |
output_file_with_sentence = open("output_file_with_sentence.txt", "w") | |
output_file_without_sentence = open("output_file_without_sentence.txt", "w") | |
for file_path in matching_files: | |
output_file_with_sentence.write(re.sub(target_directory, "", file_path).replace(".md", "") + "\n") | |
for file_path in non_matching_files: | |
output_file_without_sentence.write(re.sub(target_directory, "", file_path).replace(".md", "") + "\n") | |
# Sorting the files | |
output_file_with_sentence = open("output_file_with_sentence.txt", "r") | |
output_file_without_sentence = open("output_file_without_sentence.txt", "r") | |
lines = output_file_with_sentence.readlines() | |
lines.sort() | |
output_file_with_sentence = open("output_file_with_sentence.txt", "w") | |
output_file_with_sentence.writelines(lines) | |
lines = output_file_without_sentence.readlines() | |
lines.sort() | |
output_file_without_sentence = open("output_file_without_sentence.txt", "w") | |
output_file_without_sentence.writelines(lines) | |
# Add comment to error code output_all_files, if the error code is in output_file_with_sentence | |
output_all_files = open("output_all_files.txt", "r") | |
output_file_with_sentence = open("output_file_with_sentence.txt", "r") | |
# output_file_without_sentence = open("output_file_without_sentence.txt", "r") | |
lines = output_all_files.readlines() | |
lines_with_sentence = output_file_with_sentence.readlines() | |
# lines_without_sentence = output_file_without_sentence.readlines() | |
output_map = open("output_map.txt", "w") | |
output_case = open("output_case.txt", "w") # add each line of this format "case ErrorCode::E0001: return "E0001";" | |
output_macro = open("output_macro.txt", "w") # for converting 0001 to string https://github.com/Rust-GCC/gccrs/pull/2468#discussion_r1274684661 | |
# To print in this format "TABLE_LINE(line)," ignoring the 'E' | |
# add each line of this format "{ErrorCode::E0001, "E0001"},\n" to output_map.txt | |
for line in lines: | |
output_map.write("{ErrorCode::" + line.replace("\n", "") + ", \"" + line.replace("\n", "") + "\"},\n") | |
output_case.write("case ErrorCode::" + line.replace("\n", "") + ": return \"" + line.replace("\n", "") + "\";\n") | |
# output_macro.write("TABLE_LINE(" + line.replace("E", "").replace("\n", "") + "),\n") | |
output_macro.write("TABLE_TO_MAP(" + line.replace("\n", "") + "),\n") | |
# output_maco_include.write("ERROR(" + line.replace("\n", "") + "),\n") | |
output_map.close() | |
output_case.close() | |
output_macro.close() | |
output_all_files = open("output_all_files.txt", "w") | |
output_file_with_sentence = open("output_file_with_sentence.txt", "w") | |
# output_file_without_sentence = open("output_file_without_sentence.txt", "w") | |
output_maco_include = open("output_maco_include.txt", "w") # ERROR( ), | |
for line in lines: | |
if line in lines_with_sentence: | |
output_all_files.write(line.replace("\n", "") + ", // this error code is no longer emitted by the compiler\n") | |
output_maco_include.write("ERROR(" + line.replace("E","").replace("\n", "") + "), // this error code is no longer emitted by the compiler\n") | |
else: | |
output_all_files.write(line.replace("\n", "") + ",\n") | |
output_maco_include.write("ERROR(" + line.replace("E","").replace("\n", "")+ "),\n") | |
# for line in lines_with_sentence: | |
# output_file_with_sentence.write(line) | |
# for line in lines_without_sentence: | |
# output_file_without_sentence.write(line) | |
output_maco_include.close() | |
output_all_files.close() | |
output_file_with_sentence.close() | |
output_file_without_sentence.close() | |
output_file_with_sentence_markdown = open("output_file_with_sentence_markdown.md", "w") | |
output_file_without_sentence_markdown = open("output_file_without_sentence_markdown.md", "w") | |
for file_path in matching_files: | |
output_file_with_sentence_markdown.write(create_url(re.sub(target_directory, "", file_path).replace(".md", "")) + "\n") | |
for file_path in non_matching_files: | |
# output_file_without_sentence_markdown.write(create_url(re.sub(target_directory, "", file_path).replace(".md", "")) + "\n") | |
# Appending "- [ ]" to each line | |
output_file_without_sentence_markdown.write("- [ ] " + create_url(re.sub(target_directory, "", file_path).replace(".md", "")) + "\n") | |
# sorting the files and converting them to url | |
output_file_with_sentence_markdown = open("output_file_with_sentence_markdown.md", "r") | |
output_file_without_sentence_markdown = open("output_file_without_sentence_markdown.md", "r") | |
lines = output_file_with_sentence_markdown.readlines() | |
# convering each code to url | |
# for i in range(len(lines)): | |
# lines[i] = create_url(lines[i].replace("\n", "")) + "\n" | |
lines.sort() | |
output_file_with_sentence_markdown = open("output_file_with_sentence_markdown.md", "w") | |
output_file_with_sentence_markdown.writelines(lines) | |
lines = output_file_without_sentence_markdown.readlines() | |
# for i in range(len(lines)): | |
# lines[i] = create_url(lines[i].replace("\n", "")) + "\n" | |
lines.sort() | |
output_file_without_sentence_markdown = open("output_file_without_sentence_markdown.md", "w") | |
output_file_without_sentence_markdown.writelines(lines) | |
output_file_with_sentence_markdown.close() | |
output_file_without_sentence_markdown.close() | |
### For my final report | |
input_filename = "output_file_without_sentence.txt" | |
output_filename = "output_file_with_extension.txt" | |
# Reading the input file and process each line | |
with open(input_filename, 'r') as input_file: | |
lines = input_file.readlines() | |
# Appending ".md" extension to each line and write to the output file | |
with open(output_filename, 'w') as output_file: | |
for line in lines: | |
line = line.strip() # Remove any leading/trailing whitespace | |
if line: # Skip empty lines | |
new_line = f"{line}.md\n" | |
output_file.write(new_line) | |
print("File extensions appended successfully.") | |
# # Second step | |
# input_filename = "output_file_with_extension.txt" | |
# output_filename = "output_results.txt" | |
# with open(input_filename, 'r') as input_file: | |
# filenames = input_file.readlines() | |
# with open(output_filename, 'w') as output_file: | |
# for filename in filenames: | |
# filename = filename.strip() # Remove leading/trailing whitespace | |
# if filename: | |
# try: | |
# with open(filename, 'r') as content_file: | |
# content_lines = content_file.readlines() | |
# # Find the first non-empty lines | |
# non_empty_lines = [] | |
# for line in content_lines: | |
# if line.strip(): # Non-empty line | |
# non_empty_lines.append(line) | |
# else: # Empty line encountered | |
# break | |
# output_file.write(f'The output of {filename} is:\n') | |
# for line in non_empty_lines: | |
# output_file.write(line) | |
# except FileNotFoundError: | |
# output_file.write(f'File {filename} not found.\n') | |
# output_file.write('\n') # Separate entries | |
# print("Output written successfully.") | |
# Third step | |
input_filename = "output_file_without_sentence_markdown.md" | |
with open(input_filename, 'r') as input_file: | |
lines = input_file.readlines() | |
file_urls = {} | |
for line in lines: | |
if "[ ]" in line: | |
filename_start = line.find("`") | |
filename_end = line.find("`", filename_start + 1) | |
if filename_start != -1 and filename_end != -1: | |
filename = line[filename_start + 1:filename_end] | |
url_start = line.find("https://") | |
url_end = line.find(".html") | |
if url_start != -1 and url_end != -1: | |
url = line[url_start:url_end + len(".html")] | |
file_urls[filename] = url | |
# Second step - Append file content to corresponding lines in the markdown file | |
for filename, url in file_urls.items(): | |
md_filename = filename + ".md" | |
try: | |
with open(md_filename, 'r') as content_file: | |
content_lines = content_file.readlines() | |
non_empty_lines = [] | |
for line in content_lines: | |
if line.strip(): | |
non_empty_lines.append(line) | |
else: | |
break | |
output_line = f'- [ ] [`{filename}`]({url})\n - **Error Description:** ' | |
for line in non_empty_lines: | |
output_line += line | |
# Find the line number corresponding to the current filename | |
line_number = next(i for i, line in enumerate(lines) if filename in line) | |
lines[line_number] = output_line | |
except FileNotFoundError: | |
print(f'File {md_filename} not found.') | |
# Write the updated lines back to the markdown file | |
updated_input_filename = "updated_output_file_without_sentence_markdown.md" | |
with open(updated_input_filename, 'w') as updated_input_file: | |
updated_input_file.writelines(lines) | |
print("Updated markdown file created successfully.") |
I created this to update the gccrs error code framework and converting the existing code to enum usage.
- Python code for converting
ErrorCode (Exxxx)
toErrorCode::Exxxx
"""*
* Author : Mahad
* Created : Jul-26-2023 15:35:45 converter.py
*"""
import os
import re
def replace_pattern_in_file(file_path):
try:
with open(file_path, 'r') as file:
content = file.read()
# Use regular expression to find the pattern " (Exxxx)"
# where x can be any digit from 0 to 9
pattern = r'\s\("(E\d{4})"\)'
replaced_content = re.sub(pattern, r'::\1', content)
with open(file_path, 'w') as file:
file.write(replaced_content)
print(f"Replaced in file: {file_path}")
except Exception as e:
print(f"Error processing file: {file_path} - {e}")
def recursive_search_and_replace(directory_path):
for root, _, files in os.walk(directory_path):
for file in files:
if file.endswith(".h"):
file_path = os.path.join(root, file)
replace_pattern_in_file(file_path)
if __name__ == "__main__":
path_to_directory = "/home/mahad/Desktop/mahad/gccrs/gcc/rust/"
recursive_search_and_replace(path_to_directory)
E0407 - E0324 - E0438 - E0323
Useful debugging statement:
printf("\nThis is line %d of file %s (function %s) \n", __LINE__, __FILE__, __func__ );
Failed to resolve type path
Repr:
https://doc.rust-lang.org/error_codes/E0658.html
https://doc.rust-lang.org/error_codes/E0552.html
Rust-GCC/gccrs#915
Rust-GCC/gccrs#1188
https://doc.rust-lang.org/reference/type-layout.html#representations
rust-lang/rust#110083
rust-lang/rust#103693
https://godbolt.org/z/5cj81hKa3
https://godbolt.org/z/7Y4K831Kv
rust-lang/rust#56071
https://stackoverflow.com/questions/47846844/static-constexpr-of-set
https://en.cppreference.com/w/cpp/language/constexpr
https://en.cppreference.com/w/cpp/language/eval_order
https://en.cppreference.com/w/cpp/container/unordered_map/unordered_map
https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a08615.html
https://godbolt.org/z/osG7hanTj
https://stackoverflow.com/questions/3019609/any-utility-to-test-expand-c-c-define-macros
https://devblogs.microsoft.com/cppblog/macro-expansions-in-quick-info-tooltips/
https://stackoverflow.com/questions/5530248/creating-a-string-list-and-an-enum-list-from-a-c-macro
https://stackoverflow.com/questions/5439174/print-the-month-corresponding-to-appropriate-input/