Skip to content
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

Rollup of 10 pull requests #120121

Merged
merged 41 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
17edbe7
Use AtomicU8 instead of AtomicUsize in backtrace.rs
GnomedDev Dec 10, 2023
1c5b2ce
Docs: Use non-SeqCst in module example of atomics
AngelicosPhosphoros Dec 19, 2023
46ad131
update fn pointer trait impl docs
asquared31415 Jan 12, 2024
56df3bb
Move nonzero_integers macro call to bottom of module
dtolnay Dec 6, 2023
54cb822
Define only a single NonZero type per macro call
dtolnay Dec 6, 2023
9196d2a
Unindent nonzero_integer macro body
dtolnay Dec 6, 2023
a6152cd
Format nonzero_integer macro calls same way we do the primitive int i…
dtolnay Dec 6, 2023
3de0af1
Move 'impl FromStr for NonZero' into nonzero_integer macro
dtolnay Dec 6, 2023
81e1a7c
Move impl Div and Rem into nonzero_integer macro
dtolnay Dec 6, 2023
a78d9a6
Unindent nonzero_integer_impl_div_rem macro body
dtolnay Dec 6, 2023
f846ed5
Move leading_zeros and trailing_zeros methods into nonzero_integer macro
dtolnay Dec 6, 2023
757ed25
Move Neg impl into the macro that generates Div and Rem
dtolnay Dec 6, 2023
4291b3f
Move signedness dependent methods into the omnibus impl block
dtolnay Dec 6, 2023
b21b9cc
Unindent nonzero_integer_signedness_dependent_methods macro body
dtolnay Dec 6, 2023
c6d776e
Work around rustfmt doc attribute indentation bug
dtolnay Dec 6, 2023
63256af
Move nonzero_unsigned_signed_operations methods into the omnibus impl…
dtolnay Dec 6, 2023
4419136
Move is_power_of_two into unsigned part of signedness_dependent_methods
dtolnay Dec 6, 2023
7f7c5af
Move unsigned MIN and MAX into signedness_dependent_methods
dtolnay Dec 6, 2023
66cda3b
Move signed MIN and MAX into signedness_dependent_methods
dtolnay Dec 6, 2023
c537132
Move BITS into omnibus impl block
dtolnay Dec 6, 2023
cdee1fe
Unbreak tidy's feature parser
dtolnay Dec 6, 2023
c1c7707
Deny braced macro invocations in let-else
compiler-errors Dec 18, 2023
ec263df
Suggest wrapping mac args in parens rather than the whole expression
compiler-errors Dec 18, 2023
0373ce6
Warn when no profiler runtime means coverage tests won't be run/blessed
Zalathar Jan 18, 2024
d95d6ce
`dead_code` treats `#[repr(transparent)]` the same as `#[repr(C)]`
shepmaster Jan 18, 2024
fb7762b
Remove no-longer-needed `allow(dead_code)` from the standard library
shepmaster Jan 18, 2024
92cc57b
Remove no-longer-needed `allow(dead_code)` from the tests
shepmaster Jan 18, 2024
aeeaed9
Remove no-longer-needed `allow(dead_code)` from Miri tests
shepmaster Jan 18, 2024
7fead95
Remove myself from review rotation
WaffleLapkin Jan 18, 2024
35a9fc3
Clarify docs for Vec::into_boxed_slice, Vec::shrink_to_fit
invpt Jan 18, 2024
1a34342
Fix typo in documentation in base.rs
kapilsinha Jan 19, 2024
122b3f9
Rollup merge of #118665 - dtolnay:signedness, r=Nilstrieb
matthiaskrgr Jan 19, 2024
2d828cd
Rollup merge of #118798 - GnomedDev:use-atomicu8-backtrace, r=Nilstrieb
matthiaskrgr Jan 19, 2024
2e4c6fc
Rollup merge of #119062 - compiler-errors:asm-in-let-else, r=davidtwc…
matthiaskrgr Jan 19, 2024
f9076bb
Rollup merge of #119138 - AngelicosPhosphoros:use_proper_atomics_in_s…
matthiaskrgr Jan 19, 2024
48ba721
Rollup merge of #119907 - asquared31415:fn_trait_docs, r=Nilstrieb
matthiaskrgr Jan 19, 2024
987445c
Rollup merge of #120083 - Zalathar:no-profiler, r=wesleywiser
matthiaskrgr Jan 19, 2024
332f8f7
Rollup merge of #120107 - shepmaster:dead-code-repr-transparent, r=Ni…
matthiaskrgr Jan 19, 2024
7219bd2
Rollup merge of #120110 - invpt:patch-1, r=the8472
matthiaskrgr Jan 19, 2024
e35dfed
Rollup merge of #120113 - WaffleLapkin:🔥-1, r=compiler-errors
matthiaskrgr Jan 19, 2024
b4616f5
Rollup merge of #120118 - kapilsinha:patch-1, r=Nilstrieb
matthiaskrgr Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move Neg impl into the macro that generates Div and Rem
  • Loading branch information
dtolnay committed Jan 14, 2024
commit 757ed2566701feba8fc67cae3d21a7423254efba
40 changes: 20 additions & 20 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,12 @@ macro_rules! nonzero_integer {
}
}

nonzero_integer_impl_div_rem!($Ty $signedness $Int);
nonzero_integer_signedness_dependent_impls!($Ty $signedness $Int);
};
}

macro_rules! nonzero_integer_impl_div_rem {
($Ty:ident signed $Int:ty) => {
// nothing for signed ints
};

macro_rules! nonzero_integer_signedness_dependent_impls {
// Impls for unsigned nonzero types only.
($Ty:ident unsigned $Int:ty) => {
#[stable(feature = "nonzero_div", since = "1.51.0")]
impl Div<$Ty> for $Int {
Expand All @@ -288,6 +285,23 @@ macro_rules! nonzero_integer_impl_div_rem {
}
}
};

// Impls for signed nonzero types only.
($Ty:ident signed $Int:ty) => {
#[stable(feature = "signed_nonzero_neg", since = "1.71.0")]
impl Neg for $Ty {
type Output = $Ty;

#[inline]
fn neg(self) -> $Ty {
// SAFETY: negation of nonzero cannot yield zero values.
unsafe { $Ty::new_unchecked(self.get().neg()) }
}
}

forward_ref_unop! { impl Neg, neg for $Ty,
#[stable(feature = "signed_nonzero_neg", since = "1.71.0")] }
};
}

// A bunch of methods for unsigned nonzero types only.
Expand Down Expand Up @@ -921,20 +935,6 @@ macro_rules! nonzero_signed_operations {
unsafe { $Ty::new_unchecked(result) }
}
}

#[stable(feature = "signed_nonzero_neg", since = "1.71.0")]
impl Neg for $Ty {
type Output = $Ty;

#[inline]
fn neg(self) -> $Ty {
// SAFETY: negation of nonzero cannot yield zero values.
unsafe { $Ty::new_unchecked(self.get().neg()) }
}
}

forward_ref_unop! { impl Neg, neg for $Ty,
#[stable(feature = "signed_nonzero_neg", since = "1.71.0")] }
)+
}
}
Expand Down