Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 1 addition & 6 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl<'a> Parser<'a> {
defaultness: Defaultness,
is_reuse: bool,
) -> PResult<'a, ItemKind> {
let mut constness = self.parse_constness(Case::Sensitive);
let constness = self.parse_constness(Case::Sensitive);
let safety = self.parse_safety(Case::Sensitive);
self.expect_keyword(exp!(Impl))?;

Expand All @@ -674,11 +674,6 @@ impl<'a> Parser<'a> {
generics
};

if let Const::No = constness {
// FIXME(const_trait_impl): disallow `impl const Trait`
constness = self.parse_constness(Case::Sensitive);
}

if let Const::Yes(span) = constness {
self.psess.gated_spans.gate(sym::const_trait_impl, span);
}
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/vec/partial_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::borrow::Cow;
macro_rules! __impl_slice_eq1 {
($($const:ident, )? [$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, $(#[$stability:meta])+ ) => {
$(#[$stability])+
impl<T, U, $($vars)*> $($const)? PartialEq<$rhs> for $lhs
$($const)? impl<T, U, $($vars)*> PartialEq<$rhs> for $lhs
where
T: $([$const])? PartialEq<U>,
$($ty: $bound)?
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ascii/ascii_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ macro_rules! into_int_impl {
$(
#[unstable(feature = "ascii_char", issue = "110998")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const From<AsciiChar> for $ty {
const impl From<AsciiChar> for $ty {
#[inline]
fn from(chr: AsciiChar) -> $ty {
chr as u8 as $ty
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ mod impls {
$(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
impl const Clone for $t {
const impl Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
Expand All @@ -720,7 +720,7 @@ mod impls {
#[doc(hidden)]
#[unstable(feature = "trivial_clone", issue = "none")]
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
unsafe impl const TrivialClone for $t {}
const unsafe impl TrivialClone for $t {}
)*
}
}
Expand Down
10 changes: 5 additions & 5 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ mod impls {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const PartialEq for $t {
const impl PartialEq for $t {
#[inline]
fn eq(&self, other: &Self) -> bool { *self == *other }
#[inline]
Expand Down Expand Up @@ -1903,7 +1903,7 @@ mod impls {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const Eq for $t {}
const impl Eq for $t {}
)*)
}

Expand Down Expand Up @@ -1952,7 +1952,7 @@ mod impls {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const PartialOrd for $t {
const impl PartialOrd for $t {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (*self <= *other, *self >= *other) {
Expand Down Expand Up @@ -1994,7 +1994,7 @@ mod impls {
($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const PartialOrd for $t {
const impl PartialOrd for $t {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(crate::intrinsics::three_way_compare(*self, *other))
Expand All @@ -2005,7 +2005,7 @@ mod impls {

#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const Ord for $t {
const impl Ord for $t {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
crate::intrinsics::three_way_compare(*self, *other)
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cmp/bytewise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) const unsafe trait BytewiseEq<Rhs = Self>:

macro_rules! is_bytewise_comparable {
($($t:ty),+ $(,)?) => {$(
unsafe impl const BytewiseEq for $t {}
const unsafe impl BytewiseEq for $t {}
)+};
}

Expand Down
22 changes: 11 additions & 11 deletions library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ macro_rules! impl_from_bool {
($($int:ty)*) => {$(
#[stable(feature = "from_bool", since = "1.28.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const From<bool> for $int {
const impl From<bool> for $int {
/// Converts from [`bool`] to
#[doc = concat!("[`", stringify!($int), "`]")]
/// , by turning `false` into `0` and `true` into `1`.
Expand Down Expand Up @@ -63,7 +63,7 @@ macro_rules! impl_from {
($small:ty => $large:ty, $(#[$attrs:meta]),+) => {
$(#[$attrs])+
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const From<$small> for $large {
const impl From<$small> for $large {
#[doc = concat!("Converts from [`", stringify!($small), "`] to [`", stringify!($large), "`] losslessly.")]
#[inline(always)]
fn from(small: $small) -> Self {
Expand Down Expand Up @@ -185,7 +185,7 @@ macro_rules! impl_float_from_bool {
) => {
#[stable(feature = "float_from_bool", since = "1.68.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const From<bool> for $float {
const impl From<bool> for $float {
#[doc = concat!("Converts a [`bool`] to [`", stringify!($float),"`] losslessly.")]
/// The resulting value is positive `0.0` for `false` and `1.0` for `true` values.
///
Expand Down Expand Up @@ -238,7 +238,7 @@ macro_rules! impl_try_from_unbounded {
($source:ty => $($target:ty),+) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const TryFrom<$source> for $target {
const impl TryFrom<$source> for $target {
type Error = TryFromIntError;

/// Tries to create the target number type from a source
Expand All @@ -257,7 +257,7 @@ macro_rules! impl_try_from_lower_bounded {
($source:ty => $($target:ty),+) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const TryFrom<$source> for $target {
const impl TryFrom<$source> for $target {
type Error = TryFromIntError;

/// Tries to create the target number type from a source
Expand All @@ -280,7 +280,7 @@ macro_rules! impl_try_from_upper_bounded {
($source:ty => $($target:ty),+) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const TryFrom<$source> for $target {
const impl TryFrom<$source> for $target {
type Error = TryFromIntError;

/// Tries to create the target number type from a source
Expand All @@ -303,7 +303,7 @@ macro_rules! impl_try_from_both_bounded {
($source:ty => $($target:ty),+) => {$(
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const TryFrom<$source> for $target {
const impl TryFrom<$source> for $target {
type Error = TryFromIntError;

/// Tries to create the target number type from a source
Expand All @@ -330,7 +330,7 @@ macro_rules! impl_try_from_integer_for_bool {
($signedness:ident $($int:ty)+) => {$(
#[stable(feature = "bool_try_from_int", since = "1.95.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const TryFrom<$int> for bool {
const impl TryFrom<$int> for bool {
type Error = TryFromIntError;

/// Tries to create a bool from an integer type.
Expand Down Expand Up @@ -585,7 +585,7 @@ macro_rules! impl_nonzero_int_try_from_nonzero_int {
($source:ty => $($target:ty),+) => {$(
#[stable(feature = "nzint_try_from_nzint_conv", since = "1.49.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
impl const TryFrom<NonZero<$source>> for NonZero<$target> {
const impl TryFrom<NonZero<$source>> for NonZero<$target> {
type Error = TryFromIntError;

// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
Expand Down Expand Up @@ -674,7 +674,7 @@ macro_rules! impl_int_cast {
($Src:ty as [$($Dst:ty),*]) => {$(
#[unstable(feature = "integer_casts", issue = "157388")]
#[rustc_const_unstable(feature = "integer_casts", issue = "157388")]
impl const CheckedCastFromInt<$Src> for $Dst {
const impl CheckedCastFromInt<$Src> for $Dst {
#[inline]
fn checked_cast_from(value: $Src) -> Option<Self> {
value.try_into().ok()
Expand All @@ -698,7 +698,7 @@ macro_rules! impl_int_cast {

#[unstable(feature = "integer_casts", issue = "157388")]
#[rustc_const_unstable(feature = "integer_casts", issue = "157388")]
impl const BoundedCastFromInt<$Src> for $Dst {
const impl BoundedCastFromInt<$Src> for $Dst {
#[inline(always)]
fn wrapping_cast_from(value: $Src) -> Self {
value as Self
Expand Down
10 changes: 5 additions & 5 deletions library/core/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
macro_rules! forward_ref_unop {
(impl $imp:ident, $method:ident for $t:ty, $(#[$attr:meta])+) => {
$(#[$attr])+
impl const $imp for &$t {
const impl $imp for &$t {
type Output = <$t as $imp>::Output;

#[inline]
Expand All @@ -19,7 +19,7 @@ macro_rules! forward_ref_unop {
macro_rules! forward_ref_binop {
(impl $imp:ident, $method:ident for $t:ty, $u:ty, $(#[$attr:meta])+) => {
$(#[$attr])+
impl const $imp<$u> for &$t {
const impl $imp<$u> for &$t {
type Output = <$t as $imp<$u>>::Output;

#[inline]
Expand All @@ -30,7 +30,7 @@ macro_rules! forward_ref_binop {
}

$(#[$attr])+
impl const $imp<&$u> for $t {
const impl $imp<&$u> for $t {
type Output = <$t as $imp<$u>>::Output;

#[inline]
Expand All @@ -41,7 +41,7 @@ macro_rules! forward_ref_binop {
}

$(#[$attr])+
impl const $imp<&$u> for &$t {
const impl $imp<&$u> for &$t {
type Output = <$t as $imp<$u>>::Output;

#[inline]
Expand All @@ -58,7 +58,7 @@ macro_rules! forward_ref_binop {
macro_rules! forward_ref_op_assign {
(impl $imp:ident, $method:ident for $t:ty, $u:ty, $(#[$attr:meta])+) => {
$(#[$attr])+
impl const $imp<&$u> for $t {
const impl $imp<&$u> for $t {
#[inline]
#[track_caller]
fn $method(&mut self, other: &$u) {
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/intrinsics/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub const trait CarryingMulAdd: Copy + 'static {
macro_rules! impl_carrying_mul_add_by_widening {
($($t:ident $u:ident $w:ident,)+) => {$(
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
impl const CarryingMulAdd for $t {
const impl CarryingMulAdd for $t {
type Unsigned = $u;
#[inline]
fn carrying_mul_add(self, a: Self, b: Self, c: Self) -> ($u, $t) {
Expand Down Expand Up @@ -127,7 +127,7 @@ macro_rules! zero {
macro_rules! impl_disjoint_bitor {
($($t:ident,)+) => {$(
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
impl const DisjointBitOr for $t {
const impl DisjointBitOr for $t {
#[cfg_attr(miri, track_caller)]
#[inline]
unsafe fn disjoint_bitor(self, other: Self) -> Self {
Expand Down Expand Up @@ -161,7 +161,7 @@ pub const trait FunnelShift: Copy + 'static {
macro_rules! impl_funnel_shifts {
($($type:ident),*) => {$(
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
impl const FunnelShift for $type {
const impl FunnelShift for $type {
#[cfg_attr(miri, track_caller)]
#[inline]
unsafe fn unchecked_funnel_shl(self, rhs: Self, shift: u32) -> Self {
Expand Down Expand Up @@ -229,7 +229,7 @@ pub const trait CarrylessMul: Copy + 'static {
macro_rules! impl_carryless_mul{
($($type:ident),*) => {$(
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
impl const CarrylessMul for $type {
const impl CarrylessMul for $type {
#[inline]
fn carryless_mul(self, rhs: Self) -> Self {
let mut result = 0;
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ macro_rules! step_integer_impls {
#[allow(unreachable_patterns)]
#[unstable(feature = "step_trait", issue = "42168")]
#[rustc_const_unstable(feature = "step_trait", issue = "42168")]
impl const Step for $u_narrower {
const impl Step for $u_narrower {
step_identical_methods!();
step_unsigned_methods!();

Expand Down Expand Up @@ -298,7 +298,7 @@ macro_rules! step_integer_impls {
#[allow(unreachable_patterns)]
#[unstable(feature = "step_trait", issue = "42168")]
#[rustc_const_unstable(feature = "step_trait", issue = "42168")]
impl const Step for $i_narrower {
const impl Step for $i_narrower {
step_identical_methods!();
step_signed_methods!($u_narrower);

Expand Down Expand Up @@ -365,7 +365,7 @@ macro_rules! step_integer_impls {
#[allow(unreachable_patterns)]
#[unstable(feature = "step_trait", issue = "42168")]
#[rustc_const_unstable(feature = "step_trait", issue = "42168")]
impl const Step for $u_wider {
const impl Step for $u_wider {
step_identical_methods!();
step_unsigned_methods!();

Expand Down Expand Up @@ -396,7 +396,7 @@ macro_rules! step_integer_impls {
#[allow(unreachable_patterns)]
#[unstable(feature = "step_trait", issue = "42168")]
#[rustc_const_unstable(feature = "step_trait", issue = "42168")]
impl const Step for $i_wider {
const impl Step for $i_wider {
step_identical_methods!();
step_signed_methods!($u_wider);

Expand Down Expand Up @@ -514,7 +514,7 @@ macro_rules! step_nonzero_impls {
#[allow(unreachable_patterns)]
#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]
#[rustc_const_unstable(feature = "step_trait", issue = "42168")]
impl const Step for NonZero<$narrower> {
const impl Step for NonZero<$narrower> {
step_nonzero_identical_methods!($narrower);

#[inline]
Expand All @@ -540,7 +540,7 @@ macro_rules! step_nonzero_impls {
#[allow(unreachable_patterns)]
#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]
#[rustc_const_unstable(feature = "step_trait", issue = "42168")]
impl const Step for NonZero<$wider> {
const impl Step for NonZero<$wider> {
step_nonzero_identical_methods!($wider);

#[inline]
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/net/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ macro_rules! bitop_impls {
)*) => {
$(
$(#[$attr])*
impl const $BitOpAssign for $ty {
const impl $BitOpAssign for $ty {
fn $bitop_assign(&mut self, rhs: $ty) {
let mut idx = 0;
while idx < self.octets.len() {
Expand All @@ -2479,14 +2479,14 @@ macro_rules! bitop_impls {
}

$(#[$attr])*
impl const $BitOpAssign<&'_ $ty> for $ty {
const impl $BitOpAssign<&'_ $ty> for $ty {
fn $bitop_assign(&mut self, rhs: &'_ $ty) {
self.$bitop_assign(*rhs);
}
}

$(#[$attr])*
impl const $BitOp for $ty {
const impl $BitOp for $ty {
type Output = $ty;

#[inline]
Expand All @@ -2497,7 +2497,7 @@ macro_rules! bitop_impls {
}

$(#[$attr])*
impl const $BitOp<&'_ $ty> for $ty {
const impl $BitOp<&'_ $ty> for $ty {
type Output = $ty;

#[inline]
Expand All @@ -2508,7 +2508,7 @@ macro_rules! bitop_impls {
}

$(#[$attr])*
impl const $BitOp<$ty> for &'_ $ty {
const impl $BitOp<$ty> for &'_ $ty {
type Output = $ty;

#[inline]
Expand All @@ -2520,7 +2520,7 @@ macro_rules! bitop_impls {
}

$(#[$attr])*
impl const $BitOp<&'_ $ty> for &'_ $ty {
const impl $BitOp<&'_ $ty> for &'_ $ty {
type Output = $ty;

#[inline]
Expand Down
Loading
Loading