Skip to content

Commit 5cefaeb

Browse files
committed
wip3: Remove UnsizedConstParamTy related stuff
1 parent 1bc49ad commit 5cefaeb

File tree

8 files changed

+15
-82
lines changed

8 files changed

+15
-82
lines changed

compiler/rustc_builtin_macros/src/deriving/bounds.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,7 @@ pub(crate) fn expand_deriving_const_param_ty(
3939
) {
4040
let trait_def = TraitDef {
4141
span,
42-
path: path_std!(marker::ConstParamTy_),
43-
skip_path_as_bound: false,
44-
needs_copy_as_bound_if_packed: false,
45-
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
46-
supports_unions: false,
47-
methods: Vec::new(),
48-
associated_types: Vec::new(),
49-
is_const,
50-
is_staged_api_crate: cx.ecfg.features.staged_api(),
51-
};
52-
53-
trait_def.expand(cx, mitem, item, push);
54-
55-
let trait_def = TraitDef {
56-
span,
57-
path: path_std!(marker::UnsizedConstParamTy),
58-
skip_path_as_bound: false,
59-
needs_copy_as_bound_if_packed: false,
60-
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],
61-
supports_unions: false,
62-
methods: Vec::new(),
63-
associated_types: Vec::new(),
64-
is_const,
65-
is_staged_api_crate: cx.ecfg.features.staged_api(),
66-
};
67-
68-
trait_def.expand(cx, mitem, item, push);
69-
}
70-
71-
pub(crate) fn expand_deriving_unsized_const_param_ty(
72-
cx: &ExtCtxt<'_>,
73-
span: Span,
74-
mitem: &MetaItem,
75-
item: &Annotatable,
76-
push: &mut dyn FnMut(Annotatable),
77-
is_const: bool,
78-
) {
79-
let trait_def = TraitDef {
80-
span,
81-
path: path_std!(marker::UnsizedConstParamTy),
42+
path: path_std!(marker::ConstParamTy),
8243
skip_path_as_bound: false,
8344
needs_copy_as_bound_if_packed: false,
8445
additional_bounds: vec![ty::Ty::Path(path_std!(cmp::Eq))],

compiler/rustc_builtin_macros/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
129129
Clone: clone::expand_deriving_clone,
130130
Copy: bounds::expand_deriving_copy,
131131
ConstParamTy: bounds::expand_deriving_const_param_ty,
132-
UnsizedConstParamTy: bounds::expand_deriving_unsized_const_param_ty,
133132
Debug: debug::expand_deriving_debug,
134133
Default: default::expand_deriving_default,
135134
Eq: eq::expand_deriving_eq,

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
820820
let def_id = param.def_id.expect_local();
821821

822822
if tcx.features().adt_const_params() || tcx.features().unsized_const_params() {
823-
// TODO: should we get rid of the check for LangItem::ConstParamTy? If yes, how should we check
823+
// fixme: should we get rid of the check for LangItem::ConstParamTy? If yes, how should we check
824824
// if the trait is implemented.
825825
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
826826
wfcx.register_bound(

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ pub(super) fn check_trait<'tcx>(
4242
checker.check(lang_items.const_param_ty_trait(), |checker| {
4343
visit_implementation_of_const_param_ty(checker, LangItem::ConstParamTy)
4444
})?;
45-
checker.check(lang_items.unsized_const_param_ty_trait(), |checker| {
46-
visit_implementation_of_const_param_ty(checker, LangItem::UnsizedConstParamTy)
47-
})?;
4845
checker.check(lang_items.coerce_unsized_trait(), visit_implementation_of_coerce_unsized)?;
4946
checker
5047
.check(lang_items.dispatch_from_dyn_trait(), visit_implementation_of_dispatch_from_dyn)?;

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ symbols! {
207207
CoerceUnsized,
208208
Command,
209209
ConstParamTy,
210-
ConstParamTy_,
211210
Context,
212211
Continue,
213212
ControlFlow,

library/core/src/marker.rs

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,58 +1077,41 @@ pub trait Tuple {}
10771077
/// that all fields are also `ConstParamTy`, which implies that recursively, all fields
10781078
/// are `StructuralPartialEq`.
10791079
#[lang = "const_param_ty"]
1080-
#[unstable(feature = "unsized_const_params", issue = "95174")]
10811080
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
10821081
#[allow(multiple_supertrait_upcastable)]
10831082
// We name this differently than the derive macro so that the `adt_const_params` can
10841083
// be used independently of `unsized_const_params` without requiring a full path
10851084
// to the derive macro every time it is used. This should be renamed on stabilization.
1086-
pub trait ConstParamTy_: StructuralPartialEq + Eq {}
1085+
pub trait ConstParamTy: StructuralPartialEq + Eq {}
10871086

10881087
/// Derive macro generating an impl of the trait `ConstParamTy`.
10891088
#[rustc_builtin_macro]
1090-
#[allow_internal_unstable(unsized_const_params)]
1089+
#[allow_internal_unstable(unsized_const_params)] // todo: remove this?
10911090
#[unstable(feature = "adt_const_params", issue = "95174")]
10921091
pub macro ConstParamTy($item:item) {
10931092
/* compiler built-in */
10941093
}
10951094

1096-
#[lang = "unsized_const_param_ty"]
1097-
#[unstable(feature = "unsized_const_params", issue = "95174")]
1098-
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
1099-
/// A marker for types which can be used as types of `const` generic parameters.
1100-
///
1101-
/// Equivalent to [`ConstParamTy_`] except that this is used by
1102-
/// the `unsized_const_params` to allow for fake unstable impls.
1103-
pub trait UnsizedConstParamTy: StructuralPartialEq + Eq {}
1104-
1105-
/// Derive macro generating an impl of the trait `ConstParamTy`.
1106-
#[rustc_builtin_macro]
1107-
#[allow_internal_unstable(unsized_const_params)]
1108-
#[unstable(feature = "unsized_const_params", issue = "95174")]
1109-
pub macro UnsizedConstParamTy($item:item) {
1110-
/* compiler built-in */
1111-
}
1112-
11131095
// FIXME(adt_const_params): handle `ty::FnDef`/`ty::Closure`
11141096
marker_impls! {
11151097
#[unstable(feature = "adt_const_params", issue = "95174")]
1116-
ConstParamTy_ for
1098+
#[unstable_feature_bound(adt_const_params)]
1099+
ConstParamTy for
11171100
usize, u8, u16, u32, u64, u128,
11181101
isize, i8, i16, i32, i64, i128,
11191102
bool,
11201103
char,
11211104
(),
1122-
{T: ConstParamTy_, const N: usize} [T; N],
1105+
{T: ConstParamTy, const N: usize} [T; N],
11231106
}
11241107

11251108
marker_impls! {
11261109
#[unstable(feature = "unsized_const_params", issue = "95174")]
11271110
#[unstable_feature_bound(unsized_const_params)]
1128-
ConstParamTy_ for
1111+
ConstParamTy for
11291112
str,
1130-
{T: ConstParamTy_} [T],
1131-
{T: ConstParamTy_ + ?Sized} &T,
1113+
{T: ConstParamTy} [T],
1114+
{T: ConstParamTy + ?Sized} &T,
11321115
}
11331116

11341117
/// A common trait implemented by all function pointers.

library/core/src/mem/transmutability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::marker::ConstParamTy_;
1+
use crate::marker::ConstParamTy;
22

33
/// Marks that `Src` is transmutable into `Self`.
44
///
@@ -290,7 +290,7 @@ pub struct Assume {
290290

291291
#[unstable(feature = "transmutability", issue = "99571")]
292292
#[unstable_feature_bound(transmutability)]
293-
impl ConstParamTy_ for Assume {}
293+
impl ConstParamTy for Assume {}
294294

295295
impl Assume {
296296
/// With this, [`TransmuteFrom`] does not assume you have ensured any safety

library/core/src/tuple.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// See core/src/primitive_docs.rs for documentation.
22

33
use crate::cmp::Ordering::{self, *};
4-
use crate::marker::{ConstParamTy_, StructuralPartialEq, UnsizedConstParamTy};
4+
use crate::marker::{ConstParamTy, StructuralPartialEq};
55
use crate::ops::ControlFlow::{self, Break, Continue};
66

77
// Recursive macro for implementing n-ary tuple functions and operations
@@ -47,14 +47,8 @@ macro_rules! tuple_impls {
4747
maybe_tuple_doc! {
4848
$($T)+ @
4949
#[unstable(feature = "adt_const_params", issue = "95174")]
50-
impl<$($T: ConstParamTy_),+> ConstParamTy_ for ($($T,)+)
51-
{}
52-
}
53-
54-
maybe_tuple_doc! {
55-
$($T)+ @
56-
#[unstable(feature = "unsized_const_params", issue = "95174")]
57-
impl<$($T: UnsizedConstParamTy),+> UnsizedConstParamTy for ($($T,)+)
50+
#[unstable_feature_bound(adt_const_params)]
51+
impl<$($T: ConstParamTy),+> ConstParamTy for ($($T,)+)
5852
{}
5953
}
6054

0 commit comments

Comments
 (0)