rapx/analysis/api_dependency/graph/
std_tys.rs1use rustc_middle::ty::{self, Ty, TyCtxt};
2use rustc_span::sym;
3
4pub fn std_vec<'tcx>(element_ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option<Ty<'tcx>> {
5 let vec_def_id = tcx.get_diagnostic_item(sym::Vec)?;
6 let alloc_def_id = tcx.lang_items().global_alloc_ty()?;
7 let alloc_ty = tcx.type_of(alloc_def_id).skip_binder();
8 let args = tcx.mk_args(&[
9 ty::GenericArg::from(element_ty),
10 ty::GenericArg::from(alloc_ty),
11 ]);
12 Some(Ty::new_adt(tcx, tcx.adt_def(vec_def_id), args))
13}
14
15pub fn std_string<'tcx>(tcx: TyCtxt<'tcx>) -> Option<Ty<'tcx>> {
16 let string_def_id = tcx.lang_items().string()?;
17 Some(tcx.type_of(string_def_id).skip_binder())
18}