This is actually the expected behavior for the time being. Rust requires the add lang element to be implemented for a type, even if it is an inline type. An implementation can be completely fictitious (as long as it compiles), as it will be replaced by an inline operation .
The reason this is done is because the type of code that checks the built-in types was erroneous and complex. This simplified the type checking code, and there were already sign implementations anyway.
To do this, you need to add the following two declarations in order to be able to use the + operator even in the built-in type u32
#[lang = "add"] pub trait Add<RHS=Self> { type Output; fn add(self, rhs: RHS) -> Self::Output; } impl Add for u32 { type Output = u32; fn add(self, _rhs: u32) -> u32 { 42 } }
Here is a complete example that is not related to the absence of some libc files: https://play.rust-lang.org/?gist=a223d48b0f2d8533996f&version=nightly
Note that you should not create a fake implementation as shown, because you can use the built-in type in the general context where the implementation will actually be implemented
oli_obk - ker
source share