Skip to content

Commit 7d57bdc

Browse files
committed
Auto merge of #484 - eddyb:dox-unops, r=alexcrichton
Support Neg and Not in no_core mode. Needed by rust-lang/rust#38776 which requires the traits to be implemented even for integer types. This is already the case with binary operator traits, which always require the trait and its impls.
2 parents 3e89579 + 974f7ba commit 7d57bdc

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/dox.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ mod imp {
4040
$mac!(u32);
4141
$mac!(u64);
4242
$mac!(usize);
43+
each_signed_int!($mac);
44+
)
45+
}
46+
47+
macro_rules! each_signed_int {
48+
($mac:ident) => (
4349
$mac!(i8);
4450
$mac!(i16);
4551
$mac!(i32);
@@ -128,6 +134,38 @@ mod imp {
128134
}
129135
each_int!(impl_bitor);
130136

137+
#[lang = "neg"]
138+
pub trait Neg {
139+
type Output;
140+
fn neg(self) -> Self::Output;
141+
}
142+
143+
macro_rules! impl_neg {
144+
($($i:ident)*) => ($(
145+
impl Neg for $i {
146+
type Output = $i;
147+
fn neg(self) -> $i { -self }
148+
}
149+
)*)
150+
}
151+
each_signed_int!(impl_neg);
152+
153+
#[lang = "not"]
154+
pub trait Not {
155+
type Output;
156+
fn not(self) -> Self::Output;
157+
}
158+
159+
macro_rules! impl_not {
160+
($($i:ident)*) => ($(
161+
impl Not for $i {
162+
type Output = $i;
163+
fn not(self) -> $i { !self }
164+
}
165+
)*)
166+
}
167+
each_int!(impl_not);
168+
131169
pub mod mem {
132170
pub fn size_of_val<T>(_: &T) -> usize { 4 }
133171
}

0 commit comments

Comments
 (0)