Skip to content

Commit e4eb54d

Browse files
authored
Rollup merge of #65263 - mbStavola:dedup-raw-item-fns, r=Centril
Deduplicate is_{freeze,copy,sized}_raw Fixes #65259 Deduplicates `is_{freeze,copy,sized}_raw` by delegating to a new method which takes in a `LangItem`.
2 parents 2403c37 + ee08114 commit e4eb54d

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/librustc/ty/util.rs

+12-21
Original file line numberDiff line numberDiff line change
@@ -1017,34 +1017,25 @@ impl<'tcx> ty::TyS<'tcx> {
10171017
}
10181018

10191019
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1020-
let (param_env, ty) = query.into_parts();
1021-
let trait_def_id = tcx.require_lang_item(lang_items::CopyTraitLangItem, None);
1022-
tcx.infer_ctxt()
1023-
.enter(|infcx| traits::type_known_to_meet_bound_modulo_regions(
1024-
&infcx,
1025-
param_env,
1026-
ty,
1027-
trait_def_id,
1028-
DUMMY_SP,
1029-
))
1020+
is_item_raw(tcx, query, lang_items::CopyTraitLangItem)
10301021
}
10311022

10321023
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1033-
let (param_env, ty) = query.into_parts();
1034-
let trait_def_id = tcx.require_lang_item(lang_items::SizedTraitLangItem, None);
1035-
tcx.infer_ctxt()
1036-
.enter(|infcx| traits::type_known_to_meet_bound_modulo_regions(
1037-
&infcx,
1038-
param_env,
1039-
ty,
1040-
trait_def_id,
1041-
DUMMY_SP,
1042-
))
1024+
is_item_raw(tcx, query, lang_items::SizedTraitLangItem)
1025+
10431026
}
10441027

10451028
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1029+
is_item_raw(tcx, query, lang_items::FreezeTraitLangItem)
1030+
}
1031+
1032+
fn is_item_raw<'tcx>(
1033+
tcx: TyCtxt<'tcx>,
1034+
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
1035+
item: lang_items::LangItem,
1036+
) -> bool {
10461037
let (param_env, ty) = query.into_parts();
1047-
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem, None);
1038+
let trait_def_id = tcx.require_lang_item(item, None);
10481039
tcx.infer_ctxt()
10491040
.enter(|infcx| traits::type_known_to_meet_bound_modulo_regions(
10501041
&infcx,

0 commit comments

Comments
 (0)