-
Notifications
You must be signed in to change notification settings - Fork 195
New Error Code Framework #2468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Error Code Framework #2468
Conversation
c0145de to
b06be4d
Compare
6306980 to
89dd433
Compare
P-E-P
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great work!
CohenArthur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you, good work @MahadMuhammad !
89dd433 to
5a74b6a
Compare
gcc/rust/rust-diagnostics.h
Outdated
| #define TABLE_TO_MAP(NUM) {ErrorCode::ERROR_CODE(NUM), XSTR(ERROR_CODE(NUM))} | ||
|
|
||
| const char *m_str; | ||
| static std::unordered_map<ErrorCode,const char *> ErrorCodeString = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...this:
| static std::unordered_map<ErrorCode,const char *> ErrorCodeString = { | |
| static std::unordered_map<ErrorCode, char *> ErrorCodeString = { |
also I would suggest renaming the table to error_code_strings
34244a3 to
42a31b3
Compare
42a31b3 to
ab673eb
Compare
|
@MahadMuhammad please keep the changes simple for now - I think we should look at using the |
5912c3b to
3c5a056
Compare
Updated ErrorCode struct to enum class to enforce proper error codes, similiar to rustc. For converting the enum to the respective error code, I used a map and updated make_description & make_url function accordingly and also removes the memory leak from the previous frame- work. Also, added macro to safely convert the enum number to string. gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (Intrinsics::compile): Formatted according to enum class. * checks/errors/rust-feature-gate.cc (FeatureGate::gate): likewise. * checks/errors/rust-unsafe-checker.cc (check_unsafe_call): likewise. * hir/rust-ast-lower-base.cc (struct_field_name_exists): likewise. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): likewise. * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): likewise. (PatternDeclaration::add_new_binding): likewise. * resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): likewise. * resolve/rust-ast-verify-assignee.h: likewise. * rust-diagnostics.cc: updated make_desc & url function for enum class. * rust-diagnostics.h (struct ErrorCode): removed struct to switch to enum. (enum class): Switched from errorcode struct to enum class. (XSTR): Macro for converting enum to string. (STR): macro Used by XSTR for converting to string. (ERROR_CODE): macro used by map for check. (TABLE_TO_MAP): macro used by map for check * typecheck/rust-casts.cc (TypeCastRules::emit_cast_error): Formatted according to enum class. * typecheck/rust-hir-path-probe.h: likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): likewise. (TypeCheckImplItemWithTrait::visit): likewise. * typecheck/rust-hir-type-check-item.cc: likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): likewise. (emit_invalid_field_error): likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve): likewise. * typecheck/rust-tyty-call.cc (emit_unexpected_argument_error): likewise. (TypeCheckCallExpr::visit): likewise. * typecheck/rust-tyty-subst.cc (SubstitutionRef::get_mappings_from_generic_args): likewise. * typecheck/rust-tyty.cc (BaseType::bounds_compatible): likewise. Signed-off-by: Muhammad Mahad <[email protected]>
1f50f81 to
0d73f08
Compare
CohenArthur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you!
Updated ErrorCode Framework
There is no need to add check for wrong error codes, as it was automatically handled by Enum class.
Fixes Improve
ErrorCodeframework #2452Converted from ErrorCode Struct to class.
Updated make_description accordingly.
Updated make_url accordingly.
Updated ErrorCode calling function.
Currently, there are some obsolete error codes which are not emitted by rustc. I was added them in the class, with comment, to keep consistency with rustc. The error codes which are rustc uses are all in this file https://github.com/rust-lang/rust/blob/master/compiler/rustc_error_codes/src/error_codes.rs.
Error Codes which are no longer emitted by rustc are :
E0001E0002E0007E0009E0014E0073E0074E0087E0088E0089E0090E0110E0136E0137E0139E0154E0162E0165E0192E0193E0205E0208E0211E0243E0244E0251E0256E0263E0281E0297E0301E0302E0303E0312E0329E0383E0386E0387E0388E0389E0398E0439E0447E0448E0477E0482E0495E0497E0504E0523E0595E0619E0632E0633E0660E0661E0662E0663E0664E0665E0668E0669E0671E0687E0688E0759E0760E0772The error codes which are emitted by rustc are :
E0004E0005E0010E0013E0015E0023E0025E0026E0027E0029E0030E0033E0034E0038E0040E0044E0045E0046E0049E0050E0053E0054E0055E0057E0059E0060E0061E0062E0063E0067E0069E0070E0071E0072E0075E0076E0077E0080E0081E0084E0091E0092E0093E0094E0106E0107E0109E0116E0117E0118E0119E0120E0121E0124E0128E0130E0131E0132E0133E0138E0152E0158E0161E0164E0170E0178E0183E0184E0185E0186E0191E0195E0197E0198E0199E0200E0201E0203E0204E0206E0207E0210E0212E0214E0220E0221E0222E0223E0224E0225E0226E0227E0228E0229E0230E0231E0232E0252E0253E0254E0255E0259E0260E0261E0262E0264E0267E0268E0271E0275E0276E0277E0282E0283E0284E0307E0308E0309E0310E0311E0316E0317E0320E0321E0322E0323E0324E0325E0326E0328E0364E0365E0366E0367E0368E0369E0370E0371E0373E0374E0375E0376E0377E0378E0379E0380E0381E0382E0384E0390E0391E0392E0393E0399E0401E0403E0404E0405E0407E0408E0409E0411E0412E0415E0416E0422E0423E0424E0425E0426E0428E0429E0430E0431E0432E0433E0434E0435E0436E0437E0438E0445E0446E0449E0451E0452E0453E0454E0455E0457E0458E0459E0460E0461E0462E0463E0464E0466E0468E0469E0472E0476E0478E0491E0492E0493E0496E0498E0499E0500E0501E0502E0503E0505E0506E0507E0508E0509E0510E0511E0512E0514E0515E0516E0517E0518E0519E0520E0521E0522E0524E0525E0527E0528E0529E0530E0531E0532E0533E0534E0535E0536E0537E0538E0539E0541E0542E0543E0544E0545E0546E0547E0549E0550E0551E0552E0554E0556E0557E0559E0560E0561E0562E0565E0566E0567E0568E0569E0570E0571E0572E0573E0574E0575E0576E0577E0578E0579E0580E0581E0582E0583E0584E0585E0586E0587E0588E0589E0590E0591E0592E0593E0594E0596E0597E0599E0600E0601E0602E0603E0604E0605E0606E0607E0608E0609E0610E0614E0615E0616E0617E0618E0620E0621E0622E0623E0624E0625E0626E0627E0628E0631E0634E0635E0636E0637E0638E0639E0640E0641E0642E0643E0644E0646E0647E0648E0657E0658E0659E0666E0667E0670E0689E0690E0691E0692E0693E0695E0696E0697E0698E0699E0700E0701E0703E0704E0705E0706E0708E0710E0711E0712E0713E0714E0715E0716E0717E0718E0719E0720E0722E0724E0725E0726E0727E0728E0729E0730E0731E0732E0733E0734E0735E0736E0737E0739E0740E0741E0742E0743E0744E0745E0746E0747E0748E0749E0750E0751E0752E0753E0754E0755E0756E0757E0758E0761E0762E0763E0764E0765E0766E0767E0768E0769E0770E0771E0773E0774E0775E0776E0777E0778E0779E0780E0781E0782E0783E0784E0785E0786E0787E0788E0789E0790E0791E0792E0793E0794