Prevent implementation of external types
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
We currently don't limit implementation of types from outside your package so you can even do something like:
```sway
library;
impl u64 {
pub fn foo() {}
}
```
We should have sensible rules similar to Rust's and generally speaking only permit implementing a trait for a type if either the trait or type were defined in the package.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the compiler code that validates trait implementations and the existing tests for impl declarations. Compare the intended rule with Rust's orphan-rule behavior, then add coverage showing that external type and trait combinations are rejected while permitted implementations still compile.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100