Skip to content

Commit 90bf4a1

Browse files
committed
wip2: remove the error of needing to implement unsizedconstparamty
1 parent d369c53 commit 90bf4a1

File tree

2 files changed

+4
-13
lines changed
  • compiler

2 files changed

+4
-13
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -819,17 +819,9 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
819819
let span = tcx.def_span(param.def_id);
820820
let def_id = param.def_id.expect_local();
821821

822-
if tcx.features().unsized_const_params() {
823-
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
824-
wfcx.register_bound(
825-
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),
826-
wfcx.param_env,
827-
ty,
828-
tcx.require_lang_item(LangItem::UnsizedConstParamTy, span),
829-
);
830-
Ok(())
831-
})
832-
} else if tcx.features().adt_const_params() {
822+
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
824+
// if the trait is implemented.
833825
enter_wf_checking_ctxt(tcx, tcx.local_parent(def_id), |wfcx| {
834826
wfcx.register_bound(
835827
ObligationCause::new(span, def_id, ObligationCauseCode::ConstParam(ty)),

compiler/rustc_trait_selection/src/traits/misc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
102102
lang_item: LangItem,
103103
parent_cause: ObligationCause<'tcx>,
104104
) -> Result<(), ConstParamTyImplementationError<'tcx>> {
105-
// FIXME: remove the unsizedconstparamty item
105+
// FIXME: core panics if remove unsizedconstparamty, figure out why
106106
assert_matches!(lang_item, LangItem::ConstParamTy | LangItem::UnsizedConstParamTy);
107107
let mut need_unstable_feature_bound = false;
108108

@@ -123,7 +123,6 @@ pub fn type_allowed_to_implement_const_param_ty<'tcx>(
123123
need_unstable_feature_bound = true;
124124
vec![Ty::new_slice(tcx, tcx.types.u8)]
125125
}
126-
127126
ty::Array(inner_ty, _) => vec![inner_ty],
128127

129128
// `str` morally acts like a newtype around `[u8]`

0 commit comments

Comments
 (0)