Commit 0d7b96a
committed
Trait coherence: disallow inherent impls on external types
This improves the trait coherence checks for impl self case,
and polishes a bit of the wording on the existing diagnostics.
* Add CompileError::InherentImplForExternalType and diagnostics.
Reason/issue/help now refer to "package" to match coherence scope
* Enforce package-level check in impl-self type checking
Reject inherent impls for external nominal types (struct/enum)
Temporary whitelist: allow inherent impls on std::storage::StorageKey<_>
This is a workaround so current code that uses this pattern keeps
working.1 parent 6981d3d commit 0d7b96a
File tree
4 files changed
+92
-11
lines changed- sway-core/src/semantic_analysis/ast_node/declaration
- sway-error/src
- test/src/e2e_vm_tests/test_programs/should_fail/trait_coherence
- impl_self_overlap
- orphan_rules/impl_orphan
4 files changed
+92
-11
lines changedLines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
529 | 577 | | |
530 | 578 | | |
531 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1085 | 1085 | | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | | - | |
| 1088 | + | |
1089 | 1089 | | |
1090 | 1090 | | |
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1094 | 1100 | | |
1095 | 1101 | | |
1096 | 1102 | | |
| |||
1325 | 1331 | | |
1326 | 1332 | | |
1327 | 1333 | | |
| 1334 | + | |
1328 | 1335 | | |
1329 | 1336 | | |
1330 | 1337 | | |
| |||
3121 | 3128 | | |
3122 | 3129 | | |
3123 | 3130 | | |
3124 | | - | |
| 3131 | + | |
3125 | 3132 | | |
3126 | 3133 | | |
3127 | 3134 | | |
3128 | 3135 | | |
3129 | 3136 | | |
3130 | | - | |
| 3137 | + | |
3131 | 3138 | | |
3132 | 3139 | | |
3133 | 3140 | | |
3134 | 3141 | | |
3135 | 3142 | | |
3136 | | - | |
| 3143 | + | |
3137 | 3144 | | |
3138 | 3145 | | |
3139 | | - | |
| 3146 | + | |
3140 | 3147 | | |
3141 | 3148 | | |
3142 | 3149 | | |
| |||
3145 | 3152 | | |
3146 | 3153 | | |
3147 | 3154 | | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
3148 | 3180 | | |
3149 | 3181 | | |
3150 | 3182 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments